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

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

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

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

Theory of Computation (IX) Yijia Chen Fudan University

V Honors Theory of Computation

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Decidability (What, stuff is unsolvable?)

Decidability (intro.)

ACS2: Decidability Decidability

Further discussion of Turing machines

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

Decidability. Overview. Preliminaries to Halting Problem. Decidable Problems of Regular Languages. Decidable Problems of Context-Free Languages

CSE 105 THEORY OF COMPUTATION

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

Turing Machines Part III

CSE 105 THEORY OF COMPUTATION

Lecture Notes: The Halting Problem; Reductions

Decidable and undecidable languages

1 Showing Recognizability

Theory of Computation

CSE 105 THEORY OF COMPUTATION

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2018, face-to-face day section Prof. Marvin K. Nakayama

Intro to Theory of Computation

Computability Theory

Chap. 4,5 Review. Algorithms created in proofs from prior chapters

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 THEORY OF COMPUTATION

Undecidable Problems and Reducibility

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 THEORY OF COMPUTATION

Computability Theory

CPSC 421: Tutorial #1

CS154, Lecture 10: Rice s Theorem, Oracle Machines

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

acs-07: Decidability Decidability Andreas Karwath und Malte Helmert Informatik Theorie II (A) WS2009/10

Properties of Context-Free Languages. Closure Properties Decision Properties

Decidability and Undecidability

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

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,

Midterm Exam 2 CS 341: Foundations of Computer Science II Fall 2016, face-to-face day section Prof. Marvin K. Nakayama

UNIT-VIII COMPUTABILITY THEORY

Intro to Theory of Computation

Reducability. Sipser, pages

Theory of Computation p.1/?? Theory of Computation p.2/?? We develop examples of languages that are decidable

AC68 FINITE AUTOMATA & FORMULA LANGUAGES DEC 2013

Introduction to Turing Machines. Reading: Chapters 8 & 9

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement:

Lecture 23: Rice Theorem and Turing machine behavior properties 21 April 2009

A non-turing-recognizable language

I have read and understand all of the instructions below, and I will obey the University Code on Academic Integrity.

TURING MAHINES

CSE 105 THEORY OF COMPUTATION

SD & Turing Enumerable. Lecture 33: Reductions and Undecidability. Lexicographically Enumerable. SD & Turing Enumerable

Lecture 12: Mapping Reductions

Nondeterministic finite automata

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

CSE 105 THEORY OF COMPUTATION

MA/CSSE 474 Theory of Computation

Mapping Reducibility. Human-aware Robotics. 2017/11/16 Chapter 5.3 in Sipser Ø Announcement:

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

CS5371 Theory of Computation. Lecture 14: Computability V (Prove by Reduction)

CS 154 Introduction to Automata and Complexity Theory

CS20a: Turing Machines (Oct 29, 2002)

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

Computability and Complexity

CS481F01 Solutions 8

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

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

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

CSE 105 Theory of Computation

NPDA, CFG equivalence

Computability and Complexity

CSE 311: Foundations of Computing. Lecture 23: Finite State Machine Minimization & NFAs

Homework Assignment 6 Answers

Turing Machine Recap

CS 154. Finite Automata, Nondeterminism, Regular Expressions

CS 361 Meeting 26 11/10/17

Introduction to the Theory of Computing

Computational Models Lecture 8 1

Computational Models - Lecture 5 1

MTAT Introduction to Theoretical Computer Science

DM17. Beregnelighed. Jacob Aae Mikkelsen

Turing Machines. Reading Assignment: Sipser Chapter 3.1, 4.2

Reading Assignment: Sipser Chapter 3.1, 4.2

Computational Models Lecture 8 1

1 Reducability. CSCC63 Worksheet Reducability. For your reference, A T M is defined to be the language { M, w M accepts w}. Theorem 5.

CSE 105 THEORY OF COMPUTATION

Languages, regular languages, finite automata

More Turing Machines. CS154 Chris Pollett Mar 15, 2006.

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

Midterm II : Formal Languages, Automata, and Computability

CSE 105 Theory of Computation

CSCE 551 Final Exam, Spring 2004 Answer Key

Automata and Computability. Solutions to Exercises

The Turing machine model of computation

