← Index

Limits of Logic #2: Undecidable Sets

From: Limits of Logic (Jeffrey Sanford Russell)

1.5.5 Exercise: Undecidable Sets

Let SS be a set of strings. Let PP be a set of programs. Each program is a string in SS i.e. PSP⊆S.

We can run any given program with a string input and it may or may not "succeed" (for example, by eventually printing a result True). So we have a two place relation program AA succeeds with input string s.

Say a string XX is decidable if and only if there is some program AA that succeeds for all and only the strings in XX. If there is no program AA like this then XX is undecidable.

Show that there is at least one undecidable set of strings.


Let's try to rephrase this exercise, and thus, this notion of undecidability in a more generic manner.

Although programs are relevant to undecidability as it is discusssed in Limits Of Logic, I find it is clarifying to notice how the notion of undecidability itself has no hard relation with this magical entity of "programs".

Also, the exercise is a bit of a word salad. Let's try:


Let SS be a non-empty set and PSP⊆S.

We have a relation RP×SR⊆P×S.

A set XSX⊆S is decidable iff there is some sPs∈P such that sRdsRd for all and only dXd∈X.

If there is no such sPs∈P for some XSX⊆S, then XX is undecidable.

Show there is at least one undecidable set XSX⊆S.


I believe this is a correct generic restatement of the exercise. A subset is decidable if it's the image of an element under some relation. So, a set being "undecidable" simply means that the relation we're considering does not pick out that subset as an image of any of its inputs.

We'll see how this understanding of decidability holds as we move along the text and encounter what's meant to be the rigorous notion of decidability.

For now, the proof.


Proof:

Consider the function f:PPSf:P→PS taking a program sPs∈P to the set of all strings (inputs) XSX⊆S that it succeeds with.

If the function ff is onto, it means that for any XSX⊆S, there is at least one program sPs∈P such that f(s)=Xf(s)=X.

But given Cantor's theorem, a function ff from the set of programs PSP⊆S to the power set PSPS cannot be onto. Therefore, there is at least one XSX⊆S that is not in the range of ff.

This means there is at least one XSX⊆S such that no program sPs∈P succeeds with all and only the strings (input) in XX. And so, there is at least one undecidable set.


How should we understand the relation " program AA succeeds with input ss " and, as a result, what does the exercise really tell us (when it says there is an undecidable set)?

We can imagine appending a print statement (printing True) at the end of every possible program, such that the print statement always runs as long as the program does not run into an infinite loop.

This means we don't really care about whether a program suceeds in the way we'd expect a test case to succeed i.e. "the program is giving the intended output for whatever input." As long as the program terminates -- even as a result of "erroring out" -- we'll take it to print True and consider that it succeeds for its input.

So, we can rephrase the relation " program AA succeeds with input ss " as " program AA terminates for input ss ". In this way, we've interpreted any given program as an identifier, or a procedure that tells us the exhaustive and exclusive set of strings (inputs) it terminates for.

What then does the exercise tell us when it says there is an undecidable set.

A set XX is undecidable if there is no program which terminates for all and only those inputs in that set. That means, there is no "program" i.e. systematic procedure that can tell us whether a given string is a member of XX.

To see the higher level consequences of the result, note that there may be sets that we may be interested in (as we uncover later, sets like "the set of all true statements in a language / mathematics"), and there may be no program that can simply churn out the members of that set.