Halting Problem - PowerPoint PPT Presentation

1 / 26
About This Presentation
Title:

Halting Problem

Description:

Definition. Design a program, H, that will do the following: ... I've claimed that the traveling salesperson problem is intractable. ... – PowerPoint PPT presentation

Number of Views:82
Avg rating:3.0/5.0
Slides: 27
Provided by: nathans78
Category:

less

Transcript and Presenter's Notes

Title: Halting Problem


1
Halting Problem
2
Background - Halting Problem
  • Common error Program goes into an infinite
    loop.
  • Wouldnt it be nice to have a tool that would
    warn us that our program has this bug?

3
Example
  • Infinite loop - we get into a loop but for some
    reason we never get out of it.

while x lt 3 x x - 1
4
Definition
  • Design a program, H, that will do the following
  • Take as its input a description of a program P.
    (in binary, say).
  • Halt eventually and answer "yes" if P will
    eventually halt, or halt and answer "no" if P
    will run forever.

5
Halting Problem
  • In other words,
  • Program H will always halt and give the correct
    answer no matter what program has been given as
    input.

H
P
Halts? Yes or No
6
Proving the Halting Problem
  • We want to prove that the halting problem is
    non-computable.
  • In other words, there is no algorithm that we can
    use to tell whether or not a program will halt.
  • We will use proof by contradiction.

7
Proof by Contradiction
  • Assume that what we want to prove is false.
  • Demonstrate that a logical contradiction results.
  • We can conclude that the the thing we were trying
    to prove must be true.
  • Example There is no largest integer.

8
Proof by Contradiction
  • Well assume that the Halting Problem CAN be
    computed.
  • Well develop another program that uses the
    Halting Problem function.
  • Well find ourselves caught in a paradox (the
    contradiction).
  • Well have proven that our original assumption is
    false.

9
Assume Halting Problem OK
  • Let H be a program (or sub-program) that
    determines whether a program will halt.

H
P
Halts? Yes or No
10
Lets Build Another Program
  • Let B be a program that uses H.
  • For any given program, B will call H and pass it
    the given program.


B
H
P
P
11
What does P do?
  • Now, B acts as follows
  • B takes a program as input and feeds the program
    to H as input.
  • If H answer yes, then B will enter an infinite
    loop and run forever.
  • If H answer no, then B will stop.

12
What does B do?
B

B loops
H
Yes
P
P
No
B Halts
13
What Can We Do With P?
  • Lets give B a copy of itself as its input.

B
B loops
H
Yes
B
B
No
B Halts
14
What if B Halts?
B
B loops
H
Yes
B
B
No
B Halts
15
What if B Loops Forever?
B
B loops
H
Yes
B
B
No
B Halts
16
The Paradox
  • If B is a program that halts when given itself as
    its input,
  • then, when given itself as input,
  • B will go into an infinite loop.
  • If B is a program that loops indefinitely when
    given itself as its input,
  • then , when given itself as input,
  • B will halt immediately.

17
What Went Wrong?
  • Theres nothing wrong with B.
  • The problem must be with the assumption that we
    could write H.

18
So, Proof by Contradiction
  • We assumed that the Halting Problem COULD be
    computed.
  • We developed another program that used the
    Halting Problem function.
  • We found ourselves caught in a paradox (the
    contradiction).
  • We proved that the Halting Problem is not
    computable.

19
Conclusions
  • Rices theorem says that Any nontrivial property
    of programs is undecidable.
  • Thus, we cant write programs to answer questions
    about programs.

20
Intractability
  • Ive claimed that the traveling salesperson
    problem is intractable.
  • The best algorithm weve seen so far is O(N!).
  • How can we know that there isnt a better
    algorithm? Maybe O(N)?
  • The short answer is that we cant.
  • There is a longer answer that leads us to
    conclude that TSP is very likely intractable

21
P and NP
  • P the set of problems that can be solved in
    polynomial time by a Turing machine.
  • NP the set of problems that can be solved in
    polynomial time by a non-deterministic Turing
    machine.
  • Non-deterministic Turing Machine????

22
Non-Deterministic Turing Machines
  • Easiest way to describe them is to say that they
    have the ability to instantly guess an answer,
    but they need to do the work of verifying that it
    is correct.
  • Example Traveling salesperson decision problem.
  • Deterministic TM.
  • Non-deterministic TM.

23
Whats the Difference?
  • Everyone who is anyone believes that P and NP are
    different sets.
  • In other words, there are some problems that can
    be solved in polynomial time using
    non-determinism, but cant be solved in
    polynomial time deterministically.

24
NP-Completeness
  • It has been proven that the problem SAT is
    NP-complete.
  • (The SAT problem is to determine whether or not a
    given boolean expression can ever be true.)
  • If we could solve SAT in polynomial time, then we
    could solve any other problem in NP in polynomial
    time. (No time for the proof of this.)
  • It is NP-complete At least as hard as every
    other problem in NP.

25
So What?
  • This means that it is very very likely that SAT
    does not have a polynomial time algorithm.
  • If it does, then PNP, which no one believes.
  • What does any of this have to do with TSP?

26
Reductions
  • We would like to show a polynomial time reduction
    from SAT to TSP.
  • This involves showing how to convert any instance
    of the SAT into an instance of the TSP problem
    that has the same solution.
  • This would mean that any solution to the TSP
    problem would immediately give us a solution to
    SAT.
  • We could conclude that the TSP solution is at
    least as hard as SAT, and by extension, at least
    has hard as every other problem in NP.

27
TSP
  • How do we reduce TSP to SAT?
  • It can be done, but it is beyond the scope of
    this lecture )
  • It turns out that many problems are NP-Complete.
Write a Comment
User Comments (0)
About PowerShow.com