1 / 32

Decidability in One Day – or maybe two (I can’t decide)

Decidability in One Day – or maybe two (I can’t decide). CS 331, Tandy Warnow Some slides by Luay Nakhleh , Rice University. Outline. Countability and uncountability What is decidability? There has to be a language that is not decidable An example of a language that is not decidable

vivian
Download Presentation

Decidability in One Day – or maybe two (I can’t decide)

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Decidability in One Day – or maybe two (I can’t decide) CS 331, Tandy Warnow Some slides by LuayNakhleh, Rice University

  2. Outline • Countability and uncountability • What is decidability? • There has to be a language that is not decidable • An example of a language that is not decidable • Reductions again

  3. Countability • Definition: A set S is countably infinite if there is a bijection from S to the positive integers. • A bijection from a set A to B is a function F such that • F is 1:1 (i.e., F(a)=F(b) if and only if a=b) • F is onto (i.e., for all b in B, there is an a in A such that F(a)=b)

  4. Countable sets • Obviously the set of positive integers is countably infinite – F(x)=x • The set of negative integers is countably infinite • F(x) = -x • The set of integersis countably infinite • F(x) = 1+2x if x is non-negative • F(x) = –2x if x is negative

  5. What about the following? • The set of finite subsets of the integers • The set of rational numbers • The set of functions from {0,1} to the integers • The set of functions from the integers to {0,1} • The set of strings over {0,1}* • The set of finite strings over {0,1}*

  6. Cantor’s Diagonalization Cantor proved (by contradiction) that the set S of infinite length binary strings is uncountable. • Proof (By contradiction). Suppose S is countable. Then we can enumerate the elements of S s1, s2, s3, …, where each si is one infinitely long binary string. Let sij be the jth letter in string si. • Let s* be defined by s*ij = 1-sij • Then s* is different from every element in S, and so cannot be in S. • But s* is an infinite length binary string, and so must be in S. • Contradicton. • Hence S must not be countable.

  7. What about the number of programs? • Assumption: Every program can be written down using a finite length string over the given alphabet. Hence, without loss of generality, we can write the program out in binary (over {0,1}*). • How many finite length binary strings are there? Is this countable or uncountable?

  8. The set of finite binary strings is countable • Enumerate the set of finite binary strings as follows: • First write down the empty string • Then enumerate the strings of length 1 • Then enumerate the strings of length 2 • Etc. Hence the set of programs is countable

  9. What is a “language”?

  10. Basics • A language X is a set of strings (all finite length) over an alphabet. • Examples: • {anbn: n = 0,1,2,…} • {anbm: n,m = 0, 1, 2…} • {a,b,c,…,z}* • {0,1}* - 0* - 1*

  11. Basics • A language X is a set of strings (all finite length) over an alphabet. • A program “accepts” a set of finite length strings. • L(M) is the set of strings accepted by program M. • Every program can be described by a finite length string over the alphabet. • The difference between countable and uncountable sets. • There are only countably many programs.

  12. Decidability • A language X is decidable if there is an algorithm M that on input w: • M says “yes” if w in X • M says “no” if w not in X • Every problem/language you’ve seen so far in this class is decidable.

  13. Finite programs can accept infinite languages Consider language L = {anbm: n>1, m>1}. Could you write a program to accept L? (In other words, is this language decidable?)

  14. Finite programs can accept infinite languages Similarly, consider a language that would describe all Eulerian graphs (of any size). (So each string in this language represents a single Eulerian graph.) Could you write a program that would return YES if and only if the graph was Eulerian?

  15. Finite programs, infinite languages • Similarly, consider the language of strings describing graphs that are 3-colorable. • Could you write a program to accept this language? • Note: this has nothing to do with how much time it takes, as long as it is finite.

  16. Does there exist a language that is not decidable? • You are encouraged to think about it in terms of the programs you can write using some programming language, say C: • The number of possible languages is uncountable (as this is the number of all subsets of Σ*) • The number of possible C programs is countable (every program is a finite string over the “C language alphabet”, and the number of finite strings over any finite alphabet is countable).

  17. Does there exist a language that is not decidable? • So, the number of languages is uncountable, and the number of programs in C is countable. • Therefore, there is at least one language for which there is no program (algorithm). • (In fact, there are an uncountable number of languages for which there are no programs.)

  18. Can we find a specific language that is not decidable? • HP = {<M,w>: M is a C program, and w is a string, and M halts on w} • Or the decision problem version: • Input: C program M, and input w • Question: Does M halt on w? • We will prove that HP is NOT decidable.

  19. Proof that HP is not decidable • HP = {<M,w>: M is a C program, and w is a string, and M halts on w} • We will prove that HP is NOT decidable by contradiction. • So suppose it is decidable. There some program exists that always terminates and answers “True” (or “yes”, whatever you prefer) for exactly those inputs <M,w> where M halts on w. • We will derive a contradiction. This will mean that HP is not decidable. • The remaining slides are based on http://www.cgl.uwaterloo.ca/~csk/halt

  20. Proof that HP is not decidable • HP = {<M,w>: M is a C program, and w is a string, and M halts on w} • We will prove that HP is NOT decidable by contradiction. • So suppose it is decidable. There some program exists that always terminates and answers “True” (or “yes”, whatever you prefer) for exactly those inputs <M,w> where M halts on w. • We will derive a contradiction. This will mean that HP is not decidable. • The remaining slides are based on http://www.cgl.uwaterloo.ca/~csk/halt

  21. Proof that HP is not decidable • HP = {<M,w>: M is a C program, and w is a string, and M halts on w} • We will prove that HP is NOT decidable by contradiction. • So suppose it is decidable. There some program exists that always terminates and answers “True” (or “yes”, whatever you prefer) for exactly those inputs <M,w> where M halts on w. • We will derive a contradiction. This will mean that HP is not decidable. • The remaining slides are based on http://www.cgl.uwaterloo.ca/~csk/halt

  22. Proof that HP is not decidable • HP = {<M,w>: M is a C program, and w is a string, and M halts on w} • We will prove that HP is NOT decidable by contradiction. • So suppose it is decidable. There some program exists that always terminates and answers “True” (or “yes”, whatever you prefer) for exactly those inputs <M,w> where M halts on w. • We will derive a contradiction. This will mean that HP is not decidable. • The remaining slides are based on http://www.cgl.uwaterloo.ca/~csk/halt

  23. HP (Halting Problem) • Assume HP is decidable and program WouldItStop (in C or whatever language) decides it. • So WouldItStop answers YES or NO on all inputs, and never goes into an infinite loop. • The input to WouldItStop is a pair <M,w> where M is a program and w is an input to the program, and WouldItStop(M,w) returns YES if M halts on w, and else returns NO. http://www.cgl.uwaterloo.ca/~csk/halt

  24. HP • Assume HP is decidable and program WouldItStop decides it (=correctly answers it). • Create program stops_on_self that takes a C program M’ as input and does the following: • Runs WouldItStop on <M’,M’> and returns the same output (YES or NO) http://www.cgl.uwaterloo.ca/~csk/halt

  25. HP • Assume HP is decidable and program WouldItStop decides it (=correctly answers it). • Create program stops_on_selfthat takes a C program M’ as input and does the following: • Runs WouldItStop on <M’,M’> and returns the same output (YES or NO) • We now create “BobsYerUncle” http://www.cgl.uwaterloo.ca/~csk/halt

  26. Bob’s Yer Uncle Boolbobs_yer_uncle ( char * program) { if (stops_on_self( program ) ) { while ( 1 ) {} return FALSE } else { return TRUE; } } http://www.cgl.uwaterloo.ca/~csk/halt

  27. Paradox What happens when you run bobs_yer_uncle on itself? Note: bobs_yer_uncle either returns TRUE or it runs forever. If it returns TRUE it’s because stops_on_self(bobs_yer_uncle) returned FALSE. But that means WouldItStop(bobs_yer_uncle, bobs_yer_uncle) returned FALSE. So think about it… Same kind of problem if bobs_yer_uncle runs forever. Contradiction!!! Hence, WouldItStop just cannot exist – no algorithm can solve the Halting Problem. You have just proved that the Halting Problem is undecidable!

  28. Paradox What happens when you run bobs_yer_uncle on itself? Note: bobs_yer_uncle either returns TRUE or it runs forever. If it returns TRUE it’s because stops_on_self(bobs_yer_uncle) returned FALSE. But that means WouldItStop(bobs_yer_uncle, bobs_yer_uncle) returned FALSE. So think about it… Same kind of problem if bobs_yer_uncle runs forever. Contradiction!!! Hence, WouldItStop just cannot exist – no algorithm can solve the Halting Problem. You have just proved that the Halting Problem is undecidable!

  29. Paradox What happens when you run bobs_yer_uncle on itself? Note: bobs_yer_uncle either returns TRUE or it runs forever. If it returns TRUE it’s because stops_on_self(bobs_yer_uncle) returned FALSE. But that means WouldItStop(bobs_yer_uncle, bobs_yer_uncle) returned FALSE. So think about it… Same kind of problem if bobs_yer_uncle runs forever. Contradiction!!! Hence, WouldItStop just cannot exist – no algorithm can solve the Halting Problem. You have just proved that the Halting Problem is undecidable!

  30. Paradox What happens when you run bobs_yer_uncle on itself? Note: bobs_yer_uncle either returns TRUE or it runs forever. If it returns TRUE it’s because stops_on_self(bobs_yer_uncle) returned FALSE. But that means WouldItStop(bobs_yer_uncle, bobs_yer_uncle) returned FALSE. So think about it… Same kind of problem if bobs_yer_uncle runs forever. Contradiction!!! Hence, WouldItStop just cannot exist – no algorithm can solve the Halting Problem. You have just proved that the Halting Problem is undecidable!

  31. Paradox What happens when you run bobs_yer_uncle on itself? Note: bobs_yer_uncle either returns TRUE or it runs forever. If it returns TRUE it’s because stops_on_self(bobs_yer_uncle) returned FALSE. But that means WouldItStop(bobs_yer_uncle, bobs_yer_uncle) returned FALSE. So think about it… Same kind of problem if bobs_yer_uncle runs forever. Contradiction!!! Hence, WouldItStop just cannot exist – no algorithm can solve the Halting Problem. You have just proved that the Halting Problem is undecidable!

  32. Reductions Again • Recall reductions for proving NP-hardness! • If we drop the requirement that the reduction is computable in polynomial time, we get a tool to establish (un)decidability of other languages. • That is, if L1 reduces to L2 (where the mapping is computable, but not necessarily in poly time), then: If L2 is decidable, then L1 is decidable (equivalently, if L1 is undecidable, then L2 is undecidable). • Prove this result! (Somewhat easy, since it’s a simple composition of programs.)

More Related