flat
DESCRIPTION
TRANSCRIPT
![Page 1: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/1.jpg)
1
Theory of Automata &
Formal Languages
![Page 2: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/2.jpg)
2
BOOKS
Theory of computer Science: K.L.P.Mishra &
N.Chandrasekharan
Intro to Automata theory, Formal languages and computation: Ullman,Hopcroft
Motwani
Elements of theory of computation Lewis & papadimitrou
![Page 3: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/3.jpg)
3
Syllabus
Introduction
Deterministic and non deterministic Finite Automata, Regular Expression,Two way finite automata,Finite automata with output,properties of regular sets,pumping lemma, closure properties,Myhill nerode theorem
![Page 4: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/4.jpg)
4
Context free Grammar: Derivation trees, Simplification forms
Pushdown automata: Def, Relationship between PDA and context free language,Properties, decision algorithms
Turing Machines: Turing machine model,Modification of turing machines,Church’s thesis,Undecidability,Recursive and recursively enumerable languages Post correspondence problems recursive functions
![Page 5: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/5.jpg)
5
Chomsky Hierarchy: Regular grammars, unrestricted grammar, context sensitive language, relationship among languages
![Page 6: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/6.jpg)
6
CPU
input memory
output memory
Program memory
temporary memory
![Page 7: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/7.jpg)
7
CPU
input memory
output memoryProgram memory
temporary memory3)( xxf
compute xx
compute xx 2
2x
42*2 z82*)( zxf
![Page 8: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/8.jpg)
8
Automaton
CPU
input memory
output memory
Program memory
temporary memory
Automaton
![Page 9: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/9.jpg)
9
input memory
output memory
temporary memory
Finite
Automaton
![Page 10: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/10.jpg)
10
Different Kinds of Automata
Automata are distinguished by the temporary memory
• Finite Automata: no temporary memory
• Pushdown Automata: stack
• Turing Machines: random access memory
![Page 11: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/11.jpg)
11
input memory
output memory
Stack
Pushdown
Automaton
Pushdown Automaton
Programming Languages (medium computing power)
Push, Pop
![Page 12: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/12.jpg)
12
input memory
output memory
Random Access Memory
Turing
Machine
Turing Machine
Algorithms (highest computing power)
![Page 13: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/13.jpg)
13
Finite
Automata
Pushdown
Automata
Turing
Machine
Power of Automata
![Page 14: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/14.jpg)
14
Power sets
A power set is a set of sets
Powerset of S = the set of all the subsets of S
S = { a, b, c }
2S = { , {a}, {b}, {c}, {a, b}, {a, c}, {b, c}, {a, b, c} }
Observation: | 2S | = 2|S| ( 8 = 23 )
![Page 15: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/15.jpg)
15
Cartesian ProductA = { 2, 4 } B = { 2, 3, 5 }
A X B = { (2, 2), (2, 3), (2, 5), ( 4, 2), (4, 3), (4, 4) }
|A X B| = |A| |B|
Generalizes to more than two sets
A X B X … X Z
![Page 16: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/16.jpg)
16
RELATIONS R = {(x1, y1), (x2, y2), (x3, y3), …}
xi R yi
e. g. if R = ‘>’: 2 > 1, 3 > 2, 3 > 1
In relations xi can be repeated
![Page 17: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/17.jpg)
17
Equivalence Relations
• Reflexive: x R x
• Symmetric: x R y y R x
• Transitive: x R Y and y R z x R z
Example: R = ‘=‘
• x = x
• x = y y = x
• x = y and y = z x = z
![Page 18: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/18.jpg)
18
Equivalence ClassesFor equivalence relation R
equivalence class of x = {y : x R y}
Example:
R = { (1, 1), (2, 2), (1, 2), (2, 1),
(3, 3), (4, 4), (3, 4), (4, 3) }
Equivalence class of 1 = {1, 2}
Equivalence class of 3 = {3, 4}
![Page 19: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/19.jpg)
19
Example of Equivalence relationLet Z = set of integers
R be defined on it as:
R= {(x,y)| x Z, y Z and
(x - y)is divisible by 5}
This relation is known as
” congruent modulo 5”
![Page 20: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/20.jpg)
20
The equivalence classes are
[0]R= {…-10, -5, 0, 5,10,…}
[1]R = {…..,-9, -4, 1, 6, 11, 16….}
[2]R= {….-8, -3,2,7,12,17…..}
[3]R = {….-7, -2, 3, 8 ,13,…}
[4]R = {….-6,-1,4,9,14,19,….}
Z/R ={[0]R, [1]R, [2]R, [3]R, [4]R}
![Page 21: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/21.jpg)
21
PROOF TECHNIQUES
• Proof by induction
• Proof by contradiction
![Page 22: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/22.jpg)
22
Induction
We have statements P1, P2, P3, …
If we know
• for some k that P1, P2, …, Pk are true
• for any n >= k that
P1, P2, …, Pn imply Pn+1
Then
Every Pi is true
![Page 23: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/23.jpg)
23
Treesroot
leaf
parent
child
Trees have no cycles
![Page 24: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/24.jpg)
24
Proof by Induction• Inductive basis
Find P1, P2, …, Pk which are true
• Inductive hypothesis
Let’s assume P1, P2, …, Pn are true,
for any n >= k
• Inductive step
Show that Pn+1 is true
![Page 25: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/25.jpg)
25
root
leaf
Level 0
Level 1
Level 2
Level 3
Height 3
![Page 26: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/26.jpg)
26
Binary Trees
![Page 27: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/27.jpg)
27
Example
Theorem: A binary tree of height n
has at most 2n leaves.
Proof:
let l(i) be the number of leaves at level i
l(0) = 0
l(3) = 8
![Page 28: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/28.jpg)
28
Induction Step
hypothesis: l(n) <= 2n
Level
n
n+1
![Page 29: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/29.jpg)
29
We want to show: l(i) <= 2i
• Inductive basis
l(0) = 1 (the root node)
• Inductive hypothesis
Let’s assume l(i) <= 2i for all i = 0, 1, …, n
• Induction step
we need to show that l(n + 1) <= 2n+1
![Page 30: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/30.jpg)
30
hypothesis: l(n) <= 2n
Level
n
n+1
l(n+1) <= 2 * l(n) <= 2 * 2n = 2n+1
Induction Step
![Page 31: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/31.jpg)
31
Proof by Contradiction
We want to prove that a statement P is true
• we assume that P is false
• then we arrive at an incorrect conclusion
• therefore, statement P must be true
![Page 32: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/32.jpg)
32
Example
Theorem: is not rational
Proof:
Assume by contradiction that it is rational
= n/m
n and m have no common factors
We will show that this is impossible
2
2
![Page 33: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/33.jpg)
33
= n/m 2 m2 = n2
Therefore, n2 is evenn is even
n = 2 k
2 m2 = 4k2 m2 = 2k2m is even
m = 2 p
Thus, m and n have common factor 2
Contradiction!
2
![Page 34: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/34.jpg)
34
Basic Terms
Alphabet: A finite non empty set of elements.
={a,b,c,d,…z}
![Page 35: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/35.jpg)
35
• String: A sequence of letters
– Examples: “cat”, “dog”, “house”, …
– Defined over an alphabet:
zcba ,,,,
Language: It is a set of strings on some alphabet
![Page 36: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/36.jpg)
36
Alphabets and Strings
• We will use small alphabets:
• Strings
abbaw
bbbaaav
abu
ba,
baaabbbaaba
baba
abba
ab
a
![Page 37: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/37.jpg)
37
String Operations
m
n
bbbv
aaaw
21
21
bbbaaa
abba
mn bbbaaawv 2121
Concatenation
abbabbbaaa
![Page 38: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/38.jpg)
38
12aaaw nR
naaaw 21 ababaaabbb
Reverse
bbbaaababa
![Page 39: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/39.jpg)
39
String Length
• Length:
• Examples:
naaaw 21
nw
1
2
4
a
aa
abba
![Page 40: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/40.jpg)
40
Recursive Definition of Length
For any letter:
For any string :
Example:
1a
1wwawa
4
1111
111
11
1
a
ab
abbabba
![Page 41: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/41.jpg)
41
Length of Concatenation
• Example:
vuuv
853
8
5,
3,
vuuv
aababaabuv
vabaabv
uaabu
![Page 42: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/42.jpg)
42
Proof of Concatenation Length
• Claim:
• Proof: By induction on the length
– Induction basis:– From definition of length:
vuuv v
1v
vuuuv 1
![Page 43: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/43.jpg)
43
– Inductive hypothesis:
• for
– Inductive step: we will prove–
– for
vuuv
nv ,,2,1
1nv
vuuv
![Page 44: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/44.jpg)
44
Inductive Step
• Write , where
• From definition of length:
• From inductive hypothesis:
• Thus:
wav 1, anw
1
1
wwa
uwuwauv
wuuw
vuwauwuuv 1
![Page 45: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/45.jpg)
45
Empty String
• A string with no letters:
• Observations:
abbaabbaabba
www
0
![Page 46: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/46.jpg)
46
Substring
• Substring of string:
– a subsequence of consecutive characters
• String Substring
bbab
b
abba
ab
abbab
abbab
abbab
abbab
![Page 47: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/47.jpg)
47
Prefix and Suffix
• Prefixes Suffixes abbab
abbab
abba
abb
ab
a
b
ab
bab
bbab
abbabuvw
prefix
suffix
![Page 48: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/48.jpg)
48
Another Operation
• Example:
• Definition:–
n
n wwww
abbaabbaabba 2
0w
0abba
![Page 49: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/49.jpg)
49
The * Operation
• : the set of all possible strings from• alphabet
•
*
,,,,,,,,,*
,
aabaaabbbaabaaba
ba
![Page 50: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/50.jpg)
50
The + Operation : the set of all possible strings from alphabet except
,,,,,,,,,*
,
aabaaabbbaabaaba
ba
*
,,,,,,,, aabaaabbbaabaaba
![Page 51: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/51.jpg)
51
Language
• A language is any subset of
• Example:
• Languages:
*
,,,,,,,,*
,
aaabbbaabaaba
ba
},,,,,{
,,
aaaaaaabaababaabba
aabaaa
![Page 52: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/52.jpg)
52
Another Example
• An infinite language
}0:{ nbaL nn
aaaaabbbbb
aabb
ab
L Labb
![Page 53: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/53.jpg)
53
Operations on Languages
• The usual set operations
• Complement:
aaaaaabbbaaaaaba
ababbbaaaaaba
aaaabbabaabbbaaaaaba
,,,,
}{,,,
},,,{,,,
LL * ,,,,,,, aaabbabaabbaa
![Page 54: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/54.jpg)
54
Reverse
• Definition:
• Examples:
}:{ LwwL RR
ababbaabababaaabab R ,,,,
}0:{
}0:{
nabL
nbaL
nnR
nn
![Page 55: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/55.jpg)
55
Concatenation
• Definition:
• Example:
2121 ,: LyLxxyLL
baaabababaaabbaaaab
aabbaaba
,,,,,
,,,
![Page 56: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/56.jpg)
56
Another Operation
• Definition:
• Special case:
n
n LLLL
bbbbbababbaaabbabaaabaaa
babababa
,,,,,,,
,,,, 3
0
0
,, aaabbaa
L
![Page 57: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/57.jpg)
57
More Examples
• }0:{ nbaL nn
}0,:{2 mnbabaL mmnn
2Laabbaaabbb
![Page 58: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/58.jpg)
58
Star-Closure (Kleene *)
• Definition:
• Example:
•
210* LLLL
,,,,
,,,,
,,
,
*,
abbbbabbaaabbaaa
bbbbbbaabbaa
bbabba
![Page 59: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/59.jpg)
59
Positive Closure
• Definition:
*
21
L
LLL
,,,,
,,,,
,,
,
abbbbabbaaabbaaa
bbbbbbaabbaa
bba
bba
![Page 60: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/60.jpg)
60
Finite AutomatonInput
String
•
Output
String
FiniteAutomaton
![Page 61: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/61.jpg)
61
Finite Accepter
•
Input
“Accept” or“Reject”
String
FiniteAutomaton
Output
![Page 62: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/62.jpg)
62
Transition Graph
•
initialstate
final state“accept”state
transition
Abba -Finite Accepter
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
![Page 63: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/63.jpg)
63
Initial Configuration
•
1q 2q 3q 4qa b b a
5q
a a bb
ba,
Input Stringa b b a
ba,
0q
![Page 64: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/64.jpg)
64
Reading the Input
•
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b b a
ba,
![Page 65: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/65.jpg)
65
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b b a
ba,
![Page 66: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/66.jpg)
66
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b b a
ba,
![Page 67: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/67.jpg)
67
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b b a
ba,
![Page 68: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/68.jpg)
68
0q 1q 2q 3q 4qa b b a
Output: “accept”
5q
a a bb
ba,
a b b a
ba,
Input finished
![Page 69: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/69.jpg)
69
Rejection
•
1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b a
ba,
0q
![Page 70: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/70.jpg)
70
•
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b a
ba,
![Page 71: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/71.jpg)
71
•
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b a
ba,
![Page 72: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/72.jpg)
72
•
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b a
ba,
![Page 73: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/73.jpg)
73
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
Output:“reject”
a b a
ba,
Input finished
![Page 74: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/74.jpg)
74
Another Example
a
b ba,
ba,
0q 1q 2q
a ba
![Page 75: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/75.jpg)
75
a
b ba,
ba,
0q 1q 2q
a ba
![Page 76: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/76.jpg)
76
a
b ba,
ba,
0q 1q 2q
a ba
![Page 77: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/77.jpg)
77
a
b ba,
ba,
0q 1q 2q
a ba
![Page 78: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/78.jpg)
78
a
b ba,
ba,
0q 1q 2q
a ba
Output: “accept”
Input finished
![Page 79: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/79.jpg)
79
Rejection
a
b ba,
ba,
0q 1q 2q
ab b
![Page 80: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/80.jpg)
80
a
b ba,
ba,
0q 1q 2q
ab b
![Page 81: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/81.jpg)
81
a
b ba,
ba,
0q 1q 2q
ab b
![Page 82: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/82.jpg)
82
a
b ba,
ba,
0q 1q 2q
ab b
![Page 83: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/83.jpg)
83
a
b ba,
ba,
0q 1q 2q
ab b
Output: “reject”
Input finished
![Page 84: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/84.jpg)
84
• Deterministic Finite Accepter (DFA)
FqQM ,,,, 0
Q
0q
F
: Finite set of states
: input alphabet
: transition function
: initial state is a member of Q
: set of final states
: Q X Q
![Page 85: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/85.jpg)
85
Input Alphabet
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
ba,
![Page 86: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/86.jpg)
86
Set of States
Q
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
543210 ,,,,, qqqqqqQ
ba,
![Page 87: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/87.jpg)
87
Initial State
0q
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
0q
![Page 88: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/88.jpg)
88
Set of Final States
F
0q 1q 2q 3qa b b a
5q
a a bb
ba,
4qF
ba,
4q
![Page 89: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/89.jpg)
89
Transition Function
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
QQ :
ba,
![Page 90: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/90.jpg)
90
10 , qaq
2q 3q 4qa b b a
5q
a a bb
ba,
ba,
0q 1q
![Page 91: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/91.jpg)
91
50 , qbq
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
0q
![Page 92: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/92.jpg)
92
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
32 , qbq
![Page 93: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/93.jpg)
93
Transition Function
•
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
a b
0q
1q
2q
3q
4q
5q
1q 5q
5q 2q
2q 3q
4q 5q
ba,5q5q5q5q
![Page 94: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/94.jpg)
94
Extended Transition Function
*
QQ *:*
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
![Page 95: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/95.jpg)
95
20 ,* qabq
3q 4qa b b a
5q
a a bb
ba,
ba,
0q 1q 2q
![Page 96: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/96.jpg)
96
40 ,* qabbaq
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
![Page 97: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/97.jpg)
97
50 ,* qabbbaaq
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
0q
![Page 98: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/98.jpg)
98
50 ,* qabbbaaq
1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
0q
Observation: There is a walk from to with label
0qabbbaa
1q
![Page 99: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/99.jpg)
99
Recursive Definition
•
)),,(*(,*
,*
awqwaq
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
![Page 100: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/100.jpg)
100
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
2
1
0
0
0
0
,
,,
,,,*
),,(*
,*
q
bq
baq
baq
baq
abq
![Page 101: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/101.jpg)
101
Languages Accepted by DFAs• Take DFA
• Definition:
– The language contains – all input strings accepted by
– = { strings that drive to a final state}
M
MLM
M ML
![Page 102: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/102.jpg)
102
Example
•
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
abbaML M
accept
![Page 103: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/103.jpg)
103
Another Example
0q 1q 2q 3q 4qa b b a
5q
a a bb
ba,
ba,
abbaabML ,, M
acceptacceptaccept
•
![Page 104: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/104.jpg)
104
Formally
• For a DFA Language accepted by :
FqQM ,,,, 0
M
FwqwML ,*:* 0
alphabet transitionfunction
initialstate
finalstates
![Page 105: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/105.jpg)
105
Observation
• Language accepted by :
• Language rejected by :
FwqwML ,*:* 0M
FwqwML ,*:* 0M
![Page 106: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/106.jpg)
106
More Examples•
a
b ba,
ba,
0q 1q 2q
}0:{ nbaML n
accept trap state or dead state
![Page 107: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/107.jpg)
107
•
ML = { all strings with prefix }ab
a b
ba,
0q 1q 2q
accept
ba,3q
ab
![Page 108: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/108.jpg)
108
•
ML = { all strings without substring }001
0 00 001
1
0
1
10
0 1,0
![Page 109: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/109.jpg)
109
Regular Languages
• A language is regular if there is
• a DFA such that
• All regular languages form a language family–
LM MLL
![Page 110: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/110.jpg)
110
Example
• The language
• is regular:
•
*,: bawawaL
a
b
ba,
a
b
ba
0q 2q 3q
4q
![Page 111: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/111.jpg)
111
Non Deterministic Automata
![Page 112: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/112.jpg)
112
Non Deterministic Finite Accepter
FqQM ,,,, 0
: 2QQ
![Page 113: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/113.jpg)
113
1q 2q
3q
a
a
a
0q
}{aAlphabet =
Nondeterministic Finite Accepter (NFA)
![Page 114: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/114.jpg)
114
1q 2q
3q
a
a
a
0q
Two choices
}{aAlphabet =
Nondeterministic Finite Accepter (NFA)
![Page 115: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/115.jpg)
115
No transition
1q 2q
3q
a
a
a
0q
Two choices No transition
}{aAlphabet =
Nondeterministic Finite Accepter (NFA)
![Page 116: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/116.jpg)
116
a a
0q
1q 2q
3q
a
a
First Choice
a
![Page 117: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/117.jpg)
117
a a
0q
1q 2q
3q
a
a
a
First Choice
![Page 118: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/118.jpg)
118
a a
0q
1q 2q
3q
a
a
First Choice
a
![Page 119: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/119.jpg)
119
a a
0q
1q 2q
3q
a
a
a “accept”
First Choice
All input is consumed
![Page 120: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/120.jpg)
120
a a
0q
1q 2q
3q
a
a
Second Choice
a
![Page 121: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/121.jpg)
121
a a
0q
1q 2qa
a
Second Choice
a
3q
![Page 122: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/122.jpg)
122
a a
0q
1q 2qa
a
a
3q
Second Choice
No transition:the automaton hangs
![Page 123: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/123.jpg)
123
a a
0q
1q 2qa
a
a
3q
Second Choice
“reject”
Input cannot be consumed
![Page 124: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/124.jpg)
124
An NFA accepts a string:
when there is a computation of the NFAthat accepts the string
•All the input is consumed and the automaton is in a final state
![Page 125: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/125.jpg)
125
An NFA rejects a string:
when there is no computation of the NFAthat accepts the string
• All the input is consumed and the automaton is in a non final state
• The input cannot be consumed
![Page 126: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/126.jpg)
126
Example
aa is accepted by the NFA:
0q
1q 2q
3q
a
a
a
“accept”
0q
1q 2qa
a
a
3q “reject”
because this computationaccepts aa
![Page 127: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/127.jpg)
127
a
0q
1q 2q
3q
a
a
Rejection example
a
![Page 128: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/128.jpg)
128
a
0q
1q 2q
3q
a
a
a
First Choice
![Page 129: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/129.jpg)
129
a
0q
1q 2q
3q
a
a
a
First Choice
“reject”
![Page 130: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/130.jpg)
130
Second Choice
a
0q
1q 2q
3q
a
a
a
![Page 131: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/131.jpg)
131
Second Choice
a
0q
1q 2qa
a
a
3q
![Page 132: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/132.jpg)
132
Second Choice
a
0q
1q 2qa
a
a
3q “reject”
![Page 133: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/133.jpg)
133
Examplea is rejected by the NFA:
0q
1q 2qa
a
a
3q “reject”
0q
1q 2qa
a
a
3q
“reject”
All possible computations lead to rejection
![Page 134: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/134.jpg)
134
Rejection example
a a
0q
1q 2q
3q
a
a
a
a
![Page 135: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/135.jpg)
135
a a
0q
1q 2q
3q
a
a
a
First Choice
a
![Page 136: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/136.jpg)
136
a a
0q
1q 2q
3q
a
a
First Choice
a
a
No transition:the automaton hangs
![Page 137: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/137.jpg)
137
a a
0q
1q 2q
3q
a
a
a “reject”
First Choice
a
Input cannot be consumed
![Page 138: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/138.jpg)
138
a a
0q
1q 2q
3q
a
a
Second Choice
a
a
![Page 139: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/139.jpg)
139
a a
0q
1q 2qa
a
Second Choice
a
3q
a
![Page 140: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/140.jpg)
140
a a
0q
1q 2qa
a
a
3q
Second Choice
No transition:the automaton hangs
a
![Page 141: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/141.jpg)
141
a a
0q
1q 2qa
a
a
3q
Second Choice
“reject”
a
Input cannot be consumed
![Page 142: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/142.jpg)
142
aaais rejected by the NFA:
0q
1q 2q
3q
a
a
a
“reject”
0q
1q 2qa
a
a
3q “reject”
All possible computations lead to rejection
![Page 143: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/143.jpg)
143
1q 2q
3q
a
a
a
0q
Language accepted: }{aaL
![Page 144: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/144.jpg)
144
Lambda →Transitions
1q 3qa0q
2q a
![Page 145: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/145.jpg)
145
a a
1q 3qa0q
2q a
![Page 146: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/146.jpg)
146
a a
1q 3qa0q
2q a
![Page 147: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/147.jpg)
147
a a
1q 3qa0q
2q a
(read head doesn’t move)
![Page 148: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/148.jpg)
148
a a
1q 3qa0q
2q a
![Page 149: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/149.jpg)
149
a a
1q 3qa0q
2q a
“accept”
String is acceptedaa
all input is consumed
![Page 150: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/150.jpg)
150
a a
1q 3qa0q
2q a
Rejection Example
a
![Page 151: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/151.jpg)
151
a a
1q 3qa0q
2q a
a
![Page 152: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/152.jpg)
152
a a
1q 3qa0q
2q a
(read head doesn’t move)
a
![Page 153: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/153.jpg)
153
a a
1q 3qa0q
2q a
a
No transition:the automaton hangs
![Page 154: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/154.jpg)
154
a a
1q 3qa0q
2q a
“reject”
String is rejectedaaa
a
Input cannot be consumed
![Page 155: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/155.jpg)
155
Language accepted: }{aaL
1q 3qa0q
2q a
![Page 156: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/156.jpg)
156
Another NFA Example
0q 1q 2qa b
3q
![Page 157: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/157.jpg)
157
a b
0q 1q 2qa b
3q
![Page 158: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/158.jpg)
158
0q 2qa b
3q
a b
1q
![Page 159: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/159.jpg)
159
a b
0q 1qa b
3q2q
![Page 160: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/160.jpg)
160
a b
0q 1qa b
3q2q
“accept”
![Page 161: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/161.jpg)
161
0qa b
a b
Another String
a b
1q 2q 3q
![Page 162: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/162.jpg)
162
0qa b
a b a b
1q 2q 3q
![Page 163: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/163.jpg)
163
0qa b
a b a b
1q 2q 3q
![Page 164: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/164.jpg)
164
0qa b
a b a b
1q 2q 3q
![Page 165: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/165.jpg)
165
0qa b
a b a b
1q 2q 3q
![Page 166: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/166.jpg)
166
0qa b
a b a b
1q 2q 3q
![Page 167: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/167.jpg)
167
0qa b
a b a b
1q 2q 3q
![Page 168: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/168.jpg)
168
a b a b
0qa b
1q 2q 3q
“accept”
![Page 169: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/169.jpg)
169
ab
ababababababL ...,,,
Language accepted
0q 1q 2qa b
3q
![Page 170: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/170.jpg)
170
Another NFA Example
0q 1q 2q0
11,0
![Page 171: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/171.jpg)
171
{ }{ } *10=
...,101010,1010,10,λ=)(ML
0q 1q 2q0
11,0
Language accepted
![Page 172: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/172.jpg)
172
Remarks:
•The symbol never appears on the input tape
0q2M
0q1M
{}=)M(L 1 }λ{=)M(L 2
•Extreme automata:
![Page 173: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/173.jpg)
173
0q
2q
1qa
0q 1qa
}{=)( 1 aML
2M1M
}{=)( 2 aML
NFA DFA
•NFAs are interesting because we can express languages easier than DFAs
ba,b
a,b
![Page 174: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/174.jpg)
174
Formal Definition of NFAs
FqQM ,,,, 0
:Q
::0q
:F
Set of states, i.e. 210 ,, qqq
: Input alphabet, i.e. ba,
Transition function
Initial state
Final states
![Page 175: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/175.jpg)
175
10 1, qq
0
11,0
Transition Function
0q 1q 2q
![Page 176: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/176.jpg)
176
0q
0
11,0
},{)0,( 201 qqq
1q 2q
![Page 177: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/177.jpg)
177
0q
0
11,0
1q 2q
},{),( 200 qqq
![Page 178: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/178.jpg)
178
0q
0
11,0
1q 2q
)1,( 2q
![Page 179: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/179.jpg)
179
Extended Transition Function
•
*
0q
5q4q
3q2q1qa
aa
b
10 ,* qaq
![Page 180: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/180.jpg)
180
540 ,,* qqaaq
0q
5q4q
3q2q1qa
aa
b
![Page 181: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/181.jpg)
181
0320 ,,,* qqqabq
0q
5q4q
3q2q1qa
aa
b
![Page 182: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/182.jpg)
182
Formally
wqq ij ,*
It holdsif and only if
there is a walk from towith label
iq jqw
![Page 183: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/183.jpg)
183
The Language of an NFA
•
0q
5q4q
3q2q1qa
aa
b
540 ,,* qqaaq
M
)(MLaa
50 ,qqF
![Page 184: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/184.jpg)
184
0q
5q4q
3q2q1qa
aa
b
0320 ,,,* qqqabq MLab
50 ,qqF
![Page 185: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/185.jpg)
185
•
0q
5q4q
3q2q1qa
aa
b
50 ,qqF
540 ,,* qqabaaq )(MLaaba
![Page 186: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/186.jpg)
186
0q
5q4q
3q2q1qa
aa
b
50 ,qqF
10 ,* qabaq MLaba
![Page 187: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/187.jpg)
187
0q
5q4q
3q2q1qa
aa
b
aaababaaML *
![Page 188: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/188.jpg)
188
Formally
• The language accepted by NFA is:
• where
• and there is some
M
,...,, 321 wwwML
,...},{),(* 0 jim qqwq
Fqk (final state)
![Page 189: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/189.jpg)
189
•
0q kq
w
w
w
),(* 0 wq MLw
Fqk
iq
jq
![Page 190: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/190.jpg)
190
Equivalence of NFAs and DFAs
![Page 191: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/191.jpg)
191
Equivalence of Machines
• For DFAs or NFAs:
• Machine is equivalent to machine
• if
•
1M 2M
21 MLML
![Page 192: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/192.jpg)
192
• 0q 1q 2q
0
11,0
0q 1q 2q
0
11
0
1,0
NFA
DFA
*}10{1 ML
*}10{2 ML
1M
2M
![Page 193: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/193.jpg)
193
• Since
• machines and are equivalent
*1021 MLML
1M 2M
0q 1q 2q
0
11,0
0q 1q 2q
0
11
0
1,0
DFA
NFA 1M
2M
![Page 194: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/194.jpg)
194
Equivalence of NFAs and DFAs
Question: NFAs = DFAs ?
Same power?Accept the same languages?
![Page 195: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/195.jpg)
195
Equivalence of NFAs and DFAs
Question: NFAs = DFAs ?
Same power?Accept the same languages?
YES!
![Page 196: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/196.jpg)
196
We will prove:
Languages acceptedby NFAs
Languages acceptedby DFAs
NFAs and DFAs have the same computation power
![Page 197: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/197.jpg)
197
Languages acceptedby NFAs
Languages acceptedby DFAs
Step 1
Proof: Every DFA is trivially an NFA
A language accepted by a DFAis also accepted by an NFA
![Page 198: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/198.jpg)
198
Languages acceptedby NFAs
Languages acceptedby DFAs
Step 2
Proof: Any NFA can be converted to anequivalent DFA
A language accepted by an NFAis also accepted by a DFA
![Page 199: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/199.jpg)
199
NFA to DFA
•
a
b
a
0q 1q 2q
NFA
DFA
0q
M
M
![Page 200: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/200.jpg)
200
•
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
M
M
![Page 201: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/201.jpg)
201
•
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
M
M
![Page 202: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/202.jpg)
202
•
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
a
M
M
![Page 203: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/203.jpg)
203
•
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
M
M
![Page 204: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/204.jpg)
204
•
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
ba,
M
M
![Page 205: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/205.jpg)
205
•
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
ba,
M
M
)(MLML
![Page 206: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/206.jpg)
206
NFA to DFA: Remarks
• We are given an NFA
• We want to convert it to an equivalent DFA
M
M
)(MLML
![Page 207: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/207.jpg)
207
• If the NFA has states
• the DFA has states in the power set
•
,...,, 210 qqq
,....,,,,,,, 7432110 qqqqqqq
![Page 208: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/208.jpg)
208
Procedure NFA to DFA
•
• 1. Initial state of NFA:
•
• Initial state of DFA:
0q
0q
![Page 209: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/209.jpg)
209
•
a
b
a
0q 1q 2q
NFA
DFA
0q
M
M
![Page 210: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/210.jpg)
210
Procedure NFA to DFA
• 2. For every DFA’s state
• Compute in the NFA
•
• Add transition to DFA
},...,,{ mji qqq
...
,,*
,,*
aq
aq
j
i
},...,,{ mji qqq
},...,,{},,...,,{ mjimji qqqaqqq
![Page 211: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/211.jpg)
211
•
a
b
a
0q 1q 2q
NFA
0q 21,qqa
DFA
},{),(* 210 qqaq
210 ,, qqaq
M
M
},{),(* 210 qqaq
![Page 212: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/212.jpg)
212
Procedure NFA to DFA
• Repeat Step 2 for all letters in alphabet,
• until
• no more transitions can be added.
![Page 213: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/213.jpg)
213
•
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
ba,
M
M
![Page 214: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/214.jpg)
214
Procedure NFA to DFA
• 3. For any DFA state
• If some is a final state in the NFA
• Then, • is a final state in the DFA•
},...,,{ mji qqq
jq
},...,,{ mji qqq
![Page 215: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/215.jpg)
215
•
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
ba,
Fq 1
Fqq 21,
M
M
![Page 216: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/216.jpg)
216
Theorem
• Take NFA M
Apply procedure to obtain DFA M
Then and are equivalent :M M
MLML
![Page 217: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/217.jpg)
217
FinallyWe have proven
Languages acceptedby NFAs
Languages acceptedby DFAs
![Page 218: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/218.jpg)
218
Languages acceptedby NFAs
Languages acceptedby DFAs
We have proven
Regular Languages
![Page 219: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/219.jpg)
219
Languages acceptedby NFAs
Languages acceptedby DFAs
We have proven
Regular LanguagesRegular Languages
![Page 220: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/220.jpg)
220
Languages acceptedby NFAs
Languages acceptedby DFAs
We have proven
Regular LanguagesRegular Languages
Thus, NFAs accept the regular languages
![Page 221: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/221.jpg)
221
Single Final State for NFAs and DFAs
![Page 222: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/222.jpg)
222
Observation
• Any Finite Automaton (NFA or DFA)
• can be converted to an equivalent NFA
• with a single final state
![Page 223: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/223.jpg)
223
a
b
b
aNFA
Equivalent NFA
a
b
b
a
Example
![Page 224: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/224.jpg)
224
NFAIn General
Equivalent NFA
Singlefinal state
![Page 225: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/225.jpg)
225
Extreme Case
NFA without final state
Add a final stateWithout transitions
![Page 226: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/226.jpg)
226
Some Properties of Regular Languages
![Page 227: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/227.jpg)
227
1L2L
21LLConcatenation:
*1LStar:
21 LL Union:
Are regularLanguages
For regular languages and we will prove that:
properties
![Page 228: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/228.jpg)
228
We Say:Regular languages are closed under
21LLConcatenation:
*1LStar:
21 LL Union:
![Page 229: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/229.jpg)
229
Properties
1L 2L
21LLConcatenation:
*1LStar:
21 LL Union:
Are regularLanguages
For regular languages and we will prove that:
![Page 230: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/230.jpg)
230
1LRegular language
11 LML
1M
Single final state
NFA 2M
2L
Single final state
22 LML
Regular language
NFA
![Page 231: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/231.jpg)
231
Example
}{1 baL na
b 1M
baL 2ab
2M
![Page 232: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/232.jpg)
232
Union
• NFA for 1M
2M
21 LL
![Page 233: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/233.jpg)
233
• a
b
ab
}{1 baL n
}{2 baL
}{}{21 babaLL n NFA for
![Page 234: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/234.jpg)
234
Concatenation
• NFA for
21LL
1M 2M
![Page 235: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/235.jpg)
235
Example
•
• NFA for
a
b ab
}{1 baL n}{2 baL
}{}}{{21 bbaababaLL nn
![Page 236: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/236.jpg)
236
Star Operation• NFA for *1L
1M
*1L
![Page 237: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/237.jpg)
237
Example
• NFA for
*}{*1 baL n
a
b
}{1 baL n
N>= 0
![Page 238: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/238.jpg)
238
Procedure: NFA to DFA
1 Create a graph with vertex {q0}.Identify this vertex as initial vertex of DFA.
2 Repeat the following steps until no more edges are missing.Take any vertex {qi,qj,….qk} of G that has no outgoing edge for some symbol a of the alphabet.Compute (qi, a), (qj, a)…. (qk, a)Then form the union of all these yielding the set {ql, qm, …qn}.Create a vertex for G labeled {ql, qm,…qn} if it does not already exist.Add to G an edge from {qi, qj,…qk} to {ql,qm…qn} and label it with a.
3 Every state of G whose label contains any qf of F is identified as a final vertex of DFA.
4 If NFA accepts then vertex {q0} in G is also made a final vertex.
**
*
*
![Page 239: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/239.jpg)
239
q0 q2q10,1 0,1
10
![Page 240: Flat](https://reader031.vdocuments.us/reader031/viewer/2022020803/5479f672b4af9f08748b457e/html5/thumbnails/240.jpg)
240
q0
{q0,q1}
q1
q0,q1,q2q1,q2
q2
0
01
1
0
0,1
0,1
1
1
0,1
Equivalent DFA
Start
0