25
Slide 1 of Insert Unit Name Here Lecture L: Computability Unit L1: What is Computation?

Lecture L: Computability

  • Upload
    nolen

  • View
    23

  • Download
    0

Embed Size (px)

DESCRIPTION

Lecture L: Computability. Unit L1: What is Computation?. Physical Computation. f(x,0) = 1 f(x,y) = g(y,f(x,y-1)) g(z,0) = 0 g(z,w) = h(w,g(z,w-1)) h(r,0) = r h(r,s) = h(r,s-1)+1. public class PrintPrimes { public static void main(String[] args){ for(j = 2; j < 1000; j++) - PowerPoint PPT Presentation

Citation preview

Page 1: Lecture L: Computability

Slide 1 of No.Insert Unit Name Here

Lecture L: Computability

Unit L1: What is Computation?

Page 2: Lecture L: Computability

Slide 2 of No.Insert Unit Name Here

Physical Computation

Page 3: Lecture L: Computability

Slide 3 of No.Insert Unit Name Here

Mathematically defined computation

f(x,0) = 1f(x,y) = g(y,f(x,y-1))g(z,0) = 0g(z,w) = h(w,g(z,w-1))h(r,0) = rh(r,s) = 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; }}

Page 4: Lecture L: Computability

Slide 4 of No.Insert Unit Name Here

Turing Machines

0 1ab

z

0, R, b1, L, b 0, L, a

1, L, g

0, L, a1, R, x

a

b

ze

Page 5: Lecture L: Computability

Slide 5 of No.Insert Unit Name Here

Turing Machine for adding 1

a

b

0 1

1, _, b 0, L, a

1, _, b0, _, b

start

halt

Page 6: Lecture L: Computability

Slide 6 of No.Insert Unit Name Here

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){ … }

Page 7: Lecture L: Computability

Slide 7 of No.Insert Unit Name Here

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

Page 8: Lecture L: Computability

Slide 8 of No.Insert Unit Name Here

CTH: The Modern Version

Everything efficiently computable is computable efficiently by a randomized Turing machine “Efficiently”: in “polynomial time”. Running time is for

some constant c. “Randomized”: allow to “flip coins” – use randomization All “good enough” computers are equivalent -- even if you worry

about efficiency

)( cnO

Page 9: Lecture L: Computability

Slide 9 of No.Insert Unit Name Here

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

Page 10: Lecture L: Computability

Slide 10 of No.Insert Unit Name Here

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?

Page 11: Lecture L: Computability

Slide 11 of No.Insert Unit Name Here

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

Page 12: Lecture L: Computability

Slide 12 of No.Insert Unit Name Here

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

Page 13: Lecture L: Computability

Slide 13 of No.Insert Unit Name Here

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

Page 14: Lecture L: Computability

Slide 14 of No.Insert Unit Name Here

The Turing Test

Page 15: Lecture L: Computability

Slide 15 of No.Insert Unit Name Here

Lecture L: Computability

Unit L2: The limits of computation and mathematics

Page 16: Lecture L: Computability

Slide 16 of No.Insert Unit Name Here

The Halting problem

• 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)

/** * 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?}

Page 17: Lecture L: Computability

Slide 17 of No.Insert Unit Name Here

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;}

Page 18: Lecture L: Computability

Slide 18 of No.Insert Unit Name Here

The Halting problem cannot be solved

• 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.

String paradoxString = “class Test {\n” + “ static boolean paradox(String program){\n” + … “ static boolean halt(String program, String input){\n” + …Boolean answer = Test.paradox(paradoxString);

Page 19: Lecture L: Computability

Slide 19 of No.Insert Unit Name Here

Diophantine Equations

• Fact: It is possible to write compileToEquations above

• Theorem: There does not exist any program that can solve diophantine equations

• Proof: If there was, we could write the halt method.

02

...023

03

67

322

23

zwwz

zzwzx

xwzzyx

/** * 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) { … }

Page 20: Lecture L: Computability

Slide 20 of No.Insert Unit Name Here

Formal Proofs

Theorem: Proof: QED

Axiom

Follows from previous lines

Page 21: Lecture L: Computability

Slide 21 of No.Insert Unit Name Here

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

Page 22: Lecture L: Computability

Slide 22 of No.Insert Unit Name Here

Zermelo-Fraenkel Set Theory

• The basis of all mathematics (one possibility)

• 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

...)(

])([TzSzzTS

TSTzSzzTS

Page 23: Lecture L: Computability

Slide 23 of No.Insert Unit Name Here

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}

Page 24: Lecture L: Computability

Slide 24 of No.Insert Unit Name Here

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){ … }

Page 25: Lecture L: Computability

Slide 25 of No.Insert Unit Name Here

Godel’s incompleteness theoremstatic 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