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

Similar documents
Pumping Lemma for CFLs

An example of a decidable language that is not a CFL Implementation-level description of a TM State diagram of TM

An example of a decidable language that is not a CFL Implementation-level description of a TM State diagram of TM

jflap demo Regular expressions Pumping lemma Turing Machines Sections 12.4 and 12.5 in the text

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Computational Models - Lecture 4

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

CSE 105 THEORY OF COMPUTATION

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

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

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

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Context-Free Languages (Pre Lecture)

CISC4090: Theory of Computation

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

(pp ) PDAs and CFGs (Sec. 2.2)

Introduction to Theory of Computing

SCHEME FOR INTERNAL ASSESSMENT TEST 3

Lecture 17: Language Recognition

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

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

MA/CSSE 474 Theory of Computation

PUSHDOWN AUTOMATA (PDA)

The View Over The Horizon

Context-Free and Noncontext-Free Languages

October 6, Equivalence of Pushdown Automata with Context-Free Gramm

V Honors Theory of Computation

NPDA, CFG equivalence

Computational Models - Lecture 5 1

(pp ) PDAs and CFGs (Sec. 2.2)

Properties of Context-Free Languages. Closure Properties Decision Properties

CISC 4090 Theory of Computation

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

Computational Models - Lecture 4 1

Homework 5 - Solution

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

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

1 Unrestricted Computation

Computational Models - Lecture 5 1

