CSCI3390-Assignment 2 Solutions

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

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

CSCC63 Worksheet Turing Machines

Homework Assignment 6 Answers

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

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

CS4026 Formal Models of Computation

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

Introduction to Turing Machines. Reading: Chapters 8 & 9

Turing Machines. Lecture 8

Chapter 3: The Church-Turing Thesis

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

Most General computer?

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

Lecture Notes: The Halting Problem; Reductions

1 Showing Recognizability

The Church-Turing Thesis

V Honors Theory of Computation

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Homework. Turing Machines. Announcements. Plan for today. Now our picture looks like. Languages

Part I: Definitions and Properties

CSE 105 THEORY OF COMPUTATION

CSCI3390-Lecture 6: An Undecidable Problem

Computability Theory. CS215, Lecture 6,

Lecture 12: Mapping Reductions

The Turing machine model of computation

Decidability (What, stuff is unsolvable?)

Turing Machines Part II

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

Theory of Computation

CpSc 421 Homework 9 Solution

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

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

Notes for Comp 497 (Comp 454) Week 12 4/19/05. Today we look at some variations on machines we have already seen. Chapter 21

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

CPSC 421: Tutorial #1

TURING MAHINES

Boolean circuits. Lecture Definitions

Decidability: Church-Turing Thesis

1 Definition of a Turing machine

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

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

Turing machines and linear bounded automata

Turing Machines. 22c:135 Theory of Computation. Tape of a Turing Machine (TM) TM versus FA, PDA

Universal Turing Machine. Lecture 20

Decidability and Undecidability

Variants of Turing Machine (intro)

CS 21 Decidability and Tractability Winter Solution Set 3

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

1 Unrestricted Computation

Lecture 1: Course Overview and Turing machine complexity

Turing Machine Recap

SE 3310b Theoretical Foundations of Software Engineering. Turing Machines. Aleksander Essex

Turing Machines. Nicholas Geis. February 5, 2015

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

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

Turing Machines. Our most powerful model of a computer is the Turing Machine. This is an FA with an infinite tape for storage.

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

UNIT-VIII COMPUTABILITY THEORY

15-251: Great Theoretical Ideas in Computer Science Fall 2016 Lecture 6 September 15, Turing & the Uncomputable

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

Theory of Computation

CS 361 Meeting 26 11/10/17

Variations of the Turing Machine

Decidable Languages - relationship with other classes.

Chapter 7 Turing Machines

More About Turing Machines. Programming Tricks Restrictions Extensions Closure Properties

Automata Theory CS S-12 Turing Machine Modifications

The Power of One-State Turing Machines

CS21 Decidability and Tractability

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

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

SD & Turing Enumerable. Lecture 33: Reductions and Undecidability. Lexicographically Enumerable. SD & Turing Enumerable

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

Turing Machines Part III

1 Acceptance, Rejection, and I/O for Turing Machines

CS154 Final Examination

Introduction to Languages and Computation

Foundations of

Turing Machines, diagonalization, the halting problem, reducibility

CS154, Lecture 10: Rice s Theorem, Oracle Machines

Turing Machines. Fall The Chinese University of Hong Kong. CSCI 3130: Formal languages and automata theory

CS151 Complexity Theory. Lecture 1 April 3, 2017

Turing s Thesis. Fall Costas Busch - RPI!1

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

CpSc 421 Final Exam December 15, 2006

Further discussion of Turing machines

Theory of Computation (IX) Yijia Chen Fudan University

Theory of Computation

CSCE 551 Final Exam, Spring 2004 Answer Key

Undecibability. Hilbert's 10th Problem: Give an algorithm that given a polynomial decides if the polynomial has integer roots or not.

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

Lecture notes on Turing machines

Languages, regular languages, finite automata

Week 2: Defining Computation

Lecture 14: Recursive Languages

Undecidable Problems and Reducibility

Reducability. Sipser, pages

Theory of Computation - Module 4

Computational Models Lecture 8 1

Transcription:

CSCI3390-Assignment 2 Solutions due February 3, 2016 1 TMs for Deciding Languages Write the specification of a Turing machine recognizing one of the following three languages. Do one of these problems. Options (b) and (c) are meant to be challenging and will get you extra-credit points. Part (a) can be approached very similarly to the way we handled the design of Turing machines that reversed the input, or determined if the number of as and bs was the same. (a) {w#w : w {a, b} }. That is, the input alphabet is {a, b, #}, and the machine will accept a string if and only if it contains exactly one # and the portion before the # matches the portion after. Thus the machine should accept ab#ab but reject both ab#a and ab##ab#. (b) {ww : w {a, b} }. So the machine determines if the first half of the string matches the second half. This is harder, because you don t have a convenient marker to tell you where the middle is. (c) If v {0, 1}, then we denote by (v) 2 the integer represented by v in binary. So for example, (110) 2 and (0110) 2 are both equal to the integer 6. The language is {u#v : (u) 2 < (v) 2 }. In other words, the machine takes as input two integers encoded in binary and determines is the first is less than the second. Thus it should accept 0110#1000 but reject both 111#0110 and #1#0. Solution. I only did the first one (I look forward to seeing the solutions of those who rose to the challenge of (b) or (c)). The strategy is pretty simple, and should 1

Figure 1: Turing machine deciding the language in Problem 1(a) be reminiscent of our reversal machine: Start in the left half, cross off the first symbol that is either a or b, and remember it in the state. Move right past the #, then continue right to the first a or b. If it matches the remembered character, cross it off, go back to the start, and repeat. If it doesn t match, reject. If no a or b is found in the right half when the machine is searching for it, reject. If no a or b is found in the left half, and and a or b is found in the right half, reject. The remaining alternative is a scan that finds no occurrence of a or b in the left or right half, in which case the machine accepts. The specification file is posted on the website. The state-transition diagram is pictured in Figure 1. 2 The move-over machine The first step in simulating a two-tape machine by a one-tape machine is spreading out the original input string so that every second cell contains a blank. Here you are asked to show how this is done. Part (a) is a warmup, and if you solve both parts, you only need to submit your answer for (b). (a) Design a Turing machine that puts a blank between its first input symbol and 2

second input symbol. That is, if the machine is started with abba on its tape, it will halt with on the tape. a bba (b) Design a Turing machine that puts a blank between every pair of consecutive input symbols. So if it starts with abba on its tape, it will halt with on the tape. a b b a Solution. For (a), move right to the second input symbol. Halt if it s blank; if not, write a blank, remembering the erased input symbol in the state, and move right. Then repeatedly write the remembered symbol, and remember the overwritten symbol in the state, until you overwrite a blank. It s ok to halt here, but to get ready for the next part, go left to the blank, move right and halt. For (b), instead of halting in the last step, return to the initial state. We only have to change one symbol in the specification file from (a) to do this! The specifications are posted. The state diagrams are shown below. 3 One-way infinite tapes Many texts give a different definition of the basic Turing machine: Instead of having the tape extend infinitely in both directions, it is only infinite toward the right. Thus there is a leftmost cell. We need to specify what happens if a transition tells the reading head to move left if it is positioned on the leftmost cell. Crash the program? Stay where it is? We will adopt the second of these rules: the machine will continue to run, but the reading head will not change its position. The simulator program includes the option to run in one-way mode. The way you do this (with, say, the reverse.tm specification) is by typing 3

Figure 2: Turing machine deciding the language in Problem 2(a) 4

Figure 3: Turing machine deciding the language in Problem 2(b). Observe that it is identical to the preceding machine, apart from the loop back to the initial state. 5

Figure 4: Turing machine for reversal with a one-way infinite tape. runtm( reverse, 110,bidirectional=False) Try this out and make sure you understand the behavior you observe. Then modify the specification file reverse.tm (give it a new name) so that it reverses its input when run with these new rules. (HINT: You will have to somehow mark the leftmost cell of the tape.) Solution. The two-way version of this problem halts when, while it searches for letters a, b to copy, encounters the blank cell to the left of the start of the original input. We cannot do this with the one-way tape, so instead we use special symbols for the leftmost cell of the tape, writing a in place of a, b in place of 0, and Y in place of X when writing to this cell. Thus the machine stops when it reaches the initial Y during a leftward scan. The state-transition diagram is shown in Figure 4, and the specification file is posted on the website. An alternative solution is to shift the entire input rightward one cell, using the strategy from Problem 2(a), and then use the original version of the reversal machine. 6

4 *More on one-way infinite tapes Prove that every Turing-recognizable language is recognized by a TM with a oneway infinite tape. You will have to describe a simulation, much in the higherlevel spirit of our proof that a two-tape machine can be simulated by a one-tape machine. (However, the simulation is easier, and the time penalty is much less.) Solution. The problem is to show how to simulate a normal TM M by a one-way TM M. I saw four different methods (well, three-and-a-half, since the first two are very similar) for doing this described in your homework submissions. All of them are correct, although some of your descriptions lacked correct or sufficient detail. I ll describe the first method in some detail, along with pictures, and the others more briefly. This resembles the simulation method we used to simulate two-tape machines by 1-tape machines. We first alter the initial configuration of the tape with the move-over method (see Problem 2). As the simulation progresses, the symbols to the left of the initial head position are recorded in reversed order on alternate cells of the tape. Note that that leftmost cell of the right half, and the rightmost cell of the left half are marked. We have to alter the states somewhat essentially, each state of the original machine splits into two copies, one for when it is scanning a cell on the left half of the tape, one for the right half. (This can also be accomplished with additional markings on the tape symbols.) A transition of the form δ(p, β) = (q, γ, R) of the original machine gives rise to several transitions of the new machine: If we are dealing with the right copy of the state p, the machine will write γ, transition to the right copy of q, and move two cells to the right. For the left copy of p, the rightward transition induces motion two cells to the left. Something special has to happen when the reading head in the original machine moves from the left half to the right half, or vice-versa. In this case, a rightward transition of the original machine δ(p, β) = (q, γ, R) also gives rise to a transition using the marked symbols δ(p left, β ) = (q right, γ, L). 7

Figure 5: Simulation of a Turing machine with a two-way infinite tape by a machine with a one-way tape. The top diagram shows the initial preparation: the initial position and all the cells to the right are copied to alternating cells of the one-way tape, and the two leftmost cells are marked. The bottom figure shows a snapshot during the simulation. Cells to the left of the initial position of the twoway machine appear in reversed order in alternate cells of the one-way machine. If the two-way machine is about to move one cell to the right from the illustrated configuration, the one-way machine will move two cells to the left. 8

A variant of this interleaving method is to use a larger tape alphabet in which each tape cell of the one-tape machine contains a pair of symbols from the original machine. A very similar strategy is to split the two halves again and use a one-way two-tape machine.. A rightward transition of the original machine induces a rightward transition on the first tape, and a leftward transition on the second. We can then simulate the one-way two-tape machine by a one-way onetape machine, just as we did in class with two bidirectional tapes. So the simulation here is a two-step process. (This also incurs a large time penalty in the second simulation of the two-tape machine by a one-tape machine.) The final method is to mark the left end of the tape, as usual. Whenever the original machine calls for a leftward transition off the leftmost cell, the new machine first shifts its entire tape contents one cell to the right, and then executes the transition. In so doing, we need to be sure that the symbol in the leftmost cell is always marked, and the in the other cells unmarked. We saw in 2(a) how to do the rightward shift. This method also incurs a large time penalty. 5 Hilbert s Tenth Problem When we started the class, I mentioned the decision problem Hilbert s Tenth Problem: Given a multivariable polynomial with integer coefficients, something like x 2 y 13x 3 y 4 + 27, determine whether there are integer values of x and y that make the polynomial evaluate to 0. The solution to Hilbert s problem is that this problem is undecidable. In terms of our formal definition, we can obviously encode polynomials as strings the one above might be encoded as x x y - 1 3 x x x y y y y +2 7. The question then becomes whether the set of encodings of polynomials that have integer roots is a decidable language. The answer is no. (This is a very difficult problem that took mathematicians many years to solve.) Prove that it is a Turing-recognizable language. You should give a very highlevel argument so you don t need to talk about Turing machines at all. Just 9

describe a procedure that will correctly answer yes for exactly the polynomials that have integer roots. (This is actually an easy problem with practically no technical detail, intended to make sure that you understand the underlying concept of the difference between decidable and Turing-recognizable.) Solution. If the polynomial has m variables, we substitute each m-tuple of integers (i 1, i 2,..., i m ) for the variables in the polynomial. If the result is zero, the algorithm says Yes. This solution requires that we have some algorithm for generating the sequence of all m-tupes. Here is one such method: For each i = 0, 1, 2,..., list all triples (there are only finitely many) such that the sum of the absolute values of the components is equal to i. With m = 3 this gives: i = 0 : (0, 0, 0). i = 1 : (±1, 0, 0), (0, ±1, 0), (0, 0, ±1). i = 2 : (±2, 0, 0), (±1, ±1, 0), (±1, 0, ±1), (0, ±2, 0), (0, ±1, ±1, ), (0, 0, ±2), etc. Thus if the polynomial has a root, this algorithm will find it and answer yes. If the polynomial has no root, the algorithm runs forever. Note that it is crucial to be able to enumerate the triples in such a manner that we will never skip one. It is incorrect to say that you are testing the possible solutions in the order (0, 0, 0), (1, 0, 0), (2, 0, 0), and so on, because you will never reach (0, 1, 0) this way. It is not quite enough to say test all possible triples of integers, or even the set of triples of integers is countable, so they can be enumerated. That s on the right track, but there has to be an algorithm that will systematically produce such a list of triples. 10