Undecidability. We are not so much concerned if you are slow as when you come to a halt. (Chinese Proverb)

CSE 105 THEORY OF COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

Transcription:

CS 301 Lecture 18 Decidable languages Stephen Checkoway April 2, 2018 1 / 26

Decidable language Recall, a language A is decidable if there is some TM M that 1 recognizes A (i.e., L(M) = A), and 2 halts on every input (i.e., w Σ, M either accepts or rejects w) Such a TM is called a decider 2 / 26

Acceptance The acceptance problem for a type of machine 1 asks whether a given machine of the specified type accepts a string Examples: A DFA = { B, w B is a DFA that accepts the string w} A NFA = { B, w B is an NFA that accepts the string w} A REX = { R, w R is a regular expression that generates the string w} A PDA = { B, w B is a PDA that accepts the string w} A CFG = { G, w G is a CFG that generates the string w} A TM = { B, w B is a TM that accepts the string w} 1 For models of computation like regular expressions and grammars, the acceptance problems asks if it generates the string, rather than accepts it 3 / 26

Emptiness and equivalence The emptiness problem asks whether the language of the machine is empty Examples: E DFA = { B B is a DFA and L(B) = } E CFG = { G G is a CFG and L(G) = } E TM = { B B is a TM and L(B) = } 4 / 26

Emptiness and equivalence The emptiness problem asks whether the language of the machine is empty Examples: E DFA = { B B is a DFA and L(B) = } E CFG = { G G is a CFG and L(G) = } E TM = { B B is a TM and L(B) = } The equivalence problem asks whether two machines have the same language Examples: EQ DFA = { A, B A and B are DFAs and L(A) = L(B)} EQ CFG = { G, H G and H are CFGs and L(G) = L(H)} EQ TM = { A, B A and B are TMs and L(A) = L(B)} 4 / 26

A DFA is decidable Theorem The language A DFA = { B, w B is a DFA that accepts the string w} is decidable. 5 / 26

A DFA is decidable Theorem The language A DFA = { B, w B is a DFA that accepts the string w} is decidable. Proof. We want to build a TM M that decides A DFA : M = On input B, w, 1 Run (or simulate) B on w 2 If B ends in an accept state, accept; otherwise reject Since the simulation always ends after w steps, M is a decider. If w L(B), then M will accept. If w L(B), then M will reject. 5 / 26

A DFA is decidable Theorem The language A DFA = { B, w B is a DFA that accepts the string w} is decidable. Proof. We want to build a TM M that decides A DFA : M = On input B, w, 1 Run (or simulate) B on w 2 If B ends in an accept state, accept; otherwise reject Since the simulation always ends after w steps, M is a decider. If w L(B), then M will accept. If w L(B), then M will reject. Note that the form of the input to M matches exactly the form of the strings in the language we want to decide 5 / 26

Using a TM as a subroutine in another TM Given a TM R, we can construct another TM M that uses R The language A = { B, w B is a DFA, w L(B), and w R L(B)} is decidable Let R be the decider for A DFA. M = On input B, w, 1 Run R on w and if R rejects, reject 2 Run R on w R and if R accepts, accept; otherwise reject How does this work? 6 / 26

Using a TM as a subroutine in another TM Given a TM R, we can construct another TM M that uses R The language A = { B, w B is a DFA, w L(B), and w R L(B)} is decidable Let R be the decider for A DFA. M = On input B, w, 1 Run R on w and if R rejects, reject 2 Run R on w R and if R accepts, accept; otherwise reject How does this work? The details aren t important, but here s one way we could incorporate R s implementation into M s: 1 Construct M as a 2-TM that uses its second tape for the implementation of R 6 / 26

Using a TM as a subroutine in another TM Given a TM R, we can construct another TM M that uses R The language A = { B, w B is a DFA, w L(B), and w R L(B)} is decidable Let R be the decider for A DFA. M = On input B, w, 1 Run R on w and if R rejects, reject 2 Run R on w R and if R accepts, accept; otherwise reject How does this work? The details aren t important, but here s one way we could incorporate R s implementation into M s: 1 Construct M as a 2-TM that uses its second tape for the implementation of R 2 So M first copies w to the second tape and then simulates R on it. If R doesn t reject, it copies w R to the second tape and simulates R a second time 6 / 26

