ASSIGNMENT THREE SOLUTIONS MATH 4805 / COMP 4805 / MATH (1) (a) A transition diagram appears below for the TM specified by the 7-tuple M =

Similar documents
Turing Machines (TM) Deterministic Turing Machine (DTM) Nondeterministic Turing Machine (NDTM)

1 Showing Recognizability

Introduction to Turing Machines. Reading: Chapters 8 & 9

Griffith University 3130CIT Theory of Computation (Based on slides by Harald Søndergaard of The University of Melbourne) Turing Machines 9-0

CSCC63 Worksheet Turing Machines

Turing s thesis: (1930) Any computation carried out by mechanical means can be performed by a Turing Machine

Computability and Complexity

CSE 105 THEORY OF COMPUTATION

Turing Machines Part II

CS4026 Formal Models of Computation

Part I: Definitions and Properties

Homework 5 Solution CSCI 2670 October 6, c) New text q 1 1##1 xq 3 ##1 x#q 5 #1 q reject. Old text. ~q 3 ##1 ~#q 5 #1

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS

Turing Machines. Nicholas Geis. February 5, 2015

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

Chapter 3: The Church-Turing Thesis

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

Limits of Computability

Undecidable Problems and Reducibility

Lecture 12: Mapping Reductions

Theory of Computation

Turing Machines. Lecture 8

The Turing Machine. CSE 211 (Theory of Computation) The Turing Machine continued. Turing Machines

CSCE 551 Final Exam, Spring 2004 Answer Key

ECS 120 Lesson 20 The Post Correspondence Problem

IV. Turing Machine. Yuxi Fu. BASICS, Shanghai Jiao Tong University

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

Computable Functions

CpSc 421 Homework 9 Solution

Turing Machines. Chapter 17

15.1 Proof of the Cook-Levin Theorem: SAT is NP-complete

Turing machine recap. Universal Turing Machines and Undecidability. Alphabet size doesn t matter. Robustness of TM

TURING MAHINES

Theory of Computation

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

Turing Machines Part III

Theory of Computation Lecture Notes. Problems and Algorithms. Class Information

Chapter 8. Turing Machine (TMs)

FORMAL LANGUAGES, AUTOMATA AND COMPUTABILITY

Most General computer?

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

4.2 The Halting Problem

Turing Machines, diagonalization, the halting problem, reducibility

Deterministic Finite Automata (DFAs)

Harvard CS 121 and CSCI E-121 Lecture 14: Turing Machines and the Church Turing Thesis

Deterministic Finite Automata (DFAs)

Computation Histories

1 Unrestricted Computation

CS21 Decidability and Tractability

Lecture 1: Introduction

Midterm II : Formal Languages, Automata, and Computability

CSE 105 THEORY OF COMPUTATION

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

Turing Machine Recap

ECS 120 Lesson 15 Turing Machines, Pt. 1

A Universal Turing Machine

Turing Machines. The Language Hierarchy. Context-Free Languages. Regular Languages. Courtesy Costas Busch - RPI 1

Lecture 14: Recursive Languages

CMPT 710/407 - Complexity Theory Lecture 4: Complexity Classes, Completeness, Linear Speedup, and Hierarchy Theorems

Q = Set of states, IE661: Scheduling Theory (Fall 2003) Primer to Complexity Theory Satyaki Ghosh Dastidar

The Power of One-State Turing Machines

Automata Theory - Quiz II (Solutions)

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

Deterministic Finite Automata (DFAs)

CS20a: Turing Machines (Oct 29, 2002)

Sample Project: Simulation of Turing Machines by Machines with only Two Tape Symbols

Turing machines Finite automaton no storage Pushdown automaton storage is a stack What if we give the automaton a more flexible storage?

ACS2: Decidability Decidability

Turing Machines Extensions

CSCI3390-Assignment 2 Solutions

problem X reduces to Problem Y solving X would be easy, if we knew how to solve Y

Non-emptiness Testing for TMs

Turing Machines. Wolfgang Schreiner

