Professional Documents
Culture Documents
• We reason by contradiction:
– Suppose we have managed to construct a DFA M for L
– We argue something must be wrong with this DFA
– In particular, M must accept some strings outside L
A non-regular language
imaginary DFA for L with n states
M
x
0 M
x 0 0 0 0
0r1n+1
0 M
x 0 0 0 0
0r1n+1
0 M
0 0 0 0
0r1n+1
an
z a1 … ak ak+1 … an-1
an+1…am
v
z … …
u w
Arguing non-regularity
• If L is regular, then:
There exists n such that for every z in L, we can
write z = u v w where |uv| ≤ n, |v| ≥ 1 and
For every i ≥ 0, the string u vi w is in L.
adversary you
1 choose n choose z L
2 write z = uvw (|uv| ≤ n,|v| ≥ 1) choose i
you win if uviw L
Example
adversary you
1 choose n choose z L
2 write z = uvw (|uv| ≤ n,|v| ≥ 1) choose i
you win if uviw L
L = {0n1n: n ≥ 0}
adversary you
1 choose n z = 0n1n
2 write z = uvw i=2
000000000000000111111111111111 uv2w = 0n+k1n L
u v w
0000000000000000000111111111111111
u v v w
Example
LDUP = {0n10n1: n ≥ 0}
adversary you
1 choose n z = 0n10n1
2 write z = uvw i=2
uv2w = 0n+k10n1 L
000000000000001000000000000001
u v w
0000000000000000001000000000000001
u v v w
Which of these are regular?
adversary you
1 choose n z = 0n1n
2 write z = uvw i=2
uv2w = 0n+k1n L3
00000000000000011111111111111
1 u v w
0000000000000000000111111111111111
u v v w
Example
adversary you
1 choose n z = 0n+11n
2 write z = uvw i=0
uv0w = 0j+l1n+1 L2
000000000000000111111111111111
u v w
00000000000111111111111111
u w
Example
adversary you
1 choose n z = (01)n(11)n
n=1 z = 0111 L4
has too many 11s
What we have in mind:
n=1 z = 011 z = (01)n1n
n=2 z = 010111
n=3 z = 010101111 has n 01s and n 11s
Example
or 010101010101010111111111 so uv0w L3
u v w
Example
adversary you
1 choose n z = (01)n(10)n
n=1 z = 0110
n=2 z = 01011010
n=3 z = 010101101010
Example
5 01 patterns
5 10 patterns
010101101010
u v w
6 01 patterns 4 01 patterns
6 10 patterns 4 10 patterns
01010101101010 0101101010
u v v w u w
Example
1 0 one more 10
0
r0 r1
1 1
q0
0 0 1 one more 01
1
s0 s1
0
adversary you
1 choose n z=?
L5 = {1p: p is prime}
adversary you
1 choose n z = 1p: p > n is prime
2 write z = uvw = 1a1b1c i = ?a + c
uviw = 1a1ib1c
= 1(a+c)+ib
11111111111111111111111111111
1u = 1a v = 1b w = 1c = 1(a+c)+(a+c)b
= 1(a+c)(b+1)
= 1composite L5
DFA minimization
Example
• Construct a DFA over alphabet {0, 1} that accepts
those strings that end in 111
0
1 1 1
q0 q1 q2 q3 1
0
0
inputs: M
e, 1, 11, 111
M 1, 11
inputs:
e, 1, 11, 111 11, 111
“ends in 111”
M e, 1
inputs:
e, 1, 11, 111 11, 111
“ends in 111”
we conclude that
0
DFA minimization
w1 w2 … wk-1 wk
q
w1 w2 wk-1 wk
q’ …
0 1 1
1 0 1
q0 q1 q2 q3
0
0
0 q2 q2
q0 0
0
0, 1
0, 1
q01 1
1
q1 1
q3 0, 1 q3
0, 1
0, 1
q1 x q1’
q0
q00
q0 q1 x x
q01 q00 x
qe
q10
q01 x x x
q1 q10 x x
q11 q11 x x x x x x
qe q0 q1 q00 q01 q10
q00
q0 A
q0 q1 x x
A q01 q00 A A x
qe
q10
q01 x x B x
q1 q10 A A x A x
B q11 q11 x x x x x x
C qe q0 q1 q00 q01 q10
0 q00
q0 A
q0 1
q1 x x
A 0 1
q01 0 q00 A A x
qe 1 0
0 q10
q01 x x B x
1 1
q1 0 q10 A A x A x
1
B q11 q11 x x x x x x
C 1
qe q0 q1 q00 q01 q10
0
1 1
minimized DFA: qA
0
qB qC 1
0
Example of DFA minimization
0
1 1
qA qB qC 1
0
0
qB 1
Answer: All pairs are distinguishable qC e e
qA qB
Why it works
• Why do we end up finding all distinguishable pairs?
w1 w2 … wk-1 wk
q
x x x x
w1 w2 wk-1 wk
q’ …
Suppose there is
M smaller DFA M’
v q
q’’
q’ v, v’
v’
Why it works
• Why is there no smaller DFA?
But then
M smaller DFA M’
v q w
q’’ w
?
q’ v, v’
v’ w