Using a TM as a subroutine in another TM Given a TM R, we can construct another TM M that uses R The language A = { B, w B is a DFA, w L(B), and w R L(B)} is decidable Let R be the decider for A DFA. M = On input B, w, 1 Run R on w and if R rejects, reject 2 Run R on w R and if R accepts, accept; otherwise reject How does this work? The details aren t important, but here s one way we could incorporate R s implementation into M s: 1 Construct M as a 2-TM that uses its second tape for the implementation of R 2 So M first copies w to the second tape and then simulates R on it. If R doesn t reject, it copies w R to the second tape and simulates R a second time 3 Construct the basic TM M by the procedure that lets us simulate a k-tm on a basic TM 6 / 26

TM subroutines We re going to be doing this a lot so there are some important things to watch out for If R isn t a decider, then the simulation of R on some input may not halt; if it doesn t the machine we re building won t either! We can t say, Run R on some input and if it loops, do something because we don t know how to tell if a TM is looping 7 / 26

A NFA is decidable Theorem The language A NFA = { B, w B is an NFA that accepts the string w} is decidable. 8 / 26

A NFA is decidable Theorem The language A NFA = { B, w B is an NFA that accepts the string w} is decidable. Proof. We want to build a TM M that decides A NFA. Let R be the TM that decides A DFA and build M = On input B, w, 8 / 26

A NFA is decidable Theorem The language A NFA = { B, w B is an NFA that accepts the string w} is decidable. Proof. We want to build a TM M that decides A NFA. Let R be the TM that decides A DFA and build M = On input B, w, 1 Convert the NFA B to an equivalent DFA C using the power set construction 2 Run R on C, w. If R accepts, accept; otherwise reject 8 / 26

A NFA is decidable Theorem The language A NFA = { B, w B is an NFA that accepts the string w} is decidable. Proof. We want to build a TM M that decides A NFA. Let R be the TM that decides A DFA and build M = On input B, w, 1 Convert the NFA B to an equivalent DFA C using the power set construction 2 Run R on C, w. If R accepts, accept; otherwise reject Since R is a decider, the simulation in step 2 will always halt so M is a decider. If w L(B), then w L(C) so R will accept C, w and thus M accepts. If w L(B), then w L(C) so both R and M will reject. 8 / 26

A REX is decidable Theorem The language A REX = { R, w R is a regular expression that generates the string w} is decidable. 9 / 26

A REX is decidable Theorem The language A REX = { R, w R is a regular expression that generates the string w} is decidable. Proof. We want to build a TM M that decides A REX. Let R be the TM that decides A NFA and build M = On input R, w, 9 / 26

A REX is decidable Theorem The language A REX = { R, w R is a regular expression that generates the string w} is decidable. Proof. We want to build a TM M that decides A REX. Let R be the TM that decides A NFA and build M = On input R, w, 1 Convert the regular expression R to an equivalent NFA N using the standard construction 2 Run R on N, w. If R accepts, accept; otherwise reject 9 / 26

A REX is decidable Theorem The language A REX = { R, w R is a regular expression that generates the string w} is decidable. Proof. We want to build a TM M that decides A REX. Let R be the TM that decides A NFA and build M = On input R, w, 1 Convert the regular expression R to an equivalent NFA N using the standard construction 2 Run R on N, w. If R accepts, accept; otherwise reject Since R is a decider, the simulation in step 2 will always halt so M is a decider. If w L(R), then w L(N) so R will accept N, w and thus M accepts. If w L(R), then w L(N) so both R and M will reject. 9 / 26

DFAs, NFAs, and regular expressions are equivalent For the purposes of constructing TMs, it doesn t matter if the input is a DFA, NFA, or regular expression The TM can always convert from one to another using the procedures we ve been learning about all semester 10 / 26

Emptiness problem Consider the DFAs M 1 : a q 0 b q 1 Is L(M 1 ) =? 11 / 26

Emptiness problem Consider the DFAs M 1 : a q 0 b q 1 Is L(M 1 ) =? Yes 11 / 26

