big picture - northeastern university college of computer ...dfa (deterministic finite automata) q0...
TRANSCRIPT
![Page 1: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/2.jpg)
DFA (Deterministic Finite Automata)
q0 qa
1
1
0
0
1
001
![Page 3: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/3.jpg)
DFA (Deterministic Finite Automata)
q0 qa
1
1
0
0
● States , this DFA has 4 states
● Transitions
labelled with elements of the alphabet S = {0,1}
1
001
![Page 4: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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)
S = {0,1}q0 q1
10
0
1
![Page 21: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/21.jpg)
Exampleq0 q1
1
M :=
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)
S = {0,1} 0
1
![Page 22: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/22.jpg)
ExampleM :=
0
● L(M) = ?
1
S = {0,1}
![Page 23: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/23.jpg)
ExampleM :=
0
● L(M) = every possible string over {0,1}
= {0,1}*
1
S = {0,1}
![Page 24: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/24.jpg)
Example
M :=0
● L(M) = ?
1
S = {0,1}
0
1q0
0
1
![Page 25: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/25.jpg)
Example
M :=0
● L(M) = all strings over {0,1} except empty string e
= {0,1}* - { e }
1
S = {0,1}
0
1q0
0
1
![Page 26: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/26.jpg)
Example
M :=
0S = {0,1}
1
q0
0
1
11
0
0
1 0
● L(M) = ?
![Page 27: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/27.jpg)
Example
M :=
● L(M) = { w : w starts and ends with same symbol }● Memory is encoded in … what ?
0S = {0,1}
1
q0
0
1
11
0
0
1 0
![Page 28: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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
0S = {0,1}
1
q0
0
1
11
0
0
1
Remember 0
Remember 10
![Page 29: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 :=
q0
1
01
![Page 30: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/32.jpg)
Example ∑ = {0,1}
M =
L(M) = ?
0,10,1
![Page 33: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/33.jpg)
Example ∑ = {0,1}
M =
L(M) = ∑2 = {00,01,10,11}
0,10,1
![Page 34: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/34.jpg)
Example from programming languages:
Recognize strings representing numbers:
S = {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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/35.jpg)
Example from programming languages:
Recognize strings representing numbers:
S = {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 one
Possibly put decimal point
Follow with arbitrarily many digits, possibly none
0,...,90,...,9
![Page 36: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/36.jpg)
Example from programming languages:
Recognize strings representing numbers:
S = {0,1,2,3,4,5,6,7,8,9, +, -, . }
0,...,9
+
-
.0,...,9
Input w = 17 ACCEPT
Input w = + REJECT
Input w = -3.25 ACCEPT
Input w = +2.35-. REJECT
0,...,90,...,9
![Page 37: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 that
there is no DFA that recognizes that language !
S = {0,1}
![Page 38: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 S
1
![Page 40: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/40.jpg)
● Definition: A finite automaton (DFA) is a 5-tuple (Q, S, d, q0, F) where
● Q is a finite set of states● S is the input alphabet● d : Q X S → Q is the transition function● q0 in Q is the start state
● F Q is the set of accept states
Q X S 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 - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/41.jpg)
● Example: above DFA is 5-tuple (Q, S, d, q0, F) where
● Q = { q0, q1}
● S = {0,1}● d(q0 ,0) = ?
q0 q11
00
1
![Page 42: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/42.jpg)
● Example: above DFA is 5-tuple (Q, S, d, q0, F) where
● Q = { q0, q1}
● S = {0,1}● d(q0 ,0) = q0 d(q0 ,1) = ?
q0 q11
00
1
![Page 43: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/43.jpg)
● Example: above DFA is 5-tuple (Q, S, d, q0, F) where
● Q = { q0, q1}
● S = {0,1}● d(q0 ,0) = q0 d(q0 ,1) = q1
d(q1 ,0) = q1 d(q1 ,1) = q0
● q0 in Q is the start state
● F = ?
q0 q11
00
1
![Page 44: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/44.jpg)
● Example: above DFA is 5-tuple (Q, S, d, q0, F) where
● Q = { q0, q1}
● S = {0,1}● d(q0 ,0) = q0 d(q0 ,1) = q1
d(q1 ,0) = q1 d(q1 ,1) = q0
● q0 in Q is the start state
● F = { q0} Q is the set of accept states
q0 q11
00
1
![Page 45: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/45.jpg)
● Definition: A DFA (Q, S, d, q0, F) accepts a string w if
● w = w1 w2 … wk where, 1 i k, wi is in S
(the k symbols of w)
● The sequence of k+1 states r0, r1, .., rk where
ri = is state DFA is in after reading i-th symbol in w:
(1) r0 = q0, and
(2) ri+1 = d(ri ,wi+1 ) 0 i < k
has rk in F
● We call this sequence the trace of the DFA on w
![Page 46: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/46.jpg)
● Above DFA (Q, S, d, q0, F) accepts w = 011
q0 q11
00
1Example
![Page 47: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/47.jpg)
● Above DFA (Q, S, d, q0, F) accepts w = 011
● w = 011 = w1 w2 w3 w1 = 0 w2 = 1 w3 = 1
q0 q11
00
1Example
![Page 48: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/48.jpg)
● Above DFA (Q, S, d, q0, F) accepts w = 011
● w = 011 = w1 w2 w3 w1 = 0 w2 = 1 w3 = 1
We must show trace of DFA on w ends in F, that is:● The sequence of 3+1=4 states r0, r1, r2, r3 such that:
(1) r0 = q0
(2) ri+1 = d(ri ,wi+1 ) 0 i < 3
has r3 in F
q0 q11
00
1Example
![Page 49: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/49.jpg)
● Above DFA (Q, S, d, q0, F) accepts w = 011
● w = 011 = w1 w2 w3 w1 = 0 w2 = 1 w3 = 1
● r0 = q0
● r1 := ?
q0 q11
00
1Example
![Page 50: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/50.jpg)
● Above DFA (Q, S, d, q0, F) accepts w = 011
● w = 011 = w1 w2 w3 w1 = 0 w2 = 1 w3 = 1
● r0 = q0
● r1 = d(r0 ,w1 )=d(q0 ,0 ) = q0
● r2 := ?
q0 q11
00
1Example
![Page 51: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/51.jpg)
● Above DFA (Q, S, d, q0, F) accepts w = 011
● w = 011 = w1 w2 w3 w1 = 0 w2 = 1 w3 = 1
● r0 = q0
● r1 = d(r0 ,w1 )=d(q0 ,0 ) = q0
● r2 = d(r1 ,w2 )=d(q0 ,1 ) = q1
● r3 := ?
q0 q11
00
1Example
![Page 52: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/52.jpg)
● Above DFA (Q, S, d, q0, F) accepts w = 011
● w = 011 = w1 w2 w3 w1 = 0 w2 = 1 w3 = 1
● r0 = q0
● r1 = d(r0 ,w1 )=d(q0 ,0 ) = q0
● r2 = d(r1 ,w2 )=d(q0 ,1 ) = q1
● r3 = d(r2 ,w3 )=d(q1 ,1 ) = q0
● r3 = q0 in F OK DONE!
q0 q11
00
1Example
![Page 53: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/53.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 54: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/54.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\>' file
selects all words starting with c and ending with h
in file
![Page 55: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/55.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 56: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 }
● Terminology: Are regular languages closed
under not, U, o, * ?
![Page 57: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/57.jpg)
● Theorem:
If A is a regular language, then so is (not A)
![Page 58: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/58.jpg)
● Theorem:
If A is a regular language, then so is (not A)
● Proof idea: ?????????? the set of accept states
![Page 59: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/59.jpg)
● Theorem:
If A is a regular language, then so is (not A)
● Proof idea: Complement the set of accept states● Example
![Page 60: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/60.jpg)
● Theorem:
If A is a regular language, then so is (not A)
● Proof idea: Complement the set of accept states● Example:
q0 q1
10 0
1
L(M) =
{ w : w has even number of 1}
M :=
![Page 61: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/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 q1
10 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 62: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/62.jpg)
● Theorem: If A is a regular language, then so is (not A)● Proof:Given DFA M = (Q, S, d, q0, F) such that L(M) = A.
Define DFA M' = ??????????????????????????
This definition is the creative step of this proof,
the rest is (perhaps complicated but) mechanical
“unwrapping definitions”
![Page 63: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/63.jpg)
● Theorem: If A is a regular language, then so is (not A)● Proof:Given DFA M = (Q, S, d, q0, F) such that L(M) = A.
Define DFA M' = (Q, S, d, q0, F'), where F' := not F.
● We need to show L(M') = not L(M), that is:
for any w, ??????????????????????????
![Page 64: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/64.jpg)
● Theorem: If A is a regular language, then so is (not A)● Proof:Given DFA M = (Q, S, d, q0, F) such that L(M) = A.
Define DFA M' = (Q, S, d, q0, F'), where F' := not F.
● We need to show L(M') = not L(M), that is:
for any w, M' accepts w M does not accept w.
● Note that the traces of M and M' on w … ?
![Page 65: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/65.jpg)
● Theorem: If A is a regular language, then so is (not A)● Proof:Given DFA M = (Q, S, d, q0, F) such that L(M) = A.
Define DFA M' = (Q, S, d, q0, F'), where F' := not F.
● We need to show L(M') = not L(M), that is:
for any w, M' accepts w M does not accept w
● Note that the traces of M and M' on w are equal
● Let rk be the last state in this trace
● Note that rk in F' r k not in F, since F' = not F.
![Page 66: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/66.jpg)
What is a proof?
● A proof is an explanation, written in English, of why
something is true.
● Every sentence must be logically connected to the
previous ones, often by “so”, “hence”, “since”, etc.
● Your audience is a human being, NOT a machine.
![Page 67: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/67.jpg)
● Theorem: If A is a regular language, then so is (not A)● Proof:
DFA M = (Q, S, d, q0, F) such that L(M) = A.
DFA M' = (Q, S, d, q0, F'), where F' := not F.
L(M') = not L(M)
M' accepts w M does not accept w
Trace of M on w.
rk in F' r k not in F, F' = not F.
![Page 68: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/68.jpg)
What is a proof?
Complement the set of accept states
Given DFA M = (Q, S, d, q0, F) such that L(M) = A.
Define DFA M' = (Q, S, d, q0, F'), where F' := not F.● We need to show L(M') = not L(M), that is: ● for any w, M' accepts w M does not accept w● Note that the traces of M and M' on w are equal● Let rk be the last state in this trace● Note that rk in F' r k not in F, since F' = not F.
To know a proof means to know all the pyramid
![Page 69: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/69.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 70: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/70.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 71: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/71.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 }
![Page 72: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/72.jpg)
● Theorem: If A, B are regular, then so is A U B
● Proof idea: Take Cartesian product of states
In a pair (q,q'),
q tracks DFA for A,
q' tracks DFA for B.
● Next we see an example.
In it we abbreviate
with
1
1
1
![Page 73: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/73.jpg)
a b1
0 0
L(MA) = A = ?
MA := c d
1 1
0MB :=
L(MB) = B = ?
Example
![Page 74: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/74.jpg)
a b1
0 0
L(MA) = A =
{ w : w has even number of 1}
MA := c d
1 1
0MB :=
L(MB) = B =
{ w : w has odd number of 0}
MAUB := How many states?
Example
![Page 75: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/75.jpg)
a b1
0 0
L(MA) = A =
{ w : w has even number of 1}
MA := c d
1 1
0MB :=
L(MB) = B =
{ w : w has odd number of 0}
MAUB := a,c
0
a,d
b,c1
0
1
Example
b,d
L(MAUB) = AUB =
{ w : w has even number of 1,
or odd number of 0}
![Page 76: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/76.jpg)
● Theorem: If A, B are regular, then so is A U B● Proof:Given DFA MA = (QA,S, δA,qA, FA) such that L(M) = A,
DFA MB = (QB,S, δB,qB, FB) such that L(M) = B.
Define DFA M = (Q, S, d, q0, F), where
Q := ?
![Page 77: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/77.jpg)
● Theorem: If A, B are regular, then so is A U B● Proof:Given DFA MA = (QA,S, δA,qA, FA) such that L(M) = A,
DFA MB = (QB,S, δB,qB, FB) such that L(M) = B.
Define DFA M = (Q, S, d, q0, F), where
Q := QA X QB
q0 := ?
![Page 78: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/78.jpg)
● Theorem: If A, B are regular, then so is A U B● Proof:Given DFA MA = (QA,S, δA,qA, FA) such that L(M) = A,
DFA MB = (QB,S, δB,qB, FB) such that L(M) = B.
Define DFA M = (Q, S, d, q0, F), where
Q := QA X QB
q0 := (qA , qB )
F := ?
![Page 79: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/79.jpg)
● Theorem: If A, B are regular, then so is A U B● Proof:Given DFA MA = (QA,S, δA,qA, FA) such that L(M) = A,
DFA MB = (QB,S, δB,qB, FB) such that L(M) = B.
Define DFA M = (Q, S, d, q0, F), where
Q := QA X QB
q0 := (qA , qB )
F := {(q,q') Q : q F∈ ∈ A or q' F∈ B }
δ( (q,q'), v) := (?, ? )
![Page 80: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/80.jpg)
● Theorem: If A, B are regular, then so is A U B● Proof:Given DFA MA = (QA,S, δA,qA, FA) such that L(M) = A,
DFA MB = (QB,S, δB,qB, FB) such that L(M) = B.
Define DFA M = (Q, S, d, q0, F), where
Q := QA X QB
q0 := (qA , qB )
F := {(q,q') Q : q F∈ ∈ A or q' F∈ B }
δ( (q,q'), v) := (δA (q,v), δB (q',v) )
● We need to show L(M) = A U B that is, for any w:M accepts w M A accepts w or MB accepts w
![Page 81: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/81.jpg)
● Proof M accepts w M A accepts w or MB accepts w
● Suppose that M accepts w of length k.● From the definitions of accept and M,the trace (s0 , t0 ) , …, (sk , tk ) of M on w
has (sk,tk) ∈?
![Page 82: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/82.jpg)
● Proof M accepts w M A accepts w or MB accepts w
● Suppose that M accepts w of length k.● From the definitions of accept and M,the trace (s0 , t0 ) , …, (sk , tk ) of M on w
has (sk,tk) F.∈
● By our definition of F, what can we say about (sk,tk ) ?
![Page 83: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/83.jpg)
● Proof M accepts w M A accepts w or MB accepts w
● Suppose that M accepts w of length k.● From the definitions of accept and M,the trace (s0 , t0 ) , …, (sk , tk ) of M on w
has (sk,tk) F.∈
● By our definition of F, sk F∈ A or tk F∈ B.
● Without loss of generality, assume sk F∈ A.
Then MA accepts w because s0 , …, sk
is the trace of MA on w, and sk F∈ A .
![Page 84: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/84.jpg)
● Proof M accepts w M A accepts w or MB accepts w
● W/out loss of generality, assume MA accepts w, |w|=k
● From the definition of MA accepts w,
the trace r0 , …, rk of MA on w has rk in FA
● Let t0 , …, tk be the trace of MB on w
● M accepts w because the trace of M on w is
??????????
![Page 85: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/85.jpg)
● Proof M accepts w M A accepts w or MB accepts w
● W/out loss of generality, assume MA accepts w, |w|=k
● From the definition of MA accepts w,
the trace r0 , …, rk of MA on w has rk in FA
● Let t0 , …, tk be the trace of MB on w
● M accepts w because the trace of M on w is(r0 , t0 ), …, (rk , tk )
and (rk,tk) is in F, by our definition of F.
![Page 86: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/86.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 } 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 }
● Other two are more complicated!
● Plan: we introduce NFA
prove that NFA are equivalent to DFA
reprove A U B, prove A o B, A* regular, using NFA
![Page 87: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/87.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 88: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/88.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 e-transitions:
can follow without reading anything
1
1
1
e
![Page 89: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/89.jpg)
Example of NFA
Intuition of how it computes:● Accept string w if there is a way to follow transitions
that ends in accept state● Transitions labelled with symbol in S = {a,b}
must be matched with input● e transitions can be followed without matching
q0
q1q2
e
a,b
b
a
a
![Page 90: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/90.jpg)
Example of NFA
Example:● Accept a (first follow e-transition )● Accept baaa
q0
q1q2
e
a,b
b
a
a
![Page 91: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/91.jpg)
ANOTHER Example of NFA
q0
q1
q2
q3e
b
b
a,b
a
b
Example:● Accept bab (two accepting paths, one
uses the e-transition)● Reject ba (two possible paths, but neither has final state = q
1)
![Page 92: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/92.jpg)
● Definition: A non-deterministic finite automaton (NFA) is a 5-tuple (Q, S, d, q0, F) where
● Q is a finite set of states● S is the input alphabet● d : Q X (S U {e} ) → 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 Q
Example: Powerset({1,2}) = ?
![Page 93: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/93.jpg)
● Definition: A non-deterministic finite automaton (NFA) is a 5-tuple (Q, S, d, q0, F) where
● Q is a finite set of states● S is the input alphabet● d : Q X (S U {e} ) → 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 Q
Example: Powerset({1,2}) = {, {1}, {2}, {1,2} }
![Page 94: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/94.jpg)
● Example: above NFA is 5-tuple (Q, S, d, q0, F)
● Q = { q0, q1}
● S = {0,1}● d(q0 ,0) = ?
q0 q1e0, 1
1
![Page 95: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/95.jpg)
● Example: above NFA is 5-tuple (Q, S, d, q0, F)
● Q = { q0, q1}
● S = {0,1}● d(q0 ,0) = {q0} d(q0 ,1) = ?
q0 q1e0, 1
1
![Page 96: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/96.jpg)
● Example: above NFA is 5-tuple (Q, S, d, q0, F)
● Q = { q0, q1}
● S = {0,1}● d(q0 ,0) = {q0} d(q0 ,1) = {q0, q1} d(q0 ,e) = ?
q0 q1e0, 1
1
![Page 97: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/97.jpg)
● Example: above NFA is 5-tuple (Q, S, d, q0, F)
● Q = { q0, q1}
● S = {0,1}● d(q0 ,0) = {q0} d(q0 ,1) = {q0, q1} d(q0 ,e) =
d(q1 ,0) = ?
q0 q1e0, 1
1
![Page 98: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/98.jpg)
● Example: above NFA is 5-tuple (Q, S, d, q0, F)
● Q = { q0, q1}
● S = {0,1}● d(q0 ,0) = {q0} d(q0 ,1) = {q0, q1} d(q0 ,e) =
d(q1 ,0) = d(q1 ,1) = ?
q0 q1e0, 1
1
![Page 99: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/99.jpg)
● Example: above NFA is 5-tuple (Q, S, d, q0, F)
● Q = { q0, q1}
● S = {0,1}● d(q0 ,0) = {q0} d(q0 ,1) = {q0, q1} d(q0 ,e) =
d(q1 ,0) = d(q1 ,1) = d(q1 ,e) = ?
q0 q1e0, 1
1
![Page 100: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/100.jpg)
● Example: above NFA is 5-tuple (Q, S, d, q0, F)
● Q = { q0, q1}
● S = {0,1}● d(q0 ,0) = {q0} d(q0 ,1) = {q0, q1} d(q0 ,e) =
d(q1 ,0) = d(q1 ,1) = d(q1 ,e) = {q0}
● q0 in Q is the start state
● F = ?
q0 q1e0, 1
1
![Page 101: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/101.jpg)
● Example: above NFA is 5-tuple (Q, S, d, q0, F)
● Q = { q0, q1}
● S = {0,1}● d(q0 ,0) = {q0} d(q0 ,1) = {q0, q1} d(q0 ,e) =
d(q1 ,0) = d(q1 ,1) = d(q1 ,e) = {q0}
● q0 in Q is the start state
● F = { q1} Q is the set of accept states
q0 q1e0, 1
1
![Page 102: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/102.jpg)
● Definition: A NFA (Q, S, d, 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 S U {e}
(the symbols of w, or e)
● $ sequence of k+1 states r0, r1, .., rk in Q such that:
● r0 = q0
● ri+1 d(ri ,wi+1 ) 0 i < k● rk is in F
● Differences with DFA are in green
![Page 103: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/103.jpg)
Back to first example NFA:q0
q1q2
e
a,b
b
a
a
Accepts w = baaa w
1 = b, w
2 = a, w
3 = a, w
4= e, w
5 = a
Accepting sequence of 5+1 = 6 states: r
0 = ?
![Page 104: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/104.jpg)
Back to first example NFA:q0
q1q2
e
a,b
b
a
a
Accepts w = baaa w
1 = b, w
2 = a, w
3 = a, w
4= e, w
5 = a
Accepting sequence of 5+1 = 6 states: r
0 = q
0, r
1 = ?
![Page 105: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/105.jpg)
Back to first example NFA:q0
q1q2
e
a,b
b
a
a
Accepts w = baaa w
1 = b, w
2 = a, w
3 = a, w
4= e, w
5 = a
Accepting sequence of 5+1 = 6 states: r
0 = q
0, r
1 = q
1, r
2 = ?
Transitions:r1 d(r
0,b) = {q
1}
![Page 106: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/106.jpg)
Back to first example NFA:q0
q1q2
e
a,b
b
a
a
Accepts w = baaa w
1 = b, w
2 = a, w
3 = a, w
4= e, 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 d(r
0,b) = {q
1} r2 d(r
1,a) = {q
1,q
2}
![Page 107: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/107.jpg)
Back to first example NFA:q0
q1q2
e
a,b
b
a
a
Accepts w = baaa w
1 = b, w
2 = a, w
3 = a, w
4= e, 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 d(r
0,b) = {q
1} r2 d(r
1,a) = {q
1,q
2}
r3 d(r2,a) = {q
0}
![Page 108: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/108.jpg)
Back to first example NFA:q0
q1q2
e
a,b
b
a
a
Accepts w = baaa w
1 = b, w
2 = a, w
3 = a, w
4= e, 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 d(r
0,b) = {q
1} r2 d(r
1,a) = {q
1,q
2}
r3 d(r2,a) = {q
0} r4 d(r
3,e) = {q
2}
![Page 109: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/109.jpg)
Back to first example NFA:q0
q1q2
e
a,b
b
a
a
Accepts w = baaa w
1 = b, w
2 = a, w
3 = a, w
4= e, 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 d(r
0,b) = {q
1} r2 d(r
1,a) = {q
1,q
2}
r3 d(r2,a) = {q
0} r4 d(r
3,e) = {q
2} r5 d(r
4,a) = {q
0}
![Page 110: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/110.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 111: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/111.jpg)
● Theorem:
For every NFA N there is DFA M : L(M) = L(N)
● Construction without e transitions● Given NFA N (Q, S, d, q, F)● Construct DFA M (Q', S, d', q', F') where:● Q' := Powerset(Q)● q' = {q}● F' = { S : S Q' and S contains an element of F}● d'(S, a) := Us S d(s,a)
= { t : t d (s,a) for some s S }
![Page 112: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/112.jpg)
● It remains to deal with e 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 e transitions }
● We think of following e transitions at beginning, or
right after reading an input symbol in S
![Page 113: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/113.jpg)
● Theorem:
For every NFA N there is DFA M : L(M) = L(N)
● Construction including e transitions● Given NFA N (Q, S, d, q, F)● Construct DFA M (Q', S, d', q', F') where:● Q' := Powerset(Q)● q' = E({q})● F' = { S : S Q' and S contains an element of F}● d'(S, a) := E( Us S d(s,a) )
= { t : t E( d (s,a) ) for some s S }
![Page 114: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/114.jpg)
Example: NFA → DFA conversion
e
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 115: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/115.jpg)
Example: NFA → DFA conversion
e
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 116: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/116.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA
1
FDFA
= {S : S contains
an element of FNFA
}
DFA
{1,3}
{2} {2,3}
{3}
{1,2,3}
{1} {1,2}
![Page 117: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/117.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA
1
dDFA
({1}, a)
= E(dNFA
(1, a))
= E() =
DFA
{1,3}
{2} {2,3}
{3}
{1,2,3}
a{1} {1,2}
![Page 118: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/118.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA
1
dDFA
({1}, b)
= E(dNFA
(1, b))
= E({2}) = {2}
DFA
{1,3}
{2} {2,3}
{3}
{1,2,3}
a
b
{1} {1,2}
![Page 119: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/119.jpg)
a
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA
1
dDFA
({2}, a)
= E(dNFA
(2, a))
= E({2,3}) = {2,3}
DFA
{1,3}
{2} {2,3}
{3}
{1,2,3}
a
b
{1} {1,2}
![Page 120: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/120.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA
1
dDFA
({2}, b)
= E(dNFA
(2, b))
= E({3}) = {3}
DFA
{1,3}
{2} {2,3}a
{3}
b
{1,2,3}
a
b
{1} {1,2}
![Page 121: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/121.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA
1
dDFA
({3}, a)
= E(dNFA
(3, a))
= E({1}) = {1,3}
DFA
{1,3}
{2} {2,3}a
{3}
b
a
{1,2,3}
a
b
{1} {1,2}
![Page 122: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/122.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA
1
dDFA
({3}, b)
= E(dNFA
(3, b))
= E() =
DFA
{1,3}
{2} {2,3}a
{3}
b
ab
{1,2,3}
a
b
{1} {1,2}
![Page 123: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/123.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA
1
dDFA
({2,3}, a)
= E(dNFA
(2,a) U dNFA
(3,a))
= E({2,3} U {1}) = {1,2,3}
DFA
{1,3}
{2} {2,3}a
{3}
b
ab
{1,2,3}
a
a
b
{1} {1,2}
![Page 124: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/124.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA
1
dDFA
({2,3}, b)
= E(dNFA
(2,b) U dNFA
(3,b))
= E({3} U ) = {3}
DFA
{1,3}
{2} {2,3}a
{3}
b
ab
{1,2,3}
b
a
a
b
{1} {1,2}
![Page 125: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/125.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA
1
dDFA
({1,3}, a)
= E(dNFA
(1,a) U dNFA
(3,a))
= E( U {1}) = {1,3}
DFA
{1,3}
a
{2} {2,3}a
{3}
b
ab
{1,2,3}
b
a
a
b
{1} {1,2}
![Page 126: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/126.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA
1
dDFA
({1,3}, b)
= E(dNFA
(1,b) U dNFA
(3,b))
= E({2} U ) = {2}
DFA
{1,3}
a
b
{2} {2,3}a
{3}
b
ab
{1,2,3}
b
a
a
b
{1} {1,2}
![Page 127: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/127.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA DFA
1
dDFA
({1,2}, a)
= E(dNFA
(1,a) U dNFA
(2,a))
= E( U {2,3}) = {2,3}
{1,3}
a
b
{2} {2,3}a
{3}
b
ab
{1,2,3}
b
a
aab
{1} {1,2}
![Page 128: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/128.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA DFA
1
dDFA
({1,2}, b)
= E(dNFA
(1,b) U dNFA
(2,b))
= E({2} U {3}) = {2,3}
{1,3}
a
b
{2} {2,3}a
{3}
b
ab
{1,2,3}
b
a
aa,bb
{1} {1,2}
![Page 129: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/129.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA DFA
1
dDFA
({1,2,3}, a)
=E(dNFA
(1,a) U dNFA
(2,a) U dNFA
(3,a))
=E( U {2,3} U {1}) = {1,2,3}
{1,3}
a
b
{2} {2,3}a
{3}
b
ab
{1,2,3}
b
a
a
aa,bb
{1} {1,2}
![Page 130: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/130.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA DFA
1
dDFA
({1,2,3}, b)
=E(dNFA
(1,b) U dNFA
(2,b) U dNFA
(3,b))
=E({2} U {3} U ) = {2,3}
{1,3}
a
b
{2} {2,3}a
{3}
b
ab
{1,2,3}
b
a
b
a
aa,bb
{1} {1,2}
![Page 131: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/131.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA DFA
1
dDFA
(, a) =
dDFA
(, b) =
{1,3}
a
b
{2} {2,3}a
{3}
b
ab
{1,2,3}
b
a
b
a
aa,bb
{1} {1,2}
a,b
![Page 132: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/132.jpg)
Example: NFA → DFA conversion
e
a,b
ba
a
2 3
NFA DFA
1
We can delete the
unreachable states.
{1,3}
a
b
{2} {2,3}a
{3}
b
ab
{1,2,3}
b
a
b
a
a,b
![Page 133: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/133.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
3
1 2
ea
b
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
QDFA
= Powerset(QNFA
)
= Powerset({1,2,3})
= {,{1},{2},{3},{1,2}...}
![Page 134: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/134.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
3
1 2
ea
b
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
qDFA
= E({qNFA
})
= E({1})
= {1}
![Page 135: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/135.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
3
1 2
ea
b
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
FDFA
= {S : S contains
an element of FNFA
}
![Page 136: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/136.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
a
3
1 2
ea
b
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
dDFA
({1}, a)
= E(dNFA
(1, a))
= E() =
![Page 137: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/137.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
ba
3
1 2
ea
b
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
dDFA
({1}, b)
= E(dNFA
(1, b))
= E({2,3}) = {1,2,3}
![Page 138: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/138.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
ba
a
3
1 2
ea
b
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
dDFA
({2}, a)
= E(dNFA
(2, a))
= E({3}) = {1,3}
![Page 139: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/139.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
ba
b
a
3
1 2
ea
b
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
dDFA
({2}, b)
= E(dNFA
(2, b))
= E() =
![Page 140: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/140.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa
b
a
3
1 2
ea
b
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
dDFA
({3}, a)
= E(dNFA
(3, a))
= E() =
![Page 141: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/141.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
b
a
3
1 2
ea
b
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
dDFA
({3}, b)
= E(dNFA
(3, b))
= E() =
![Page 142: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/142.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
b
a
3
1 2
ea
b
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
dDFA
({1,2}, a)
= E(dNFA
(1,a) U dNFA
(2,a))
= E( U {3}) = {1,3}
![Page 143: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/143.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
b
a
3
1 2
ea
b
b
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
dDFA
({1,2}, b)
= E(dNFA
(1,b) U dNFA
(2,b))
= E({2,3} U ) = {1,2,3}
![Page 144: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/144.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
ab
a
3
1 2
ea
b
b
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
dDFA
({1,3}, a)
= E(dNFA
(1,a) U dNFA
(3,a))
= E( U ) =
![Page 145: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/145.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
a bb
a
3
1 2
ea
b
b
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
dDFA
({1,3}, b)
= E(dNFA
(1,b) U dNFA
(3,b))
= E({2,3} U ) = {1,2,3}
![Page 146: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/146.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
a bb
a
3
1 2
ea
b
b
a
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
dDFA
({2,3}, a)
= E(dNFA
(2,a) U dNFA
(3,a))
= E({3} U ) = {1,3}
![Page 147: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/147.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
a bb
a
3
1 2
ea
b
b
b
a
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
dDFA
({2,3}, b)
= E(dNFA
(2,b) U dNFA
(3,b))
= E( U ) =
![Page 148: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/148.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
a abb
a
3
1 2
ea
b
b
b
a
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
dDFA
({1,2,3}, a)
=E(dNFA
(1,a) U dNFA
(2,a) U dNFA
(3,a))
=E( U {3} U ) = {1,3}
![Page 149: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/149.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
a abb
a
3
1 2
ea
b
b
b
a
b
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
dDFA
({1,2,3}, b)
=E(dNFA
(1,b) U dNFA
(2,b) U dNFA
(3,b))
=E({2,3} U U ) = {1,2,3}
![Page 150: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/150.jpg)
{1}
{1,2,3}
{1,3}
{3}
{2,3}
{2}{1,2}
baa,b
a abb
a
3
1 2
a
b
a
b
b
a
ANOTHER Example: NFA → DFA conversion
NFA DFA
e
b
b
dDFA
(, a) =
dDFA
(, b) =
a,b
![Page 151: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/151.jpg)
{1}
{1,2,3}
{1,3}
ba
a ab
3
1 2
ea
b
b
b
ANOTHER Example: NFA → DFA conversion
NFA DFA
We can delete the
unreachable states.
a,b
![Page 152: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/152.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 } 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 153: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/153.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 =
e
e
M
A
M
B
N
![Page 154: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/154.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
DFA MB = (QB, S, dB, qB, FB) : L(MB) = B,
● Construct NFA N = (Q, S, d, q, F) where:● Q := ?
U =
e
e
MA M
B
N
![Page 155: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/155.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
DFA MB = (QB, S, dB, qB, FB) : L(MB) = B,
● Construct NFA N = (Q, S, d, q, F) where:● Q := {q} U QA U QB , F := ?
U =
e
e
MA M
B
N
![Page 156: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/156.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
DFA MB = (QB, S, dB, qB, FB) : L(MB) = B,
● Construct NFA N = (Q, S, d, q, F) where:● Q := {q} U QA U QB , F := FA U FB
● d(r,x) := { dA(r,x) } if r in QA and x e● d(r,x) := ? if r in QB and x e
U =
e
e
MA M
B
N
![Page 157: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/157.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
DFA MB = (QB, S, dB, qB, FB) : L(MB) = B,
● Construct NFA N = (Q, S, d, q, F) where:● Q := {q} U QA U QB , F := FA U FB
● d(r,x) := { dA(r,x) } if r in QA and x e● d(r,x) := { dB(r,x) } if r in QB and x e● d(q,e) := ?
U =
e
e
MA M
B
N
![Page 158: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/158.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
DFA MB = (QB, S, dB, qB, FB) : L(MB) = B,
● Construct NFA N = (Q, S, d, q, F) where:● Q := {q} U QA U QB , F := FA U FB
● d(r,x) := { dA(r,x) } if r in QA and x e● d(r,x) := { dB(r,x) } if r in QB and x e● d(q,e) := {qA, qB}
● We have L(N) = A U B
U =
e
e
MA M
B
N
![Page 159: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/159.jpg)
Example
Is L = {w in {0,1}* : |w| is divisible by 3 OR
w starts with a 1} regular?
![Page 160: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/160.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 161: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/161.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 162: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/162.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 163: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/163.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,11
M2 =
L(M2) = L
2
![Page 164: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/164.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,1
0,11e
e
M = L(M) = L(M
1) U L(M
2)
= L1 U L
2
= L
L is regular.
![Page 165: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/165.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 166: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/166.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.
M
A
M
Bo
N
=
e
ee
![Page 167: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/167.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
DFA MB = (QB, S, dB, qB, FB) : L(MB) = B,
● Construct NFA N = (Q, S, d, q, F) where:● Q := ?
M
A
MB
o
N
=eee
![Page 168: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/168.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
DFA MB = (QB, S, dB, qB, FB) : L(MB) = B,
● Construct NFA N = (Q, S, d, q, F) where:● Q := QA U QB , q := ?
M
A
MB
o
N
=eee
![Page 169: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/169.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
DFA MB = (QB, S, dB, qB, FB) : L(MB) = B,
● Construct NFA N = (Q, S, d, q, F) where:● Q := QA U QB , q := q
A , F := ?
M
A
MB
o
N
=eee
![Page 170: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/170.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
DFA MB = (QB, S, dB, qB, FB) : L(MB) = B,
● Construct NFA N = (Q, S, d, q, F) where:● Q := QA U QB , q := q
A , F := FB
● d(r,x) := ? if r in QA and x e
M
A
MB
o
N
=eee
![Page 171: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/171.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
DFA MB = (QB, S, dB, qB, FB) : L(MB) = B,
● Construct NFA N = (Q, S, d, q, F) where:● Q := QA U QB , q := q
A , F := FB
● d(r,x) := { dA(r,x) } if r in QA and x e● d(r,e) := ? if r in F
A
M
A
MB
o
N
=eee
![Page 172: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/172.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
DFA MB = (QB, S, dB, qB, FB) : L(MB) = B,
● Construct NFA N = (Q, S, d, q, F) where:● Q := QA U QB , q := q
A , F := FB
● d(r,x) := { dA(r,x) } if r in QA and x e● d(r,e) := { qB } if r in F
A
● d(r,x) := ? if r in QB and x e
M
A
MB
o
N
=eee
![Page 173: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/173.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
DFA MB = (QB, S, dB, qB, FB) : L(MB) = B,
● Construct NFA N = (Q, S, d, q, F) where:● Q := QA U QB , q := q
A , F := FB
● d(r,x) := { dA(r,x) } if r in QA and x e● d(r,e) := { qB } if r in F
A
● d(r,x) := { dB(r,x) } if r in QB and x e
● We have L(N) = A o B
M
A
MB
o
N
=eee
![Page 174: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/174.jpg)
Example
Is L = {w in {0,1}* : w contains a 1 after a 0}
regular?
Note: L = {01, 0001001, 111001, … }
![Page 175: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/175.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 176: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/176.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 177: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/177.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 178: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/178.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
e
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 179: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/179.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 180: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/180.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*
=e
M
A
N
* ee
![Page 181: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/181.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
Construct NFA N = (Q, S, d, q, F) where:● Q := ?
=e
MA
N
* ee
![Page 182: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/182.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
Construct NFA N = (Q, S, d, q, F) where:● Q := {q} U QA , F := ?
=e
MA
N
* ee
![Page 183: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/183.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
Construct NFA N = (Q, S, d, q, F) where:● Q := {q} U QA , F := {q} U FA
● d(r,x) := ? if r in QA and x e
=e
MA
N
* ee
![Page 184: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/184.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
Construct NFA N = (Q, S, d, q, F) where:● Q := {q} U QA , F := {q} U FA
● d(r,x) := { dA(r,x) } if r in QA and x e● d(r,e) := ? if r in {q} U FA
=e
MA
N
* ee
![Page 185: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/185.jpg)
Construction:● Given DFA MA = (QA, S, dA, qA, FA) : L(MA) = A,
Construct NFA N = (Q, S, d, q, F) where:● Q := {q} U QA , F := {q} U FA
● d(r,x) := { dA(r,x) } if r in QA and x e● d(r,e) := { qA } if r in {q} U FA
● We have L(N) = A*
=e
MA
N
* ee
![Page 186: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/186.jpg)
Example
Is L = {w in {0,1}* : w has even length}
regular?
![Page 187: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/187.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 188: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/188.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 189: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/189.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,1e
e
L is regular.
![Page 190: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/190.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 191: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/191.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 192: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/192.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 193: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/193.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 194: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/194.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 195: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/195.jpg)
How to specify a regular language?
Write a picture → complicated
Write down formal definition → complicated d(q0 ,0) = q0, …
Use symbols from S and operations *, o, U → good
({0} * U {1}) o {001}
![Page 196: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/196.jpg)
Regular expressions: anything you can write with
, ε , symbols from S, 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*, S*, S*001S*, (SS)*, 01 U 10
![Page 197: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/197.jpg)
Definition Regular expressions RE over ∑ are:
Ø
ε
a if a in S
R R' if R, R' are RE
R U R' if R, R' are RE
R* if R is RE
![Page 198: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/198.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 199: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/199.jpg)
Example ∑ = { a, b}
RE Language● ab U ba ?● a* ● (a U b)* ● a*ba* ● ∑*b∑* ● ∑*aab∑* ● (∑∑)* ● a*(a*ba*ba*)* ● a*baba*a Ø
![Page 200: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/200.jpg)
Example ∑ = { a, b}
RE Language● ab U ba {ab, ba}● a* ● (a U b)* ● a*ba* ● ∑*b∑* ● ∑*aab∑* ● (∑∑)* ● a*(a*ba*ba*)* ● a*baba*a Ø
![Page 201: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/201.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*(a*ba*ba*)* ● a*baba*a Ø
![Page 202: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/202.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*(a*ba*ba*)* ● a*baba*a Ø
![Page 203: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/203.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*(a*ba*ba*)* ● a*baba*a Ø
![Page 204: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/204.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*(a*ba*ba*)* ● a*baba*a Ø
![Page 205: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/205.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*(a*ba*ba*)* ● a*baba*a Ø
![Page 206: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/206.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*(a*ba*ba*)* ● a*baba*a Ø
![Page 207: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/207.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*(a*ba*ba*)* {w : w contains even number of b}● a*baba*a Ø
![Page 208: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/208.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*(a*ba*ba*)* {w : w contains even number of b}● a*baba*a Ø Ø (anything o Ø = Ø)
![Page 209: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/209.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R)
![Page 210: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/210.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R)
Construction:● R = M := ?
![Page 211: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/211.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R)
Construction:● R = M :=
● R = e M := ?
![Page 212: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/212.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R)
Construction:● R = M :=
● R = e M :=
● R = a M := ?
![Page 213: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/213.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R)
Construction:● R = M :=
● R = e M :=
● R = a M :=
● R = R U R' ?
a
![Page 214: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/214.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R)
Construction:● R = M :=
● R = e M :=
● R = a M :=
● R = R U R' use construction for A U B seen earlier● R = R o R' ?
a
![Page 215: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/215.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R)
Construction:● R = M :=
● R = e 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 216: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/216.jpg)
Theorem: For every RE R there is NFA M: L(M) = L(R)
Construction:● R = M :=
● R = e 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 217: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/217.jpg)
Example: RE → NFA
RE = (ab U a)*
![Page 218: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/218.jpg)
Example: RE → NFA
aMa
=
L(Ma)=L(a)
RE = (ab U a)*
![Page 219: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/219.jpg)
Example: RE → NFA
RE = (ab U a)*
aMa
=
L(Ma)=L(a)
bMb
=
L(Mb)=L(b)
![Page 220: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/220.jpg)
Example: RE → NFA
Mab
=
L(Mab
)=L(ab)
a be
RE = (ab U a)*
![Page 221: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/221.jpg)
Example: RE → NFA
Mab
=
L(Mab
)=L(ab)
a be
RE = (ab U a)*
aMa
=
L(Ma)=L(a)
![Page 222: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/222.jpg)
Example: RE → NFA
Mab U a
=
L(Mab U a
)=L(ab U a)
a be
RE = (ab U a)*
e
e a
![Page 223: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/223.jpg)
Example: RE → NFA
M(ab U a)*
=
L(M(ab U a)*
)=L((ab U a)*)=L(RE)
RE = (ab U a)*
a be
a
e
ee
e
e
![Page 224: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/224.jpg)
ANOTHER Example: RE → NFA
RE =(e U a)ba*
![Page 225: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/225.jpg)
ANOTHER Example: RE → NFA
Me
=
L(Me)=L(e)
RE =(e U a)ba*
![Page 226: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/226.jpg)
ANOTHER Example: RE → NFA
Me
=
L(Me)=L(e)
aMa
=
L(Ma)=L(a)
RE =(e U a)ba*
![Page 227: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/227.jpg)
ANOTHER Example: RE → NFA
Me U a
=
L(Me U a
)=L(e U a)
RE =(e U a)ba*
e
ea
![Page 228: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/228.jpg)
ANOTHER Example: RE → NFA
Me U a
=
L(Me U a
)=L(e U a)
bMb
=
L(Mb)=L(b)
RE =(e U a)ba*
e
ea
![Page 229: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/229.jpg)
ANOTHER Example: RE → NFA
L(M(e U a)b
)=L((e U a)b)
e
ea
be
e
M(e U a)b
=
RE =(e U a)ba*
![Page 230: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/230.jpg)
ANOTHER Example: RE → NFA
L(M(e U a)b
)=L((e U a)b)
e
ea
be
e
aMa
=
L(Ma)=L(a)
M(e U a)b
=
RE =(e U a)ba*
![Page 231: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/231.jpg)
ANOTHER Example: RE → NFA
L(M(e U a)b
)=L((e U a)b)
e
ea
be
e
Ma*
=e
e
a
L(Ma*)=L(a*)
M(e U a)b
=
RE =(e U a)ba*
![Page 232: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/232.jpg)
ANOTHER Example: RE → NFA
RE =(e U a)ba*
M(e U a)ba*
=
L(M(e U a)ba*
)=L((e U a)ba*)=L(RE)
e
ea
be
e e a
e e
![Page 233: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/233.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 234: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/234.jpg)
Generalized NFA (GNFA)
q0 qa
a*b*
a U b*
ab
Nondeterministic
Transitions labelled by RE
Read blocks of input symbols at a time
![Page 235: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/235.jpg)
Generalized NFA (GNFA)
q0 qa
a*b*
a U b*
ab
Convention:
Unique final state
Exactly one transition between each pair of states
except nothing going into start state
nothing going out of final state
If arrow not shown in picture, label =
![Page 236: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/236.jpg)
● Definition: A generalized finite automaton (GNFA)● is a 5-tuple (Q, S, d, q0, qa) where
● Q is a finite set of states● S is the input alphabet● d : (Q - {qa}) X (Q – {q0}) → Regular Expressions
● q0 in Q is the start state
● qa in Q is the accept state
![Page 237: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/237.jpg)
● Definition: GNFA (Q, S, d, q0, qa) accepts a string w if
● ∃ integer k, k strings w∃ 1 , w2 , …, wk S*
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(d(ri ,ri+1 )) 0 i < k● rk = qa
● Differences with NFA are in green
![Page 238: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/238.jpg)
Example
q0 q1 qa
a*
b*
ab
Accepts w = aaabbabw1=?
![Page 239: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/239.jpg)
Example
q0 q1 qa
a*
b*
ab
Accepts w = aaabbabw1=aaa w2=?
![Page 240: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/240.jpg)
Example
q0 q1 qa
a*
b*
ab
Accepts w = aaabbabw1=aaa w2=bb w3=ab
r0=q0 r1=?
![Page 241: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/241.jpg)
Example
q0 q1 qa
a*
b*
ab
Accepts w = aaabbabw1=aaa w2=bb w3=ab
r0=q0 r1=q1 r2=?
w1 = aaa L(d(r0,r1)) = L(d(q0,q1)) = L(a*)
![Page 242: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/242.jpg)
Example
q0 q1 qa
a*
b*
ab
Accepts w = aaabbabw1=aaa w2=bb w3=ab
r0=q0 r1=q1 r2=q1 r3 = ?
w1 = aaa L(d(r0,r1)) = L(d(q0,q1)) = L(a*)
w2 = bb L(d(r1,r2)) = L(d(q1,q1)) = L(b*)
![Page 243: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/243.jpg)
Example
q0 q1 qa
a*
b*
ab
Accepts w = aaabbabw1=aaa w2=bb w3=ab
r0=q0 r1=q1 r2=q1 r3 = qa
w1 = aaa L(d(r0,r1)) = L(d(q0,q1)) = L(a*)
w2 = bb L(d(r1,r2)) = L(d(q1,q1)) = L(b*)
w3 = ab L(d(r2,r3)) = L(d(q1,qa)) = L(ab)
![Page 244: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/244.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
e
eee
![Page 245: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/245.jpg)
Theorem: GNFA N RE R : L(R) = L(N)
Construction:
If N has 2 states, then N =
thus R := Sq0 qa
S
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 qr
qr qi qj
R1 R3
R4
Repeat until 2 states remain
R2
![Page 246: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/246.jpg)
Example: DFA → GNFA → RE
q2q
1
a b
b,c
DFA
![Page 247: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/247.jpg)
Example: DFA → GNFA → RE
q2q
1
a b
b U c
GNFA
q0
qa
e e
![Page 248: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/248.jpg)
Example: DFA → GNFA → RE
q2q
1
a b
q0
qa
e e
q2
b
q0
qa
e
b U c
Eliminate q1: re-draw GNFA with all other states
![Page 249: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/249.jpg)
Example: DFA → GNFA → RE
q2q
1
a b
q0
qa
e e
q2
b
q0
qa
e
b U c
Eliminate q1: find a path through q
1
![Page 250: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/250.jpg)
Example: DFA → GNFA → RE
q2q
1
a b
q0
qa
e e
q2
b
q0
qa
e
Eliminate q1: add edge to new GNFA
b U c
e a* (b U c) U Ø
Ø
Don't forget: no arrow means label Ø
![Page 251: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/251.jpg)
Example: DFA → GNFA → RE
q2q
1
a b
q0
qa
e e
q2
b
q0
qa
e
Eliminate q1: simplify RE on new edge
a* (b U c)
b U c
![Page 252: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/252.jpg)
Example: DFA → GNFA → RE
q2q
1
a b
q0
qa
e e
q2
b
q0
qa
e
Eliminate q1: if no more paths through q
1, start over
a* (b U c)
b U c
![Page 253: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/253.jpg)
Example: DFA → GNFA → RE
q2
b
q0
qa
ea* (b U c)
Eliminate q2: re-draw GNFA with all other states
q0
qa
![Page 254: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/254.jpg)
Example: DFA → GNFA → RE
q2
b
q0
qa
ea* (b U c)
q0
qa
Eliminate q2: find a path through q
2
![Page 255: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/255.jpg)
Example: DFA → GNFA → RE
q2
b
q0
qa
ea* (b U c)
q0
qa
Eliminate q2: add edge to new GNFA
a* (b U c) b* e U Ø
![Page 256: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/256.jpg)
Example: DFA → GNFA → RE
q2
b
q0
qa
ea* (b U c)
q0
qa
Eliminate q2: simplify RE on new edge
a* (b U c) b*
![Page 257: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/257.jpg)
Example: DFA → GNFA → RE
q2
b
q0
qa
ea* (b U c)
q0
qa
Eliminate q2: if no more paths through q
2, start over
a* (b U c) b*
![Page 258: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/258.jpg)
Example: DFA → GNFA → RE
q0
qa
Only two states remain:
RE = a* (b U c) b*
a* (b U c) b*
![Page 259: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/259.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q3
DFA
c
c
b
![Page 260: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/260.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qe eq3 a
GNFA
c
c
b
![Page 261: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/261.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qe eq3
Eliminate q1:
re-draw GNFA with
all other states
a
q0
q2
a
qeq3 a
b
c
c
b
![Page 262: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/262.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qe eq3
Eliminate q1:
find a path through q
1
a
q0
q2
a
qeq3 a
c
c
b
b
![Page 263: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/263.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qe eq3
Eliminate q1:
add edge to
new GNFA
a
q0
q2
a
qeq3 a
c
c
e a*b U Ø
b
b
![Page 264: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/264.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qe eq3
Eliminate q1:
find anotherpath through q
1
a
q0
q2
a
qeq3 a
c
c
b
b
e a*b U Ø
![Page 265: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/265.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qe eq3
Eliminate q1:
add edge to
new GNFA
a
b
q0
q2
a
qeq3 a
c
c
e a*c U Ø
b
e a*b U Ø
![Page 266: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/266.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qe eq3
Eliminate q1:
find anotherpath through q
1
a
q0
q2
a
qeq3 a
c
c
b
b
e a*b U Ø
e a*c U Ø
![Page 267: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/267.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qe eq3
Eliminate q1:
add edge to
new GNFA
a
q0
q2
ca*b U a
qeq3 a
c
c
b
b
don't forget current q
2 → q
3 edge!
This time is not Ø !
e a*b U Ø
e a*c U Ø
![Page 268: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/268.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qe eq3
Eliminate q1:
find anotherpath through q
1
a
q0
q2
qeq3 a
c
c
b
b
ca*b U a
e a*b U Ø
e a*c U Ø
![Page 269: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/269.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qe eq3 a
q0
q2
qeq3 a
c
c
b
ca*c U b
ca*b U a
Eliminate q1:
add edge to
new GNFA
don't forget current q
2 → q
2 edge!
e a*b U Ø
e a*c U Ø
![Page 270: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/270.jpg)
ANOTHER Example: DFA → GNFA → RE
q1
a
b
q2
a
q0
qe eq3
Eliminate q1:
when no more pathsthrough q
1, start over
(and simplify
REs)
a
q0
q2
qeq3 a
c
c
a*b
b
a*c ca*b U a
ca*c U b
![Page 271: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/271.jpg)
ANOTHER Example: DFA → GNFA → RE
qeq3 a
Eliminate q2:
re-draw GNFA with
all other states
q0
q2
qeq3 aa*b
a*c ca*b U a
ca*c U b
q0
a*b
![Page 272: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/272.jpg)
ANOTHER Example: DFA → GNFA → RE
qeq3 a
Eliminate q2:
find a path through q2
q0
q2
qeq3 aa*b
a*c ca*b U a
ca*c U b
q0
a*b
![Page 273: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/273.jpg)
ANOTHER Example: DFA → GNFA → RE
q0 qeq
3 a
a*c(ca*c U b)*(ca*b U a) U a*b
Eliminate q2:
add edge to new GNFA
q0
q2
qeq3 aa*b
a*c ca*b U a
ca*c U b
![Page 274: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/274.jpg)
ANOTHER Example: DFA → GNFA → RE
q0 qeq
3 a
a*c(ca*c U b)*(ca*b U a) U a*b
Eliminate q2:
when no more pathsthrough q
2, start over
q0
q2
qeq3 aa*b
a*c ca*b U a
ca*c U b
![Page 275: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/275.jpg)
ANOTHER Example: DFA → GNFA → RE
q0 qeq
3 a
a*c(ca*c U b)*(ca*b U a) U a*b
Eliminate q3:
re-draw GNFA with
all other states
q0 qa
![Page 276: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/276.jpg)
ANOTHER Example: DFA → GNFA → RE
q0 qeq
3 a
a*c(ca*c U b)*(ca*b U a) U a*b
Eliminate q3:
find a path through q3
q0 qa
don't forget: no arrow means Ø
Ø
Ø
![Page 277: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/277.jpg)
ANOTHER Example: DFA → GNFA → RE
q0 qeq
3 a
a*c(ca*c U b)*(ca*b U a) U a*b
Eliminate q3:
add edge to new GNFA
q0 qa
(a*c(ca*c U b)*(ca*b U a) U a*b) Ø* ε U Ø
Ø
Ø
![Page 278: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/278.jpg)
ANOTHER Example: DFA → GNFA → RE
q0 qeq
3 a
a*c(ca*c U b)*(ca*b U a) U a*b
Eliminate q3:
when no more paths through q3, start over
(and simplify REs)
q0 qa
a*c(ca*c U b)*(ca*b U a) U a*b
don't forget: Ø*= ε
![Page 279: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/279.jpg)
ANOTHER Example: DFA → GNFA → RE
q0 qa
a*c(ca*c U b)*(ca*b U a) U a*b
Only two states remain:
RE = a*c(ca*c U b)*(ca*b U a) U a*b
![Page 280: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/280.jpg)
Recap:
Here “” means “can be converted to”
RE DFA NFA
Any of the three recognize exactly
the regular languages (initially defined using DFA)
![Page 281: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/281.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 282: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/282.jpg)
What language is NOT regular?
Is { 0n 1n : n 0 } = {ε, 01, 0011, 000111, … } regular?
![Page 283: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/283.jpg)
Pumping lemma:
L regular language
Recall y0 = e, 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 284: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/284.jpg)
Pumping lemma:
L regular language
Proof Idea:
Let M be a DFA recognizing L. Choose p := |Q|
Let w L, |w| p.
Among the first p+1 states of the trace of M on w,
2 states must be the same q.
y = portion of w that brings q back to q
can repeat or remove 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 285: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/285.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 286: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/286.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 287: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/287.jpg)
Proving something like
bla bla bla bla bla
means winning a game
Theory is all about winning games!
![Page 288: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/288.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 289: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/289.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 290: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/290.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 291: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/291.jpg)
Another example:
Theorem: NFA N DFA M : L(M) = L(N)
We already saw a winning strategy for this game
What is it?
![Page 292: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/292.jpg)
Another example:
Theorem: NFA N DFA M : L(M) = L(N)
We already saw a winning strategy for this game
The power set construction.
![Page 293: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/293.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 294: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/294.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|p
You pick i 0
Finally, 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 295: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/295.jpg)
Theorem: L := {0n 1n : n 0} is not regular
Proof:
Use pumping lemma
Adversary moves p
You move w := 0p 1p
Adversary moves x,y,z
You move i := 2
You must show xyyz L:
Since |xy|p and w = xyz = 0p 1p , y only has 0
So 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 296: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/296.jpg)
Theorem: L := {w : w has as many 0 as 1} not regular
Same Proof:
Use pumping lemma
Adversary moves p
You move w := ?
p 0
w L, |w| p
x,y,z : w = xyz, |y| > 0, |xy| p
i 0 : xyiz L
![Page 297: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/297.jpg)
Theorem: L := {w : w has as many 0 as 1} not regular
Same Proof:
Use pumping lemma
Adversary moves p
You move w := 0p 1p
Adversary moves x,y,z
You move i := ?
p 0
w L, |w| p
x,y,z : w = xyz, |y| > 0, |xy| p
i 0 : xyiz L
![Page 298: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/298.jpg)
Theorem: L := {w : w has as many 0 as 1} not regular
Same Proof:
Use pumping lemma
Adversary moves p
You move w := 0p 1p
Adversary moves x,y,z
You move i := 2
You must show xyyz L:
Since |xy|p and w = xyz = 0p 1p , y only has 0
So xyyz = ?
p 0
w L, |w| p
x,y,z : w = xyz, |y| > 0, |xy| p
i 0 : xyiz L
![Page 299: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/299.jpg)
Theorem: L := {w : w has as many 0 as 1} not regular
Same Proof:
Use pumping lemma
Adversary moves p
You move w := 0p 1p
Adversary moves x,y,z
You move i := 2
You must show xyyz L:
Since |xy|p and w = xyz = 0p 1p , y only has 0
So 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 300: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/300.jpg)
Theorem: L := {0j 1k : j > k} is not regular
Proof:
Use pumping lemma
Adversary moves p
You move w := ?
p 0
w L, |w| p
x,y,z : w = xyz, |y| > 0, |xy| p
i 0 : xyiz L
![Page 301: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/301.jpg)
Theorem: L := {0j 1k : j > k} is not regular
Proof:
Use pumping lemma
Adversary moves p
You move w := 0p+1 1p
Adversary moves x,y,z
You move i := ?
p 0
w L, |w| p
x,y,z : w = xyz, |y| > 0, |xy| p
i 0 : xyiz L
![Page 302: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/302.jpg)
Theorem: L := {0j 1k : j > k} is not regular
Proof:
Use pumping lemma
Adversary moves p
You move w := 0p+1 1p
Adversary moves x,y,z
You move i := 0
You must show xz L:
Since |xy|p and w = xyz = 0p+1 1p , y only has 0
So 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 303: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/303.jpg)
Theorem: L := {uu : u {0,1}* } is not regular
Proof:
Use pumping lemma
Adversary moves p
You move w := ?
p 0
w L, |w| p
x,y,z : w = xyz, |y| > 0, |xy| p
i 0 : xyiz L
![Page 304: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/304.jpg)
Theorem: L := {uu : u {0,1}* } is not regular
Proof:
Use pumping lemma
Adversary moves p
You move w := 0p1 0p 1
Adversary moves x,y,z
You move i := ?
p 0
w L, |w| p
x,y,z : w = xyz, |y| > 0, |xy| p
i 0 : xyiz L
![Page 305: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/305.jpg)
Theorem: L := {uu : u {0,1}* } is not regular
Proof:
Use pumping lemma
Adversary moves p
You move w := 0p 1 0p 1
Adversary moves x,y,z
You move i := 2
You must show xyyz L:
Since |xy|p and w = xyz = 0p 1 0p 1 , y only has 0
So xyyz = 0p + |y| 1 0p 1
Since |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 306: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/306.jpg)
Theorem: L := { 1n2 : n 0 } is not regular
Proof:
Use pumping lemma
Adversary moves p
You move w := ?
p 0
w L, |w| p
x,y,z : w = xyz, |y| > 0, |xy| p
i 0 : xyiz L
![Page 307: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/307.jpg)
Theorem: L := { 1n2 : n 0 } is not regular
Proof:
Use pumping lemma
Adversary moves p
You move w := 1p2
Adversary moves x,y,z
You move i := ?
p 0
w L, |w| p
x,y,z : w = xyz, |y| > 0, |xy| p
i 0 : xyiz L
![Page 308: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/308.jpg)
Theorem: L := { 1n2 : n 0 } is not regular
Proof:
Use pumping lemma
Adversary moves p
You move w := 1p2
Adversary moves x,y,z
You move i := 2
You 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 309: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/309.jpg)
Theorem: L := { 1n2 : n 0 } is not regular
Proof:
Use pumping lemma
Adversary moves p
You move w := 1p2
Adversary moves x,y,z
You move i := 2
You 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 310: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/310.jpg)
Theorem: L := { 1n2 : n 0 } is not regular
Proof:
Use pumping lemma
Adversary moves p
You move w := 1p2
Adversary moves x,y,z
You move i := 2
You 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 311: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/311.jpg)
Theorem: L := { 1n2 : n 0 } is not regular
Proof:
Use pumping lemma
Adversary moves p
You move w := 1p2
Adversary moves x,y,z
You move i := 2
You 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 312: Big picture - Northeastern University College of Computer ...DFA (Deterministic Finite Automata) q0 qa Computation on input w: Begin in start state Read input string in a one-way fashion](https://reader035.vdocuments.us/reader035/viewer/2022070621/5e3992e099ac7c07ec4488d9/html5/thumbnails/312.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