Finite Automata
Finite Automata
Finite Automata
Motivation An Example
Informal Explanation
Finite automata are finite collections of states with transition rules that take you from one state to another. Original application was sequential switching circuits, where the state was the settings of internal bits. Today, several kinds of software can be modeled by FA.
2
Representing FA
Simplest representation is often a graph.
Nodes = states. Arcs indicate state transitions. Labels on arcs tell what causes the transition.
i n
Saw in
nothing Start
Saw i
Saw ing
Automata to Code
In C/C++, make a piece of code for each state. This code:
1. Reads the next input. 2. Decides on the next state. 3. Jumps to the beginning of the code for that state.
Extended Example
Thanks to Jay Misra for this example. On a distant planet, there are three species, a, b, and c. Any two different species can mate. If they do:
1. The participants die. 2. Two children of the third species are born.
9
11
Questions (2)
These questions mirror real ones about protocols.
Can the planet fail? is like asking whether a protocol can enter some undesired or error state. Must the planet fail is like asking whether a protocol is guaranteed to terminate.
Here, failure is really the good condition of termination.
12
13
Notice: four states are must-fail states. The others are cant-fail states. State 111 has several transitions.
15
Notice: states 400, etc. are must-fail states. All other states are might-fail states.
16
17
The Cases 2, 3, 4
110 x 200 111 x 300 x 211 x 310 x 210 x Notice: for the case n = 4, there is nondeterminism : different transitions are possible from 211 on the same input. 18 220 x 400
5 Individuals
500 410 221
320
311
6 Individuals
600 510 420 411 330 222
321
Notice: 600 is a must-fail state; 510, 420, and 321 are cant-fail states; 411, 330, and 222 are might-fail states.
20
7 Individuals
700 610 322 331
421
22