1 / 27

INHERENT LIMITATIONS OF COMPUTER PROGAMS

CSci 4011. INHERENT LIMITATIONS OF COMPUTER PROGAMS. A PDA transition function takes as input a state, an input symbol, and:. QUIZ 2. a stack symbol. If P is a PDA then L(P) is the set:. { w | P accepts w }. Let G = (V,Σ,R,S) be a CFG then R is the set of:. Production rules.

lonato
Download Presentation

INHERENT LIMITATIONS OF COMPUTER PROGAMS

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. CSci 4011 INHERENT LIMITATIONS OF COMPUTER PROGAMS

  2. A PDA transition function takes as input a state, an input symbol, and: QUIZ 2 a stack symbol If P is a PDA then L(P) is the set: { w | P accepts w } Let G = (V,Σ,R,S) be a CFG then R is the set of: Production rules The regular pumping lemma says that… if w L and |w| ≥ P, then Ǝx,y,z so w = xyz and: (1) |xy| ≤ P (2) |y| > 0 (3) For every i ≥ 0, xyiz  L. Give a CFG for the language {anb2n : n ≥ 0 }: S → aSbb | ε

  3. What are practical uses for PDAs? Why are pumping lemmas annoying? Buddhist temple, CFG, levitating during meditation? What will be on the upcoming midterm? WTF Implementation of PL? Context-Free Pumping Lemma? Why do I care about CNF? Where are we going with this? What does it mean for something to be context free? How does a CFG relate to a computer? What is your favorite topic in this class? Is there a rule for the CF pumping lemma like |xy|≤P? Is there a multi-stack PDA? How many more types of languages are there? PDA/CFG conversions? CNF Unit rule redundancy? Do we need to prove every case for the pumping lemma? Is this class graded on a curve?

  4. I will be in my office: Today 4-5:30pm and Thurs. 9:00am-11:00am HW4 SOLUTIONS POSTED TOMORROW AT NOON.

  5. NOTATION An alphabetΣ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x a string, |x| is the length of x The unique string of length 0 will be denoted by ε and will be called the empty or null string A language over Σ is a set of strings over Σ

  6. q1 1 0 0,1 1 M q0 q2 0 0 1 q3 M = (Q, Σ, , q0, F) where Q = {q0, q1, q2, q3} are states Σ = {0,1} is the alphabet  : Q Σ→ Q transition function* q0 Q is start state F = {q1, q2} Q accept states * NFAs have “choices” --  : Q  ΣP (Q), and accept on input w if there is a path from q0 to a qa∈ F.

  7. NFA DFA DEF Regular Language Regular Expression

  8. SOME LANGUAGES ARE NOT REGULAR! B = {0n1n | n ≥ 0} is NOT regular! Suppose B is regular and let P be the pumping length. The string 0P1P  B and has length at least P. So by the pumping lemma, there should be xyz = 0P1P so that |xy| ≤ P, |y| > 0, and xyyzB. But y must be only 0s (otherwise |xy| > P), so xyyz has at least P+1 “0”s (because |y| > 0) but only P “1”s. So xyyz  B, contradicting the pumping lemma. Therefore B is not regular.

  9. string pop push ε,ε → $ 0,ε→ 0 1,0→ε ε,$ → ε 1,0→ε A PDA accepts the string x if there is a path on input x and empty stack from q0 to some qa2 F. Following transition “a,bc” reads “a” from the input, pops “b” off the stack, and pushes “c” onto it.

  10. CONTEXT-FREE GRAMMARS production rules start variable A → 0A1 A → B B → # variables terminals A  0A1  00A11  00B11  00#11 uVw yields uvw if (V → v) 2 R. A derives 00#11 in 4 steps.

  11. PARSE TREES A A A B 0 0 # 1 1 A  0A1  00A11  00B11  00#11 Each node corresponds to a rule in the derivation. A string is derived ambiguously if it has ≥ 2 parse trees. A grammar is ambiguous if it derives a string ambiguously.

  12. THE CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form: A → BC B and C are not start variable A → a a is a terminal S → ε S is the start variable Any variable A that is not the start variable can only generate strings of length > 0 Theorem: If G is in CNF, w  L(G) and |w| > 0, then any derivation of w in G has length ≤ 2|w| - 1

  13. THE CONTEXT-FREE PUMPING LEMMA 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 any i ≥ 0 { ww | w ∈Σ* } is not regular!

  14. USING THE PUMPING LEMMA Prove L = {w#wR | w ∈ {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∈L. So there should be uvxyz=s with: 1) |vy| > 0, 2) |vxy| ≤ P, 3)∀i, uvixyiz ∈ L. P P P P s = 00…0011…11#11…1100…00

  15. USING THE PUMPING LEMMA Prove L = {w#wR | w ∈ {0,1}* and #1s = #0s} is not context-free 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) ∀i, uvixyiz ∈ L. P P P P s = 00…0011…11#11…1100…00 vxy

  16. NON-REGULAR NON-CFL REGULAR LANGUAGES CONTEXT-FREE LANGUAGES 100 100 100 200 200 200 300 300 300 FINAL JEOPARDY

  17. A DFA for the language (ab ∪ ba)*

  18. A regular expression for the set of strings accepted by the NFA: 1 0,1

  19. A proof that the language { w  Σ*| w ≠ wR } is not regular.

  20. The language accepted by the following PDA: 0,ε→ 0 1,0→ε ε,ε → $ 1,0→ε ε,0 → ε

  21. A CFG for the language { w # bn | |w| = n }.

  22. DAILY DOUBLE Regular operations that the Context-Free Languages are closed under.

  23. A class of strings in the language L = { 1n#1n | n ≥ 0} that contradicts the regular pumping lemma for each pumping length p.

  24. A class of strings in the language {an#an#an | n ≥ 0 } that contradicts the context-free pumping lemma for each pumping length p.

  25. A proof that the language { an#bm | m = n2, n ≥ 0 } is not context-free.

  26. TRUE

More Related