15-251 Great Theoretical Ideas in Computer Science about AWESOME Some Generating Functions Probability Infinity Computability With Alan! (not Turing) Mind-

Slides:



Advertisements
Similar presentations
COMPSCI 102 Introduction to Discrete Mathematics.
Advertisements

Lecture 3 Universal TM. Code of a DTM Consider a one-tape DTM M = (Q, Σ, Γ, δ, s). It can be encoded as follows: First, encode each state, each direction,
Lecture 19. Reduction: More Undecidable problems
CS 461 – Nov. 9 Chomsky hierarchy of language classes –Review –Let’s find a language outside the TM world! –Hints: languages and TM are countable, but.
The Recursion Theorem Sipser – pages Self replication Living things are machines Living things can self-reproduce Machines cannot self reproduce.
CSCI 4325 / 6339 Theory of Computation Zhixiang Chen Department of Computer Science University of Texas-Pan American.
1 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
1 Introduction to Computability Theory Lecture12: Reductions Prof. Amos Israeli.
1 Introduction to Computability Theory Lecture13: Mapping Reductions Prof. Amos Israeli.
Courtesy Costas Busch - RPI1 A Universal Turing Machine.
Great Theoretical Ideas in Computer Science.
CPSC 411, Fall 2008: Set 12 1 CPSC 411 Design and Analysis of Algorithms Set 12: Undecidability Prof. Jennifer Welch Fall 2008.
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata are like Turing Machines with a restriction: The working space of the tape is the space of the.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
Great Theoretical Ideas in Computer Science.
1 Uncountable Sets continued Theorem: Let be an infinite countable set. The powerset of is uncountable.
1 Lecture 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex.
CHAPTER 4 Decidability Contents Decidable Languages
1 Lecture 7 Halting Problem –Fundamental program behavior problem –A specific unsolvable problem –Diagonalization technique revisited Proof more complex.
Fall 2004COMP 3351 A Universal Turing Machine. Fall 2004COMP 3352 Turing Machines are “hardwired” they execute only one program A limitation of Turing.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 18 Instructor: Paul Beame.
January 28, 2015CS21 Lecture 101 CS21 Decidability and Tractability Lecture 10 January 28, 2015.
CS21 Decidability and Tractability
1 Introduction to Computability Theory Lecture11: The Halting Problem Prof. Amos Israeli.
Cantor’s Legacy: Infinity And Diagonalization Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 25Apr 13, 2004Carnegie.
Turing’s Legacy: The Limits Of Computation. Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 26April 20, 2003Carnegie.
MA/CSSE 474 Theory of Computation More Reduction Examples Non-SD Reductions.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
Great Theoretical Ideas in Computer Science for Some.
MA/CSSE 474 Theory of Computation Enumerability Reduction.
Halting Problem Introduction to Computing Science and Programming I.
A Universal Turing Machine
CSE 311 Foundations of Computing I Lecture 26 Computability: Turing machines, Undecidability of the Halting Problem Spring
CSE 311 Foundations of Computing I Lecture 29 Computability: Turing machines, Undecidability of the Halting Problem Autumn 2012 CSE 3111.
COMPSCI 102 Introduction to Discrete Mathematics.
Great Theoretical Ideas in Computer Science.
Great Theoretical Ideas in Computer Science.
CS 3813: Introduction to Formal Languages and Automata Chapter 12 Limits of Algorithmic Computation These class notes are based on material from our textbook,
1 Linear Bounded Automata LBAs. 2 Linear Bounded Automata (LBAs) are the same as Turing Machines with one difference: The input string tape space is the.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Great Theoretical Ideas in Computer Science.
CSE 311 Foundations of Computing I Lecture 28 Computability: Other Undecidable Problems Autumn 2011 CSE 3111.
Recursively Enumerable and Recursive Languages
Thales’ Legacy: What Is A Proof? Great Theoretical Ideas In Computer Science Steven RudichCS Spring 2004 Lecture 27April 22, 2004Carnegie Mellon.
Great Theoretical Ideas in Computer Science about AWESOME Some Generating Functions Probability.
Overview of the theory of computation Episode 3 0 Turing machines The traditional concepts of computability, decidability and recursive enumerability.
To Infinity And Beyond! CS Lecture 11 The Ideal Computer: no bound on amount of memory Whenever you run out of memory, the computer contacts the.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
The Church-Turing Thesis Chapter Are We Done? FSM  PDA  Turing machine Is this the end of the line? There are still problems we cannot solve:
1 A Universal Turing Machine. 2 Turing Machines are “hardwired” they execute only one program A limitation of Turing Machines: Real Computers are re-programmable.
Fall 2013 Lecture 27: Turing machines and decidability CSE 311: Foundations of Computing.
Turing’s Legacy: The Limits Of Computation. Great Theoretical Ideas In Computer Science Anupam GuptaCS Fall 2005 Lecture 26Nov 29, 2005Carnegie.
Great Theoretical Ideas In Computer Science
A Universal Turing Machine
Introduction to Computing Science and Programming I
Self-Reference And Undecidability
Discrete Mathematics for Computer Science
Great Theoretical Ideas in Computer Science
Turing’s Legacy: The Limits Of Computation.
CSE 311 Foundations of Computing I
Great Theoretical Ideas in Computer Science
CSCE 411 Design and Analysis of Algorithms
Turing’s Legacy: The Limits Of Computation.
Discrete Math for CS CMPSC 360 LECTURE 43 Last time: Variance
Formal Languages, Automata and Models of Computation
Great Theoretical Ideas in Computer Science
Introduction to Discrete Mathematics
CS21 Decidability and Tractability
Turing Machines Everything is an Integer
Presentation transcript:

