1 More Applications of the Pumping Lemma. 2 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we.

Slides:



Advertisements
Similar presentations
1 Let’s Recapitulate. 2 Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Advertisements

Lecture 9,10 Theory of AUTOMATA
Fall 2006Costas Busch - RPI1 Non-regular languages (Pumping Lemma)
3.2 Pumping Lemma for Regular Languages Given a language L, how do we know whether it is regular or not? If we can construct an FA to accept the language.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY
CSCI 2670 Introduction to Theory of Computing September 13, 2005.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Mount Holyoke College 2 Nonregular languages? We now know: –Regular languages may be specified either.
Nonregular languages Sipser 1.4 (pages 77-82). CS 311 Fall Nonregular languages? We now know: –Regular languages may be specified either by regular.
Courtesy Costas Busch - RPI1 More Applications of the Pumping Lemma.
Courtesy Costas Buch - RPI1 Simplifications of Context-Free Grammars.
1 More Properties of Regular Languages. 2 We have proven Regular languages are closed under: Union Concatenation Star operation Reverse.
Costas Busch - RPI1 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
CS5371 Theory of Computation Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
Costas Busch - RPI1 The Pumping Lemma for Context-Free Languages.
CS5371 Theory of Computation Lecture 6: Automata Theory IV (Regular Expression = NFA = DFA)
1 More Applications of the Pumping Lemma. 2 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we.
Courtesy Costas Busch - RPI1 Non-regular languages.
Fall 2003Costas Busch1 More Applications of The Pumping Lemma.
Homework 4 Solutions.
Fall 2004COMP 3351 Standard Representations of Regular Languages Regular Languages DFAs NFAs Regular Expressions Regular Grammars.
Fall 2006Costas Busch - RPI1 More Applications of the Pumping Lemma.
1 More Applications of The Pumping Lemma. 2 The Pumping Lemma: there exists an integer such that for any string we can write For infinite context-free.
Prof. Busch - LSU1 Pumping Lemma for Context-free Languages.
Prof. Busch - LSU1 Non-regular languages (Pumping Lemma)
Fall 2006Costas Busch - RPI1 Lex. Fall 2006Costas Busch - RPI2 Lex: a lexical analyzer A Lex program recognizes strings For each kind of string found.
Prof. Busch - LSU1 More Applications of the Pumping Lemma.
1 Non-regular languages. 2 Regular languages Non-regular languages.
Costas Busch - RPI1 More Applications of the Pumping Lemma.
1 Applications of Regular Closure. 2 The intersection of a context-free language and a regular language is a context-free language context free regular.
1 The Pumping Lemma for Context-Free Languages. 2 Take an infinite context-free language Example: Generates an infinite number of different strings.
Costas Busch1 More Applications of The Pumping Lemma.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
CMSC 331, Some material © 1998 by Addison Wesley Longman, Inc. 1 Chapter 4 Chapter 4 Lexical analysis.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
1 Problem of the Day: Factor (ab) k as xyz in all ways such that y ≠ ε.
Solution Exercise 1.43 a A r r s q q > b b e b s’ q r q’ b r’ a A’
TRANSITION DIAGRAM BASED LEXICAL ANALYZER and FINITE AUTOMATA Class date : 12 August, 2013 Prepared by : Karimgailiu R Panmei Roll no. : 11CS10020 GROUP.
Lexical Analysis: Finite Automata CS 471 September 5, 2007.
1 Lex. 2 Lex is a lexical analyzer Var = ; if (test > 20) temp = 0; else while (a < 20) temp++; Lex Ident: Var Integer: 12 Oper: + Integer: 9 Semicolumn:
IN LINE FUNCTION AND MACRO Macro is processed at precompilation time. An Inline function is processed at compilation time. Example : let us consider this.
Compiler Construction Sohail Aslam Lecture 9. 2 DFA Minimization  The generated DFA may have a large number of states.  Hopcroft’s algorithm: minimizes.
Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?
Properties of Regular Languages
CS355 - Theory of Computation Regular Expressions.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 9 Mälardalen University 2006.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Costas Busch - LSU1 Pumping Lemma for Context-free Languages.
Costas Busch - LSU1 Lex. Costas Busch - LSU2 Lex: a lexical analyzer A Lex program recognizes strings For each kind of string found the lex program takes.
1 Find as many examples as you can of w, x, y, z so that w is accepted by this DFA, w = x y z, y ≠ ε, | x y | ≤ 7, and x y n z is in L for all n ≥ 0.
Nonregular Languages How do you prove a language to be regular? How do you prove a language to be nonregular? A Pumping Lemma.
Equivalence with FA * Any Regex can be converted to FA and vice versa, because: * Regex and FA are equivalent in their descriptive power ** Regular language.
Lecture 8UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 8.
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
Non-regular languages
Standard Representations of Regular Languages
CSE322 PUMPING LEMMA FOR REGULAR SETS AND ITS APPLICATIONS
More Applications of the Pumping Lemma
PROPERTIES OF REGULAR LANGUAGES
Infiniteness Test The Pumping Lemma Nonregular Languages
Pumping Lemma for Context-free Languages
Elementary Questions about Regular Languages
Non-regular languages
Chapter 1 Regular Language - 02
More Applications of the Pumping Lemma
More Applications of The Pumping Lemma
Applications of Regular Closure
COSC 3340: Introduction to Theory of Computation
Presentation transcript:

