Download presentation

Presentation is loading. Please wait.

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

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

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

4
Courtesy Costas Busch - RPI4 Derivation treestring

5
Courtesy Costas Busch - RPI5 repeated Derivation treestring

6
Courtesy Costas Busch - RPI6

7
7 Repeated Part

8
Courtesy Costas Busch - RPI8 Another possible derivation from

9
Courtesy Costas Busch - RPI9

10
10 A Derivation from

11
Courtesy Costas Busch - RPI11

12
Courtesy Costas Busch - RPI12

13
Courtesy Costas Busch - RPI13 A Derivation from

14
Courtesy Costas Busch - RPI14

15
Courtesy Costas Busch - RPI15

16
Courtesy Costas Busch - RPI16

17
Courtesy Costas Busch - RPI17

18
Courtesy Costas Busch - RPI18 A Derivation from

19
Courtesy Costas Busch - RPI19

20
Courtesy Costas Busch - RPI20

21
Courtesy Costas Busch - RPI21

22
Courtesy Costas Busch - RPI22 In General:

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

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

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

26
Courtesy Costas Busch - RPI26

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

28
Courtesy Costas Busch - RPI28 Number of productions in grammar

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

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

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

32
Courtesy Costas Busch - RPI32 Possible derivations:

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

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

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

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

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

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

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

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

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

42
Courtesy 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
Courtesy Costas Busch - RPI43 Reminders Choosing m : The thing to remember about the pumping length m is that you don’t get to choose it! The pumping lemma itself “supplies” this value to you. So you cannot make any assumption about what the value of m is, you simply must use it as a fixed value over which you have no control.

44
Courtesy Costas Busch - RPI44 Reminders Choosing w : A good place to start is with a string that incorporates the pumping length m in it somehow, e.g. a m b m if your alphabet is {a, b}. The right string can reduce the number of different partitions you must consider. As you work through more and more examples of these types of proofs, you gather insight into the types of strings that will work best. So the best way to get better at choosing w is to read examples and, even better, to work problems.

45
Courtesy Costas Busch - RPI45 Reminders Choosing the partition of w : The thing to remember about the partition of w into its parts u, v, x, y & z is, again, that you don’t get to choose it! The partition is, in some sense, chosen for you. But it is never explicitly given to you (the way you can think of the pumping length as being given to you), so you must consider all possible partitions. Remember, that for each partition of w, you must show that for some integer i, the string uv i xy i z is not in L.

46
Courtesy Costas Busch - RPI46 Reminders Choosing i : You do get to choose this, and you’re given quite a bit of freedom. You may pick i so that it is any integer greater than 1, or even 0. It doesn’t make sense to select i = 1, since that would describe w, a string which you already know to be in L.) You may even choose i differently in different cases of your proof. This is useful, for example, if some cases work only if you “pump down” to i = 0, while others work only if you “pump up” to i = 2 or i = 3.

47
Courtesy Costas Busch - RPI47 Cautions Be sure that the w you choose is actually in the language L you are trying to prove something about! If not, the pumping lemma doesn’t guarantee anything about whether pumping that w should give strings in L. Also, be sure that your string w is long enough: it must have length at least m. In the pumping lemma for context-free languages, when you pump a particular string, note that the i describing the number of repetitions of v must be the same i describing the number of repetitions of y. So it doesn’t help your proof to show a “pumped” string uv 0 xy 2 z which is not in L, since 0 ≠ 2.

48
Courtesy Costas Busch - RPI48 Applications of The Pumping Lemma

49
Courtesy Costas Busch - RPI49 Context-free languages Non-context free languages

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

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

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

53
Courtesy Costas Busch - RPI53 We can write: with lengths and

54
Courtesy Costas Busch - RPI54 Pumping Lemma says: for all

55
Courtesy Costas Busch - RPI55 We examine all the possible locations of string in

56
Courtesy Costas Busch - RPI56 Case 1: is within

57
Courtesy Costas Busch - RPI57 Case 1: and consist from only

58
Courtesy Costas Busch - RPI58 Case 1: Repeating and

59
Courtesy Costas Busch - RPI59 Case 1: From Pumping Lemma:

60
Courtesy Costas Busch - RPI60 Case 1: From Pumping Lemma: However: Contradiction!!!

61
Courtesy Costas Busch - RPI61 Case 2: is within

62
Courtesy Costas Busch - RPI62 Case 2: Similar analysis with case 1

63
Courtesy Costas Busch - RPI63 Case 3: is within

64
Courtesy Costas Busch - RPI64 Case 3: Similar analysis with case 1

65
Courtesy Costas Busch - RPI65 Case 4: overlaps and

66
Courtesy Costas Busch - RPI66 Case 4: Possibility 1:contains only

67
Courtesy Costas Busch - RPI67 Case 4: Possibility 1:contains only

68
Courtesy Costas Busch - RPI68 Case 4: From Pumping Lemma:

69
Courtesy Costas Busch - RPI69 Case 4: From Pumping Lemma: However: Contradiction!!!

70
Courtesy Costas Busch - RPI70 Case 4: Possibility 2:contains and contains only

