Formal Language and Automata Theory
Chapter 7
Limitations of Finite Automata (lecture 11 and 12)
Transparency No. 7-1
Limitations of FAs
Limitations of FAs
Problem: Is there any set not regular ? ans: yes!
example: B = {anbn | n 0 } = {e,ab,aabb,aaabbb,}
Intuition: Any machine accepting B must be able to
remember the number of as it has scanned before encountering the first b, but this requires infinite amount of memory (states) and is beyond the capability of any FA , which has only a finite amount of memory (states).
Transparency No. 7-2
Limitations of FAs
The proof
Lemma 1: Let M = (Q, S, d, s, F) be any DFA accepting B. Then for all non-negative numbers m, n , m n implies D(s, am) D(s, an). pf: Assume D(s, am) = D(s, an) from some m and n. Then D(s, ambn) = D( D(s, am), bn) = D( D(s, an), bn) = D(s, an bn)F It implies ambn L(M) = B. But ambn B since m n. Hence D(s, am) D(s, an) for all m n. Theorem: B is not regular.
Pf: Assume B is regular and accepted by some DFA M with k states. But by Lemma1, M must have an infinite number of states (Ex: to accept anbn for any n>0 it must have at least n states). This contradicts the requirement that the state set Q of M is a finite set.
Transparency No. 7-3
Limitations of FAs
Another nonregular set
C= {a2n | n > 0} = {a, aa, aaaa, aaaaaaaa, } is nonregular pf: assume C is regular and is accepted by a DFA with k states. Let n > k and x = a2n C. Now consider the sequence of states: D(s,a), D(s,aa),., D(s,an), by pigeonhole principle, there are 0<i<i+d n s.t. D(s,ai) = D(s,ai+d) [ = p] let 2n = i + d + m. => D(s, a2n+d) = D(s, aiadadad) = D(s,aiadam) = D(s, a2n) F. But since 2n + d < 2n + n < 2n+2n = 2 n+1, which is the next power of 2 > 2n, Hence a2n+d C => the DFA also accepts a string C, a contradiction! Hence C is not regular.
Transparency No. 7-4
Limitations of FAs
Intuition behind the Pumping Lemma for FA
For an FA to accept a long string s ( its number of states), the visited path for s must contains a cycle and hence can be cut or repeated to accept also many new strings.
repeat
cut
Transparency No. 7-5
Limitations of FAs
The pumping lemma
Theorem 11.1: If A is a regular set, then (P): $ k > 0 s.t. for any string xyz A with |y| k, there exists a decomposition y = uvw s.t. v e and for all i 0, the string xuviwz A.
pf: Similar to the previous example. Let k = |Q| where Q is the set of states in any FA accepting A. Also let s and F be the initial and set of final states of the FA, respectively. Now if there is a string xyz A with |y| k, consider the sequence of states: D(s,xy0), D(s, xy1), D(s,xy2), D(s, xyk), where yj (j = 0..k) denote the prefix of y of the first j symbols. Since there are k+1 items in the sequence, each a state in Q, by pigeonhole principle, there must exist two items D(s, xym), D(s, xyn) corresponding to the same state. Without loss of generality, assume m < n. Now let u = ym, yn = u v and y= uvw. We thus have D(s, xuwz) = D(s, xym wz) = D(s, xynwz) = D(s, xuvwz) F Likewise, for all j > 1, D(s, xuvjwz) = D(xuv vj-1 wz) = D(xuvj-1 wz) = = D(xuvj-2 wz) = =D(s,xuvwz) F. QED
Transparency No. 7-6
Limitations of FAs
The pumping lemma
Theorem 11.1: Let A be any language. If A is a regular, then (P): $ k > 0 s.t. for any string xyz A with |y| k, there exist a decomposition y = uvw s.t. v e and for all i 0, the string xuviwz A. Theorem 11.2 (pumping lemma, the contropositive form) If A is any language satisfying the property (~P): k> 0 $ xyz A s.t. |y| k and u,v,w with uvw = y and v e , there exists an i 0 s.t. xuvivw A, then A is not regular. [ ~P means for any k > 0, there is a substring of length k [of a member] of A, a cut or a certain duplicates of the middle of any 3segment decomposition of which will produce a string A. ]
Transparency No. 7-7
Limitations of FAs
Game semantics for quantification
1. Two players: You (want to show a theorem T holds) Demon (the opponent want to show T does not hold) rules: forall x D pick a number for x there is y Y choose a numebr for y. Result: Y win if the resulting proposition holds D wins o/w T holds if Y has a winning strategy (always wins).
Transparency No. 7-8
Limitations of FAs
Examples
Show that for all x there is y with x < y. pf: D: choose any number k for x. Y: let y be k + 1 Since Y always wins in this game. The result is proved.
Show that for all x there is y with y < x in positive intergers. pf: D: pick number 0 for x Y: pick a number m for y. D wins since ~( 0 < m). Hence the theorem is not proved.
Transparency No. 7-9
Limitations of FAs
Game-theoretical proof of nonregularity of a set
1. Two players: You (want to show that ~P holds and A is not regular) Demon (the opponent want to show that P holds) 2 The game proceeds as follows: 1. D picks a k> 0 (if A is regular, Ds best strategy is to pick k =
#states of a FA accepting A) 2. Y picks x,y,x with xyz A and |y| k.
3. D picks u,v,w s.t. y = uvw and v e. 4. Y picks i 0 3. Finally Y wins if xuviwz A and D wins if xuviwz A. 4. By Theorem 11.2, A is not regular if there is a winning strategy according to which Y always win. Note: P is a necessary but not a sufficient condition for the regularity of A (i.e., there is nonregular set A satisfying P).
Transparency No. 7-10
Limitations of FAs
Using the pumping lemma
Ex1: Show the set A = {anbm | n m } is not regular. the proof: 1. D gives k [for any k > 0] 2. Y pick x = ak, y = bk, z = e [$ xyz in A with |y| k] ==> xyz = akbk A 3. D decompose y = uvw with [for all uvw with uvw=y and |u|=j, |v|=m > 0 and |w|= n ve] 4. Y take i = 2. [$ i 0 s.t. xuviwz A] => xuv2wz = akbjb2mbn = akbk+m A => Y wins. Hence A is not regular. Ex2: C = {an! | n 0 } is not regular. pf: similar to Ex1. Left as an exercise. hint: for any k > 0 D chooses, let xyz =akxk! ak! e and let i = 0.
Transparency No. 7-11
Limitations of FAs
Other techniques:
Using closure property of regular sets. Ex3: D = { x {a,b}* | #a(x) = #b(x) } = {e, ab, ba, aabb, abab. baba, bbaa, abba, baab, } is not regular. (Why ?) if regular => D a*b* = {anbn | n 0 } = B is regular. But B is not regular, D thus is not regular. [H2E2:] A: any language; if A is regular, then rev(A) =def {xnxn-1x1 | x1x2xn A} is regular. Ex4: A = {anbm | m n } is not regular. pf: If A is regular => rev(A) and h((rev(A)) = {anbm | n m} is regular, where h(a) = b and h(b) = a. => A h(rev(A)) = {anbn | n 0} is regular, a contradiction!
Transparency No. 7-12