Emptiness problem Consider the DFAs M 1 : a q 0 b q 1 M 2 : a q 0 b q 1 Is L(M 1 ) =? Yes Is L(M 2 ) =? 11 / 26

Emptiness problem Consider the DFAs M 1 : a q 0 b q 1 M 2 : a q 0 b q 1 Is L(M 1 ) =? Yes Is L(M 2 ) =? No 11 / 26

Emptiness problem Consider the DFAs a M 1 : M 2 : a M 3 : q 0 b q 1 q 0 b q 1 q 0 q 1 Is L(M 1 ) =? Yes Is L(M 2 ) =? No Is L(M 3 ) =? 11 / 26

Emptiness problem Consider the DFAs a M 1 : M 2 : a M 3 : q 0 b q 1 q 0 b q 1 q 0 q 1 Is L(M 1 ) =? Yes Is L(M 2 ) =? No Is L(M 3 ) =? Yes 11 / 26

Emptiness problem Consider the DFAs a M 1 : M 2 : a M 3 : q 0 b q 1 q 0 b q 1 q 0 q 1 Is L(M 1 ) =? Yes Is L(M 2 ) =? No Is L(M 3 ) =? Yes What are the necessary and sufficient conditions for a DFA to recognize the empty language? 11 / 26

Emptiness problem Consider the DFAs a M 1 : M 2 : a M 3 : q 0 b q 1 q 0 b q 1 q 0 q 1 Is L(M 1 ) =? Yes Is L(M 2 ) =? No Is L(M 3 ) =? Yes What are the necessary and sufficient conditions for a DFA to recognize the empty language? There must be no path from the initial state to an accepting state 11 / 26

Algorithm to check if the language of a DFA is empty We can use a graph algorithm to determine which states are reachable from the initial state Start by marking the initial state in some way, then iteratively mark all of the neighbors of all marked states until no new states are marked If an accepting state is marked, the language is not empty, otherwise it is empty M 1 : a M 2 : a M 3 : q 0 b q 1 q 0 b q 1 q 0 q 1 12 / 26

Algorithm to check if the language of a DFA is empty We can use a graph algorithm to determine which states are reachable from the initial state Start by marking the initial state in some way, then iteratively mark all of the neighbors of all marked states until no new states are marked If an accepting state is marked, the language is not empty, otherwise it is empty M 1 : a M 2 : a M 3 : q 0 b q 1 q 0 b q 1 q 0 q 1 12 / 26

Algorithm to check if the language of a DFA is empty We can use a graph algorithm to determine which states are reachable from the initial state Start by marking the initial state in some way, then iteratively mark all of the neighbors of all marked states until no new states are marked If an accepting state is marked, the language is not empty, otherwise it is empty M 1 : a M 2 : a M 3 : q 0 b q 1 q 0 b q 1 q 0 q 1 12 / 26

E DFA is decidable Theorem The language E DFA = { B B is a DFA and L(B) = } is decidable 13 / 26

E DFA is decidable Theorem The language E DFA = { B B is a DFA and L(B) = } is decidable Proof. Let s build a TM M to decide E DFA : M = On input B, 1 Mark the initial state of B 2 Repeat until no new states are marked 3 Mark any state that has an incoming transition from a marked state 4 If any accept state is marked, reject; otherwise accept 13 / 26

E DFA is decidable Theorem The language E DFA = { B B is a DFA and L(B) = } is decidable Proof. Let s build a TM M to decide E DFA : M = On input B, 1 Mark the initial state of B 2 Repeat until no new states are marked 3 Mark any state that has an incoming transition from a marked state 4 If any accept state is marked, reject; otherwise accept If L(B), then there must be a path from the initial state to an accept state so M will reject. If L(B) =, then no such path exists and M will accept M is a decider because step 2 can happen at most Q 1 times before no new states are marked 13 / 26

Emptiness problems for NFAs and regular expression How would we show that the analogous emptiness problems for NFAs and regular expressions are decidable? 14 / 26

Emptiness problems for NFAs and regular expression How would we show that the analogous emptiness problems for NFAs and regular expressions are decidable? Let R be a decider for E DFA and then build a TM that first converts the NFA or regular expression to a DFA and then runs R on it 14 / 26