Great Theoretical Ideas in Computer Science about AWESOME Some Generating Functions Probability Infinity Computability With Alan! (not Turing) Mind- blowing

What does this do? _(__,___,____){___/__ 1&&___%__<___/__?_( __,1+ ___,____+!(___/__%(___%__))):___<__*__ ?_(__,___+1,____):0;}main(){_(100,0,0);}

Turing’s Legacy: The Limits Of Computation Anything I say say 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

The HELLO assignment Write a Java program to output the words “HELLO WORLD” 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 Script How exactly might such a script work? The grading script G must be able to take any Java program P and grade it. G(P)= Pass, if P prints only the words “HELLO WORLD” and halts. Fail, otherwise.

What does this do? _(__,___,____){___/__ 1&&___%__<___/__?_( __,1+ ___,____+!(___/__%(___%__))):___<__*__ ?_(__,___+1,____):0;}main(){_(100,0,0);}

Nasty Program n:=0; while (n is not a counter-example to the Riemann Hypothesis) { n++; } print “Hello World”; 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 can’t be computed by an ideal computer is called Computability Theory or Recursion Theory.

From the last lecture: The “grading function” we just described is not computable! (We’ll see a proof soon.) Are all reals describable? Are all reals computable? NO We saw that computable  describable but do we also have describable  computable? This lecture will hopefully shed light on what is and isn't possible using a program.

But wait! Why are we reasoning about “programs”? Don't we need to use Turing Machines to be mathematically precise?

Not necessarily. Remember the Church-Turing Thesis: any reasonable (and sufficiently powerful) notion of a “program” is equivalent to a Turing Machine. It's okay to just reason about “algorithms”.

What's Allowed in an “Algorithm”? Anything that we can create using Turing Machines! Arithmetic operations Conditionals (if) Loops (while, for, do) Arrays, pointers Functions Integers, strings Some examples: As long as we use reasonable primitives like these, we are really reasoning about Turing Machines, so our statements have a formal backing.

Extending the Idea of a Program ProgramTuring Machine Source code  Description of states and transitions Print statement  Write to a special “output” area of the tape Return true/false  Accept/Reject All of the proofs in this lecture will be about programs. We are still being rigorous because of this equivalence.

Computable Function Hence: countably many computable functions! Fix a finite set of symbols, Σ A function f: Σ * → Σ * is computable if there is a program P that when executed on an ideal computer (one with infinite memory), computes f. That is, for all strings x in Σ *, f(x) = P(x).

There are only countably many programs. Hence, there are only countably many computable functions.

Uncountably Many Functions The functions f: Σ * → {0,1} are in 1-1 onto correspondence with the subsets of Σ * (the powerset of Σ * ). Subset S of Σ *  Function f S x in S  f S (x) = 1 x not in S  f S (x) = 0 Hence, the set of all f: Σ * → {0,1} has the same size as the power set of Σ *, which is uncountable.

