Download presentation

Presentation is loading. Please wait.

Published byMelody Bunten Modified about 1 year ago

1
1 COMP 382: Reasoning about algorithms Unit 9: Undecidability [Slides adapted from Amos Israeli’s]

2
Limits to computation There are problems for which there cannot be an algorithm, provably. – Undecidable problems There are problems for which polynomial-time algorithms are unlikely to exist – NP-complete problems

3
Diagonalization Technique for proving results about the cardinality of sets Invented by German mathematician Georg Cantor

4
Cardinality How many natural numbers are there? Infinity! How many real numbers are there? Infinity! Does the number of natural numbers equal the number of real numbers? How is the size of infinite sets measured?

5
Cardinality The cardinality of a set is a property marking its size. Two sets have the same cardinality if there is a (one-to-one) correspondence between their elements

6
Think about a correspondence between sets A and B as 2 lists: A list of A ’s elements and in parallel a list of B ’s elements. These 2 lists are juxtaposed so that each element of A corresponds to a unique element of B. Intuitive Notion of Correspondence 6

7
Clearly, the cardinality of A is equal to the cardinality of B. How about the cardinality of infinite sets? Example 7

8
Is the cardinality of natural numbers larger than the cardinality of even natural numbers? Question 8

9
Naturals and even naturals 9 Correspondence:

10
A set A is countable if it is either finite or its cardinality is equal to the cardinality of N. “A set is countable if a list of its elements can be created”. Countable Sets 10

11
“A set is countable if a list of its elements can be created”. This list does not have to be finite, but for each natural number i, one should be able to specify the i -th element on the list. For example, for EN the i -th element on the list is 2 i. Countable Sets 11

12
Is the set Q of rational numbers countable? Question 12

13
Theorem The set of positive rational numbers is countable. Proof We have to show how a complete list of the rational numbers can be formed. The set of Rationals is Countable 13

14
Recall that each natural number is defined by a pair of natural numbers. List rationals in an infinite rectangle. The set of rationals is countable 14 ……… ………………………………………………...

15
How can we form a list including all these numbers? The set of rationals is countable 15 ……… ………………………………………………... Can’t reach all numbers

16
The set of rationals is countable 16 A better way

17
Note that some rational numbers appear more than once. For example: all numbers on the main diagonal are equal to 1, so this list is not final. In order to compute the actual place of a given rational, we need to erase all duplicates, but this is a technicality… The set of rationals is countable 17

18
The set of infinite binary sequences is not countable. Are all sets countable? 18

19
Assume that there exists a list of all binary sequences. Such a list may look like this: Uncountable Sets 19 ……… ……………………

20
But can you be sure that all sequences are in this list? In fact, There exist infinitely many sequences that are not on the list: Uncountable Sets 20 ……… ……………………

21
Consider for example S= 0,0,1,1,0,…. The sequence S is formed so that 1 st elt. Of 1 st seq. 2 nd elt. Of 2 nd seq. 3 rd elt. Of 3 rd seq. And so on … Uncountable Sets 21 ……… ……………………

22
Define. Obviously, for every, the i -th element of S, differs from the i -th element of the i -th sequence in the list, that is: The element on the diagonal. Can the sequence S appear on the list? Uncountable Sets 22

23
Uncountable Sets 23 Contradiction Diagonalization

24
Back to Turing machines Turing machine = model of a program Inputs coded as strings over a finite input alphabet Language = Set of strings Intuition: A language corresponds to a computational decision problem

25
Example Problem: check if a given number n is even Language: All inputs on which the answer is “yes”

26
Back to Turing machines The collection of strings that M accepts is the language of M, denoted. A language is Turing Recognizable if there exists a Turing machine that recognizes it.

27
Since it is hard to tell whether a running machine is looping, we prefer machines that halt on all inputs. These machines are called deciders. A decider that recognizes a language L is said to decide L. A language is Turing decidable if there exists a Turing machine that decides it, and undecidable otherwise. Turing deciders (algorithms) 27

28
Claim Some Languages are not Turing-recognizable. Proof For any (finite) alphabet,, the set of (finite) strings, is countable. A list of all elements in is obtained by first listing strings of length 1, then 2, …, then n … Turing unrecognizable languages 28

29
The set of all TM-s is also countable because every TM,, can be described by its encoding, which is a string over. So the set of TM-s corresponds to a subset of. Note: Here we use the (unproven but correct) fact that the cardinality of a set is always not greater then the cardinality of any of its supersets. Proof (cont.) 29

30
Since each TM recognizes exactly a single language, a list of all TM-s can be used as a list of all recognizable languages. If we show that the set of languages over is uncountable, we can deduce that at least a single language is not on the list, that is: it is not recognized by any TM. Proof (cont.) 30

