Compsci 102: Introduction To Discrete Mathematics
Compsci 102: Introduction To Discrete Mathematics
says is false!
This lecture will change the way you think about computer programs Many questions which appear easy at first glance are impossible to solve in general.
Well only be taking a brief look at a vast landscape in logic and computer science theory.
Grading Script
The 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 kind of program could a student who hated his/her TA hand in?
Note: This probably isnt the best idea for how to do well on assignments.
Nasty Program
n:=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 the Riemann Hypothesis is false.
A TA nightmare: 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 cant be computed by an ideal computer is called Computability Theory or Recursion Theory.
Are all reals describable? Are all reals computable? We saw that computable describable, but do we also have describable computable?
NO NO
The grading function we just described is not computable! (Well see a proof soon.)
Computable Function
Fix 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 Function
Fix 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!
It follows from our conventions that P(P) means the output obtained when we run P on the text of its own source code.
HALT(P) = HALT(P) =
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) HALT(P) = = yes, if P(P) halts no, if P(P) does not halt
CONFUSE
CONFUSE(P) { if (HALT(P)) then loop forever; else exit; // text of HALT goes here }
CONFUSE
CONFUSE(P) { if (HALT(P)) then loop forever; else exit; // text of HALT goes here }
Suppose CONFUSE(CONFUSE) halts then HALT(CONFUSE) = TRUE CONFUSE will loop forever on input CONFUSE
Suppose CONFUSE(CONFUSE) does not halt CONTRADICTIO then HALT(CONFUSE) N = FALSE CONFUSE will halt on input CONFUSE
Turings argument is essentially the reincarnation of Cantors Diagonalization argument that we saw in the previous lecture.
All Programs (the input) P0 All Programs P0 P1 Pi Programs (computable functions) are countable, so we can put them in a (countably long) list P1 P2 Pj
All Programs (the input) P0 All Programs P0 P1 Pi YES, if Pi(Pj) halts No, otherwise P1 P2 Pj
CONFUSE(Pi) halts iff di = no (The CONFUSE function is the negation of the diagonal.) Hence CONFUSE cannot be on this list.
Consider the real number RK whose binary expansion has a 1 in the jth position iff PjK (i.e., if the jth program halts).
then use FRED to compute jth bit of RK return YES if (bit == 1), NO if (bit == 0)
We call a set S* decidable or recursive if there is a program P such that: P(x) = yes, if xS P(x) = no, if xS We already know: the halting set K is undecidable
Set S is decidable function fS is computable Sets are decidable (or undecidable), whereas functions are computable (or not)
YES/NO
4?
No
81?
Yes
Oracle for S
Oracle for K0
GIVEN:
But you can use this oracle for K0 to build an oracle for K.
K0= the set of programs that take no input and halt P = [input I; Q] Does P(P) halt?
Oracle for K
Oracle for K0
Weve reduced the problem of deciding membership in K to the problem of deciding membership in K0.
Hence, deciding membership for K0 must be at least as hard as deciding membership for K.
Oracle for K0
BUILD:
HELLO Oracle
GIVEN:
EQUAL = All <P,Q> such that P and Q have identical output behavior on all inputs
Is P in set HELLO?
HELLO Oracle
BUILD:
GIVEN:
Oracle
EQUAL
Halting with input, Halting without input, HELLO, and EQUAL are all undecidable.
Diophantine Equations
Does polynomial 4X2Y + XY2 + 1 = 0 have an integer root? I.e., does it have a zero at a point where all variables are integers?
D = {multivariate integer polynomials P | P has a root where all variables are integers}
http://www.goldenmuseum.com/1612Hilbert_engl.html
HALTING Oracle
BUILD:
Problems that have no obvious relation to halting, or even to computation can encode the Halting Problem is non-obvious ways.
PHILOSOPHICAL INTERLUDE
CHURCH-TURING THESIS
Any well-defined procedure that can be grasped and performed by the human mind and pencil/paper, can be performed on a conventional digital computer with no bound on memory.
The Church-Turing Thesis is NOT a theorem. It is a statement of belief concerning the universe we live in.
Your opinion will be influenced by your religious, scientific, and philosophical beliefs
mileage may vary
Empirical Intuition
No one has ever given a counterexample to the Church-Turing thesis. I.e., no one has given a concrete example of something humans compute in a consistent and well defined way, but that cant be programmed on a computer. The thesis is true.
Mechanical Intuition
The brain is a machine. The components of the machine obey fixed physical laws. In principle, an entire brain can be simulated step by step on a digital computer. Thus, any thoughts of such a brain can be computed by a simulating computer. The thesis is true.
Quantum Intuition
The brain is a machine, but not a classical one. It is inherently quantum mechanical in nature and does not reduce to simple particles in motion. Thus, there are inherent barriers to being simulated on a digital computer. The thesis is false. However, the thesis is true if we allow quantum computers.
There are many other viewpoints you might have concerning the Church-Turing Thesis. But this aint philosophy class!
Enumerating K
EnumerateK { for n = 0 to forever { for W = all strings of length < n do { if W(W) halts in n steps then output W; } } }
Now that we have established that the Halting Set is undecidable, we can use it for a jumping off points for more natural undecidability results.
Do these theorems about the limitations of computation tell us something about the limitations of human thought?
Thanks to John Lafferty for his slides from the Fall 2006 incarnation of 15251. They served as the basis for this lecture.