1 / 24

Intro to Theory of Computation

L ECTURE 6 Theory of Computation Proving that a language is not regular Pushdown automaton (PDA) Context-free grammar (CFG). Intro to Theory of Computation. CS 464. Sofya Raskhodnikova. THE PUMPING LEMMA. Let L be a regular language with |L| = .

Download Presentation

Intro to Theory of Computation

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. LECTURE 6 • Theory of Computation • Proving that a language is not regular • Pushdown automaton (PDA) • Context-free grammar (CFG) Intro to Theory of Computation CS 464 Sofya Raskhodnikova SofyaRaskhodnikova; based on slides by Nick Hopper

  2. THE PUMPING LEMMA Let L be a regular language with |L| =  Then there exists a length p such that if w  L and |w| ≥ p then w can be split into three parts w=xyz where: 1. |y| > 0 2. |xy| ≤ p 3. xyiz L for all i ≥ 0 Sofya Raskhodnikova; based on slides by Nick Hopper

  3. GENERAL STRATEGY Proof by contradiction – assume L is regular Then there is a pumping length p Find a string w 2 L with |w| ¸p Show that no matter how an adversary choosesxyz, your w cannot be pumped! Conclude that L is not regular Sofya Raskhodnikova; based on slides by Nick Hopper

  4. PUMPING DOWN USING THE PUMPING LEMMA: ProveC= { 0i1j | i > j ¸ 0} is not regular. Proof: Assume … pumping length p Find a w 2C longer than p 0P+11P Show that … w cannot be pumped: p p+1 w= 00…0011…11 y xz = 0…0011…11 xyyz = 00…00011…11 ·p > p+1 P P Sofya Raskhodnikova; based on slides by Nick Hopper

  5. PUMPING DOWN ProveC= { 0i1j | i > j ¸ 0} is not regular. Proof: Assume … pumping length p Find a w 2C longer than p 0P+11P If w = xyz with |xy| ·p then y = 0J for some J¸ 1. Then xy0z = xz = 0P+1-J1P C Contradiction! xz = 0…0011…11 Sofya Raskhodnikova; based on slides by Nick Hopper

  6. WHAT THE PUMPING LEMMA DOESN’T SAY - I For every p, w  L with |w| ≥ p there exist xyz=w, where 1. |y| > 0 2. |xy| ≤ p 3. xyiz L for all i ≥ 0 Let L = 1*. L is regular. The string 10 cannot be pumped with p=1. You need to show that no matter what p is chosen, L has a string w, |w| ≥ p, that cannot be pumped. Sofya Raskhodnikova; based on slides by Nick Hopper

  7. WHAT THE PUMPING LEMMA DOESN’T SAY - II For every xyz=w, where: 1. |y| > 0 2. |xy| ≤ p 3. xyiz L for all i ≥ 0 Example: Let L = 10*1*. Picking w = 10P1P; x=ε; y=10P; z=1P does not contradict pumping lemma! (You can pick x=1, y=0, z=0P-11P.) Sofya Raskhodnikova; based on slides by Nick Hopper

  8. CHOOSING WISELY Let BALANCED = { w | w has an equal # of 1sand 0s } Assume … there is a p Find a w 2 BALANCED longer than p (01)P 0P1P Show that w cannot be pumped: If w = xyz with |xy| ·p then y = 0J for some J>0. Then xyyz = 0P+J1P BALANCED Sofya Raskhodnikova; based on slides by Nick Hopper

  9. REUSING A PROOF Pumping a language can be lots of work… Let’s try to reuse that work! {0n1n : n ¸ 0} = BALANCED ∩ 0*1* If BALANCED is regular then so is {0n1n: n ¸ 0} Sofya Raskhodnikova; based on slides by Nick Hopper

  10. USING CLOSURE Prove: A is not regular ∩ A C = B (Not regular) (regular) or any of {¢, [, ∩, :, R, *} If A is regular, then A ∩ C (= B) is regular. But B is not regular so neither is A. Sofya Raskhodnikova; based on slides by Nick Hopper

  11. USINGCLOSURE: example Prove A = {0i1j : i  j} is not regular using B = {0n1n : n¸0} :A = B [ { strings that mix 0s and 1s } :A ∩ 0*1* = B Sofya Raskhodnikova; based on slides by Nick Hopper

  12. PUMPING NON-REGULAR LANGUAGES Let F = {aibjck | i, j, k ¸ 0 and i=1 ) j=k} F has pumping length 2! i = 0 i = 1 i = 2 HW3: prove that F is not regular. A non-regular language may still satisfy the pumping lemma. Sofya Raskhodnikova; based on slides by Nick Hopper

  13. 464 so far MODEL OF A PROBLEM: LANGUAGE MODEL OF A PROGRAM: DFA EQUIVALENT MODELS: NFA, REGEXP PROBLEMS THAT A DFA CAN’T SOLVE ARE WE DONE? Sofya Raskhodnikova; based on slides by Nick Hopper

  14. NONE OF THESE ARE REGULAR • Σ = {0, 1}, L = { 0n1n | n ≥ 0 } • Σ = {a, b, c, …, z}, L = { w | w = wR } • Σ = { (, ) }, L = { balanced strings of parens } We can write a SCHEME or JAVA program for any of them! Sofya Raskhodnikova; based on slides by Nick Hopper

  15. PUSHDOWNAUTOMATA (PDA) FINITE STATE CONTROL INPUT STACK (Last in, first out) Sofya Raskhodnikova; based on slides by Nick Hopper

  16. string pop push ε,ε → $ 0,ε→ 0 11 0011 0011 011 1,0 →ε ε,$ → ε 1,0 →ε 1 0 STACK $ 0 $ $

  17. string pop push ε,ε → $ 0,ε→ 0 1 001 001 01 1,0 →ε ε,$ → ε 1,0 →ε 0 STACK $ 0 $ $ PDA to recognize L = { 0n1n | n ≥ 0 }

  18. Formal Definition A PDAis a 6-tuple P = (Q, Σ, Γ, , q0, F) Q is a finite set of states Σ is the alphabet Γis the stack alphabet  : Q ΣεΓε → P(Q Γε) is the transition function q0 Q is the start state F  Q is the set of accept states P(Q Γε) is the set of subsets of Q Γεand Σε = Σ {ε} Note: A PDA is defined to be nondeterministic. Sofya Raskhodnikova; based on slides by Nick Hopper

  19. Formal Definition A PDAis a 6-tuple P = (Q, Σ, Γ, , q0, F) Q is a finite set of states Σ is the alphabet Γis the stack alphabet  : Q ΣεΓε → P(Q Γε) is the transition function q0 Q is the start state F  Q is the set of accept states A PDA starts with an empty stack. Itaccepts a string if at least one of its computational branches reads all the input and gets into an accept state at the end of it. Sofya Raskhodnikova; based on slides by Nick Hopper

  20. ε,ε → $ 0,ε→ 0 q0 q1 1,0 →ε ε,$ → ε q3 q2 1,0 →ε Q = {q0, q1, q2, q3} Σ = {0,1} Γ = {$,0}  : Q Σε Γε→ P(Q  Γε) (q1,1,0) = { (q2,ε) } (q2,1,1) = 

  21. EVEN-LENGTH PALINDROMES Σ = {a, b, c, …, z} ε,ε → $ ,ε→ q0 q1 ε,ε→ε ε,$ → ε ,→ε q3 q2

  22. q2 q3 q1 q4 q6 q5 Build a PDA to recognize L = { aibjck | i, j, k ≥ 0 and (i = j or i = k) } c,ε→ε b,a →ε q0 ε,$ → ε ε,ε → ε ε,ε → $ ε,ε → ε ε,ε → ε ε,$ → ε a,ε→ a b,ε→ε c,a →ε

  23. CONTEXT-FREEGRAMMARS (CFGs) production rules start variable A → 0A1 A → B B → # variables terminals A  0A1  00A11  00B11  00#11 Sofya Raskhodnikova; based on slides by Nick Hopper

  24. VALLEY GIRL GRAMMAR <PHRASE> → <FILLER><PHRASE> <PHRASE> → <START><END> <FILLER> → LIKE <FILLER> → UMM <START> → YOU KNOW <START> → ε <END> → GAG ME WITH A SPOON <END> → AS IF <END> → WHATEVER <END> → LOSER Sofya Raskhodnikova; based on slides by Nick Hopper

More Related