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. □
˙