Undecidability. Andreas Klappenecker. [based on slides by Prof. Welch]

Similar documents
There are two main techniques for showing that problems are undecidable: diagonalization and reduction

CSCE 551: Chin-Tser Huang. University of South Carolina

ECS 120 Lesson 18 Decidable Problems, the Halting Problem

Discrete Mathematics for CS Spring 2007 Luca Trevisan Lecture 27

CSCI3390-Lecture 6: An Undecidable Problem

Turing Machine Recap

Great Theoretical Ideas in Computer Science. Lecture 5: Cantor s Legacy

1 Showing Recognizability

Turing Machines, diagonalization, the halting problem, reducibility

1 Reals are Uncountable

Functions. Definition 1 Let A and B be sets. A relation between A and B is any subset of A B.

Lecture Notes: The Halting Problem; Reductions

Undecibability. Hilbert's 10th Problem: Give an algorithm that given a polynomial decides if the polynomial has integer roots or not.

ACS2: Decidability Decidability

Decidability: Church-Turing Thesis

Intro to Theory of Computation

16.1 Countability. CS125 Lecture 16 Fall 2014

acs-07: Decidability Decidability Andreas Karwath und Malte Helmert Informatik Theorie II (A) WS2009/10

Undecidability COMS Ashley Montanaro 4 April Department of Computer Science, University of Bristol Bristol, UK

MATH 3300 Test 1. Name: Student Id:

CS 125 Section #10 (Un)decidability and Probability November 1, 2016

SETS AND FUNCTIONS JOSHUA BALLEW

Undecidability. We are not so much concerned if you are slow as when you come to a halt. (Chinese Proverb)

Discrete Mathematics and Probability Theory Spring 2014 Anant Sahai Note 20. To Infinity And Beyond: Countability and Computability

Decidability and Undecidability

15-251: Great Theoretical Ideas in Computer Science Fall 2016 Lecture 6 September 15, Turing & the Uncomputable

Turing Machines Part III

1 Computational Problems

Notes for Lecture Notes 2

A Universal Turing Machine

CSE 105 THEORY OF COMPUTATION

COMP/MATH 300 Topics for Spring 2017 June 5, Review and Regular Languages

1 Definition of a Turing machine

1.4 Cardinality. Tom Lewis. Fall Term Tom Lewis () 1.4 Cardinality Fall Term / 9

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

4.2 The Halting Problem

Warm-Up Problem. Please fill out your Teaching Evaluation Survey! Please comment on the warm-up problems if you haven t filled in your survey yet.

CSE 4111/5111/6111 Computability Jeff Edmonds Assignment 3: Diagonalization & Halting Problem Due: One week after shown in slides

} Some languages are Turing-decidable A Turing Machine will halt on all inputs (either accepting or rejecting). No infinite loops.

CSE 311: Foundations of Computing. Lecture 26: Cardinality

Limits of Computability

The Turing Machine. Computability. The Church-Turing Thesis (1936) Theory Hall of Fame. Theory Hall of Fame. Undecidability

Theory of Computation p.1/?? Theory of Computation p.2/?? We develop examples of languages that are decidable

Understanding Computation

CS20a: Turing Machines (Oct 29, 2002)

CS 361 Meeting 26 11/10/17

CITS2211 Discrete Structures (2017) Cardinality and Countability

Computational Models Lecture 8 1

TURING MAHINES

Computability, Undeciability and the Halting Problem

Introduction to Turing Machines. Reading: Chapters 8 & 9

6.045: Automata, Computability, and Complexity Or, Great Ideas in Theoretical Computer Science Spring, Class 10 Nancy Lynch

ADVANCED CALCULUS - MTH433 LECTURE 4 - FINITE AND INFINITE SETS

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

Reductions in Computability Theory

CSE 105 THEORY OF COMPUTATION

Non-emptiness Testing for TMs

One-to-one functions and onto functions

A Note on Turing Machine Design

