Top Banner
1 Incomputable Languages Zeph Grunschlag
39
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

1

Incomputable Languages

Zeph Grunschlag

Page 2: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

2

Announcements

HW Due Tuesday

Page 3: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

3

Agenda

Incomputable LanguagesExistence ProofExplicit undecidable language: ATM

Unrecognizable LanguageNeither recognizable nor corecognizableExample of a “real world” unsolvable problem

Page 4: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

4

Incomputable LanguagesAre there questions of a computational nature

which cannot be answered methodically? We saw last time that the computability viewpoint is to encode algorithmic problems as formal languages and then ask: Are there undecidable languages? Are there languages which are not even recognizable? Can we construct a specific language that’s undecidable? Are there “useful” undecidable languages?

Page 5: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

5

Incomputable LanguagesExistential Proof

We start first with an indirect proof that an undecidable language exists. In fact, we can show that a language exists that is neither recognizable nor corecognizable: I.e., there is no TM which halts on all positive instances, and there is no TM which halts on all negative instances so we have no way of necessarily telling when an arbitrary string is or isn’t in the language.

The proof is “existential” in that a counting argument is used to show that the language must exist, but we don’t know a priori what the language is.

Page 6: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

6

Incomputable LanguagesExistence Proof

The idea is simple: We show that there are many more languages than Turing machines.

Every TM can be encoded in binary by some string. Consequently the cardinality1 of the set of TM’s is no greater than that of {0,1}*. Recall the notion of countable : A set S is countable if there is a 1-to-1 function f : S N from S to the natural numbers. Equivalently, an infinite set is countable if there is a bijection N S.

THM: The set of bit strings {0,1}* is countable.

Page 7: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

7

Countability of {0,1}*Proof. Intuitively we can strike up the 1-to-1

correspondence f : N {0,1}* by listing the strings in short-lex order:

0 1 00 01 10 11 000 001 010 011 100…1 2 3 4 5 6 7 8 9 10 11 12…Can even give recursive definition for f :

Can then use induction to prove that f is 1-to-1 and onto.

kk

kk

unfu

nf

n

nf

