Saturday, November 22, 2014

Week 11: Halting proof is the best proof ever.

Have you ever wondered "Geez, why do we learn the halting problem? If we can't write it, we dont need to deal with it."
Hold up. By proving that halt f'n cannot be written, we can prove any problem's un-algorithm-ability  by reduction.

First why halting proof is awesome:

  • It was proved by someone who didn't know what computers were. (You : HOWWWW?)
    Well, they just defined what computers are (a machine that processes algorithms).
    Then they proceeded to say that some problems just can't be handled by algorithms.
  • This proof is for all computer languages. (Turing Complete means even the best language ever made, python, can't handle it.)

Now on reduction...

def somefunction(g, v):
    ’’’Now this function would be similar to "If not something, then return false."
    (function, str) -> bool
    ’’’
    # leave blank

def halt(f,i):
    def childfunction(y):
        f(i)               
        something    #eg) if we're checking for execution, just execute it; no need to return
                             #eg) if something is a value, then return it. 
        return somefunction(childfunction, x)

Explanation:
  • We're assuming that somefunction is programmable (for contradiction)
  • We're using somefunction to define halt.
  • We need childfunction to deal with two things: f, i & something.
  • In general, f(i) will halt or not halt. 
  • In the case that it does halt, then 'something' is executed.
    Well, if 'something' is executed, then somefunction returns true.
    If it isn't executed (because f(i) loops forever), then somefunction returns False.
  • We just made a halt out of somefunction. But halt is impossible! So then somefunction must not exists. If it does, then halt exists.

Reduction took some time for me to understand, but now that I do, it is pretty awesome. 
This is why I love logic. 
Best use of logic ever (for me anyway) in this course.

No comments:

Post a Comment