Decidability. Human-aware Robotics. 2017/10/31 Chapter 4.1 in Sipser Ø Announcement:

LECTURE 22: COUNTABLE AND UNCOUNTABLE SETS

CSE 20 DISCRETE MATH. Fall

Computational Models Lecture 8 1

Sets are one of the basic building blocks for the types of objects considered in discrete mathematics.

Section 14.1 Computability then else

On Rice s theorem. Hans Hüttel. October 2001

CSCI 2200 Foundations of Computer Science Spring 2018 Quiz 3 (May 2, 2018) SOLUTIONS

Decidability (What, stuff is unsolvable?)

Turing Machines. Lecture 8

Chapter 20. Countability The rationals and the reals. This chapter covers infinite sets and countability.

CSE 105 THEORY OF COMPUTATION

Discrete Mathematics 2007: Lecture 5 Infinite sets

Computational Models Lecture 8 1

Exercises for Unit VI (Infinite constructions in set theory)

Definition: Let S and T be sets. A binary relation on SxT is any subset of SxT. A binary relation on S is any subset of SxS.

Computational Models Lecture 9, Spring 2009

Discrete Mathematics: Lectures 6 and 7 Sets, Relations, Functions and Counting Instructor: Arijit Bishnu Date: August 4 and 6, 2009

Undecidable Problems. Z. Sawa (TU Ostrava) Introd. to Theoretical Computer Science May 12, / 65

Most General computer?

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Decision Problems with TM s. Lecture 31: Halting Problem. Universe of discourse. Semi-decidable. Look at following sets: CSCI 81 Spring, 2012

CSE 311: Foundations of Computing. Lecture 26: More on Limits of FSMs, Cardinality

Theory of Computation Lecture Notes. Problems and Algorithms. Class Information

Computation Histories

Automata Theory CS S-FR2 Final Review

From Fundamentele Informatica 1: inleverdatum 1 april 2014, 13:45 uur. A Set A of the Same Size as B or Larger Than B. A itself is not.

Decidability of Existence and Construction of a Complement of a given function

15-251: Great Theoretical Ideas in Computer Science Lecture 7. Turing s Legacy Continues

CPSC 421: Tutorial #1

Turing machine recap. Universal Turing Machines and Undecidability. Alphabet size doesn t matter. Robustness of TM

A non-turing-recognizable language

Computability Theory

1 Acceptance, Rejection, and I/O for Turing Machines

Math 3361-Modern Algebra Lecture 08 9/26/ Cardinality

CSE 311: Foundations of Computing. Lecture 26: Cardinality, Uncomputability

CS154, Lecture 10: Rice s Theorem, Oracle Machines

Selected problems from past exams

Functions and cardinality (solutions) sections A and F TA: Clive Newstead 6 th May 2014

Mapping Reducibility. Human-aware Robotics. 2017/11/16 Chapter 5.3 in Sipser Ø Announcement:

Theory of Computation

Transcription:

Undecidability Andreas Klappenecker [based on slides by Prof. Welch] 1

Sources Theory of Computing, A Gentle Introduction, by E. Kinber and C. Smith, Prentice-Hall, 2001 Automata Theory, Languages and Computation, 3rd Ed., by J. Hopcroft, R. Motwani, and J. Ullman, 2007 2

Understanding Limits of Computing So far, we have studied how efficiently various problems can be solved. There has been no question as to whether it is possible to solve the problem If we want to explore the boundary between what can and what cannot be computed, we need a model of computation 3

Models of Computation Need a way to clearly and unambiguously specify how computation takes place Many different mathematical models have been proposed: Turing Machines Random Access Machines They have all been found to be equivalent! 4

Church-Turing Thesis Conjecture: Anything we reasonably think of as an algorithm can be computed by a Turing Machine (specific formal model). So we might as well think in our favorite programming language, or in pseudocode. Frees us from the tedium of having to provide boring details in principle, pseudocode descriptions can be converted into some appropriate formal model 5

Short Review of some Basic Set Theory Concepts 6

