Turing machine proofs

Published

2023-08-17

Some tips for proofs (Turing machines, decidability, reducibility)

Set builder notation

Enumerating all elements of a set is very often (almost always) impractical. So instead we use set builder notation.

Here’s how we would write the sets of all even and odd numbers (respectively):

Even: \{n \; | \; n = 2k, k \in \mathbb{Z} \}

Odd: \{n \; | \; n = 2k + 1, k \in \mathbb{Z} \}

We read “|” as “such that” or “having the property”. So the set of all even numbers is the set of all n such that n = 2k where k \in \mathbb{Z} (k is an integer). The set of all odd numbers is the set of all n having the property that they can be written 2k + 1 where k \in \mathbb{Z}.

We use this notation to describe languages.

String representations of programs or machines

Every program or machine can be represented by a string. For example, the source code of a program is a string representation; the compiled source code of a program is a string of 0s and 1s.

Python source:

print("Hello World")

Abstract syntax tree:

"Module(body=[Expr(value=Call(func=Name(id='print', ctx=Load()), 
        args=[Constant(value='Hello World')], keywords=[]))], type_ignores=[])"

Bytecode:

  1           0 LOAD_NAME                0 (print)
              2 LOAD_CONST               0 ('Hello World')
              4 CALL_FUNCTION            1
              6 RETURN_VALUE

Transpiled to C, and compiled to object code (shown in hexadecimal):

CFFAEDFE 07000001 03000000 02000000 
11000000 D8050000 85802100 00000000 
19000000 48000000 5F5F5041 47455A45 
524F0000 00000000 ... you get the idea.

These are all equivalent string representations of this program.

A language is a set of strings

Example: EQ_{DFA} is the language of all string representations of pairs of DFAs, A, B, such that the language of A is equivalent to the language of B.

We write this:

EQ_{DFA} = \{\langle A, B \rangle \; | \; A, B \text{ are DFAs, and } \mathcal{L}(A) = \mathcal{L}(B) \}.

It’s important to understand that EQ_{DFA} isn’t a machine, it’s a set of strings! In this case, it’s a set of pairs of strings that satisfy the stated conditions.

The angle brackets, \langle X \rangle, indicate we have a string representation, of X (whatever X may be).

Proving something is decidable

One way to prove a language is decidable is to produce a decider. Oftentimes, we can use a decider that exists for a somewhat different language as a component of our decider. But keep in mind what it means to be a decider! For example, if we have a decider for EQ_{DFA} this is a machine which decides whether a pair of strings \langle A, B \rangle is in the language of EQ_{DFA} or not.

Some decidable languages

Here is a list of some languages we know are decidable. Thus, we can assume for each of these that a decider exists without having to produce it.

  • A_{DFA} = \{\langle B, w \rangle \; | \; B \text{ is a DFA that accepts input string } w \}.
  • A_{NFA} = \{\langle B, w \rangle \; | \; B \text{ is an NFA that accepts input string } w \}.
  • A_{REX} = \{\langle R, w \rangle \; | \; R \text{ is a regular expression that generates the string } w \}.
  • E_{DFA} = \{\langle A, w \rangle \; | \; A \text{ is an DFA and } \mathcal{L}(A) = \emptyset \}.
  • EQ_{DFA} = \{\langle A, B \rangle \; | \; A, B \text{ are DFAs, and } \mathcal{L}(A) = \mathcal{L}(B) \}.
  • A_{CFG} = \{\langle G, w \rangle \; | \; G \text{ is a CFG that generates string } w \}.
  • E_{CFG} = \{\langle G \rangle \; | \; G \text{ is a CFG and } \mathcal{L}(G) = \emptyset \}.
  • A_{LBA} = \{\langle M, w \rangle \; | \; M \text{ is a linear-bounded automaton and } M \text{ accepts } w \}.

When you’re working on a proof and you want to show something is decidable, maybe you can use one of these as a component in your decider!

Proving something is undecidable

One way to prove something is undecidable is to use a reduction. Reduction always involves two problems, A and B. If A reduces to B, we can use a solution to B to solve A. When using a reduction to prove a language is undecidable, we reduce from a language that is known to be undecidable by supposing that a decider for B exists. We show that if we had such a decider for B, we could use it to solve A. If we know A is undecidable, this gives us a contradiction. Therefore our supposition must be incorrect. Therefore the supposed decider cannot exist. Therefore B is undecidable. Boom.

Some undecidable languages

Note: To say a language is undecidable is not the same as saying we can’t tell if a particular Turing machine accepts a particular string. Rather, what we are saying is that there is no algorithm which takes an arbitrary Turing machine and an arbitrary string and can, in all cases, decide that the Turing machine accepts that string.[1]

  • A_{TM} = \{\langle M, w \rangle \; | \; M \text{ is a Turing machine and } M \text{ accepts } w \}.
  • H\mkern-3muALT_{TM} = \{\langle M, w \rangle \; | \; M \text{ is a Turing machine and } M \text{ halts on input } w \}.
  • E_{TM} = \{\langle M \rangle \; | \; M \text{ is a Turing machine and } \mathcal{L}(M) = \emptyset \}.
  • REGULAR_{TM} = \{\langle M \rangle \; | \; M \text{ is a Turing machine and } \mathcal{L}(M) \text{ is a regular language} \}.
  • EQ_{TM} = \{\langle M_1, M_2 \rangle \; | \; M_1, M_2 \text{ are Turing machines, and } \mathcal{L}(M_1) = \mathcal{L}(M_2) \}.
  • E_{LBA} = \{\langle M, w \rangle \; | \; M \text{ is a linear-bounded automaton and } \mathcal{L}(M) = \emptyset \}.
  • ALL_{CFG} = \{\langle G \rangle \; | \; G \text{ is a CFG and } \mathcal{L}(G) = \Sigma^* \}.
  • EQ_{CFG} = \{\langle G, H \rangle \; | \; G, H \text{ are CFGs and } \mathcal{L}(G) = \mathcal{L}(H) \}.

When you’re working on a proof and you want to show something is undecidable, maybe you can use a reduction from one of these!

Some unrecognizable languages

  • \overline{A_{TM}} = \{\langle M, w \rangle \; | \; M \text{ is a Turing machine and } M \text{ does not accept } w \}.

Rice’s Theorem

Any non-trivial semantic property of a language is undecidable. A property is trivial only if it is true for all languages or if it is true for none. Any other semantic property of a language is non-trivial.



Notes:

1. There are many problems out in the real world that are undecidable (and we have proofs of their undecidability). Here are a few examples:

  • Games: Determining whether a player has a winning strategy in a game of Magic: The Gathering.
  • Physics: The problem of determining whether a quantum mechanical system has a spectral gap.
  • Mathematics: Determining whether two finite simplicial complexes are homeomorphic.

There are many others.