31
We have already seen that the set of infinite binary sequences is uncountable. Now we form a correspondence between the set of languages over and the set of infinite binary sequences to show that the set of languages is uncountable. Proof (cont.) 31

32
We have already seen that the set is countable. Consider a fixed list l of all words in. A correspondence between the set of infinite binary sequences and the set of languages is formed as follows: For every infinite binary sequence S, corresponds the language: QED Proof (cont.) 32

33
Moral of the story There are more problems than programs

34
Now we’ll show an undecidable language. The language that we prove to be undecidable is a very natural language namely the language consisting of pairs of the form where M is a TM accepting string w : The Halting Problem 34

35
Since this language requires to decide whether the computation of TM M halts on input w, it is often called The Halting Problem. Is the halting problem Turing Recognizable? The Halting Problem 35

36
Since this language requires to decide whether the computation of TM M halts on input w, it is often called The Halting Problem. Claim The halting problem is Turing Recognizable. The Halting Problem 36

37
Consider a TM U that gets a pair as input and simulates the run of M on input w. If M accepts or rejects so does U. Otherwise, U loops. Note: U recognizes A TM,since it accepts any pair, that is: any pair in which M accepts input w. Proof 37

38
TM N works as follows: 1.Mark M ’s initial state and w ’s initial symbol as the “current state” and “current head location”. 2.Look for M ’s next transition on the description of its transition function. 3.Execute M ’s transition. A TM N that simulates an input TM N 38

39
4.Move M ’s “current state” and “current head location” to their new places. 5.If M ’s new state is a deciding state decide according to the state, otherwise – repeat stages 2-5. Simulating an Input TM 39

40
So far we proved the existence of a language which is not Turing recognizable. Now we continue our quest to prove: Theorem The language is undecidable. The language is undecidable 40

41
Before we start the proof let us consider two ancient questions: Question1: Can god create a boulder so heavy such that he (god) cannot lift? The Language is undecidable 41

42
Question2: In a small town, there is a single barber: Over the barber’s chair there is a note saying: “ I will shave you on one condition: You shall never shave yourself.” Who Shaves the Barber? 42 The Language is undecidable

43
Assume, by way of contradiction, that is decidable and let H be a TM deciding. That is Define now another TM, D, that uses H as a subroutine as follows: Proof 43

44
Define now another TM new D that uses H as a subroutine as follows: D= “On input where M is a TM: 1. Run H on input. 2. Output the opposite of H ’s output namely: If H accepts reject, otherwise accept.“ Proof 44

45
Note: What we do here is taking advantage of the two facts: Fact1: TM M should be able to compute with any string as input. Fact2: The encoding of M,, is a string. Proof 45

46
Running a machine on its encoding is analogous to using a compiler for the computer language C, to compile itself (the compiler is written in C). Proof 46

47
What we got now is: Consider now the result of running D with input. What we get is: Proof 47

48
So if D accepts, it rejects and if it rejects it accepts. And it’s all caused by our assumption that TM H exists! Proof 48

49
1.Define. 2.Assume that id decidable and let H be a TM deciding it. 3.Use H to build TM D that gets a string and behaves exactly opposite to H ’s behavior, namely: Proof review 49

50
4.Run TM D on its encoding and conclude: Contradiction. Proof review 50

51
The following table describes the behavior of each machine on some machine encodings: So where is the diagonalization? 51

52
This table describes the behavior of TM H. Note: TM H rejects where loops. So where is the diagonalization? 52

53
Now TM D is added to the table… Proof review 53

54
Use the undecidability of to prove many other languages undecidable. Reductions 54

55
Show that a solution for some problem A induces a solution for problem B. If we know that B does not have a solution, we may deduce that A is also unsolvable. In this case we say that B is reducible to A. Reductions 55

56
Say you want to prove that a certain language L is undecidable. Assume that L is decidable, and show that a decider for L, can be used to devise a decider for. Since is undecidable, so is the language L. Reductions 56

57
Using a decider for L to construct a decider for, is called reducing to L. Note: Once we prove that a certain language L is undecidable, we can prove that some other language, say L’, is undecidable, by reducing L’ to L. Reductions 57

58
1.We know that A is undecidable. 2.We want to prove B is undecidable. 3.We assume that B is decidable and use this assumption to prove that A is decidable. 4.We conclude that B is undecidable. Note: The reduction is from A to B. Schematic of a Reduction 58

59
Consider Theorem is undecidable. Proof By reducing to The “Real” halting problem 59

60
Assume by way of contradiction that is decidable. Recall that a decidable set has a decider R : A TM that halts on every input and either accepts or rejects, but never loops!. We will use the assumed decider of to devise a decider for. Intuition 60

