A truth that cannot be proved

The centrepiece of the series: starting from a concrete self-referential Python program, we prove both a semantic and a syntactic version of Gödel's First Incompleteness Theorem. We then present the classical Gödel–Rosser statement, explore the relationship to Hilbert's second problem, and discuss the philosophical implications for the mind–machine debate.

17 min read

If a "religion" is defined as a system of ideas that contains unprovable statements, then Gödel taught us that mathematics is not only a religion, it is the only religion that can prove itself to be one.

John D. Barrow, Pi in the Sky (2011)1

From Leibniz and Boole to Hilbert, mathematicians imagined that it would be possible to determine the truth of mathematical formulas automatically. We now ask the same question: we have worked with simple logical systems that are decidable, i.e., for which a program can determine whether a formula is true or false. In the case of more complex logical systems, such as Peano arithmetic, this is not possible. This is because the existence of undecidable computational problems leads directly to the existence of undecidable mathematical statements.

5.1 #A first approach

Before proceeding with the proof of a first version of the First Incompleteness Theorem, we will discuss in detail Program 5.1. In Line 3 we import the function is_theorem_peano, whose existence we proved in Proposition 4.29. Recall that, since the axioms of Peano\textbf{Peano} are recursively enumerable (i.e., Peano\textbf{Peano} is recursively axiomatizable), we can write the program is_theorem_peano(formula) that returns yes if formula is a theorem in Peano\textbf{Peano}, and does not halt otherwise (see Proposition 4.29).

Program5.1—godel_peano.py
import utilities
 
from is_theorem_peano import is_theorem_peano  # NOT an oracle
from halting_to_peano import halting_to_peano      # NOT an oracle
 
def godel_peano(input):
godel_program = utilities.read('godel_peano.py')
halts_in_peano = halting_to_peano(godel_program)
does_not_halt_in_peano = 'NO (' + halts_in_peano + ')'
 
if is_theorem_peano(does_not_halt_in_peano) == 'yes':
return 'halts'
else:
utilities.loop_forever()

Line 4 imports the function halting_to_peano, whose existence we already discussed after Proposition 4.24. This function translates, given a program PP, the statement “PP halts on empty input” into a Peano\textbf{Peano} formula.

In Line 7 we store the program godel_peano.py itself in the variable godel_program. In Line 8 we use the function halting_to_peano just discussed, and in Line 9 we negate the formula halts_in_peano. In this way:

does_not_halt_in_peano means that “godel_peano.py does not halt on empty input”

(⋆1)(\star 1)

Now is when things get interesting. If does_not_halt_in_peano is a theorem, the function is_theorem_peano will return yes, and in this way the program will verify the condition in Line 11 and return halts, making the program halt. If does_not_halt_in_peano is not a theorem, it will enter an infinite loop (is_theorem_peano will not halt, and therefore neither will godel_peano.py). It is clear that Line 14 will never execute, but we include it to emphasize this fact.

Now we ask: what is the behavior of godel_peano.py on empty input?

Proposition5.1

Program 5.1 does not halt on empty input.

Proof

Suppose godel_peano.py halts on empty input; we will reach a contradiction. The only way it can halt is at Line 12, which happens only if:

is_theorem_peano(does_not_halt_in_peano) == 'yes'

(⋆2)(\star 2)

(⋆2)(\star 2) is equivalent to saying that does_not_halt_in_peano is a theorem. By the soundness of Peano\textbf{Peano}, does_not_halt_in_peano is true.

But the fact that does_not_halt_in_peano is true, together with (⋆1)(\star 1), tells us that godel_peano.py does not halt on empty input, yielding the expected contradiction.

∎

We are now in a position to prove the main result of this work.

Theorem5.2—Incompleteness of Peano Arithmetic

Peano arithmetic is incomplete: there exist true formulas of Peano\textbf{Peano} that are not theorems. Specifically, the formula stored in the variable does_not_halt_in_peano at Line 9 of Program 5.1 is an example of a formula that is true but not provable (not a theorem) in Peano\textbf{Peano}.

Proof

We must show that does_not_halt_in_peano is true and is not a theorem.

To prove that it is true, by Proposition 5.1, we know that godel_peano.py does not halt on empty input. Recalling (⋆1)(\star 1), we immediately obtain that does_not_halt_in_peano is true.

To prove that it is not a theorem, we again use the fact that godel_peano.py does not halt on empty input. This tells us that, at Line 11, the call to the function

