Professional Documents
Culture Documents
We represent the machine M = (S, I, O, f, g, ) Example : We describe a nite state machine with two input symbols I = {a, b} and two output symbols O = {0, 1} that accepts any string from I and outputs as many 1s as as there are at the beginning of the string, then it outputs only 0s. The internal states are S = {0 , 1 }, where 0 is the initial statewe interpret it as not having seeing any b yet; then the machine will switch to 1 as soon as the rst b arrives. The next-state and output functions are as follows: f I S 0 1 a b g a b
0 1 1 0 1 1 0 0
133
134
This nite-state machine also can be represented with the following transition diagram :
a/1 a/0
start
b/0
The vertices of the diagram are the states. If in state an input i causes the machine to output o and go to state then we draw an arrow from to labeled i/o or i, o. Example : The following example is similar to the previous one but the machine outputs 1 only after a change of input symbol, otherwise it outputs 0:
@ABC / GFED 0 BB | BB b/0 | a/0 || BB | BB || B | b/ 1 | ~ , GFED @ABC @ABC 3 GFED 1 m 2 k
start
a/0
a/1
b/0
Example : A Serial-Adder. A serial adder accepts two bits and outputs its sum. So the input set is I = {00, 01, 10, 11}. The output set is O = {0, 1}. The set of states is S = {N C, C }, which stands for no carry and carry respectively. The transition diagram is the following:
00/0 01/1 01/0 10/0
start
10.1.2. Finite-State Automata. A nite-state automaton is similar to a nite-state machine but with no output, and with a set of states called accepting or nal states. More specically, nite-state automaton consists of: 1. A nite set of states S. 2. A nite set of input symbols I. 3. A next-state or transition function f : S I S.
135
4. An initial state S. 5. A subset F S of accepting or nal states. We represent the automaton A = (S, I, f, , F). We say that an automaton accepts or recognizes a given string of input symbols if that strings takes the automaton from the start state to a nal state. Example : The following transition diagrams represent an automaton accepting any string of as and bs ending with an a. The rst diagram uses the same scheme as with nite-state machines, with 1 representing accept or recognize, and 0 representing not accept:
b/0 a/1
start
The second kind of diagram omits the outputs and represents the accepting states with double circles:
b a
start
Two nite-state automata that accept exactly the same set of strings are said to be equivalent. For instance the following automaton also accepts precisely strings of as abd bs that end with an a, so it is equivalent to the automaton shown above:
b a a
start
Example : The following automaton accepts strings of as and bs with exactly an even number of as:
136
start
Example : The following automaton accepts strings starting with one a followed by any number of bs:
b a a
start
@ABC / GFED 0
@ABC / GFED 2 g D
start
@ABC / GFED 0 R
@ABC / GFED 1 F Z
a
@ABC / GFED 2 l
a
a b