Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


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

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

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

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

4 Costas Busch - RPI4 Derivation treestring

5 Costas Busch - RPI5 repeated Derivation treestring

6 Costas Busch - RPI6

7 7 Repeated Part

8 Costas Busch - RPI8 Another possible derivation from

9 Costas Busch - RPI9

10 10 A Derivation from

11 Costas Busch - RPI11

12 Costas Busch - RPI12

13 Costas Busch - RPI13 A Derivation from

14 Costas Busch - RPI14

15 Costas Busch - RPI15

16 Costas Busch - RPI16

17 Costas Busch - RPI17

18 Costas Busch - RPI18 A Derivation from

19 Costas Busch - RPI19

20 Costas Busch - RPI20

21 Costas Busch - RPI21

22 Costas Busch - RPI22 In General:

23 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

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

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

26 Costas Busch - RPI26

27 Costas Busch - RPI27 maximum right hand side of any production

28 Costas Busch - RPI28 Number of productions in grammar

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

30 Costas Busch - RPI30 Some variable is repeated Derivation of string

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

32 Costas Busch - RPI32 Possible derivations:

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

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

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

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

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

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

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

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

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

42 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:

43 Costas Busch - RPI43 Applications of The Pumping Lemma

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

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

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

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

48 Costas Busch - RPI48 We can write: with lengths and

49 Costas Busch - RPI49 Pumping Lemma says: for all

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

51 Costas Busch - RPI51 Case 1: is within

52 Costas Busch - RPI52 Case 1: and consist from only

53 Costas Busch - RPI53 Case 1: Repeating and

54 Costas Busch - RPI54 Case 1: From Pumping Lemma:

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

56 Costas Busch - RPI56 Case 2: is within

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

58 Costas Busch - RPI58 Case 3: is within

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

60 Costas Busch - RPI60 Case 4: overlaps and

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

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

63 Costas Busch - RPI63 Case 4: From Pumping Lemma:

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

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

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

67 Costas Busch - RPI67 Case 4: From Pumping Lemma:

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

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

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

71 Costas Busch - RPI71 Case 5: overlaps and

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

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

74 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


Ads by Google