# costas busch - rpi1 more applications of the pumping lemma

Post on 22-Dec-2015

214 views

Category:

## Documents

Embed Size (px)

TRANSCRIPT

• Slide 1
• Costas Busch - RPI1 More Applications of the Pumping Lemma
• Slide 2
• Costas Busch - RPI2 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we can write with and such that:
• Slide 3
• Costas Busch - RPI3 Regular languages Non-regular languages
• Slide 4
• Costas Busch - RPI4 Theorem: The language is not regular Proof: Use the Pumping Lemma
• Slide 5
• Costas Busch - RPI5 Assume for contradiction that is a regular language Since is infinite we can apply the Pumping Lemma
• Slide 6
• Costas Busch - RPI6 We pick Let be the integer in the Pumping Lemma Pick a string such that: length and
• Slide 7
• Costas Busch - RPI7 Write it must be that length From the Pumping Lemma Thus:
• Slide 8
• Costas Busch - RPI8 From the Pumping Lemma: Thus:
• Slide 9
• Costas Busch - RPI9 From the Pumping Lemma: Thus:
• Slide 10
• Costas Busch - RPI10 BUT: CONTRADICTION!!!
• Slide 11
• Costas Busch - RPI11 Our assumption that is a regular language is not true Conclusion: is not a regular language Therefore:
• Slide 12
• Costas Busch - RPI12 Regular languages Non-regular languages
• Slide 13
• Costas Busch - RPI13 Theorem: The language is not regular Proof: Use the Pumping Lemma
• Slide 14
• Costas Busch - RPI14 Assume for contradiction that is a regular language Since is infinite we can apply the Pumping Lemma
• Slide 15
• Costas Busch - RPI15 We pick Let be the integer in the Pumping Lemma Pick a string such that: length and
• Slide 16
• Costas Busch - RPI16 Write it must be that length From the Pumping Lemma Thus:
• Slide 17
• Costas Busch - RPI17 From the Pumping Lemma: Thus:
• Slide 18
• Costas Busch - RPI18 From the Pumping Lemma: Thus:
• Slide 19
• Costas Busch - RPI19 BUT: CONTRADICTION!!!
• Slide 20
• Costas Busch - RPI20 Our assumption that is a regular language is not true Conclusion: is not a regular language Therefore:
• Slide 21
• Costas Busch - RPI21 Regular languages Non-regular languages
• Slide 22
• Costas Busch - RPI22 Theorem: The language is not regular Proof: Use the Pumping Lemma
• Slide 23
• Costas Busch - RPI23 Assume for contradiction that is a regular language Since is infinite we can apply the Pumping Lemma
• Slide 24
• Costas Busch - RPI24 We pick Let be the integer in the Pumping Lemma Pick a string such that: length
• Slide 25
• Costas Busch - RPI25 Write it must be that length From the Pumping Lemma Thus:
• Slide 26
• Costas Busch - RPI26 From the Pumping Lemma: Thus:
• Slide 27
• Costas Busch - RPI27 From the Pumping Lemma: Thus:
• Slide 28
• Costas Busch - RPI28 Since: There must exist such that:
• Slide 29
• Costas Busch - RPI29 However:for for any
• Slide 30
• Costas Busch - RPI30 BUT: CONTRADICTION!!!
• Slide 31
• Costas Busch - RPI31 Our assumption that is a regular language is not true Conclusion: is not a regular language Therefore:
• Slide 32
• Costas Busch - RPI32 Lex
• Slide 33
• Costas Busch - RPI33 Lex: a lexical analyzer A Lex program recognizes strings For each kind of string found the lex program takes an action
• Slide 34
• Costas Busch - RPI34 Var = 12 + 9; if (test > 20) temp = 0; else while (a < 20) temp++; Lex program Identifier: Var Operand: = Integer: 12 Operand: + Integer: 9 Semicolumn: ; Keyword: if Parenthesis: ( Identifier: test.... Input Output
• Slide 35
• Costas Busch - RPI35 In Lex strings are described with regular expressions if then + - = /* operators */ /* keywords */ Lex program Regular expressions
• Slide 36
• Costas Busch - RPI36 (0|1|2|3|4|5|6|7|8|9)+ /* integers */ /* identifiers */ Regular expressions (a|b|..|z|A|B|...|Z)+ Lex program
• Slide 37
• Costas Busch - RPI37 integers [0-9]+(0|1|2|3|4|5|6|7|8|9)+
• Slide 38
• Costas Busch - RPI38 (a|b|..|z|A|B|...|Z)+ [a-zA-Z]+ identifiers
• Slide 39
• Costas Busch - RPI39 Each regular expression has an associated action (in C code) Examples: \n Regular expressionAction linenum++; [a-zA-Z]+ printf(identifier); [0-9]+ prinf(integer);
• Slide 40
• Costas Busch - RPI40 Default action: ECHO; Prints the string identified to the output
• Slide 41
• Costas Busch - RPI41 A small lex program % [a-zA-Z]+printf(Identifier\n); [0-9]+printf(Integer\n); [ \t\n] ; /*skip spaces*/
• Slide 42
• Costas Busch - RPI42 1234 test var 566 78 9800 Input Output Integer Identifier Integer
• Slide 43
• Costas Busch - RPI43 % [a-zA-Z]+ printf(Identifier\n); [0-9]+ prinf(Integer\n); [ \t] ; /*skip spaces*/. printf(Error in line: %d\n, linenum); Another program %{ int linenum = 1; %} \nlinenum++;
• Slide 44
• Costas Busch - RPI44 1234 test var 566 78 9800 + temp Input Output Integer Identifier Integer Error in line: 3 Identifier
• Slide 45
• Costas Busch - RPI45 Lex matches the longest input string if ifend Regular Expressions Input: ifend if Matches: ifend if Example:
• Slide 46
• Costas Busch - RPI46 Internal Structure of Lex Lex Regular expressions NFADFA Minimal DFA The final states of the DFA are associated with actions