More Applications of the Pumping Lemma

Slides:



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

Lex -- a Lexical Analyzer Generator (by M.E. Lesk and Eric. Schmidt) –Given tokens specified as regular expressions, Lex automatically generates a routine.
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
1 Introduction to Computability Theory Lecture4: Non Regular Languages Prof. Amos Israeli.
1 FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY (For next time: Read Chapter 1.3 of the book)
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 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.
1 Introduction to Computability Theory Lecture4: Non Regular Languages Prof. Amos Israeli.
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.
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.
Costas Busch1 More Applications of The Pumping Lemma.
1 CD5560 FABER Formal Languages, Automata and Models of Computation Lecture 7 Mälardalen University 2010.
1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 5 School of Innovation, Design and Engineering Mälardalen University 2012.
TRANSITION DIAGRAM BASED LEXICAL ANALYZER and FINITE AUTOMATA Class date : 12 August, 2013 Prepared by : Karimgailiu R Panmei Roll no. : 11CS10020 GROUP.
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:
Class Discussion Can you draw a DFA that accepts the language {a k b k | k = 0,1,2,…} over the alphabet  ={a,b}?
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.
CSCI 3130: Formal languages and automata theory Tutorial 3 Chin.
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.
INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
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.
1 A Universal Turing Machine. 2 Turing Machines are “hardwired” they execute only one program A limitation of Turing Machines: Real Computers are re-programmable.
General Discussion of “Properties” The Pumping Lemma Membership, Emptiness, Etc.
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
PROPERTIES OF REGULAR LANGUAGES
Linear Bounded Automata LBAs
Nonregular Languages Section 2.4 Wed, Oct 5, 2005.
Single Final State for NFA
Infiniteness Test The Pumping Lemma Nonregular Languages
DPDA Deterministic PDA
Pumping Lemma for Context-free Languages
Elementary Questions about Regular Languages
Non-regular languages
Chapter 4 Properties of Regular Languages
Chapter 1 Regular Language - 02
More Applications of the Pumping Lemma
DPDA Deterministic PDA
More Applications of The Pumping Lemma
Applications of Regular Closure
CHAPTER 1 Regular Languages
COSC 3340: Introduction to Theory of Computation
Presentation transcript:

More Applications of the Pumping Lemma

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

Non-regular languages

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

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

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

Write From the Pumping Lemma it must be that length Thus:

From the Pumping Lemma: Thus:

From the Pumping Lemma: Thus:

BUT: CONTRADICTION!!!

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

Non-regular languages

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

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

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

Write From the Pumping Lemma it must be that length Thus:

From the Pumping Lemma: Thus:

From the Pumping Lemma: Thus:

BUT: CONTRADICTION!!!

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

Non-regular languages

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

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

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

Write From the Pumping Lemma it must be that length Thus:

From the Pumping Lemma: Thus:

From the Pumping Lemma: Thus:

Since: There must exist such that:

However: for for any

BUT: CONTRADICTION!!!

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

Lex

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

Lex Output Identifier: Var Operand: = Input Integer: 12 Operand: + Semicolumn: ; Keyword: if Parenthesis: ( Identifier: test .... Input Var = 12 + 9; if (test > 20) temp = 0; else while (a < 20) temp++; Lex program

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

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

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

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

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

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

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

Output Input Integer Identifier 1234 test var 566 78 9800

. Another program %{ int linenum = 1; %} %% [ \t] ; /*skip spaces*/ \n prinf(“Integer\n”); [0-9]+ [a-zA-Z]+ printf(“Identifier\n”); . printf(“Error in line: %d\n”, linenum);

Output Input Integer Identifier Error in line: 3 1234 test var 566 78 9800 + temp

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

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