0% found this document useful (0 votes)
61 views

COMP 3803 - Assignment 4

This document provides instructions for Assignment 4 in COMP 3803. It is due on April 11th at 23:59 and must be submitted as a single PDF file with a specific naming convention. Late assignments will not be accepted. Students are encouraged to collaborate but must write their own solutions. The assignment contains 5 questions - the first asks for name and student number, and the next 3 questions involve constructing Turing machines with specific properties. The final 2 questions use Rice's Theorem to prove that certain languages are undecidable.

Uploaded by

Nizam CAN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
61 views

COMP 3803 - Assignment 4

This document provides instructions for Assignment 4 in COMP 3803. It is due on April 11th at 23:59 and must be submitted as a single PDF file with a specific naming convention. Late assignments will not be accepted. Students are encouraged to collaborate but must write their own solutions. The assignment contains 5 questions - the first asks for name and student number, and the next 3 questions involve constructing Turing machines with specific properties. The final 2 questions use Rice's Theorem to prove that certain languages are undecidable.

Uploaded by

Nizam CAN
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 3

COMP 3803 — Assignment 4

Due: Sunday April 11, 23:59.


Assignment Policy:
• Your assignment must be submitted as one single PDF file through cuLearn.

Use the following format to name your file:

LastName StudentId a4.pdf

• Late assignments will not be accepted. I will not reply to emails of the
type “my internet connection broke down at 23:57” or “my scanner stopped
working at 23:58”, or “my dog ate my laptop charger”.

• You are encouraged to collaborate on assignments, but at the level of discussion only.
When writing your solutions, you must do so in your own words.

• Past experience has shown conclusively that those who do not put adequate effort into
the assignments do not learn the material and have a probability near 1 of doing poorly
on the exams.

• When writing your solutions, you must follow the guidelines below.

– You must justify your answers.


– The answers should be concise, clear and neat.
– When presenting proofs, every step should be justified.

Question 1: Write your name and student number.

Question 2: Construct a Turing machine with one tape that gets as input an integer x ≥ 0
and returns as output the integer x + 1. Integers are represented in binary.
Start of the computation: The tape contains the binary representation of the input x.
The tape head is on the leftmost bit of x and the Turing machine is in the start state.
End of the computation: The tape contains the binary representation of the number
x + 1. The tape head is on the leftmost bit of x + 1 and the Turing machine is in the final
state.
The Turing machine in this question does not have an accept state or a reject state;
instead, it has a final state. As soon as this final state is entered, the Turing machine
terminates. At termination, the contents of the tape is the output of the Turing machine.

1
Start by explaining your algorithm in plain English, then mention the states that you are
going to use, then explain the meaning of these states, and finally give the list of instructions.

Question 3: Construct a Turing machine with three tapes that gets as input two integers
x ≥ 0 and y ≥ 0, and returns as output the number x + y. Integers are represented in binary.
Start of the computation: Tape 1 contains the binary representation of x, its head is
on the rightmost bit of x. Tape 2 contains the binary representation of y, its head is on
the rightmost bit of y. Tape 3 is empty (that is, it contains only ’s), its head is at an
arbitrary position. At the start, the Turing machine is in the start state.
End of the computation: Tapes 1 and 2 are empty, and tape 3 contains the binary
representation of the number x + y. The head of tape 3 is on the rightmost bit of x + y.
The Turing machine is in the final state.
The Turing machine in this question does not have an accept state or a reject state;
instead, it has a final state. As soon as this final state is entered, the Turing machine
terminates. At termination, the contents of tape 3 is the output of the Turing machine.
Start by explaining your algorithm in plain English, then mention the states that you are
going to use, then explain the meaning of these states, and finally give the list of instructions.

Question 4: In class, we have seen that the language

Halt = {hP, wi : P is a Java program that terminates on the binary input string w}

is undecidable.
A Java program P is called a Hello-World-program, if the following is true: When given
the empty string  as input, P can do whatever it wants, as long as it outputs the string Hello
World and terminates. (We do not care what P does when the input string is non-empty.)
Consider the language

HW = {hP i : P is a Hello-World-program}.

The questions below will lead you through a proof of the claim that the language HW is
undecidable.
(4.1) Consider a fixed Java program P and a fixed binary string w.
We write a new Java program JP w which takes as input an arbitrary binary string x. On
such an input x, the Java program JP w does the following:

Algorithm JP w (x):
run P on the input w;
print Hello World

• Argue that P terminates on input w if and only if hJP w i ∈ HW .

2
(4.2) The goal is to prove that the language HW is undecidable. We will prove this by
contradiction. Thus, we assume that H is a Java program that decides HW . Recall what
this means:
• If P is a Hello-World-program, then H, when given hP i as input, will terminate in the
accept state.
• If P is not a Hello-World-program, then H, when given hP i as input, will terminate
in the reject state.
We write a new Java program H 0 which takes as input the binary encoding hP, wi of an
arbitrary Java program P and an arbitrary binary string w. On such an input hP, wi, the
Java program H 0 does the following:

Algorithm H 0 (hP, wi):


construct the Java program JP w described above;
run H on the input hJP w i;
if H terminates in the accept state
then terminate in the accept state
else terminate in the reject state
endif

Argue that the following are true:


• For any input hP, wi, H 0 terminates.
• If P terminates on input w, then H 0 (when given hP, wi as input), terminates in the
accept state.
• If P does not terminate on input w, then H 0 (when given hP, wi as input), terminates
in the reject state.

(4.3) Now finish the proof by arguing that the language HW is undecidable.

Question 5: Consider the two languages

Empty = {hM i : M is a Turing machine for which L(M ) = ∅}

and
UselessState = {hM, qi: M is a Turing machine, q is a state of M ,
for every input string w, the computation of M on
input w never visits state q}.
(5.1) Use Rice’s Theorem to show that Empty is undecidable.
(5.2) Use (5.1) to show that UselessState is undecidable.

You might also like