The Pumping Lemma. for all n 0, u 1 v n u 2 L (i.e. u 1 u 2 L, u 1 vu 2 L [but we knew that anyway], u 1 vvu 2 L, u 1 vvvu 2 L, etc.

Similar documents
Foundations of Informatics: a Bridging Course

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

DM17. Beregnelighed. Jacob Aae Mikkelsen

Turing machines and linear bounded automata

Pushdown automata. Twan van Laarhoven. Institute for Computing and Information Sciences Intelligent Systems Radboud University Nijmegen

Turing machines and linear bounded automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Turing machines and linear bounded automata

NPDA, CFG equivalence

Languages, regular languages, finite automata

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CISC4090: Theory of Computation

Push-down Automata = FA + Stack

SCHEME FOR INTERNAL ASSESSMENT TEST 3

CMPSCI 250: Introduction to Computation. Lecture #22: From λ-nfa s to NFA s to DFA s David Mix Barrington 22 April 2013

Theory Bridge Exam Example Questions

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Sri vidya college of engineering and technology

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

Harvard CS 121 and CSCI E-207 Lecture 10: CFLs: PDAs, Closure Properties, and Non-CFLs

MA/CSSE 474 Theory of Computation

CS500 Homework #2 Solutions

CS 455/555: Finite automata

Final exam study sheet for CS3719 Turing machines and decidability.

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Homework. Context Free Languages. Announcements. Before We Start. Languages. Plan for today. Final Exam Dates have been announced.

Ogden s Lemma for CFLs

Introduction to Turing Machines. Reading: Chapters 8 & 9

T (s, xa) = T (T (s, x), a). The language recognized by M, denoted L(M), is the set of strings accepted by M. That is,

Outline. CS21 Decidability and Tractability. Machine view of FA. Machine view of FA. Machine view of FA. Machine view of FA.

PS2 - Comments. University of Virginia - cs3102: Theory of Computation Spring 2010

Properties of Context-Free Languages. Closure Properties Decision Properties

CS Lecture 29 P, NP, and NP-Completeness. k ) for all k. Fall The class P. The class NP

AC68 FINITE AUTOMATA & FORMULA LANGUAGES JUNE 2014

Automata: a short introduction

3515ICT: Theory of Computation. Regular languages

NODIA AND COMPANY. GATE SOLVED PAPER Computer Science Engineering Theory of Computation. Copyright By NODIA & COMPANY

Pushdown Automata. Notes on Automata and Theory of Computation. Chia-Ping Chen

CPSC 421: Tutorial #1

Automata Theory - Quiz II (Solutions)

CS481F01 Solutions 6 PDAS

Pushdown Automata. Chapter 12

Pushdown Automata (2015/11/23)

Computational Models - Lecture 4

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

60-354, Theory of Computation Fall Asish Mukhopadhyay School of Computer Science University of Windsor

How to Pop a Deep PDA Matters

Final Exam Comments. UVa - cs302: Theory of Computation Spring < Total