CSE 105 THEORY OF COMPUTATION

The Unsolvability of the Halting Problem. Chapter 19

Chomsky Normal Form and TURING MACHINES. TUESDAY Feb 4

1 From previous lectures

Turing Machine properties. Turing Machines. Alternate TM definitions. Alternate TM definitions. Alternate TM definitions. Alternate TM definitions

Computational Models Lecture 8 1

Turing machines COMS Ashley Montanaro 21 March Department of Computer Science, University of Bristol Bristol, UK

Computability Theory

Homework Assignment 6 Answers

Computability and Complexity Theory

Decidability (What, stuff is unsolvable?)

1 Definition of a Turing machine

Complexity (Pre Lecture)

Further discussion of Turing machines

Computational Models Lecture 8 1

Computational Models Lecture 8 1

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Time-bounded computations

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

CSE 105 THEORY OF COMPUTATION

The tape of M. Figure 3: Simulation of a Turing machine with doubly infinite tape

6.045J/18.400J: Automata, Computability and Complexity. Quiz 2. March 30, Please write your name in the upper corner of each page.

Lecture 13: Turing Machine

Automata and Computability. Solutions to Exercises

Universal Turing Machine. Lecture 20

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

Transcription:

ASSIGNMENT THREE SOLUTIONS MATH 4805 / COMP 4805 / MATH 5605 (1) (a) A transition diagram appears below for the TM specified by the 7-tuple M = ({q, q 0, q 1, q 2, q 01, q 02, q 12, q 012, r, f, z}, {0, 1}, {0, 1, B, X}, δ, q, B, {f}). (Note that q is used as the start state in this TM as opposed to q 0.) 1/X 1/X 0/0 q 1 1/X q 01 0/0 2/2 1/1 1/1 q 12 q 012 2/2 r 1/X 1/X f z 1/X 1/X q 2 q 02 q 0 (b) The TM proceeds in a number of passes starting from state q with the tape head scanning the first non-blank symbol. The TM moves the tape head to the right during a pass until it replaces the first 0, first 1, and first 2 by an X. The states q, q 0, q 1, q 2, q 01, q 02, q 12, q 012 keep track of which symbols have been replaced by X during the pass. Once successfully replacing these three symbols by X the TM will be in state q 012 and there are two cases to consider. If the next symbol to the right is the blank, then the TM moves into state z. If the TM is in state z, then there must be no remaining copies of at least one of 0, 1, 2 on the tape. Thus, when the TM is in state z it checks to see if all of the symbols on the tape are X, and if so it moves to state f to. If the the next symbol to the right is not the blank, then it must be one of 0, 1, 2. The TM reads this symbol and moves into state r which proceeds to rewind the tape head to the beginning of the tape. Once the tape head is properly rewound, the TM moves into state q to begin the next pass. The TM does not a string if a pass ends without finding occurrences of 0, 1, and 2 (unless the initial contents of the tape was blank). 1

