CS3240 Chap 2
CS3240 Chap 2
CS3240 Chap 2
Language
Machine
Grammar
Regular
Finite
Automaton
Regular
Expression,
Regular Grammar
Context-Free
Pushdown
Automaton
Context-Free
Grammar
Recursively
Enumerable
Turing Machine
Unrestricted
Phrase-Structure
Grammar
CS 3240 - Introduction
2.1:
2.2:
An input alphabet
A transition function
CS 3240 - Finite Automata
Quintuple:
1)
A set of states, Q
2) An input alphabet,
3) A transition function, : Q x ->
Q
4) An initial state, q0
5) A set of final states, F Q
CS 3240 - Finite Automata
(q0,0) = q0
(q1,0) = q0
(q2,0) = q2
(q0,1) = q1
(q1,1) = q2
(q2,1) = q1
-q0
q0
q1
+q1
q0
q2
q2
q2
q1
What language is
this?
Strings
as
Strings
that end in ab
Strings
Strings
Each
Advantage:
Easy to code
Disadvantage:
Hard-codes the machine
CS 3240 - Finite Automata
10
Transition
array
See fa2.cpp
Advantage:
Even easier to code
Disadvantage:
Hard-codes the table
11
Transition
Advantage:
Can process any DFA
Disadvantage:
Hard to code in a static language
Not so bad in Python, etc.
12
Sometimes
What language is
this?
CS 3240 - Finite Automata
13
If
Think
14
Find
15
16
17
Build
Build
18
19
20
21
Consider
strings:
Construct a DFA where each state
Pretty easy
the last digit read determines the remainder
CS 3240 - Finite Automata
22
23
Design
24
same character
A Choice (multiple edges or even leave them out)
As
25
Note: no out-edges.
Not required in an
NFA.
Any subsequent
input
crashes the system.
26
It
They
can be converted to an
equivalent DFA!
Rabin-Scott algorithm
27
Quintuple:
1)
2)
3)
A set of states, Q
An input alphabet,
A transition function, : Q x ({})
-> 2Q
4) An initial state, q0
5) A set of final states, F Q
Note:
28
29
Strings
Strings
Strings
that contain aa
that contain aa or bb
that begin and end with the
same letter
(ab + aba)*
30
Start
Could be a composite
Out-going -transitions give a free ride!
See
simultaneously)
Repeat
31
The
lambda transition
When
32
a
0
{0,1,
2}
33
a
0
{0,1,
2}
{0,1, {0,1, 2
2}
2}
{1,2
}
34
a
0
{0,1,
2}
{0,1, {0,1, 2
2}
2}
{1,2
}
{1,2
}
{1,2
}
35
aa
-0 0
bb
{0,1,
{0,1,
2}
2}
+
{0,1, 2
{0,1,2 2}
}
{1,2
}
+2
+
{1,2}
{1,2
}
36
emerge
37
Well do this by
hand
CS 3240 - Finite Automata
38
NFAs
as well
Only
39
40
NFA
Sometimes
its easy to
remove/combine them by inspection
Sometimes its not!
There
is an algorithm to determine
whether states are distinguishable
CS 3240 - Finite Automata
41
42
43
44
Mark
45
46
q0
q1
q2
q3
q4
q0
q1
q2
q3
q4
CS 3240 - Finite Automata
47
indistinguishable
q0
q0
q1
q2
q3
q4
q1
q2
x
x
q3
x
x
q4
CS 3240 - Finite Automata
48
49
Minimize
50
What
51