Title: A1262292114lCUpY
12.2 Fiction Finite State Automata
A fiction finite state automaton M consists of an
input tape, a tape read head and a control unit
as follows
input tape
read head
Q
F
control unit
?
Reset
?
Set
Start
Current state
2By pressing the reset button, we can either reset
an alphabet ?, the set Q of states of the
automaton, the set F of final states, or the
transition function ?, or supply a new input on
the input tape. The state q 0 is the unique
initial state in the control unit.
By pressing the set button, the tape read head
moves to the leftmost cell of the tape. And the
current state is set to the initial state q 0.
The input to the machine M are set up manually,
and the symbols on the tape are over the alphabet
? except the one after the end of the input which
is a blank denoted by the letter B ? ?.
By pressing the start button, the machine M
starts to scan cells of the input tape from left
to right one after another, and never moves back.
Each move, based on the the current state and
the current scanned input symbol, the machine M
enters a new state according to the transition
function ?, and the read head moves one cell to
the right.
3The transition function ? is a function ? Q ??
? Q.
The machine M continues the process until it
reads the last input symbol and stops at the
blank cell. If the machine enters a final state
after reading the input, then the accept bulb
will be lit up. In this case, we say that the
machine accepts the input. Otherwise, the reject
bulb is lit up instead, and the machine rejects
the input.
Consider the above case, where
?
? 0, 1
Q q 0, q 1 , q 2, q 3
F q 0
? Q ?? ? Q
4We may simplify the above machine M as follows.
input tape
finite control
The input is 0110. The initial state is q0.
The moves of the automaton M are shown as follows.
5The machine M accepts the input 0110.
6In case the input is 011. Each move of the
machine M is shown as follows and the machine M
will reject the input.
reject
7Definition 1 The set of strings accepted by a
finite state automaton M is denoted by L(M).
The set of strings over the alphabet ? 0, 1
accepted by the above finite state automaton M is
the set of strings containing even number of 0s
and even number of 1s. We have that L(M) ? ?
? the number of 0s and the number of 1s in ?
are both even.
The most important part of a finite state
automaton is the transition function ? of the
machine. If we can show the transition function
?, automatically we can show the machine right a
way.
Therefore, we can use transition diagram of the
transition function ? as a representative of a
finite state automaton.
8The transition diagram of the above finite state
automaton M is shown as follows.
The initial state is pointed by the start arrow.
A final state is doubly circled.
An input symbol is on a directed edge of the
transition diagram.
q 0 stands for even 0s and even 1s
q 1 stands for odd 0s and even 1s
q 2 stands for even 0s and odd 1s
q 3 stands for odd 0s and odd 1s
9For the input 0110, each move of the machine is
as follows.
10The instantaneous description of each move of a
finite state automaton can be denoted by a string
of the input associated with the current state to
the left of the symbol being scanned.
The instantaneous descriptions of the following
two instances of the finite state automaton are q
00110 and 0q 1110 .
For a move of the machine ?(q 0, 0) q 1 , we can
show the change of the instantaneous descriptions
by the notation q00110 0q 1110. The notation
is read as q 00110 yields 0q1110 .
11For the moves of the machine M with input 0110,
the change of the instantaneous descriptions can
be listed as follows .
0110 q 0
q 0 0110
0q 1110
01q 310
--
--
--
011q 10
--
The binary relation -- can be extended to the
relation -- as the reflexive and transitive
closure of the relation -- .
The relation -- can also be defined by the
following
(1) ?q ? -- ?q ? , for any ? and ? ? ?. In
this case it means that there is no move at all.
(2) If ?q 1 ? -- ? ? q 2 and ?(q 2 , a) q 3 ,
then we have that ?q 1 ?a -- ? ?a q 3. In this
case, it means that there are either 1 or more
moves changed from ?q 1 ?a to ??aq3.
12By the definition of the relation --, the
following moves
can be written as
Definition 2 Therefore, we can define the
language or the set accepted by a finite state
automaton M by L(M) ? ? ? q 0 ? -- ? p,
where p ? F .
13Properties of Finite State Automata
The read head can move only one way from left to
right.
The input tape can not be written, or we can not
change its contents, during a computation after
the start button is pressed.
Basically, there is no storage to store what the
machine reads from the input.
A finite state automaton is a program that can
recognize a kind of inputs.
14A C program that can recognize inputs containing
even number of 0s and even number of 1s and
nothing else.
main()
char c
int count00, count10//storage used
while((cgetchar())! )
if(c0)count0
else if(c1)count1
elseprintf(No)return
if(count020count120)
printf(Yes)
else printf(No)
15main()
char c //no extra storage used
q0 cgetchar() if(c0)goto q1
else if(c1) goto q2
else if(c )printf(Yes)return
elseprintf(No)return
q1 cgetchar() if(c0)goto q0
else if(c1) goto q3
elseprintf(No)return
q2 cgetchar() if(c0)goto q3
else if(c1) goto q0
elseprintf(No)return
q3 cgetchar() if(c0)goto q2
else if(c1) goto q1
elseprintf(No)return
16char delta(char state, char c)
if((state0)(c0)) return 1
else if((state0)(c1)) return 2
else if((state1)(c0)) return 0
else if((state1)(c1)) return 3
else if((state2)(c0)) return 3
else if((state2)(c1)) return 0
else if((state3)(c0)) return 2
else if((state3)(c1)) return 1
else printf(No) exit(1)
main()
char c, currentState //no extra storage
currentState0
while((cgetchar())! )
currentStatedelta(currentState, c)
if(currentState0) printf(Yes)
else printf(No)