Logic and
Computability
Daniel Naylor
Contents
1 Non-classical Logic
There are no non-experienced truths – L.E.J. Brouwer
1.1 Intuitionistic Logic
Idea: a proof of is a “procedure”
that comments a proof of
into a proof of .
In particular, is not
always the same as .
Fact: The law of excluded middle ()
is not generally intuitionistically valid.
Moreover, the Axiom of Choice is incompatible with intuitionistic set theory.
We take choice to mean that any family of inhabited sets admits a choice function.
Theorem 1.1.1 (Diaconescu).
The law of excluded middle can be intuitionistically deduced from the Axiom
of Choice.
Proof.
Let
be a proposition. By the Axiom of Separation, the following are sets (i.e. we can construct a proof that they
are sets):
|
As
and ,
we have that
is a family of inhabited sets, thus admits a choice function
by the Axiom of Choice. This satisfies
and
by definition.
Thus we have
and .
Now
means that
and similarly for .
We can have the following:
-
(1)
We have a proof of ,
so
has a proof, so we must have a proof of .
-
(2)
We have a proof of ,
which similarly gives a proof of .
-
(3)
We have
and ,
in which case we can prove :
given a proof of ,
we can prove that
(by Extensionality), in which case ,
a contradiction.
So we can always specify a proof of
or a proof of
or a proof of .
□
Why bother?
-
Intuitionistic maths is more general: we assume less.
-
Several notions that are conflated in classical maths are genuinely different constructively.
-
Intuitionistic proofs have a computable content that may be absent in classical proofs.
-
Intuitionistic logic is the internal logic of an arbitrary topos.
Let’s try to formalise the BHK interpretation of logic.
We will inductively define a provability relation by enforcing rules that implement the BHK
interpretation.
We will use the notation to
mean that is a consequence
of the formulae in the set .
Rules for Intuitionistic Propositional Calculus (IPC)
-
(-I)
-
(-I)
,
-
(-E)
and
-
(-E)
-
(-I)
-
(-E)
-
(-E)
for any
-
(Ax)
for any
-
(Weak)
-
(Contr)
We obtain classical propositional logic (CPC) by adding either:
By
we mean ‘if we can prove
assuming and we
can prove assuming
, then we can infer
by “discharging / closing”
the open assumptions
and ’.
In particular, the (-I)-rule
can be written as
We obtain intiuitionistic first-order logic (IQC) by adding rules for quantification:
-
(-I)
,
where
is a term.
-
(-E)
,
if
is not free in .
-
(-I)
if
is not free in .
-
(-E)
,
where
is a term.
Example 1.1.2.
Let’s give a natural deduction proof of
.
|
Example 1.1.3.
Let’s prove the Hilbert-style axioms
and
.
|
(toE) |
|
|
|
(toE) |
|
|
|
(toI,ψ) |
|
|
| (toI, φ→ψ) |
|
|
|
(toI, (φ→(ψ→χ))) |
|
|
|
If is a set of propositions
in the language and is a
proposition, we write ,
,
,
, if there is a
proof of
from in
the respective logic.
Lemma 1.1.4.
Assuming that:
Then . Moreover,
if
is a primitive
proposition and
is any proposition, then
Proof.
Induction over the size of proofs. □
1.2 The simply typed -calculus
For now we assume given a set
of simple types generated by a grammar
where is a countable set of type
variables, as well as an infinite set
of variables.
Definition 1.2.1 (Simply typed lambda-term).
The set
of simply
typed -terms
is defined by the grammar
|
A context is a set of pairs
where the
are (distinct) variables and each .
We write
for the set of all possible contexts. Given a context ,
we also write
for the context
(if
does not appear in ).
The domain of
is the set of variables that occur in it, and the range
is the set of types that it manifests.
Definition 1.2.2 (Typability relation).
We define the typability relation
via:
-
(1)
For every
context ,
and variable
not occurring in
,
and
type ,
we have
.
-
(2)
Let
be a
context,
a variable not occurring in
,
and let
be
types, and
be a
-term.
If
,
then
.
-
(3)
Let
be a context,
be types, and
be
terms. If
and
,
then
.
A variable occurring
in a -abstraction
is bound, and it is free
otherwise. We say that terms
and are
-equivalent
if they differ only in the names of the bound variables.
If and
are
-terms and
is a variable, then we
define the substitution of
for in
by:
-
;
-
if ;
-
for -terms
;
-
,
where
and
is not free in .
Definition 1.2.3 (beta-reduction).
The
-reduction relation is
the smallest relation
on
closed under the following rules:
-
-
if
,
then for all variables
and types
,
we have
,
-
and
as a
-term,
then
and
.
We also define -equivalence
as the smallest equivalence
relation containing .
Example 1.2.4 (Informal).
We have .
When we reduce , the term
being reduced is called a -redex,
and the result is its -contraction.
Lemma 1.2.5 (Free variables lemma).
Assuming that:
Then
-
(1)
If ,
then .
-
(2)
The free variables of
occur in .
-
(3)
There is a context
comprising exactly the free variables in ,
with .
Lemma 1.2.6 (Generation Lemma).
-
(1)
For every variable
,
context ,
and
type ,
if
,
then
;
-
(2)
If
,
then there is a type
such that
and
;
-
(3)
If
,
then there are
types
and
such that
and
.
Lemma 1.2.7 (Substitution Lemma).
-
(1)
If
and
is a
type variable, then
;
-
(2)
If
and
,
then
.
Proposition 1.2.8 (Subject reduction).
Assuming that:
Proof.
By induction on the derivation of ,
using Lemma 1.2.6 and Lemma 1.2.7. □
Theorem 1.2.9 (Church-Rosser for lambda(->)).
Assuming that:
Then there is a
-term
such
that
,
, and
.
Pictorially:
Definition (-normal form).
A -term
is in -normal
form if there is no term
such that .
Proposition 1.2.11 (Uniqueness of types).
-
(1)
If
and
,
then
.
-
(2)
If
,
,
and
,
then
.
Example 1.2.12.
There is no way to assign a type to
. If
is of type
, then in
order to apply
to , it has to
be of type
for some .
But .
Definition 1.2.13 (Height).
The height function is the recursively defined map
that maps a type variable to ,
and a function type
to .
We extend the height function from types to -redexes
by taking the height of its -abstraction.
Not.: .
Theorem 1.2.14 (Weak normalisation for lambda(->)).
Assuming that:
Proof (“Taming the Hydra”).
The idea is to apply induction on the complexity of
. Define
a function
by
|
where
is the greatest height of a redex in ,
and
is the number of redexes in
of that height.
We will use induction over
to show that if
is typable, then it admits a reduction to -normal
form.
Problem: reductions can copy redexes or create new ones.
Strategy: always reduce the right most redex of maximum height.
We will argue that by following this strategy, any new redexes we generate have to be lower than the
height of the redex we picked to reduce.
If and
is already in
-normal form, then claim
is trivially true. If is
not in -normal form, let
be the rightmost redex
of maximal height .
By reducing ,
we may introduce copies of existing redexes, or create new ones. Creation of new redexes of
has to
happen in one of the following ways:
-
(1)
If
is of the form ,
then it reduces to ,
in which case there is a new redex of height .
-
(2)
We have
occurring in
in the scenario .
Say
reduces to .
Then we create a new redex of height .
-
(3)
The last possibility is that ,
and that it occurs in
as .
Reduction then gives the redex
of height .
Now itself is gone
(lowering the count by ),
and we just showed that any newly created redexes have height
.
If we have and
contains multiple free
occurrences of , then all the
redexes in are multiplied
when performing -reduction.
However, our choice of ensures that
the height of any such redex in
has height , as they
occur to the right of in
. It is this always the case that
(in the lexicographic order), so
by the induction hypothesis,
can be reduced to -normal
form (and thus so can ).
□
Theorem 1.2.15 (Strong Normalisation for lambda(->)).
Assuming that:
Then there is no infinite reduction sequence
.
Proof.
See Example Sheet 1. □
1.3 The Curry-Howard Correspondence
Propositions-as-types: idea is to think of
as the “type of its proofs”.
The properties of the STC
match the rules of IPC rather precisely.
First we will show a correspondence between
and the implication fragment IPC
of IPC that includes only the
connective, the axiom scheme, and the
and
rules. We will later extend this to the whole of IPC by introducing more complex types to
.
Start with IPC and build
a STC out of it whose
set of type variables
is precisely the set of primitive propositions of the logic.
Clearly, the set
of types then matches the set of propositions in the logic.
Comment:
if is not
free in .
Proposition 1.3.1 (Curry-Howard for IPC(->)).
Assuming that:
Then
-
(1)
If ,
then
-
(2)
If ,
then there is a simply typed -term
such that .
Proof.
-
(1)
We induct over the derivation of .
If
is a variable not occurring in
and the derivation is of the form ,
then we’re supposed to prove that .
But that follows from
as .
If the derivation has
of the form
and ,
then we must have .
By the induction hypothesis, we have that ,
i.e. .
But then
by (-I).
If the derivation has the form ,
then we must have
and .
By the induction hypothesis, we have that
and ,
so
by (-E).
-
(2)
Again, we induct over the derivation of .
Write .
Then we only have a few ways to construct a proof at a given stage. Say the derivation is of the form
.
If ,
then clearly ,
and if
then .
Suppose the derivation is at a stage of the form
Then by the induction hypothesis, there are -terms
and
such that
and ,
from which .
Finally, if the stage is given by
then we have two sub-cases:
-
If ,
then the induction hypothesis gives
for some term .
By weakening, we have ,
where
does not occur in .
But then
as needed.
-
If ,
then the induction hypothesis gives
for some ,
thus
as needed. □
Example 1.3.2.
Let be
primitive propositions. The -term
|
has type ,
and therefore encodes a proof of that proposition in IPC().
,
.
|
(toE) |
|
|
|
(toE) |
|
|
| (toI, φ→ψ) |
|
|
| (toI, (φ→ψ) →φ) |
|
|
|
Definition 1.3.3 (Full STlambdaC).
The types of the full simply typed
-calculus
are generated by the following grammar:
where
is a set of type variables (usually countable).
Its terms are given by
given by:
|
where
is an infinite set of variables, and
is a constant.
We have new typing rules:
-
-
-
-
-
-
-
-
for each
They come with new reduction rules:
-
Projections:
and
-
Pairs:
-
Definition by cases:
and
-
Unit: If ,
then
When setting up Curry-Howard with these new types, we let:
Example 1.3.4.
Consider the following proof of :
|
() |
|
|
| () |
|
|
|
We decorate this proof by turning the assumptions into variables and following the Curry-Howard
correspondence:
|
() |
|
|
| () |
|
|
|
STC |
IPC |
|
|
(primitive) types |
(primitive) propositions |
variable |
hypothesis |
ST-term | proof |
type constructor | logical connective |
term inhabitation |
provability |
term reduction |
proof normalisation |
1.4 Semantics for IPC
Definition 1.4.1 (Lattice).
A lattice is a set
equipped with binary commutative and associative operations
and
that
satisfy the absorption laws:
for all .
A lattice is:
-
Distributive if
for all .
-
Bounded if there are elements
such that
and .
-
Complemented if it is bounded and for every
there is
such that
and .
A Boolean algebra is a complemented distributive lattice.
Note that
and
are idempotent in any lattice. Moreover, we can define an ordering on
by
setting
if .
Proposition 1.4.3.
Assuming that:
Then is a partial order
with least element
,
greatest element
,
and for any
,
we have
and
.
Conversely, every partial order with all finite infs and sups is a
bounded lattice.
Classically, we say that
if for every valuation
with for
all we
have .
We might want to replace
with some other Boolean algebra to get a semantics for IPC, with an accompanying Completeness Theorem.
But Boolean algebras believe in the Law of Excluded Middle!
Definition 1.4.4 (Heyting algebra).
A Heyting algebra is a bounded lattice equipped with a binary operation
such
that
for all .
A morphism of Heyting algebras is a function that preserves all finite meets, finite joins, and .
Definition 1.4.6 (Valuation in Heyting algebras).
Let
be a Heyting algebra and
be a propositional language
with a set of primitive
propositions. An -valuation
is a function , extended
to the whole of
recursively by setting:
-
,
-
,
-
,
-
A proposition
is -valid
if for all
-valuations
, and is an
-consequence of a (finite)
set of propositions
if for all
-valuations
(written
).
Lemma 1.4.7 (Soundness of Heyting semantics).
Assuming that:
Then
implies
.
Proof.
By induction over the structure of the proof
.
-
(Ax)
As
for any
and .
-
(-I)
and we have derivations ,
,
with .
By the induction hypothesis, we have ,
i.e. .
-
(-I)
and so we must have .
By induction hypothesis, we have .
By the definition of ,
this implies ,
i.e. .
-
(-I)
and without loss of generality we have a derivation .
By the induction hypothesis we have ,
but ,
and hence .
-
(-E)
By the induction hypothesis, we have .
-
(-E)
We know that .
From ,
we derive
by definition of .
So if
and ,
then ,
as needed.
-
(-E)
By induction hypothesis: ,
and .
This last fact means that .
Now this is the same as
as Heyting algebras are distributive lattices (see Example Sheet 2), and this is
by the first two inequalities of this paragraph.
-
(-E)
If ,
then ,
in which case
for any
by minimality of
in .
□
Example 1.4.8.
The Law of Excluded Middle is not intuitionistically valid. Let
be a primitive proposition and consider the Heyting algebra given by the topology
on .
We can define a valuation
with ,
in which case .
So . Thus Soundness of Heyting
semantics implies that .
Example 1.4.9.
Peirce’s Law
is not intuitionistically valid.
Take the valuation on the usual topology of
that maps
to and
to
.
Classical completeness:
if and only if .
Intuitionistic completeness: no single finite replacement for
.
Definition (Lindenbaum-Tarski algebra).
Let
be a logical doctrine (CPC, IPC, etc),
be a propositional language, and
be an -theory. The
Lindenbaum-Tarski algebra
is built in the following way:
-
The underlying set of
is the set of equivalence classes
of propositions ,
where
when
and ;
-
If
is a logical connective in the fragment ,
we set
(should check well-defined: exercise).
We’ll be interested in the case ,
, and
.
Proof.
Clearly, and
inherit associativity and
commutativity, so in order for
to be a lattice we need only to check the absorption laws:
Equation ()
is true since
by (-I), and
also by
(-E).
Equation ()
is similar.
Now, for distributivity:
by (-E) followed
by (-E):
|
(-E) |
|
|
| (-E) |
|
|
|
Conversely,
by (-E) followed
by (-I).
□
Proof.
We already saw that
is a distributive lattice, so it remains to show that
gives a Heyting implication, and that
is bounded.
Suppose that ,
i.e. . We want
to show that ,
i.e. .
But that is clear:
|
|
|
|
|
(hyp) |
|
|
| (-I, ) |
|
|
|
Conversely, if , then
we can prove :
|
(-E) |
|
|
|
(hyp) |
|
|
| (-E) |
|
|
|
So defining
provides a Heyting .
The bottom element of
is just :
if is any
element, then
by -E.
The top element is :
if is any
proposition, then
via
□
Theorem 1.4.12 (Completeness of the Heyting semantics).
A proposition is provable in IPC if and only if it is
-valid for every
Heyting algebra .
Proof.
One direction is easy: if ,
then there is a derivation in IPC, thus
for any Heyting algebra
and valuation ,
by Soundness of Heyting semantics. But then
and
is -valid.
For the other direction, consider the Lindenbaum-Tarski algebra
of the empty theory relative to IPC, which is a Heyting algebra by Lemma 1.4.11. We can define a
valuation
by extending ,
to all propositions.
As
is a valuation, it follows by induction (and the construction of )
that
for all propositions.
Now
is valid in every Heyting algebra, and so is valid in
in particular. So ,
hence ,
hence .
□
Given a poset , we
can construct sets
called principal up-sets.
Recall that is a
terminal segment if
for each .
Proposition 1.4.13.
If
is a poset, then the set
can be made into a Heyting algebra.
Proof.
Order the terminal segments by .
Meets and joins are
and ,
so we just need to define .
If ,
define .
If , we
have
which happens if for every
and
we have .
But
is a terminal segment, so this is the same as saying that .
□
Definition 1.4.14 (Kripke model).
Let
be a set of primitive propositions. A Kripke model is a tuple
where
is a poset (whose elements are called “worlds” or “states”, and whose ordering is called the “accessibility
relation”) and
is a binary relation (“forcing”) satisfying the persistence property: if
is such that
and ,
then .
Every valuation
on induces a Kripke
model by setting
is .
Definition 1.4.15 (Forcing relation).
Let
be a Kripke model for a propositional language. We define the extended forcing relation inductively as follows:
-
There is no
with
;
-
if and only if
and
;
-
if and only if
or
;
-
if and only if
implies
for every
.
It is easy to check that the persistence property extends to arbitrary propositions.
Moreover:
-
if and only if
for all .
-
if and only if for every ,
there exists
with .
Notation.
for
a proposition
if all worlds in
force .
Example 1.4.16.
Consider the following Kripke models:
In (1), we have ,
since and
. We also
know that ,
thus .
It is also the case that ,
yet , so
either.
In (2), since
can’t access a
world that forces .
Also either,
as
forces .
So .
In (3), . All
worlds force , and
. So to check the claim we
just need to verify that .
But that is the case, as
and .
Definition 1.4.17 (Filter).
A filter
on a lattice is
a subset of
with the following properties:
A filter is proper if .
A filter
on a Heyting algebra is prime if it is proper and satisfies: whenever
, we can
conclude that
or .
If is a proper filter and
, then there is a prime
filter extending that
still doesn’t contain
(by Zorn’s Lemma).
Lemma 1.4.19.
Assuming that:
Then there is a Kripke model
such that if and
only if
, for every
proposition .
Proof (sketch).
Let
be the set of all prime filters of ,
ordered by inclusion. We write
if and only if
for primitive propositions .
We prove by induction that
if and only if
for arbitrary propositions.
For the implication case, say that
and . Let
be the least
filter containing
and .
Then
|
Note that ,
or else
for some ,
whence
and so
(as
is a terminal segment).
In particular,
is proper. So let
be a prime filter extending
that does not contain
(exists by Zorn’s lemma).
By the induction hypothesis, ,
and since
and
(this )
contains ,
we have that .
But then ,
contradiction.
This settles that
implies .
Conversely, say that .
By the induction hypothesis, ,
and so
(as ).
But then ,
as
is a filter.
So the induction hypothesis gives ,
as needed.
The cases for the other connectives are easy (
needs primality). So
is a Kripke model. Want to show that
if and only if ,
for each .
Conversely, say ,
but .
Since ,
there must be a proper filter that does not contain it. We can extend it to a prime filter
that does not contain it, but then ,
contradiction. □
Theorem 1.4.20 (Completeness of the Kripke semantics).
Assuming that:
Then if and only if
for all Kripke models ,
the condition
implies .
Proof.
Soundness: induction over the complexity of .
Adequacy: Say .
Then
but
for some Heyting algebra
and -valuation
(Theorem 1.4.12). But then Lemma 1.4.19 applied to and
provides a Kripke model
such that ,
but ,
contradicting the hypothesis on every Kripke model. □
1.5 Negative translations
Definition 1.5.1 (Double-negation translation).
We recursively define the
-translation
of a
proposition
in the following way:
Lemma 1.5.2.
Assuming that:
Then the map
preserves
and
.
Proof.
Example Sheet 2. □
Lemma 1.5.3 (Regularisation).
Assuming that:
Then
Proof.
-
(1)
Give
the inherited order, so that ,
,
and
(which are preserved by )
remain the same. We just need to define disjunctions in
properly.
Define
in .
It is easy to show that this gives
in
(as
preserves order), so
is a Heyting algebra.
As every element of
is regular (i.e. ),
it is a Boolean algebra (see Example Sheet 2).
-
(2)
Given a Heyting homomorphism ,
where
is a Boolean algebra, define
as .
It clearly preserves ,
as those operations in
are inherited from .
But we also have
Thus is a morphism of Boolean
algebras. Note that any
provides an element ,
since in
.
Additionally,
for all
(as
is in a Boolean algebra).
Now, if is a morphism of
Boolean algebras with
for all ,
then
for all .
So
is unique with this property. □
In particular, if
is a set, then .
Theorem 1.5.4 (Glivenko’s Theorem).
Assuming that:
Then if
and only if .
Corollary 1.5.5.
Assuming that:
Then if
and only if .
Proof.
Induction over the complexity of formulae. □
Corollary 1.5.6.
CPC is inconsistent if and only if IPC is inconsistent.
Proof.
-
If CPC is inconsistent, then there is
such that
and .
But then
and ,
so .
-
Obvious. □
2 Computability
“If a ‘religion’ is defined to be a system of ideas that contains improvable statements, then Gödel taught us
that mathematics is not only a religion; it is the only religion that can prove itself to be on.” – John
Barrow
2.1 Recursive functions and -computability
Definition 2.1.1 (Partial recursive function).
The class of recursive functions is the smallest class of partial functions
of the form
that contains the basic functions:
and is closed under:
-
Compositions: if
is partial recursive and so are ,
then the function
given by
is partial recursive.
-
Primitive recursion: Given partial recursive functions
and
, the
function
defined by
|
-
Minimisation: Suppose
is partial recursive. Then the function
that maps
to the least
such that
(if it exists) is partial recursive.
Notation: .
The class of functions produced by the same conditions but excluding minimisation is called the class of
primitive recursive functions.
A partial recursive function that is defined everywhere is called a total recursive function.
The terms of the untyped -calculus
are
given by the grammar
where
is a (countable) set of variables.
The notions we previously discussed (-equality,
-reduction,
-reduction,
etc) apply tit for tat.
Example 2.1.2.
Let
and . Then
. This shows that we can have an
infinite reduction chain of -terms.
Question: If ,
, do we
have
and for
some ?
Idea: “Simultaneously reduce” all the redexes in
to get a term .
This might have new redexes, so we can iterate the process to get terms
.
should reduce
to , so we
have . We’ll
see that if
reduces to
in steps,
then .
Using this, we will show (assuming ):
To get there, we want to build
with two properties:
-
(1)
;
-
(2)
If ,
then .
Definition 2.1.3 (Takahashi Translation).
The Takahashi translation
of a
-term
is
recursively defined as follows:
-
(1)
,
for
a variable;
-
(2)
If
is a
redex, then
;
-
(3)
-
(4)
These rules are numbered by order of precedence, in case of ambiguity. We also define
and
.
Note that is not
necessarily in -normal
form, for example if ,
then
|
Lemma 2.1.4.
Assuming that:
Proof.
Induction over the structure of -terms.
□
Proof.
By definition, . By
induction over the structure of ,
we can check that:
-
If is
not a -abstraction,
then ,
-
If ,
then .
□
Lemma 2.1.6.
Assuming that:
Proof.
Induction over the structure of .
We’ll leave the easier cases as exercises, and focus on when
is a redex, or when ,
where
is not a -abstraction
and
with .
Suppose that is a redex. Then
there are three possibilities for .
-
(1)
:
here
by the previous lemma.
-
(2)
, where
: here
. By the induction
hypothesis, ,
so
|
-
(3)
,
where :
is similar.
Now suppose ,
where is not a
-abstraction,
and
with .
Here . If
is not a
-abstraction, the result is
clear. So let . Applying the
induction hypothesis to ,
we get .
Thus
|
Corollary 2.1.7.
If ,
then .
Proof.
Induction over the length of the chain ,
using Lemma 2.1.6. □
Applying this multiple times,
implies
for all .
Theorem 2.1.8.
Assuming that:
Proof.
By induction over .
The base case is clear, as
implies .
For , there is a
term with
. By induction
hypothesis, .
Since , we have
by Lemma 2.1.4.
Thus we get
by the previous observation. Putting it all together:
Theorem 2.1.9 (Church, Rosser, 1936).
Assuming that:
-
are
-terms
such that
Then there is a
-term
such
that
.
Proof.
Say ,
.
Without loss of generality, say .
By Theorem 2.1.8, we have that
and .
But
by successive applications of Lemma 2.1.4 (as ).
So take .
□
Reminder of the picture to think of:
This has some important consequences:
-
If ,
then they
to the same term;
-
If the -normal
form of a term exists, it is unique;
-
We can use this to show that two terms are not -equivalent.
Example.
and
are different terms in
-normal form, so they
can’t be -equivalent.
Definition 2.1.10 (Church numeral).
Let
be a natural number. Its corresponding Church numeral
is the
-term
, where
denotes
Example 2.1.11.
is the ‘function’ that takes
to the identity map.
is the ‘function’ that takes
to itself.
takes a
function to
its -fold
composite .
Definition 2.1.12 (lambda-definability).
A partial function
is -definable
if there is a -term
such that .
Proposition 2.1.13 (Rosser).
Define the following
-term:
Then for all :
Proof.
We’ll show that ,
and leave the rest to you.
First note that
|
So:
In a similar fashion, we can also encode binary truth-values:
Proposition 2.1.14.
Define the -terms:
Then for -terms
and
, we
have
-
(i)
;
-
(ii)
Proof.
Just compute it! □
With this, we can encode logical connectives via:
-
;
-
;
-
.
We can also encode pairs: if we define ,
then and
. However, it is
not true that !
Recursively defining terms within the -calculus
requires a clever idea: we see such a term as a solution to a fixed point equation
where
occurs
somewhere in .
Theorem 2.1.15 (Fixed Point Theorem).
There is a
-term
such that,
for all :
Proof.
Define
If we compute ,
we get:
We call any combinator (i.e. a -term
without free variables)
satisfying the property
for all terms a
fixed-point combinator.
Corollary 2.1.16.
Given a -term
, there is
a -term
such
that .
Proof.
Take .
Then
|
Example 2.1.17.
Suppose
is a -term
encoding a predicate, i.e.
or
for every .
Let’s write down a -termthat
encodes a program that takes a number and computes the next number satisfying the predicate.
First consider
|
where encodes the successor map.
Our goal is to have run on itself.
This can be done by using the term .
Indeed:
|
for every .
Notation.
will
be short hand for
(and the obvious generalisation to any number of variables, labelled in any way).
Proof.
The -th
projection
is definable by .
Successor is implemented by .
The zero map is given by .
Just compute! □
Proof.
Say
is a -term
defining , and
that -terms
define
. Then the
composite map
is definable by the term
|
by inspection. □
Proof.
Suppose
is obtained from
and by
primitive recursion.
and the -terms
and
define
and
respectively.
We need a -term
to keep track of a pair that records the current state of computation: the value of
and the
value of
at that stage.
So define
|
which acts on a pair by updating
the iteration data. Then
ought to be definable by
|
Indeed,
by definition of ,
and since
we have
|
as needed. □
Proof.
Suppose
-defines
,
and that
is defined from
by minimisation: .
We can -define
by implementing an algorithm that searches for the least
in the following way:
First define a term that can check if a Church numeral is
, for
example
You can check that
|
Now we want a term that, on input ,
checks if
and returns
if so, else runs itself on .
If we can do this, running it on input
will perform the search.
Let:
|
and set
|
Note that
|
which is
|
Thus
|
if and
|
otherwise, as
is -defined
by .
Hence
|
if
is defined on .
So
-defines
.
□
Definition 2.1.23 (Godel numbering).
Let
be a first-order language. A Gödel numbering is an injection
that
is:
-
(1)
Computable (assuming some notion of computability for strings of symbols over a finite alphabet);
-
(2)
Its image is a recursive subset of ;
-
(3)
Its inverse (where defined) is also computable.
One way: assign a unique number
to each symbol in
your finite alphabet .
We can then define
Remark.
We can also encode proofs: add a symbol
to the alphabet and
code a proof with lines
as .
Theorem 2.1.24.
Assuming that:
2.2 Decidability in Logic
Recall that a subset
is recursive (or decidable) if its characteristic map is total recursive.
Definition 2.2.1 (Recursively enumerable).
We say that
is
recursively enumerable if any of the following are true:
Note, if and
are both recursively
enumerable, then
is recursive. Note that the set of partial recursive function is countable, so we can fix an enumeration
.
Definition 2.2.3 (Recursive / decidable language).
A language
is recursive if there is an algorithm that decides whether a string of symbols is an -formula.
An -theory
is recursive if membership in
is decidable (for -sentences).
An -theory
is decidable if there is an algorithm for deciding whether .
We will work with recursive from now on.
Theorem 2.2.4 (Craig).
Assuming that:
Proof.
By hypothesis, there is a total recursive
such that the axioms of
are exactly .
Idea: Replace
with something equivalent, but with a shape that lets us retrieve
. Let
for each
and
Then
has the same deductive closure as .
As formulae have finite length, we can check in finite time whether some
is
or some .
By appropriate use of brackets, we can make sure that such an
is “unique” if we are working with some .
In the first case, we halt and say we have a member of .
In the second case, we check if ,
saying we have a member of
if so, and that we don’t otherwise.
We can do this because we can scan the list
and check symbol by symbol whether
matches ,
which takes finite time.
If the input is not of the right shape, we halt and decide that it is .
□
Definition 2.2.6 (Language of arithmetic).
The language of arithmetic is the first-order language
with signature
. The base theory of
arithmetic is the -theory
whose
axioms express that:
-
(1)
and
are commutative and associative, with identity elements
and
respectively;
-
(2)
distributes over ;
-
(3)
is a linear ordering compatible with
and ;
-
(4)
;
-
(5)
;
-
(6)
.
The (first-order) theory of Peano arithmetic PA is obtained from
by adding the scheme of
induction: for each -formula
, the
axiom
|
Definition 2.2.7 (Delta0-formula, Sigma1-formula).
A -formula
of PA is one whose quantifiers are bounded, i.e.
or ,
where
is not free in
and
is quantifier free.
We say is a
-formula if there
is a -formula
such
that
It is a -formula
if there is a -formula
such
that
In Example Sheet 4, you will prove that the characteristic function of a
-definable set is partial recursive.
We will show that the -definable
sets are precisely the recursively enumerable ones.
Recall that defining yields
a total recursive bijection .
Applying this a bunch of times, we get total recursive bijections
by
.
This is not good, as we have a different function for each
. We’d
like a “pairing function” that lets us see a number as a code for a sequence of any length.
This can be done within any model of PA by using a single function
(known as
Gödel’s -function)
which is definable in PA.
We want an arithmetic procedure that can associate a code to sequences of any length, and such that the
entries of the sequence can be recovered from the code.
We will do this by a clever application of the Chinese Remainder Theorem.
Suppose given a sequence of natural
numbers. We want numbers
to serve as moduli, with ,
and all of which are pairwise coprime. If we can find
such that these conditions
hold, then there is a number
such that .
Taking
works.
We say that the pair
codes the sequence.
Definition 2.2.8 (beta indexing).
The function
is defined by ,
where
and
are the unique numbers such that .
Remark.
The forumula is
given in PA by a -formula.
We will use the notation
for ; thus the decoding
property is that
if codes
.
Lemma 2.2.9 (Godel’s Lemma).
Assuming that:
Then there is
such that
for all .
Theorem 2.2.10.
Assuming that:
Then is recursive if and
only if
there is a -formula
such
that .
Proof.
-
Suppose that
is -definable
by
(so ).
The function
is primitive recursive. By minimisation, the function
|
is partial recursive.
Since for
tuples , we
have that .
Thus
|
as for each
there is at most one
such that .
Now ,
so
whenever defined. So
is partial recursive.
-
We will show that the class of all functions with -graphs
contains the basic functions and is closed under composition, primitive recursion, and minimisation.
The graphs of zero, successor, and -th
projection are the formulae ,
,
and
respectively, so are -definable.
If and
all have
-graphs,
then the graph of the composite is given by:
|
This is equal to a -formula,
as those are closed under .
If is
obtained by primitive recursion
|
where and
have
-graphs,
then we can use Godel’s Lemma to show that the graph of
is
given by
|
We do this by coding the sequence
by . This formula is
equal to a -formula
since:
-
(1)
is ;
-
(2)
If the graph of
is defined by
with ,
then
|
is equal to
|
as we can take
to be the maximum between suitable
with ,
,
with .
A similar argument gives closure under minimisation.
If is
and the graph
of is definable
by a -formula,
then the graph of
is definable by
|
by using Godel’s Lemma to code .
Again, this is equal to a -formula
if the graph of
is given by
with ,
then is
equal in
to
|
Corollary 2.2.11.
A subset is recursively
enumerable if and only if there is a -formula
such that,
given , we
have if and
only if .
Proof.
-
If
is recursively enumerable, then there is a recursive
such that .
Given ,
we thus have
if and only if .
But
is equal to a -formula
by Theorem 2.2.10.
-
Conversely, if
is defined in
by a -formula
,
define
if ,
and
otherwise. The graph of
is given by ,
which is ,
and so
is recursive by Theorem 2.2.10. But ,
so
is recursively enumerable. □
Any model of PA
includes a copy of
inside of it: consider the standard natural numbers
In fact, embeds
in any model PA
as an initial segment: essentially because
|
In Example Sheet 4, you will see that
is a -elementary substructure
of any model of PA:
every -sentence
true in
is also
true in the model.
Definition 2.2.12 (Representation of a total function).
Let
be total
and be any
-theory
extending PA.
We say that is
represented in
if there is an
formula such
that, for all :
Lemma 2.2.13.
Every total recursive function
is -represented
in PA.
Proof.
The graph of
is given by a -formula
by Theorem 2.2.10, say
where .
Without loss of generality, we may assume that
is a single variable (for example, rewrite ).
Let be the
-formula
|
Then the -formula
represents
in PA.
We show
first, where .
Note that
is the unique element of
such that ,
as
is a function.
Take
to be the first natural number such that .
Then
too, whence .
But any -sentence
true in
is true in any model of PA(c.f.
Example Sheet 4), so ,
i.e. .
To see that ,
let
be the first number such that ,
where .
Suppose ,
with .
We will show that .
Completeness settles the claim. Again,
is a -sentence
true in ,
thus true in .
Using the fact that
is a linear ordering in ,
we have ,
so
(as
is an initial segment of ).
Now ,
hence
and thus .
Thus
as needed. □
Lemma 2.2.15 (Diagonalisation Lemma).
Assuming that:
-
-
-
an
-formula
with one free variable
Then there is an
-sentence
such
that
Moreover, if is a
-formula, then
we can take to
be a -sentence.
Proof.
Define a total recursive function
this way: on input ,
check if
is the Gödel numbering of some -formula
.
If so, return ,
else return .
As is total recursive,
it is -represented
in by
some .
Consider the formula
Let and
. This makes
the sentence whose
Gödel numbering is .
It is obvious that ,
so we know that
α |
Now
represents
in , and
by
construction, hence
β |
Combining ()
and (),
we get
as needed.
Finally, note that if ,
then both
and
are equal to a -formula.
□
Theorem 2.2.16 (Crude Incompleteness).
Assuming that:
Then there is a
-sentence
such
that
and
.
Proof.
Let be a
-formula that
represents
in PA,
so that
|
This exists since
is recursive. By the Diagonalisation Lemma, there is a -sentence
such that .
If ,
then ,
and thus .
But then
(as
and
proves it).
If ,
then ,
so ,
and thus .
As
and ,
we have .
Since
is consistent, we can’t have either of
or
in .
□
Corollary 2.2.17 (Godel-Rosser Theorem).
Let
be a consistent
-theory extending
and admitting a recursively
enumerable axiomatisation. Then
is -incomplete:
there is a -sentence
such
that
and .
Proof.
By Craig’s Theorem, we may assume that
is recursive. Suppose that
is -complete,
and consider the set
of (Gödel numberings of) all the
and
sentences in
that
proves.
The set
is recursive: we can effectively decide if a given sentence is
or ,
then check if
by systematically searching through all proofs using the axioms in ,
until we either find a proof of
or a proof of .
Since
is -complete,
there is always such a proof, and we’ll find it in finite time.
But then
satisfies the hypotheses of Theorem 2.2.16, so there is a -sentence
with
and ,
contradicting -completeness
of .
□
Definition 2.2.18 (Recursive structure).
A (countable) -structure
is recursive if there are total recursive functions ,
,
a binary recursive relation ,
and natural numbers
such that
as -structures.
We will show that the usual is
the only recursive model of
(up to ).
Strategy:
-
(1)
Given a countable model
of ,
we note that we encode subsets of
as elements of ;
-
(2)
If
is non-standard, then there is an element that codes a non-recursive set;
-
(3)
If
also has recursive ,
then there is a membership decision procedure for any subset that it codes.
Note that there is a -formula
that captures
being
the -th
prime, and .
So if thinks
that is the
-th prime, then any
model of thinks
so too. Write
for the -th
prime.
Lemma 2.2.19 (Overspill).
Assuming that:
Then there is a nonstandard natural number
such that .
Proof.
Say
for all standard ,
but only them. Then
and
holds (if
holds, then
and hence
are standard).
By
(induction), we conclude that .
But
is non-standard, so there is non-standard
with ,
contradiction. □
Fix some , and
a property
of the natural numbers.
-
There is a number
such that ,
namely the product of all primes
with
and .
-
We perceive
as a code for the numbers with the property
below ,
which we can decode by prime factorisation.
Definition 2.2.20 (Canonically coded).
A subset
is canonically
coded in a model
of if
there is
such that
where
denotes the standard number
in the model.
We could use other formulas to code subsets. Th subsets of
coded
in are those
for which there
is a -formula
and
such
that .
As it turns out, coding via -formulae
gives nothing new:
Proposition 2.2.21.
Assuming that:
-
-
a non-standard model of
Then given any
,
there is
such
that, for any
:
|
Proof (sketch*).
The following formula holds in
for any :
|
This is by the reasoning we gave when introducing codes, which works due to the bound on
and .
This can be proved in *.
Thus
|
for any . So by Lemma 2.2.19
there is a non-standard
such that
|
So for any ,
there must be
such that
|
Now is
non-standard, so
for all . So
for any
there is
with
|
for all .
□
Definition 2.2.22 (Recursively inseparable).
We say that subsets
are recursively inseparable if they are disjoint and there is no recursive
with
and .
Proof.
Fix an effective enumeration
of the partial recursive functions. Define
and ,
which are clearly disjoint and are clearly recursively enumerable.
Suppose there is a recursive
with
and ,
and write
for its (total recursive) characteristic function. There must be
such that ,
as
is total recursive.
Since
and is either
or ,
we have either
or .
If ,
then ,
so ,
contradicting ;
so .
But then ,
so ,
contradicting .
Thus
and
are recursively inseparable. □
Lemma 2.2.24.
Assuming that:
Then there is a non-
recursive set
which is canonically coded in
.
Proof.
Say
are recursively enumerable and recursively inseparable. By Corollary 2.2.11, there are -formulae
and
defining
and
respectively (so
and
are -formulae).
Fix . As
the sets are disjoint, we have:
|
As this sentence is , it follows,
for any non-standard
and
that:
|
By Overspill, there is some non-standard
such that
|
Now define .
Note that:
-
:
let ,
so that
for some
(a
is defined by ).
Then ,
as
is .
Hence
as any standard
is below
as it is non-standard. But then .
-
:
if ,
then
for some ,
so arguing as before we get .
By (),
we can deduce .
So .
As and
are recursively
inseparable, can’t be
recursive. This shows that
must encode a non-recursive set, which implies that it must canonically encode a non-recursive set by
Proposition 2.2.21. □
Theorem 2.2.25 (Tennenbaum).
Assuming that:
-
a countable non-standard model of
Proof.
As
is countable, we may as well assume that ,
,
.
By Lemma 2.2.24, there is some
that canonically codes a non-recursive subset .
As
proves that
we have that
for all . So
if and only
if there is
such that
Suppose is recursive.
Then we can can through
(which is ) and
look for some
that realises the disjunction of:
|
As
is recursive, we can decide whether the disjunction holds of a given
. Moreover, the
search for such
always terminates:
-
Euclidean division is provable in :
for any
with ,
there are unique
such that
and .
-
|
Combining these, we get that division of
by in
leaves a unique
quotient , and
remainder ,
which is either
or or
or …or
( times);
i.e. one of the disjunctions from before.
Now we see that is recursive:
if our search provides
such that
then , and if the search
gives satisfying one of the
other disjunctions, then .
This contradicts the choice of ,
so can’t
be recursive. □
˙
Index
Gödel numbering
PA
-equivalent
Boolean algebra
-contraction
bounded
-normal
form
-redex
-reduction
base theory of arithmetic
canonically coded
Church numeral
complemented
composition
context
decide
decidable
decidable
distributive
filter
force
forcing
fixed-point combinator
Heyting algebra
height
Heyting homomorphism
-valid
-valuation
IPC
Kripke model
-abstraction
-application
lattice
-definable
-define
lpa
Lindenbaum-Tarski algebra
-term
minimisation
persistence
partial recursive
partial recursive function
prime
primitive recursion
primitive recursive
principal
projection
proper
principal up-set
recursive
recursive
recursive
reduces
redex
reduction
recursively enumerable
represent
represented
representable
representation
recursively inseparable
state
simply typed -term
successor
term
total recursive
typability relation
terminal segment
Takahashi translation
type
-term
term
valuation
world
zero