LectureNotes14

# LectureNotes14 - ECS 120 Lesson 14 Non-Context-Free...

This preview shows pages 1–3. Sign up to view the full content.

ECS 120 Lesson 14 – Non-Context-Free Languages, the Context-Free Pumping Lemma Oliver Kreylos Monday, April 30th, 2001 In this lecture, we will close our discussion of context-free languages by introducing a version of the Pumping Lemma for context-free languages. It will allow us to prove that certain languages are not context-free, meaning they can neither be generated by context-free grammars, nor can they be accepted by pushdown automata. Here are some examples of non-context free languages: L 1 = ± 0 n 1 n 0 n ² ² n 0 ³ L 2 = ± ww ² ² w Σ * ³ L 3 = ± w ASCII * ² ² w is a syntactically correct C program ³ 1 The Context-Free Pumping Lemma For regular languages, the one observation that led us to the discovery of the Pumping Lemma was that every regular language is accepted by a ﬁnite state machine, and that every ﬁnite state machine A has a ﬁnite number p of states. From this we were able to conclude that the computation chain for any word in the language accepted by A that has at least p characters must include one of A ’s states twice. This leads to a loop in the computation chain, that can be taken by the machine any number of times, without the machine being able to notice this. Therefore, any word resulting from taking the loop any number of times must be in the language as well. 1

This preview has intentionally blurred sections. Sign up to view the full version.

View Full Document
For context-free languages, we can observe a similar fact. In this case, however, our reasoning will be based on context-free grammars, not on push- down automata. Since the latter have an arbitrarily large stack, reasoning in a similar way as for ﬁnite automata would not work. Instead, we concentrate on the fact that each grammar can only have a ﬁnite number of variables. Let us consider a grammar G = ( V, Σ , R, S ) in Chomsky Normal Form. We know that every parse tree for any word w L ( G ) in the grammar’s language is a binary tree: Each rule in a CNF grammar is either of the form A a or A BC . We will now try to ﬁnd out more about the structure of those parse trees. One important property when reasoning about trees is their depth . The depth of a tree is deﬁned recursively as follows: 1. The depth d ( T ) of a tree T consisting only of a single node (the root node) is deﬁned to be zero. 2. If a tree T is not only a single node, it is a root node having chil- dren T 1 , T 2 , . . . , T k , where each child T i is again a tree. The depth d ( T ) of T is deﬁned as d ( T ) := 1 + max ± d ( T i ) ² ² i = 1 , 2 , . . . , k ³ . We now ask how the length of a word w L ( G ) and the depth of its parse trees are related. We know that the characters of w are associated with leaves of its parse tree, so we have to ﬁnd out how the depth of a binary tree relates to its maximum number of leaves. We claim that every binary tree T of depth d ( T ) has at most #leaves( T ) 2 d ( T ) leaves. We prove this claim by induction on the depth d ( T ). Induction Basis
This is the end of the preview. Sign up to access the rest of the document.

## This note was uploaded on 05/20/2010 for the course ECS 120 taught by Professor Filkov during the Spring '07 term at UC Davis.

### Page1 / 9

LectureNotes14 - ECS 120 Lesson 14 Non-Context-Free...

This preview shows document pages 1 - 3. Sign up to view the full document.

View Full Document
Ask a homework question - tutors are online