Some Notation If A and B are sets, then the set of all functions from A to B is denoted by B A. If A is a set, then P(A) denotes the power set, i.e., P(A) is the set of all subsets of A. 7

Cardinality Two sets A and B are said to have the same cardinality if and only if there exists a bijective function from A onto B. [ A function is bijective if it is one-to-one and onto ] We write A = B if A and B have the same cardinality. [Note that A = B says that A and B have the same number of elements, even if we do not yet know about numbers!] 8

How Set Theorists Count Set theorists count 0 = {} // the empty set exists by axiom This set contains no elements 1 = {0} = {{}} // form the set containing {} This set contains one element 2 = {0,1} = { {}, {{}} } This set contains two elements Keep including all previously created sets as elements of the next set. 9

Example Theorem: P(X) = 2 X Proof: The bijection from P(X) onto 2 X is given by the characteristic function. q.e.d. Example: X = {a,b} corresponds to f(a)=0, f(b)=0 {a} corresponds to f(a)=1, f(b)=0 {b} corresponds to f(a)=0, f(b)=1 {a,b} corresponds to f(a)=1, f(b)=1 10

More About Cardinality Let A and B be sets. We write A <= B if and only if there exists an injective function from A to B. We write A < B if and only if there exist an injective function from A to B, but no bijection exists from A to B. 11

Cardinality Cantor s Theorem: Let S be any set. Then S < P(S). Proof: Since the function i from S to P(S) given by i(s)= {s} is injective, we have S <= P(S). Claim: There does not exist any function f from S to P(S) that is surjective. Indeed, T = { s S: s f(s) } is not contained in f(s). An element s in S is either contained in T or not. If s T, then s f(s) by definition of T. Thus, T f(s). If s T, then s f(s) by definition of T. Thus, T f(s). Therefore, f is not surjective. This proves the claim. 12

Uncountable Sets and Uncomputable Functions 13

Countable Sets Let N be the set of natural numbers. A set X is called countable if and only if there exists a surjective function from N onto X. Thus, finite sets are countable, N is countable, but the set of real numbers is not countable. 14

An Uncountable Set Theorem: The set N N = { f f:n->n } is not countable. Proof: We have N < P(N) by Cantor s theorem. Since P(N) = 2 N and 2 N is a subset of N N we can conclude that N < P(N) = 2 N <= N N. q.e.d. 15

Alternate Proof: The Set N N is Uncountable Seeking a contradiction, we assume that the set of functions from N to N is countable. Let the functions in the set be f 0, f 1, f 2, We will obtain our contradiction by defining a function f d (using "diagonalization") that should be in the set but is not equal to any of the f i 's. 16

Diagonalization 0 1 2 3 4 5 6 f 0 4 14 34 6 0 1 2 f 1 55 32 777 3 21 12 8 f 2 90 2 5 21 66 901 2 f 3 4 44 4 7 8 34 28 f 4 80 56 32 12 3 6 7 f 5 43 345 12 7 3 1 0 f 6 0 3 6 9 12 15 18 17

Diagonalization 0 1 2 3 4 5 6 f 0 4 14 34 6 0 1 2 f 1 55 32 777 3 21 12 8 f 2 90 2 5 21 66 901 2 f 3 4 44 4 7 8 34 28 f 4 80 56 32 12 3 6 7 f 5 43 345 12 7 3 1 0 f 6 0 3 6 9 12 15 18 17

Diagonalization 18

Diagonalization Define the function: f d (n) = f n (n) + 1 18

Diagonalization Define the function: f d (n) = f n (n) + 1 In the example: 18

Diagonalization Define the function: f d (n) = f n (n) + 1 In the example: f d (0) = 4 + 1 = 5, so f d f 0 18

Diagonalization Define the function: f d (n) = f n (n) + 1 In the example: f d (0) = 4 + 1 = 5, so f d f 0 f d (1) = 32 + 1 = 33, so f d f 1 18