Equivalence of DFAs The equivalence problem for DFAs asks if two DFAs recognize the same language Using a decider for E DFA, we could check if both languages are empty, but that doesn t really help We also have a decider to check if a string is in a language 15 / 26

An idea that doesn t work Let s try to build a decider for EQ DFA = { A, B A and B are DFAs and L(A) = L(B)} Let R be a decider for A DFA and build M = On input A, B, 1 Repeat for each string w Σ 2 Run R on A, w 3 Run R on B, w 4 If one of A or B accepts w and the other rejects, reject 5 Otherwise, A and B agree on all strings so accept If there is a string w that is accepted by A but rejected by B or vice versa, M will eventually reject in step 4. Otherwise L(A) = L(B) so M will accept in step 5 16 / 26

An idea that doesn t work Let s try to build a decider for EQ DFA = { A, B A and B are DFAs and L(A) = L(B)} Let R be a decider for A DFA and build M = On input A, B, 1 Repeat for each string w Σ 2 Run R on A, w 3 Run R on B, w 4 If one of A or B accepts w and the other rejects, reject 5 Otherwise, A and B agree on all strings so accept If there is a string w that is accepted by A but rejected by B or vice versa, M will eventually reject in step 4. Otherwise L(A) = L(B) so M will accept in step 5 Why doesn t this idea work? 16 / 26

An idea that doesn t work Let s try to build a decider for EQ DFA = { A, B A and B are DFAs and L(A) = L(B)} Let R be a decider for A DFA and build M = On input A, B, 1 Repeat for each string w Σ 2 Run R on A, w 3 Run R on B, w 4 If one of A or B accepts w and the other rejects, reject 5 Otherwise, A and B agree on all strings so accept If there is a string w that is accepted by A but rejected by B or vice versa, M will eventually reject in step 4. Otherwise L(A) = L(B) so M will accept in step 5 Why doesn t this idea work? There are infinitely many strings in Σ so the loop on line 1 will never end if L(A) = L(B) 16 / 26

A better idea Given two languages X and Y, consider the language D = (X Y ) (Y X) Three cases: 1 If there is a string x which is in X but not in Y, then X Y so D 17 / 26

A better idea Given two languages X and Y, consider the language D = (X Y ) (Y X) Three cases: 1 If there is a string x which is in X but not in Y, then X Y so D 2 If there is a string w which is in Y but not in X, then Y X so D 17 / 26

A better idea Given two languages X and Y, consider the language D = (X Y ) (Y X) Three cases: 1 If there is a string x which is in X but not in Y, then X Y so D 2 If there is a string w which is in Y but not in X, then Y X so D 3 If X = Y, then X Y and Y X are both so D = 17 / 26

A better idea Given two languages X and Y, consider the language D = (X Y ) (Y X) Three cases: 1 If there is a string x which is in X but not in Y, then X Y so D 2 If there is a string w which is in Y but not in X, then Y X so D 3 If X = Y, then X Y and Y X are both so D = If X and Y are regular languages, then D is regular because X Y = X Y and regular languages are closed under union, intersection, and complement 17 / 26

EQ DFA is decidable Theorem The language EQ DFA = { A, B A and B are DFAs and L(A) = L(B)} is decidable 18 / 26

EQ DFA is decidable Theorem The language EQ DFA = { A, B A and B are DFAs and L(A) = L(B)} is decidable Proof. Let R be a decider for E DFA and build M = On input A, B, 1 Construct DFA C where L(C) = (L(A) L(B)) (L(B) L(A)) 2 Run R on C 3 If R accepts, accept; otherwise reject 18 / 26

EQ DFA is decidable Theorem The language EQ DFA = { A, B A and B are DFAs and L(A) = L(B)} is decidable Proof. Let R be a decider for E DFA and build M = On input A, B, 1 Construct DFA C where L(C) = (L(A) L(B)) (L(B) L(A)) 2 Run R on C 3 If R accepts, accept; otherwise reject The construction in step 1 can be carried out using the constructions we ve seen earlier in the semester M is a decider because R is a decider L(C) = iff L(A) = L(B) so M accepts iff L(A) = L(B) 18 / 26

Recapitulation The acceptance, emptiness, and equivalence problems for DFAs/NFAs/regular expressions are all decidable For some of these, we used deciders for other languages as subroutines 19 / 26

