Languages: Finite State Machines - PowerPoint PPT Presentation

1 / 25
About This Presentation
Title:

Languages: Finite State Machines

Description:

Chapter 6 Languages: Finite State Machines. 6.1 Language: The Set Theory of Strings : a nonempty finite ... A vending machine: 20c for cola (C), root beer(RB) ... – PowerPoint PPT presentation

Number of Views:88
Avg rating:3.0/5.0
Slides: 26
Provided by: rsch96
Category:

less

Transcript and Presenter's Notes

Title: Languages: Finite State Machines


1
Languages Finite State Machines
Chapter 6
problems
strings (languages)
answers
machines
2
Chapter 6 Languages Finite State Machines
6.1 Language The Set Theory of Strings
a nonempty finite set of symbols, collectively
called an alphabet.
0,1,2,11 or a,b bb is not considered as an
alphabet. That is, juxtaposition of symbols is
not included in an alphabet.
3
Chapter 6 Languages Finite State Machines
6.1 Language The Set Theory of Strings
4
Chapter 6 Languages Finite State Machines
6.1 Language The Set Theory of Strings
recognizer of L
yes, y in L
y
Lxnx01,n in N
no
5
Chapter 6 Languages Finite State Machines
6.1 Language The Set Theory of Strings
6
Chapter 6 Languages Finite State Machines
6.1 Language The Set Theory of Strings
7
Chapter 6 Languages Finite State Machines
6.1 Language The Set Theory of Strings
8
Chapter 6 Languages Finite State Machines
6.1 Language The Set Theory of Strings
9
Chapter 6 Languages Finite State Machines
6.1 Language The Set Theory of Strings
10
Chapter 6 Languages Finite State Machines
6.1 Language The Set Theory of Strings
11
Chapter 6 Languages Finite State Machines
6.1 Language The Set Theory of Strings
recursively defined sets
Which languages in the above examples are harder
to recognize?
12
Chapter 6 Languages Finite State Machines
6.1 Language The Set Theory of Strings
6.16
Which one is harder, xx or xxR? If xxR, x is
called a palindrome. (noon, madam, did,...)
13
Chapter 6 Languages Finite State Machines
6.2 Finite State Machines A First Encounter
A vending machine 20c for cola (C), root
beer(RB) and accepting 5c, 10c, and 25c, and
returning the necessary changes
Purchase root beer (white button)
Purchase cola (black button)
14
Chapter 6 Languages Finite State Machines
6.2 Finite State Machines A First Encounter
The major features of such a machine (1) in only
one of finitely many states at a given time
(state set S) (2) accept as input only a finite
number of symbols (input alphabet set
I) (3) state transition function depending on
input and current state (
is the next state function) (4) finite set of
output alphabet set O (optional) (
is the output function) (5)
deterministic (vs. nondeterministic)
15
Chapter 6 Languages Finite State Machines
6.2 Finite State Machines A First Encounter
(or use final states set F instead of O)
Ex. 6.17
1,0
0,0
start
0,0
1,0
s0
s1
s2
1,1
0,0
state transition table
state transition diagram
16
Chapter 6 Languages Finite State Machines
6.2 Finite State Machines A First Encounter
language Axx in 0,1 and has at least 1 0's
1,0
1
start
start
s0
s0
x
x
0,1 1,1
0 1
0,1
0
final state
s1
s1
x is in A if the output contains 1's.
x is in A if the machine stays at s1 when the
input is consumed.
17
Chapter 6 Languages Finite State Machines
6.2 Finite State Machines A First Encounter
Ex. 6.19 Design a 1-bit binary adder.
00,0 01,1 10,1
01,0 10,0 11,1
11,0
start
s0
s1
00,1
state to remember a carry
18
Chapter 6 Languages Finite State Machines
6.3 Finite State Machines A Second Encounter
sequence recognizer
Ex. 6.20 Construct a machine that recognizes each
occurrence of the sequence 111 as it is
encountered in any input string of 0,1. For
example, input 1110101111, the output should be
0010000011.
1,1
a minimal machine (3 states)
1,1
0,0
1,0
1,1
1,0
start
s0
s2
s3
s1
0,0
0,0
0,0
19
Chapter 6 Languages Finite State Machines
6.3 Finite State Machines A Second Encounter
Ex. 6.21 recognize the occurrences of 111 that
end in a position that is a multiple of three.
(input 1110111, output 0010000)
1,1
0,0
1,0
1,0
start
s0
s1
s2
0,0
0,0
used to consume extra symbols before counting
0,0 1,0
s4
s3
0,0 1,0
20
Chapter 6 Languages Finite State Machines
6.3 Finite State Machines A Second Encounter
Ex. 6.23 Languages that cannot be recognized by a
finite state machine. A0i1ii is a positive
integer
Assume there is a FSM that recognizes A with n
states.
start
s0 s1 s2 ... si ...
sj ... sn-1
by the pigeonhole principle, this cycle must exist
transition for x 0n1n
If x is recognized, then 0n-(j-i1)1n would also
be recognized. Therefore, such FSM cannot exist.
21
Chapter 6 Languages Finite State Machines
6.3 Finite State Machines A Second Encounter
k-unit delay machines
Ex. 6.25 1-unit delay machine
0,0
0,0
remembering 0
s1
start
s0
1,0
0,1
1,0
s2
1,1
remembering 1
22
Chapter 6 Languages Finite State Machines
6.3 Finite State Machines A Second Encounter
Ex. 6.25 2-unit delay machine
start
s0
1,0
0,0
s1
s2
1,0
1,0
0,0
0,0
0,0
0,0
1,1
1,0
0,1
s3
s4
s5
s6
1,1
1,0
0,1
23
Chapter 6 Languages Finite State Machines
6.3 Finite State Machines A Second Encounter
Def. 6.14 (a) reachable v(si,x)sj (b) transient
state v(s,x)s implies x , s2 is the only
transient state.
(c) sink state v(s,x)s for all x s3 is the
only sink (d) submachine (e) strongly connected
for any si,sj, si is reachable from sj
s0
0,1
0,0
1,0
0,1
1,1
s1
s4
s5
s2
1,1
1,1
1,1 0,0
0,1
0,1
0,0
s3
s7
s6
1,0
a strongly connected submachine
1,0 0,0
1,1
24
Chapter 6 Languages Finite State Machines
6.3 Finite State Machines A Second Encounter
Ex. 6.26
v w
Find a transfer sequence from s0 to s2.
0 1 0 1
0
1
s0 s6 s1 0 1 s1 s5 s0
0 1 s2 s1 s2 0 1 s3
s4 s0 0 1 s4 s2 s1 0 1 s5
s3 s5 0 1 s6 s3 s6 0
1
s0
s6
s1
0
1
0
1
s5
s3
s0
s6
1
1
0
0
s0
s5
s3
s4
1
0
s1
s2
25
Chapter 6 Languages Finite State Machines
Exercise P291 16 P298 6
P305 4,6
Write a Comment
User Comments (0)
About PowerShow.com