V Honors Theory of Computation

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

CPSC 421: Tutorial #1

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Theory of Computation (IX) Yijia Chen Fudan University

CSE 105 THEORY OF COMPUTATION

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

Computability and Complexity

Decidability (What, stuff is unsolvable?)

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

CS481F01 Solutions 8

CSCE 551 Final Exam, Spring 2004 Answer Key

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

1 Showing Recognizability

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

CS154, Lecture 10: Rice s Theorem, Oracle Machines

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

THEORY OF COMPUTATION (AUBER) EXAM CRIB SHEET

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

CS20a: Turing Machines (Oct 29, 2002)

Automata and Computability. Solutions to Exercises

Homework Assignment 6 Answers

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

Exam Computability and Complexity

CSE 105 THEORY OF COMPUTATION

Automata and Computability. Solutions to Exercises

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

UNIT-VIII COMPUTABILITY THEORY

Introduction to Languages and Computation

DM17. Beregnelighed. Jacob Aae Mikkelsen

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

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

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

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

Turing Machines A Turing Machine is a 7-tuple, (Q, Σ, Γ, δ, q0, qaccept, qreject), where Q, Σ, Γ are all finite

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

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

Theory of Computation

Computation Histories

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

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

Further discussion of Turing machines

Properties of Context-Free Languages. Closure Properties Decision Properties

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

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

Final exam study sheet for CS3719 Turing machines and decidability.

Undecidable Problems and Reducibility

CP405 Theory of Computation

Decidable and undecidable languages

TURING MAHINES

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

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

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

Turing Machines Part II

TAKE-HOME: OUT 02/21 NOON, DUE 02/25 NOON

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

Decidability (intro.)

Context Free Language Properties

Reducability. Sipser, pages

Non-emptiness Testing for TMs

ACS2: Decidability Decidability

SCHEME FOR INTERNAL ASSESSMENT TEST 3

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

CSE 555 Homework Three Sample Solutions

CSE 105 Theory of Computation

CpSc 421 Final Exam December 6, 2008

Foundations of

NPDA, CFG equivalence

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

CSCC63 Worksheet Turing Machines

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

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

Computational Models Lecture 8 1

Functions on languages:

Decidability and Undecidability

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

CSE 105 THEORY OF COMPUTATION

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

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

CSE 105 THEORY OF COMPUTATION

CSE 105 THEORY OF COMPUTATION

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

CpSc 421 Homework 9 Solution

CSE 105 THEORY OF COMPUTATION

Testing Emptiness of a CFL. Testing Finiteness of a CFL. Testing Membership in a CFL. CYK Algorithm

The Church-Turing Thesis

Lecture 12: Mapping Reductions

Computability Theory. CS215, Lecture 6,

Computability and Complexity

Pumping Lemma for CFLs

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

CS21 Decidability and Tractability

Homework 8. a b b a b a b. two-way, read/write

MA/CSSE 474 Theory of Computation

Computational Models Lecture 8 1

CpSc 421 Final Exam December 15, 2006

Space Complexity. The space complexity of a program is how much memory it uses.

Transcription:

V22.0453-001 Honors Theory of Computation Problem Set 3 Solutions Problem 1 Solution: The class of languages recognized by these machines is the exactly the class of regular languages, thus this TM variant is not equivalent to the standard version. The intuition is that such a TM cannot remember what it has written on tape cells to the left of the current head position, as the TM is unable to return to these cells and thus its computation in the future is independent of the contents of these cells. Also for this reason, we can assume without loss of generality that the head of the TM never goes beyond the cell containing the last symbol of the input string. (Why?) Stay-put transitions can be simulated by ε-moves. Details follow. Let M = (Q, Σ, Γ, δ, q 0, q accept, q reject ) be any TM with stay-put instead of left. We constuct a NFA N = (Q, Σ, δ, q start, F ) that simulates M as follows. The special state q start is the start state of N. Every other element of Q (i.e. state of N) is of the form q, a, where q Q and a Γ. Set F = { q accept, a : a Γ}, where q accept is the accept state of M. We now describe the transition function δ. For each a Σ, set δ (q start, a) = { q 0, a }, where q 0 is the start state of M. For each p, q Q where p {q accept, q reject }, for each a Γ, if M has a transition of the form δ(p, a) = (q, b, R), then for each c Σ, set δ ( p, a, c) = { q, c }. For each p, q Q where p {q accept, q reject }, for each a Σ, if M has a transition of the form δ(p, a) = (q, b, S), then set δ ( p, a, ε) = { q, b }. For each a Γ and c Σ, set δ ( q accept, a, c) = { q accept, a }. For each a Γ and c Σ, set δ ( q reject, a, c) = { q reject, a }. It is not hard to see that L(N) = L(M). On the other hand, it is not hard to see that every NFA can be simulated by TM with stay-put instead of left. 1

