What can be computed with finite memory? input tape 0 1 1 0 ···...
Transcript of What can be computed with finite memory? input tape 0 1 1 0 ···...
![Page 1: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/1.jpg)
Finite Automata
What can be computed with finite memory?
state
0 1 1 0 · · ·input tape
![Page 2: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/2.jpg)
Finite Automata
What can be computed with finite memory?
state
0 1 1 0 · · ·input tape
![Page 3: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/3.jpg)
Finite Automata
What can be computed with finite memory?
state
0 1 1 0 · · ·input tape
![Page 4: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/4.jpg)
A “Wild” Finite Automaton
The input is the numbers pressed by theuser
The correct code is 1234
Actually the door is opened if{0, . . . ,9}∗1234{0, . . . ,9}∗ is entered
The machine needs to remember if theinput given so far contains thesubsequence 1234
![Page 5: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/5.jpg)
Finite Automata: Informal Definition
q1 q2
1
0
0 1
The machine M:
States: q1 and q2
Start state: q1 (arrow from nowhere)
Accept state: q2 (double circle)
State transitions: arrows
![Page 6: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/6.jpg)
Finite Automata: Informal Definition
q1 q2
1
0
0 1
The machine M:On input string s = s1s2 · · · sn, M operates as follows:
Begins in start state q1 and reads the string s from left torightWhen reading symbol si it follows the transition labeled si
from the current stateAfter reading sn, the last symbol in the string, it
accepts s if it is in an accept staterejects s if it is not in an accept state
![Page 7: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/7.jpg)
Finite Automata: Informal Definition
q1 q2
1
0
0 1
The machine M:On input:011
![Page 8: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/8.jpg)
Finite Automata: Informal Definition
q1 q2
1
0
0 1
The machine M:On input:011 ACCEPT
![Page 9: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/9.jpg)
Finite Automata: Informal Definition
q1 q2
1
0
0 1
The machine M:On input:011 ACCEPT10
![Page 10: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/10.jpg)
Finite Automata: Informal Definition
q1 q2
1
0
0 1
The machine M:On input:011 ACCEPT10 REJECT
![Page 11: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/11.jpg)
Finite Automata: Informal Definition
q1 q2
1
0
0 1
The machine M:On input:011 ACCEPT10 REJECT110
![Page 12: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/12.jpg)
Finite Automata: Informal Definition
q1 q2
1
0
0 1
The machine M:On input:011 ACCEPT10 REJECT110 REJECT
![Page 13: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/13.jpg)
A “Wild” Finite Automaton
The input is the numbers pressed by theuser
The correct code is 1234
Actually the door is opened if{0, . . . ,9}∗1234{0, . . . ,9}∗ is entered
The machine needs to remember if theinput given so far contains thesubsequence 1234
![Page 14: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/14.jpg)
A “Wild” Finite Automaton
The input is the numbers pressed by theuser
The correct code is 1234
Actually the door is opened if{0, . . . ,9}∗1234{0, . . . ,9}∗ is entered
The machine needs to remember if theinput given so far contains thesubsequence 1234
qs q1 q12 q123 q12341 2 3 4
0,2, . . . ,9
1
0,3, . . . ,9
0, . . . ,90,2,4, . . . ,9
0,2,3,5, . . . ,9
1
1
![Page 15: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/15.jpg)
Representation of finite automata
State diagram
q1 q2
1
0
0 1
Transition table0 1
→ q1 q1 q2
F q2 q1 q2
![Page 16: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/16.jpg)
Definition of DFAs
Definition
A deterministic finite automaton (DFA) is a 5-tuple(Q,Σ, δ,q0,F ) where
Q is a finite set called the states
Σ is a finite set called the alphabet
δ : Q × Σ → Q is the transition function
q0 ∈ Q is the start state
F ⊆ Q is the set of accept states
![Page 17: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/17.jpg)
The language recognized by a DFA
Definition
Let M = (Q,Σ, δ,q0,F ) be a DFA and s = s1s2 · · · sn a stringover Σ. M accepts s if there is a sequence of states r0, r1, . . . rn
from Q such that
r0 = q0,
δ(ri , si+1) = ri+1 (i = 0, . . . ,n − 1), and
rn ∈ F
![Page 18: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/18.jpg)
The language recognized by a DFA
Definition
Let M = (Q,Σ, δ,q0,F ) be a DFA and s = s1s2 · · · sn a stringover Σ. M accepts s if there is a sequence of states r0, r1, . . . rn
from Q such that
r0 = q0,
δ(ri , si+1) = ri+1 (i = 0, . . . ,n − 1), and
rn ∈ F
Definition
M recognizes language L if L = {s | M accepts s}
L(M) denotes the language recognized by M
![Page 19: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/19.jpg)
Regular Languages
DefinitionA language is a regularlanguage if some DFArecognizes it
![Page 20: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/20.jpg)
Nondeterminism
The machines we have seen so far have beendeterministic. The next state follows uniquely from thecurrent state and the input symbol
In a nondeterministic machine several possible next statesmay follow from the current state and input symbol. Thesepossibilities can be thought of as being explored in parallel
Understanding the power of nondeterminism is a centraltopic in the theory of computation (and this course)
![Page 21: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/21.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
![Page 22: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/22.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
An NFA accepts a string s if, after reading the last symbolof s, at least one of its active states is an accept state
An NFA rejects a string s if, after reading the last symbol ofs, none if its active states is an accept state
![Page 23: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/23.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
![Page 24: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/24.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
0101
![Page 25: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/25.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
0101
![Page 26: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/26.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
0101
![Page 27: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/27.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
0101
![Page 28: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/28.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
0101
![Page 29: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/29.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
0101
![Page 30: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/30.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
0101
![Page 31: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/31.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
0101
![Page 32: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/32.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
0101
![Page 33: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/33.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
0101 REJECT
![Page 34: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/34.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
110
![Page 35: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/35.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
110
![Page 36: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/36.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
110
![Page 37: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/37.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
110
![Page 38: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/38.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
110
![Page 39: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/39.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
110
![Page 40: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/40.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
110
![Page 41: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/41.jpg)
Example of a nondeterminstic finite automaton (NFA)
p q r1 0,1
0,1
110 ACCEPT
![Page 42: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/42.jpg)
Example of a NFA with ε transitions
p q r1 0,1
0,1
q1 q2
1
0
0 1
![Page 43: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/43.jpg)
Example of a NFA with ε transitions
p q r1 0,1
0,1
q1 q2
s
ε
ε
1
0
0 1
![Page 44: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/44.jpg)
Example of a NFA with ε transitions
p q r1 0,1
0,1
q1 q2
s
ε
ε
1
0
0 1
01
![Page 45: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/45.jpg)
Example of a NFA with ε transitions
p q r1 0,1
0,1
q1 q2
s
ε
ε
1
0
0 1
01
![Page 46: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/46.jpg)
Example of a NFA with ε transitions
p q r1 0,1
0,1
q1 q2
s
ε
ε
1
0
0 1
01
![Page 47: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/47.jpg)
Example of a NFA with ε transitions
p q r1 0,1
0,1
q1 q2
s
ε
ε
1
0
0 1
01 ACCEPT
![Page 48: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/48.jpg)
Definition of NFAs
The power set of Q, written P(Q), is the set of all subsets of Q
Example
If A = {1,2} then P(A) = {∅, {1}, {2}, {1,2}}
![Page 49: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/49.jpg)
Definition of NFAs
Definition
A nondeterministic finite automaton (NFA) is a 5-tuple(Q,Σ, δ,q0,F ) where
Q is a finite set called the states
Σ is a finite set called the alphabet
δ : Q × (Σ ∪ {ε}) → P(Q) is the transition function
q0 ∈ Q is the start state
F ⊆ Q is the set of accept states
![Page 50: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/50.jpg)
The language recognized by a NFA
Definition
Let N = (Q,Σ, δ,q0,F ) be a NFA and s = s1s2 · · · sm a stringover Σ. N accepts s if there is a sequence of states r0, r1, . . . rn
from Q and s can be written as s = s1, s2 . . . , sn where eachsi ∈ Σ ∪ {ε} such that
r0 = q0,
ri+1 ∈ δ(ri , si+1) (i = 0, . . . ,n − 1), and
rn ∈ F
![Page 51: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/51.jpg)
Equivalence of DFAs and NFAs
Definition
Two machines are equivalent if they recognize the samelanguage
![Page 52: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/52.jpg)
Equivalence of DFAs and NFAs
TheoremEvery NFA has an equivalent DFA
![Page 53: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/53.jpg)
Equivalence of DFAs and NFAs
TheoremEvery NFA has an equivalent DFA
Proof idea.
Given a NFA we need to construct a DFA that simulate the NFA
The DFA need to keep track of the set of active states ofthe NFA at each step
If k is the number of states of the NFA, then the DFA mightneed up to 2k states (one for each subset of states of theNFA)
So, the states of the DFA should be P(Q) where Q is thestates of the NFA
![Page 54: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/54.jpg)
Equivalence of DFAs and NFAs
TheoremEvery NFA has an equivalent DFA
Notation: Let E(R) be the set of states that can be reachedfrom R using 0 or more ε transitions.
![Page 55: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/55.jpg)
Equivalence of DFAs and NFAs
Theorem
Every NFA has an equivalent DFA
Notation: Let E(R) be the set of states that can be reachedfrom R using 0 or more ε transitions.
Proof.
The subset construction: Given a NFA N = (Q,Σ, δ,q0,F ) weconstruct an equivalent DFA M = (Q′,Σ, δ′,q′
0,F′) where
Q′ = P(Q)
q′
0 = E({q0})
F ′ = {R ∈ Q′ | R ∩ F 6= ∅}
![Page 56: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/56.jpg)
Equivalence of DFAs and NFAs
TheoremEvery NFA has an equivalent DFA
Notation: Let E(R) be the set of states that can be reachedfrom R using 0 or more ε transitions.
Proof.
The subset construction: Given a NFA N = (Q,Σ, δ,q0,F ) weconstruct an equivalent DFA M = (Q′,Σ, δ′,q′
0,F′) where
For R ∈ Q′ and a ∈ Σ,δ′(R,a) = {q ∈ Q | q ∈ E(δ(r ,a)) for some r ∈ R}
δ′(R,a) is the set of all states that can be reached (in theNFA) by first following a transition labeled a from a state inR and then following 0 or more ε transitions
![Page 57: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/57.jpg)
Equivalence of DFAs and NFAs: Example
p q r1 0,1
0,1
q1 q2
s
ε
ε
1
0
0 1
0 1→ {s,q1,p} {q1,p} {q2,p,q}
![Page 58: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/58.jpg)
Equivalence of DFAs and NFAs: Example
p q r1 0,1
0,1
q1 q2
s
ε
ε
1
0
0 1
0 1→ {s,q1,p} {q1,p} {q2,p,q}{q1,p} {q1,p} {q2,p,q}
![Page 59: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/59.jpg)
Equivalence of DFAs and NFAs: Example
p q r1 0,1
0,1
q1 q2
s
ε
ε
1
0
0 1
0 1→ {s,q1,p} {q1,p} {q2,p,q}{q1,p} {q1,p} {q2,p,q}F {q2,p,q} {q1,p, r} {q2,p,q, r}
![Page 60: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/60.jpg)
Equivalence of DFAs and NFAs: Example
p q r1 0,1
0,1
q1 q2
s
ε
ε
1
0
0 1
0 1→ {s,q1,p} {q1,p} {q2,p,q}{q1,p} {q1,p} {q2,p,q}F {q2,p,q} {q1,p, r} {q2,p,q, r}F {q1,p, r} {q1,p} {q2,p,q}
![Page 61: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/61.jpg)
Equivalence of DFAs and NFAs: Example
p q r1 0,1
0,1
q1 q2
s
ε
ε
1
0
0 1
0 1→ {s,q1,p} {q1,p} {q2,p,q}{q1,p} {q1,p} {q2,p,q}F {q2,p,q} {q1,p, r} {q2,p,q, r}F {q1,p, r} {q1,p} {q2,p,q}F {q2,p,q, r} {q1,p, r} {q2,p,q, r}
![Page 62: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/62.jpg)
Equivalence of DFAs and NFAs: Example
p q r1 0,1
0,1
q1 q2
s
ε
ε
1
0
0 1
{q1,p} {q2,p,q, r}0
{q2,p,q} {q1,p, r}
{s,q1,q}
0
1 1
1
0
0
1
0
1
![Page 63: What can be computed with finite memory? input tape 0 1 1 0 ··· …TDDD65/lectures/finiteautomataI1... · 2013-08-27 · 0 1 1 0 ··· input tape ... Finite Automata: Informal](https://reader034.fdocuments.in/reader034/viewer/2022042022/5e79ed56a26997761b6f74b7/html5/thumbnails/63.jpg)
Equivalence of DFAs and NFAs
TheoremEvery NFA has an equivalent DFA
Corollary
Every language recognized by a NFA can be recognized by aDFA