Computability and Undecidability

Slides:



Advertisements
Similar presentations
Countability. The cardinality of the set A is equal to the cardinality of a set B if there exists a bijection from A to B cardinality? bijection? injection.
Advertisements

Data Structures and Functional Programming Computability Ramin Zabih Cornell University Fall 2012.
1 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]
Computability and Complexity 4-1 Existence of Undecidable Problems Computability and Complexity Andrei Bulatov.
Introduction to Computability Theory
The Halting Problem Sipser 4.2 (pages ). CS 311 Mount Holyoke College 2 Taking stock All languages Turing-recognizable Turing-decidable Context-free.
The Halting Problem Sipser 4.2 (pages ).
CSCI 2670 Introduction to Theory of Computing October 19, 2005.
Courtesy Costas Busch - RPI1 A Universal Turing Machine.
Great Theoretical Ideas in Computer Science.
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]
Decidable and undecidable problems deciding regular languages and CFL’s Undecidable problems.
Functions f( ) = A B Lecture 15: Nov 4.
CHAPTER 4 Decidability Contents Decidable Languages
Fall 2004COMP 3351 A Universal Turing Machine. Fall 2004COMP 3352 Turing Machines are “hardwired” they execute only one program A limitation of Turing.
CS 310 – Fall 2006 Pacific University CS310 The Halting Problem Section 4.2 November 15, 2006.
1 CSE 417: Algorithms and Computational Complexity Winter 2001 Lecture 18 Instructor: Paul Beame.
Lecture 27UofH - COSC Dr. Verma 1 COSC 3340: Introduction to Theory of Computation University of Houston Dr. Verma Lecture 27.
1 Introduction to Computability Theory Lecture11: The Halting Problem Prof. Amos Israeli.
1 Reducibility. 2 Problem is reduced to problem If we can solve problem then we can solve problem.
Cardinality of Sets Section 2.5.
The Halting Problem – Undecidable Languages Lecture 31 Section 4.2 Wed, Oct 31, 2007.
1 Undecidability Reading: Chapter 8 & 9. 2 Decidability vs. Undecidability There are two types of TMs (based on halting): (Recursive) TMs that always.
Undecidable Languages (Chapter 4.2) Héctor Muñoz-Avila.
1 1 CDT314 FABER Formal Languages, Automata and Models of Computation Lecture 15-1 Mälardalen University 2012.
A Universal Turing Machine
Relations, Functions, and Countability
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.
CS 208: Computing Theory Assoc. Prof. Dr. Brahim Hnich Faculty of Computer Sciences Izmir University of Economics.
Cardinality with Applications to Computability Lecture 33 Section 7.5 Wed, Apr 12, 2006.
1 Turing’s Thesis. 2 Turing’s thesis: Any computation carried out by mechanical means can be performed by a Turing Machine (1930)
Computability Universal Turing Machine. Countability. Halting Problem. Homework: Show that the integers have the same cardinality (size) as the natural.
CSE 311 Foundations of Computing I Lecture 25 Pattern Matching, Cardinality, Computability Spring
CSE 311: Foundations of Computing Fall 2013 Lecture 26: Pattern matching, cardinality.
CSE 311: Foundations of Computing Fall 2014 Lecture 27: Cardinality.
1 Undecidability Andreas Klappenecker [based on slides by Prof. Welch]
Section 2.5. Cardinality Definition: A set that is either finite or has the same cardinality as the set of positive integers (Z + ) is called countable.
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.
Cardinality with Applications to Computability
CSCI 2670 Introduction to Theory of Computing
The Acceptance Problem for TMs
Discrete Mathematics CS 2610
A Universal Turing Machine
CS 461 – Nov. 2 Sets Prepare for ATM finite vs. infinite Infinite sets
CIS Automata and Formal Languages – Pei Wang
Recursively Enumerable and Recursive Languages
This statement is false.
CSCI 2670 Introduction to Theory of Computing
CSE 311 Foundations of Computing I
Lecture12 The Halting Problem
CSCI 2670 Introduction to Theory of Computing
2.4 Sequences and Summations
BCS 2143 Theory of Computer Science
Cardinality of Sets Section 2.5.
Finite and Infinite Sets
Busch Complexity Lectures: Undecidable Problems (unsolvable problems)
Decidable Languages Costas Busch - LSU.
Discrete Math for CS CMPSC 360 LECTURE 43 Last time: Variance
Formal Languages, Automata and Models of Computation
Intro to Theory of Computation
CS21 Decidability and Tractability
Cardinality Definition: The cardinality of a set A is equal to the cardinality of a set B, denoted |A| = |B|, if and only if there is a one-to-one correspondence.
CSCI 2670 Introduction to Theory of Computing
Cpt S 317: Spring 2009 Reading: Chapter 8 & 9
Instructor: Aaron Roth
Intro to Theory of Computation
CIS Automata and Formal Languages – Pei Wang
Presentation transcript:

Computability and Undecidability We have seen lots of things computers can do. Q. Is there anything they cannot do?

Computability and Undecidability We have seen lots of things computers can do. Q. Is there anything they cannot do? A. Yes—almost everything.

Today we'll see some things that cannot be computed. And prove that they cannot be computed, no matter what program, what language, what machine, how long you wait, anything.

Why? 1. Too many functions, so few programs... 2. There are many interesting functions that cannot be computed, e.g. various compiler optimizations.

Why? 1. Too many functions, so few programs... Orders of infinity [Cantor 1890] 2. There are many interesting functions that cannot be computed, e.g. various compiler optimizations.

Why? 1. Too many functions, so few programs... Orders of infinity [Cantor 1890] 2. There are many interesting functions that cannot be computed, e.g. various compiler optimizations. Undecidability of the halting problem [Turing 1936] Godel's incompleteness theorem [Godel 1936]

Plan 1. Show there are countably many programs. This means we can pair them up in a one-to-one fashion with the natural numbers N = {0,1,2,...}. 2. Show there are uncountably many functions. It's impossible to pair them up with the elements of N. 3. There must be some function that isn't programmable. 4. An interesting one—the halting problem.

Example {0,1,2} is the same size as {2,4,6}: Definition [Cantor, 1890] Two sets are the same size if there is an exact one-to-one pairing between them. Example {0,1,2} is the same size as {2,4,6}: 0  2 1  4 2  6 Definition A set is countable if it is the same size as N = {0,1,2,…}.

Examples of countable sets 2N = {0,2,4,6,…} Z = {…,-3,-2,-1,0,1,2,3,…} 0  0 0  0 1  2 1  -1 2  4 2  1 3  6 3  -2 4  8 4  2 5  10 5  -3 6  12 6  3 7  14 7  -4 … … n  2n 2n  n … 2n+1  -1-n …

Rationals 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 2/5 ... 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . .

Rationals 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 2/5 ... 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . .

Rationals 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 2/5 ... 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . .

Rationals 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 2/5 ... 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . .

Rationals 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 2/5 ... 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . .

Rationals 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 2/5 ... 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . .

Rationals 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 2/5 ... 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . .

Rationals 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 2/5 ... 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . .

Rationals 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 2/5 ... 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . .

Rationals 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 2/5 ... 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . .

Rationals 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 2/5 ... 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . . 0 1 2

Rationals 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 2/5 ... 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . . 0 1 3 2 4

Rationals 1/1 1/2 1/3 1/4 1/5 ... 2/1 2/2 2/3 2/4 2/5 ... 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . . 0 1 3 5 2 6 4 7 8

Rationals 1/1 1/2 1/3 1/4 1/5 .. 2/1 2/2 2/3 2/4 2/5 ... 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . . 0 1 3 5 9 2 6 4 7 8 10

Rationals 1/1 1/2 1/3 1/4 1/5 .. 2/1 2/2 2/3 2/4 2/5 .. 3/1 3/2 3/3 3/4 3/5 ... 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . . 0 1 3 5 9 2 6 12 4 7 13 8 14 10 15

Rationals 1/1 1/2 1/3 1/4 1/5 .. 2/1 2/2 2/3 2/4 2/5 .. 3/1 3/2 3/3 3/4 3/5 .. 4/1 4/2 4/3 4/4 4/5 ... 5/1 5/2 5/3 5/4 5/5 ... . . . . . 0 1 3 5 9 2 6 12 4 7 13 18 8 14 10 15 19

There are countably many Dylan programs every Dylan program is a finite string of characters number them lexicographically 0  (empty string) strings of length 0 1  a strings of length 1 2  b . … . 26  z . 27  aa strings of length 2 28  ab . 29  ac . 702  zz . 703  aaa strings of length 3 704  aab .