Diagonalization Define the function: f d (n) = f n (n) + 1 In the example: f d (0) = 4 + 1 = 5, so f d f 0 f d (1) = 32 + 1 = 33, so f d f 1 f d (2) = 5 + 1 = 6, so f d f 2 18

Diagonalization Define the function: f d (n) = f n (n) + 1 In the example: f d (0) = 4 + 1 = 5, so f d f 0 f d (1) = 32 + 1 = 33, so f d f 1 f d (2) = 5 + 1 = 6, so f d f 2 f d (3) = 7 + 1 = 8, so f d f 3 18

Diagonalization Define the function: f d (n) = f n (n) + 1 In the example: f d (0) = 4 + 1 = 5, so f d f 0 f d (1) = 32 + 1 = 33, so f d f 1 f d (2) = 5 + 1 = 6, so f d f 2 f d (3) = 7 + 1 = 8, so f d f 3 f d (4) = 3 + 1 = 4, so f d f 4 18

Diagonalization Define the function: f d (n) = f n (n) + 1 In the example: f d (0) = 4 + 1 = 5, so f d f 0 f d (1) = 32 + 1 = 33, so f d f 1 f d (2) = 5 + 1 = 6, so f d f 2 f d (3) = 7 + 1 = 8, so f d f 3 f d (4) = 3 + 1 = 4, so f d f 4 etc. 18

Uncomputable Functions Exist! Consider all programs (in our favorite model) that compute functions in N N. The set N N is uncountable, hence cannot be enumerated. However, the set of all programs can be enumerated (i.e., is countable). Thus there must exist some functions in N N that cannot be computed by a program. 19

Set of All Programs is Countable Fix your computational model (e.g., programming language). Every program is finite in length. For every integer n, there is a finite number of programs of length n. Enumerate programs of length 1, then programs of length 2, then programs of length 3, etc. 20

Uncomputable Functions Previous proof just showed there must exist uncomputable functions Did not exhibit any particular uncomputable function Maybe the functions that are uncomputable are uninteresting But actually there are some VERY interesting functions (problems) that are uncomputable 21

The Halting Problem 22

The Function Halt 23

The Function Halt Consider this function, called Halt: 23

The Function Halt Consider this function, called Halt: input: code for a program P and an input X for P 23

The Function Halt Consider this function, called Halt: input: code for a program P and an input X for P output: 1 if P terminates (halts) when executed on input X, and 0 if P doesn't terminate (goes into an infinite loop) when executed on input X 23

The Function Halt Consider this function, called Halt: input: code for a program P and an input X for P output: 1 if P terminates (halts) when executed on input X, and 0 if P doesn't terminate (goes into an infinite loop) when executed on input X By the way, a compiler is a program that takes as input the code for another program 23

The Function Halt Consider this function, called Halt: input: code for a program P and an input X for P output: 1 if P terminates (halts) when executed on input X, and 0 if P doesn't terminate (goes into an infinite loop) when executed on input X By the way, a compiler is a program that takes as input the code for another program Note that the input X to P could be (the code for) P itself 23

The Function Halt Consider this function, called Halt: input: code for a program P and an input X for P output: 1 if P terminates (halts) when executed on input X, and 0 if P doesn't terminate (goes into an infinite loop) when executed on input X By the way, a compiler is a program that takes as input the code for another program Note that the input X to P could be (the code for) P itself in the compiler example, a compiler can be run on its own code 23

The Function Halt We can view Halt as a function from N to N: P and X can be represented in ASCII, which is a string of bits. This string of bits can also be interpreted as a natural number. The function Halt would be a useful diagnostic tool in debugging programs 24

Halt is Uncomputable Suppose in contradiction there is a program P halt that computes Halt. Use P halt as a subroutine in another program, P self. Description of P self : input: code for any program P constructs pair (P,P) and calls P halt on (P,P) returns same answer as P halt 25

P self P P self (P,P) P halt 0 if P halts on input P 1 if P doesn't halt on input P 26

