CSCE 411 Lecture 35

From Notes
Jump to navigation Jump to search
Lecture Slides

« previous | Monday, November 19, 2012 | next »


Cardinality

Alternate Proof of Uncountability

Seeking a contradiction, assume f: is countable.

Enumerate these function f0, f1, etc.

Obtain contradiction by defining fd using "diagonalization" that should be in set, but is not equal to any fi's: Let fd(n)=fn(n)+1.


The Halting Problem

Consider a function halt:

  • input: code for program P and an input x for P
  • output: 1 if P terminates (halts) when executed on input x and 0 if P doesn't terminate (goes into an infinite loop) when executed on input x

By the way, a compiler is a program that takes as input the code for another program.

This problem would be the ultimate debugging tool of all time!, but... what if we give halt itself?

View halt as a function from to :

  • P and x can be represented in ASCII, which is a string of bits
  • Any string of bits can be interpreted as a natural number.

Suppose there is a program Phalt that computes halt.

Use Phalt as a subroutine in another program Pself:

  • input: code for any program P
  • constructs pair (P,P) and calls Phalt on (P,P)
  • returns same answer as Phalt.

Use Pself as subroutine in another program Pdiag:

  • input: code for any program P
  • call Pself on P
  • if Pself returns 1 (i.e. does not go into an infinite loop), then go into an infinite loop.
  • if Pself returns 0 (i.e. goes into an infinite loop), then output 0.

In effect, Pdiag does the opposite of what program P does on input P:

  • If P halts when executed on input P, then Pdiag goes into an infinite loop
  • If P does not halt when executed on input P, then Pdiag halts and outputs 0

What happens if Pdiag is given its own code as input? It should either halt or not halt.

  • If Pdiag halts when executed on input Pdiag, then Pdiag goes into an infinite loop.
  • If Pdiag doesn't halt when executed on input Pdiag, then Pdiag halts.

contradiction!

What went wrong? Our assumption that there is an algorithm to compute halt was incorrect.


Undecidability

Analog of uncomputable function is an undecidable set.

Theory of what can and can't be computed focuses on identifying strings:

  • algorithm is required to "decide" if a gived input string is in the set of interest
  • similar to deciding if the input to some NPC problem is a YES or NO instance

Formal language is set of strings, assuming some encoding.

  • Analogous to halt is set H of all strings that encode programs and an input X such that P halts when executed on X
  • No program can determine whether a string is in H or not


More reductions:

  • For NP-completeness, we were concerned with the time complexity of problems: reduction from P1 to P2 had to be in poly time
  • now concerned with computability of problems: reduction just has to be computable, no matter how slow it is.


Many-One Reduction

Similar to NPC reductions:

  • YES map to YES
  • NO map to NO
  • computable
  • notation: L1mL2 (think L2 is at least as hard to compute as L1