71
Courtesy Costas Busch - RPI71 Case 4: Possibility 2:contains and contains only

72
Courtesy Costas Busch - RPI72 Case 4: From Pumping Lemma:

73
Courtesy Costas Busch - RPI73 Case 4: From Pumping Lemma: However: Contradiction!!!

74
Courtesy Costas Busch - RPI74 Case 4: Possibility 3:contains only contains and

75
Courtesy Costas Busch - RPI75 Case 4: Possibility 3:contains only contains and Similar analysis with Possibility 2

76
Courtesy Costas Busch - RPI76 Case 5: overlaps and

77
Courtesy Costas Busch - RPI77 Case 5: Similar analysis with case 4

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

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

80
Courtesy Costas Busch - RPI80 More Applications of The Pumping Lemma

81
Courtesy Costas Busch - RPI81 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:

82
Courtesy Costas Busch - RPI82 Context-free languages Non-context free languages

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

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

85
Courtesy Costas Busch - RPI85 Pumping Lemma gives a magic number such that: Pick any string of with length at least we pick:

86
Courtesy Costas Busch - RPI86 We can write: with lengths and Pumping Lemma says: for all

87
Courtesy Costas Busch - RPI87 We examine all the possible locations of string in

88
Courtesy Costas Busch - RPI88 Case 1: is within the first

89
Courtesy Costas Busch - RPI89 Case 1: is within the first

90
Courtesy Costas Busch - RPI90 Case 1: is within the first

91
Courtesy Costas Busch - RPI91 Case 1: is within the first Contradiction!!! However, from Pumping Lemma:

92
Courtesy Costas Busch - RPI92 is in the first Case 2:

93
Courtesy Costas Busch - RPI93 is in the first Case 2:

94
Courtesy Costas Busch - RPI94 is in the first Case 2:

95
Courtesy Costas Busch - RPI95 is in the first Case 2: Contradiction!!! However, from Pumping Lemma:

96
Courtesy Costas Busch - RPI96 is in the first overlaps the first Case 3:

97
Courtesy Costas Busch - RPI97 is in the first overlaps the first Case 3:

98
Courtesy Costas Busch - RPI98 is in the first overlaps the first Case 3:

99
Courtesy Costas Busch - RPI99 is in the first overlaps the first Case 3: Contradiction!!! However, from Pumping Lemma:

100
Courtesy Costas Busch - RPI100 Overlaps the first in the first Case 4: Analysis is similar to case 3

101
Courtesy Costas Busch - RPI101 Other cases: is within or Analysis is similar to case 1:

102
Courtesy Costas Busch - RPI102 More cases: overlaps or Analysis is similar to cases 2,3,4:

103
Courtesy Costas Busch - RPI103 Since, it is impossible to overlap: There are no other cases to consider nor

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

105
Courtesy Costas Busch - RPI105 Context-free languages Non-context free languages

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

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

108
Courtesy Costas Busch - RPI108 Pumping Lemma gives a magic number such that: Pick any string of with length at least we pick:

109
Courtesy Costas Busch - RPI109 We can write: with lengths and Pumping Lemma says: for all

110
Courtesy Costas Busch - RPI110 We examine all the possible locations of string in There is only one case to consider

111
Courtesy Costas Busch - RPI111

112
Courtesy Costas Busch - RPI112

113
Courtesy Costas Busch - RPI113

114
Courtesy Costas Busch - RPI114

115
Courtesy Costas Busch - RPI115 Since, for we have:

116
Courtesy Costas Busch - RPI116

117
Courtesy Costas Busch - RPI117 Contradiction!!! However, from Pumping Lemma:

118
Courtesy Costas Busch - RPI118 We obtained a contradiction Therefore: The original assumption that is context-free must be wrong Conclusion:is not context-free

119
Courtesy Costas Busch - RPI119 Context-free languages Non-context free languages

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

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

122
Courtesy Costas Busch - RPI122 Pumping Lemma gives a magic number such that: Pick any string of with length at least we pick:

123
Courtesy Costas Busch - RPI123 We can write: with lengths and Pumping Lemma says: for all

124
Courtesy Costas Busch - RPI124 We examine all the possible locations of string in

125
Courtesy Costas Busch - RPI125 Most complicated case: is in

126
Courtesy Costas Busch - RPI126

127
Courtesy Costas Busch - RPI127 Most complicated sub-case:and

128
Courtesy Costas Busch - RPI128 Most complicated sub-case:and

129
Courtesy Costas Busch - RPI129 Most complicated sub-case:and

130
Courtesy Costas Busch - RPI130 and

131
Courtesy Costas Busch - RPI131

132
Courtesy Costas Busch - RPI132 However, from Pumping Lemma: Contradiction!!!

133
Courtesy Costas Busch - RPI133 When we examine the rest of the cases we also obtain a contradiction

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

Similar presentations

© 2021 SlidePlayer.com Inc.

All rights reserved.

To make this website work, we log user data and share it with processors. To use this website, you must agree to our Privacy Policy, including cookie policy.

Ads by Google