Insert Lesson Name

Lecture L: Computability
Unit L1: What is Computation?
Insert Unit Name Here
Slide 1 of No.
Physical Computation
Insert Unit Name Here
Slide 2 of No.
Mathematically defined computation
f(x,0)
f(x,y)
g(z,0)
g(z,w)
h(r,0)
h(r,s)
=
=
=
=
=
=
1
g(y,f(x,y-1))
0
h(w,g(z,w-1))
r
h(r,s-1)+1
public class PrintPrimes {
public static void
main(String[] args){
for(j = 2; j < 1000; j++)
if (isPrime(j))
System.out.println(j);
}
private static boolean
isPrime(int n) {
for(int j=2; j < n; j++)
if (n%j == 0)
return false;
return true;
}
}
Insert Unit Name Here
Slide 3 of No.
Turing Machines
a
b
0
1
a 0, R, b 1, L, g
b 1, L, b 0, L, a
e
z
z 1, R, x 0, L, a
Insert Unit Name Here
Slide 4 of No.
Turing Machine for adding 1
0
a
b
1, _, b
0, _, b
1
start
0, L, a
1, _, b
Insert Unit Name Here
halt
Slide 5 of No.
Universal Computers
• Theoretical version: there exists a single Universal Turing
Machine that can simulate all other Turing machines

The input will be a coding of another machine + an input to the
other machine
• Hardware version: stored program computer
• Software version: interpreter
/**
* Runs the first method in the Java class that is given in
* “program” on the parameter given in “input”. Returns
* the value returned by the method. The method must be
* static, accept a single String parameter, and return a
* String value.
*/
static String simulate(String program, String input){ … }
Insert Unit Name Here
Slide 6 of No.
The Church-Turing Hypothesis
Everything computable is computable by a Turing machine





Physical interpretation
Conceptual interpretation
Definition of Computation
Everything computable is computable by a Java program
All “good enough” computers are equivalent
Insert Unit Name Here
Slide 7 of No.
CTH: The Modern Version
Everything efficiently computable is computable efficiently by
a randomized Turing machine
c
 “Efficiently”: in “polynomial time”. Running time is O ( n ) for


some constant c.
“Randomized”: allow to “flip coins” – use randomization
All “good enough” computers are equivalent -- even if you worry
about efficiency
Insert Unit Name Here
Slide 8 of No.
CTH and Chaos
• The physical world is analog
• When we simulate it on a digital device we use a given
precision





Input and output are given in finite precision
How many bits of precision do we need?
How much can  error in the input affect the output?
Normally: a little
Chaotic systems: a lot
• When we simulate a digital device on an analog device we
can encode many bits in one analog signal


Limits to precision of analog systems: atoms, quantum effects
Hard to think of a physical signal of even 64 bits of precision
Insert Unit Name Here
Slide 9 of No.
CTH and Quantum Physics
• Only known challenge to the “modern” version of CTH
• We do not know how to simulate quantum mechanical
systems efficiently
• The quantum “probability amplitudes” are different from
normal probabilities
• Maybe “quantum computers” can efficiently do more than
normal randomized computers

Efficient “quantum algorithm” for factoring is known
• Can quantum computers be built?

Existing physics? New physical laws? Technology?
• Can quantum computers be simulated efficiently on a
randomized Turing machines?
Insert Unit Name Here
Slide 10 of No.
CTH and the Brain
• Is the brain just a computer?
• Metaphysics: The mind-body problem


Monism: everything is matter -- including humans
Dualism: there is more (“soul”, “mind”, “consciousness” …)
• Technical differences


Parallel, complicated, analog, …
Still equivalent to a Turing Machine
Insert Unit Name Here
Slide 11 of No.
The Brain vs. a Pentium
• There are 10^9 -- 10^10 neurons in the brain
• Each neuron receives input from 10^3 -- 10^4 synapses
• Each neuron can fire about 1 -- 10^2 times/sec
• Total computing power is 10^9 -- 10^16 ops/sec
• Pentium III computing power = 10^8 ops/sec
Insert Unit Name Here
Slide 12 of No.
AI
• Why can’t we program computers to do what humans
easily do?


