2.3 Formal Definition of Finite State Automata - PowerPoint PPT Presentation

1 / 19
About This Presentation
Title:

2.3 Formal Definition of Finite State Automata

Description:

is a finite set alphabet, Q is a finite set of states, : Q Q is a transition ... 3 with input 0. The input symbol 0 appending to the end of the string 010 forms ... – PowerPoint PPT presentation

Number of Views:55
Avg rating:3.0/5.0
Slides: 20
Provided by: jim87
Category:

less

Transcript and Presenter's Notes

Title: 2.3 Formal Definition of Finite State Automata


1
2.3 Formal Definition of Finite State Automata
Definition 3 A finite state automaton(FA) M
(?, Q, ?, q 0, F), where
? is a finite set alphabet,
Q is a finite set of states,
? Q ? ? ? Q is a transition function,
q 0 ? Q is the initial state,
F ? Q is the set of final states.
Note A finite state automaton (FA) M defined
above is a deterministic finite state automaton
(DFA), since each move of the machine is uniquely
determined.
2
Example A finite state automaton M 1 (?, Q, ?
1, q 0, F), where
? 0, 1,
Q q 0, q 1, q 2 , q t ,
q 0 ? Q is the initial state,
F q 1, q 2,
? 1 Q ? ? ? Q is defined as below.
3
The state q t is a trap state in the machine M 1.
For simplicity, we can ignore the trap state.
Then the transition function and transition
diagram of M 1 becomes as follows.
In this case, the machine accepts the strings
over 0, 1 interpreted as numbers in binary.
4
An FA M (?, Q, ?, q 0, F), extend the
transition function ? Q ? ? ? Q to a function
? Q ? ? ? Q defined by
(1) ?(q, ?) q, and
(2) ?(q, ?a) ? (? (q, ?), a), for all string
? and a ? ?.
Note ?(q, ?) p means after reading ? an FA M
changes from state q to p. It may include 0, 1or
more moves.
Example ? 1(q 0, 1010) q 2
? 1(q 0, 1010) ? 1 (? 1(q 0, 101) , 0) ?
1(? 1( ? 1(q 0, 10), 1) , 0)
? 1(? 1(? 1( ? 1(q 0, 1), 0), 1) , 0)
? 1(? 1(? 1(? 1( ? 1(q 0, ?), 1), 0), 1) , 0)
? 1(? 1(? 1(? 1(q 0, 1), 0), 1) , 0) ? 1(?
1(? 1(q 2, 0), 1) , 0)
? 1(? 1(q 2, 1) , 0) ? 1(q 2 , 0) q 2
5
Definition 4 The set L accepted by an FA M
(?, Q, ?, q 0, F) can be defined as L L(M) ?
? ? ?(q 0, ?) ? F.
Definition 2 and definition 4 are equivalent,
since ?(q 0, ?) q ? F is same as q 0 ?-- ?q .
Definition 5 A language L over an alphabet ?
is said to be regular if there is an FA M (?,
Q, ?, q 0, F) that accepts L.
Example The set of strings over 0, 1
interpreted as numbers in binary is a regular
language.
Example The set of strings over 0, 1 those
have even number of 0s and even number of 1s is
regular.
6
Example Design an FA M to accept strings over
0, 1, and while the strings interpreted as
binary numbers they all are congruent to 1 mod 3.
Solution The most important part to design an
FA M is to design the transition diagram of the
FA. In this case, the state q n of the machine
can be classified as ?? n mod 3 for some n, i.e,
after reading ? the machine enters the state q n.
The strings 100, 1101, 110100 are accepted by the
machine, since 100 ? 1101 ? 110100 ? 1 mod 3.
7
The way to design an FA M is similar to design a
program. But the expressive methods are
different, so are the processes.
To design an FA M, usually we first to connect
the initial state to a final state. Next, add
states and connect those states with the required
input symbols.
Example Design an FA M to accept strings over
0, 1 ending with the substring 010.
Solution Step 1 construct states from the
initial state to a final state with the input
string 010 as follows.
8
Step 2 Consider the initial state q 0 with
input 1. The input symbol 1 does not help to
form a string of 010. Hence, we let it repeat
again back to state q 0.
Step 3 Consider the state q 1 with input 0.
The input symbol 0 does not affect the ending
string 010. Hence, we let it repeat again back
to state q 1.
9
Step 4 Consider the state q 2 with input 1.
The input symbol 1 breaks up the ending string
010. Hence, we have to connect the state q 2
back to state q 0 in order to start to form an
ending string 010.
10
Step 5 Consider the state q 3 with input 0.
The input symbol 0 appending to the end of the
string 010 forms a new string 0100. We only need
to add two more symbols 10 to get a string ending
with 010. Hence, we need connect the state q 3
back to state q 1.
11
Step 6 Consider the state q 3 with input 1.
The input symbol 1 appending to the end of the
string 010 forms a new string 0101. We only need
to add one more symbol 0, and we can get a string
ending with 010. Hence, we need connect the
state q 3 back to state q 2.
12
Example Design an FA M to accept strings over
0, 1 such that the 2nd symbol from the right
end of the strings is 0.
Solution Step 1 construct states from the
initial state to a final state with the input
string 00 as follows.
Step 2 At the state q 0, repeating the symbol 1
does not affect the result. The state q 0 is
done. At the state q 2, repeating the symbol 0
the strings must be accepted by the machine.
Hence, it goes to the same state q 2.
13
Step 3 At the state q 1, reading the symbol 1
the machine must enter a new final state q 3.
And the state q 1 is done.
Step 4 At the state q 2, reading the symbol 1
the machine must enter a new final state q 4.
And the state q 2 is done.
14
Step 5 At the state q 3, reading the symbol 0
the machine must enter the state q 1. In this
case, the state q 3 is quite similar to the state
q 0.
Step 6 At the state q 3, reading the symbol 1
the machine must enter the state q 0 because of 2
consecutive 1s. The state q 3 is done.
15
Step 7 At the state q 4, reading the symbol 0
the machine must enter the state q 1. In this
case, the state q 4 is equivalent to the state q
3.
Step 8 Now we can drop out the state q 4, and
change ?(q 2, 1) q3.
16
Example Design an FA M to accept strings over
0, 1 so that each 3 consecutive symbols in a
string containing at least 2 0s.
Solution There could be many states in the
machine. It may require a large piece of paper
to draw the transition diagram of the machine.
In stead of drawing the transition diagram of the
machine, it is sufficient to describe the
transition function as follows.
Let Q q ? ?q a a 0 or 1? q ab a, b
0 or 1 ? q abc a, b, c 0 or 1
The initial state is q ?.
17
The transition function ? has the following
properties
(1) ?(q ?, a) q a, for a 0 or 1,
(2) ?(q a, b) q ab, for a, b 0 or 1,
(3) ?(q ab, c) q abc, for a, b, c 0 or 1,
(4) ?(q abc, d) q abc, for a, b, c, d 0 or 1,
and abc gt 1
(5) ?(q abc, d) q bcd, for a, b, c, d 0 or 1,
and abc lt 2
Final states are of the form q abc , where a, b,
c 0 or 1 and at least two of a, b and c are
0s.
18
Example Design an FA M to accept strings over
0, 1 so that the evaluation of the string ?
according to the following operation is same as
the evaluation of ? R.
The operation is not associative. Hence the way
to evaluate from left to right may be different
from that to evaluate from right to left.
The evaluation of the string 1000 100 10 1.
The evaluation of the string 1000 R 0001 001
01 0.
The string 1000 is not accepted by M.
19
The evaluation of the string 1100 000 00 0.
The evaluation of the string 1100 R 0011 011
01 0.
The string 1100 is accepted by M.
This problem is not easy to handle, since we have
to consider two different ways to evaluate the
same string. We list the solution first, and
leave the constructive method later until we
reach section 2.4 nondeterministic FA.
Solution
Write a Comment
User Comments (0)
About PowerShow.com