Automata
-
Upload
ayhan-epik -
Category
Documents
-
view
211 -
download
6
Transcript of Automata
![Page 1: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/1.jpg)
1
Non Deterministic Automata
![Page 2: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/2.jpg)
2
1q 2q
3q
a
a
a
0q
}{aAlphabet =
Nondeterministic Finite Accepter (NFA)
![Page 3: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/3.jpg)
3
1q 2q
3q
a
a
a
0q
Two choices
}{aAlphabet =
Nondeterministic Finite Accepter (NFA)
![Page 4: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/4.jpg)
4
No transition
1q 2q
3q
a
a
a
0q
Two choices No transition
}{aAlphabet =
Nondeterministic Finite Accepter (NFA)
![Page 5: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/5.jpg)
5
a a
0q
1q 2q
3q
a
a
First Choice
a
![Page 6: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/6.jpg)
6
a a
0q
1q 2q
3q
a
a
a
First Choice
![Page 7: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/7.jpg)
7
a a
0q
1q 2q
3q
a
a
First Choice
a
![Page 8: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/8.jpg)
8
a a
0q
1q 2q
3q
a
a
a “accept”
First Choice
![Page 9: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/9.jpg)
9
a a
0q
1q 2q
3q
a
a
Second Choice
a
![Page 10: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/10.jpg)
10
a a
0q
1q 2qa
a
Second Choice
a
3q
![Page 11: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/11.jpg)
11
a a
0q
1q 2qa
a
a
3q
Second Choice
No transition:the automaton hangs
![Page 12: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/12.jpg)
12
a a
0q
1q 2qa
a
a
3q
Second Choice
“reject”
![Page 13: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/13.jpg)
13
Observation
An NFA accepts a stringifthere is a computation of the NFAthat accepts the string
![Page 14: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/14.jpg)
14
Example
aa is accepted by the NFA:
0q
1q 2q
3q
a
a
a
![Page 15: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/15.jpg)
15
Lambda Transitions
1q 3qa0q
1q a
![Page 16: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/16.jpg)
16
a a
1q 3qa0q
2q a
![Page 17: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/17.jpg)
17
a a
1q 3qa0q
2q a
![Page 18: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/18.jpg)
18
a a
1q 3qa0q
2q a
(read head doesn’t move)
![Page 19: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/19.jpg)
19
a a
1q 3qa0q
2q a
![Page 20: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/20.jpg)
20
a a
1q 3qa0q
2q a
“accept”
String is acceptedaa
![Page 21: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/21.jpg)
21
Language accepted: }{aaL
1q 3qa0q
2q a
![Page 22: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/22.jpg)
22
Another NFA Example
0q 1q 2qa b
3q
![Page 23: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/23.jpg)
23
a b
0q 1q 2qa b
3q
![Page 24: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/24.jpg)
24
0q 2qa b
3q
a b
1q
![Page 25: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/25.jpg)
25
a b
0q 1qa b
3q2q
![Page 26: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/26.jpg)
26
a b
0q 1qa b
3q2q
“accept”
![Page 27: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/27.jpg)
27
0qa b
a b
Another String
a b
1q 2q 3q
![Page 28: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/28.jpg)
28
0qa b
a b a b
1q 2q 3q
![Page 29: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/29.jpg)
29
0qa b
a b a b
1q 2q 3q
![Page 30: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/30.jpg)
30
0qa b
a b a b
1q 2q 3q
![Page 31: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/31.jpg)
31
0qa b
a b a b
1q 2q 3q
![Page 32: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/32.jpg)
32
0qa b
a b a b
1q 2q 3q
![Page 33: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/33.jpg)
33
0qa b
a b a b
1q 2q 3q
![Page 34: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/34.jpg)
34
a b a b
0qa b
1q 2q 3q
“accept”
![Page 35: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/35.jpg)
35
ab
ababababababL ...,,,
Language accepted
0q 1q 2qa b
3q
![Page 36: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/36.jpg)
36
Another NFA Example
0q 1q 2q0
11,0
![Page 37: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/37.jpg)
37
*10
...,101010,1010,10,
L
0q 1q 2q0
11,0
Language accepted
![Page 38: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/38.jpg)
38
Formal Definition of NFAs FqQM ,,,, 0
:Q
::0q
:F
Set of states, i.e. 210 ,, qqq
: Input aplhabet, i.e. ba,Transition function
Initial state
Final states
![Page 39: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/39.jpg)
39
10 1, qq
0
11,0
Transition Function
0q 1q 2q
![Page 40: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/40.jpg)
40
0q
0
11,0
},{)0,( 201 qqq
1q 2q
![Page 41: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/41.jpg)
41
0q
0
11,0
1q 2q
},{),( 200 qqq
![Page 42: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/42.jpg)
42
0q
0
11,0
1q 2q
)1,( 2q
![Page 43: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/43.jpg)
43
Extended Transition Function
*
0q
5q4q
3q2q1qa
aa
b
10 ,* qaq
![Page 44: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/44.jpg)
44
540 ,,* qqaaq
0q
5q4q
3q2q1qa
aa
b
![Page 45: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/45.jpg)
45
0320 ,,,* qqqabq
0q
5q4q
3q2q1qa
aa
b
![Page 46: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/46.jpg)
46
Formally
wqq ij ,*It holds
if and only if
there is a walk from towith label
iq jqw
![Page 47: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/47.jpg)
47
The Language of an NFA
0q
5q4q
3q2q1qa
aa
b
540 ,,* qqaaq
M
)(MLaa
50 ,qqF
![Page 48: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/48.jpg)
48
0q
5q4q
3q2q1qa
aa
b
0320 ,,,* qqqabq MLab
50 ,qqF
![Page 49: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/49.jpg)
49
0q
5q4q
3q2q1qa
aa
b
50 ,qqF
540 ,,* qqabaaq )(MLaaba
![Page 50: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/50.jpg)
50
0q
5q4q
3q2q1qa
aa
b
50 ,qqF
10 ,* qabaq MLaba
![Page 51: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/51.jpg)
51
0q
5q4q
3q2q1qa
aa
b
aaababaaML *
![Page 52: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/52.jpg)
52
FormallyThe language accepted by NFA is:
where
and there is some
M
,...,, 321 wwwML
,...},{),(* 0 jim qqwq
Fqk (final state)
![Page 53: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/53.jpg)
53
0q kq
w
w
w
),(* 0 wq MLw
Fqk
iq
jq
![Page 54: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/54.jpg)
54
Equivalence of NFAs and DFAs
![Page 55: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/55.jpg)
55
Equivalence of Machines
For DFAs or NFAs:
Machine is equivalent to machine
if
1M 2M
21 MLML
![Page 56: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/56.jpg)
56
Example
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 57: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/57.jpg)
57
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 58: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/58.jpg)
58
Equivalence of NFAs and DFAs
Question: NFAs = DFAs ?
Same power?Accept the same languages?
![Page 59: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/59.jpg)
59
Equivalence of NFAs and DFAs
Question: NFAs = DFAs ?
Same power?Accept the same languages?
YES!
![Page 60: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/60.jpg)
60
We will prove:
Languages acceptedby NFAs
Languages acceptedby DFAs
![Page 61: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/61.jpg)
61
We will prove:
Languages acceptedby NFAs
Languages acceptedby DFAs
NFAs and DFAs have the same computation power
![Page 62: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/62.jpg)
62
Languages acceptedby NFAs
Languages acceptedby DFAs
Step 1
![Page 63: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/63.jpg)
63
Languages acceptedby NFAs
Languages acceptedby DFAs
Step 1
Proof: Every DFA is also an NFA
![Page 64: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/64.jpg)
64
Languages acceptedby NFAs
Languages acceptedby DFAs
Step 1
Proof: Every DFA is also an NFA
A language accepted by a DFAis also accepted by an NFA
![Page 65: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/65.jpg)
65
Languages acceptedby NFAs
Languages acceptedby DFAs
Step 2
![Page 66: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/66.jpg)
66
Languages acceptedby NFAs
Languages acceptedby DFAs
Step 2
Proof: Any NFA can be converted to anequivalent DFA
![Page 67: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/67.jpg)
67
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 68: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/68.jpg)
68
NFA to DFA
a
b
a
0q 1q 2q
NFA
DFA
0q
![Page 69: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/69.jpg)
69
NFA to DFA
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
![Page 70: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/70.jpg)
70
NFA to DFA
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
![Page 71: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/71.jpg)
71
NFA to DFA
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
a
![Page 72: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/72.jpg)
72
NFA to DFA
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
![Page 73: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/73.jpg)
73
NFA to DFA
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
ba,
![Page 74: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/74.jpg)
74
NFA to DFA
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
ba,
![Page 75: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/75.jpg)
75
NFA to DFA: Remarks
We are given an NFA
We want to convert it to an equivalent DFA
With
M
M
)(MLML
![Page 76: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/76.jpg)
76
If the NFA has states
the DFA has states in the powerset
,...,, 210 qqq
,....,,,,,,, 7432110 qqqqqqq
![Page 77: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/77.jpg)
77
Procedure NFA to DFA
1. Initial state of NFA:
Initial state of DFA:
0q
0q
![Page 78: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/78.jpg)
78
Example
a
b
a
0q 1q 2q
NFA
DFA
0q
![Page 79: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/79.jpg)
79
Procedure NFA to DFA
2. For every DFA’s state
Compute in the NFA
Add transition
},...,,{ mji qqq
...
,,*
,,*
aq
aq
j
i
},...,,{ mji qqq
},...,,{},,...,,{ mjimji qqqaqqq
![Page 80: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/80.jpg)
80
Exampe
a
b
a
0q 1q 2q
NFA
0q 21,qqa
DFA
},{),(* 210 qqaq
210 ,, qqaq
![Page 81: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/81.jpg)
81
Procedure NFA to DFA
Repeat Step 2 for all letters in alphabet,
untilno more transitions can be added.
![Page 82: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/82.jpg)
82
Example
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
ba,
![Page 83: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/83.jpg)
83
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 84: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/84.jpg)
84
Example
a
b
a
0q 1q 2q
NFA
DFA
0q 21,qqa
b
ab
ba,
Fq 1
Fqq 21,
![Page 85: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/85.jpg)
85
Theorem Take NFA M
Apply procedure to obtain DFA M
Then and are equivalent :M M
MLML
![Page 86: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/86.jpg)
86
Finally
We have proven
Languages acceptedby NFAs
Languages acceptedby DFAs
![Page 87: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/87.jpg)
87
Languages acceptedby NFAs
Languages acceptedby DFAs
We have proven
Regular Languages
![Page 88: Automata](https://reader035.fdocuments.net/reader035/viewer/2022062708/5587573dd8b42a763c8b46b4/html5/thumbnails/88.jpg)
88
Languages acceptedby NFAs
Languages acceptedby DFAs
We have proven
Regular LanguagesRegular Languages