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

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

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

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Theory of Computation (IX) Yijia Chen Fudan University

Decidability (intro.)

V Honors Theory of Computation

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

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

Computability Theory

Computability Theory

Decidability (What, stuff is unsolvable?)

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

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

ACS2: Decidability Decidability

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

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

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

Theory of Computation

1 Showing Recognizability

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CS5371 Theory of Computation. Lecture 15: Computability VI (Post s Problem, Reducibility)

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

Intro to Theory of Computation

Computability and Complexity

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

CSE 105 THEORY OF COMPUTATION

CSCE 551 Final Exam, Spring 2004 Answer Key

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

CSE 105 THEORY OF COMPUTATION

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

Intro to Theory of Computation

CSE 105 Theory of Computation

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

Decidable and undecidable languages

CSE 105 THEORY OF COMPUTATION

CS154, Lecture 10: Rice s Theorem, Oracle Machines

TURING MAHINES

Lecture 12: Mapping Reductions

Lecture Notes: The Halting Problem; Reductions

CSE 105 THEORY OF COMPUTATION

CS20a: Turing Machines (Oct 29, 2002)

Homework Assignment 6 Answers

Turing Machines Part III

Computational Models Lecture 8 1

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

UNIT-VIII COMPUTABILITY THEORY

CS5371 Theory of Computation. Lecture 18: Complexity III (Two Classes: P and NP)

Decidability and Undecidability

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

Reducability. Sipser, pages

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

Computational Models Lecture 8 1

MTAT Introduction to Theoretical Computer Science

CPSC 421: Tutorial #1

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

Decidable Languages - relationship with other classes.

Undecidable Problems and Reducibility

MA/CSSE 474 Theory of Computation

Computational Models Lecture 8 1

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

Foundations of

Turing Machines Part II

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

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

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

Automata and Computability. Solutions to Exercises

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

CSE 105 THEORY OF COMPUTATION

Computability Theory. CS215, Lecture 6,

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

Equivalence of TMs and Multitape TMs. Theorem 3.13 and Corollary 3.15 By: Joseph Lauman

CP405 Theory of Computation

CSE 105 THEORY OF COMPUTATION

Exam Computability and Complexity

Turing Machines Part II

Computability and Complexity

Automata and Computability. Solutions to Exercises

CSCC63 Worksheet Turing Machines

Decidability. Linz 6 th, Chapter 12: Limits of Algorithmic Computation, page 309ff

A Note on Turing Machine Design

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

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

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Midterm II : Formal Languages, Automata, and Computability

Introduction to Languages and Computation

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

Busch Complexity Lectures: Turing s Thesis. Costas Busch - LSU 1

Turing Machine Variants

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

CpSc 421 Final Exam December 15, 2006

Turing Machines. Lecture 8

CS481F01 Solutions 8

CS 361 Meeting 28 11/14/18

Turing Machine Recap

ECS 120 Lesson 24 The Class N P, N P-complete Problems

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

6.045 Final Exam Solutions

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 8 Nancy Lynch

CSE 105 THEORY OF COMPUTATION

COL 352 Introduction to Automata and Theory of Computation Major Exam, Sem II , Max 80, Time 2 hr. Name Entry No. Group

Transcription:

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

Objectives 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

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 E.g., if D is a DFA accepting even length strings, and D is a DFA accepting odd length strings, then, D, 01, D, 0000, D, 1, D, 111 are strings in A DFA, but D, 1, D, 000, D, 1000, D, 11 are not

Acceptance by DFA (2) Theorem 1: A DFA is a decidable language Proof: We construct a TM M that decides A DFA as follows: M = 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 M perform the above steps?? M uses 3 tapes; initially, Tape 1 stores the input B, w, the other two all blanks Then, M copies w into Tape 2, and write the start state of B in Tape 3 Usage: Tape head of Tape 2 stores next char in w for B to read, Tape 3 stores the current state Based on Tapes 2 and 3, M moves back and forth Tape 1 to know how B performs each transition, and update the tapes accordingly

Acceptance by DFA (4) Q2: Why is M a decider for A DFA? For any input B, w, M can simulate B so that each transition in B takes finite number of steps in M To know which state B is at after reading w, there are only w transitions in B Thus, M takes finite number of steps to know if B accepts w or not. Then, M 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) Proof: [Solution 1] We can use the same idea when we simulate NTM by TM, so that we give a TM that decides A NFA. Precisely, we need to try every possible branch of computation, but only of length up to b w, where b is the branching factor of B (why??)

Acceptance by NFA (3) [Solution 2 (easier)] We re-use the TM M that decides A DFA to give a TM N that decides A NFA : N = On input B, w 1. Convert B to an equivalent DFA C 2. Run TM M on C, w 3. If M accepts, accept. Else, reject

Acceptance by NFA (4) Q1: How can N perform the above steps?? N uses 5 tapes; initially, Tape 1 stores the input B, w, Tape 2 stores the encoding of M, the other two all blanks Then, N converts B to C and store it in Tape 3 N then consults M in Tape 2, to know how M 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, as N simulates M to simulate C

Acceptance by NFA (5) Q2: Why is N a decider for A NFA? For any input B, w, N convert B into the equivalent DFA C in finite number of steps Then, M takes finite number of steps to know if C accepts w or not. Thus, N 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 P that decides A RE : P = On input R, w 1. Convert R to an equivalent NFA A 2. Run TM N of Theorem 2 (the NFAstring checker ) on A, w 3. If N accepts A, w, 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: A 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 T that decides E DFA as follows: T = On input B 1. Mark the start state of B 2. Repeat until no new states are marked 2a. 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 F that decides EQ DFA as follows: F = On input A,B 1. Construct C (how?) 2. Run TM T of Theorem 4 (the Emptiness-Tester for DFA ) on C 3. If T 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 X that decides A CFG as follows: X = 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 (# of such derivations (4 V T ) 2 w -1. That is, a finite number) 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 R that decides E CFG as follows: R = On input G 1. Mark all terminals of G 2. Repeat until no new variable is marked 2a. 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 (if you recall Tutorial 3) 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 recognizes the same language How about, if we are given a CFG, can we find a TM that recognizes the same language? The answer is YES!

TM can simulate CFG (2) Theorem 8: Given a CFG G, we can construct a TM that recognizes 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 TM X of Theorem 6 (the CFGstring checker ) on G, w 2. If X accepts G, w, accept. Else, reject We can see that M G recognizes the same language as G. This completes the proof

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

Next Time Undecidable Languages Languages that CANNOT be decided by ANY Turing Machine Example 1: Turing-recognizable, but not Turing-decidable Example 2: Non-Turing recognizable (that is, even more difficult!!)