# prof. busch - lsu1 pumping lemma for context-free languages

Post on 22-Dec-2015

214 views

Category:

## Documents

Tags:

• #### repeated slide

Embed Size (px)

TRANSCRIPT

• Slide 1
• Prof. Busch - LSU1 Pumping Lemma for Context-free Languages
• Slide 2
• Prof. Busch - LSU2 Take an infinite context-free language Example: Generates an infinite number of different strings
• Slide 3
• Prof. Busch - LSU3 A possible derivation: In a derivation of a long enough string, variables are repeated
• Slide 4
• Prof. Busch - LSU4 Derivation Tree Repeated variable
• Slide 5
• Prof. Busch - LSU5 Derivation Tree Repeated variable
• Slide 6
• Prof. Busch - LSU6
• Slide 7
• 7
• Slide 8
• 8
• Slide 9
• 9 Putting all together
• Slide 10
• Prof. Busch - LSU10 We can remove the middle part
• Slide 11
• Prof. Busch - LSU11
• Slide 12
• Prof. Busch - LSU12 We can repeated middle part two times 1 2
• Slide 13
• Prof. Busch - LSU13
• Slide 14
• Prof. Busch - LSU14 We can repeat middle part three times 1 2 3
• Slide 15
• Prof. Busch - LSU15
• Slide 16
• Prof. Busch - LSU16 Repeat middle part times i 1
• Slide 17
• Prof. Busch - LSU17 For any
• Slide 18
• Prof. Busch - LSU18 From Grammar and given string We inferred that a family of strings is in for any
• Slide 19
• Prof. Busch - LSU19 Arbitrary Grammars Consider now an arbitrary infinite context-free language Take so that it has no unit-productions and no -productions Let be the grammar of (remove them)
• Slide 20
• Prof. Busch - LSU20 Let be the number of variables Let be the maximum right-hand size of any production Example:
• Slide 21
• Prof. Busch - LSU21 Take string with. Then in the derivation tree of there is a path from the root to a leaf where a variable of is repeated Claim: Proof: Proof by contradiction
• Slide 22
• Prof. Busch - LSU22 Derivation tree of some variable is repeated We will show:
• Slide 23
• Prof. Busch - LSU23 First we show that the tree of has at least levels of nodes Suppose the opposite: Levels At most
• Slide 24
• Prof. Busch - LSU24 Level 0: Level 1: nodes Maximum number of nodes per level nodes The maximum right-hand side of any production
• Slide 25
• Prof. Busch - LSU25 Level 0: Level 1: nodes Level 2: Maximum number of nodes per level
• Slide 26
• Prof. Busch - LSU26 nodesLevel : Levels nodesLevel : Maximum possible string length = max nodes at level = Maximum number of nodes per level Level 0:nodes At most
• Slide 27
• Prof. Busch - LSU27 Therefore, maximum length of string : However we took, Contradiction!!! Therefore, the tree must have at least levels
• Slide 28
• Prof. Busch - LSU28 Thus, there is a path from the root to a leaf with at least nodes Levels At least symbol Variables (root) (leaf)
• Slide 29
• Prof. Busch - LSU29 Since there are at most different variables, some variable is repeated Pigeonhole principle END OF CLAIM PROOF
• Slide 30
• Prof. Busch - LSU30 Take now a stringwith some variable is repeated Take to be the deepest, so that only is repeated in subtree subtree of From claim:
• Slide 31
• Prof. Busch - LSU31 Strings of terminals yield We can write
• Slide 32
• Prof. Busch - LSU32 Example:
• Slide 33
• Prof. Busch - LSU33 Possible derivations
• Slide 34
• Prof. Busch - LSU34 Example:
• Slide 35
• Prof. Busch - LSU35 Remove Middle Part Yield:
• Slide 36
• Prof. Busch - LSU36 Repeat Middle part two times 1 2 Yield:
• Slide 37
• Prof. Busch - LSU37
• Slide 38
• Prof. Busch - LSU38 Repeat Middle part times 1 i Yield:
• Slide 39
• Prof. Busch - LSU39
• Slide 40
• Prof. Busch - LSU40 If we know that: then we also know: Therefore, For all since
• Slide 41
• Prof. Busch - LSU41 Observation 1: Since has no unit and -productions At least one of or is not
• Slide 42
• Prof. Busch - LSU42 Observation 2: since in subtree only variable is repeated subtree of Explanation follows.
• Slide 43
• Prof. Busch - LSU43 subtree of Various yields since no variable is repeated in Maximum right-hand side of any production
• Slide 44
• Prof. Busch - LSU44 Thus, if we choose critical length then, we obtain the pumping lemma for context-free languages
• Slide 45
• Prof. Busch - LSU45 The Pumping Lemma: there exists an integer such that for any string we can write For any infinite context-free language with lengths and it must be that:
• Slide 46
• Prof. Busch - LSU46 Applications of The Pumping Lemma
• Slide 47
• Prof. Busch - LSU47 Context-free languages Non-context free languages
• Slide 48
• Prof. Busch - LSU48 Theorem: The language is not context free Proof: Use the Pumping Lemma for context-free languages
• Slide 49
• Prof. Busch - LSU49 Assume for contradiction that is context-free Since is context-free and infinite we can apply the pumping lemma
• Slide 50
• Prof. Busch - LSU50 Let be the critical length of the pumping lemma Pick any string with length We pick:
• Slide 51
• Prof. Busch - LSU51 we can write: with lengths and From pumping lemma:
• Slide 52
• Prof. Busch - LSU52 Pumping Lemma says: for all
• Slide 53
• Prof. Busch - LSU53 We examine all the possible locations of string in
• Slide 54
• Prof. Busch - LSU54 Case 1: is in
• Slide 55
• Prof. Busch - LSU55
• Slide 56
• Prof. Busch - LSU56
• Slide 57
• Prof. Busch - LSU57 From Pumping Lemma: However: Contradiction!!!
• Slide 58
• Prof. Busch - LSU58 Case 2: is in Similar to case 1
• Slide 59
• Prof. Busch - LSU59 Case 3: is in Similar to case 1
• Slide 60
• Prof. Busch - LSU60 Case 4: overlaps and
• Slide 61
• Prof. Busch - LSU61 Sub-case 1:contains only
• Slide 62
• Prof. Busch - LSU62
• Slide 63
• Prof. Busch - LSU63
• Slide 64
• Prof. Busch - LSU64 From Pumping Lemma: However: Contradiction!!!
• Slide 65
• Prof. Busch - LSU65 Sub-case 2:contains and contains only
• Slide 66
• Prof. Busch - LSU66 By assumption
• Slide 67
• Prof. Busch - LSU67
• Slide 68
• Prof. Busch - LSU68 From Pumping Lemma: However: Contradiction!!!
• Slide 69
• Prof. Busch - LSU69 Sub-case 3:contains only contains and Similar to sub-case 2
• Slide 70
• Prof. Busch - LSU70 Case 5: overlaps and Similar to case 4
• Slide 71
• Prof. Busch - LSU71 Case 6: overlaps, and Impossible!
• Slide 72
• Prof. Busch - LSU72 In all cases we obtained a contradiction Therefore: the original assumption that is context-free must be wrong Conclusion:is not context-free

Recommended