10 )1( if ,01

1 )1( if ,0

1 if , ε

)( 1

Page 8: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

8

Countability of {TM-Languages}

Consequently, as every TM is described by a bit string, there can only be as many TM’s as bit strings. In particular, the following sets are countable:

L1 = {recognizable languages}

L2 = {corecognizable languages}

DEF: A language L over the alphabet is corecognizable if *-L is recognizable.

Page 9: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

9

Countability of {TM-Languages}

Therefore,L1 L2 = {languages which are accepted or rejected

by a TM}is a union of countable sets so is countable itself. However, next we will see that the power set P ({0,1}*) –the set of binary languages!– is uncountable. As a corollary, there must be strictly more binary languages than languages in L1 L2. Therefore:

THM: A language of bit strings exists which is neither recognizable nor corecognizable.

So let’s prove that P ({0,1}*) is uncountable:

Page 10: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

10

Uncountability of P (*)Notice that any subset T in P (*) can be

viewed as a function * {0,1}. This is done by making the function take the value 1 for elements in the set, and the value 0 for elements not in the set.

EG: Consider the function f : * {0,1} defined by the following table:

Q: What language does f represent?

x 0 100

01

10

11

000

001

010

011

100

101

111

0000

f (x)

1 1 1 1 0 0 1 1 0 1 0 0 1 1 1 …

Page 11: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

11

Uncountability of P (*)

A: f represents pal. Suppose that P (*) were countable. Thus

it would be possible to find a bijection from N to P (*) and hence list all binary languages as a sequence

L1 , L2 , L3 , L4 , L5 , L6 , L7, …supposedly containing every language of bit strings. The lists creates a table whose rows describe the associated function for each subset:

x 0 100

01

10

11

000

001

010

011

100

101

111

0000

f (x)

1 1 1 1 0 0 1 1 0 1 0 0 1 1 1 …

Page 12: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

12

Uncountability of P (*)

0 1 00 01 10 11 …

L1 1 1 1 1 0 0 1

L2 0 0 0 0 0 0 0

L3 1 0 0 0 0 0 0

L4 1 1 0 1 0 0 0

L5 1 1 1 1 1 1 1

L6 0 0 1 0 0 0 1

L7 1 0 0 1 1 1 1. . .

strings in {0,1}*

Page 13: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

13

Uncountability of P (*)Cantor’s Diabolical

DiagonalCantor’s diabolical diagonalization

argument takes this supposed table, and creates a language Levil that’s not on the list. I.e., one uses the table to create a row that’s not there proving that the table cannot be comprehensive –contradicting the countability assumption and proving that P (*) is not countable.

Page 14: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

14

Uncountability of P (S*)Cantor’s Diabolical

DiagonalLevil is created as follows: The j th column

of Levil is the opposite of the j th column of the j th row Li. In other words, Levil is the anti-diagonal of the table. This guarantees that Levil disagrees with every listed language on some string: If the j th language contains the j th

string, then Levil doesn’t, and if the j th

language doesn’t contain the j th string, then Levil does.

Let’s see how this works in practice:

evilr

Page 15: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

15

Cantor Diagonalization

0 1 00 01 10 11 …

L1

L2

L3

L4

L5

L6

L7. . .

Levil

strings in {0,1}*

Page 16: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

16

Cantor Diagonalization

0 1 00 01 10 11 …

L1 1 1 1 1 0 0 1

L2

L3

L4

L5

L6

L7. . .

Levil 0

strings in {0,1}*

Page 17: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

17

Cantor Diagonalization

0 1 00 01 10 11 …

L1 1 1 1 1 0 0 1

L2 0 0 0 0 0 0 0

L3

L4

L5

L6

L7. . .

Levil 0 1

strings in {0,1}*

Page 18: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

18

Cantor Diagonalization

0 1 00 01 10 11 …

L1 1 1 1 1 0 0 1

L2 0 0 0 0 0 0 0

L3 1 0 0 0 0 0 0

L4

L5

L6

L7. . .

Levil 0 1 1

strings in {0,1}*

Page 19: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

19

Cantor Diagonalization

0 1 00 01 10 11 …

L1 1 1 1 1 0 0 1

L2 0 0 0 0 0 0 0

L3 1 0 0 0 0 0 0

L4 1 1 0 1 0 0 0

L5

L6

L7. . .

Levil 0 1 1 0

strings in {0,1}*

Page 20: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

20

Cantor Diagonalization

0 1 00 01 10 11 …

L1 1 1 1 1 0 0 1

L2 0 0 0 0 0 0 0

L3 1 0 0 0 0 0 0

L4 1 1 0 1 0 0 0

L5 1 1 1 1 1 1 1

L6

L7. . .

Levil 0 1 1 0 0

strings in {0,1}*

Page 21: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

21

Cantor Diagonalization

0 1 00 01 10 11 …

L1 1 1 1 1 0 0 1

L2 0 0 0 0 0 0 0

L3 1 0 0 0 0 0 0

L4 1 1 0 1 0 0 0

L5 1 1 1 1 1 1 1

L6 0 0 1 0 0 0 1

L7. . .

Levil 0 1 1 0 0 1

strings in {0,1}*

Page 22: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

22

Cantor Diagonalization

0 1 00 01 10 11 …

L1 1 1 1 1 0 0 1

L2 0 0 0 0 0 0 0

L3 1 0 0 0 0 0 0

L4 1 1 0 1 0 0 0

L5 1 1 1 1 1 1 1

L6 0 0 1 0 0 0 1

L7 1 0 0 1 1 1 1. . .

Levil 0 1 1 0 0 1 0

strings in {0,1}*

Page 23: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

23

Specifically UndecidableOkay, so now we know that there exist

unrecognizable language. In fact, most languages are unrecognizable as the cardinality of P (*) is a bigger infinity than that of *! However, the existential proof is not constructive. We would like an explicit example of such a language.

THM: ATM is recognizable but undecidable.

Page 24: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

24

ATM: Recognizablebut Undecidable

ATM is recognizable as follows:

“On input <M,x>:1. Simulate the TM M running on input x2. If M accepts, then ACCEPT”

This algorithm tells us when strings are accepted, but for rejected strings, there is no output, and even worse, for infinite loops, the algorithm gets caught in its own infinite loop as it’s simulating M’s infinite loop.

Page 25: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

25

ATM: Recognizablebut Undecidable

ATM is undecidable:

Suppose for contradiction, that ATM were decidable. Then some TM exists, call it D which decides ATM. Consider the implicit encoding scheme M <M>. Use D to construct an evil TM E (in the spirit of Cantor) which we’ll show cannot exist thus proving that ATM must not be decidable.

Page 26: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

26

The Evil TME = “On input w

1. If w doesn’t encode a TM, REJECT.2. Else, let M be the TM encoded by w. Simulate the machine D running on input <M,w>.3. If D accepts, REJECT4. If D rejects, ACCEPT”

Since D is a decider, so is E.

Page 27: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

27

The Evil TMThe following nagging problem remains:Does E accept or reject the self-encoding <E>?

CASE 1) Accepts. Then D rejected the input < E, <E> >. Therefore, by step 4 of E’s pseudocode, E must not accept <E>. This contradicts the assumption of acceptance!

CASE 2) Rejects. Then D accepted the input < E, <E> >. Therefore, by step 3 of E’s pseudocode, E must accept <E>. This contradicts the assumption of rejection!

Thus neither case happens so D doesn’t exist! �

Page 28: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

28

Java Consequences

The undecidability of ATM has far reaching consequences. For example:

