### Reductions

```Reductions
(Section 5.1)
Héctor Muñoz-Avila
Summary of Previous Lectures
• The Halting problem is undecidable:
– HALT = {<M,w> | M is a Turing machine, w  *, M halts on input w}
• The proof involved a paradox
Proving that Other Problems are
Undecidable
• We use the reductions method
– A is reduced into B (written: A ≤red B)
– Implies: deciding B is at least as hard as as deciding A
• This method requires that we know at least one problem
to be undecidable
• Reductions are also used to prove intractability
– E.g., NP-completeness
Intuition
• A ≤red B if I can use a decider for B (assuming one exists)
to construct a decider for A
• Implies: deciding B is at least as hard as as deciding A
Intuition
• A ≤red B if I can use a decider for B (assuming one exists)
to construct a decider for A
• Implies: deciding B is at least as hard as as deciding A
•
Example?
Intuition
• A ≤red B if I can use a decider for B (assuming one exists)
to construct a decider for A
• Implies: deciding B is at least as hard as as deciding A
• Example 1: when we use software libraries to solve a
problem A
Software library
SolutionA() {
solutionB1()
solutionB2()
solutionB3()
}
Intuition
• A ≤red B if I can use a decider for B (assuming one exists)
to construct a decider for A
• Implies: deciding B is at least as hard as as deciding A
• Example 1: when we use software libraries to solve a
problem A
Software library
SolutionA() {
…
solutionB2()
….
}
solutionB1()
solutionB2()
solutionB3()
Intuition
• A ≤red B if I can use a decider for B (assuming one exists)
to construct a decider for A
• Implies: deciding B is at least as hard as as deciding A
• Example 2: How to use a solution of B to solve A if:
– A = “find the largest number among an array of
integers array[1..n]”
– B = “find the smallest number among an array of
integers array[1..n]”
Intuition
• A ≤red B if I can use a decider for B (assuming one exists)
to construct a decider for A
• Implies: deciding B is at least as hard as as deciding A
• Example 3: How to use a solution of B to solve A if:
– A = “find if there is a zero in an array of integers
array[1..n]”
– B = “determine the product of all numbers in an array
of integers array[1..n]” (e.g., if array[…] contains 2, 3, 7
then the result will be 42.
Intuition
• A ≤red B if I can use a decider for B (assuming one exists)
to construct a decider for A
• Implies: deciding B is at least as hard as as deciding A
• Relations:
• Assume A is undecidable, is B undecidable?
• Assume A is decidable, is B decidable?
• Assume B is decidable, is A decidable?
• Assume B is undecidable, is A undecidable?
Intuition
• A ≤red B if I can use a decider for B (assuming one exists)
to construct a decider for A
• Implies: deciding B is at least as hard as as deciding A
If B is decidable
Then A is decidable
Intuition
• A ≤red B if I can use a decider for B (assuming one exists)
to construct a decider for A
• Implies: deciding B is at least as hard as as deciding A
If B is decidable
Then A is decidable
If A is undecidable
Then B is undecidable
• Given a program P, an input w for P, and a line of code i
in P, will P ever execute line I when running with input
w?
• Given a program P, an input w for P, and a line of code i
in P, will P ever execute line I when running with input
w?
P(w)
{
if (w == 1) then
println(“yes”)
else
printlin(“no”)
}
• Given a program P, an input w for P, and a line of code i
in P, will P ever execute line I when running with input
w?
P(w)
{
Foo()
if (w == 1) then
println(“yes”)
else
printlin(“no”)
}
Foo()
• We are going to show HALT ≤red DEAD-Code
• Lets construct a decider MH for HALT assuming a
decider MD for DEAD-Code is available
Example: Do-Nothing Problem
• Given a program P, will P reject every input w?
Example: Do-Nothing Problem
• Given a program P, will P reject every input w?
P(w)
{
return reject
}
Example: Do-Nothing Problem
• Given a program P, will P reject every input w?
P(w)
{
Foo()
return accept
}
Foo()
Example: Do-Nothing Problem
• We are going to show HALT ≤red Do-Nothing
• Hence, Do-Nothing is undecidable
• Lets construct a decider MH for HALT assuming a
decider MDN for Do-Nothing is available
Summary of the Previous
Lecture (I)
• A ≤red B if I can use a decider for B (assuming one exists)
to construct a decider for A
• Implies: deciding B is at least as hard as as deciding A
If B is decidable
Then A is decidable
If A is undecidable
Then B is undecidable
Summary of the Previous
Lecture (II)
• A ≤red B if I can use a decider for B (assuming one exists)
to construct a decider for A
• Implies: deciding B is at least as hard as as deciding A
•
We proved:
• HALT ≤red Do-Nothing
• Hence, DEAD-Code and Do-Nothing are undecidable
Observations
• HALT is recognizable
• We can easily proof this
• Is there a problem that is not recognizable?
Equivalence
• Given two programs P, P’ are they equivalent?
– For every input w, P(w) = P(w’)
– For example, if P and P’ return either true or false
then: For every input w, P(w) is true iff P(w’) is true
Equivalence
• Given two programs P, P’ are they equivalent?
– For every input w, P(w) = P’(w)
• The following 2 programs receive as input an array of
integers (a[1..n] in the left and A[0..MAXDIN] in the
right). Are they equivalent?
Equivalence
• Given two programs P, P’ are they equivalent?
– For every input w, P(w) = P(w’)
• So what you think is Equivalence decidable?
Equivalence
• Given two programs P, P’ are they equivalent?
– For every input w, P(w) = P(w’)
•
We can prove that HALT ≤red Equivalence
• Lets construct a decider MH for HALT assuming a
decider ME for Equivalence is available
• Hence, Equivalence is not decidable
• As it turns out Equivalence is not even recognizable
HALT ≤red Equivalence
MH :- on input <M,w>
Maux1 :- on input x
1. reject
Maux2 :- on input x
1. Run M on input w
2. reject
1. Run ME on <Maux1,Maux2>
2. if accept then accept
else reject
The AI Question
Héctor Muñoz-Avila
Informally
• Can we construct a machine that exhibits “human level”
intelligence?
We Certainly Have Come a
Long Way
• Many AI paradigms are constructed from our
understanding of how humans think
– E.g., case-based reasoning: recall past experiences
– Neural networks: simulate connectionism of brain
cells
Example of AI: The Case Base
Reasoning Cycle
Driving from
Allentown
Problem
to NYC?
Allentown to NYC?
New NYC)
(Allentown,
Case
(Allentown,
most of
the way to JC,
Learned
using byCase
pass highway,
NYC)
previous
Driving
Cases
cases
(Allentown,
Retrieved
(Allentown,
New
Jersey
CaseCity)
NYC)
Case
General
Jerry’s
Knowledge
(Allentown,
Tested/Repaired
most of the way to JC,
Case
using bypass highway,
NYC)
(Allentown,
Solved
Jersey
CaseCity,
NYC)
34
We Certainly Have seen
Impressive Examples of
Machine’s Capabilities
Impressive But…
• Could humans “solve” HALT?
– E.g., “Crowdsourcing”
• Humans have been able to solve problems
that are difficult for computers
And Now You Understand the
Limitations of Computation