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 finite state machine, and that every finite state machine A has a finite 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 finite automata would not work. Instead, we concentrate on the fact that each grammar can only have a finite 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 find 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 defined recursively as follows: 1. The depth d ( T ) of a tree T consisting only of a single node (the root node) is defined 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 defined 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 find 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 ).
This is the end of the preview. Sign up to access the rest of the document.

{[ snackBarMessage ]}

### What students are saying

• As a current student on this bumpy collegiate pathway, I stumbled upon Course Hero, where I can find study resources for nearly all my courses, get online help from tutors 24/7, and even share my old projects, papers, and lecture notes with other students.

Kiran Temple University Fox School of Business ‘17, Course Hero Intern

• I cannot even describe how much Course Hero helped me this summer. It’s truly become something I can always rely on and help me. In the end, I was not only able to survive summer classes, but I was able to thrive thanks to Course Hero.

Dana University of Pennsylvania ‘17, Course Hero Intern

• The ability to access any university’s resources through Course Hero proved invaluable in my case. I was behind on Tulane coursework and actually used UCLA’s materials to help me move forward and get everything together on time.

Jill Tulane University ‘16, Course Hero Intern