(c) The following IDs show that 201210 is ed. q201210 Xq 2 01210 XXq 02 1210 XXXq 012 210 XXrX210 XrXX210 rxxx210 rbxxx210 qxxx210 XqXX210 XXqX210 XXXq210 XXXXq 2 10 XXXXXq 12 0 XXXXXXq 012 B XXXXXzX XXXXzXX XXXzXXX XXzXXXX XzXXXXX zxxxxxx fxxxxxx halt (d) The following IDs show that 10102 is not ed. q10102 Xq 1 0102 XXq 01 102 XX1q 01 02 XX10q 01 2 XX10Xq 012 B XX10rX XX1r0X halt (2) (a) The binary representation of 11160850 is 101010100100110100010010. (b) The binary string w 11160850 = 01010100100110100010010. (c) The binary string w 11160850 does not encode a valid Turing machine, so the transition diagram appears below. q 1 (d) w 4 = 00 / L(M 11160850 ) because L(M 11160850 ) =. Note: The intended question was to start with the decimal value 44643402. (a) The binary representation of 44643402 is 10101010010011010001001010. (b) The binary string w 44643402 = 0101010010011010001001010. (c) The binary string 01010100100 encodes the transition δ(q 1, 0) = (q 1, 1, R) and the binary string 010001001010 encodes the transition δ(q 1, B) = (q 2, 0, L), and so the transition diagram appears below. 0/1 q B/0 1 q 2 (d) w 4 = 00 L(M 44643402 ) due to the following IDs since q 2 is the final state. q 1 00 1q 1 0 11q 1 B 1q 2 10 halt (3) (a) We define the ID so that a new symbol # / (Γ Q) appears to the left of the symbol that the second tape head is scanning. If the two tape heads are scanning the same cell, then we choose to write #q to the left of this cell where q Q is the current state. To formalize these conventions, suppose the area of interest on the tape is w 1 w 2... w n, the 2HTM is in state q, the first head is scanning w i and the second head is scanning w j. Now we consider the various cases. If i = j, then the ID is If i < j, then the ID is w 1 w 2... w i 1 #qw i w i+1... w n. w 1 w 2... w i 1 qw i w i+1... w j 1 #w j w j+1... w n. 2

If j < i, then the ID is w 1 w 2... w i 1 #w i w i+1... w j 1 qw j w j+1... w n. (b) When defining we must take into account the special cases when i = n (the region of interest will grow), j = 1 and Z = B (the region of interest will shrink), and i = j (we choose to have the second tape head write overtop of what the first tape head writes). The various cases appear below. If 1 < i < j < n, then w 1 w 2... w i 1 qw i w i+1... w j 1 #w j w j+1... w n w 1 w 2... w i 1 Y pw i+1 w i+2... w j 1 Z#w j+1 w j+2... w n. If 1 < i = j < n, then If 1 < j < i < n, then w 1 w 2... w i 1 #qw i w i+1... w n w 1 w 2... w i 1 Z#pw i+1 w i+2... w n. w 1 w 2... w i 1 #w i w i+1... w j 1 qw j w j+1... w n w 1 w 2... w i 1 Z#w i+1 w i+2... w j 1 Y pw j+1 w j+2... w n. If 1 < j < i = n, then w 1 w 2... w i 1 #w i w i+1... w n 1 qw n w 1 w 2... w i 1 Z#w i+1 w i+2... w n 1 Y pb. If 1 = j < i < n and Z = B, then #w 1 w 2... w j 1 qw j w j+1... w n #w 2... w j 1 w j 1 Y pw j+1 w j+2... w n. If 1 = j < i = n and Z = B, then #w 1 w 2... w n 1 qw n #w 2... w j 1 w n 1 Y pb. (c) Using our definition previous answers we can define the language of the 2HTM as L(M) = {w Σ #q 0 w αfβ where α, β {Γ {#}} and f F }. Notice that in our definition the initial ID is #q 0 w, which means we have chosen the two tape heads to start scanning the first cell in the input. (d) The language of binary palindromes L = {w {0, 1} w = w reverse } could be decided more efficiently using a 2HTM since the 2HTM could avoid scanning back-and-forth. More specifically, if w is a binary string and w = n, then a 2HTM could decide L in at approximately 2n steps. This could be done by having the second head move to the end of the tape, and then comparing the symbols at position i and n i + 1 on the tape for i = 1, 2,..., n. On the 2 other hand, a regular TM would require approximately n 2 steps. This is because it would take n i steps to compare the symbols at positions i and n i + 1 for i = 1, 2,..., n. (Additional states could be used to reduce some of this 2 work, but could not avoid the fact that the regular TM would have to scan back-and-forth.) 3

