CS30 - Spring 2016 - Class 25

Lecture notes

  • admin
       - assignment 11

  • Nim tournament!

  • halting problem
       - Could we write a Turing machine that simulates the running of another Turing machine?
          - take as input two things:
             1) some representation of the Turing machine
             2) some input to run on the Turing machine input (i.e. the input Turing machine from 1)
          - would then "run" the Turing machine it was simulating on the input
          - this is called a "universal Turing machine"
       - Consider a TM H that does the following:
          H(M,w) =
             - accept if M finishes (accepts or rejects) with input w
             - reject if M never finishes with input w, i.e. runs forever

          - this is called the halting problem
             - this program comes up a lot in CS
                - you run your program
                - it doesn't finish
                - will it or is it stuck in an infinite loop?
                   - for particular types of problems we can definitely answer this problem
                   - can we in general, though?

          - Could we ever write this Turing machine?

  • To prove that we *cannot* we'll do a proof by contradiction
       - We assume that we can, i.e. that we could construct H above
       - And show that this results in a contradiction, meaning it couldn't be the case

       - Let's construct the following Turing machine
          D(M) =
             Run H(M, [M]) where [M] is the string representation of M
             - if it accepts (i.e. H(M, [M]) will finish), then loop infinitely
             - if it rejects (i.e. H(M, [M] will loop forever), then stop

       - What happens when we run D(D)?
          - Run H(D, [D])
             - if it accepts, that implies that D(D) finishes
                - however, if H(D, [D]) accepts, then we know that D(D) loops infinitely
             - if it rejects, that implies that D(D) never finishes
                - however, if H(D, [D]) rejects, then we know that D(D) halts

       - We've reached a contradiction!
          - If H says D finishes, then it loops infinitely
          - If H says D loops, then it halts