THM (assumes Church-Turing thesis): There is no algorithm for telling if an arbitrary Java program halts. I.e. the language

HaltJava = { compiled Java programs that

eventually exit on their own }is undecidable.

Page 29: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

29

Undecidability of HaltJava

Why? Suppose that HaltJava were decidable. Note that there are TM-simulators written in Java. Such a simulator TMSimulate.java would run by, taking two arguments arg1, arg2 as input with arg1 a TM encoding and arg2 a string which the TM will be run on. More specifically, TMSimulate.java contains the method:

public static boolean run(String arg1, String arg2) which returns true if and only if M

accepts arg2.

Page 30: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

30

Undecidability of HaltJava

The upshot: The following program would then solve ATM which contradicts the fact that the problem is undecidable (assuming that TM’s can in turn, simulate Java –which follows from the Church-Turing thesis but can also be demonstrated directly).

Page 31: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

31

Undecidability of HaltJava

public class D{

public static void main(String[] args){

if(TMSimulate.run(args[0],args[1]))

System.exit(0);

else

while(true);

}

}

So if an algorithm for telling when Java program halted existed, would be able to tell when TM’s accept by seeing when the program above halts!

Page 32: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

32

Undecidability of ETM and EQTM

Recall that ETM is the emptiness problem for Turing machines:

“Given a TM M does L(M) = ?”And that EQTM is the equality problem:“Given TM’s M and M’ does L(M) = L(M’ )?”Notice that EQTM at least as hard as ETM

since ETM is a special case of EQTM.Q: Why?

Page 33: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

33

Undecidability of ETM and EQTM

A: Just set the second TM M’ to be a TM which rejects all inputs!

So to prove that EQTM is undecidable it suffices to show that ETM is undecidable and we can kill two birds with one stone:

THM: ETM is undecidable.

Proof. Suppose ETM were decidable. Let F be a decider for ETM. We’ll use F to solve ATM by applying F to a class of TM’s whose purpose is to encode the acceptance problem as instances of the emptiness problem.

Page 34: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

34

Undecidability of ETM and EQTM

Given any TM M and string w construct a TM KM,w whose language is nonempty iff w is accepted by M. The description of KM,w is as follows:

“On input x1. Erase x and replace by w.2. Simulate M running on input w.”

So if M accepts w, KM,w accepts every possible x ! On the other hand, if M doesn’t accept w, then KM,w either rejects every x or goes into an infinite loop on every x. Summarizing:

)( if {},

)( if *,)( , MLw

MLwKL wM

Page 35: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

35

Undecidability of ETM and EQTM

If ETM were solvable, we could decide when L(KM,w) is empty, and therefore decide when M accepts w because of the fact:

This completes the proof that ETM and consequently EQTM are undecidable. �

The above is a specific case of a general technique for showing that new problems are undecidable by using reductions from previously known undecidable problems.

)( if {},

)( if *,)( , MLw

MLwKL wM

Page 36: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

36

Undecidability of ALLTM

The same fact

shows that the the problem of telling if a TM accepts all inputs is also undecidable. Formally:

ALLTM = “Given a TM M. Does L(M) = * ?”

Q: Is ETM recognizable? Corecognizable? How about ALLTM?

)( if {},

)( if *,)( , MLw

MLwKL wM

Page 37: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

37

Further Look at ETM

A: ETM is corecognizable but not recognizable: We can tell when a TM isn’t empty by simulating the TM on all inputs –by dovetailng– and then outputting NON-EMPTY when the TM accepts some string. ETM is not recognizable because knowing when to answer “YES” would mean that we would know when to answer “NO” for ATM –by the construction above. But this is precisely what we cannot do, since we do know how to answer “YES” for ATM, and being able to also answer “NO” would mean that ATM is decidable.

Page 38: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

38

Further Look at ALLTM

On the other hand, ALLTM is an example of a language that is neither recognizable nor corecognizable, so is the explicit example of the language proved to exist earlier by the cardinality argument. We cannot answer “NO” to ALLTM as the reverse of the above argument for EQTM would imply that would be able to answer “NO” to ATM. Thus ALLTM is not corecognizable. Furthermore, ALLTM is also not recognizable as follows:

Page 39: 1 Incomputable Languages Zeph Grunschlag. 2 Announcements HW Due Tuesday.

39

ALLTM: Neither Recognizable nor Corecognizable

Suppose we could recognize ALLTM. As TM enumerators convert into TM acceptors, would be able to recognize when a TM enumerates all possible strings. For each TM-string pair (M,w) consider the enumerator EM,w:

1. Simulate M running on w in the background.2. At the same time, print out *.3. If the background simulation accepts, STOP!4. If it rejects, print out * forever.By construction, L(EM,w) = * iff M doesn’t accept

w. Answering “YES” to ALLTM means we can answer “NO” to ATM which is impossible!