1/27
DFA Minimization, Pumping Lemma
CSCI 3130 Formal Languages and Automata Theory Siu On CHAN
Chinese University of Hong Kong
Fall 2015
DFA Minimization, Pumping Lemma CSCI 3130 Formal Languages and - - PowerPoint PPT Presentation
1/27 DFA Minimization, Pumping Lemma CSCI 3130 Formal Languages and Automata Theory Siu On CHAN Chinese University of Hong Kong Fall 2015 2/27 There is a simpler one L = strings ending in 111 0 3/27 1 0 1 0 1 0 1 Can we do it in
1/27
CSCI 3130 Formal Languages and Automata Theory Siu On CHAN
Chinese University of Hong Kong
Fall 2015
2/27
There is a simpler one…
3/27
1 1 1 1 Can we do it in 3 states?
4/27
Intuitively, needs to remember number of ones recently read We will show
In other words
are all distinguishable by L Then use this result from last lecture: If strings x1, . . . , xn are pairwise distinguishable by L, any DFA accepting L must have at least n states
5/27
What do we mean by “1 and 11 are distinguishable”?
We saw from last lecture If x and y are distinguishable by L, any DFA accepting L must reach different states upon reading x and y
6/27
Why are 1 and 11 distinguishable by L?
Take z 1 11
111
More generally, why are 1i and 1j distinguishable by L?
Take z 1
j
1i1
j
1j1
j
1 11 111 are pairwise distinguishable by L Thus our 4-state DFA is minimal
6/27
Why are 1 and 11 distinguishable by L?
Take z = 1 11 /
111 ∈ L More generally, why are 1i and 1j distinguishable by L?
Take z = 13−j 1i13−j /
1j13−j ∈ L
Thus our 4-state DFA is minimal
7/27
1 1 1 1 We now show how to turn any DFA for L into the minimal DFA for L
8/27
1 1 1 1 Distinguishable strings must be in different states Indistinguishable strings may end up in the same state DFA minimial ⇔ Every pair of states is distinguishable
9/27
Two states q and r are distinguishable if
… accept
… reject
10/27
1 0,1 0,1 1
1 0,1 0,1 Which of the following pairs are distinguishable? by which string?
distinguishable by
distinguishable by
distinguishable by
distinguishable by 0
distinguishable by 0
indistinguishable indistinguishable pairs can be merged
10/27
1 0,1 0,1 1
1 0,1 0,1 Which of the following pairs are distinguishable? by which string?
indistinguishable pairs can be merged
10/27
1 0,1 0,1 1
1 0,1 0,1 Which of the following pairs are distinguishable? by which string?
indistinguishable pairs can be merged
11/27
Phase 1:
X If q is accepting and q′ is rejecting Mark (q, q′) as distinguishable (X) Phase 2:
a a X X If (q, q′) are marked Mark (r, r′) as distinguishable (X) Phase 3: Unmarked pairs are indistinguishable Merge them into groups
11/27
Phase 1:
X If q is accepting and q′ is rejecting Mark (q, q′) as distinguishable (X) Phase 2:
a a X X If (q, q′) are marked Mark (r, r′) as distinguishable (X) Phase 3: Unmarked pairs are indistinguishable Merge them into groups
11/27
Phase 1:
X If q is accepting and q′ is rejecting Mark (q, q′) as distinguishable (X) Phase 2:
a a X X If (q, q′) are marked Mark (r, r′) as distinguishable (X) Phase 3: Unmarked pairs are indistinguishable Merge them into groups
12/27
1 1 1 1 1 1 1
(Phase 1)
is distinguishable from all other states
12/27
1 1 1 1 1 1 1
X X X X X X (Phase 1)
13/27
1 1 1 1 1 1 1
X X X X X X 1 (Phase 2) Looking at (r, r′) = (qε, q0) Neither (q0, q00) nor (q1, q01) are distinguishable
14/27
1 1 1 1 1 1 1
X X X X X X 1 X (Phase 2) Looking at (r, r′) = (qε, q1)
15/27
1 1 1 1 1 1 1
X X X X X X X X X X X X X X (Phase 2) Afuer going through the whole table once Now we make another pass
16/27
1 1 1 1 1 1 1
X X X X X X X X X X X X X X 1 (Phase 2) Looking at (r, r′) = (qε, q0) Neither (q0, q00) nor (q1, q01) are distinguishable
17/27
1 1 1 1 1 1 1
X X X X X X X X X X X X X X 1 (Phase 2) Looking at (r, r′) = (qε, q00) Neither (q0, q00) nor (q1, q01) are distinguishable
18/27
1 1 1 1 1 1 1
X X X X X X X X X X X X X X (Phase 2) Nothing changes in the second pass Ready to go to Phase 3
19/27
1 1 1 1 1 1 1
X X X X X X X X X X X X X X A A A A A A B (Phase 3) Merge states into groups (also called equivalence classes)
20/27
1 1 1 1 1 1 1
X X X X X X X X X X X X X X A A A A A A B Minimized DFA:
1 1 1
21/27
Why have we found all distinguishable pairs?
…
…
X X X X X Because we work backwards
21/27
Why have we found all distinguishable pairs?
…
…
X X X X X Because we work backwards
21/27
Why have we found all distinguishable pairs?
…
…
X X X X X Because we work backwards
21/27
Why have we found all distinguishable pairs?
…
…
X X X X X Because we work backwards
22/27
23/27
Another way to show some language is irregular Example
We reason by contradiction: Suppose we have a DFA M for L Something must be wrong with this DFA
24/27
Imaginary DFA M with n states
0r1n What happens when M gets input x = 0n+11n+1?
Since M has n states, it must revisit one of its states while reading 0n The DFA must contain a loop with 0s The DFA will also accept strings that go around the loop multiple times But such strings have more 0s than 1s and cannot be in L
24/27
Imaginary DFA M with n states 0r1n+1 What happens when M gets input x = 0n+11n+1?
Since M has n states, it must revisit one of its states while reading 0n+1 The DFA must contain a loop with 0s The DFA will also accept strings that go around the loop multiple times But such strings have more 0s than 1s and cannot be in L
24/27
Imaginary DFA M with n states 0r1n+1 What happens when M gets input x = 0n+11n+1?
Since M has n states, it must revisit one of its states while reading 0n+1 The DFA must contain a loop with 0s The DFA will also accept strings that go around the loop multiple times But such strings have more 0s than 1s and cannot be in L
24/27
Imaginary DFA M with n states 0r1n+1 What happens when M gets input x = 0n+11n+1?
Since M has n states, it must revisit one of its states while reading 0n+1 The DFA must contain a loop with 0s The DFA will also accept strings that go around the loop multiple times But such strings have more 0s than 1s and cannot be in L
25/27
For every regular language L, there exists a number n such that for every string s ∈ L longer than n symbols, we can write s = uvw where
DFA M with n states
26/27
For every regular language L, there exists a number n such that for every string s ∈ L longer than n symbols, we can write s = uvw where
To show that a language L is irregular we need to find arbitrarily long s so that no matter how the lemma splits s into u, v, w we can find uviw /
27/27
Example: 00000011111