Reducing Undecidable Problems: v7 and 2-halt - Prof. Michael R. Kowalczyk, Study notes of Algorithms and Programming

The concept of algorithm reductions and provides examples of reducing the undecidable halting problem to the v7 problem and the 2-halt problem. The v7 problem determines if a variable ever becomes 7 during program execution, while the 2-halt problem checks if two programs halt on the same input. How to create reductions using program transformations and proves their correctness.

Typology: Study notes

Pre 2010

Uploaded on 08/01/2009

koofers-user-a80
koofers-user-a80 🇺🇸

10 documents

1 / 2

Toggle sidebar

This page cannot be seen from the preview

Don't miss anything!

bg1
Algorithm Design and Analysis 4/8/2008
Lecture 33: More Reductions
Instructor: Mike Kowalczyk
1 Examples: Reducing from Halt to show that a problem is un-
decidable
1.1 Variable attains a certain value during program execution
Suppose we want to solve the problem of figuring out if the variable vever becomes 7 as program
Pruns on input i. Let’s call this the v7 problem. It turns out to be undecidable, meaning there
is no algorithm which returns the correct output for every input. A problem instance consists
of a pair (P, i), and the answer is “yes” if the program Phas a variable vand vbecomes 7 at
some point during execution on input i, and “no” otherwise. We would like to make a reduction
Halt mv7. This would show that v7 is undecidable. Remark: In our discussion of algorithms and
reductions here, we are assuming determinism (in particular, no randomness or nondeterministic
program forking).
reduceHaltToV7(Program P, input i) {
Define program P’’ =
"Same as P, except all instances of variable v are replaced by some unused variable."
Define program P’ =
"1) Run P’’ on i
2) v = 7"
return (P’, i);
}
Let’s prove that this is a reduction from the halting problem to the v7 problem. We need to show
that every instance of the halting problem is mapped to an instance of the v7 problem, and “yes”
and “no” instances of the halting problem map to “yes” and “no” instances of the v7 problem,
respectively. If (P, i) is an instance of the halting problem, that means Phalts on i. Then P00 also
halts on i. Thus, P0reaches line 2, and vgets set to 7 during P0execution on input i. In other
words, (P0, i) is a “yes” instance of the v7 problem. Now suppose that the input (P , i) is a “no”
instance of the halting problem. Then Pdoesn’t halt on input i. Then P00 doesn’t halt on input i
either, and P00 never sets vto 7 on input i(it doesn’t even use the variable at all). Thus, (P0, i)
is a “no” instance of the v7 problem, and our reduction is complete. Halt mv7. In particular,
since Halt is undecidable, we can also conclude that v7 is undecidable.
1.2 The 2-halt problem
Define the 2Halt problem as follows: “On input (P, Q, i), the output should be “yes” if programs
Pand Qboth halt on input i, and “no” otherwise.”. Let’s try writing a reduction from Halt to
show that 2Halt is undecidable.
1
pf2

Partial preview of the text

Download Reducing Undecidable Problems: v7 and 2-halt - Prof. Michael R. Kowalczyk and more Study notes Algorithms and Programming in PDF only on Docsity!

Algorithm Design and Analysis 4/8/

Lecture 33: More Reductions

Instructor: Mike Kowalczyk

1 Examples: Reducing from Halt to show that a problem is un-

decidable

1.1 Variable attains a certain value during program execution

Suppose we want to solve the problem of figuring out if the variable v ever becomes 7 as program P runs on input i. Let’s call this the v7 problem. It turns out to be undecidable, meaning there is no algorithm which returns the correct output for every input. A problem instance consists of a pair (P, i), and the answer is “yes” if the program P has a variable v and v becomes 7 at some point during execution on input i, and “no” otherwise. We would like to make a reduction Halt ≤m v7. This would show that v7 is undecidable. Remark: In our discussion of algorithms and reductions here, we are assuming determinism (in particular, no randomness or nondeterministic program forking).

reduceHaltToV7(Program P, input i) { Define program P’’ = "Same as P, except all instances of variable v are replaced by some unused variable."

Define program P’ = "1) Run P’’ on i

  1. v = 7"

return (P’, i); }

Let’s prove that this is a reduction from the halting problem to the v7 problem. We need to show that every instance of the halting problem is mapped to an instance of the v7 problem, and “yes” and “no” instances of the halting problem map to “yes” and “no” instances of the v7 problem, respectively. If (P, i) is an instance of the halting problem, that means P halts on i. Then P ′′^ also halts on i. Thus, P ′^ reaches line 2, and v gets set to 7 during P ′^ execution on input i. In other words, (P ′, i) is a “yes” instance of the v7 problem. Now suppose that the input (P, i) is a “no” instance of the halting problem. Then P doesn’t halt on input i. Then P ′′^ doesn’t halt on input i either, and P ′′^ never sets v to 7 on input i (it doesn’t even use the variable at all). Thus, (P ′, i) is a “no” instance of the v7 problem, and our reduction is complete. Halt ≤m v7. In particular, since Halt is undecidable, we can also conclude that v7 is undecidable.

1.2 The 2-halt problem

Define the 2Halt problem as follows: “On input (P, Q, i), the output should be “yes” if programs P and Q both halt on input i, and “no” otherwise.”. Let’s try writing a reduction from Halt to show that 2Halt is undecidable.

reduceHaltTo2Halt(Program P, input i) { return (P,P,i); }

Let’s prove correctness of the reduction. If (P, i) is a “yes” instance of Halt, then P halts on i and (P, P, i) is a “yes” instance of 2Halt because both input programs halt on input i (they’re both P ). If (P, i) is a “no” instance of Halt, then P doesn’t halt on i and therefore (P, P, i) is a “no” instance of 2Halt because neither input program halts on input i (again, they’re both P ). We conclude that Halt ≤m 2 Halt and since Halt is known to be undecidable, 2Halt is also undecidable.