Recognize faces
Understand human language
• Processing power?
• Software?

Scruffy vs. Neat debate
Insert Unit Name Here
Slide 13 of No.
The Turing Test
Insert Unit Name Here
Slide 14 of No.
Lecture L: Computability
Unit L2: The limits of computation and
mathematics
Insert Unit Name Here
Slide 15 of No.
The Halting problem
/**
* Return True if the program finishes
* running when given the input as its
* parameter. Return false if it gets into
* an infinite loop.
*/
static boolean halt(String program, String input){
// fill in – can you do it?
}
•
program must be a Java class. The method that is run is the first one
in the class and must be of the form
static boolean XXXX(String input)
Insert Unit Name Here
Slide 16 of No.
Diagonalization
static boolean autoHalt(String program){
return halt(program, program);
}
static boolean paradox(String program){
if autoHalt(program)
while(true)
; // do nothing
else
return true;
}
Insert Unit Name Here
Slide 17 of No.
The Halting problem cannot be solved
String paradoxString =
“class Test {\n” +
“ static boolean paradox(String program){\n” +
…
“ static boolean halt(String program, String input){\n” +
…
Boolean answer = Test.paradox(paradoxString);
• Will paradox halt when running on its own code?


Yes ==> autoHalt(paradoxString) returns true ==> No
No ==> autoHalt(paradoxString) returns false ==> Yes
• Contradiction. Hence the assumption that
halt(program, input) exists is wrong.
• Theorem: the halt method can not be written.
Insert Unit Name Here
Slide 18 of No.
Diophantine Equations
/**
* Produce a set of diophantine equations that have a
* solution if the given program halts on the given input.
*/
static String compileToEquations(String prog, String inp) {
…
}
•
Fact: It is possible to write
compileToEquations above
x y z  xwz  3  0
•
Theorem: There does not exist
any program that can solve
diophantine equations
Proof: If there was, we could
write the halt method.
x z  3w z  2 z  0
•
3
2
2 3
...
z w  zw  2  0
7
Insert Unit Name Here
2
6
Slide 19 of No.
Formal Proofs
Theorem:
Proof:
Axiom
Follows from
previous
lines
Insert Unit Name Here
dfiecnmOWD
dklmejd
inedejde
8hdl9jlS
DJWUIMDKOPP
dfiecnmOWD
QED
Slide 20 of No.
Axiomatic System
• A syntactic way to show semantic mathematical truths
• Axioms + Deduction rules (logic)
• Must be effective

trivial to determine if a proof is correct
• Must be sound

Anything you prove must be true
• Can it be complete?

Prove all true statements
Insert Unit Name Here
Slide 21 of No.
Zermelo-Fraenkel Set Theory
• The basis of all mathematics (one possibility)
ST [z ( z  S  z  T )  S  T ]
STz ( z  S  z  T )
...
• Effective
• Sound, we think
• Anything you prove in Math courses really uses ZFC
• The details are not important, yet we will prove:
• Theorem: ZFC is not complete
Insert Unit Name Here
Slide 22 of No.
Proof Checking
/**
* Checks whether the proof is a valid proof of the
* theorem using ZFC axioms.
*/
Static boolean isProof(String theorem, String proof){
… // check line by line
}
Insert Unit Name Here
Slide 23 of No.
Computation theory is part of mathematics
/**
* Returns a formal mathematical statement that says
* that the program halts on the given input
*/
static String formalHalt(String program, String input){
…
}
/**
* Returns a formal mathematical statement that says
* that the program does not halt on the given input
*/
static String formalNoHalt(String program, String input){
…
}
Insert Unit Name Here
Slide 24 of No.
Godel’s incompleteness theorem
static boolean halt(String program, String input){
String thmYes = formalHalt(program, input);
String thmNO = formalNoHalt(program, input);
StringEnumerator e = new AllStringsEnumeration();
while(true) {
String proof = e.getNext();
if isProof(thmYes, proof)
return true;
if isProof(thmNo, proof)
return false;
}
}
Theorem: ZFC is not complete
Insert Unit Name Here
Slide 25 of No.