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

Slides:



Advertisements
Similar presentations
Grammar types There are 4 types of grammars according to the types of rules: – General grammars – Context Sensitive grammars – Context Free grammars –
Advertisements

INHERENT LIMITATIONS OF COMPUTER PROGRAMS CSci 4011.
FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY
1 CSC3130 Formal Languages and Automata Theory Tutorial 9 Undecidable Problem KN Hung SHB 1026.
February 6, 2015CS21 Lecture 141 CS21 Decidability and Tractability Lecture 14 February 6, 2015.
1 Introduction to Computability Theory Lecture14: Recap Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Decidable Languages Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
Introduction to Computability Theory
1 Introduction to Computability Theory Lecture7: PushDown Automata (Part 1) Prof. Amos Israeli.
Decidable languages Sipser 4.1 (pages ). CS 311 Mount Holyoke College 2 Hierarchy of languages All languages Turing-recognizable Turing-decidable.
CS5371 Theory of Computation
Courtesy Costas Busch - RPI1 Non Deterministic Automata.
Fall 2003Costas Busch - RPI1 Decidability. Fall 2003Costas Busch - RPI2 Recall: A language is decidable (recursive), if there is a Turing machine (decider)
CS 302: Discrete Math II A Review. An alphabet Σ is a finite set (e.g., Σ = {0,1}) A string over Σ is a finite-length sequence of elements of Σ For x.
Decidability. Why study un-solvability? When a problem is algorithmically unsolvable, we realize that the problem must be simplified or altered before.
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Rules have form String of variables and terminals String of variables and terminals.
Decidable and undecidable problems deciding regular languages and CFL’s Undecidable problems.
CS 310 – Fall 2006 Pacific University CS310 Decidability Section 4.1/4.2 November 10, 2006.
CS Master – Introduction to the Theory of Computation Jan Maluszynski - HT Lecture 6 Decidability Jan Maluszynski, IDA, 2007
Linear Bounded Automata LBAs
Foundations of (Theoretical) Computer Science Chapter 4 Lecture Notes (Section 4.1: Decidable Languages) David Martin With modifications.
CS 490: Automata and Language Theory Daniel Firpo Spring 2003.
CS5371 Theory of Computation Lecture 9: Automata Theory VII (Pumping Lemma, Non-CFL)
Fall 2006Costas Busch - RPI1 Non-Deterministic Finite Automata.
CS5371 Theory of Computation Lecture 4: Automata Theory II (DFA = NFA, Regular Language)
CS5371 Theory of Computation Lecture 8: Automata Theory VI (PDA, PDA = CFG)
Costas Busch - LSU1 Non-Deterministic Finite Automata.
Fall 2006Costas Busch - RPI1 Undecidable Problems (unsolvable problems)
Prof. Busch - LSU1 Undecidable Problems (unsolvable problems)
TM Design Universal TM MA/CSSE 474 Theory of Computation.
Computability Construct TMs. Decidability. Preview: next class: diagonalization and Halting theorem.
Decidable languages Section 4.1 CSC 4170 Theory of Computation.
Closure Properties Lemma: Let A 1 and A 2 be two CF languages, then the union A 1  A 2 is context free as well. Proof: Assume that the two grammars are.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
CSCI 2670 Introduction to Theory of Computing October 12, 2005.
 2005 SDU Lecture13 Reducibility — A methodology for proving un- decidability.
1Computer Sciences Department. Book: INTRODUCTION TO THE THEORY OF COMPUTATION, SECOND EDITION, by: MICHAEL SIPSER Reference 3Computer Sciences Department.
D E C I D A B I L I T Y 1. 2 Objectives To investigate the power of algorithms to solve problems. To explore the limits of algorithmic solvability. To.
Computability Review homework. Video. Variations. Definitions. Enumerators. Hilbert's Problem. Algorithms. Summary Homework: Give formal definition of.
CSCI 2670 Introduction to Theory of Computing October 13, 2005.
1 The Chomsky Hierarchy. 2 Unrestricted Grammars: Productions String of variables and terminals String of variables and terminals.
 2005 SDU Lecture11 Decidability.  2005 SDU 2 Topics Discuss the power of algorithms to solve problems. Demonstrate that some problems can be solved.
