Download presentation
Presentation is loading. Please wait.
Published byAlbert French Modified over 9 years ago
2
INHERENT LIMITATIONS OF COMPUTER PROGAMS CSci 4011
3
QUIZ 2 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, xy i z L. Give a CFG for the language {a n b 2n : n ≥ 0 }: S → aSbb | ε A PDA transition function takes as input a state, an input symbol, and: 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
4
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?
5
I will be in my office: Today 4-5:30pm and Thurs. 9:00am-11:00am HW4 SOLUTIONS POSTED TOMORROW AT NOON.
6
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| isthe length of x The unique string of length 0 will be denoted by ε and will be called the empty or null string NOTATION A language over Σ is a set of strings over Σ
7
Q = {q 0, q 1, q 2, q 3 } are states Σ = {0,1} is the alphabet : Q Σ → Q transition function * q 0 Q is start state F = {q 1, q 2 } Q accept states M = (Q, Σ, , q 0, F) where 01 q0q0 q0q0 q1q1 q1q1 q2q2 q2q2 q2q2 q3q3 q2q2 q3q3 q0q0 q2q2 * q2q2 0 0,1 0 0 1 1 1 q0q0 q1q1 q3q3 M NFAs have “choices” -- : Q Σ P (Q), and accept on input w if there is a path from q 0 to a q a ∈ F.
8
DFA NFA Regular Language Regular Expression DEF
9
SOME LANGUAGES ARE NOT REGULAR! B = {0 n 1 n | n ≥ 0} is NOT regular! Suppose B is regular and let P be the pumping length. The string 0 P 1 P B and has length at least P. So by the pumping lemma, there should be xyz = 0 P 1 P 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.
10
ε,ε → $ 0,ε → 0 1,0 → ε ε,$ → ε stringpoppush A PDA accepts the string x if there is a path on input x and empty stack from q 0 to some q a 2 F. Following transition “a,b c” reads “a” from the input, pops “b” off the stack, and pushes “c” onto it.
11
A → 0A1 A → B B → # CONTEXT-FREE GRAMMARS A 0A1 00A11 00B11 00#11 A derives 00#11 in 4 steps. uVw yields uvw if (V → v) 2 R. variables terminals production rules start variable
12
PARSE TREES A 0A1 00A11 00B11 00#11 A B 01# A A 01 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.
13
THE CHOMSKY NORMAL FORM A context-free grammar is in Chomsky normal form if every rule is of the form: A → BC A → a S → ε B and C are not start variable a is a terminal 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
14
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 1. |vy| > 0 there exist uvxyz=w, where: 3. uv i xy i z L for any i ≥ 0 2. |vxy| ≤ P { ww | w ∈ Σ* } is not regular!
15
USING THE PUMPING LEMMA Prove L = {w#w R | 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 = 0 P 1 P #1 P 0 P has |s| ≥ P and s ∈ L. So there should be uvxyz=s with: 1) |vy| > 0, 2) |vxy| ≤ P, 3) ∀ i, uv i xy i z ∈ L. s = 00…0011…11#11…1100…00 P P P P
16
USING THE PUMPING LEMMA Prove L = {w#w R | 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 = 0 P 1 P #1 P 0 P has |s| ¸ P and s 2 L. So there should be uvxyz=s with: 1) |vy| > 0, 2) |vxy| ≤ P, 3) ∀ i, uv i xy i z ∈ L. s = 00…0011…11#11…1100…00 P P P P vxy cannot be only in either half, since pumping would make one side of # longer than the other. # cannot be in v or y since pumping would add too many #s. So it must be in x. vxy since # is in x and |vxy| · P, neither v nor y can have 0s, and at least one must have a 1. Then uv 2 xy 2 z has more 1s than 0s and is not in L.
18
CONTEXT-FREE LANGUAGES 100 200 300 REGULAR LANGUAGES 100 200 300 NON-REGULAR NON-CFL 100 200 300 FINAL JEOPARDY
19
A DFA for the language (ab ∪ ba)*
20
A regular expression for the set of strings accepted by the NFA: 0,1 1
21
A proof that the language { w Σ*| w ≠ w R } is not regular.
22
The language accepted by the following PDA: ε,ε → $ 0,ε → 0 1,0 → ε ε,0 → ε
23
A CFG for the language { w # b n | |w| = n }.
24
Regular operations that the Context-Free Languages are closed under. DAILY DOUBLE
25
A class of strings in the language L = { 1 n #1 n | n ≥ 0} that contradicts the regular pumping lemma for each pumping length p.
26
A class of strings in the language {a n #a n #a n | n ≥ 0 } that contradicts the context-free pumping lemma for each pumping length p.
27
A proof that the language { a n #b m | m = n 2, n ≥ 0 } is not context-free.
28
TRUE
Similar presentations
© 2025 SlidePlayer.com. Inc.
All rights reserved.