is_theorem_peano(does_not_halt_in_peano)

cannot return yes. But this immediately implies that does_not_halt_in_peano is not provable, which completes the proof.

∎

We have just shown that Peano\textbf{Peano} is incomplete, as we already anticipated in Table 4.1. We explore the consequences of this fact in detail in Section 5.4. However, let us pause for a moment to analyze what we have just proved.

5.2 #Semantic version

To find a true and unprovable formula, we have needed a logical system that is, first of all, recursively axiomatizable. Otherwise, we would not have been able to create a program capable of knowing when a formula of the system is a theorem. On the other hand, we have assumed that the system is sound, which is to be expected. We also need effective translations of statements about programs and a formal account of finite-computation verification (see Proposition 4.24). We collect these conditions in the following definition of a “Turing-type” system.

Definition5.3—Turing-type system

Let S\mathcal{S} be a formal system with effective syntax and classical logic. We say that S\mathcal{S} is of Turing type2 if it admits an effective encoding of programs and computations3 with these properties:

  • Given a program PP, we can computably construct a sentence HPH_P expressing “PP halts on empty input” and a sentence APA_P expressing “PP accepts on empty input”.
  • The system can verify finite computations: if PP halts on empty input, S⊢HP\mathcal{S}\vdash H_P; if it accepts, S⊢AP\mathcal{S}\vdash A_P; if it rejects, S⊢¬AP\mathcal{S}\vdash\neg A_P.

For a logical system, we also require HPH_P and APA_P to have those meanings in its interpretation. This definition does not require the system to settle nonterminating computations.

Merely being able to write these statements in the language is insufficient: we need a computable translation and the stated provability properties for finite runs. A classical theory extending Robinson arithmetic QQ admits an encoding with these properties.4

To understand the last condition, we can encode APA_P as “there is an accepting computation before any rejection”. If PP accepts, a finite trace supplies a witness. If it rejects after rr steps, we can verify that it did not accept before rr and that any later acceptance would already have an earlier rejection; that same trace lets the theory prove ¬AP\neg A_P. The ability to formalize this reasoning is part of the hypothesis, rather than a consequence of consistency alone.

Observe that, however, at no point have we used the system Peano\textbf{Peano} itself. This indicates that we could carry out this proof with another system that is not Peano\textbf{Peano}, as long as it satisfies such conditions. We state this result below.

Theorem5.4—Semantic First Incompleteness Theorem

Let G\mathcal{G} be a logical system satisfying the following conditions:

  1. G\mathcal{G} is sound.
  2. G\mathcal{G} is recursively axiomatizable.
  3. G\mathcal{G} is of Turing type.

Then G\mathcal{G} is incomplete, i.e., there exist true formulas of G\mathcal{G} that are not theorems.

To reinforce this important result, we include a summary of the process we have followed for Peano\textbf{Peano}, in general form, in the proof of this theorem.

Proof

In Program 5.2 we import two functions. On the one hand, at Line 3 we import the function is_theorem_in_G, which checks whether a formula is a theorem in G\mathcal{G}. This function halts if the formula is a theorem, and runs indefinitely otherwise. The existence of this function is guaranteed by (2).

On the other, at Line 4 we import the function halting_to_G which, given a program PP, converts the statement “PP halts on empty input” into a formula of G\mathcal{G}, which is possible by (3).

At Line 9 we have that:

does_not_halt_in_G means that “semantic_incomplete.py does not halt on empty input” (in G\mathcal{G})

(⋆3)(\star 3)

If does_not_halt_in_G is a theorem, the function is_theorem_in_G(does_not_halt_in_G) (Line 11) halts and returns yes, while the same function loops if it is not a theorem.

The question we must ask is: what happens to semantic_incomplete.py when input is empty?

If we assume that semantic_incomplete.py halts on empty input, the only way it can do so is because at Line 11 we have is_theorem_in_G(does_not_halt_in_G) == 'yes', which can only happen if does_not_halt_in_G is a theorem. But, by (1), and since G\mathcal{G} is sound, we have that does_not_halt_in_G is true.

But if does_not_halt_in_G is true, by (⋆3)(\star 3), this would mean that semantic_incomplete.py does not halt on empty input, entering into contradiction, so it must be:

semantic_incomplete.py does not halt on empty input

(⋆4)(\star 4)