(b) If G=({S}, {a}, {S SS}, S) find the language generated by G. [8+8] 2. Convert the following grammar to Greibach Normal Form G = ({A1, A2, A3},

Section 1 (closed-book) Total points 30

Computational Models - Lecture 5 1

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Fundamentele Informatica II

Introduction to Turing Machines

Introduction to the Theory of Computation. Automata 1VO + 1PS. Lecturer: Dr. Ana Sokolova.

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Lecture Notes On THEORY OF COMPUTATION MODULE -1 UNIT - 2

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

Deterministic Finite Automata. Non deterministic finite automata. Non-Deterministic Finite Automata (NFA) Non-Deterministic Finite Automata (NFA)

Recap DFA,NFA, DTM. Slides by Prof. Debasis Mitra, FIT.

Automata & languages. A primer on the Theory of Computation. Laurent Vanbever. ETH Zürich (D-ITET) October,

V Honors Theory of Computation

SYLLABUS. Introduction to Finite Automata, Central Concepts of Automata Theory. CHAPTER - 3 : REGULAR EXPRESSIONS AND LANGUAGES

CS Pushdown Automata

Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. Pushdown Automata. The stack

UNIT-VI PUSHDOWN AUTOMATA

CSE 105 THEORY OF COMPUTATION

Theory of Computation Turing Machine and Pushdown Automata

Introduction and Motivation. Introduction and Motivation. Introduction to Computability. Introduction and Motivation. Theory. Lecture5: Context Free

Theory of Computation

INSTITUTE OF AERONAUTICAL ENGINEERING

CS 154, Lecture 2: Finite Automata, Closure Properties Nondeterminism,

Nondeterministic Finite Automata

Part I: Definitions and Properties

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

Automata Theory (2A) Young Won Lim 5/31/18

Introduction to the Theory of Computing

5 Context-Free Languages

CISC 4090: Theory of Computation Chapter 1 Regular Languages. Section 1.1: Finite Automata. What is a computer? Finite automata

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

2.1 Solution. E T F a. E E + T T + T F + T a + T a + F a + a

Finite Automata and Languages

DD2371 Automata Theory

Part 4 out of 5 DFA NFA REX. Automata & languages. A primer on the Theory of Computation. Last week, we showed the equivalence of DFA, NFA and REX

INF210 Datamaskinteori (Models of Computation)

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

CSE 105 THEORY OF COMPUTATION

Theory of Computation (Classroom Practice Booklet Solutions)

CS Lecture 28 P, NP, and NP-Completeness. Fall 2008

CDM Parsing and Decidability

CS21 Decidability and Tractability

Embedded systems specification and design

(pp ) PDAs and CFGs (Sec. 2.2)

Context-free Languages and Pushdown Automata

Automata and Computability. Solutions to Exercises

CSE 105 THEORY OF COMPUTATION

Lecture 17: Language Recognition

Closure Properties of Regular Languages. Union, Intersection, Difference, Concatenation, Kleene Closure, Reversal, Homomorphism, Inverse Homomorphism

INF Introduction and Regular Languages. Daniel Lupp. 18th January University of Oslo. Department of Informatics. Universitetet i Oslo

Transcription:

The Pumping Lemma For every regular language L, there is a number l 1 satisfying the pumping lemma property: All w L with w l can be expressed as a concatenation of three strings, w = u 1 vu 2, where u 1, v and u 2 satisfy: v 1 (i.e. v = ε) u 1 v l for all n 0, u 1 v n u 2 L (i.e. u 1 u 2 L, u 1 vu 2 L [but we knew that anyway], u 1 vvu 2 L, u 1 vvvu 2 L, etc.) Note similarity to construction in Kleene (b)

Suppose L = L(M) for a DFA M = (Q, Σ, δ, s, F). Taking l to be the number of elements in Q, if n l, then in a s = 1 a q 0 2 q1 q2 al q }{{} l l+1 states an q n F q 0,..., q l can t all be distinct states. So q i = q j for some 0 i < j l. So the above transition sequence looks like v where s = q 0 u 1 q i = q j u 2 q n F u 1 a 1... a i v a i+1... a j u 2 a j+1... a n

How to use the Pumping Lemma to prove that a language L is not regular For each l 1, find some w L of length l so that no matter how w is split into three, w = u 1 vu 2, with u 1 v l and v 1, there is some n 0 for which u 1 v n ( ) u 2 is not in L

Examples None of the following three languages are regular: (i) L 1 {a n b n n 0}

L 1 = {a n b n n 0} For each l 1, take w = a l b l L 1 If w = u 1 vu 2 with u 1 v l & v 1, then for some r and s: u 1 = a r

L 1 = {a n b n n 0} For each l 1, take w = a l b l L 1 If w = u 1 vu 2 with u 1 v l & v 1, then for some r and s: u 1 = a r v = a s, with r+s l and s 1

L 1 = {a n b n n 0} For each l 1, take w = a l b l L 1 If w = u 1 vu 2 with u 1 v l & v 1, then for some r and s: u 1 = a r v = a s, with r+s l and s 1 u 2 = a l r s b l

L 1 = {a n b n n 0} For each l 1, take w = a l b l L 1 If w = u 1 vu 2 with u 1 v l & v 1, then for some r and s: u 1 = a r v = a s, with r+s l and s 1 u 2 = a l r s b l so u 1 v 0 u 2 =

L 1 = {a n b n n 0} For each l 1, take w = a l b l L 1 If w = u 1 vu 2 with u 1 v l & v 1, then for some r and s: u 1 = a r v = a s, with r+s l and s 1 u 2 = a l r s b l so u 1 v 0 u 2 = a r ǫ a l r s b l =

L 1 = {a n b n n 0} For each l 1, take w = a l b l L 1 If w = u 1 vu 2 with u 1 v l & v 1, then for some r and s: u 1 = a r v = a s, with r+s l and s 1 u 2 = a l r s b l so u 1 v 0 u 2 = a r ǫ a l r s b l = a l s b l

L 1 = {a n b n n 0} For each l 1, take w = a l b l L 1 If w = u 1 vu 2 with u 1 v l & v 1, then for some r and s: u 1 = a r v = a s, with r+s l and s 1 u 2 = a l r s b l so u 1 v 0 u 2 = a r ǫ a l r s b l = a l s b l But a l s b l L 1

L 1 = {a n b n n 0} For each l 1, take w = a l b l L 1 If w = u 1 vu 2 with u 1 v l & v 1, then for some r and s: u 1 = a r v = a s, with r+s l and s 1 u 2 = a l r s b l so u 1 v 0 u 2 = a r ǫ a l r s b l = a l s b l But a l s b l L 1, so, by the Pumping Lemma, L 1 is not a regular language

Examples None of the following three languages are regular: (i) L 1 {a n b n n 0} [For each l 1, a l b l L 1 is of length l and has property ( ).]

Examples None of the following three languages are regular: (i) L 1 {a n b n n 0} [For each l 1, a l b l L 1 is of length l and has property ( ).] (ii) L 2 {w {a, b} w a palindrome}

Examples None of the following three languages are regular: (i) L 1 {a n b n n 0} [For each l 1, a l b l L 1 is of length l and has property ( ).] (ii) L 2 {w {a, b} w a palindrome} [For each l 1, a l ba l L 1 is of length l and has property ( ).]

Examples None of the following three languages are regular: (i) L 1 {a n b n n 0} [For each l 1, a l b l L 1 is of length l and has property ( ).] (ii) L 2 {w {a, b} w a palindrome} [For each l 1, a l ba l L 1 is of length l and has property ( ).] (iii) L 3 {a p p prime}

L 3 = {a p p prime} For each l 1 let w = a p L 3, p prime & p > 2l If w = u 1 vu 2 with the usual...

L 3 = {a p p prime} For each l 1 let w = a p L 3, p prime & p > 2l If w = u 1 vu 2 with the usual... then u 1 = a r v = a s u 2 = a p r s with s 1 & r+s l

L 3 = {a p p prime} For each l 1 let w = a p L 3, p prime & p > 2l If w = u 1 vu 2 with the usual... then u 1 = a r v = a s u 2 = a p r s with s 1 & r+s l so u 1 v p s u 2 =

L 3 = {a p p prime} For each l 1 let w = a p L 3, p prime & p > 2l If w = u 1 vu 2 with the usual... then u 1 = a r v = a s u 2 = a p r s with s 1 & r+s l so u 1 v p s u 2 = a r a s(p s) a p r s =

L 3 = {a p p prime} For each l 1 let w = a p L 3, p prime & p > 2l If w = u 1 vu 2 with the usual... then u 1 = a r v = a s u 2 = a p r s with s 1 & r+s l so u 1 v p s u 2 = a r a s(p s) a p r s = a (p s)(s+1)

L 3 = {a p p prime} For each l 1 let w = a p L 3, p prime & p > 2l If w = u 1 vu 2 with the usual... then u 1 = a r v = a s u 2 = a p r s with s 1 & r+s l so u 1 v p s u 2 = a r a s(p s) a p r s = a (p s)(s+1) but s 1 s+1 2 and (p s) > (2l l) 1 (p s) 2

L 3 = {a p p prime} For each l 1 let w = a p L 3, p prime & p > 2l If w = u 1 vu 2 with the usual... then u 1 = a r v = a s u 2 = a p r s with s 1 & r+s l so u 1 v p s u 2 = a r a s(p s) a p r s = a (p s)(s+1) but s 1 s+1 2 and (p s) > (2l l) 1 (p s) 2 so a (p s)(s+1) L 3

Examples None of the following three languages are regular: (i) L 1 {a n b n n 0} [For each l 1, a l b l L 1 is of length l and has property ( ).] (ii) L 2 {w {a, b} w a palindrome} [For each l 1, a l ba l L 1 is of length l and has property ( ).] (iii) L 3 {a p p prime} [For each l 1, we can find a prime p with p > 2l and then a p L 3 has length l and has property ( ).]

Pumping Lemma property is necessary for a language to be regular It is not sufficient

Example of a non-regular language with the pumping lemma property L {c m a n b n m 1 & n 0} {a m b n m, n 0} satisfies the pumping lemma property with l = 1. [For any w L of length 1, can take u 1 = ε, v = first letter of w, u 2 = rest of w.] But L is not regular see Exercise 5.1.

L is not regular: (sketch).

L is not regular: (sketch) If L is regular there is a DFA M with L = L(M). Let s build a new machine, M from it..

L is not regular: (sketch) If L is regular there is a DFA M with L = L(M). Let s build a new machine, M from it. Take a c transition from the start state of M. Make the state you reach the start state of M.

L is not regular: (sketch) If L is regular there is a DFA M with L = L(M). Let s build a new machine, M from it. Take a c transition from the start state of M. Make the state you reach the start state of M. Delete all transitions involving c (and remove c from the alphabet). But don t remove any states and keep the same accept states.

L is not regular: (sketch) If L is regular there is a DFA M with L = L(M). Let s build a new machine, M from it. Take a c transition from the start state of M. Make the state you reach the start state of M. Delete all transitions involving c (and remove c from the alphabet). But don t remove any states and keep the same accept states. What language does M recognise?

The way ahead, in THEORY What does is mean for a function to be computable? [ Ib Computation Theory ]

The way ahead, in THEORY What does is mean for a function to be computable? [ Ib Computation Theory ] Are some computational tasks intrinsiclaly unfeasible? [ Ib ComplexityTheory ]

The way ahead, in THEORY What does is mean for a function to be computable? [ Ib Computation Theory ] Are some computational tasks intrinsiclaly unfeasible? [ Ib ComplexityTheory ] How do we specify and reason about program behaviour? [ Ib Logic and Proof, 1b Semantics of PLs ]

The way ahead, in FORMAL LANGUAGES Are there other useful language classes?

The way ahead, in FORMAL LANGUAGES Are there other useful language classes? Are there other useful automata classes that have a correspondence to them?

The way ahead, in FORMAL LANGUAGES Are there other useful language classes? Are there other useful automata classes that have a correspondence to them? What if we ask the same questions about them that we asked about regular languages?

Chomsky Hierarchy of Languages Regular Languages Context Free Languages Context Sensitive Languages Recursively Enumerable Languages

Grammars Grammars are a shorthand way of expressing the inductive definition of subset inclusion for strings in a Language.

Grammars Grammars are a shorthand way of expressing the inductive definition of subset inclusion for strings in a Language. Often by convention we use capitals for non-terminal symbols (which are disjoint from symbols in the alphabet used by the language).

Grammars Grammars are a shorthand way of expressing the inductive definition of subset inclusion for strings in a Language. Often by convention we use capitals for non-terminal symbols (which are disjoint from symbols in the alphabet used by the language). We also have productions (or production rules) of the form e.g. A a which says that the non-terminal symbol A can be replaced by the (terminal) symbol a. More complex productions are allowed.

Grammars Grammars are a shorthand way of expressing the inductive definition of subset inclusion for strings in a Language. Often by convention we use capitals for non-terminal symbols (which are disjoint from symbols in the alphabet used by the language). We also have productions (or production rules) of the form e.g. A a which says that the non-terminal symbol A can be replaced by the (terminal) symbol a. More complex productions are allowed. There is also a distinguished non-terminal called the goal symbol (we ll use G)

Everybody s favourite grammar G E 0 E E+T 1 E T 2 T T P 3 T P 4 P (E) 5 P x 6

Everybody s favourite grammar G E 0 E E+T 1 E T 2 T T P 3 T P 4 P (E) 5 P x 6 so, e.g. G 0 E

Everybody s favourite grammar G E 0 E E+T 1 E T 2 T T P 3 T P 4 P (E) 5 P x 6 so, e.g. G 0 E 1 E+T

Everybody s favourite grammar G E 0 E E+T 1 E T 2 T T P 3 T P 4 P (E) 5 P x 6 so, e.g. G 0 E 1 E+T 4 E+P

Everybody s favourite grammar G E 0 E E+T 1 E T 2 T T P 3 T P 4 P (E) 5 P x 6 so, e.g. G 0 E 1 E+T 4 E+P 6 E+x

Everybody s favourite grammar G E 0 E E+T 1 E T 2 T T P 3 T P 4 P (E) 5 P x 6 so, e.g. G 0 E 1 E+T 4 E+P 6 E+x 2 T + x

Everybody s favourite grammar G E 0 E E+T 1 E T 2 T T P 3 T P 4 P (E) 5 P x 6 so, e.g. G 0 E 1 E+T 4 E+P 6 E+x 2 T + x 4 P+x

Everybody s favourite grammar G E 0 E E+T 1 E T 2 T T P 3 T P 4 P (E) 5 P x 6 so, e.g. G 0 E 1 E+T 4 E+P 6 E+x 2 T + x 4 P+x 5 (E)+x

Everybody s favourite grammar G E 0 E E+T 1 E T 2 T T P 3 T P 4 P (E) 5 P x 6 so, e.g. G 0 E 1 E+T 4 E+P 6 E+x 2 T + x 4 P+x 5 (E)+x... (x+x)+x

Everybody s favourite grammar G E 0 E E+T 1 E T 2 T T P 3 T P 4 P (E) 5 P x 6 so, e.g. G 0 E 1 E+T 4 E+P 6 E+x 2 T + x 4 P+x 5 (E)+x... (x+x)+x is a derivation of (x+x)+x

Language classes by forms of production α, β, γ any strings of terminals and non-terminals

Language classes by forms of production α, β, γ any strings of terminals and non-terminals Context Free Languages: [ Type 2 ] productions of form N β

Language classes by forms of production α, β, γ any strings of terminals and non-terminals Context Free Languages: [ Type 2 ] productions of form N β Context Sensitive Languages: [ Type 1 ] productions of the form αnβ αγβ

Language classes by forms of production α, β, γ any strings of terminals and non-terminals Context Free Languages: [ Type 2 ] productions of form N β Context Sensitive Languages: [ Type 1 ] productions of the form αnβ αγβ Recursively Enumerable Languages: [ Type 0 ] productions of the form α β

Language classes by forms of production

Language classes by forms of production How about Regular Languages? [ Type 3 ]

Language classes by forms of production How about Regular Languages? [ Type 3 ] A, B any non-terminals, a any terminal symbol, S any non-terminal that doesn t appear on right side

Language classes by forms of production How about Regular Languages? [ Type 3 ] A, B any non-terminals, a any terminal symbol, S any non-terminal that doesn t appear on right side production of the form A a or S ε or A ab (right regular)

Language classes by forms of production How about Regular Languages? [ Type 3 ] A, B any non-terminals, a any terminal symbol, S any non-terminal that doesn t appear on right side production of the form A a or S ε or A ab (right regular) or of the form A a or S ε or A Ba (left regular)

Language classes by forms of production How about Regular Languages? [ Type 3 ] A, B any non-terminals, a any terminal symbol, S any non-terminal that doesn t appear on right side production of the form A a or S ε or A ab (right regular) or of the form A a or S ε or A Ba (left regular) but not both left and right regular in the same grammar

Machines????? Regular Languages: Deterministic Finite Automata

Machines????? Regular Languages: Deterministic Finite Automata Context Free Languages: Nondeterministic Push-Down Automata

Machines????? Regular Languages: Deterministic Finite Automata Context Free Languages: Nondeterministic Push-Down Automata Context Sensitive Languages: Linear Bounded Nondeterministic Turing Machine

Machines????? Regular Languages: Deterministic Finite Automata Context Free Languages: Nondeterministic Push-Down Automata Context Sensitive Languages: Linear Bounded Nondeterministic Turing Machine Recursively Enumerable Languages: Turing Machine

Machines????? Regular Languages: Deterministic Finite Automata Context Free Languages: Nondeterministic Push-Down Automata Context Sensitive Languages: Linear Bounded Nondeterministic Turing Machine Recursively Enumerable Languages: Turing Machine Context Free Languages (and particularly the subset that can be recognised by deterministic push-down automata) are important since most programming languages are deterministic context free languages.

Deterministic Push-Down Automata (Sketch) Idea: need some way to remember arbitrary number of things that we have seen, eg a n b n

Deterministic Push-Down Automata (Sketch) Idea: need some way to remember arbitrary number of things that we have seen, eg a n b n Slightly modified DFA along with a stack which stores pairs of states and symbols.

Deterministic Push-Down Automata (Sketch) Idea: need some way to remember arbitrary number of things that we have seen, eg a n b n Slightly modified DFA along with a stack which stores pairs of states and symbols. DPDA looks at top of stack as well as input to decide what to do

Deterministic Push-Down Automata (Sketch) Idea: need some way to remember arbitrary number of things that we have seen, eg a n b n Slightly modified DFA along with a stack which stores pairs of states and symbols. DPDA looks at top of stack as well as input to decide what to do on state transitions, DPDA can pop and/or push things on the stack as well as (perhaps) reading symbol

What about our "questions"?

What about our "questions"? Given two DPDA, M 1 and M 2, can we determine if L(M 1 ) = L(M 2 )?

What about our "questions"? Given two DPDA, M 1 and M 2, can we determine if L(M 1 ) = L(M 2 )? Yes.

What about our "questions"? Given two DPDA, M 1 and M 2, can we determine if L(M 1 ) = L(M 2 )? Yes. Proved in 1997.

What about our "questions"? Given two DPDA, M 1 and M 2, can we determine if L(M 1 ) = L(M 2 )? Yes. Proved in 1997. Earned 2002 Gödel Prize.

What about our "questions"? Given two DPDA, M 1 and M 2, can we determine if L(M 1 ) = L(M 2 )? Yes. Proved in 1997. Earned 2002 Gödel Prize. But for NPDA, the question of equivalence is

What about our "questions"? Given two DPDA, M 1 and M 2, can we determine if L(M 1 ) = L(M 2 )? Yes. Proved in 1997. Earned 2002 Gödel Prize. But for NPDA, the question of equivalence is undecidable