# Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages.

## Presentation on theme: "Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages."— Presentation transcript:

Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages

Costas Busch - RPI2 Take an infinite context-free language Example: Generates an infinite number of different strings

Costas Busch - RPI3 A derivation: In a derivation of a long string, variables are repeated

Costas Busch - RPI4 Derivation treestring

Costas Busch - RPI5 repeated Derivation treestring

Costas Busch - RPI6

7 Repeated Part

Costas Busch - RPI8 Another possible derivation from

Costas Busch - RPI9

10 A Derivation from

Costas Busch - RPI11

Costas Busch - RPI12

Costas Busch - RPI13 A Derivation from

Costas Busch - RPI14

Costas Busch - RPI15

Costas Busch - RPI16

Costas Busch - RPI17

Costas Busch - RPI18 A Derivation from

Costas Busch - RPI19

Costas Busch - RPI20

Costas Busch - RPI21

Costas Busch - RPI22 In General:

Costas Busch - RPI23 Consider now an infinite context-free language Take so that I has no unit-productions no -productions Let be the grammar of

Costas Busch - RPI24 (Number of productions) x (Largest right side of a production) = Let Example : Let

Costas Busch - RPI25 Take a string with length We will show: in the derivation of a variable of is repeated

Costas Busch - RPI26

Costas Busch - RPI27 maximum right hand side of any production

Costas Busch - RPI28 Number of productions in grammar

Costas Busch - RPI29 Number of productions in grammar Some production must be repeated Repeated variable

Costas Busch - RPI30 Some variable is repeated Derivation of string

Costas Busch - RPI31 Last repeated variable repeated Strings of terminals Derivation tree of string

Costas Busch - RPI32 Possible derivations:

Costas Busch - RPI33 We know: This string is also generated:

Costas Busch - RPI34 This string is also generated: The original We know:

Costas Busch - RPI35 This string is also generated: We know:

Costas Busch - RPI36 This string is also generated: We know:

Costas Busch - RPI37 This string is also generated: We know:

Costas Busch - RPI38 Therefore, any string of the form is generated by the grammar

Costas Busch - RPI39 knowing that we also know that Therefore,

Costas Busch - RPI40 Observation: Since is the last repeated variable

Costas Busch - RPI41 Observation: Since there are no unit or -productions

Costas Busch - RPI42 The Pumping Lemma: there exists an integer such that for any string we can write For infinite context-free language with lengths and it must be:

Costas Busch - RPI43 Applications of The Pumping Lemma

Costas Busch - RPI44 Context-free languages Non-context free languages

Costas Busch - RPI45 Theorem: The language is not context free Proof: Use the Pumping Lemma for context-free languages

Costas Busch - RPI46 Assume for contradiction that is context-free Since is context-free and infinite we can apply the pumping lemma

Costas Busch - RPI47 Pumping Lemma gives a magic number such that: Pick any string with length We pick:

Costas Busch - RPI48 We can write: with lengths and

Costas Busch - RPI49 Pumping Lemma says: for all

Costas Busch - RPI50 We examine all the possible locations of string in

Costas Busch - RPI51 Case 1: is within

Costas Busch - RPI52 Case 1: and consist from only

Costas Busch - RPI53 Case 1: Repeating and

Costas Busch - RPI54 Case 1: From Pumping Lemma:

Costas Busch - RPI55 Case 1: From Pumping Lemma: However: Contradiction!!!

Costas Busch - RPI56 Case 2: is within

Costas Busch - RPI57 Case 2: Similar analysis with case 1

Costas Busch - RPI58 Case 3: is within

Costas Busch - RPI59 Case 3: Similar analysis with case 1

Costas Busch - RPI60 Case 4: overlaps and

Costas Busch - RPI61 Case 4: Possibility 1:contains only

Costas Busch - RPI62 Case 4: Possibility 1:contains only

Costas Busch - RPI63 Case 4: From Pumping Lemma:

Costas Busch - RPI64 Case 4: From Pumping Lemma: However: Contradiction!!!

Costas Busch - RPI65 Case 4: Possibility 2:contains and contains only

Costas Busch - RPI66 Case 4: Possibility 2:contains and contains only

Costas Busch - RPI67 Case 4: From Pumping Lemma:

Costas Busch - RPI68 Case 4: From Pumping Lemma: However: Contradiction!!!

Costas Busch - RPI69 Case 4: Possibility 3:contains only contains and

Costas Busch - RPI70 Case 4: Possibility 3:contains only contains and Similar analysis with Possibility 2

Costas Busch - RPI71 Case 5: overlaps and

Costas Busch - RPI72 Case 5: Similar analysis with case 4

Costas Busch - RPI73 There are no other cases to consider (since, string cannot overlap, and at the same time)

Costas Busch - RPI74 In all cases we obtained a contradiction Therefore: The original assumption that is context-free must be wrong Conclusion:is not context-free

Download ppt "Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages."

Similar presentations