1 More Applications of the Pumping Lemma

2 The Pumping Lemma: Given a infinite regular language there exists an integer for any string with length we can write with and such that:

3 Regular languages Non-regular languages

4 Theorem: The language is not regular Proof: Use the Pumping Lemma

5 Assume for contradiction that is a regular language Since is infinite we can apply the Pumping Lemma

6 pick Let be the integer in the Pumping Lemma Pick a string such that: length

7 Write it must be that length From the Pumping Lemma

8 From the Pumping Lemma: Thus: We have:

9 Therefore: BUT: CONTRADICTION!!!

10 Our assumption that is a regular language is not true Conclusion: is not a regular language Therefore:

11 Regular languages Non-regular languages

12 Theorem: The language is not regular Proof: Use the Pumping Lemma

13 Assume for contradiction that is a regular language Since is infinite we can apply the Pumping Lemma

14 pick Let be the integer in the Pumping Lemma Pick a string such that: length

15 Write it must be that length From the Pumping Lemma

16 From the Pumping Lemma: Thus: We have:

17 Therefore: BUT: CONTRADICTION!!!

18 Our assumption that is a regular language is not true Conclusion: is not a regular language Therefore:

19 Regular languages Non-regular languages

20 Theorem: The language is not regular Proof: Use the Pumping Lemma

21 Assume for contradiction that is a regular language Since is infinite we can apply the Pumping Lemma

22 pick Let be the integer in the Pumping Lemma Pick a string such that: length

23 Write it must be that length From the Pumping Lemma

24 From the Pumping Lemma: Thus: We have:

25 Therefore: And since: There is :

26 However:for for any

27 Therefore: BUT: CONTRADICTION!!! and

28 Our assumption that is a regular language is not true Conclusion: is not a regular language Therefore:

29 Lex

30 Lex: a lexical analyzer A Lex program recognizes strings For each kind of string found the lex program takes an action

31 Var = ; 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

32 In Lex strings are described with regular expressions “if” “then” “+” “-” “=“ /* operators */ /* keywords */ Lex program Regular expressions

33 (0|1|2|3|4|5|6|7|8|9)+ /* integers */ /* identifiers */ Regular expressions (a|b|..|z|A|B|...|Z)+ Lex program

34 integers [0-9]+(0|1|2|3|4|5|6|7|8|9)+

35 (a|b|..|z|A|B|...|Z)+ [a-zA-Z]+ identifiers

36 Each regular expression has an associated action (in C code) Examples: \n Regular expressionAction linenum++; [a-zA-Z]+ printf(“identifier”); [0-9]+ prinf(“integer”);

37 Default action: ECHO; Prints the string identified to the output

38 A small program % [a-zA-Z]+printf(“Identifier\n”); [0-9]+printf(“Integer\n”); [ \t\n] ; /*skip spaces*/

test var Input Output Integer Identifier Integer

40 % [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++;

test var temp Input Output Integer Identifier Integer Error in line: 3 Identifier

42 Lex matches the longest input string “if” “ifend” Regular Expressions Input: ifend if ifn Matches: “ifend” “if” nomatch Example:

43 Internal Structure of Lex Lex Regular expressions NFADFA Minimal DFA The final states of the DFA are associated with actions