1 / 8

Intro to Theory of Computation

L ECTURE 9 Theory of Computation Review Pumping Lemma for CFLs Correctness of CFGs. Intro to Theory of Computation. CS 464. Sofya Raskhodnikova. Pumping lemma for CFLs. Let L be a context-free language. Then there exists P such that For every w  L with |w| ≥ P.

Télécharger la présentation

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. LECTURE9 • Theory of Computation • Review • Pumping Lemma for CFLs • Correctness of CFGs Intro to Theory of Computation CS 464 Sofya Raskhodnikova Sofya Raskhodnikova; based on slides by Nick Hopper

  2. Pumping lemma for CFLs Let L be a context-free language Then there exists P such that For every w  L with |w| ≥ P there exist uvxyz=w, where: 1. |vy| > 0 2. |vxy| ≤ P 3. uvixyiz L for all i ≥ 0

  3. Negating the pumping lemma L is not context-free Let L be a context-free language. Then there exists P such that For every w  L with |w| ≥ P for every P, If There is a For every there exist uvxyz=w, where: 1. |vy| > 0 2. |vxy| ≤ P  There is an 3. For every i ≥ 0, uvixyiz  L

  4. Using the pumping lemma Prove L = {w#wR | w 2 {0,1}* and #1s = #0s} is not context-free Assume L is context-free. Then there is a pumping length P. No matter what P is, the string s = 0P1P#1P0P has |s| ¸ P and s 2 L. So there should be uvxyz=s with: 1) |vy| > 0, 2) |vxy| · P, 3) 8i, uvixyiz2 L. P P P P s = 00…0011…11#11…1100…00

  5. {w#wR | w 2 {0,1}* and #1s = #0s}is not a CFL: proof Assume L is context-free. Then there is a pumping length P. vxy cannot be only in either half, since pumping would make one side of # longer than the other. since # is in x and |vxy| · P, neither v nor y can have 0s, and at least one must have a 1. Then uv2xy2z has more 1s than 0s and is not in L. No matter what P is, the string s = 0P1P#1P0P has |s| ¸ P and s 2 L. # cannot be in v or y since pumping would add too many #s. So it must be in x. So there should be uvxyz=s with: 1) |vy| > 0, 2) |vxy| · P, 3) 8 i, uvixyiz 2 L. P P P P s = 00…0011…11#11…1100…00 vxy

  6. Give the language of this CFG Answer: the set of all strings over alphabet {a,b} that have the same number of ’s and ’s Prove that your answer is correct

  7. Proof of correctness Every generated string has the same number of ’s and ’s Proof: Every rule that generates terminals, generates the same number of ’s and ’s Sofya Raskhodnikova; based on slides by Nick Hopper

  8. Proof of correctness Every string that has the same number of ’s and ’s is generated. Proof idea: Consider a string that has the same number of ’s and ’s. Plot ’s of ’s in the first characters of as a function of (Done on the board). Sofya Raskhodnikova; based on slides by Nick Hopper

More Related