CSCI3390-Lecture 6: An Undecidable Problem

Similar documents
Lecture Notes: The Halting Problem; Reductions

CHAPTER 6. Copyright Cengage Learning. All rights reserved.

1 Showing Recognizability

Turing Machine Recap

16.1 Countability. CS125 Lecture 16 Fall 2014

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

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

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.

FORMAL LANGUAGES, AUTOMATA AND COMPUTATION

ECS 120 Lesson 18 Decidable Problems, the Halting Problem

Decidable Languages - relationship with other classes.

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

CS 361 Meeting 26 11/10/17

1 Reals are Uncountable

TURING MAHINES

Notes for Lecture Notes 2

Turing Machines, diagonalization, the halting problem, reducibility

We introduce one more operation on sets, perhaps the most important

Decidability and Undecidability

1 Computational Problems

Intro to Theory of Computation

Decidability: Church-Turing Thesis

Discrete Mathematics for CS Spring 2007 Luca Trevisan Lecture 27

Theory of Computation

4.2 The Halting Problem

CSE 105 THEORY OF COMPUTATION

ACS2: Decidability Decidability

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

CS 301. Lecture 18 Decidable languages. Stephen Checkoway. April 2, 2018

CPSC 421: Tutorial #1

Introduction to the Theory of Computing

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

17.1 The Halting Problem

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

Computability Crib Sheet

CSCI3390-Assignment 2 Solutions

Computability, Undeciability and the Halting Problem

Turing Machines. Lecture 8

Introduction to Turing Machines. Reading: Chapters 8 & 9

CS154, Lecture 10: Rice s Theorem, Oracle Machines

A Little History Incompleteness The First Theorem The Second Theorem Implications. Gödel s Theorem. Anders O.F. Hendrickson

CSE 105 THEORY OF COMPUTATION

Theory of Computation

CpSc 421 Homework 9 Solution

A non-turing-recognizable language

CSE355 SUMMER 2018 LECTURES TURING MACHINES AND (UN)DECIDABILITY

Turing Machines Part Three

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

The Two Faces of Infinity Dr. Bob Gardner Great Ideas in Science (BIOL 3018)

CS481F01 Solutions 8

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

CSE 105 Theory of Computation

Exam Computability and Complexity

Further discussion of Turing machines

CSE 105 THEORY OF COMPUTATION

CSE 105 Theory of Computation

A Universal Turing Machine

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

1 Reducability. CSCC63 Worksheet Reducability. For your reference, A T M is defined to be the language { M, w M accepts w}. Theorem 5.

Understanding Computation

Lecture 12: Mapping Reductions

The Power of One-State Turing Machines

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

Notes on induction proofs and recursive definitions

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

6.045J/18.400J: Automata, Computability and Complexity. Quiz 2. March 30, Please write your name in the upper corner of each page.

Computational Models Lecture 8 1

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

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

CS154, Lecture 17: conp, Oracles again, Space Complexity

Most General computer?

Computational Models Lecture 8 1

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

Decidability (What, stuff is unsolvable?)

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

Introduction to Proofs

Set Theory. CSE 215, Foundations of Computer Science Stony Brook University

Undecidable Problems and Reducibility

CSE 105 THEORY OF COMPUTATION. Spring 2018 review class

Decidability. Linz 6 th, Chapter 12: Limits of Algorithmic Computation, page 309ff

Time-bounded computations

Computational Models Lecture 8 1

One-to-one functions and onto functions

CS151 Complexity Theory. Lecture 1 April 3, 2017

U.C. Berkeley CS278: Computational Complexity Professor Luca Trevisan August 30, Notes for Lecture 1

CS20a: Turing Machines (Oct 29, 2002)

CSE 311: Foundations of Computing. Lecture 26: Cardinality

Sequence convergence, the weak T-axioms, and first countability

Homework Assignment 6 Answers

1 Definition of a Turing machine

Introduction to Computer Science

Turing Machines Part III

Algorithms: Lecture 2

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

V Honors Theory of Computation

Part I: Definitions and Properties

CS6901: review of Theory of Computation and Algorithms