61
Recall the definition of : Why is it impossible to decide ? Because as long as M runs, we cannot determine whether it will eventually halt. Well, now we can, using the decider R for. Intuition 61

62
Assume that is decidable and let R be a TM deciding it. We give a TM S that uses R as a subroutine and decides. Since is undecidable, this is a contradiction. Proof 62

63
S= “On input where M is a TM: 1. Run R on input until it halts. 2. If R rejects, (i.e. M loops on w ) - reject. (At this stage we know that R accepts, and we conclude that M halts on input w.) 3. Simulate M on w until it halts. 4. If M accepts - accept, otherwise - reject. “ Proof 63

64
Show that the following language is undecidable. The TM Emptiness Problem 64

65
The proof is by reduction from : 1.We know that is undecidable. 2.We want to prove is undecidable. 3.We assume toward a contradiction that is decidable and devise a decider for. 4.We conclude that is undecidable. Proof Outline 65

66
Assume that is decidable and let R be a TM deciding it. Now we give a TM S that uses R as a subroutine and decides. Proof 66

67
Given an instance for,, we may try to run R on this instance. If R accepts, we know that. In particular, M does not accept w so a decider for must reject. Proof 67

68
What happens if R rejects? The only conclusion we can draw is that. What we need to know though is whether. In order to use our decider R for, we once again modify the input machine M to obtain TM : Proof 68

69
We start with a TM satisfying. Description of 69

70
Now we add a filter to divert all inputs but w. Description of 70 filter no yes

71
TM has a filter that rejects all inputs excepts w, so the only input reaching M, is w. Therefore, satisfies: Proof 71

72
Here is a formal description of : “On input x : 1. If - reject. 2. If - run M on w and accept if M accepts. ” Note: M accepts w if and only if. Proof 72

73
This way, if R accepts, S “can be sure” that and accept. Note that S gets the pair as input, thus before S runs R, it should compute an encoding of. This encoding is not too hard to compute using S ’s input. Proof 73

74
S= “On input where M is a TM: 1. Compute an encoding of TM. 2. Run R on input. 3. If R rejects - accept, otherwise - reject. Proof 74

75
Recall that R is a decider for. If R rejects the modified machine,, hence by the specification of,, and a decider for must accept. If however R accepts, it means that, hence, and S must reject. QED Proof 75

76
76 Rice’s Theorem We will show that for every nontrivial property P of recognizable languages is undecidable. Consider the language L P = { | M satisfies property P } We show how to reduce to L P. Since is undecidable, it follows that L P is also undecidable.

77
77 The Reduction Our reduction algorithm takes M and w and produces a TM M ’. L(M ’ ) has property P if and only if M accepts w. M’ has two tapes, used for: 1.Simulates another TM M L on the input to M ’. 2.Simulates M on w. neither M, M L, nor w is input to M ’.

78
78 The Reduction (continued) Assume that does not have property P. – If it does, consider the complement of P, which would also be decidable. Let L be any language with property P, and let M L be a TM that accepts L. M ’ is constructed to work as follows.

79
79 Design of M’ 1.On the second tape, write w and then simulate M on w. 2.If M accepts w, then simulate M L on the input x to M ’, which appears initially on the first tape. 3.M’ accepts its input x if and only if M L accepts x.

80
80 Action of M’ if M Accepts w Simulate M on input w x Simulate M L on input x On accept Accept iff x is in M L

81
81 Design of M’ (continued) Suppose M accepts w. Then M ’ simulates M L and therefore accepts x if and only if x is in L. That is, L(M ’ ) = L, L(M ’ ) has property P.

82
82 Design of M’ – (3) Suppose M does not accept w. Then M ’ never starts the simulation of M L, and never accepts its input x. Thus, L(M ’ ) = , and L(M ’ ) does not have property P. That is, M ’ is not in L P.

83
83 Action of M’ if M Does not Accept w Simulate M on input w x Never accepts, so nothing else happens and x is not accepted

84
84 Design of M’ – Conclusion Thus, the algorithm that converts M and w to M ’ is a reduction of to L P. Thus, L P is undecidable.

85
85 Picture of the Reduction A real reduction algorithm M, w Hypothetical algorithm for property P M’M’ Accept iff M accepts w Otherwise halt without accepting This would be an algorithm for L u, which doesn ’ t exist

86
86 Applications of Rice’s Theorem We now have any number of undecidable questions about TM ’ s: – Is a TM equivalent to a finite automaton? – Does a TM accept any palindromes? – Does a TM accept more than 1000 strings? –...

Similar presentations

© 2016 SlidePlayer.com Inc.

All rights reserved.

Ads by Google