CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA)

Similar documents
CS5371 Theory of Computation. Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)

Context-Free Languages

MA/CSSE 474 Theory of Computation

Automata Theory. CS F-10 Non-Context-Free Langauges Closure Properties of Context-Free Languages. David Galles

Context-Free and Noncontext-Free Languages

SCHEME FOR INTERNAL ASSESSMENT TEST 3

Computational Models - Lecture 5 1

Pumping Lemma for CFLs

Context Free Languages: Decidability of a CFL

Before We Start. The Pumping Lemma. Languages. Context Free Languages. Plan for today. Now our picture looks like. Any questions?

Context-Free Languages (Pre Lecture)

CSE 355 Test 2, Fall 2016

Intro to Theory of Computation

Computational Models - Lecture 4

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

CISC4090: Theory of Computation

Problem 2.6(d) [4 pts] Problem 2.12 [3pts] Original CFG:

Theory of Computation (IV) Yijia Chen Fudan University

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

The Pumping Lemma for Context Free Grammars

CS 341 Homework 16 Languages that Are and Are Not Context-Free

Computational Models - Lecture 4 1

Chapter 16: Non-Context-Free Languages

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Cliff s notes for equivalence of CFLs and L(PDAs) LisaCFL L = L(M) for some PDA M L=L(M)forsomePDAM L = L(G) for some CFG G

Introduction to Theory of Computing

Harvard CS 121 and CSCI E-207 Lecture 12: General Context-Free Recognition

CS500 Homework #2 Solutions

PUSHDOWN AUTOMATA (PDA)

Properties of Context-Free Languages

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

Pushdown Automata. We have seen examples of context-free languages that are not regular, and hence can not be recognized by finite automata.

The View Over The Horizon

Closure Properties of Context-Free Languages. Foundations of Computer Science Theory

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CISC 4090 Theory of Computation

Functions on languages:

Note: In any grammar here, the meaning and usage of P (productions) is equivalent to R (rules).

CS5371 Theory of Computation. Lecture 12: Computability III (Decidable Languages relating to DFA, NFA, and CFG)

Notes for Comp 497 (Comp 454) Week 10 4/5/05

Non-context-Free Languages. CS215, Lecture 5 c

Properties of Context-Free Languages. Closure Properties Decision Properties

Einführung in die Computerlinguistik

3130CIT Theory of Computation

Fall 1999 Formal Language Theory Dr. R. Boyer. Theorem. For any context free grammar G; if there is a derivation of w 2 from the

Theory of Computation

Computational Models - Lecture 5 1

Lecture 17: Language Recognition

CS375: Logic and Theory of Computing

Foundations of Informatics: a Bridging Course

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

MA/CSSE 474 Theory of Computation

Final exam study sheet for CS3719 Turing machines and decidability.

Notes for Comp 497 (454) Week 10

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

CISC 4090 Theory of Computation

CS5371 Theory of Computation. Lecture 7: Automata Theory V (CFG, CFL, CNF)

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

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

6.1 The Pumping Lemma for CFLs 6.2 Intersections and Complements of CFLs

ÖVNINGSUPPGIFTER I SAMMANHANGSFRIA SPRÅK. 17 april Classrum Edition

Further discussion of Turing machines

Section 1 (closed-book) Total points 30

Theory Bridge Exam Example Questions

DM17. Beregnelighed. Jacob Aae Mikkelsen

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

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

CS311 Computational Structures More about PDAs & Context-Free Languages. Lecture 9. Andrew P. Black Andrew Tolmach

UNIT-VI PUSHDOWN AUTOMATA

CS20a: summary (Oct 24, 2002)

CS481F01 Prelim 2 Solutions

CS375: Logic and Theory of Computing

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

CpSc 421 Final Exam December 15, 2006

Context Free Languages and Grammars

Computational Models: Class 5

Question Bank UNIT I

Lecture III CONTEXT FREE LANGUAGES

Properties of context-free Languages

CS5371 Theory of Computation. Lecture 5: Automata Theory III (Non-regular Language, Pumping Lemma, Regular Expression)

This lecture covers Chapter 7 of HMU: Properties of CFLs

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

ECS 120: Theory of Computation UC Davis Phillip Rogaway February 16, Midterm Exam

CPS 220 Theory of Computation

Properties of Context-free Languages. Reading: Chapter 7

Chap. 7 Properties of Context-free Languages

Computability Theory

Context-Free Languages

Theory of Computation (VI) Yijia Chen Fudan University

NPDA, CFG equivalence

Pushdown Automata (2015/11/23)

Theory of Computation (Classroom Practice Booklet Solutions)

Automata and Computability. Solutions to Exercises

CS481F01 Solutions 6 PDAS

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

Part 3 out of 5. Automata & languages. A primer on the Theory of Computation. Last week, we learned about closure and equivalence of regular languages

Please give details of your answer. A direct answer without explanation is not counted.

Automata and Computability. Solutions to Exercises

Context Free Languages (CFL) Language Recognizer A device that accepts valid strings. The FA are formalized types of language recognizer.

St.MARTIN S ENGINEERING COLLEGE Dhulapally, Secunderabad

Transcription:

CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL, DPDA PDA)

Objectives Introduce the Pumping Lemma for CFL Show that some languages are non- CFL Discuss the DPDA, which is a PDA with deterministic transition function

Pumping Lemma for CFL Theorem: If L is a context-free language, then there is a number p (pumping length) where, if s is any string in L of length at least p, we can find u,v,x,y,z such that s = uvxyz and For each i 0, uv i xy i z is in L vy 0, and vxy p