CS5371 Theory of Computation. Lecture 10: Computability Theory I (Turing Machine)

Reductions in Computability Theory

Transcription:

CSCI3390-Lecture 6: An Undecidable Problem September 21, 2018 1 Summary The language L T M recognized by the universal Turing machine is not decidable. Thus there is no algorithm that determines, yes or no, whether a given Turing machine accepts a given input string. This is proved by a variant of the Cantor diagonal argument, originally used to show that there are uncountable infinite sets. As a consequence, we are able to show that a large number of basic questions about the behavior of Turing machines, and therefore about the behavior of computer programs, are also undecidable. The main tool for proving this is to reduce the problem that we want to show is undecidable to a problem we already know to be undecidable. We ll discuss reductions in the next lecture. 2 The main result: L T M is not decidable. We showed that the language L T M = {< M, w >: M accepts w} is Turing-recognizable. When you strip away the formal description, L T M is the decision problem: Input: A Turing machine M and a string w {0, 1}, Output: Yes, if M accepts w, no if M does not accept w. 1

The fact that L T M is Turing-recognizable translates to: there is an algorithm for this problem that always answers Yes when that is the correct output, and never answers incorrectly. This is simply the procedure of simulating M on the string w, which you carried out in the first assignment. However, this algorithm does not completely solve the decision problem, because it may fail to answer, by running forever. We want to know if there is an algorithm that always answers Yes when M accepts w, and always answers No when M does not accept w. We will show that no such algorithm exists. That is, Theorem 1 L T M is undecidable. Before we proceed to the proof, let s think about what a proof that L T M is decidable would look like. Suppose we could prove something along the lines of 3 Cantor s Diagonal Argument You could skip right ahead to the proof of Theorem 1. This section is partly historical background, partly motivation for the argument. Below is a listing of the elements of several infinite sets: the natural numbers, the integers, ordered pairs of integers, and strings of bits. N: 0, 1, 2, 3,... Z: 0, 1, 1, 2, 2, 3, 3... Z Z: (0, 0), (0, 1), (0, 1), (1, 0), ( 1, 0), (0, 2), (0, 2), (1, 1), (1, 1),... {0, 1} : ɛ, 0, 1, 00, 01, 10, 11, 000, 001,... (In case it s not clear, the method for listing the elements of Z Z is to list all those pairs such that the sum of the absolute values of the components is 0, then those whose sum is 1, then 2, etc. There are only finitely many pairs in each of these groups.) An infinite set X whose elements can be listed this way is said to be a countable set. Another, more formal way to say this is that there is a bijective function f : N X. Are there any uncountable sets? The answer is yes. The mathematician Georg Cantor, who invented the modern theory of sets, gave several proofs of this fact. 2

The one we give here was published in 1891. If X is a set, the P(X) denotes the power set of X, the set of all subsets of X. For example, P({1, 2, 3}) = {, {1}, {2}, {3}, {1, 2}, {1, 3}, {2, 3}, {1, 2, 3}}. Cantor s result is Theorem 2 Let X be a set. There is no onto function f : X P(X). If X is finite, this theorem is trivial, because P(X) contains more elements than X. If X is an infinite set, this gives meaning to one infinite set having more elements than another infinite set. Observe that if Y is a countable set, then we can list all its elements y 0, y 1, y 2,..., and thus there is an onto function f : N Y defined by f(j) = y j. So, in particular, the above theorem implies that P(N) is an uncountable set. Proof of Theorem 2. Suppose to the contrary that such an onto function f : X P(X) exists. Define Z = {z X : z / f(z)}. Z is a subset of X, so since f is onto, there is some y X such that f(y) = Z. Is y an element of f(y)? If y f(y), then by the definition of Z, y / Z = f(y), and if y / f(y), then again, by the definition of Z, y f(y). So we get the paradoxical conclusion that y is an element of f(y) if and only if it isn t. But there s really no paradox, just a contradiction. Our original assumption that f is onto must be false, so no such onto function exists. This theorem tells us something about Turing machines and decidability as well. Every Turing machine can be encoded by a bit string, so the set of Turing machines is countable. Consider the function g that maps a Turing machine M with input alphabet {0, 1} to the language L {0, 1} that it recognizes. Since P({0, 1} ) is uncountable, g cannot be an onto function, so there must be some languages (in fact, almost all languages) that are not Turing-recognizable, and therefore not decidable. But this observation is not terribly informative, since it does not provide an example of an undecidable problem. Cantor s argument was used by Bertrand Russell in 1901 to formulate Russell s Paradox: Let Z be the set of all sets that are not elements of themselves. Then Z Z if and only if Z / Z. The upshot is that no system of logic or set 3

