Pumping Lemma for CFLs

Similar documents
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

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

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

Context-Free Languages (Pre Lecture)

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

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

SCHEME FOR INTERNAL ASSESSMENT TEST 3

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

Context-Free and Noncontext-Free Languages

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

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Computational Models - Lecture 4

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

V Honors Theory of Computation

CSE 105 THEORY OF COMPUTATION

Properties of Context-Free Languages. Closure Properties Decision Properties

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

MA/CSSE 474 Theory of Computation

CISC4090: Theory of Computation

The View Over The Horizon

CSE 355 Test 2, Fall 2016

DM17. Beregnelighed. Jacob Aae Mikkelsen

CS21 Decidability and Tractability

Context-Free Languages

CSE 105 Theory of Computation

1 Unrestricted Computation

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

Finite Automata Theory and Formal Languages TMV027/DIT321 LP4 2018

Homework 5 - Solution

NPDA, CFG equivalence

Theory of Computation (IV) Yijia Chen Fudan University

Ogden s Lemma for CFLs

CpSc 421 Final Exam December 15, 2006

CSE 105 THEORY OF COMPUTATION

Decidability (What, stuff is unsolvable?)

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

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

Homework Assignment 6 Answers

Final exam study sheet for CS3719 Turing machines and decidability.

Lecture 17: Language Recognition

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

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

Functions on languages:

CSE 105 THEORY OF COMPUTATION

Theory of Computation (Classroom Practice Booklet Solutions)

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

CISC 4090 Theory of Computation

Computational Models - Lecture 4 1

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

Computability Theory

CS500 Homework #2 Solutions

Introduction to Theory of Computing

Decidable and undecidable languages

Theory of Computation

Further discussion of Turing machines

Automata and Computability. Solutions to Exercises

Automata and Computability. Solutions to Exercises

} Some languages are Turing-decidable A Turing Machine will halt on all inputs (either accepting or rejecting). No infinite loops.

Decidable Languages - relationship with other classes.

Context Free Languages: Decidability of a CFL

Intro to Theory of Computation

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

Properties of Context-Free Languages

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Computational Models - Lecture 5 1

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

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

CPSC 421: Tutorial #1

Intro to Theory of Computation

Introduction to Turing Machines. Reading: Chapters 8 & 9

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

CSCC63 Worksheet Turing Machines

Intro to Theory of Computation

Solution Scoring: SD Reg exp.: a(a

Closure under the Regular Operations

ACS2: Decidability Decidability

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

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

Grade 6 Math Circles October 20/21, Formalism and Languages: Beyond Regular Languages

CSCE 551 Final Exam, Spring 2004 Answer Key

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

Automata Theory CS S-12 Turing Machine Modifications

Computability and Complexity

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Section 1 (closed-book) Total points 30

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Reducability. Sipser, pages

Undecidable Problems and Reducibility

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

CISC 4090 Theory of Computation

Part I: Definitions and Properties

CS20a: summary (Oct 24, 2002)

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

Foundations of Informatics: a Bridging Course

CS20a: Turing Machines (Oct 29, 2002)

Transcription:

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, and z such that s = uvxyz and: 1. uv i xy i z L for all i 0, and 2. vy 1, and 3. vxy p. 1

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 1 and vxy p, 5. Choose an i 0 such that uv i xy i z is not in L. 2

Example 1 Oh boy Jolly good Show that L = {0 n 1 n 0 n n 0} 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 p 1 p 0 p (note that s > p) 4. For all possible ways of decomposing s = 0 p 1 p 0 p into uvxyz, where vy 1 and vxy p, 5. We need i 0 such that uv i xy i z is not in L: Case 1: Both v and y contain only 0s or only 1s Then uv 2 xy 2 z contains unequal no. of 0s, 1s, and 0s. Case 2: v or y contain both 0 and 1 Then uv 2 xy 2 z is not of the form 0*1*0*. In both cases, uv 2 xy 2 z is not in L, contradicting pumping lemma. Therefore L cannot be a CFL. 3

Example 2 Prime time, baby! 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 1 and 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. 4

Closure properties of CFLs You showed in homework that CFLs are closed under union, concatenation and star. How about intersection? How about complement? 5

Two surprising results about CFLs 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 complement 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 this week s homework). 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 complement. 6

Can we make PDAs more powerful? PDA = NFA + What if we allow arbitrary reads/writes to the stack instead of only push and pop? 7

Enter the Turing Machine 8

Turing Machines Blank part of tape 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 one symbol at a time from a cell on the tape, write one symbol, then move the read/write pointer (head) left (L) or right (R) 9

Who was 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). 10

How do Turing Machines compute? δ(current state, symbol under the head) = (next state, symbol to write over current symbol, direction of head movement) Diagram shows: δ(q 1,1) = (q rej, 0, L) (R = right, L = left) In terms of Configurations : 110q 1 10 11q rej 000 11

Next Time: Turing-Recognizable versus Decidable Languages How does a TM accept a string? How can a TM reject a string? What is a decider TM? 12