Proof of Pumping Lemma Let b be the maximum branching factor in the parse tree of any string in L (that is, the right side of any rule has at most b terminals and variables) Let p = b V +1 What is the minimum height of the parse tree for a string longer than p?

Proof of Pumping Lemma (2) The height of the tree is at least V + 1 There is a path in tree with length V +2 nodes Only one can be terminal, so that there are V +1 variable on the path What does that mean? Some variable appear at least two times!

Proof of Pumping Lemma (3) S R R u v x y z

Proof of Pumping Lemma (4) At this point, we note that uv i xy i z is in L for any i 0 From the parse tree, we know that R can derive x, and R can derive vxy As S derives urz, S can derive uxz As S derives uvryz, S can derive uvvxyyz To complete the prove, we need to show vy 0, and vxy p The current construction cannot, but

Proof of Pumping Lemma (5) If we let the above parse tree to be the smallest among all that generates the string, and If we use the longest path from S to any leaf, and R be the repeating variable from the lowest V +1 in this path Then, vy 0 (why?) and vxy p (why?)

Why is vy 0? Suppose on the contrary that vy = 0. This occurs when both v and y are empty strings If this happen, we can replace the subtree rooted at R that generates vxy by the subtree rooted at R that generates x Resulting parse tree also geneartes uvxyz, but it has fewer nodes contradiction occurs (why?)

Why is vxy p? R is chosen from the lowest V + 1 variable The height of the subtree at R that generates vxy has at most V +1 (why?) It has at most b V +1 leaves Thus, it can generate at most p characters (as p = b V +1 ) Recall: b = maximum branching factor

Non-CFL (example 1) Theorem: The language A = {a n b n c n n 0} is not a context-free language. How to prove? Use pumping lemma on a p b p c p

Proof (example 1) We apply pumping lemma on a p b p c p, what can be the corresponding vxy? Case 1: if both v and y contain only one type of char Case 2: if either v or y contain more than one type of char In both cases, uvvxyyz cannot be in A (why?) Thus, a string longer than p in A does not satisfy pumping lemma A is not CFL

Non-CFL (example 2) Theorem: The language B = {a i b j c k 0 i j k} is not a context-free language. How to prove? Use pumping lemma on a p b p c p

Proof (example 2) We apply pumping lemma on a p b p c p, what can be the corresponding vxy? Case 1: if both v and y contain only one type of char Case 2: if either v or y contain more than one type of char We can guarantee that for Case 2, uvvxyyz cannot be in B However, for Case 1, if v = b, y = c, then the string uvvxyyz can always be in B (so, how to get a contradiction??)

Proof (example 2) We can divide Case 1 into two subcases: When char a does not appear in v or y When char a appears in v or y For the first subcase, uxz (here, we pump down the string) cannot be in B (why?) For the second subcase, uvvxyyz (here, we pump up the string) cannot be in B (why?) Thus, a string longer than p in B does not satisfy pumping lemma B is not CFL

Non-CFL (example 3) Theorem: The language C = {ww w in {0,1}*} is not a context-free language. How to prove? Use pumping lemma on 0 p 1 p 0 p 1 p

Proof (example 3) We apply pumping lemma on 0 p 1 p 0 p 1 p, what can be the corresponding vxy? Case 1: vxy appears in the first half Case 2: vxy appears in the second half Case 3: vxy includes the middle 10 For Cases 1 or 2, uvvxyyz not in C (why?) For Case 3, u must start with 0 p, and z must end with 1 p (because vxy p and vxy includes the middle 10 ). Then, uxz cannot be in C (why?)

Is CFL closed under complement? What is the complement of A = {a n b n c n n 0}? Assume = {a, b, c} They include: strings containing ba, ca, or cb; strings a i b j c k with i j or j k Thus, the complement of A is context free. (why??) As A is not context free, what can we conclude?

Is CFL closed under intersection? Is A = {a n b n c m n,m 0} a CFL? Is B = {a m b n c n n,m 0} a CFL? What is the intersection of A and B? Is it a CFL? What can we conclude?

DPDA Roughly speaking, a deterministic PDA is a PDA with only one choice at any time Precisely, for current state q, input char a, and stack symbol s, (1) (q, a, s) = 1 for all a2 and (q,, s) = 0, or (2) (q, a, s) = 0 for all a2 and (q,, s) = 1 Then, at the end of reading the input, the PDA can be in at most 1 state

DPDA (2) We also need to assume that all input strings for DPDA ends with a special char # (which does not appear at other places in the input string) Since, unlike PDA, we cannot guess the end of the input string

DPDA = PDA?? Suppose L is a language recognized by a DPDA D. Will the complement of L be recognized by some DPDA D? Yes ( rough idea only ) Consider all the states that correspond to the end of reading the input strings (which has an incoming transition arrow labeling with (#, b c)). If it is accept/reject state in D, reverse it in D

DPDA = PDA?? As language recognized by DPDA is closed under complement, but language recognized by PDA (that is, CFL) is not closed, we have DPDA PDA in terms of descriptive power.

What we have learnt so far? PDA = CFG Prove by Construction Properties of CFG (Ambiguous, CNF) More on these in Homework 2 Pumping Lemma Prove by Construction (using Parse Tree) Existence of non-cfl DPDA PDA

Language Hierarchy Set of Languages (= set of set of strings ) {ww} {0 n 1 n 2 n } {w with even w } {w w = w R } {0 x 1 y } {0 n 1 n } Set of Regular Language Set of Context- Free Language

Next Time Turing Machine A even more power computer