We verify that does_not_halt_in_G is true but is not a theorem. Indeed, it is true by (⋆4)(\star 4). However, it is not a theorem. For this, we again use (⋆4)(\star 4). The fact that semantic_incomplete.py does not halt indicates that it is impossible for the condition at Line 11, is_theorem_in_G(does_not_halt_in_G) == 'yes', to hold—in other words, does_not_halt_in_G is not a theorem.

∎
import utilities
 
from is_theorem_G import is_theorem_G  # NOT an oracle
from halting_to_G import halting_to_G      # NOT an oracle
 
def semantic_incomplete(input):
program = utilities.read('semantic_incomplete.py')
halts_in_G = halting_to_G(program)
does_not_halt_in_G = 'NOT (' + halts_in_G + ')'
 
if is_theorem_G(does_not_halt_in_G) == 'yes':
return 'halts'
else:
utilities.loop_forever()

Our result tells us that, if we have a logical system that is recursively axiomatizable and of Turing type, we cannot expect it to be both sound and complete at the same time. That is, if all theorems of the system are true, we will always be able to find formulas of the system that are true but are not theorems.

We can apply the Theorem 5.4 to other logical systems, as long as they satisfy the hypotheses. One of them is, for example, the Zermelo–Fraenkel axiom system.

5.3 #Syntactic version

The previous result uses soundness. We now want syntactic incompleteness under the weaker assumption of consistency. The distinction matters: a consistent system can prove false statements without proving a contradiction.

First we need a procedure to decide theoremhood if we additionally assume that the system is complete.

Proposition5.5

Let S\mathcal{S} be a classical formal system with effective syntax that is recursively axiomatizable, syntactically consistent, and syntactically complete. Then IsTheoremS\textsc{IsTheorem}_\mathcal{S}, restricted to sentences of its language, is decidable.

Proof

The theorems of S\mathcal{S} can be effectively enumerated. If its axioms are merely computably enumerable, interleave axiom enumeration with the generation of finite derivations: at stage nn, inspect derivations of size bounded by nn from the axioms obtained so far. Every finite proof is eventually considered.

To decide whether a sentence ϕ\phi is a theorem, enumerate conclusions until either ϕ\phi or ¬ϕ\neg\phi appears. Completeness ensures that one appears; consistency ensures that they do not both appear. Return yes on finding ϕ\phi, or no on finding ¬ϕ\neg\phi.

Program 5.3 expresses this procedure. At Line 1, we use an enumerator that eventually produces every theorem, and at Line 5, we construct the sentence's syntactic negation. We do not assume a decidable proof checker without specifying how the use of enumerable axioms is certified.

∎
Program5.3—is_theorem_S.py — pseudocode
from enumerate_theorems_S import enumerate_theorems_S  # NOT an oracle
from syntax_S import negate
 
def is_theorem_S(formula):
negated_formula = negate(formula)
for theorem in enumerate_theorems_S():
if theorem == formula:
return 'yes'
if theorem == negated_formula:
return 'no'

We now use the impossibility of solving GuessConsistent with a total computable predictor (Proposition 3.28).5

Theorem5.6—Syntactic First Incompleteness Theorem

Let S\mathcal{S} be a formal system satisfying these conditions:

  1. S\mathcal{S} is syntactically consistent.
  2. S\mathcal{S} is recursively axiomatizable.
  3. S\mathcal{S} is of Turing type in the sense of Definition 5.3.

Then S\mathcal{S} is syntactically incomplete: there is a sentence ϕ\phi such that neither ϕ\phi nor ¬ϕ\neg\phi is a theorem.

Proof

Suppose, for a contradiction, that S\mathcal{S} is syntactically complete. By Proposition 5.5, we can decide theoremhood for its sentences.

Given a program PP, effectively construct the sentence APA_P expressing “PP accepts on empty input”. Program 5.4 returns yes if S⊢AP\mathcal{S}\vdash A_P and no otherwise. It does not run PP.

Check the requirements of GuessConsistent:

  • If PP accepts, verification of its finite computation gives S⊢AP\mathcal{S}\vdash A_P. The predictor returns yes.
  • If PP rejects, that verification gives S⊢¬AP\mathcal{S}\vdash\neg A_P. Consistency rules out S⊢AP\mathcal{S}\vdash A_P, so the predictor returns no.
  • If PP loops, either answer is allowed. The predictor still halts, because the theoremhood procedure is total under the assumed completeness.