Halt is Uncomputable Now use P self as a subroutine inside another program P diag. Description of P diag : input: code for any program P call P self on input P if P self returns 1 then go into an infinite loop if P self returns 0 then output 0 P diag on input P does the opposite of what program P does on input P 27

P diag P P diag P P self (P,P) P halt 1 if P halts on input P 0 if P doesn't halt on input P 0 28

Halt is Uncomputable 29

Halt is Uncomputable Review behavior of P diag on input P: 29

Halt is Uncomputable Review behavior of P diag on input P: If P halts when executed on input P, then P diag goes into an infinite loop 29

Halt is Uncomputable Review behavior of P diag on input P: If P halts when executed on input P, then P diag goes into an infinite loop If P does not halt when executed on input P, then P diag halts (and outputs 0) 29

Halt is Uncomputable Review behavior of P diag on input P: If P halts when executed on input P, then P diag goes into an infinite loop If P does not halt when executed on input P, then P diag halts (and outputs 0) What happens if P diag is given its own code as input? It either halts or doesn't. 29

Halt is Uncomputable Review behavior of P diag on input P: If P halts when executed on input P, then P diag goes into an infinite loop If P does not halt when executed on input P, then P diag halts (and outputs 0) What happens if P diag is given its own code as input? It either halts or doesn't. If P diag halts when executed on input P diag, then P diag goes into an infinite loop 29

Halt is Uncomputable Review behavior of P diag on input P: If P halts when executed on input P, then P diag goes into an infinite loop If P does not halt when executed on input P, then P diag halts (and outputs 0) What happens if P diag is given its own code as input? It either halts or doesn't. If P diag halts when executed on input P diag, then P diag goes into an infinite loop If P diag doesn't halt when executed on input P diag, then P diag halts 29

Halt is Uncomputable Review behavior of P diag on input P: If P halts when executed on input P, then P diag goes into an infinite loop If P does not halt when executed on input P, then P diag halts (and outputs 0) What happens if P diag is given its own code as input? It either halts or doesn't. If P diag halts when executed on input P diag, then P diag goes into an infinite loop If P diag doesn't halt when executed on input P diag, then P diag halts Contradiction 29

Halt is Uncomputable What went wrong? Our assumption that there is an algorithm to compute Halt was incorrect. So there is no algorithm that can correctly determine if an arbitrary program halts on an arbitrary input. 30

Undecidability 31

Undecidability The analog of an uncomputable function is an undecidable set. The theory of what can and cannot be computed focuses on identifying sets of strings: an algorithm is required to "decide" if a given input string is in the set of interest similar to deciding if the input to some NPcomplete problem is a YES or NO instance 32

Undecidability Recall that a (formal) language is a set of strings, assuming some encoding. Analogous to the function Halt is the set H of all strings that encode a program P and an input X such that P halts when executed on X. There is no algorithm that can correctly identify for every string whether it belongs to H or not. 33

More Reductions For NP-completeness, we were concerned with (time) complexity of probems: reduction from P1 to P2 had to be fast (polynomial time) Now we are concerned with computability of problems: reduction from P1 to P2 just needs to be computable, don't care how slow it is 34

Many-One Reduction all strings over L 1 's alphabet all strings over L 2 's alphabet L 1 L 2 f 35

Many-One Reduction all strings over L 1 's alphabet all strings over L 2 's alphabet L 1 L 2 f 35

Many-One Reduction all strings over L 1 's alphabet all strings over L 2 's alphabet L 1 L 2 f 35

Many-One Reduction all strings over L 1 's alphabet all strings over L 2 's alphabet L 1 L 2 f 35

Many-One Reduction all strings over L 1 's alphabet all strings over L 2 's alphabet L 1 L 2 f 35

Many-One Reduction all strings over L 1 's alphabet all strings over L 2 's alphabet L 1 L 2 f 35

Many-One Reduction all strings over L 1 's alphabet all strings over L 2 's alphabet L 1 L 2 f 35