CSCI 3130: Formal languages and automata theory Andrej Bogdanov The Chinese University of Hong Kong Decidable.
FORMAL LANGUAGES, AUTOMATA, AND COMPUTABILITY * Read chapter 4 of the book for next time * Lecture9x.ppt.
Recursively Enumerable and Recursive Languages. Definition: A language is recursively enumerable if some Turing machine accepts it.
Decidability.
February 1, 2016CS21 Lecture 121 CS21 Decidability and Tractability Lecture 12 February 1, 2016.
Busch Complexity Lectures: Reductions
Reductions Costas Busch - LSU.
CSE 105 theory of computation
BCS 2143 Theory of Computer Science
CSE 2001: Introduction to Theory of Computation Fall 2013
CSCI 2670 Introduction to Theory of Computing
CSE 105 theory of computation
Busch Complexity Lectures: Undecidable Problems (unsolvable problems)
Intro to Theory of Computation
Jaya Krishna, M.Tech, Assistant Professor
Intro to Theory of Computation
Decidable Languages Costas Busch - LSU.
CSC 4170 Theory of Computation Decidable languages Section 4.1.
Decidable and undecidable languages
CSCI 2670 Introduction to Theory of Computing
Instructor: Aaron Roth
Theory of Computability
CSE 105 theory of computation
Automata, Grammars and Languages
Intro to Theory of Computation
CSE 105 theory of computation
Presentation transcript:

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

Recall that decidable languages are languages that can be decided by TM (that means, the corresponding TM will accept or reject correctly, never loops) In this lecture, we investigate some decidable languages that are related to DFA, NFA, and CFG –Testing Acceptance, Emptiness, or Equality Also, we show how TM can simulate CFG Objectives

Acceptance by DFA Let A DFA be the language {  B, w  | B is a DFA that accepts w} where  B, w  denotes the encoding of B followed by w For example, if D is a DFA accepting even length strings, then,  D, 01 ,  D, 0000  are strings in A DFA, but  D, 1 ,  D, 000  are not

Acceptance by DFA (2) Theorem 1: A DFA is a decidable language Proof: We construct a TM D A DFA that decides A DFA as follows: D A DFA = “On input  B, w  1. Simulate B on input w 2. If the simulation ends in an accept state, accept. Else, reject ”

Acceptance by DFA (3) Q1: How can D A DFA perform the above steps?? It uses 3 tapes; initially, Tape 1 stores the input  B, w , the other two all blanks Then, D A DFA copies w into Tape 2, and write the start state of B in Tape 3 Usage: Tape head of Tape 2 points to next char in w for B to read, Tape 3 stores current state Based on Tapes 2 and 3, D A DFA moves back and forth Tape 1 to know how B performs each transition, and update the 3 tapes accordingly

Acceptance by DFA (4) Q2: Why is D A DFA a decider for A DFA ? For any input  B, w , it can simulate B so that each transition in B takes finite number of steps To know which state B is at after reading w, there are only |w| transitions in B Thus, it takes finite number of steps to know if B accepts w or not. So, D A DFA can decide (no infinite loop) whether to accept or reject  B, w 

Acceptance by NFA Let A NFA be the language {  B, w  | B is an NFA that accepts w} Theorem 2: A NFA is a decidable language

Acceptance by NFA (2) [Solution 2 ] D A DFA to give a TM D A NFA that decides A NFA : D A NFA = “On input  B, w  1. Convert B to an equivalent DFA C 2. Run D A DFA on  C, w  3. If D A DFA accepts, accept. Else, reject”

Acceptance by NFA (3) Q1: How can D A NFA perform the above steps?? It uses 5 tapes; initially, Tape 1 stores the input  B, w , Tape 2 stores the encoding of D A DFA, the other three all blanks Then, D A NFA converts B to C and store C in Tape 3 It then consults D A DFA in Tape 2, to know how D A DFA simulates C running on w Tapes 4 and 5 can be used to store the current state of C, and the next char for C to read, so that D A NFA can simulate D A DFA to simulate C

Acceptance by NFA (4) Q2: Why is D A NFA a decider for A NFA ? For any input  B, w , it convert B into the equivalent DFA C in finite number of steps Then, it consults D A DFA which takes finite number of steps to know if C accepts w or not. Thus, D A NFA can decide (no infinite loop) whether to accept or reject  B, w 

