The proof that there exists an unrecognisable language hinges around the fact that languages can be infinite, while any model of computation is finite. More specifically, it depends on the fact that the set of languages are uncountable, while Turing machines are countable.

Proof (By Uncountability)

Firstly, note that there is a one-to-one correspondance between a Turing machine and the language it recognises. That is, a Turing Machine can accept only one language, not multiple (a language can be accepted by multiple Turing machines). Mathematically, the relation between a TM and a language is a#todo (What is it? injective? surjective?)

If we can show that there are more languages than Turing machines, then by the pigeonhole principle, there must be some languages that are not recognisable by any Turing machine (because, like we said, a Turing Machine cannot accept multiple languages). Mathematically, we need to show that the cardinality(size) of the set of all languages is greater than the cardinality of the set of all TMs.

The Set of Turing Machines is Countable

Firstly, we know that Turing machines have a finite set of states, and so their transition function must be finite. This means that their TM Encoding, is a finite string. If we take every single one of these strings, we now have a infinite set of finite strings. This means TMs are countable. Intuitively, it means we can make a list of every single Turing Machine, arranged by sorting (a string) in lexographical order:

  1. And so on,

In a more programmer-oriented approach, the set of all Turing Machines is enumerable. Mathematically, we have constructed a bijection to the natural number, given by the function . This function gives a unique Turing machine encoding for every natural number. Thus, by definition, the set of Turing Machines are countable.

%%🖋 Edit in Excalidraw, and the dark exported image%%

The Set of Languages is Uncountable

However, we will now show that such a list cannot be constructed for all languages. More specifically, we will show that we can construct a language that does not appear in the list, making the list incomplete. Firstly, we take the theorem that

#todo lecture 22

Proof (By Self-Referencing Diagonalisation)

Let’s start by looking at the set of all Turing machines, which we know to be countable. Then, this means the set of all Turing machine encodings are also countable. Also, given a Turing machine , it accepts some strings and does not accept (runs forever or rejects) other strings. This includes machine codes (that is, encodings of other Turing machines), including . So we could construct an entry for a machine :

Does not acceptAcceptsDoes not acceptDoes not accept
Equivalently, if we take the associated language (which is the set of strings that accepts), we have:
NoYesNoNo
That is, has a ‘yes’ in the table iff accepts .

Extending this table gives us:

NoYesNoNo
YesYesYesNo
NoNoNoYes

Now consider the language:

This language corresponds to taking the diagonal of the table above, and only adding machines which have a ‘No’ in the diagonal entry %%🖋 Edit in Excalidraw, and the dark exported image%%

For the example table above, it would be

This language is unrecognisable (will be shown by contradiction):

  1. Assume is recognisable. Then, by definition, there exists a Turing machine, that recognises it i.e.
  2. That is, accepts some machine code only if its associated machine does not accept . In our example above, accepts and only.
  3. Since is a Turing machine, it must appear somewhere in our table (due to TMs being countable).
  4. Does belong in ? Remember, is a set, so any string either belongs in or it does not.
    1. Assume does belong in
      • Then (by definition of being in ), must not accept
      • But, then, and we assumed by construction that accepts . So must accept
      • This is a contradiction
    2. Assume does not belong in
      • Then (by not being in ), must accept
      • But is a recogniser for , so it will only accept strings if they belong in . Since does not belong in , does not accept
      • Contradiction
  5. Since we have a contradiction in both cases, it must mean is not recognisable!