Many-One Reduction all strings over L 1 's alphabet all strings over L 2 's alphabet L 1 L 2 f 35

Many-One Reduction YES instances map to YES instances NO instances map to NO instances computable (doesn't matter how slow) Notation: L 1 m L 2 Think: L 2 is at least as hard to compute as L 1 36

Many-One Reduction Theorem Theorem: If L 1 m L 2 and L 2 is computable, then L 1 is computable. Proof: Let f be the many-one reduction from L 1 to L 2. Let A 2 be an algorithm for L 2. Here is an algorithm A 1 for L 1. input: x compute f(x) run A 2 on input f(x) 37

Implication If there is no algorithm for L 1, then there is no algorithm for L 2. In other words, if L 1 is undecidable, then L 2 is also undecidable. Pay attention to the direction! 38

Example of a Reduction Consider the language L NE consisting of all strings that encode a program that halts (does not go into an infinite loop) on at least one input. Use a reduction to show that L NE is not decidable: Show some known undecidable language m L NE. Our only choice for the known undecidable language is H (the language corresponding to the halting problem) So show H m L NE. 39

Example of a Reduction Given an arbitrary H input (encoding of a program P and an input X for P), compute an L NE input (encoding of a program P') such that P halts on input X if and only if P' halts on at least one input. Construction consists of writing code to describe P'. What should P' do? It's allowed to use P and X 40

Example of a Reduction The code for P' does this: input X': ignore X' call program P on input X if P halts on input X then return whatever P returns How does P' behave? If P halts on X, then P' halts on every input If P does not halt on X, then P' does not halt on any input 41

Example of a Reduction Thus if (P,X) is a YES input for H (meaning P halts on input X), then P' is a YES input for L NE (meaning P' halts on at least one input). Similarly, if (P,X) is NO input for H (meaning P does not halt on input X), then P' is a NO input for L NE (meaning P' does not halt on even one input) Since H is undecidable, and we showed H m L NE, L NE is also undecidable. 42

Generalizing Such Reductions There is a way to generalize the reduction we just did, to show that lots of other languages that describe properties of programs are also undecidable. Focus just on programs that accept languages (sets of strings): I.e., programs that say YES or NO about their inputs Ex: a compiler tells you YES or NO whether its input is syntactically correct 43

Properties About Programs Define a property about programs to be a set of strings that encode some programs. The "property" corresponds to whatever it is that all the programs have in common Example: Program terminates in 10 steps on input y Program never goes into an infinite loop Program accepts a finite number of strings Program contains 15 variables Program accepts 0 or more inputs 44

Functional Properties A property about programs is called functional if it just refers to the language accepted by the program and not about the specific code of the program Program terminates in 10 steps on input y (n.f.) Program never goes into an infinite loop (f.) Program accepts a finite number of strings (f.) Program contains 15 variables (n.f.) 45

Nontrivial Properties A functional property about programs is nontrivial if some programs have the property and some do not Example of nontrivial programs: Program never goes into an infinite loop Program accepts a finite number of strings Example of a trivial program: Program accepts 0 or more inputs 46

Rice's Theorem Every nontrivial (functional) property about programs is undecidable. The proof is a generalization of the reduction shown earlier. Very powerful and useful theorem: To show that some property is undecidable, only need to show that is nontrivial and functional, then appeal to Rice's Theorem 47

Applying Rice's Theorem Consider the property "program accepts a finite number of strings". This property is functional: it is about the language accepted by the program and not the details of the code of the program This property is nontrivial: Some programs accept a finite number of strings (for instance, the program that accepts no input) some accept an infinite number (for instance, the program that accepts every input) By Rice's theorem, the property is undecidable. 48

Implications of Undecidable Program Property It is not possible to design an algorithm (write a program) that can analyze any input program and decide whether the input program satisfies the property! Essentially all you can do is simulate the input program and see how it behaves but this leaves you vulnerable to an infinite loop 49