(4) Consider the following language where L d is the diagonalization language L = {x {0, 1} x = 1w and w L d } {x {0, 1} x = 0w and w / L d }. To understand L it is helpful to understand the role of the first bit in each string in the language. If the first bit is 1, then the remaining portion of the string must be in L d. On the other hand, if the first bit is 0, then the remaining portion of the string must not be in L d. Now we prove that L is not able. For the sake of contradiction, suppose L is able. Then there exists a Turing machine M such that L(M) = L. Consider the Turing machine M d that behaves as follows: Given input w it s if 1w is ed by M, and it does not if 1w is not ed by M. w 1w M not not M d It is clear that L(M d ) = L d. However, we know that L d is not able. Therefore, our initial assumption that L is able must not be true. The complement of L is L = ({x {0, 1} x = 0w and w L d } {x {0, 1} x = 1w and w / L d }) {ɛ}. Now we prove that L is not able. For the sake of contradiction, suppose L is able. Then there exists a Turing machine M such that L(M) = L. Consider the Turing machine M d that behaves as follows: Given input w it s if 0w is ed by M, and it does not if 0w is not ed by M. w 0w M not not M d It is clear that L(M d ) = L d. However, we know that L d is not able. Therefore, our initial assumption that L is able must not be true. (5) To illustrate the reductions used in the problem, we will refer to the following directed graph and use i = 1 and j = 3. v1 v4 v2 (a) If b {0, 1} can be expressed as b = g1110 i 10 j where g encodes a directed graph, then let f(b) = 0 j 10 i 11b. In other words, the function f simply adds an arc from v j to v i. If b cannot be expressed in this way, then let f(b) = b. For example, the result of applying f to the above example appears below. (In this example, there is no directed path from v 1 to v 3 in the original directed graph, so there is no directed cycle containing v 1 and v 3 in the directed graph below.) 4 v3

v1 v4 v2 Now we prove that b L p f(b) L c. If b L p, then there is a directed path from v i to v j in the directed graph encoded by g. This directed path together with the arc from v j to v i provides a directed cycle containing v i and v j in the directed graph encoded by 0 j 10 i 11g, and therefore f(b) = 0 j 10 i 11b L c. If b / L p, then there is no directed path from v i to v j in the directed graph encoded by g. Therefore, there is also no directed path from v i to v j in the directed graph encoded by 0 j 10 i 11g. Therefore, there is no directed cycle containing v i and v j in the directed graph encoded by 0 j 10 i 11g, and so f(b) = 0 j 10 i 11b / L c. (b) If b {0, 1} can be expressed as b = g1110 i 10 j where g encodes a directed graph G with n vertices, then let f(b) = g 1110 i 0 i+n, where g encodes a directed graph G defined as follows. Let G be obtained by making a second copy of G and relabelling each vertex v x by v x+n in the second copy. Also, add an arc from v j to its duplicate v j+n in the second copy. If b cannot be expressed in this way, then let f(b) = b. For example, the result of applying f to the above example appears below. (In this example, there is no directed cycle containing v 1 and v 3 in the original directed graph, so there is no directed path from v 1 to v 5 in the directed graph below.) v3 v1 v4 v5 v7 v2 v3 v6 v8 Now we prove that b L c f(b) L p. If b L c, then there is a directed cycle including v i and v j in the directed graph G. This directed cycle includes a directed path from v i to v j together with a directed path from v j to v i. Therefore, there is a directed path from v i to v j in G, and also a directed path from v j+n to v i+n in G. The first of these directed paths, followed by the arc from v j to v j+n, followed by the second of these directed paths collectively provide a directed path from v i to v i+n in G. Therefore, f(b) L p. If b / L c, then there is no directed cycle including v i and v j in the directed graph G. Therefore, there is either no directed path from v i to v j in G, or there is no directed path from v j to v i in G. If there is no directed path from v i to v j in G, then there is no directed path from v i to v j in G. Furthermore, since the only arc between the 5

two copies of G in G is from v j to v j+1, then there is no directed path from v i to v i+n in G. Therefore, f(b) / L c. If there is no directed path from v j to v i in G, then there is no directed path from v j+n to v i+n in G. Furthermore, since the only arc between the two copies of G in G is from v j to v j+1, then there is no directed path from v i to v i+n in G. Therefore, f(b) / L c. 6