But there are uncountably many functions! There are even uncountably many Boolean valued functions of one argument f:N  {#t,#f} All the following sets are the same size, and all uncountable: Boolean valued functions of one argument infinite binary strings, e.g. 01101001010010... real numbers in the interval [0,1] paths in the infinite complete binary tree subsets of N

Consider the set of all Boolean valued functions of one argument f:N  {#t,#f}. Let's show this set is not countable. Any such function f can be thought of as a row in an infinite table, where we list in column n the value of the function on input n: n = 0 1 2 3 4 5 6 7 8 9 ... odd? #f #t #f #t #f #t #f #t #f #t ... prime? #f #f #t #t #f #t #f #t #f #f ... even? #t #f #t #f #t #f #t #f #t #f ... =4? #f #f #f #f #t #f #f #f #f #f ... ...

0 1 2 3 4 5 6 7 8 9 ... S0 #f #t #f #t #f #t #f #t #f #t ... S1 #f #f #t #t #f #t #f #t #f #f ... S2 #t #f #t #f #t #f #t #f #t #f ... S3 #f #f #f #f #t #f #f #f #f #f ... S4 #f #t #f #f #t #t #t #f #f #t ... .

0 1 2 3 4 5 6 7 8 9 ... S0 #f #t #f #t #f #t #f #t #f #t ... S1 #f #f #t #t #f #t #f #t #f #f ... S2 #t #f #t #f #t #f #t #f #t #f ... S3 #f #f #f #f #t #f #f #f #f #f ... S4 #f #t #f #f #t #t #t #f #f #t ... . . . . . .

0 1 2 3 4 5 6 7 8 9 ... S0 #f #t #f #t #f #t #f #t #f #t ... S1 #f #f #t #t #f #t #f #t #f #f ... S2 #t #f #t #f #t #f #t #f #t #f ... S3 #f #f #f #f #t #f #f #f #f #f ... S4 #f #t #f #f #t #t #t #f #f #t ... . . . . . . d = #t #t #f #t #f . . .

The Halting Problem Given a program prog and an argument arg, does (prog arg) halt and return a value? Example (define prog (method (x) (x 3))) (define arg inc) (prog arg) ==> 4 but (define prog (method (x) (prog x))) (define arg 3) (prog arg) runs forever

Wouldn't it be nice if we had a program halts? that could test whether (prog arg) will halt... (halts? prog arg) ==> #t if (prog arg) halts and returns a value #f if it doesn't.

Wouldn't it be nice if we had a program halts? that could test whether (prog arg) will halt... (halts? prog arg) ==> #t if (prog arg) halts and returns a value #f if it doesn't. Unfortunately, halts? does not exist.

Proof by contradiction (essentially a diagonalization argument). Suppose there were such a program halts?. (define Cantor (method ((p <function>)) (if (halts? p p) (not (p p)) #f))) Note Cantor always halts on any <function>, e.g. (Cantor (method (x) 4)) ==> (not ((method (x) 4) (method (x) 4))) ==> (not 4) ==> #f

It halts, as we just argued. What is its value? What about (Cantor Cantor)? It halts, as we just argued. What is its value? (define Cantor (method ((p <function>)) (if (halts? p p) (not (p p)) #f))) (Cantor Cantor) ==> (if (halts? Cantor Cantor) (not (Cantor Cantor)) #f ==> (not (Cantor Cantor))

It halts, as we just argued. What is its value? What about (Cantor Cantor)? It halts, as we just argued. What is its value? (define Cantor (method ((p <function>)) (if (halts? p p) (not (p p)) #f))) (Cantor Cantor) ==> (if (halts? Cantor Cantor) (not (Cantor Cantor)) #f ==> (not (Cantor Cantor))

Turing's Halting Theorem Conclusion: halts? does not exist. We have just proved ...and none of the neat programming tricks we've taught you can possibly help. Turing's Halting Theorem It is undecidable whether a given program halts on a given input.

Other undecidable problems the dead code problem: given a block of code in a program, will that code ever be executed? the equivalence problem: given two programs, do they compute the same function?

We've enjoyed teaching this class very much, and we hope that we've given you some sense of what computer science is like. We hope to see you later on in some of our upper level courses. Thanks!