This would give a total computable predictor for GuessConsistent, contradicting Proposition 3.28. Therefore S\mathcal{S} cannot be complete.

∎
Program5.4—guess_consistent.py — pseudocode
from acceptance_to_S import acceptance_to_S  # effective translation
from is_theorem_S import is_theorem_S  # under the completeness assumption
 
def guess_consistent(program):
accepts_formula = acceptance_to_S(program)
return is_theorem_S(accepts_formula)

The case of looping programs is essential. We have not assumed that a proof of halting implies actual halting, or that the system can recognize every infinite run. Querying a proof of halting and then running the program could leave the predictor stuck: consistency alone does not guarantee the truth of that proof. Here the answer depends only on a proof search that terminates by the assumed completeness.

We have proved two versions of the First Incompleteness Theorem. We summarize the differences between them below.

Theorem 5.4 Theorem 5.6
System type G\mathcal{G} logical system S\mathcal{S} formal system
Hypotheses rec. axiom., of Turing type, and sound rec. axiom., of Turing type, and syntactically consistent
Logical condition ϕ theorem⇒ϕ true\phi\text{ theorem}\Rightarrow\phi\text{ true} ∄ϕ:ϕ and ¬ϕ are theorems\nexists\phi:\phi\text{ and }\neg\phi\text{ are theorems}
Conclusion G\mathcal{G} not (semantically) complete: ∃ϕ:ϕ is true and is not a theorem\exists\phi:\phi\text{ is true and is not a theorem} S\mathcal{S} not syntactically complete: ∃ϕ:neither ϕ nor ¬ϕ is a theorem\exists\phi:\text{neither }\phi\text{ nor }\neg\phi\text{ is a theorem}
Table 5.1. Comparison of the two versions of the First Incompleteness Theorem

The corresponding classical formulation is the Gödel–Rosser theorem. We state it next with an explicit arithmetic hypothesis.

Theorem5.7—First Incompleteness Theorem (Gödel–Rosser)

Let S\mathcal{S} be a formal system satisfying the following conditions:

  1. S\mathcal{S} is syntactically consistent.
  2. S\mathcal{S} is recursively axiomatizable.
  3. S\mathcal{S} is a classical theory extending Robinson arithmetic QQ.

Then S\mathcal{S} is syntactically incomplete, i.e., there are formulas ϕ\phi of S\mathcal{S} such that neither ϕ\phi nor ¬ϕ\neg\phi is a theorem.

As in our syntactic version, we require that the system be syntactically consistent and recursively axiomatizable. Gödel's original theorem required as a hypothesis a stronger form of syntactic consistency called ω\omega-consistency. This more general form of the theorem is due to the work of John B. Rosser, author of what is today known as the Rosser trick.67

The third hypothesis requires that the system be able to prove certain statements of elementary arithmetic. This is because Gödel intended to prove that no sufficiently expressive, effective, consistent axiomatization of arithmetic could be complete (see Chapter 1), so he used in his proof a way of numbering theorems that is today known as Gödel numbering.

5.4 #Consequences

The First Incompleteness Theorem has profound mathematical and philosophical implications.

5.4.1 #Relationship to Hilbert's second problem

We already introduced Hilbert's celebrated problems in Chapter 1, and in particular the second of them, which we will refer to again below:

  1. Is mathematics complete? That is, can every mathematical sentence be proved or disproved?
  2. Is mathematics consistent? That is, is it impossible to prove simultaneously a statement and its negation?
  3. Is mathematics decidable? That is, does there exist an automatic method that can be applied to any mathematical statement and determine whether it is true? This problem is known as the Entscheidungsproblem.

It is necessary to point out that Hilbert's formulation of this problem is relative to arithmetic. It is clear that, for this case, the Theorem 5.7 guarantees the existence of unprovable formulas, answering (1) negatively8. On the other hand, in Proposition 4.27 we prove that truth in Peano\textbf{Peano} is undecidable, proving that the answer to question (3) is negative. Question (2) falls outside the scope of this work.

However, it is interesting to see these questions without needing to limit ourselves to arithmetic. We introduced logical systems precisely to formalize the concepts of truth and proof, which are the soul of mathematics.

We can find analogous answers for recursively enumerable formal systems of Turing type. In such a case, the Theorem 5.6 answers question (1) negatively, while a generalization of Proposition 4.27 (similar to the one we made in the Theorem 5.4 from the Theorem 5.2) allows us to answer question (3) negatively.

