Sub topic 12
Turing Reductions and Oracles
This chapter assumes you know many-one reductions, polynomial-time (Karp) reductions, and the Independent Set problem from earlier chapters. You should also be comfortable reading short Python functions.
Why many-one reductions are sometimes too strict
A many-one reduction from A to B transforms one instance of A into one instance of B and copies B's answer unchanged. Many natural ways of solving A with B break both rules. You might want to ask B several questions, choose the next question based on earlier answers, or flip the final answer. A Turing reduction permits all of these.
Oracles and the definition
An oracle for B is a black box that answers any question "is y in B?" in one step. A Turing reduction from A to B, written A ≤T B, is an algorithm that decides A while asking an oracle for B as many questions as it likes. It can post-process the answers in any way.
If the algorithm runs in polynomial time, apart from the oracle calls, the reduction is a polynomial-time Turing reduction, also called a Cook reduction. Every many-one reduction is a Turing reduction that makes exactly one call and returns the answer unchanged.
Two examples with an Independent Set oracle
The code below uses a brute-force function as the oracle so that it runs. Each reduction only calls the oracle and never looks inside it.
from itertools import combinations
def has_is(vertices, edges, k):
# Stand-in oracle: does the graph have an independent set of size k?
present = {frozenset(e) for e in edges}
return any(all(frozenset(p) not in present for p in combinations(s, 2))
for s in combinations(vertices, k))
def no_is_of_size(vertices, edges, k, oracle):
# Complement problem: one call, answer negated
return not oracle(vertices, edges, k)
def max_is_size(vertices, edges, oracle):
# Binary search: about log2(|V|) adaptive calls
lo, hi = 0, len(vertices)
while lo < hi:
mid = (lo + hi + 1) // 2
if oracle(vertices, edges, mid):
lo = mid
else:
hi = mid - 1
return lo
vertices = [1, 2, 3, 4]
edges = [(1, 2), (2, 3), (3, 4)]
assert max_is_size(vertices, edges, has_is) == 2
assert no_is_of_size(vertices, edges, 3, has_is)The first function negates the oracle's answer, which a many-one reduction is not allowed to do. The second asks a sequence of questions, and each question depends on the previous answer.
Choosing between the two
| Property | Many-one (≤m) | Turing (≤T) |
|---|---|---|
| Oracle calls | Exactly one | Any number, adaptive |
| Post-processing of the answer | None | Arbitrary |
| A ≤ co-A always holds | No | Yes |
| Preserves membership in NP, and recognizability | Yes | No |
| Typical use | NP-completeness, undecidability via recognizability | Search and optimization from decision problems |
Both kinds of reduction still transfer decidability in the same direction. If A ≤T B and B is decidable, then A is decidable. Equivalently, if A is undecidable, B is too.
Exercise
Let HALT be the halting problem and co-HALT its complement. Show that HALT ≤T co-HALT, and explain why HALT ≤m co-HALT is impossible.
Show answer
Turing reduction: given (M, w), ask the co-HALT oracle about (M, w) and return the opposite answer. This uses one call and one negation. For many-one: a mapping f with x in HALT iff f(x) in co-HALT would also give x in co-HALT iff f(x) in HALT. That means co-HALT ≤m HALT. HALT is recognizable, and recognizability transfers backward along many-one reductions, so co-HALT would be recognizable. A language that is recognizable and has a recognizable complement is decidable, so HALT would be decidable. That is a contradiction.
Exercise
How many oracle calls does maxissize make on a graph with n vertices, and why does that keep it a polynomial-time Turing reduction?
Show answer
It makes about ceil(log2(n + 1)) calls, one per halving of the range [0, n]. The work between calls takes constant time, so the total running time outside the oracle is O(log n). That is polynomial in the input size.