Turing’s Legacy: The Limits Of Computation.Carnegie Mellon UniversityNovember 28, 2006Lecture 26CS 15-251 Fall 2006John LaffertyGreat Theoretical Ideas In Computer ScienceAnythingsays is false!The HELLO assignmentWrite a JAVA program to output the word “HELLO” on the screen and halt.Space and time are not an issue. The program is for an ideal computer. PASS for any working HELLO program, no partial credit.Grading ScriptThe grading script G must be able to take any Java program P and grade it.Pass, if P prints only the word G(P)= “HELLO” and halts.Fail, otherwise.How exactly might such a script work?What does this do?#include <stdio.h> main(t,_,a)char *a;{return!0<t?t<3?main(-79,-13,a+main(-87,1-_, main(-86,0,a+1)+a)):1,t<_?main(t+1,_,a):3,main(-94,-27+t,a)&&t==2?_<13? main(2,_+1,"%s %d %d\n"):9:16:t<0?t<-72?main(_,t, "@n'+,#'/*{}w+/w#cdnr/+,{}r/*de}+,/*{*+,/w{%+,/w#q#n+,/#{l,+,/n{n+,/+#n+,/#\ ;#q#n+,/+k#;*+,/'r :'d*'3,}{w+K w'K:'+}e#';dq#'l \q#'+d'K#!/+k#;q#'r}eKK#}w'r}eKK{nl]'/#;#q#n'){)#}w'){){nl]'/+#n';d}rw'i;# \ ){nl]!/n{n#'; r{#w'r nc{nl]'/#{l,+'K {rw' iK{;[{nl]'/w#q#n'wk nw' \iwk{KK{nl]!/w{%'l##w#' i; :{nl]'/*{q#'ld;r'}{nlwb!/*de}'c \ ;;{nl'-{}rw]'/+,}##'*}#nc,',#nw]'/+kd'+e}+;#'rdq#w! nr'/ ') }+}{rl#'{n' ')# \}'+}##(!!/") :t<-50?_==*a?putchar(31[a]):main(-65,_,a+1):main((*a=='/')+t,_,a+1) :0<t?main(2,2,"%s"):*a=='/'||main(0,main(-61,*a, "!ek;dc i@bK'(q)-[w]*%n+r3#l,{}:\nuwloca-O;m .vpbks,fxntdCeghiry"),a+1);}What kind of program could a student who hated his/her TA hand in?Nasty Programn:=0;while (n is not a counter-example to the Riemann Hypothesis) {n++;}print “Hello”;The nasty program is a PASS if and only if theRiemann Hypothesis is false.Despite the simplicity of the HELLO assignment, there is no program to correctly grade it! And we will prove this.The theory of what can and can’t be computed by an ideal computer is called Computability Theoryor Recursion Theory.Are all reals describable?Are all reals computable?We saw thatcomputable ⇒ describable, but do we also havedescribable ⇒ computable?NONOFrom Lecture 25:The “grading function” we just describedis not computable! (We’ll see a proof soon.)Infinite RAM ModelPlatonic Version:One memory location for each natural number 0, 1, 2, …Aristotelian Version:Whenever you run out of memory, the computer contacts the factory. A maintenance person is flown by helicopter and attaches 100 Gig of RAM and all programs resume their computations, as if they had never been interrupted.Computable FunctionFix any finite set of symbols, Σ. Fix any precise programming language, e.g., Java. A program is any finite string of characters that is syntactically valid.A function f : Σ*→Σ*is computable if there is a program P that when executed on an ideal computer, computes f. That is, for all strings x in Σ*, f(x) = P(x).Computable FunctionFix any finite set of symbols, Σ.Fix any precise programming language, e.g., Java. A program is any finite string of characters that is syntactically valid.A function f : Σ*→Σ*is computable if there is a program P that when executed on an ideal computer, computes f. That is, for all strings x in Σ*, f(x) = P(x).Hence: countably many computable functions!There are only countably many Java programs. Hence, there are only countably manycomputable functions.Uncountably many functionsThe functions f: Σ*→ {0,1} are in 1-1 onto correspondence with the subsets of Σ* (the powerset of Σ*).Subset S of Σ*⇔ Function fSx in S ⇔ fS(x) = 1x not in S ⇔ fS(x) = 0Uncountably many functionsThe functions f: Σ*→ {0,1} are in 1-1 onto correspondence with the subsets of Σ* (the powerset of Σ*).Hence, the set of all f: Σ*→ {0,1} has thesame size as the power set of Σ*. And since Σ*is countably infinite, its power set is uncountably infinite.Countably many computable functions.Uncountably manyfunctions from Σ*to {0,1}.Thus, most functions from Σ*to {0,1} are not computable.Can we explicitly describe an uncomputablefunction? Can we describe an interesting uncomputablefunction?Notation And ConventionsFix a single programming language (Java)When we write program P we are talking about the text of the source code for PP(x) means the output that arises from running program P on input x, assuming that P eventually halts.P(x) = ⊥ means P did not halt on xThe meaning of P(P)It follows from our conventions that P(P) means the output obtained when we run P on the text of its own source code.P(P) … So that’s what I look likeThe Halting Set KDefinition:K is the set of all programs P such that P(P) halts.K = { Java P | P(P) halts }The Halting ProblemIs there a program HALT such that:HALT(P) = yes, if P(P) haltsHALT(P) = no, if P(P) does not haltThe Halting ProblemK = {P | P(P) halts }Is there a program HALT such that:HALT(P) = yes, if P∈KHALT(P) = no, if P∉KHALT decides whether or not any given program is in K.THEOREM: There is no program to solve the halting problem(Alan Turing 1937)Suppose a program HALT existed that solved the halting problem.HALT(P) = yes, if P(P) haltsHALT(P) = no, if P(P) does not haltWe will call HALT as a subroutine in a new program called CONFUSE.CONFUSECONFUSE(P){ if (HALT(P)) then loop forever; //i.e., we dont haltelse exit; //i.e., we halt// text of HALT goes here}Does CONFUSE(CONFUSE) halt?CONFUSECONFUSE(P){ if (HALT(P)) then loop forever; //i.e., we dont haltelse exit; //i.e., we halt// text of HALT goes here }Suppose CONFUSE(CONFUSE) haltsthen HALT(CONFUSE) = TRUE⇒ CONFUSE will loop forever on input CONFUSESuppose CONFUSE(CONFUSE) does not haltthen HALT(CONFUSE) = FALSE⇒ CONFUSE will halt on input CONFUSECONTRADICTIONAlan Turing (1912-1954)Theorem: [1937]There is no program to solve the halting problemTuring’s argument is essentially the reincarnation of Cantor’s Diagonalization argumentthat we saw in the previous lecture.P2…P1…PjP1P0…Pi…P0All ProgramsAll Programs (the input)Programs (computable functions) are countable,so we can put them in a (countably long) listP2…P1…PjP1P0…Pi…P0YES, if Pi(Pj) haltsNo, otherwiseAll ProgramsAll Programs (the input)…P2di…d1P1…PjP1P0……Pi…d0P0CONFUSE(Pi) halts iff di= no(The CONFUSE function is the negation of the diagonal.)Hence CONFUSE cannot be on this list.Letdi= HALT(Pi) All ProgramsAll Programs (the input)Alan Turing (1912-1954)Theorem: [1937]There is no program to solve the halting problemIs
View Full Document