Solution sketch 5 - Computational Models - Spring...

3
Solution sketch 5 - Computational Models - Spring 2017 1. (a) Incorrect. For example, define the languages A = {0 n 1 n | n 0} and B = {1}, both over the alphabet Σ = {0, 1}. Define the function f * 7Σ * as f (w) = 1 if w A and f (w) = 0 if w 6A. Observe that A is a context-free language, so it is also Turing-decidable. Thus, f is a computable function. Also, w A if and only if f (w) = 1, which is true if and only if f (w) B. Hence, A m B. Language A is nonregular, but B is regular since it is finite. (b) Correct. A is context-free, so A ∈R. Let M A be the TM that decides A. Let f (x)= hM,xi, be such that M on input x: Run M A on x and answer the same. Clearly, f is computable. Now, obviously, x A ⇐⇒ M accepts x. (c) Correct. Let f be the reduction from A to B and let g be the reduction from B to C . Define h * Σ * such that h(x)= g(f (x)). As f and g are computable, h is computable as well (how?). Also, x A if and only if f (x) B if and only if g(f (x)) C if and only if h(x) C , as desired. (d) Incorrect. Let A = A TM and B = A TM . It is not the case that A m B since B co-RE but A 6co-RE . Similarly, it is not the case that B m A. 2. We show that EMPTY TM m USELESS TM by the following mapping reduction. We define f (hM i) such that if hM i is an illegal encoding then f returns an arbitrary NO instance of EMPTY TM and otherwise returns hM,q a i. Clearly f is computable. In addition, note that q a is a useless state if and only if L(M )= . Thus hM i∈ EMPTY TM ⇐⇒ f (hM i)= hM,q a i∈ USELESS TM . 3. We show that A TM m S TM by the following mapping reduction. We define f (hM,wi) such that if hM i is an illegal encoding then f returns an arbitrary 1

Transcript of Solution sketch 5 - Computational Models - Spring...

Page 1: Solution sketch 5 - Computational Models - Spring 2017tau-cm2017b.wdfiles.com/local--files/home-assignments/sol5_2017b.pdf · Solution sketch 5 - Computational Models - Spring 2017

Solution sketch 5 - Computational Models -Spring 2017

1. (a) Incorrect. For example, define the languages A = {0n1n | n ≥ 0}and B = {1}, both over the alphabet Σ = {0, 1}. Define the functionf : Σ∗ 7→ Σ∗ as f(w) = 1 if w ∈ A and f(w) = 0 if w 6∈ A. Observe thatA is a context-free language, so it is also Turing-decidable. Thus, f is acomputable function. Also, w ∈ A if and only if f(w) = 1, which is trueif and only if f(w) ∈ B. Hence, A ≤m B. Language A is nonregular,but B is regular since it is finite.

(b) Correct. A is context-free, so A ∈ R. Let MA be the TM that decidesA. Let f(x) = 〈M,x〉, be such that M on input x: Run MA on x andanswer the same. Clearly, f is computable. Now, obviously, x ∈ A⇐⇒ M accepts x.

(c) Correct. Let f be the reduction from A to B and let g be the reductionfrom B to C. Define h : Σ∗ → Σ∗ such that h(x) = g(f(x)). As f andg are computable, h is computable as well (how?). Also, x ∈ A if andonly if f(x) ∈ B if and only if g(f(x)) ∈ C if and only if h(x) ∈ C, asdesired.

(d) Incorrect. Let A = ATM and B = ATM . It is not the case that A ≤m Bsince B ∈co-RE but A 6∈co-RE . Similarly, it is not the case that B ≤m

A.

2. We show that EMPTYTM ≤m USELESSTM by the following mappingreduction. We define f(〈M〉) such that if 〈M〉 is an illegal encoding thenf returns an arbitrary NO instance of EMPTYTM and otherwise returns〈M, qa〉.Clearly f is computable. In addition, note that qa is a useless state if andonly if L(M) = ∅. Thus 〈M〉 ∈ EMPTYTM ⇐⇒ f(〈M〉) = 〈M, qa〉 ∈USELESSTM .

3. We show that ATM ≤m STM by the following mapping reduction. We definef(〈M,w〉) such that if 〈M〉 is an illegal encoding then f returns an arbitrary

1

Page 2: Solution sketch 5 - Computational Models - Spring 2017tau-cm2017b.wdfiles.com/local--files/home-assignments/sol5_2017b.pdf · Solution sketch 5 - Computational Models - Spring 2017

