Docsity

Undecidable Problems - Lecture Slides | CS 1120, Study notes of Computer Science

Toggle sidebar
bg1
1
David Evans
http://www.cs.virginia.edu/evans
CS150: Computer Science
University of Virginia
Computer Science
Class 25:
Undecidable
Problems
2
CS150 Fall 2005: Lecture 25: Undecidable Problems
Menu
• Review:
– Undecidability
– Halting Problem
• How do we prove a problem is
undecidable?
• What do we do when faced with an
undecidable problem?
3
CS150 Fall 2005: Lecture 25: Undecidable Problems
Problem Classes if P ≠NP:
Simulating
Universe:
O(n3)
Smileys
Find
Best:
Θ(n)
NP-Complete
P
Θ(n)
NP
3SAT
Decidable
Undecidable
find proof
halts?
4
CS150 Fall 2005: Lecture 25: Undecidable Problems
Halting Problem
Define a procedure halts? that takes a
procedure and an input evaluates to #t if
the procedure would terminate on that
input, and to #f if would not terminate.
(define (halts? procedure input) … )
5
CS150 Fall 2005: Lecture 25: Undecidable Problems
Informal Proof
(define (contradict-halts x)
(if (halts? contradict-halts null)
(loop-forever)
#t))
If contradict-halts halts, the if test is true and
it evaluates to (loop-forever) - it doesn’t halt!
If contradict-halts doesn’t halt, the if test if false,
and it evaluates to #t. It halts!
6
CS150 Fall 2005: Lecture 25: Undecidable Problems
Proof by Contradiction
1. Show
X
is nonsensical.
2. Show that if you have
A
and
B
you can
make
X
.
3. Show that you can make
A
.
4. Therefore,
B
must not exist.
X
= contradict-halts
A
= a Scheme interpreter that follows the evaluation rules
B
= halts?
pf3
pf4

Partial preview of the text

Download Undecidable Problems - Lecture Slides | CS 1120 and more Study notes Computer Science in PDF only on Docsity!

David Evans http://www.cs.virginia.edu/evans

CS150: Computer Science University of Virginia Computer Science

Class 25:

Undecidable

Problems

CS150 Fall 2005: Lecture 25: Undecidable Problems 2

Menu

  • Review:
    • Undecidability
    • Halting Problem
  • How do we prove a problem is undecidable?
  • What do we do when faced with an undecidable problem?

CS150 Fall 2005: Lecture 25: Undecidable Problems 3

Problem Classes if P ≠ NP:

Simulating Universe: O ( n^3 )

Smileys

Find Best: NP-Complete Θ( n )

P Θ( n )

NP

3SAT

Decidable

Undecidable

find proof

halts?

CS150 Fall 2005: Lecture 25: Undecidable Problems 4

Halting Problem

Define a procedure halts? that takes a procedure and an input evaluates to #t if the procedure would terminate on that input, and to #f if would not terminate.

(define (halts? procedure input) … )

CS150 Fall 2005: Lecture 25: Undecidable Problems 5

Informal Proof

(define (contradict-halts x) (if (halts? contradict-halts null) (loop-forever) #t))

If contradict-halts halts, the if test is true and it evaluates to (loop-forever) - it doesn’t halt!

If contradict-halts doesn’t halt, the if test if false, and it evaluates to #t. It halts!

CS150 Fall 2005: Lecture 25: Undecidable Problems 6

Proof by Contradiction

  1. Show X is nonsensical.
  2. Show that if you have A and B you can make X.
  3. Show that you can make A.
  4. Therefore, B must not exist.

X = contradict-halts A = a Scheme interpreter that follows the evaluation rules B = halts?

CS150 Fall 2005: Lecture 25: Undecidable Problems 7

“Evaluates to 3” Problem

Input: A procedure P and input I

Output: true if evaluating ( P I )

would result in 3; false otherwise.

Is “Evaluates to 3” decidable?

CS150 Fall 2005: Lecture 25: Undecidable Problems 8

Undecidability Proof

Suppose we could define evaluates-to-3? that decides it. Then we could define halts?:

(define (halts? P I)

(if (evaluates-to-3?

‘(begin (P I) 3))

#t

#f))

Since it evaluates to 3, we know (P I) must halt. The only way it could not evaluate to 3, is if (P I) doesn’t halt. (Note: assumes (P I) cannot produce an error.)

CS150 Fall 2005: Lecture 25: Undecidable Problems 9

Hello-World? Problem

Input: A procedure P and input I

Output: true if evaluating ( P I )

would print out “Hello World!”;

false otherwise.

Is Hello-World? decidable?

CS150 Fall 2005: Lecture 25: Undecidable Problems 10

Undecidability Proof

Suppose we could define hello-world? that decides it. Then we could define halts?:

(define (halts? P I)

(if (hello-world?

‘(begin ((remove-prints P) I)

(print “Hello World!”))

#t

#f))

CS150 Fall 2005: Lecture 25: Undecidable Problems 11

Proof by Contradiction

  1. Show X is nonsensical.
  2. Show that if you have A and B you can make X.
  3. Show that you can make A.
  4. Therefore, B must not exist. X = halts? A = a Scheme interpreter that follows the evaluation rules B = hello-world? CS150 Fall 2005: Lecture 25: Undecidable Problems 12

From Paul Graham’s “Undergraduation”: My friend Robert learned a lot by writing network software when he was an undergrad. One of his projects was to connect Harvard to the Arpanet; it had been one of the original nodes, but by 1984 the connection had died. Not only was this work not for a class, but because he spent all his time on it and neglected his studies, he was kicked out of school for a year. ... When Robert got kicked out of grad school for writing the Internet worm of 1988, I envied him enormously for finding a way out without the stigma of failure. ... It all evened out in the end, and now he’s a professor at MIT. But you’ll probably be happier if you don’t go to that extreme; it caused him a lot of worry at the time. 3 years of probation, 400 hours of community service, $10,000+ fine

CS150 Fall 2005: Lecture 25: Undecidable Problems 19

Proof Recap

  • If we had is-virus? we could define halts?
  • We know halts? is undecidable
  • Hence, we can’t have is-virus?
  • Thus, we know is-virus? is undecidable

CS150 Fall 2005: Lecture 25: Undecidable Problems 20

How convincing is our

Halting Problem proof?

(define (contradict-halts x) (if (halts? contradict-halts null) (loop-forever) #t)) If contradict-halts halts, the if test is true and it evaluates to (loop-forever) - it doesn’t halt! If contradict-halts doesn’t halt, the if test if false, and it evaluates to #t. It halts! This “proof” assumes Scheme exists and is consistent!

CS150 Fall 2005: Lecture 25: Undecidable Problems 21

Charge

  • Scheme is very complicated (requires more than 1 page to define): - Unlikely we could prove it is consistent
  • To have a convincing proof, we need a simpler programming model in which we can write contradict-halts: - Next week: Turing’s model