Problem 2 Solution: (a) Let L 1 and L 2 be two Turing-recognizable languages, and let M 1 and M 2 be TMs that recognizes L 1 and L 2 respectively. We construct a TM M that recognizes L 1 L 2 : On input w, 1. Run M 1 and M 2 on w in parallel. That is, in each step, M runs one step of M 1 and one step of M 2. 2. If either of M 1 and M 2 accepts, output ACCEPT. If both reject, output REJECT. If M 1 or M 2 accepts w, then M will halt and accept w since M 1 and M 2 are run in parallel and an accepting TM will halt and accept w in a finite number of steps. If both M 1 and M 2 reject w, then M will reject w. If neither M 1 nor M 2 accepts w and one of them loops on w, then M will loop on w. Thus L(M) = L 1 L 2, and Turing-recognizable languages are closed under union. (b) Let L 1 and L 2 be two Turing-recognizable languages, and let M 1 and M 2 be TMs that recognizes L 1 and L 2 respectively. We construct a NTM N that recognizes L 1 L 2 : On input w, 1. Nondeterministically split w into two parts w = xy. 2. Run M 1 on x. If it rejects, halt output REJECT. If it accepts, go to Step 3. 3. Run M 2 on w. If it accepts, output ACCEPT. If it rejects, output REJECT. If w L 1 L 2, then there is a way to split w into two parts w = xy such that x L 1 and y L 2, thus, M 1 halts and accepts x, and M 2 halts and accepts y. Hence at least one branch of N will accept w. On the other hand, if w L 1 L 2, then for every possible splitting w = xy, x L 1 or y L 2, so M 1 does not accept x or M 2 does not accept y. Thus, all branch of N will reject w. Therefore, L(N) = L 1 L 2, and Turing-recognizable languages are closed under concatenation. (c) Let L be a Turing-recognizable languages, and let M be a TM that recognizes L. We construct a TM M that recognizes L : On input w, 1. Nondeterministically choose an integer k and split w into k parts w = w 1 w 2 w k. 2. Run M on each w i. If M accepts all of w 1,..., w k, output ACCEPT. If M rejects one of w 1,..., w k, output REJECT. If w L, then there is a splitting of w = w 1 w 2... w k such that w i L for each i, and thus at least one branch of M will accept w. On the other hand, if w L, then for every possible splitting w = w 1 w 2... w k, w i L for at least one i, thus all branches of M will reject w. Therefore, L(M ) = L, and Turing-recognizable languages are closed under the star operation. (d) Let L 1 and L 2 be two Turing-recognizable languages, and let M 1 and M 2 be TMs that recognizes L 1 and L 2 respectively. We construct a TM M that recognizes L 1 L 2 : On input w, 1. Run M 1 on w. If it rejects, halt and output REJECT. If it accepts, go to Step 2. 2. Run M 2 on w. If it accepts, output ACCEPT. If it rejects, output REJECT. 2

Clearly L(M) = L 1 L 2, and thus Turing-recognizable languages are closed under intersection. Problem 3 Solution: Given a c.f.g. G, we give an algorithm to decide whether L(G) is infinite. Let n be the number of variables in the grammar and b be the maximum length of the right hand side of any rule. We know from the proof of pumping lemma that p = b n serves as the pumping length. We show that L(G) is infinite it contains a string of length l where p < l 2l. (Proof of =:) If there is a string s L(G), s > p, we know by pumping lemma that no matter how one partitions s = uvwxy, vxw p, vx > 0, we have uv i wx i y L(G) i 0. Thus L(G) is infinite. (Proof of = :) If L(G) is infinite, then let s 1 L(G) be a string of length > p. Partition s 1 = uvwxy, vxw p, vx > 0. We know by pumping lemma that the string s 2 = uwy L(G). Note that s 1 p s 2 < s 1. We can use this argument repetitively and produce a sequence of strings s 1, s 2, s 3,... such that all of them are in L(G) and s i > p = s i p s i+1 < s i Hence we will find a string s i0 whose length l satisfies p < l 2p. Thus in order to decide whether L(G) is infinite, it suffices to decide whether the grammar generates a string of length l where p < l 2l. This can be done by trying out all strings of length in this range. Problem 4 Solution: We observe that L(R) L(S) if and only L(R) L(S) =. Therefore the following TM decides On input R, S : L = { R, S : R and S are regular expressions and L(R) L(S)}. 1. Construct a DFA D such that L(D) = L(R) L(S). 2. Run a TM T that decides E DFA on input D (i.e. decides whether L(D) is empty. We did this in class). 3. If T accepts, output ACCEPT. If T rejects, output REJECT. Problem 5 { } Solution: We show that A TM reduces to A = M : w R L(M) whenever w L(M). Since A TM is undecidable, it follows that A is undecidable. The reduction from A TM to A maps M, w to M where M is the following TM with M and w built in: On input x: 1. If x = 01, then halt and output ACCEPT. 3

2. Else if x 10, then halt and output REJECT. 3. Else (if x = 10), then simulate M on w. If M accepts w, then output ACCEPT; if M rejects w, then output REJECT. It is easy to see that if M, w A TM, that is, if M accepts w, then L(M ) = {01, 10}, so M A. On the other hand, if M, w A TM, that is, if M does not accept w, then L(M ) = {01}, so M A. Therefore the above mapping is a reduction from A TM to A. Note: You could also use Rice s Theorem. 4

Problem 6 Solution: Suppose that exactly k of the machines {M 1, M 2, M 3 } halt on corresponding inputs. The idea is to figure out the value of k. Once we know k, we can decide which ones halt: simply simulate the three machines on corresponding inputs simultaneously (one step of every machine at a time), and halt when exactly k of them halt. Since we know k, we are guaranteed to halt. This is how we figure out the value of k. First construct a machine M that simulates the three machines on corresponding inputs simultaneously and halts if at least two of them halt. Now decide whether M halts by asking the oracle. (Case 1): If M halts, we know that k 2. By running the machines simultaneously again, we figure out which two of the machines halt. Then by asking the oracle, we can figure out whether the third machine halts. (Case 2): If M does not halt, we know that k 1. Construct a machine M that simulates the three machines on corresponding inputs simultaneously and halts if at least one of them halts. Decide whether M halts by asking the oracle. If M halts, then we know that k = 1. If M does not halt, we know that k = 0. 5