costas busch - rpi1 the pumping lemma for context-free languages

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

Post on 21-Dec-2015

213 views

Category:

Documents

1 download

Embed Size (px)

TRANSCRIPT

  • Slide 1
  • Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages
  • Slide 2
  • Costas Busch - RPI2 Take an infinite context-free language Example: Generates an infinite number of different strings
  • Slide 3
  • Costas Busch - RPI3 A derivation: In a derivation of a long string, variables are repeated
  • Slide 4
  • Costas Busch - RPI4 Derivation treestring
  • Slide 5
  • Costas Busch - RPI5 repeated Derivation treestring
  • Slide 6
  • Costas Busch - RPI6
  • Slide 7
  • 7 Repeated Part
  • Slide 8
  • Costas Busch - RPI8 Another possible derivation from
  • Slide 9
  • Costas Busch - RPI9
  • Slide 10
  • 10 A Derivation from
  • Slide 11
  • Costas Busch - RPI11
  • Slide 12
  • Costas Busch - RPI12
  • Slide 13
  • Costas Busch - RPI13 A Derivation from
  • Slide 14
  • Costas Busch - RPI14
  • Slide 15
  • Costas Busch - RPI15
  • Slide 16
  • Costas Busch - RPI16
  • Slide 17
  • Costas Busch - RPI17
  • Slide 18
  • Costas Busch - RPI18 A Derivation from
  • Slide 19
  • Costas Busch - RPI19
  • Slide 20
  • Costas Busch - RPI20
  • Slide 21
  • Costas Busch - RPI21
  • Slide 22
  • Costas Busch - RPI22 In General:
  • Slide 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
  • Slide 24
  • Costas Busch - RPI24 (Number of productions) x (Largest right side of a production) = Let Example : Let
  • Slide 25
  • Costas Busch - RPI25 Take a string with length We will show: in the derivation of a variable of is repeated
  • Slide 26
  • Costas Busch - RPI26
  • Slide 27
  • Costas Busch - RPI27 maximum right hand side of any production
  • Slide 28
  • Costas Busch - RPI28 Number of productions in grammar
  • Slide 29
  • Costas Busch - RPI29 Number of productions in grammar Some production must be repeated Repeated variable
  • Slide 30
  • Costas Busch - RPI30 Some variable is repeated Derivation of string
  • Slide 31
  • Costas Busch - RPI31 Last repeated variable repeated Strings of terminals Derivation tree of string
  • Slide 32
  • Costas Busch - RPI32 Possible derivations:
  • Slide 33
  • Costas Busch - RPI33 We know: This string is also generated:
  • Slide 34
  • Costas Busch - RPI34 This string is also generated: The original We know:
  • Slide 35
  • Costas Busch - RPI35 This string is also generated: We know:
  • Slide 36
  • Costas Busch - RPI36 This string is also generated: We know:
  • Slide 37
  • Costas Busch - RPI37 This string is also generated: We know:
  • Slide 38
  • Costas Busch - RPI38 Therefore, any string of the form is generated by the grammar
  • Slide 39
  • Costas Busch - RPI39 knowing that we also know that Therefore,
  • Slide 40
  • Costas Busch - RPI40 Observation: Since is the last repeated variable
  • Slide 41
  • Costas Busch - RPI41 Observation: Since there are no unit or -productions
  • Slide 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:
  • Slide 43
  • Costas Busch - RPI43 Applications of The Pumping Lemma
  • Slide 44
  • Costas Busch - RPI44 Context-free languages Non-context free languages
  • Slide 45
  • Costas Busch - RPI45 Theorem: The language is not context free Proof: Use the Pumping Lemma for context-free languages
  • Slide 46
  • Costas Busch - RPI46 Assume for contradiction that is context-free Since is context-free and infinite we can apply the pumping lemma
  • Slide 47
  • Costas Busch - RPI47 Pumping Lemma gives a magic number such that: Pick any string with length We pick:
  • Slide 48
  • Costas Busch - RPI48 We can write: with lengths and
  • Slide 49
  • Costas Busch - RPI49 Pumping Lemma says: for all
  • Slide 50
  • Costas Busch - RPI50 We examine all the possible locations of string in
  • Slide 51
  • Costas Busch - RPI51 Case 1: is within
  • Slide 52
  • Costas Busch - RPI52 Case 1: and consist from only
  • Slide 53
  • Costas Busch - RPI53 Case 1: Repeating and
  • Slide 54
  • Costas Busch - RPI54 Case 1: From Pumping Lemma:
  • Slide 55
  • Costas Busch - RPI55 Case 1: From Pumping Lemma: However: Contradiction!!!
  • Slide 56
  • Costas Busch - RPI56 Case 2: is within
  • Slide 57
  • Costas Busch - RPI57 Case 2: Similar analysis with case 1
  • Slide 58
  • Costas Busch - RPI58 Case 3: is within
  • Slide 59
  • Costas Busch - RPI59 Case 3: Similar analysis with case 1
  • Slide 60
  • Costas Busch - RPI60 Case 4: overlaps and
  • Slide 61
  • Costas Busch - RPI61 Case 4: Possibility 1:contains only
  • Slide 62
  • Costas Busch - RPI62 Case 4: Possibility 1:contains only
  • Slide 63
  • Costas Busch - RPI63 Case 4: From Pumping Lemma:
  • Slide 64
  • Costas Busch - RPI64 Case 4: From Pumping Lemma: However: Contradiction!!!
  • Slide 65
  • Costas Busch - RPI65 Case 4: Possibility 2:contains and contains only
  • Slide 66
  • Costas Busch - RPI66 Case 4: Possibility 2:contains and contains only
  • Slide 67
  • Costas Busch - RPI67 Case 4: From Pumping Lemma:
  • Slide 68
  • Costas Busch - RPI68 Case 4: From Pumping Lemma: However: Contradiction!!!
  • Slide 69
  • Costas Busch - RPI69 Case 4: Possibility 3:contains only contains and
  • Slide 70
  • Costas Busch - RPI70 Case 4: Possibility 3:contains only contains and Similar analysis with Possibility 2
  • Slide 71
  • Costas Busch - RPI71 Case 5: overlaps and
  • Slide 72
  • Costas Busch - RPI72 Case 5: Similar analysis with case 4
  • Slide 73
  • Costas Busch - RPI73 There are no other cases to consider (since, string cannot overlap, and at the same time)
  • Slide 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

Recommended

View more >