Solution Scoring: SD Reg exp.: a(a

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

Theory of Computation (IV) Yijia Chen Fudan University

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

DM17. Beregnelighed. Jacob Aae Mikkelsen

CISC 4090 Theory of Computation

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

Intro to Theory of Computation

Theory of Computation

Context-Free Languages

CSE 105 Theory of Computation

Ogden s Lemma for CFLs

Computational Models: Class 5

Context Free Languages: Decidability of a CFL

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

CSE 355 Test 2, Fall 2016

Undecidable Problems and Reducibility

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CS500 Homework #2 Solutions

Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

The Pumping Lemma for Context Free Grammars

Functions on languages:

Lecture III CONTEXT FREE LANGUAGES

Final exam study sheet for CS3719 Turing machines and decidability.

Section 1 (closed-book) Total points 30

Automata and Computability. Solutions to Exercises

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

Automata and Computability. Solutions to Exercises

Computability and Complexity

Computational Models Lecture 5

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

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

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

Harvard CS 121 and CSCI E-207 Lecture 10: Ambiguity, Pushdown Automata

CSE 105 THEORY OF COMPUTATION

Properties of Context-Free Languages

CSE 105 THEORY OF COMPUTATION

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

CS21 Decidability and Tractability

MA/CSSE 474 Theory of Computation

Theory of Computation

Theory Bridge Exam Example Questions

Announcements. Problem Set 6 due next Monday, February 25, at 12:50PM. Midterm graded, will be returned at end of lecture.

Theory of Computation (Classroom Practice Booklet Solutions)

What languages are Turing-decidable? What languages are not Turing-decidable? Is there a language that isn t even Turingrecognizable?

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

CS20a: Turing Machines (Oct 29, 2002)

CSE 105 THEORY OF COMPUTATION

cse303 ELEMENTS OF THE THEORY OF COMPUTATION Professor Anita Wasilewska

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

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

Theory of Computation Turing Machine and Pushdown Automata

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

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

CPSC 421: Tutorial #1

CpSc 421 Final Exam December 15, 2006

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

CSCE 551: Chin-Tser Huang. University of South Carolina

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

Theory of Computation (IX) Yijia Chen Fudan University

Decidability (What, stuff is unsolvable?)

Transcription:

What s on our plate today? 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 Pumping Lemma (one last time) Statement of Pumping Lemma for CFLs Proof: See class notes from last time and textbook Application: Showing a given L is not a CFL Introduction to Turing Machines 1 From CFLs to PDAs LisaCFL L=L(M)forsomePDAM Proof Summary: LisaCFLmeansL=L(G)forsomeCFGG=(V,Σ,R,S) Construct PDA M = (Q, Σ, Γ, δ, q 0,{q acc }) M has only 4 main states (plus a few more for pushing strings) Q={q 0,q 1,q 2,q acc } E where E are states used in 2 below δ has 4 components: 1. Init. Stack: δ(q 0, ε, ε)={(q 1,$)}andδ(q 1, ε, ε) ={(q 2,S)} 2. Push & generate strings: δ(q 2, ε, A)={(q 2, w)} for A w inr 3. Pop & match to input: δ(q 2,a,a)={(q 2, ε)} 4. Accept if stack empty: δ(q 2, ε, $)={(q acc, ε)} Can prove by induction: w Liffw L(M) 2

From PDAs to CFLs L=L(M)forsomePDAM L=L(G)forsomeCFGG Proof Summary: Simulate M s computation using a CFG First, simplify M: 1. Only 1 accept state, 2. M empties stack before accepting, 3. Each transition either Push or Pop, not both or neither. Let M = (Q, Σ, Γ, δ, q 0,{q acc }) Construct grammar G = (V, Σ, R, S) Basic Idea: Define variables A pq for simulating M A pq generatesallstringswsuchthatwtakesmfromstatep with empty stack to state q with empty stack Then, A q0qacc generates all strings w accepted by M 3 From PDAs to CFLs (cont.) L=L(M)forsomePDAM L=L(G)forsomeCFGG Proof (cont.) Construct grammar G = (V, Σ, R, S) where V={A pq p,q Q) S=A q0qacc A rs a, ε c b, c ε R={A pq aa rs b p r s q} {A pq A pr A rq p,q,r Q} {A qq ε q Q} See text for proof by induction: w L(M) iff w L(G) Try to get G from M where L(M) = {0 n 1 n n 1} 4

Pumping Lemma for CFLs v y s Here we go again! Intuition: If L is CF, then some CFG G produces strings in L If some string in L is very long, it will have a very tall parse tree If a parse tree is taller than the number of distinct variables in G, then some variable A repeats A will have at least two sub-trees We can pump up the original string by replacing A s smaller subtree with larger, and pump down by replacing larger with smaller Pumping Lemma for CFLs in all its glory: If L is a CFL, then there is a number p (the pumping length ) such that for all strings s in L such that s p, there exist u, v, x, y, andz such that s = uvxyz and: 1. uv i xy i z Lforalli 0, and 2. vy 1, and 3. vxy p. 5 Why is the PL useful? Yawn yes, why indeed? Can use the pumping lemma to show a language L is not context-free 5 steps for a proof by contradiction: 1. Assume L is a CFL. 2. Let p be the pumping length for L given by the pumping lemma for CFLs. 3. Choose cleverly an s in L of length at least p, such that 4. For all possible ways of decomposing s into uvxyz, where vy 1and vxy p, 5. We can choose an i 0suchthatuv i xy i z is not in L. In-Class Examples: Show the following are not CFLs L={0 n 1 n 0 n n 0} and L = {0 n n is a prime number} 6

Using the Pumping Lemma Show L = {0 n n is a prime number} is not a CFL 1. Assume L is a CFL. 2. Let p be the pumping length for L given by the pumping lemma for CFLs. 3. Let s = 0 n where n is a prime p 4. Consider all possible ways of decomposing s into uvxyz, where vy 1and vxy p. Then, vy =0 r and uxz =0 q where r + q = n and r 1 5. We need an i 0 such that uv i xy i z =0 ir+q is not in L. (i = 0 won t work because q could be prime: e.g. 2 + 17 = 19) Choose i =(q+2+2r).then,ir +q=qr+2r+2r 2 +q = q(r+1)+2r(r+1) = (q+2r)(r+1) = not prime (since r 1). So, 0 ir+q is not in L contradicts pumping lemma. L is not a CFL. 7 Two cool results about CFLs Oh boy Jolly good CFLs are not closed under intersection Proof:L 1 ={0 n 1 n 0 m n,m 0} and L 2 ={0 m 1 n 0 n n,m 0} are both CFLs but L 1 L 2 ={0 n 1 n 0 n n 0} is not a CFL. CFLs are not closed under complementation Proof by contradiction: Suppose CFLs are closed under complement. Then, for L 1,L 2 above, L 1 L 2 must be a CFL (since CFLs are closed under -- see homework #5, problem 1). But, L 1 L 2 =L 1 L 2 (by de Morgan s law). L 1 L 2 ={0 n 1 n 0 n n 0} is not a CFL contradiction. Therefore CFLs are not closed under complementation. 8

CanwemakePDAsmorepowerful? PDA = NFA + What if we allow arbitrary reads/writes to the stack instead of only push and pop? 9 Enter.Turing Machines! Just like a DFA except: You have an infinite tape memory (or scratchpad) on which you receive your input and on which you can do your calculations You can read 1 symbol at a time from a cell on the tape, write 1 symbol, then move the read/write pointer (head) left (L) or right (R) 10

Who s Turing? Alan Turing (1912-1954): one of the most brilliant mathematicians of the 20 th century (one of the founding fathers of computing) Click on Theory Hall of Fame link on class web under Lectures Introduced the Turing machine as a formal model of what it means to compute and solve a problem (i.e. an algorithm ) Paper: On computable numbers, with an application to the Entscheidungsproblem, Proc. London Math. Soc. 42 (1936). 11 How do Turing Machines compute? δ(current state, symbol under the head) = (next state, symbol to write over current symbol, direction of head movement) Blank part of tape Diagram shows: δ(q 0,1) = (q 1,0,R) (R=right,L=left) In terms of Configurations : 11q 0 110 110q 1 10 12

Solving Problems with Turing Machines We know L={0 n 1 n 0 n n 0} cannot be accepted by any PDA Design a Turing Machine (TM) that accepts L Write down its operation in words 13 Next Time Formal definition of TMs Solving problems with TMs Varieties of TMs (multi-tape, nondeterministic, etc.) Homework #5 due on Friday! Can I have my Oscar now? 14