Acceptance by Regular Expression (RE) Let A RE be the language {  R, w  | R is an RE that generates w } Theorem 3: A RE is a decidable language

Acceptance by RE (2) Proof: W give a TM D A RE that decides A RE : D A RE = “On input  R, w  1. Convert R to an equivalent NFA A 2. Run D A NFA on  A, w  3. If D A NFA accepts, accept. Else, reject”

Emptiness Test for DFA Let E DFA be the language {  B  | B is a DFA and L(B) = { } } Theorem 4: E DFA is a decidable language Observation: DFA accepts no string if and only if we cannot reach any accept state from the start state by following transition arrows

Emptiness Test for DFA (2) Proof: We use similar idea as we test if a graph G is connected. Precisely, we give a TM D E DFA that decides E DFA as follows: D E DFA = “On input  B  1. Mark the start state of B 2. Repeat until no new states are marked Mark any state that has a transition coming into it from a marked state 3. If no accept state of B is marked, accept. Else, reject”

Equality Test for DFA Let EQ DFA be the language {  A,B  | A and B are DFAs and L(A) = L(B) } Theorem 5: EQ DFA is a decidable language Hint: Let C be a DFA that accepts strings that is in L(A) but not in L(B), and also strings that is in L(B) but not in L(A). Then, L(C) ={ } if and only if L(A) = L(B)

Equality Test for DFA (2) Proof: Based on the hint, we give a TM D EQ DFA that decides EQ DFA as follows: D EQ DFA = “On input  A,B  1. Construct C (how?) 2. Run D E DFA (Emptiness-Tester for DFA) on  C  3. If D E DFA accepts, accept. Else, reject”

Acceptance by CFG Let A CFG be the language {  G, w  | G is a CFG that generates w } Theorem 6: A CFG is a decidable language Hint: We need to avoid testing infinite derivations… If G is in Chomsky normal form, any derivation of w takes exactly 2|w| - 1 derivation steps

Acceptance by CFG (2) Proof: Based on the hint, we give a TM D A CFG that decides A CFG as follows: D A CFG = “On input  G, w  1. Convert G into G’ = (V,T,R,S) in CNF 2. Generate all derivations of G’ with 2|w|-1 derivation steps 3. If any derivation generates w, accept. Else, reject”

Emptiness Test for CFG Let E CFG be the language {  G  | G is a CFG and L(G) = { } } Theorem 7: E CFG is a decidable language Observation: Suppose that we can mark all the variables in G that can generate a string of terminals. Then, L(G) = { } if the start variable is not marked

Emptiness Test for CFG (2) Proof: We use similar idea as we test if a graph G is connected. Precisely, we give a TM D E CFG that decides E CFG as follows: D E CFG = “On input  G  1. Mark all terminals of G 2. Repeat until no new variable is marked Mark variable A if G has a rule A  U 1 U 2 …U k and all U i ’s are marked 3. If the start variable is not marked, accept. Else, reject”

Equality Test for CFG? Let EQ CFG be the language {  A,B  | A and B are CFGs and L(A) = L(B) } Is EQ CFG is a decidable language? Unfortunately, no… Note that we cannot apply similar trick as we prove EQ DFA is decidable We shall show EQ CFG is undecidable later…

TM can simulate CFG Previously (a long time ago), we have shown that given a DFA, we can always find a CFG that decides the same language How about, if we are given a CFG, can we find a TM that decides the same language? –The answer is YES!

TM can simulate CFG (2) Theorem 8: Given a CFG G, we can construct a TM that decides the same language. In other words, every CFL is a decidable language

TM can simulate CFG (3) Proof: We find a TM M G with  G  stored in it initially; M G then performs as follows: M G = “On input  w  1. Run D A CFG (Accept-by-CFG checker) on  G, w  2. If D A CFG accepts  G, w , accept. Else, reject ” We can see that M G decides the same language as G. This completes the proof

Language Hierarchy (revisited) Set of Regular Language Set of Context- Free Language Set of Languages (= set of “set of strings”) {0 x 1 y } {0 n 1 n } {0 n 1 n 2 n } {w with even |w|} {w | w = w R } {ww} Set of Decidable Language Set of Recognizable Language ?? ???