1.55k likes | 1.72k Views
CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 10 Mälardalen University 2012. Content The Pumping Lemma for CFL Applications of the Pumping Lemma for CFL Example of Midterm Exam 2 (CFL). The Pumping Lemma for Context-Free Languages.
E N D
CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 10 Mälardalen University 2012
ContentThe Pumping Lemma for CFLApplications of the Pumping Lemma for CFLExample of Midterm Exam 2 (CFL)
The Pumping LemmaforContext-Free Languages Based on C Busch, RPI, Models of Computation
Take an infinite context-free language. It generates an infinite number of different strings: Example:
string Derivation tree
string Derivation tree repeated
Therefore, the string is also generated by the grammar
We know: We also know the following string is generated:
We know: Therefore, the following string is also generated:
We know: Therefore, the following string is also generated:
We know: Therefore, the following string is also generated:
Therefore, knowing that is generated by grammar We also know that is generated by
We are given an infinite context-free grammar . In general Assume has no unit-productions and no -productions.
Take a string with length bigger than (Number of productions) x (Largest right side of a production) > Consequence: Some variable must be repeated in the derivation of .
string Last repeated variable repeated stringsof terminals
Possible derivations
We know: Following string is also generated:
We know: This string is also generated: The original
We know: This string is also generated:
We know: This string is also generated:
We know: This string is also generated:
Therefore, any string of the form is generated by the grammar
Therefore knowing that we also know that
(Number of productions) x (Largest right side of a production) Observation: Since is the last repeated variable A string has length bigger than >
Observation Since there are no unit or productions
For infinite context-free language there exists an integer such that for any string we can write with lengths and The Pumping Lemma for CFL
Unrestricted grammarlanguages Non-regular languages Context-Free Languages Regular Languages
Example Theorem The language is not context free. Proof Use the Pumping Lemma for context-free languages.
Assume thecontrary, that is context-free. Since is context-free and infinite we can apply the pumping lemma.
Pumping Lemma gives a number such that: for any string with length We can choose e.g.
We can write: with lengths and
Pumping Lemma says: for all
We examine all the possible locations of string in
Case 1: is within
Case 1: and consist from only
Case 1: Repeating and
Case 1: From Pumping Lemma:
Case 1: From Pumping Lemma: However: Contradiction!
Case 2: is within
Case 3: is within