big picture - universitetet i oslo · big picture. dfa (deterministic finite automata) q0 qa 1 1 0...
TRANSCRIPT
![Page 1: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/1.jpg)
●All languages●Decidable
Turing machines●NP●P●Context-free
Context-free grammars, push-down automata●Regular
Automata, non-deterministic automata, regular expressions
Big picture
![Page 2: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/2.jpg)
DFA (Deterministic Finite Automata)
q0 qa1
1
0
0
1
001
![Page 3: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/3.jpg)
DFA (Deterministic Finite Automata)
q0 qa1
1
0
0
● States , this DFA has 4 states
● Transitionslabelled with elements of the alphabet Σ = {0,1}
1
001
![Page 4: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/4.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Computation on input w:● Begin in start state ● Read input string in a one-way fashion● Follow the arrows matching input symbols● When input ends: ACCEPT if in accept state REJECT if not
1
1
0
0
q0
1
001
![Page 5: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/5.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Example: Input string w = 0011
1
1
1
0
0
0
01
![Page 6: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/6.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Example: Input string w = 0011
1
1
1
0
0
0always start in start state
01
![Page 7: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/7.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Example: Input string
w = 0011
1
1
1
0
0
0
01
![Page 8: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/8.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Example: Input string w = 0011
1
1
1
0
0
0
01
![Page 9: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/9.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Example: Input string w = 0011
1
1
1
0
0
0
01
![Page 10: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/10.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Example: Input string w = 0011
1
1
1
0
0
0
01
![Page 11: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/11.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Example: Input string w = 0011 ACCEPT because end in accept state
1
1
1
0
0
0
01
![Page 12: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/12.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Example: Input string w = 010
1
1
1
0
0
0
01
![Page 13: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/13.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Example: Input string w = 010
1
1
1
0
0
0always start in start state
01
![Page 14: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/14.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Example: Input string w = 010
1
1
1
0
0
0
01
![Page 15: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/15.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Example: Input string w = 010
1
1
1
0
0
0
01
![Page 16: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/16.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Example: Input string w = 010
1
1
1
0
0
0
01
![Page 17: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/17.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Example: Input string w = 010 REJECT because does not end in accept state
1
1
1
0
0
0
01
![Page 18: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/18.jpg)
DFA (Deterministic Finite Automata)
q0 qa
Example: Input string w = 01 ACCEPT w = 010 REJECT w = 0011 ACCEPT
w = 00110 REJECT
1
1
1
0
0
0
01
![Page 19: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/19.jpg)
DFA (Deterministic Finite Automata)
q0 qa
M recognizes language L(M) = { w : w starts with 0 and ends with 1 }L(M) is the language of strings causing M to accept
Example: 0101 is an element of L(M), 0101 ∈ L(M)
1
1
1
0
0
0M :=
01
![Page 20: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/20.jpg)
ExampleM :=
● 00 causes M to accept, so 00 is in L(M) 00 ∈ L(M)● 01 does not cause M to accept, so 01 not in L(M), 01 ∉ L(M) ● 0101 ∈ L(M)● 01101100 ∈ L(M) ● 011010 ∉ L(M)
Σ = {0,1}q0 q1
10 0
1
![Page 21: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/21.jpg)
Exampleq0 q1
1M :=
0
L(M) = {w : w has an even number of 1 }
Note: If there is no 1, then there are zero 1,zero is an even number, so M should accept.
Indeed 0000000 ∈ L(M)
Σ = {0,1} 0
1
![Page 22: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/22.jpg)
ExampleM :=
0
● L(M) = ?
1Σ = {0,1}
![Page 23: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/23.jpg)
ExampleM :=
0
● L(M) = every possible string over {0,1}
= {0,1}*
1Σ = {0,1}
![Page 24: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/24.jpg)
Example
M :=0
● L(M) = ?
1
Σ = {0,1}
0
1q0
0
1
![Page 25: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/25.jpg)
Example
M :=0
● L(M) = all strings over {0,1} except empty string ε = {0,1}* - { ε }
1
Σ = {0,1}
0
1q0
0
1
![Page 26: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/26.jpg)
Example
M :=
0Σ = {0,1}
1
q0
0
1
11
0
0
1 0
● L(M) = ?
![Page 27: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/27.jpg)
Example
M :=
● L(M) = { w : w starts and ends with same symbol }● Memory is encoded in … what ?
0Σ = {0,1}
1
q0
0
1
11
0
0
1 0
![Page 28: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/28.jpg)
Example
M :=
● L(M) = { w : w starts and ends with same symbol }● Memory is encoded in states. DFA have finite states, so finite memory
0Σ = {0,1}
1
q0
0
1
11
0
0
1
Remember 0
Remember 10
![Page 29: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/29.jpg)
Convention:
q0 qa
We already saw that L(M) = { w : w starts with 0 and ends with 1 }
The arrow leads to a “sink” state. If followed, M can never accept
1
1
1
0
0
0M :=
q01
01
![Page 30: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/30.jpg)
Convention:
q0 qa
Don't need to write such arrows:If, from some state, read symbol with no corresponding arrow, imagine M goes into “sink state” that is not shown, and REJECT.
This makes pictures more compact.
1
1
0
0
0M :=
![Page 31: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/31.jpg)
Another convention:
List multiple transition on same arrow:
Means
This makes pictures more compact.
0,1,2
10
2
![Page 32: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/32.jpg)
Example ∑ = {0,1}
M =
L(M) = ?
0,10,1
![Page 33: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/33.jpg)
Example ∑ = {0,1}
M =
L(M) = ∑2 = {00,01,10,11}
0,10,1
![Page 34: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/34.jpg)
Example from programming languages:Recognize strings representing numbers:Σ = {0,1,2,3,4,5,6,7,8,9, +, -, . }
0,...,9
+-
.0,...,9
0,...,90,...,9
Note: 0,...,9 means 0,1,2,3,4,5,6,7,8,9: 10 transitions
![Page 35: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/35.jpg)
Example from programming languages:Recognize strings representing numbers:Σ = {0,1,2,3,4,5,6,7,8,9, +, -, . }
0,...,9
+-
.0,...,9
Possibly put sign (+, -)Follow with arbitrarily many digits, but at least onePossibly put decimal pointFollow with arbitrarily many digits, possibly none
0,...,90,...,9
![Page 36: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/36.jpg)
Example from programming languages:Recognize strings representing numbers:Σ = {0,1,2,3,4,5,6,7,8,9, +, -, . }
0,...,9
+-
.0,...,9
Input w = 17 ACCEPTInput w = + REJECTInput w = -3.25 ACCEPTInput w = +2.35-. REJECT
0,...,90,...,9
![Page 37: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/37.jpg)
Example
● What about { w : w has same number of 0 and 1 }
● Can you design a DFA that recognizes that?
● It seems you need infinite memory
● We will prove later thatthere is no DFA that recognizes that language !
Σ = {0,1}
![Page 38: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/38.jpg)
Next: formal definition of DFA
● Useful to prove various properties of DFA
● Especially important to prove that things CANNOT be recognized by DFA.
● Useful to practice mathematical notation
![Page 39: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/39.jpg)
State diagram of a DFA:
●One or more states
●Exactly one start state
●Some number of accept states
●Labelled transitions exiting each state,for every symbol in Σ
1
![Page 40: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/40.jpg)
●Definition: A finite automaton (DFA) is a 5-tuple (Q, Σ, δ, q0, F) where
●Q is a finite set of states●Σ is the input alphabet●δ : Q X Σ → Q is the transition function●q0 in Q is the start state●F ⊆ Q is the set of accept states
Q X Σ is the set of ordered pairs (a,b) : a Q, b ∑∈ ∈
Example {q,r,s}X{0,1}={(q,0),(q,1),(r,0),(r,1),(s,0),(s,1)}
![Page 41: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/41.jpg)
●Example: above DFA is 5-tuple (Q, Σ, δ, q0, F) where●Q = { q0, q1}●Σ = {0,1}●δ(q0 ,0) = ?
q0 q11
0 0
1
![Page 42: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/42.jpg)
●Example: above DFA is 5-tuple (Q, Σ, δ, q0, F) where●Q = { q0, q1}●Σ = {0,1}●δ(q0 ,0) = q0 δ(q0 ,1) = ?
q0 q11
0 0
1
![Page 43: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/43.jpg)
●Example: above DFA is 5-tuple (Q, Σ, δ, q0, F) where●Q = { q0, q1}●Σ = {0,1}●δ(q0 ,0) = q0 δ(q0 ,1) = q1
δ(q1 ,0) = q1 δ(q1 ,1) = q0●q0 in Q is the start state●F = ?
q0 q11
0 0
1
![Page 44: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/44.jpg)
●Example: above DFA is 5-tuple (Q, Σ, δ, q0, F) where●Q = { q0, q1}●Σ = {0,1}●δ(q0 ,0) = q0 δ(q0 ,1) = q1
δ(q1 ,0) = q1 δ(q1 ,1) = q0●q0 in Q is the start state●F = { q0} ⊆ Q is the set of accept states
q0 q11
0 0
1
![Page 45: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/45.jpg)
●Definition: A DFA (Q, Σ, δ, q0, F) accepts a string w if
●w = w1 w2 … wk where, ∀ 1 ≤ i ≤ k, wi is in Σ
(the k symbols of w)
●∃ sequence of k+1 states r0, r1, .., rk in Q such that:● r0 = q0● ri+1 = δ(ri ,wi+1 ) ∀ 0 ≤ i < k● rk is in F(ri = state DFA is in after reading i-th symbol in w)
![Page 46: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/46.jpg)
●Above DFA (Q, Σ, δ, q0, F) accepts w = 011
q0 q11
0 0
1Example
![Page 47: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/47.jpg)
●Above DFA (Q, Σ, δ, q0, F) accepts w = 011● w = 011 = w1 w2 w3 w1 = 0 w2 = 1 w3 = 1
q0 q11
0 0
1Example
![Page 48: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/48.jpg)
●Above DFA (Q, Σ, δ, q0, F) accepts w = 011● w = 011 = w1 w2 w3 w1 = 0 w2 = 1 w3 = 1
WE MUST SHOW THAT●∃ sequence of 3+1=4 states r0, r1, r2, r3 in Q that:● r0 = q0● ri+1 = δ(ri ,wi+1 ) ∀ 0 ≤ i < 3● r3 is in F
q0 q11
0 0
1Example
![Page 49: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/49.jpg)
●Above DFA (Q, Σ, δ, q0, F) accepts w = 011● w = 011 = w1 w2 w3 w1 = 0 w2 = 1 w3 = 1●consider 4 states r0 := ?
q0 q11
0 0
1Example
![Page 50: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/50.jpg)
●Above DFA (Q, Σ, δ, q0, F) accepts w = 011● w = 011 = w1 w2 w3 w1 = 0 w2 = 1 w3 = 1●consider 4 states r0 := q0 r1 := ?● r0 = q0 OK
q0 q11
0 0
1Example
![Page 51: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/51.jpg)
●Above DFA (Q, Σ, δ, q0, F) accepts w = 011● w = 011 = w1 w2 w3 w1 = 0 w2 = 1 w3 = 1●consider 4 states r0 := q0 r1 := q0 r2:= ?● r0 = q0 OK● r1 = δ(r0 ,w1 )=δ(q0 ,0 ) = q0 OK
q0 q11
0 0
1Example
![Page 52: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/52.jpg)
●Above DFA (Q, Σ, δ, q0, F) accepts w = 011● w = 011 = w1 w2 w3 w1 = 0 w2 = 1 w3 = 1●consider 4 states r0 := q0 r1 := q0 r2:= q1 r3:= ?● r0 = q0 OK● r1 = δ(r0 ,w1 )=δ(q0 ,0 ) = q0 OK● r2 = δ(r1 ,w2 )=δ(q0 ,1 ) = q1 OK
q0 q11
0 0
1Example
![Page 53: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/53.jpg)
●Above DFA (Q, Σ, δ, q0, F) accepts w = 011● w = 011 = w1 w2 w3 w1 = 0 w2 = 1 w3 = 1●consider 4 states r0 := q0 r1 := q0 r2:= q1 r3:= q0 :● r0 = q0 OK● r1 = δ(r0 ,w1 )=δ(q0 ,0 ) = q0 OK● r2 = δ(r1 ,w2 )=δ(q0 ,1 ) = q1 OK● r3 = δ(r2 ,w3 )=δ(q1 ,1 ) = q0 OK● r3 = q0 in F OK DONE!
q0 q11
0 0
1Example
![Page 54: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/54.jpg)
● Definition: For a DFA M, we denote by L(M) the set of strings accepted by M: L(M) := { w : M accepts w} We say M accepts or recognizes the language L(M)
● Definition: A language L is regular if ∃ DFA M : L(M) = L
![Page 55: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/55.jpg)
In the next lectures we want to:
● Understand power of regular languages
● Develop alternate, compact notation to specify regular languages
Example: Unix command grep '\<c.*h\>' fileselects all words starting with c and ending with h in file
![Page 56: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/56.jpg)
● Understand power of regular languages:
● Suppose A, B are regular languages, what about● not A := { w : w is not in A }● A U B := { w : w in A or w in B }● A o B := { w1 w2 : w1 in A and w2 in B }● A* := { w1 w2 … wk : k ≥ 0 , wi in A for every i }
● Are these languages regular?
![Page 57: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/57.jpg)
● Understand power of regular languages:
● Suppose A, B are regular languages, what about● not A := { w : w is not in A }● A U B := { w : w in A or w in B }● A o B := { w1 w2 : w1 in A and w2 in B }● A* := { w1 w2 … wk : k ≥ 0 , wi in A for every i }
● Terminology: Are regular languages closed under not, U, o, * ?
![Page 58: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/58.jpg)
●Theorem: If A is a regular language, then so is (not A)
![Page 59: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/59.jpg)
●Theorem: If A is a regular language, then so is (not A)
●Proof idea: ?????????? the set of accept states
![Page 60: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/60.jpg)
●Theorem: If A is a regular language, then so is (not A)
●Proof idea: Complement the set of accept states
![Page 61: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/61.jpg)
●Theorem: If A is a regular language, then so is (not A)
●Proof idea: Complement the set of accept states●Example:
q0 q11
0 0
1
L(M) =
{ w : w has even number of 1}
M :=
![Page 62: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/62.jpg)
●Theorem: If A is a regular language, then so is (not A)
●Proof idea: Complement the set of accept states●Example:
q0 q11
0 0
1
L(M) =
{ w : w has even number of 1}
M :=q0 q1
10 0
1M' :=
L(M') = not L(M) =
{ w : w has odd number of 1}
![Page 63: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/63.jpg)
●Theorem: If A is a regular language, then so is (not A)
●Formal construction:Given DFA M = (Q, Σ, δ, q0, F) such that L(M) = AConstruct DFA M' = (Q, Σ, δ, q0, F')
F' := not F
●L(M') = not A because M' accepts w M does not accept w
![Page 64: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/64.jpg)
●Theorem: If A is a regular language, then so is (not A)
●Formal construction:Given DFA M = (Q, Σ, δ, q0, F) such that L(M) = AConstruct DFA M' = (Q, Σ, δ, q0, F')
F' := not F
●L(M') = not A because M' accepts w M does not accept w
Use formal definitionof accept to see this!
![Page 65: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/65.jpg)
Example ∑ = {0,1}
M =
L(M) = ∑2 = {00,01,10,11}
What is a DFA M' :L(M') = not ∑2 = all strings except those of length 2 ?
0,10,1
![Page 66: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/66.jpg)
Example ∑ = {0,1}
M' =
L(M') = not ∑2 = {0,1}* - {00,01,10,11}
Do not forget the convention about the sink state!
0,10,1 0,10,1 0,10,1
![Page 67: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/67.jpg)
● Suppose A, B are regular languages, what about● not A := { w : w is not in A } REGULAR● A U B := { w : w in A or w in B }● A o B := { w1 w2 : w1 in A and w2 in B }● A* := { w1 w2 … wk : k ≥ 0 , wi in A for every i }
● Other three are more complicated!
●Plan: we introduce NFA prove that NFA are equivalent to DFA prove A U B, A o B, A* regular, using NFA
![Page 68: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/68.jpg)
Non deterministic finite automata (NFA)
● DFA: given state and input symbol, unique choice for next state,deterministic:
●Next we allow multiple choices,non-deterministic
●We also allow ε-transitions:can follow without reading anything
1
1
1
ε
![Page 69: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/69.jpg)
Example of NFA
Intuition of how it computes:●Accept string w if there is a way to follow transitionsthat ends in accept state
●Transitions labelled with symbol in Σ = {a,b} must be matched with input
●ε transitions can be followed without matching
q0
q1q2
ε
a,b
b
a
a
![Page 70: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/70.jpg)
Example of NFA
Example:● Accept a (first follow ε-transition )● Accept baaa
q0
q1q2
ε
a,b
b
a
a
![Page 71: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/71.jpg)
ANOTHER Example of NFA
q0
q1
q2
q3ε
b
b
a,b
a
b
Example:● Accept bab (two accepting paths, one uses the ε-transition)
● Reject ba (two possible paths, but neither has final state = q
1)
![Page 72: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/72.jpg)
●Definition: A non-deterministic finite automaton (NFA) is a 5-tuple (Q, Σ, δ, q0, F) where
●Q is a finite set of states●Σ is the input alphabet●δ : Q X (Σ U {ε} ) → Powerset(Q)●q0 in Q is the start state●F ⊆ Q is the set of accept states
●Recall: Powerset(Q) = set of all subsets of QExample: Powerset({1,2}) = ?
![Page 73: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/73.jpg)
●Definition: A non-deterministic finite automaton (NFA) is a 5-tuple (Q, Σ, δ, q0, F) where
●Q is a finite set of states●Σ is the input alphabet●δ : Q X (Σ U {ε} ) → Powerset(Q)●q0 in Q is the start state●F ⊆ Q is the set of accept states
●Recall: Powerset(Q) = set of all subsets of QExample: Powerset({1,2}) = {∅, {1}, {2}, {1,2} }
![Page 74: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/74.jpg)
●Example: above NFA is 5-tuple (Q, Σ, δ, q0, F) where●Q = { q0, q1}●Σ = {0,1}●δ(q0 ,0) = ?
q0 q1ε0, 1
1
![Page 75: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/75.jpg)
●Example: above NFA is 5-tuple (Q, Σ, δ, q0, F) where●Q = { q0, q1}●Σ = {0,1}●δ(q0 ,0) = {q0} δ(q0 ,1) = ?
q0 q1ε0, 1
1
![Page 76: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/76.jpg)
●Example: above NFA is 5-tuple (Q, Σ, δ, q0, F) where●Q = { q0, q1}●Σ = {0,1}●δ(q0 ,0) = {q0} δ(q0 ,1) = {q0, q1} δ(q0 ,ε) = ?
q0 q1ε0, 1
1
![Page 77: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/77.jpg)
●Example: above NFA is 5-tuple (Q, Σ, δ, q0, F) where●Q = { q0, q1}●Σ = {0,1}●δ(q0 ,0) = {q0} δ(q0 ,1) = {q0, q1} δ(q0 ,ε) = ∅δ(q1 ,0) = ?
q0 q1ε0, 1
1
![Page 78: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/78.jpg)
●Example: above NFA is 5-tuple (Q, Σ, δ, q0, F) where●Q = { q0, q1}●Σ = {0,1}●δ(q0 ,0) = {q0} δ(q0 ,1) = {q0, q1} δ(q0 ,ε) = ∅δ(q1 ,0) = ∅ δ(q1 ,1) = ?
q0 q1ε0, 1
1
![Page 79: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/79.jpg)
●Example: above NFA is 5-tuple (Q, Σ, δ, q0, F) where●Q = { q0, q1}●Σ = {0,1}●δ(q0 ,0) = {q0} δ(q0 ,1) = {q0, q1} δ(q0 ,ε) = ∅δ(q1 ,0) = ∅ δ(q1 ,1) = ∅ δ(q1 ,ε) = ?
q0 q1ε0, 1
1
![Page 80: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/80.jpg)
●Example: above NFA is 5-tuple (Q, Σ, δ, q0, F) where●Q = { q0, q1}●Σ = {0,1}●δ(q0 ,0) = {q0} δ(q0 ,1) = {q0, q1} δ(q0 ,ε) = ∅δ(q1 ,0) = ∅ δ(q1 ,1) = ∅ δ(q1 ,ε) = {q1}
●q0 in Q is the start state●F = ?
q0 q1ε0, 1
1
![Page 81: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/81.jpg)
●Example: above NFA is 5-tuple (Q, Σ, δ, q0, F) where●Q = { q0, q1}●Σ = {0,1}●δ(q0 ,0) = {q0} δ(q0 ,1) = {q0, q1} δ(q0 ,ε) = ∅δ(q1 ,0) = ∅ δ(q1 ,1) = ∅ δ(q1 ,ε) = {q0}
●q0 in Q is the start state●F = { q1} ⊆ Q is the set of accept states
q0 q1ε0, 1
1
![Page 82: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/82.jpg)
●Definition: A NFA (Q, Σ, δ, q0, F) accepts a string w if∃ integer k, k strings ∃ w1 , w2 , …, wk such that
●w = w1 w2 … wk where ∀ 1 ≤ i ≤ k, wi ∈ Σ U {ε}
(the symbols of w, or ε)
●∃ sequence of k+1 states r0, r1, .., rk in Q such that:● r0 = q0
● ri+1 ∈ δ(ri ,wi+1 ) ∀ 0 ≤ i < k● rk is in F
●Differences with DFA are in green
![Page 83: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/83.jpg)
Back to first example NFA:q0
q1q2
ε
a,b
b
a
a
Accepts w = baaa w
1 = b, w
2 = a, w
3 = a, w
4= ε, w
5 = a
Accepting sequence of 5+1 = 6 states: r
0 = ?
![Page 84: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/84.jpg)
Back to first example NFA:q0
q1q2
ε
a,b
b
a
a
Accepts w = baaa w
1 = b, w
2 = a, w
3 = a, w
4= ε, w
5 = a
Accepting sequence of 5+1 = 6 states: r
0 = q
0, r
1 = ?
![Page 85: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/85.jpg)
Back to first example NFA:q0
q1q2
ε
a,b
b
a
a
Accepts w = baaa w
1 = b, w
2 = a, w
3 = a, w
4= ε, w
5 = a
Accepting sequence of 5+1 = 6 states: r
0 = q
0, r
1 = q
1, r
2 = ?
Transitions:r1 ∈ δ(r
0,b) = {q
1}
![Page 86: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/86.jpg)
Back to first example NFA:q0
q1q2
ε
a,b
b
a
a
Accepts w = baaa w
1 = b, w
2 = a, w
3 = a, w
4= ε, w
5 = a
Accepting sequence of 5+1 = 6 states: r
0 = q
0, r
1 = q
1, r
2 = q
2, r
3 = ?
Transitions:r1 ∈ δ(r
0,b) = {q
1} r2 ∈ δ(r
1,a) = {q
1,q
2}
![Page 87: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/87.jpg)
Back to first example NFA:q0
q1q2
ε
a,b
b
a
a
Accepts w = baaa w
1 = b, w
2 = a, w
3 = a, w
4= ε, w
5 = a
Accepting sequence of 5+1 = 6 states: r
0 = q
0, r
1 = q
1, r
2 = q
2, r
3 = q
0, r
4 = ?
Transitions:r1 ∈ δ(r
0,b) = {q
1} r2 ∈ δ(r
1,a) = {q
1,q
2}
r3 ∈ δ(r2,a) = {q
0}
![Page 88: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/88.jpg)
Back to first example NFA:q0
q1q2
ε
a,b
b
a
a
Accepts w = baaa w
1 = b, w
2 = a, w
3 = a, w
4= ε, w
5 = a
Accepting sequence of 5+1 = 6 states: r
0 = q
0, r
1 = q
1, r
2 = q
2, r
3 = q
0, r
4 = q
2, r
5 = ?
Transitions:r1 ∈ δ(r
0,b) = {q
1} r2 ∈ δ(r
1,a) = {q
1,q
2}
r3 ∈ δ(r2,a) = {q
0} r4 ∈ δ(r
3,ε) = {q
2}
![Page 89: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/89.jpg)
Back to first example NFA:q0
q1q2
ε
a,b
b
a
a
Accepts w = baaa w
1 = b, w
2 = a, w
3 = a, w
4= ε, w
5 = a
Accepting sequence of 5+1 = 6 states: r
0 = q
0, r
1 = q
1, r
2 = q
2, r
3 = q
0, r
4 = q
2, r
5 = q
0
Transitions:r1 ∈ δ(r
0,b) = {q
1} r2 ∈ δ(r
1,a) = {q
1,q
2}
r3 ∈ δ(r2,a) = {q
0} r4 ∈ δ(r
3,ε) = {q
2} r5 ∈ δ(r
4,a) = {q
0}
![Page 90: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/90.jpg)
●NFA are at least as powerful as DFA, because DFA are a special case of NFA
●Are NFA more powerful than DFA?
●Surprisingly, they are not:
●Theorem:For every NFA N there is DFA M : L(M) = L(N)
![Page 91: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/91.jpg)
●Theorem:For every NFA N there is DFA M : L(M) = L(N)
●Construction without ε transitions●Given NFA N (Q, Σ, δ, q, F)●Construct DFA M (Q', Σ, δ', q', F') where:●Q' := Powerset(Q)●q' = {q}●F' = { S : S ∈ Q' and S contains an element of F}● δ'(S, a) := Us ∈ S δ(s,a)
= { t : t ∈ δ (s,a) for some s ∈ S }
![Page 92: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/92.jpg)
●It remains to deal with ε transitions
●Definition: Let S be a set of states.E(S) := { q : q can be reached from some state s in S traveling along 0 or more ε transitions }
●We think of following ε transitions at beginning, or right after reading an input symbol in Σ
![Page 93: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/93.jpg)
●Theorem:For every NFA N there is DFA M : L(M) = L(N)
●Construction including ε transitions●Given NFA N (Q, Σ, δ, q, F)●Construct DFA M (Q', Σ, δ', q', F') where:●Q' := Powerset(Q)●q' = E({q})●F' = { S : S ∈ Q' and S contains an element of F}● δ'(S, a) := E( Us ∈ S δ(s,a) )
= { t : t ∈ E( δ (s,a) ) for some s ∈ S }
![Page 94: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/94.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA DFA
1{1,3}
{2} {2,3}
{3} ∅
{1,2,3}
{1} {1,2}
QDFA
= Powerset(QNFA
)
= Powerset({1,2,3}) = {∅,{1},{2},{3},{1,2}...}
![Page 95: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/95.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
1
2 3
NFA DFA
qDFA
= E({qNFA
})
= E({1}) = {1,3}
{1,3}
{2} {2,3}
{3} ∅
{1,2,3}
{1} {1,2}
![Page 96: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/96.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA
1
FDFA
= {S : S contains an element of F
NFA}
DFA
{1,3}
{2} {2,3}
{3} ∅
{1,2,3}
{1} {1,2}
![Page 97: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/97.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA
1
δDFA
({1}, a) = E(δ
ΝFA(1, a))
= E(∅) = ∅
DFA
{1,3}
{2} {2,3}
{3} ∅
{1,2,3}
a{1} {1,2}
![Page 98: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/98.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA
1
δDFA
({1}, b) = E(δ
ΝFA(1, b))
= E({2}) = {2}
DFA
{1,3}
{2} {2,3}
{3} ∅
{1,2,3}
ab
{1} {1,2}
![Page 99: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/99.jpg)
a
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA
1
δDFA
({2}, a) = E(δ
ΝFA(2, a))
= E({2,3}) = {2,3}
DFA
{1,3}
{2} {2,3}
{3} ∅
{1,2,3}
ab
{1} {1,2}
![Page 100: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/100.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA
1
δDFA
({2}, b) = E(δ
ΝFA(2, b))
= E({3}) = {3}
DFA
{1,3}
{2} {2,3}a
{3}
b
∅
{1,2,3}
ab
{1} {1,2}
![Page 101: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/101.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA
1
δDFA
({3}, a) = E(δ
ΝFA(3, a))
= E({1}) = {1,3}
DFA
{1,3}
{2} {2,3}a
{3}
b
a∅
{1,2,3}
ab
{1} {1,2}
![Page 102: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/102.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA
1
δDFA
({3}, b) = E(δ
ΝFA(3, b))
= E(∅) = ∅
DFA
{1,3}
{2} {2,3}a
{3}
b
a∅b
{1,2,3}
ab
{1} {1,2}
![Page 103: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/103.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA
1
δDFA
({2,3}, a) = E(δ
ΝFA(2,a) U δ
ΝFA(3,a))
= E({2,3} U {1}) = {1,2,3}
DFA
{1,3}
{2} {2,3}a
{3}
b
a∅b
{1,2,3}a
ab
{1} {1,2}
![Page 104: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/104.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA
1
δDFA
({2,3}, b) = E(δ
ΝFA(2,b) U δ
ΝFA(3,b))
= E({3} U ∅) = {3}
DFA
{1,3}
{2} {2,3}a
{3}
b
a∅b
{1,2,3}
b
a
ab
{1} {1,2}
![Page 105: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/105.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA
1
δDFA
({1,3}, a) = E(δ
ΝFA(1,a) U δ
ΝFA(3,a))
= E(∅ U {1}) = {1,3}
DFA
{1,3}
a
{2} {2,3}a
{3}
b
a∅b
{1,2,3}
b
a
ab
{1} {1,2}
![Page 106: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/106.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA
1
δDFA
({1,3}, b) = E(δ
ΝFA(1,b) U δ
ΝFA(3,b))
= E({2} U ∅) = {2}
DFA
{1,3}
a
b
{2} {2,3}a
{3}
b
a∅b
{1,2,3}
b
a
ab
{1} {1,2}
![Page 107: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/107.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA DFA
1
δDFA
({1,2}, a) = E(δ
ΝFA(1,a) U δ
ΝFA(2,a))
= E(∅ U {2,3}) = {2,3}
{1,3}
a
b
{2} {2,3}a
{3}
b
a∅b
{1,2,3}
b
a
aab
{1} {1,2}
![Page 108: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/108.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA DFA
1
δDFA
({1,2}, b) = E(δ
ΝFA(1,b) U δ
ΝFA(2,b))
= E({2} U {3}) = {2,3}
{1,3}
a
b
{2} {2,3}a
{3}
b
a∅b
{1,2,3}
b
a
aa,bb
{1} {1,2}
![Page 109: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/109.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA DFA
1
δDFA
({1,2,3}, a)
=E(δΝFA
(1,a) U δΝFA
(2,a) U δΝFA
(3,a))
=E(∅ U {2,3} U {1}) = {1,2,3}
{1,3}
a
b
{2} {2,3}a
{3}
b
a∅b
{1,2,3}
b
a
a
aa,bb
{1} {1,2}
![Page 110: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/110.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA DFA
1
δDFA
({1,2,3}, b)
=E(δΝFA
(1,b) U δΝFA
(2,b) U δΝFA
(3,b))
=E({2} U {3} U ∅) = {2,3}
{1,3}
a
b
{2} {2,3}a
{3}
b
a∅b
{1,2,3}
b
a
b
a
aa,bb
{1} {1,2}
![Page 111: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/111.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA DFA
1
δDFA
(∅, a) = ∅ δ
DFA(∅, b) = ∅
{1,3}
a
b
{2} {2,3}a
{3}
b
a∅b
{1,2,3}
b
a
b
a
aa,bb
{1} {1,2}
a,b
![Page 112: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/112.jpg)
Example: NFA → DFA conversion
ε
a,b
ba a
2 3
NFA DFA
1
We can delete theunreachable states.
{1,3}
a
b
{2} {2,3}a
{3}
b
a∅b
{1,2,3}
b
a
b
a
a,b
![Page 113: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/113.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
3
1 2
εab
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
QDFA
= Powerset(QNFA
)
= Powerset({1,2,3}) = {∅,{1},{2},{3},{1,2}...}
![Page 114: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/114.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
3
1 2
εab
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
qDFA
= E({qNFA
})
= E({1}) = {1}
![Page 115: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/115.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
3
1 2
εab
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
FDFA
= {S : S contains an element of F
NFA}
![Page 116: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/116.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
a
3
1 2
εab
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
δDFA
({1}, a) = E(δ
ΝFA(1, a))
= E(∅) = ∅
![Page 117: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/117.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
ba
3
1 2
εab
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
δDFA
({1}, b) = E(δ
ΝFA(1, b))
= E({2,3}) = {1,2,3}
![Page 118: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/118.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
ba
a
3
1 2
εab
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
δDFA
({2}, a) = E(δ
ΝFA(2, a))
= E({3}) = {1,3}
![Page 119: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/119.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
ba
ba
3
1 2
εab
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
δDFA
({2}, b) = E(δ
ΝFA(2, b))
= E(∅) = ∅
![Page 120: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/120.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa
ba
3
1 2
εab
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
δDFA
({3}, a) = E(δ
ΝFA(3, a))
= E(∅) = ∅
![Page 121: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/121.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
ba
3
1 2
εab
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
δDFA
({3}, b) = E(δ
ΝFA(3, b))
= E(∅) = ∅
![Page 122: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/122.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
ba
3
1 2
εab
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
δDFA
({1,2}, a) = E(δ
ΝFA(1,a) U δ
ΝFA(2,a))
= E(∅ U {3}) = {1,3}
![Page 123: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/123.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
ba
3
1 2
εab
b
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
δDFA
({1,2}, b) = E(δ
ΝFA(1,b) U δ
ΝFA(2,b))
= E({2,3} U ∅) = {1,2,3}
![Page 124: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/124.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
aba
3
1 2
εab
b
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
δDFA
({1,3}, a) = E(δ
ΝFA(1,a) U δ
ΝFA(3,a))
= E(∅ U ∅) = ∅
![Page 125: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/125.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
a bba
3
1 2
εab
b
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
δDFA
({1,3}, b) = E(δ
ΝFA(1,b) U δ
ΝFA(3,b))
= E({2,3} U ∅) = {1,2,3}
![Page 126: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/126.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
a bba
3
1 2
εab
b
a
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
δDFA
({2,3}, a) = E(δ
ΝFA(2,a) U δ
ΝFA(3,a))
= E({3} U ∅) = {1,3}
![Page 127: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/127.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
a bba
3
1 2
εab
b
b
a
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
δDFA
({2,3}, b) = E(δ
ΝFA(2,b) U δ
ΝFA(3,b))
= E(∅ U ∅) = ∅
![Page 128: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/128.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
a abba
3
1 2
εab
b
b
a
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
δDFA
({1,2,3}, a)
=E(δΝFA
(1,a) U δΝFA
(2,a) U δΝFA
(3,a))
=E(∅ U {3} U ∅) = {1,3}
![Page 129: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/129.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
a abba
3
1 2
εab
b
b
a
b
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
δDFA
({1,2,3}, b)
=E(δΝFA
(1,b) U δΝFA
(2,b) U δΝFA
(3,b))
=E({2,3} U ∅ U ∅) = {1,2,3}
![Page 130: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/130.jpg)
{1}
∅ {1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
a abba
3
1 2
a
b
a
b
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
ε
b
b
δDFA
(∅, a) = ∅ δ
DFA(∅, b) = ∅
a,b
![Page 131: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/131.jpg)
{1}
∅ {1,2,3}
{1,3}
ba
a ab3
1 2
εab
bb
ANOTHER Example: NFA → DFA conversion
NFA DFA
We can delete theunreachable states.
a,b
![Page 132: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/132.jpg)
Summary: NFA and DFA recognize the same languages
We now return to the question:● Suppose A, B are regular languages, what about● not A := { w : w is not in A } REGULAR● A U B := { w : w in A or w in B }● A o B := { w1 w2 : w1 in A and w2 in B }● A* := { w1 w2 … wk : k ≥ 0 , wi in A for every i }
![Page 133: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/133.jpg)
Theorem: If A, B are regular languages, then so is A U B := { w : w in A or w in B }
●Proof idea: Given DFA MA : L(MA) = A, DFA MB : L(MB) = B,
●Construct NFA N : L(N) = A U B
U =
ε
ε
MA MB
N
![Page 134: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/134.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A, DFA MB = (QB, Σ, δB, qB, FB) : L(MB) = B,
●Construct NFA N = (Q, Σ, δ, q, F) where:●Q := ?
U =εε
MA MBN
![Page 135: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/135.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A, DFA MB = (QB, Σ, δB, qB, FB) : L(MB) = B,
●Construct NFA N = (Q, Σ, δ, q, F) where:●Q := {q} U QA U QB , F := ?
U =εε
MA MBN
![Page 136: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/136.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A, DFA MB = (QB, Σ, δB, qB, FB) : L(MB) = B,
●Construct NFA N = (Q, Σ, δ, q, F) where:●Q := {q} U QA U QB , F := FA U FB●δ(r,x) := { δA(r,x) } if r in QA and x ≠ ε●δ(r,x) := ? if r in QB and x ≠ ε
U =εε
MA MBN
![Page 137: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/137.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A, DFA MB = (QB, Σ, δB, qB, FB) : L(MB) = B,
●Construct NFA N = (Q, Σ, δ, q, F) where:●Q := {q} U QA U QB , F := FA U FB●δ(r,x) := { δA(r,x) } if r in QA and x ≠ ε●δ(r,x) := { δB(r,x) } if r in QB and x ≠ ε●δ(q,ε) := ?
U =εε
MA MBN
![Page 138: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/138.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A, DFA MB = (QB, Σ, δB, qB, FB) : L(MB) = B,
●Construct NFA N = (Q, Σ, δ, q, F) where:●Q := {q} U QA U QB , F := FA U FB●δ(r,x) := { δA(r,x) } if r in QA and x ≠ ε●δ(r,x) := { δB(r,x) } if r in QB and x ≠ ε●δ(q,ε) := {qA, qB}●We have L(N) = A U B
U =εε
MA MBN
![Page 139: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/139.jpg)
Example
Is L = {w in {0,1}* : |w| is divisible by 3 OR w starts with a 1} regular?
![Page 140: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/140.jpg)
Example
Is L = {w in {0,1}* : |w| is divisible by 3 OR w starts with a 1} regular?
OR is like U, so try to write L = L1 U L
2
where L1, L
2 are regular
![Page 141: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/141.jpg)
Example
Is L = {w in {0,1}* : |w| is divisible by 3 OR w starts with a 1} regular?
OR is like U, so try to write L = L1 U L
2
where L1, L
2 are regular
L1 = {w : |w| is div. by 3} L
2 = {w : w starts with a 1}
![Page 142: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/142.jpg)
Example
Is L = {w in {0,1}* : |w| is divisible by 3 OR w starts with a 1} regular?
OR is like U, so try to write L = L1 U L
2
where L1, L
2 are regular
L1 = {w : |w| is div. by 3} L
2 = {w : w starts with a 1}
0,1 0,1
0,1M1 =
L(M1) = L
1
![Page 143: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/143.jpg)
Example
Is L = {w in {0,1}* : |w| is divisible by 3 OR w starts with a 1} regular?
OR is like U, so try to write L = L1 U L
2
where L1, L
2 are regular
L1 = {w : |w| is div. by 3} L
2 = {w : w starts with a 1}
0,1 0,1
0,1M1 =
L(M1) = L
1
0,11M
2 =
L(M2) = L
2
![Page 144: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/144.jpg)
Example
Is L = {w in {0,1}* : |w| is divisible by 3 OR w starts with a 1} regular?
OR is like U, so try to write L = L1 U L
2
where L1, L
2 are regular
L1 = {w : |w| is div. by 3} L
2 = {w : w starts with a 1}
0,1 0,10,1
0,11ε
ε
M = L(M) = L(M
1) U L(M
2)
= L1 U L
2
= L
⇒ L is regular.
![Page 145: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/145.jpg)
We now return to the question:● Suppose A, B are regular languages, then● not A := { w : w is not in A } REGULAR● A U B := { w : w in A or w in B } REGULAR● A o B := { w1 w2 : w1 in A and w2 in B }● A* := { w1 w2 … wk : k ≥ 0 , wi in A for every i }
![Page 146: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/146.jpg)
Theorem: If A, B are regular languages, then so is A o B := { w : w = xy for some
x in A and y in B }.●Proof idea: Given DFAs MA, MB for A, B
construct NFA N : L(N) = A o B.MA MB
o
N
=
ε
εε
![Page 147: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/147.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A, DFA MB = (QB, Σ, δB, qB, FB) : L(MB) = B,
●Construct NFA N = (Q, Σ, δ, q, F) where:●Q := ?
MA MB
o
N
=εεε
![Page 148: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/148.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A, DFA MB = (QB, Σ, δB, qB, FB) : L(MB) = B,
●Construct NFA N = (Q, Σ, δ, q, F) where:●Q := QA U QB , q := ?
MA MB
o
N
=εεε
![Page 149: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/149.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A, DFA MB = (QB, Σ, δB, qB, FB) : L(MB) = B,
●Construct NFA N = (Q, Σ, δ, q, F) where:●Q := QA U QB , q := q
A , F := ?
MA MB
o
N
=εεε
![Page 150: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/150.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A, DFA MB = (QB, Σ, δB, qB, FB) : L(MB) = B,
●Construct NFA N = (Q, Σ, δ, q, F) where:●Q := QA U QB , q := q
A , F := FB
●δ(r,x) := ? if r in QA and x ≠ ε
MA MB
o
N
=εεε
![Page 151: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/151.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A, DFA MB = (QB, Σ, δB, qB, FB) : L(MB) = B,
●Construct NFA N = (Q, Σ, δ, q, F) where:●Q := QA U QB , q := q
A , F := FB
●δ(r,x) := { δA(r,x) } if r in QA and x ≠ ε●δ(r,ε) := ? if r in F
A
MA MB
o
N
=εεε
![Page 152: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/152.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A, DFA MB = (QB, Σ, δB, qB, FB) : L(MB) = B,
●Construct NFA N = (Q, Σ, δ, q, F) where:●Q := QA U QB , q := q
A , F := FB
●δ(r,x) := { δA(r,x) } if r in QA and x ≠ ε●δ(r,ε) := { qB } if r in F
A
●δ(r,x) := ? if r in QB and x ≠ ε
MA MB
o
N
=εεε
![Page 153: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/153.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A, DFA MB = (QB, Σ, δB, qB, FB) : L(MB) = B,
●Construct NFA N = (Q, Σ, δ, q, F) where:●Q := QA U QB , q := q
A , F := FB
●δ(r,x) := { δA(r,x) } if r in QA and x ≠ ε●δ(r,ε) := { qB } if r in F
A
●δ(r,x) := { δB(r,x) } if r in QB and x ≠ ε●We have L(N) = A o B
MA MB
o
N
=εεε
![Page 154: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/154.jpg)
Example
Is L = {w in {0,1}* : w contains a 1 after a 0} regular?
Note: L = {01, 0001001, 111001, … }
![Page 155: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/155.jpg)
Example
Is L = {w in {0,1}* : w contains a 1 after a 0} regular?
Let L0 = {w : w contains a 0}
L1 = {w : w contains a 1}. Then L = L
0 o L
1.
![Page 156: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/156.jpg)
Example
Is L = {w in {0,1}* : w contains a 1 after a 0} regular?
Let L0 = {w : w contains a 0}
L1 = {w : w contains a 1}. Then L = L
0 o L
1.
0
M0 =
L(M0) = L
0
1 0,1
![Page 157: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/157.jpg)
Example
Is L = {w in {0,1}* : w contains a 1 after a 0} regular?
Let L0 = {w : w contains a 0}
L1 = {w : w contains a 1}. Then L = L
0 o L
1.
0
M0 =
L(M0) = L
0
1 0,1
1
M1 =
L(M1) = L
1
0 0,1
![Page 158: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/158.jpg)
Example
0
M =
L(M) = L(M0) o L(M
1) = L
0 o L
1 = L
1 0,1
1
0 0,1
ε
⇒ L is regular.
Is L = {w in {0,1}* : w contains a 1 after a 0} regular?
Let L0 = {w : w contains a 0}
L1 = {w : w contains a 1}. Then L = L
0 o L
1.
![Page 159: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/159.jpg)
We now return to the question:● Suppose A, B are regular languages, then● not A := { w : w is not in A } REGULAR● A U B := { w : w in A or w in B } REGULAR● A o B := { w1 w2 : w1 A and w∈ 2 B } REGULAR∈● A* := { w1 w2 … wk : k ≥ 0 , wi in A for every i }
![Page 160: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/160.jpg)
Theorem: If A is a regular language, then so is A* := { w : w = w
1...w
k, w
i in A for i=1,...,k }
●Proof idea: Given DFA MA : L(MA) = A,
Construct NFA N : L(N) = A*
=ε
MA
N
* εε
![Page 161: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/161.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A,
Construct NFA N = (Q, Σ, δ, q, F) where:●Q := ?
=ε
MA
N
* εε
![Page 162: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/162.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A,
Construct NFA N = (Q, Σ, δ, q, F) where:●Q := {q} U QA , F := ?
=ε
MA
N
* εε
![Page 163: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/163.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A,
Construct NFA N = (Q, Σ, δ, q, F) where:●Q := {q} U QA , F := {q} U FA●δ(r,x) := ? if r in QA and x ≠ ε
=ε
MA
N
* εε
![Page 164: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/164.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A,
Construct NFA N = (Q, Σ, δ, q, F) where:●Q := {q} U QA , F := {q} U FA●δ(r,x) := { δA(r,x) } if r in QA and x ≠ ε●δ(r,ε) := ? if r in {q} U FA
=ε
MA
N
* εε
![Page 165: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/165.jpg)
Construction:●Given DFA MA = (QA, Σ, δA, qA, FA) : L(MA) = A,
Construct NFA N = (Q, Σ, δ, q, F) where:●Q := {q} U QA , F := {q} U FA●δ(r,x) := { δA(r,x) } if r in QA and x ≠ ε●δ(r,ε) := { qA } if r in {q} U FA
●We have L(N) = A*
=ε
MA
N
* εε
![Page 166: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/166.jpg)
Example
Is L = {w in {0,1}* : w has even length} regular?
![Page 167: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/167.jpg)
Example
Is L = {w in {0,1}* : w has even length} regular?
Let L0 = {w : w has length = 2}. Then L = L
0*.
![Page 168: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/168.jpg)
Example
Is L = {w in {0,1}* : w has even length} regular?
Let L0 = {w : w has length = 2}. Then L = L
0*.
M0 =
L(M0) = L
0
0,10,1
![Page 169: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/169.jpg)
Example
Is L = {w in {0,1}* : w has even length} regular?
Let L0 = {w : w has length = 2}. Then L = L
0*.
M =
L(M) = L(M0)* = L
0* = L
0,10,1ε
ε
⇒ L is regular.
![Page 170: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/170.jpg)
We now return to the question:● Suppose A, B are regular languages, then● not A := { w : w is not in A } ● A U B := { w : w in A or w in B }● A o B := { w1 w2 : w1 in A and w2 in B }● A* := { w1 w2 … wk : k ≥ 0 , wi in A for every i }
are all regular!
![Page 171: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/171.jpg)
We now return to the question:● Suppose A, B are regular languages, then● not A := { w : w is not in A } ● A U B := { w : w in A or w in B }● A o B := { w1 w2 : w1 in A and w2 in B }● A* := { w1 w2 … wk : k ≥ 0 , wi in A for every i }
What about A ∩ B := { w : w in A and w in B } ?
![Page 172: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/172.jpg)
We now return to the question:● Suppose A, B are regular languages, then● not A := { w : w is not in A } ● A U B := { w : w in A or w in B }● A o B := { w1 w2 : w1 in A and w2 in B }● A* := { w1 w2 … wk : k ≥ 0 , wi in A for every i }
De Morgan's laws: A ∩ B = not ( (not A) U (not B) )By above, (not A) is regular, (not B) is regular, (not A) U (not B) is regular, not ( (not A) U (not B) ) = A ∩ B regular
![Page 173: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/173.jpg)
We now return to the question:● Suppose A, B are regular languages, then● not A := { w : w is not in A } ● A U B := { w : w in A or w in B }● A o B := { w1 w2 : w1 in A and w2 in B }● A* := { w1 w2 … wk : k ≥ 0 , wi in A for every i }● A ∩ B := { w : w in A and w in B }
are all regular
![Page 174: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/174.jpg)
How to specify a regular language?
Write a picture → complicated
Write down formal definition → complicated δ(q0 ,0) = q0, …
Use symbols from Σ and operations *, o, U → good
({0} * U {1}) o {001}
![Page 175: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/175.jpg)
Regular expressions: anything you can write with∅ , ε , symbols from Σ, and operations *, o, U
Conventions:●Write a instead of {a}●Write AB for A o B●Write ∑ for Ua ∑ ∈ a So if ∑ = {a,b} then ∑ = a U b●Operation * has precedence over o, and o over U so 1 U 01* means 1U(0(1)*)
Example: 110, 0*, Σ*, Σ*001Σ*, (ΣΣ)*, 01 U 10
![Page 176: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/176.jpg)
Definition Regular expressions RE over Σ are: ∅ ε a if a in Σ R R' if R, R' are RE R U R' if R, R' are RE R* if R is RE
![Page 177: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/177.jpg)
Definition The language described by RE: L(∅) = ∅ L(ε) = {ε} L(a) = {a} if a in Σ L(R R') = L(R) o L(R') L(R U R') = L(R) U L(R') L(R*) = L(R)*
![Page 178: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/178.jpg)
Example Σ = { a, b} RE Language● ab U ba ?● a* ● (a U b)* ● a*ba* ● Σ*bΣ* ● Σ*aabΣ* ● (ΣΣ)* ● (a*ba*ba*)* ● a*baba*a∅
![Page 179: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/179.jpg)
Example Σ = { a, b} RE Language● ab U ba {ab, ba}● a* ● (a U b)* ● a*ba* ● Σ*bΣ* ● Σ*aabΣ* ● (ΣΣ)* ● (a*ba*ba*)* ● a*baba*a∅
![Page 180: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/180.jpg)
Example Σ = { a, b} RE Language● ab U ba {ab, ba}● a* {ε, a, aa, … } = { w : w has only a}● (a U b)* ● a*ba* ● Σ*bΣ* ● Σ*aabΣ* ● (ΣΣ)* ● (a*ba*ba*)* ● a*baba*a∅
![Page 181: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/181.jpg)
Example Σ = { a, b} RE Language● ab U ba {ab, ba}● a* {ε, a, aa, … } = { w : w has only a}● (a U b)* all strings ● a*ba* ● Σ*bΣ* ● Σ*aabΣ* ● (ΣΣ)* ● (a*ba*ba*)* ● a*baba*a∅
![Page 182: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/182.jpg)
Example Σ = { a, b} RE Language● ab U ba {ab, ba}● a* {ε, a, aa, … } = { w : w has only a}● (a U b)* all strings ● a*ba* {w : w has exactly one b}● Σ*bΣ* ● Σ*aabΣ* ● (ΣΣ)* ● (a*ba*ba*)* ● a*baba*a∅
![Page 183: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/183.jpg)
Example Σ = { a, b} RE Language● ab U ba {ab, ba}● a* {ε, a, aa, … } = { w : w has only a}● (a U b)* all strings ● a*ba* {w : w has exactly one b}● Σ*bΣ* {w : w has at least one b}● Σ*aabΣ* ● (ΣΣ)* ● (a*ba*ba*)* ● a*baba*a∅
![Page 184: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/184.jpg)
Example Σ = { a, b} RE Language● ab U ba {ab, ba}● a* {ε, a, aa, … } = { w : w has only a}● (a U b)* all strings ● a*ba* {w : w has exactly one b}● Σ*bΣ* {w : w has at least one b}● Σ*aabΣ* {w : w contains the string aab}● (ΣΣ)* ● (a*ba*ba*)* ● a*baba*a∅
![Page 185: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/185.jpg)
Example Σ = { a, b} RE Language● ab U ba {ab, ba}● a* {ε, a, aa, … } = { w : w has only a}● (a U b)* all strings● a*ba* {w : w has exactly one b}● Σ*bΣ* {w : w has at least one b}● Σ*aabΣ* {w : w contains the string aab}● (ΣΣ)* {w : w has even length}● (a*ba*ba*)* ● a*baba*a∅
![Page 186: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/186.jpg)
Example Σ = { a, b} RE Language● ab U ba {ab, ba}● a* {ε, a, aa, … } = { w : w has only a}● (a U b)* all strings● a*ba* {w : w has exactly one b}● Σ*bΣ* {w : w has at least one b}● Σ*aabΣ* {w : w contains the string aab}● (ΣΣ)* {w : w has even length}● (a*ba*ba*)* {w : w contains even number of b}● a*baba*a∅
![Page 187: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/187.jpg)
Example Σ = { a, b} RE Language● ab U ba {ab, ba}● a* {ε, a, aa, … } = { w : w has only a}● (a U b)* all strings● a*ba* {w : w has exactly one b}● Σ*bΣ* {w : w has at least one b}● Σ*aabΣ* {w : w contains the string aab}● (ΣΣ)* {w : w has even length}● (a*ba*ba*)* {w : w contains even number of b}● a*baba*a∅ ∅ (anything o ∅ = ∅)
![Page 188: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/188.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R)
![Page 189: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/189.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R) Construction:● R = ∅ M := ?
![Page 190: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/190.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R) Construction:● R = ∅ M :=
● R = ε M := ?
![Page 191: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/191.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R) Construction:● R = ∅ M :=
● R = ε M :=
● R = a M := ?
![Page 192: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/192.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R) Construction:● R = ∅ M :=
● R = ε M :=
● R = a M :=
● R = R U R' ?
a
![Page 193: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/193.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R) Construction:● R = ∅ M :=
● R = ε M :=
● R = a M :=
● R = R U R' use construction for A U B seen earlier● R = R o R' ?
a
![Page 194: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/194.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R) Construction:● R = ∅ M :=
● R = ε M :=
● R = a M :=
● R = R U R' use construction for A U B seen earlier● R = R o R' use construction for A o B seen earlier● R = R* ?
a
![Page 195: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/195.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R) Construction:● R = ∅ M :=
● R = ε M :=
● R = a M :=
● R = R U R' use construction for A U B seen earlier● R = R o R' use construction for A o B seen earlier● R = R* use construction for A* seen earlier
a
![Page 196: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/196.jpg)
Example: RE → NFA
RE = (ab U a)*
![Page 197: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/197.jpg)
Example: RE → NFA
aMa
=
L(Ma)=L(a)
RE = (ab U a)*
![Page 198: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/198.jpg)
Example: RE → NFA
RE = (ab U a)*
aMa
=
L(Ma)=L(a)
bMb
=
L(Mb)=L(b)
![Page 199: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/199.jpg)
Example: RE → NFA
Mab
=
L(Mab
)=L(ab)
a bε
RE = (ab U a)*
![Page 200: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/200.jpg)
Example: RE → NFA
Mab
=
L(Mab
)=L(ab)
a bε
RE = (ab U a)*
aMa
=
L(Ma)=L(a)
![Page 201: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/201.jpg)
Example: RE → NFA
Mab U a
=
L(Mab U a
)=L(ab U a)
a bε
RE = (ab U a)*
ε
ε a
![Page 202: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/202.jpg)
Example: RE → NFA
M(ab U a)*
=
L(M(ab U a)*
)=L((ab U a)*)=L(RE)
RE = (ab U a)*
a bε
a
ε
εε
ε
ε
![Page 203: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/203.jpg)
ANOTHER Example: RE → NFA
RE =(ε U a)ba*
![Page 204: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/204.jpg)
ANOTHER Example: RE → NFA
Mε
=
L(Mε)=L(ε)
RE =(ε U a)ba*
![Page 205: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/205.jpg)
ANOTHER Example: RE → NFA
Mε
=
L(Mε)=L(ε)
aMa
=
L(Ma)=L(a)
RE =(ε U a)ba*
![Page 206: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/206.jpg)
ANOTHER Example: RE → NFA
Mε U a
=
L(Mε U a
)=L(ε U a)
RE =(ε U a)ba*
ε
εa
![Page 207: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/207.jpg)
ANOTHER Example: RE → NFA
Mε U a
=
L(Mε U a
)=L(ε U a)
bMb
=
L(Mb)=L(b)
RE =(ε U a)ba*
ε
εa
![Page 208: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/208.jpg)
ANOTHER Example: RE → NFA
L(M(ε U a)b
)=L((ε U a)b)
ε
εa
bε
ε
M(ε U a)b
=
RE =(ε U a)ba*
![Page 209: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/209.jpg)
ANOTHER Example: RE → NFA
L(M(ε U a)b
)=L((ε U a)b)
ε
εa
bε
ε
aMa
=
L(Ma)=L(a)
M(ε U a)b
=
RE =(ε U a)ba*
![Page 210: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/210.jpg)
ANOTHER Example: RE → NFA
L(M(ε U a)b
)=L((ε U a)b)
ε
εa
bε
ε
Ma*
=ε
ε
a
L(Ma*)=L(a*)
M(ε U a)b
=
RE =(ε U a)ba*
![Page 211: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/211.jpg)
ANOTHER Example: RE → NFA
RE =(ε U a)ba*
M(ε U a)ba*
=
L(M(ε U a)ba*
)=L((ε U a)ba*)=L(RE)
ε
εa
bε
ε ε a
ε ε
![Page 212: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/212.jpg)
Recap:
Here “⇒” means “can be converted to”
We have seen: RE ⇒ NFA ⇔ DFA
Next we see: DFA ⇒ RE
In two steps: DFA ⇒ Generalized NFA ⇒ RE
![Page 213: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/213.jpg)
Generalized NFA (GNFA)
q0 qaa*b*
a U b*
ab
Nondeterministic
Transitions labelled by RE
Read blocks of input symbols at a time
![Page 214: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/214.jpg)
Generalized NFA (GNFA)
q0 qaa*b*
a U b*
ab
Convention:Unique final stateExactly one transition between each pair of statesexcept nothing going into start state nothing going out of final stateIf arrow not shown in picture, label = ∅
![Page 215: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/215.jpg)
●Definition: A generalized finite automaton (GNFA)● is a 5-tuple (Q, Σ, δ, q0, qa) where●Q is a finite set of states●Σ is the input alphabet●δ : (Q - {qa}) X (Q – {q0}) → Regular Expressions●q0 in Q is the start state●qa in Q is the accept state
![Page 216: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/216.jpg)
●Definition: GNFA (Q, Σ, δ, q0, qa) accepts a string w if● ∃ integer k, k strings w∃ 1 , w2 , …, wk ∈ Σ* such that w = w1 w2 … wk
(divide w in k strings)
●∃ sequence of k+1 states r0, r1, .., rk in Q such that:● r0 = q0● wi+1 ∈L(δ(ri ,ri+1 )) ∀ 0 ≤ i < k● rk = qa
●Differences with NFA are in green
![Page 217: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/217.jpg)
Example
q0 q1 qaa*
b*
ab
Accepts w = aaabbabw1=?
![Page 218: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/218.jpg)
Example
q0 q1 qaa*
b*
ab
Accepts w = aaabbabw1=aaa w2=?
![Page 219: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/219.jpg)
Example
q0 q1 qaa*
b*
ab
Accepts w = aaabbabw1=aaa w2=bb w3=abr0=q0 r1=?
![Page 220: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/220.jpg)
Example
q0 q1 qaa*
b*
ab
Accepts w = aaabbabw1=aaa w2=bb w3=abr0=q0 r1=q1 r2=?
w1 = aaa ∈ L(δ(r0,r1)) = L(δ(q0,q1)) = L(a*)
![Page 221: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/221.jpg)
Example
q0 q1 qaa*
b*
ab
Accepts w = aaabbabw1=aaa w2=bb w3=abr0=q0 r1=q1 r2=q1 r3 = ?
w1 = aaa ∈ L(δ(r0,r1)) = L(δ(q0,q1)) = L(a*)w2 = bb ∈ L(δ(r1,r2)) = L(δ(q1,q1)) = L(b*)
![Page 222: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/222.jpg)
Example
q0 q1 qaa*
b*
ab
Accepts w = aaabbabw1=aaa w2=bb w3=abr0=q0 r1=q1 r2=q1 r3 = qa
w1 = aaa ∈ L(δ(r0,r1)) = L(δ(q0,q1)) = L(a*)w2 = bb ∈ L(δ(r1,r2)) = L(δ(q1,q1)) = L(b*)w3 = ab ∈ L(δ(r2,r3)) = L(δ(q1,qa)) = L(ab)
![Page 223: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/223.jpg)
Theorem: ∀ DFA M ∃ GNFA N : L(N) = L(M)Construction:To ensure unique transition between each pair:
To ensure unique final state, no transitions ingoing start state, no transitions outgoing final state:
1 1 U 0
0
ε
εεε
![Page 224: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/224.jpg)
Theorem: ∀ GNFA N ∃ RE R : L(R) = L(N)Construction:If N has 2 states, then N = thus R := S
q0 qaS
qi qj
R1R2*R3 U R4
If N has > 2 states, eliminate some state qr ≠ q0, qa : for every ordered pair qi, qj (possibly equal) that are connected through q
r
qr qi qjR1 R3
R4
Repeat until 2 states remain
R2
![Page 225: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/225.jpg)
Example: DFA → GNFA → RE
q2q
1
a b
b,c
DFA
![Page 226: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/226.jpg)
Example: DFA → GNFA → RE
q2q
1
a b
b U c
GNFA
q0
qa
ε ε
![Page 227: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/227.jpg)
Example: DFA → GNFA → RE
q2q
1
a b
q0
qa
ε ε
q2
b
q0
qa
ε
b U c
Eliminate q1: re-draw GNFA with all other states
![Page 228: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/228.jpg)
Example: DFA → GNFA → RE
q2q
1
a b
q0
qa
ε ε
q2
b
q0
qa
ε
b U c
Eliminate q1: find a path through q
1
![Page 229: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/229.jpg)
Example: DFA → GNFA → RE
q2q
1
a b
q0
qa
ε ε
q2
b
q0
qa
ε
Eliminate q1: add edge to new GNFA
b U c
ε a* (b U c)
![Page 230: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/230.jpg)
Example: DFA → GNFA → RE
q2q
1
a b
q0
qa
ε ε
q2
b
q0
qa
ε
Eliminate q1: simplify RE on new edge
a* (b U c)
b U c
![Page 231: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/231.jpg)
Example: DFA → GNFA → RE
q2q
1
a b
q0
qa
ε ε
q2
b
q0
qa
ε
Eliminate q1: if no more paths through q
1, start over
a* (b U c)
b U c
![Page 232: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/232.jpg)
Example: DFA → GNFA → RE
q2
b
q0
qa
εa* (b U c)
Eliminate q2: re-draw GNFA with all other states
q0
qa
![Page 233: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/233.jpg)
Example: DFA → GNFA → RE
q2
b
q0
qa
εa* (b U c)
q0
qa
Eliminate q2: find a path through q
2
![Page 234: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/234.jpg)
Example: DFA → GNFA → RE
q2
b
q0
qa
εa* (b U c)
q0
qa
Eliminate q2: add edge to new GNFA
a* (b U c) b* ε
![Page 235: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/235.jpg)
Example: DFA → GNFA → RE
q2
b
q0
qa
εa* (b U c)
q0
qa
Eliminate q2: simplify RE on new edge
a* (b U c) b*
![Page 236: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/236.jpg)
Example: DFA → GNFA → RE
q2
b
q0
qa
εa* (b U c)
q0
qa
Eliminate q2: if no more paths through q
2, start over
a* (b U c) b*
![Page 237: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/237.jpg)
Example: DFA → GNFA → RE
q0
qa
Only two states remain:
RE = a* (b U c) b*
a* (b U c) b*
![Page 238: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/238.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q3
DFA
cc
b
![Page 239: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/239.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qε εq3 a
GNFA
cc
b
![Page 240: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/240.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qε εq3
Eliminate q1:
re-draw GNFA with all other states
a
q0
q2
a
qεq3 a
b
cc
b
![Page 241: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/241.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qε εq3
Eliminate q1:
find a path through q
1
a
q0
q2
a
qεq3 a
cc
b
b
![Page 242: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/242.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qε εq3
Eliminate q1:
add edge to new GNFA
a
q0
q2
a
qεq3 a
cc
ε a*b
b
b
![Page 243: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/243.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qε εq3
Eliminate q1:
find anotherpath through q
1
a
q0
q2
a
qεq3 a
cc
ε a*b
b
b
![Page 244: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/244.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qε εq3
Eliminate q1:
add edge to new GNFA
a
b
q0
q2
a
qεq3 a
cc
ε a*b
ε a*c
b
![Page 245: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/245.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qε εq3
Eliminate q1:
find anotherpath through q
1
a
q0
q2
a
qεq3 a
cc
ε a*b
b
b
ε a*c
![Page 246: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/246.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qε εq3
Eliminate q1:
add edge tonew GNFA
a
q0
q2
a U ca*b
qεq3 a
cc
ε a*b
b
b
ε a*c
don't forget current q
2 → q
3 edge!
![Page 247: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/247.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qε εq3
Eliminate q1:
find anotherpath through q
1
a
q0
q2
qεq3 a
cc
ε a*b
b
b
ε a*c a U ca*b
![Page 248: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/248.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qε εq3 a
q0
q2
qεq3 a
cc
ε a*b
b
b U ca*c
ε a*c a U ca*b
Eliminate q1:
add edge tonew GNFA
don't forget current q
2 → q
2 edge!
![Page 249: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/249.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qε εq3
Eliminate q1:
when no more pathsthrough q
1, start over
(and simplifyREs)
a
q0
q2
qεq3 a
cc
a*b
b
a*c a U ca*b
b U ca*c
![Page 250: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/250.jpg)
ANOTHER Example: DFA → GNFA → RE
qεq3 a
Eliminate q2:
re-draw GNFA with all other states
q0
q2
qεq3 aa*b
a*c a U ca*b
b U ca*c
q0
a*b
![Page 251: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/251.jpg)
ANOTHER Example: DFA → GNFA → RE
qεq3 a
Eliminate q2:
find a path through q2
q0
q2
qεq3 aa*b
a*c a U ca*b
b U ca*c
q0
a*b
![Page 252: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/252.jpg)
ANOTHER Example: DFA → GNFA → RE
q0 qεq
3 a
a*b U a*c(b U ca*c)*(a U ca*b)
Eliminate q2:
add edge to new GNFA
q0
q2
qεq3 aa*b
a*c a U ca*b
b U ca*c
![Page 253: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/253.jpg)
ANOTHER Example: DFA → GNFA → RE
q0 qεq
3 a
a*b U a*c(b U ca*c)*(a U ca*b)
Eliminate q2:
when no more pathsthrough q
2, start over
q0
q2
qεq3 aa*b
a*c a U ca*b
b U ca*c
![Page 254: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/254.jpg)
ANOTHER Example: DFA → GNFA → RE
q0 qεq
3 a
a*b U a*c(b U ca*c)*(a U ca*b)
Eliminate q3:
re-draw GNFA with all other states
q0 qa
![Page 255: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/255.jpg)
ANOTHER Example: DFA → GNFA → RE
q0 qεq
3 a
a*b U a*c(b U ca*c)*(a U ca*b)
Eliminate q3:
find a path through q3
q0 qa
∅
don't forget: no arrow means ∅
![Page 256: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/256.jpg)
ANOTHER Example: DFA → GNFA → RE
q0 qεq
3 a
a*b U a*c(b U ca*c)*(a U ca*b)
Eliminate q3:
add edge to new GNFA
q0 qa
a*b U a*c(b U ca*c)*(a U ca*b) *∅ ε
∅
![Page 257: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/257.jpg)
ANOTHER Example: DFA → GNFA → RE
q0 qεq
3 a
a*b U a*c(b U ca*c)*(a U ca*b)
Eliminate q3:
when no more paths through q3, start over
(and simplify REs)
q0 qa
a*b U a*c(b U ca*c)*(a U ca*b)
don't forget: *= ε∅
![Page 258: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/258.jpg)
ANOTHER Example: DFA → GNFA → RE
q0 qa
a*b U a*c(b U ca*c)*(a U ca*b)
Only two states remain:
RE = a*b U a*c(b U ca*c)*(a U ca*b)
![Page 259: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/259.jpg)
Recap:Here “⇒” means “can be converted to”
RE ⇔ DFA ⇔ NFAAny of the three recognize exactlythe regular languages (initially defined using DFA)
![Page 260: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/260.jpg)
These conversions are used every time you enter an RE, for example for pattern matching using grep
●The RE is converted to an NFA●Then the NFA is converted to a DFA●The DFA representation is used to pattern-match
Optimizations have been devised,but this is still the general approach.
![Page 261: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/261.jpg)
What language is NOT regular?
Is { 0n 1n : n ≥ 0 } = {ε, 01, 0011, 000111, … } regular?
![Page 262: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/262.jpg)
Pumping lemma:L regular language ⇒
Recall y0 = ε, y1 = y, y2 = yy, y3 = yyy, ...
∃ p ≥0∀ w ∈ L, |w| ≥ p∃ x,y,z : w= xyz, |y|> 0, |xy|≤ p∀ i ≥ 0 : xyiz ∈ L
![Page 263: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/263.jpg)
Pumping lemma:L regular language ⇒
We will not see the proof. But here's the idea:p := |Q| for DFA recognizing LIf w ∈ L, |w| ≥ p, then during computation 2 states must be the same q Q∈
y = portion of w that brings back to qcan repeat y and still accept string
∃ p ≥0∀ w ∈ L, |w| ≥ p∃ x,y,z : w= xyz, |y|> 0, |xy|≤ p∀ i ≥ 0 : xyiz ∈ L
![Page 264: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/264.jpg)
Pumping lemma:L regular language ⇒
Useful to prove L NOT regular. Use contrapositive:L regular language ⇒ A same as (not A) ⇒ L not regular
∃ p ≥0∀ w ∈ L, |w| ≥ p∃ x,y,z : w= xyz, |y|> 0, |xy|≤ p∀ i ≥ 0 : xyiz ∈ L
A
![Page 265: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/265.jpg)
Pumping lemma (contrapositive)
⇒ L not regular
To prove L not regular it is enough to prove not A
Not A is the stuff in the box.
∀ p ≥0∃ w ∈ L, |w| ≥ p∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p∃ i ≥ 0 : xyiz ∉ L
not A
![Page 266: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/266.jpg)
Proving something like∀ bla ∃ bla ∀ bla ∃ bla blameans winning a game
Theory is all about winning games!
![Page 267: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/267.jpg)
Example NAME THE BIGGEST NUMBER GAME
● Two players: You, Adversary.● Rules:First Adversary says a number.
Then You say a number. You win if your number is bigger.
Can you win this game?
![Page 268: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/268.jpg)
Example NAME THE BIGGEST NUMBER GAME
● Two players: You, Adversary.● Rules:First Adversary says a number.
Then You say a number. You win if your number is bigger.
You have winning strategy: if adversary says x, you say x+1
![Page 269: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/269.jpg)
Example NAME THE BIGGEST NUMBER GAME
● Two players: You, Adversary. ∃, ∀● Rules:First Adversary says a number. ∀ x ∃ y : y > x
Then You say a number. You win if your number is bigger.
You have winning strategy: Claim is true if adversary says x, you say x+1
![Page 270: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/270.jpg)
Another example:
Theorem: ∀ NFA N ∃ DFA M : L(M) = L(N)
We already saw a winning strategy for this gameWhat is it?
![Page 271: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/271.jpg)
Another example:
Theorem: ∀ NFA N ∃ DFA M : L(M) = L(N)
We already saw a winning strategy for this gameThe power set construction.
![Page 272: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/272.jpg)
Games with more moves:Chess, Checkers, Tic-Tac-Toe
You can win if∀ move of the Adversary∃ move You can make∀ move of the Adversary∃ move You can make…: You checkmate
![Page 273: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/273.jpg)
Pumping lemma (contrapositive)
⇒ L not regular
Rules of the game:Adversary picks p,You pick w L of length ∈ ≥ p,Adversary decomposes w in xyz, where |y| > 0, |xy|≤pYou pick i ≥ 0Finally, you win if xyiz ∉ L
∀ p ≥0∃ w ∈ L, |w| ≥ p∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p∃ i ≥ 0 : xyiz ∉ L
![Page 274: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/274.jpg)
Theorem: L := {0n 1n : n ≥ 0} is not regularProof:Use pumping lemmaAdversary moves pYou move w := 0p 1p
Adversary moves x,y,zYou move i := 2You must show xyyz ∉ L:Since |xy|≤p and w = xyz = 0p 1p , y only has 0So xyyz = 0p + |y| 1p
Since |y| > 0, this is not of the form 0n 1n DONE
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 275: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/275.jpg)
Theorem: L := {w : w has as many 0 as 1} not regularSame Proof:Use pumping lemmaAdversary moves pYou move w := ?
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 276: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/276.jpg)
Theorem: L := {w : w has as many 0 as 1} not regularSame Proof:Use pumping lemmaAdversary moves pYou move w := 0p 1p
Adversary moves x,y,zYou move i := ?
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 277: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/277.jpg)
Theorem: L := {w : w has as many 0 as 1} not regularSame Proof:Use pumping lemmaAdversary moves pYou move w := 0p 1p
Adversary moves x,y,zYou move i := 2You must show xyyz ∉ L:Since |xy|≤p and w = xyz = 0p 1p , y only has 0So xyyz = ?
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 278: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/278.jpg)
Theorem: L := {w : w has as many 0 as 1} not regularSame Proof:Use pumping lemmaAdversary moves pYou move w := 0p 1p
Adversary moves x,y,zYou move i := 2You must show xyyz ∉ L:Since |xy|≤p and w = xyz = 0p 1p , y only has 0So xyyz = 0p + |y| 1p
Since |y| > 0, not as many 0 as 1 DONE
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 279: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/279.jpg)
Theorem: L := {0j 1k : j > k} is not regularProof:Use pumping lemmaAdversary moves pYou move w := ?
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 280: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/280.jpg)
Theorem: L := {0j 1k : j > k} is not regularProof:Use pumping lemmaAdversary moves pYou move w := 0p+1 1p
Adversary moves x,y,zYou move i := ?
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 281: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/281.jpg)
Theorem: L := {0j 1k : j > k} is not regularProof:Use pumping lemmaAdversary moves pYou move w := 0p+1 1p
Adversary moves x,y,zYou move i := 0You must show xz ∉ L:Since |xy|≤p and w = xyz = 0p+1 1p , y only has 0So xz = 0p + 1 - |y| 1p
Since |y| > 0, this is not of the form 0j 1k with j > k
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 282: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/282.jpg)
Theorem: L := {uu : u ∈ {0,1}* } is not regularProof:Use pumping lemmaAdversary moves pYou move w := ?
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 283: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/283.jpg)
Theorem: L := {uu : u ∈ {0,1}* } is not regularProof:Use pumping lemmaAdversary moves pYou move w := 0p1 0p 1Adversary moves x,y,zYou move i := ?
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 284: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/284.jpg)
Theorem: L := {uu : u ∈ {0,1}* } is not regularProof:Use pumping lemmaAdversary moves pYou move w := 0p 1 0p 1Adversary moves x,y,zYou move i := 2You must show xyyz ∉ L:Since |xy|≤p and w = xyz = 0p 1 0p 1 , y only has 0So xyyz = 0p + |y| 1 0p 1Since |y| > 0, first half of xyyz only 0, so xyyz ∉ L
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 285: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/285.jpg)
Theorem: L := { 1n2 : n ≥ 0 } is not regular
Proof:Use pumping lemmaAdversary moves pYou move w := ?
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 286: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/286.jpg)
Theorem: L := { 1n2 : n ≥ 0 } is not regular
Proof:Use pumping lemmaAdversary moves pYou move w := 1p2
Adversary moves x,y,zYou move i := ?
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 287: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/287.jpg)
Theorem: L := { 1n2 : n ≥ 0 } is not regular
Proof:Use pumping lemmaAdversary moves pYou move w := 1p2
Adversary moves x,y,zYou move i := 2You must show xyyz ∉ L:Since |xy|≤p, |xyyz| ≤ ?
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 288: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/288.jpg)
Theorem: L := { 1n2 : n ≥ 0 } is not regular
Proof:Use pumping lemmaAdversary moves pYou move w := 1p2
Adversary moves x,y,zYou move i := 2You must show xyyz ∉ L:Since |xy|≤p, |xyyz| ≤ p2 + p < (p+1)2
Since |y| > 0, |xyyz| > ?
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 289: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/289.jpg)
Theorem: L := { 1n2 : n ≥ 0 } is not regular
Proof:Use pumping lemmaAdversary moves pYou move w := 1p2
Adversary moves x,y,zYou move i := 2You must show xyyz ∉ L:Since |xy|≤p, |xyyz| ≤ p2 + p < (p+1)2
Since |y| > 0, |xyyz| > p2
So |xyyz| cannot be … what ?
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 290: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/290.jpg)
Theorem: L := { 1n2 : n ≥ 0 } is not regular
Proof:Use pumping lemmaAdversary moves pYou move w := 1p2
Adversary moves x,y,zYou move i := 2You must show xyyz ∉ L:Since |xy|≤p, |xyyz| ≤ p2 + p < (p+1)2
Since |y| > 0, |xyyz| > p2
So |xyyz| cannot be a square. xyyz ∉ L
∀ p ≥0
∃ w ∈ L, |w| ≥ p
∀ x,y,z : w = xyz, |y| > 0, |xy| ≤ p
∃ i ≥ 0 : xyiz ∉ L
![Page 291: Big picture - Universitetet i oslo · Big picture. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0 1 0 0 1. DFA (Deterministic Finite Automata) q0 qa 1 1 0 0](https://reader030.vdocument.in/reader030/viewer/2022011907/5f4b66295ef1f305f32d724e/html5/thumbnails/291.jpg)
●All languages●Decidable
Turing machines●NP●P●Context-free
Context-free grammars, push-down automata●Regular
Automata, non-deterministic automata, regular expressions
Big picture