Countably many computable functions. Uncountably many functions from Σ * to {0,1}. Thus, most functions from Σ * to {0,1} are not computable.

Decidable/Undecidable Sets A set (more precisely, a language) L ⊆  Σ * is said to be decidable (or recursive) if there exists a program P such that: P(x) = yes, if x ∈  L P(x) = no, if x ∉  L Notice that this is the Turing Machine equivalent of a regular language. The theory becomes nicer if we restrict “computation” to the task of deciding membership in a set.

Again, by giving a counting argument, we can say that there must be some undecidable set. The set of all languages is uncountable, but there can only be countably many decidable languages because there are only countably many programs.

Can we explicitly describe an undecidable set?

The Halting Problem

Notation And Conventions When we write P by itself, we are talking about the text of the source code for P. P(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 x

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

The Halting Set K Definition: K is the set of all programs P such that P(P) halts. K = { Program P | P(P) halts } The Halting Problem Is the Halting Set K decidable? In other words, is there a program HALT such that: HALT(P)= yes, if P(P) halts HALT(P)= no, if P(P) does not halt

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) halts HALT(P)= no, if P(P) does not halt We will call HALT as a subroutine in a new program called CONFUSE.

CONFUSE Does CONFUSE(CONFUSE) halt? CONFUSE(P) { if (HALT(P)) then loop forever;//i.e., we don't halt else exit;//i.e., we halt // text of HALT goes here }

CONFUSE CONFUSE(P) { if (HALT(P)) then loop forever;//i.e., we don't halt else exit;//i.e., we halt // text of HALT goes here } Suppose CONFUSE(CONFUSE) halts: then HALT(CONFUSE) = TRUE, so CONFUSE will loop forever on input CONFUSE Suppose CONFUSE(CONFUSE) does not halt then HALT(CONFUSE) = FALSE, so CONFUSE will halt on input CONFUSE CONTRADICTION

Alan Turing ( ) Theorem: [1937] There is no program to solve the halting problem

Turing’s argument is essentially the reincarnation of Cantor’s Diagonalization argument that we saw in the previous lecture.

P0P0 P1P1 P2P2 …PjPj … P0P0 P1P1 … PiPi … All Programs All Programs (the input) Programs (computable functions) are countable, so we can put them in a (countably long) list

P0P0 P1P1 P2P2 …PjPj … P0P0 P1P1 … PiPi … All Programs All Programs (the input) YES, if P i (P j ) halts No, otherwise

P0P0 P1P1 P2P2 …PjPj … P0P0 d0d0 P1P1 d1d1 … … PiPi didi … … All Programs All Programs (the input) Let d i = HALT(P i ) CONFUSE(P i ) halts iff d i = no (The CONFUSE function is the negation of the diagonal.) Hence CONFUSE cannot be on this list.

Is there a real number that can be described, but not computed?

Consider the real number R whose binary expansion has a 1 in the j th position iff the j th program halts on input itself.

Proof that R cannot be computed MYSTERY solves the halting problem! Suppose it is, and program FRED computes it. then consider the following program: MYSTERY(program text P) for j = 0 to forever do { if (P == P j ) then use FRED to compute j th bit of R return YES if (bit == 1), NO if (bit == 0) }

I'm still not satisfied by the CONFUSE argument that the Halting Problem is undecidable. Isn't there a simpler way to specifically show an undecidable problem?

There actually is a simpler proof, but showing it requires us to extend our understanding of what Turing Machines are capable of.

Reminder: What is a Turing Machine Capable of? Arithmetic operations Conditionals (if) Loops (while, for, do) Arrays, pointers Functions Integers, strings Some examples: But what about “obtain a copy of my own source code”? Is this allowed as pseudocode for an “algorithm”? Have we seen something like this before?

Yes, we have seen this before! The Auto-cannibal Maker assignment demonstrated that given a program (“Eat”), it is possible to construct a program (the “Auto- cannibal”) that behaves like Eat but is aware of its own source code.

The assignment was in C++/Java, but the construction is possible with Turing Machines as well. This result is known as the recursion theorem: when writing an algorithm, it is always possible for that algorithm to be aware of its own source code.

Using the recursion theorem, we can come up with a simpler example of an undecidable problem.

A Simpler Variant of the Halting Set Definition: K 0 is the set of all programs P that halt when given no input. K 0 = { Program P | P() halts } K 0 is much simpler than K!

K 0 is Undecidable Suppose there was some program HALT2 that decides K 0. Consider the following program: CONTRADICT() { Let s be the source code for CONTRADICT; if (HALT2(s)) then loop forever; else exit; // text of HALT2 goes here } CONTRADICT is able to directly turn around and contradict the statement from HALT2, so HALT2 cannot be correct in all cases, so K 0 is undecidable.

Recursively Enumerable Sets

Recursively Enumerable A set (more precisely, a language) L ⊆  Σ * is defined to be recursively enumerable (or semi-decidable) if there exists a program P such that: If x ∈  L, then P(x) halts and outputs “yes”. If x ∉  L, then either P(x) halts and outputs “no”, or P(x) does not halt. Does decidable imply recursively enumerable? Does recursively enumerable imply decidable? Yes! No!

Example: The Halting Set K Even though K is not decidable, it is easy to show that it is recursively enumerable. Here is a program P that demonstrates that fact: HALF_HALT(P) { run P(P); output “yes”; } HALF_HALT will always output “yes” if P(P) halts, and will never output “yes” if P(P) does not halt, which is all that needs to be true.

Why the Name “Enumerable”? A language L is recursively enumerable if and only if there is some program P that enumerates it. Such a program must output an infinite list of strings, where each string that is output belongs to L and each string in L eventually shows up at least once in the list.

How do we Enumerate the Halting Set? ENUM_HALT(P) { for each natural number i { For each program P of length  i { Run P(P) for i steps; If P(P) halted in that time, output it }

A Non-Example? Is there a simple set that is not recursively enumerable? Yes! The complement of the Halting Set cannot be recursively enumerable: K' = {Program P | P(P) does not halt}

HALT(P) { for each natural number i: { run HALF_HALT(P) for i steps; run HALF_NON_HALT(P) for i steps; if either one halts, we know the correct answer, so output it; } Proof: Suppose that there was a program HALF_NON_HALT that demonstrated that K' was recursively enumerable. K' is not Recursively Enumerable One of the two calls must eventually finish, so HALT decides K, even though K is undecidable! Contradiction!

In general, if a program is recursively enumerable and its complement is recursively enumerable, then that program must be decidable.

Computability Vocabulary Overview A set S is decidable if there is a program that returns “yes” on input x whenever x ∈ S and returns “no” on input x whenever x ∉ S. A set S is recursively enumerable if there is a program that returns “yes” on input x whenever x ∈ S. If x ∉ S, then the program may either return “no” or it may run forever. A function f is computable if there is a program P such that for all strings x, P(x) = f(x). A real number x is computable if there is a program P that outputs the digits of x in order, in such a way that every digit is eventually output.

Oracles and Reductions

Oracle for S Oracle For Set S Is x ∈  S? YES/NO

Example Oracle S = Odd Naturals Oracle for S 4? No 81? Yes

K 0 = the set of programs that take no input and halt GIVEN: Oracle for K 0 Hey, I ordered an oracle for the famous halting set K, but when I opened the package it was an oracle for the different set K 0. But you can use this oracle for K 0 to build an oracle for K.

GIVEN: Oracle for K 0 P = [input I; Q] Does P(P) halt? BUILD: Oracle for K Does [I:=P;Q] halt? K 0 = the set of programs that take no input and halt

We’ve reduced the problem of deciding membership in K to the problem of deciding membership in K 0. Hence, deciding membership for K 0 must be at least as hard as deciding membership for K.

Thus if K 0 were decidable then K would be as well. We already know K is not decidable, hence K 0 is not decidable.

HELLO = the set of programs that print hello and halt GIVEN: HELLO Oracle Does P halt? BUILD: Oracle for K 0 Let P’ be P with all print statements removed. (assume there are no side effects) Is [P’; print HELLO] a hello program?

Hence, the set HELLO is not decidable.

EQUAL = All such that P and Q have identical output behavior on all inputs GIVEN: EQUAL Oracle Is P in set HELLO? BUILD: HELLO Oracle Let HI = [print HELLO] Are P and HI equal?

Halting with input, Halting without input, HELLO, and EQUAL are all undecidable.

Here's What You Need to Know... Turing Machine/Program equivalence The Halting Problem: Definition, Proof of Undecidability The recursion theorem Recursively enumerable sets Oracles and Computability reductions