5.4.2 #Relationship to the human mind and the Church–Turing thesis

Some authors draw much more epistemological conclusions, concerning the human mind. Roger Penrose and John Lucas910 argue that the role of consciousness is non-algorithmic when we form mathematical judgments, which can be generalized to the role of human consciousness.

To this end, the authors comment that in any formal system there are unprovable propositions, i.e., ones for which its algorithm cannot provide an answer. If the functioning of the human mind were completely algorithmic, then the algorithm (or formal system) it uses to form its judgments could not handle such a proposition. However, the human mind can deduce that such a proposition is true. This contradiction may indicate that the human mind, as far as mathematical reasoning is concerned, was not using an algorithm in the first place.

Douglas Hofstadter1112 presents Gödel's theorems as an example of a “strange loop”, a hierarchical and self-referential structure that exists in a formal system. He argues that this is the same structure that gives rise to consciousness, the sense of “self”, in the human mind: self-reference comes from the way the brain abstracts and categorizes stimuli into “symbols”, or groups of neurons, that correspond to concepts, in what is de facto a formal system, which eventually forms symbols that correspond to the entity itself that performs the perception.

The difference between mathematics and consciousness resides, according to Hofstadter, in the direction in which reasoning is carried out: whether it is “bottom-up”, from axioms toward more complex propositions and theorems, or “top-down”, in the opposite sense.

Mathematics works bottom-up: to determine whether a formula is a theorem we must start from the axioms and reason until we reach it. The human mind, according to the physicist, works top-down, from a higher level—of desires, concepts, personalities, ideas, and thoughts—down to the lowest level of interactions between neurons and even fundamental particles. Human beings are made to perceive “big things” rather than “small things”, even though in the domain of the small seems to reside the engine of reality.

Both arguments are intimately connected to the Church–Turing thesis (see Section 2.4). If the human mind is a Turing machine, all the procedures of our brain would be nothing more than algorithms, and through Gödel's theorems, our way of reasoning would be limited—there exist statements we cannot prove! This may lead to more fantastical conclusions, with some authors speaking of Gödel's theorems, although they do not allow us to prove it, as strong evidence for the existence of God.13 14

The syntactic-version programs are presented here as updated pseudocode; they are not assumed to match files in the companion intro-to-incompleteness repository.

Footnotes

  1. Barrow, J.D. (1992). Pi in the Sky: Counting, Thinking, and Being. Oxford University Press.

    ↩
  2. We use “of Turing type” as our own shorthand for the effective encoding and computation-verification conditions in the definition; it is not standard terminology.

    ↩
  3. We prove the equivalence in the Theorem 2.23.

    ↩
  4. Open Logic Project. Incompleteness and Computability, chapters on representability in QQ and incompleteness. https://ic.openlogicproject.org/

    ↩
  5. Aaronson, S. (2011). Rosser's Theorem via Turing machines. https://scottaaronson.blog/?p=710

    ↩
  6. This is why we call it the “Gödel–Rosser” theorem, to distinguish it from Gödel's original result.

    ↩
  7. Rosser, B. (1936). Extensions of some theorems of Gödel and Church. The Journal of Symbolic Logic, 1(3):87–91.

    ↩
  8. Hellman, G. (1981). How to Gödel a Frege-Russell: Gödel's Incompleteness Theorems and Logicism. Noûs, 15(4):451–468.

    ↩
  9. Penrose, R. (1989). The Emperor's New Mind: Concerning Computers, Minds, and the Laws of Physics. Oxford University Press.

    ↩
  10. Lucas, J.R. (1961). Minds, machines and Gödel. Philosophy, 36(137):112–127.

    ↩
  11. Hofstadter, D.R. (1999). Gödel, Escher, Bach: An Eternal Golden Braid (20th anniversary ed.). Basic Books.

    ↩
  12. Hofstadter, D.R. (2007). I Am a Strange Loop. Basic Books.

    ↩
  13. There is no consensus on whether this is true, but it is easy to argue the flaws in this reasoning (see Raatikainen 2022).

    ↩
  14. Raatikainen, P. (2022). Gödel's Incompleteness Theorems. In E.N. Zalta (ed.), The Stanford Encyclopedia of Philosophy (Spring 2022). https://plato.stanford.edu/archives/spr2022/entries/goedel-incompleteness/

    ↩