# N there is a dfa m such that ln lm main idea at all

• Notes
• 121

This preview shows page 62 - 77 out of 121 pages.

N, there is a DFA M such that L(N) = L(M). } Main idea: } At all times, M keeps track of the set of states that N could be in. } Proof: } First assume N has no ࠵? -transitions } Then we’ll do the general case
Without ࠵? -transitions } NFA: N = (Q, ࠵? , ࠵? ,q,F) } DFA: M = ( Q’ , ࠵? , ࠵? ’,q’,F’) } Q’ = 2 Q { 2 Q = power set of Q} } ࠵? (R, a) = r R ࠵? (r,a) R Q’, a ࠵? } q’ = {q} } F’ = {R Q’ | R F }
Now with ࠵? -transitions } NFA: N = (Q, ࠵? , ࠵? ,q,F) } DFA: M = ( Q’ , ࠵? , ࠵? ’,q’,F’) } Q’ = 2 Q { 2 Q = power set of Q} } ࠵? ’(R, a) = r R ࠵? (r,a) R Q’, a ࠵? } q’ = {q} } F’ = {R Q’ | R F } How should ࠵? ’,q’ be fixed to handle ࠵? -transitions?
Now with ࠵? -transitions } NFA: N = (Q, ࠵? , ࠵? ,q,F) } E(R) = {r Q | r is reachable from R using zero or more ࠵? -transitions} How should ࠵? ’,q’ be fixed to handle ࠵? -transitions?
Now with ࠵? -transitions } NFA: N = (Q, ࠵? , ࠵? ,q,F) } E(R) = {r Q | r is reachable from R using zero or more ࠵? -transitions} } DFA: M = (Q’, ࠵? , ࠵? ’,q’,F’) } Q’ = 2 Q } ࠵? ’(R, a) = R Q’ , a ࠵? } q’ = E({q}) } F’ = {R | R F } How should ࠵? ’,q’ be fixed to handle ࠵? -transitions? E ( d ( r , a )) r Î R U
Example } A 3-state NFA: How many states in the corresponding DFA? What’s E({1}) ?
Example } {1,3} is the start state } 2 3 states in corresponding DFA
Example } We can simplify it by deleting unreachable states.
} Number of states directly corresponds to memory requirements . } A DFA (implicitly) needs bits of memory to remember which of |Q| states it is in. } NFA with state set Q à DFA with state set 2 Q à DFA needing log 2 (2 |Q| ) = |Q| bits of memory. } Is this exponential blowup necessary? Does non-determinism sometimes/always give an exponential improvement in the number of states? log 2 | Q | é ù
How much non-determinism helps } S = { a , b } } L k = {w { a , b }* | the k th symbol from the end is b .} } Step 1. Find a (k+1)-state NFA recognizing L. } Step 2. Prove that any DFA with < 2 k states does not recognize L. example for k=5
Step 2. Prove that any DFA with < 2 k states does not recognize L k . Proof: by contradiction . 1. Suppose there were such a DFA M with |Q|=2 k -1. 2. Imagine running M on each input w {a,b} k . |{a,b} k | = 2 k > |Q| 3. By the pigeonhole principle, w,w’ {a,b} k and r Q such that (i) w w’ (ii) After reading either w or w’, M is in state r. 4. Let j+1 be the first position where w and w’ differ: w = xxxxxxxxxx a xxxxxxxxxxxxx w’ = xxxxxxxxxx b xxxxxxxxxxxxx
4. Let j+1 be the first position where w and w’ differ: w = xxxxxxxxxx a xxxxxxxxxxxxx w’ = xxxxxxxxxx b xxxxxxxxxxxxx 5. Run M on w a j and w’ a j. On both inputs it ends in the same state, say r’. w a j = xxxxxxxxxx a xxxxxxxxxxxxx aaaaaaaaaaa w’ a j = xxxxxxxxxx b xxxxxxxxxxxxx aaaaaaaaaaa 6. Either r’ F or r’ F. Both cases lead to contradiction! j k–j j k–j j
Union, Concatenation, Star } Closure under regular operations: } Given NFAs N 1 and N 2 , find an N 3 such that } L(N 3 ) = L(N 1 ) L(N 2 ) union } L(N 3 ) = L(N 1 ) L(N 2 ) concatenation } L(N 3 ) = L(N 1 ) * star } Exercise: take union, concat, star for } L(N 1 ) = {w { a , b } * | |w| is odd} } L(N 2 ) = {w { a , b } * | w= a 3n for some n 0}
NFAs Closed Under Union , Concatenation } For NFAs N 1 ,N 2 , there is some NFA N 3 } L(N 3 ) = L(N 1 ) L(N 2 ) L(N 1 ) = {w | |w| is odd.} L(N 2 ) = {w | w = a 3n for some n 0}
} For NFAs N 1 ,N 2 , there is some NFA N 3 } L(N 3 ) = L(N 1 ) L(N 2 ) Non-deterministically choose which NFA to run NFAs Closed Under Union , Concatenation L(N 1 ) = {w | |w| is odd.} L(N 2 ) = {w | w = a 3n for some n 0}