Analogous problems for context-free languages We can consider the acceptance, emptiness, and equivalence problems for context-free languages Like the situation with DFAs, NFAs, and regular expressions, we can easily convert between CFGs and PDAs, so it suffices to consider CFGs 20 / 26

A CFG is decidable Theorem The language A CFG = { G, w G is a CFG and G generates w} is decidable. 21 / 26

A CFG is decidable Theorem The language A CFG = { G, w G is a CFG and G generates w} is decidable. This is trickier than DFAs, but we can use Chomsky normal form (CNF) If w L(G) and G is in CNF, how many steps does it take for G to derive w? 21 / 26

A CFG is decidable Theorem The language A CFG = { G, w G is a CFG and G generates w} is decidable. This is trickier than DFAs, but we can use Chomsky normal form (CNF) If w L(G) and G is in CNF, how many steps does it take for G to derive w? If w = ε, it takes 1 step If w ε, it takes 2 w 1 steps Let s use this fact along with our procedure to convert a CFG to CNF 21 / 26

Proof Proof. Build M = On input G, w, 1 Convert G to CNF 2 If w = ε, then if S ε is a rule in G, accept; otherwise reject 3 Otherwise, list all derivations of length 2 w 1 4 If any of these derivations is w, accept; otherwise reject This is a decider because there are finitely many derivations of length 2 w 1. If w L(G), then M will accept, otherwise M will reject. 22 / 26

Emptiness problem for CFGs Given a CFG, we want to figure out if the CFG can derive any string of terminals Let s figure out which variables in G can derive strings of terminals and then we can look the start variable to see if it s one that can 23 / 26

E CFG is decidable Theorem The language E CFG = { G G is a CFG and L(G) = } is decidable. 24 / 26

E CFG is decidable Theorem The language E CFG = { G G is a CFG and L(G) = } is decidable. Proof. M = On input G, 1 Mark all terminal symbols in the rules of G 2 Repeat until no new variables get marked 3 Mark any variable A in G where A u 1 u 2 u k is a rule and each u i is marked 4 If the start variable is marked, reject; otherwise accept 24 / 26

E CFG is decidable Theorem The language E CFG = { G G is a CFG and L(G) = } is decidable. Proof. M = On input G, 1 Mark all terminal symbols in the rules of G 2 Repeat until no new variables get marked 3 Mark any variable A in G where A u 1 u 2 u k is a rule and each u i is marked 4 If the start variable is marked, reject; otherwise accept M is a decider because the loop can happen only finitely many times If the start variable is marked, then it can derive a string of terminals so L(G) and M rejects If the start variable is not marked, then it cannot derive any string of terminals so L(G) = and M accepts 24 / 26

What about equivalence of CFGs? Theorem The language A = { G, H G and H are CFGs and L(G) L(H)} is Turing-recognizable (RE) 25 / 26

What about equivalence of CFGs? Theorem The language A = { G, H G and H are CFGs and L(G) L(H)} is Turing-recognizable (RE) Proof. Let R be a decider for A CFG and build M = On input G, H, 1 For each w Σ, 2 Run R on G, w 3 Run R on H, w 4 If w was generated by only one of G or H, accept If L(G) L(H), then M will accept at some iteration of the loop If L(G) = L(H), then M will run forever 25 / 26

Co-Turing-recognizable (core) The language A is clearly related to the complement of EQ CFG EQ CFG = A {w w is not a valid representation of G, H for CFGs G and H} 26 / 26

Co-Turing-recognizable (core) The language A is clearly related to the complement of EQ CFG EQ CFG = A {w w is not a valid representation of G, H for CFGs G and H} We say that a language is co-turing-recognizable (core) if its complement is Turing-recognizable (RE) The language EQ CFG is core 26 / 26

Co-Turing-recognizable (core) The language A is clearly related to the complement of EQ CFG EQ CFG = A {w w is not a valid representation of G, H for CFGs G and H} We say that a language is co-turing-recognizable (core) if its complement is Turing-recognizable (RE) The language EQ CFG is core We ll see later that EQ CFG is not RE and thus not decidable (think about what that means for grading homework problems about CFGs) 26 / 26