theory should allow one to define this set Z the problem was that the logician Frege had just published a system that allows one to do precisely that. So this was a big deal in the history of mathematical logic. Russell explained the paradox this way: Imagine a group of men that includes a barber. The barber shaves precisely the men in the group who do not shave themselves. So who shaves the barber? If he shaves himself, then by this criterion, he doesn t shave himself, and if he doesn t, he does. (The resolution of the paradox here is that no such group of men, with such a barber, can possibly exist.) 4 Proof of Theorem 1. Suppose L T M is decidable: that is, we have a Turing machine V that decides whether a given Turing machine accepts a given input string. In particular, we can decide if a given Turing machine M accepts its own encoding < M >. In other words, we would have that the language {< M >: M accepts < M >} is decidable. Let V 2 be a TM that decides it. Now we tweak V 2 simply by interchanging its accept and reject states, and get another TM V 3. Let s summarize what V 3 does on a given input u: If u is not the encoding of any Turing machine, the V 2 rejects u, so V 3 accepts u. If u =< M > for some T M M, and M accepts u, then V 2 accepts u, so V 3 rejects u. If u =< M > for some T M M, and M does not accept u, then V 2 rejects u, so V 3 accepts u. We now ask who shaves the barber? Does V 3 accept its own encoding u =< V 3 >? The second rule above says that if V 3 accepts u, then it rejects u, and if it doesn t accept u, then it accepts u. So we get the same sort of paradox. This means that V 3 cannot exist, but then neither can V 2, nor V. So L T M is undecidable. 4

5 A non-turing-recognizable language We showed earlier that a language is decidable if and only if both it and its complement are Turing recognizable. Since L T M is Turing recognizable but not decidable, its complement is not Turing-recognizable. In other words, the following problem is not Turing-recognizable: Input: A Turing machine M and a string w {0, 1}, Output: Yes, if M does not accept w, no if M accepts w. That is, there is not even an algorithm for this question that always answers Yes when that is the correct answer. 6 Perspective Theorem 1, and the related problems we discuss below, although stated about Turing machines, are true in any computational model that is equivalent in power to Turing machines. This includes any conventional programming language. So, for example, there is no Java program to determine if a given Turing machine accepts a given input, and there is no Java program to determine if a given Java function boolean f(int n) returns true on a given integer argument. Similarly, the claim below that there is no algorithm to determine if two Turing machines have the same behavior (accept the same strings) implies that there is no algorithm to determine if two Python functions behave identically. 7 A collection of undecidable problems about Turing machines All of the problems below are undecidable. We will see how to deduce this from the undecidability of L T M in the next lecture. 5

7.1 Halting Problem, version 1 Input: A Turing machine M and a string w {0, 1}. Output: Yes if M eventually halts when started on input w, No otherwise. 7.2 Halting Problem, version 2 Output: Yes if M eventually halts regardless of the input string (i.e., M is free of infinite loops), No otherwise (i.e., if M runs forever on some input). 7.3 Nonemptiness Output: Yes if there is some w {0, 1} accepted by M, no otherwise. 7.4 Finiteness. Output: Yes if the set of strings accepted by M is finite, No if M accepts infinitely many strings. 7.5 Equivalence Input: Two Turing machines M, N. Output: Yes M and N accept exactly the same strings, no otherwise. 7.6 Minimality Output: Yes if M is the smallest Turing machine that recognizes the set of strings it accepts, No if there is a smaller machine that recognizes the same language. Here you have to say what exactly you mean by the size of a Turing machine. One way to do this is to fix an encoding scheme, and use the length of the encoding of M as the size of M. 6