NO instance of STM and otherwise returns 〈M ′〉, whereas M ′ on input x: Ifx = ‘01‘ accept. Otherwise, run M on w and answers accordingly.

The reduction is computable. If M accepts w then L(M ′) = Σ∗ so 〈M ′〉 ∈STM . If M does not accept w then L(M ′) = {01} so 〈M ′〉 6∈ STM (the caseof an illegal encoding is handled in this direction as well).

4. (a) L 6∈ RE ∪ coRE.

L 6∈ RE: We will show HTM,ε ≤m L. Let Mε be the TM that oninput 〈M〉, Mε runs M on ε and answers accordingly. The reductionis f(〈M〉) such that if 〈M〉 is an illegal encoding then f returns anarbitrary YES instance of L, and otherwise returns 〈M ′〉, whereas M ′

on input x: Run M on ε for |x| steps. If within the |x| steps M halted,M ′ rejects. Otherwise, M ′ simulates Mε on x and answers accordingly.

The reduction is computable. If M does not halt on ε then L(M ′) =L(Mε) = ATM,ε and indeed ATM ≤m ATM,ε (the case of an illegalencoding is handled in this direction as well). If M does halt on ε thenM ′ necessarily accepts only a finite number of words, so L(M ′) ∈ Rand 〈M ′〉 6∈ L.

L 6∈ coRE: We will show HTM,ε ≤m L. The reduction is f(〈M〉)such that if 〈M〉 is an illegal encoding then f returns an arbitrary NOinstance of L, and otherwise returns 〈M ′〉, whereas M ′ on input x: M ′

simulates M on ε and then simulates Mε on x and answers accordingto the second simulation.

The reduction is computable. If M halts on ε then L(M ′) = L(Mε) =ATM,ε and indeed ATM ≤m ATM,ε. If M does not halt on ε thenL(M ′) = ∅ so 〈M ′〉 6∈ L (the case of an illegal encoding is handledin this direction as well).

(b) L ∈ coRE \R.

L ∈ coRE: A TM M ′ that accepts L, on input 〈M〉: Use a controlledexecution of M over all words in Σ∗ where the simulation is done onan extra tape. Whenever, some simulation reaches position |x| + 20,accept. The correctness is clear.

L 6∈ R: We will show ATM ≤m L. The reduction is f(〈M〉, w) such thatif 〈M〉 is an illegal encoding then f returns an arbitrary YES instanceof L, and otherwise returns 〈M ′〉, whereas M ′ on input x: Check if x isan accepting computational history of the run of M on w. If it is, keepgoing right forever. Otherwise, reject. The reduction is computable. IfM does not accept w then there is no accepting computational historyand for every x we reject. We saw that we don’t need any space to the

2

Page 3: Solution sketch 5 - Computational Models - Spring 2017tau-cm2017b.wdfiles.com/local--files/home-assignments/sol5_2017b.pdf · Solution sketch 5 - Computational Models - Spring 2017

right of x to check it, so 〈M ′〉 ∈ L (the case of an illegal encoding ishandled in this direction as well). If M accepts w then there exists xthat is an accepting computational history and on that x, M ′ reachesthe position |x|+ 20. Thus, 〈M ′〉 6∈ L.

5. Assume to the contrary that f is computable. Consider the following TMM ′ , that on input 〈M〉:

• If 〈M〉 is an illegal encoding, reject.

• Compute f(〈M〉) = k.

• If k =∞ reject.

• Otherwise, let m = |Q| · |Γ|k · k.

• Emulate M on ε for m+1 steps. Accept if M halts and reject otherwise.

We first argue that L(M ′) = HTM,ε. If k =∞ then clearly, M doesn’t halt onε. Otherwise m is an upper bound on the number of distinct configurationsof M on ε. If M doesn’t halt within m+ 1 steps then it repeats at least oneconfiguration more than once, and thus will never halt. Also, note that M ′

always halts, so L(M ′) ∈ R, contradicting the fact that HTM,ε 6∈ R. Hence,f is not computable.

6. Suppose on the contrary that the set of incompressible strings contains aninfinite recursively enumerable subset A. Let E be an enumerator for A.Now, let M denote the Turing machine that on input n a positive integer inbinary representation, outputs the first string printed by E that has lengthat least n (since A is infinite there exists such a string). Then, for everypositive integer n, 〈M,n〉 is a description of an incompressible string sn oflength at least n, and the description has length log n + |cM |, so we haven ≤ KU(sn) ≤ log n + |cM |, a contradiction for sufficiently large n.

3