Download presentation

Presentation is loading. Please wait.

1
1 The Pumping Lemma for Context-Free Languages

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

3
3 A derivation: In a derivation of a long string, variables are repeated

4
4 Derivation treestring

5
5 repeated Derivation treestring

6
6

7
7 Repeated Part

8
8 Another possible derivation from

9
9

10
10 A Derivation from

11
11

12
12

13
13 A Derivation from

14
14

15
15

16
16

17
17

18
18 A Derivation from

19
19

20
20

21
21

22
22 In General:

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

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

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

26
26

27
27 maximum right hand side of any production

28
28 Number of productions in grammar

29
29 Number of productions in grammar Some production must be repeated Repeated variable

30
30 Some variable is repeated Derivation of string

31
31 Last repeated variable repeated Strings of terminals Derivation tree of string

32
32 Possible derivations:

33
33 We know: This string is also generated:

34
34 This string is also generated: The original We know:

35
35 This string is also generated: We know:

36
36 This string is also generated: We know:

37
37 This string is also generated: We know:

38
38 Therefore, any string of the form is generated by the grammar

39
39 knowing that we also know that Therefore,

40
40 Observation: Since is the last repeated variable

41
41 Observation: Since there are no unit or -productions

42
42 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
43 Applications of The Pumping Lemma

44
44 Context-free languages Non-context free languages

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

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

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

48
48 We can write: with lengths and

49
49 Pumping Lemma says: for all

50
50 We examine all the possible locations of string in

51
51 Case 1: is within

52
52 Case 1: and consist from only

53
53 Case 1: Repeating and

54
54 Case 1: From Pumping Lemma:

55
55 Case 1: From Pumping Lemma: However: Contradiction!!!

56
56 Case 2: is within

57
57 Case 2: Similar analysis with case 1

58
58 Case 3: is within

59
59 Case 3: Similar analysis with case 1

60
60 Case 4: overlaps and

61
61 Case 4: Possibility 1:contains only

62
62 Case 4: Possibility 1:contains only

63
63 Case 4: From Pumping Lemma:

64
64 Case 4: From Pumping Lemma: However: Contradiction!!!

65
65 Case 4: Possibility 2:contains and contains only

66
66 Case 4: Possibility 2:contains and contains only

67
67 Case 4: From Pumping Lemma:

68
68 Case 4: From Pumping Lemma: However: Contradiction!!!

69
69 Case 4: Possibility 3:contains only contains and

70
70 Case 4: Possibility 3:contains only contains and Similar analysis with Possibility 2

71
71 Case 5: overlaps and

72
72 Case 5: Similar analysis with case 4

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

74
74 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