Lecture 41: First order logic, Gödel's theorem

\[ \newcommand\infer[3][]{ \begin{array}[b]{c c c c} \style{border-bottom:1px solid;}{ \begin{array}[b]{c c c c} #3 \\ \end{array} } & \hspace{-1em}\raise{-0.5em}{\text{#1}} \\ #2 \end{array} } \]

First order logic

Thus far we have studied propositional logic, in which the base propositions are things like \(P\), \(Q\), and \(R\), each of which stands for something that is either true or false: things like "it is cold out" or "7 is prime". We are not able to model predicates like "\(x\) is prime", nor can we reason about statements like "for all \(x\), there exists \(y\) such that \(y\) is a factor of \(x\)".

To handle these kinds of statements, we can extend our logic to add predicates and quantifiers. This extended logic is referred to as predicate logic or first-order logic. We extend the set of formulae:

\[φ ∈ Formulae ::= \cdots \mid P(x_1,x_2,\dots) \mid ∀x, φ \mid ∃x, φ\] where \(x\) is drawn from a fixed set of variables.

The definition of the semantics become more complicated, because interpretations need to assign truth values to predicates applied to values, instead of just assigning truth values to propositions. An interpretation also needs to identify a set \(D\) of values we are considering when we say "\(∀x\)", and it needs to give a truth value for each predicate when applied to each possible set of objects. \(D\) is often referred to as the domain of discourse.

Formally, an interpretation can be modelled as a set \(D\) and a function \(I : Pred \times D \times D \times D \times \cdots → \{T,F\}\).

Once we have a definition of an interpretation, we can talk about the truth of a formula in a given interpretation, as well as validity, entailment, etc.

We can also extend our proof system to prove first-order logical formulas. For example, the introductions and elimination rules for univeral statements are

\[ \infer[($∀$ intro; $y$ must not appear in $φ$)]{\cdots ⊢ ∀x, φ}{\cdots ⊢ φ[y/x]} \qquad \infer[($∀$ elim)]{\cdots ⊢ φ[y/x]}{\cdots ⊢ ∀x, φ} \]

Here \(φ[y/x]\) means "substitute all occurences of \(x\) with \(y\)", or "\(φ\) with \(y\) for \(x\)" for short.

The proof is much more complicated, but you can use the same techniques used in the previous lecture to prove that an extended set of proof rules is sound and complete for first order logic.

Mathematics

First-order logic allows us to reason about mathematical statements. For example, if we had predicates like \(isTimes(x,y,z)\) representing \(xy = z\), and predicates like \(isZero\) and \(isOne\), We could define "\(x\) is prime" as \(∀y,∀z,isTimes(y,z,x) → (isOne(y)∨isOne(z))\). We could then represent the statement "all numbers have a prime factor": \(∀x,∃p,∃y,isTimes(p,y,x)∧∀z,∀w,isTimes(z,w,p)→(isOne(z)∨isOne(w))\).

We believe the statement "all numbers have a prime factor" to be true, but we can't prove it in first-order logic without assuming additional facts about how multiplication, addition, etc. work.

These additional assumptions are called axioms. There is a small set of axioms that are typically used to reason about the natural numbers, they are called the Peano axioms. For example, one of the axioms is that there is at least one natural number (zero): \(∃zero.isZero(zero)\). Another says that every natural number has a successor: \(∀x, ∃y, isSucc(y,x)\). Other axioms say that \(equals\) is an equivalence relation: \(∀x, equals(x,x)\), \(∀x,∀y, equals(x,y)→equals(y,x)\), and \(∀x,∀y,∀z,equals(x,y)∧equals(y,z)→equals(x,z)\). There are a handful of others. These, with induction, allow you to define and prove things about addition, multiplication, etc. For example, one can prove that every number has a prime factorization, or that there are an infinite number of primes (or at least, that every prime has a bigger prime).

Gödel's theorem

We don't expect that every statement is either true in all interpretations or false in all interpretations. For example, we can't prove "it is raining", but nor can we prove "it is not raining"; in some universes, it is raining, and in others it is not.

However, we do believe that mathematical statements are either true or false; there should only be one interpretation of "isZero", and a number either is zero or it isn't. There either are infinitely many twin primes, or there aren't.

It would be good if we could find a nice set of axioms that describe the natural numbers, and that allow us to prove everything that is true about them, and to disprove everything that is false about them. That is, we would like a set of axioms \(A\) such that for any formula \(φ\), either \(A ⊢ φ\) or \(A ⊢ ¬φ\). Confusingly, a set of axioms satisfying this property is also called complete, but this notion is completely different from the completeness of a proof system.

Gödel's theorem says that that is not possible. More accurately, you cannot have a set of axioms that is simultaneously

  1. complete in the sense that for any \(φ\), either \(A ⊨ φ\) or \(A ⊨\lnot φ\)
  2. sound in the sense that if \(A ⊨ φ\) then \(φ\) is true of the natural numbers. For example, you should not be able to prove that every number is prime, or that \(1 = 2\).
  3. computable in the sense that you can write a program that looks at a formula and tells you whether or not it is an axiom.

What this says is that no matter what set of assumptions you make about the natural numbers, there will always be statements that are true, but that you cannot prove (unless you can also prove things that aren't true, but then your proof system is not very useful).