A Problem Course in Mathematical Logic: Stefan Bilaniuk
A Problem Course in Mathematical Logic: Stefan Bilaniuk
A Problem Course in Mathematical Logic: Stefan Bilaniuk
in
Mathematical Logic
Volume II
Computability and Incompleteness
Stefan Bilaniuk
Author address:
Department of Mathematics
Trent University
Peterborough, Ontario
Canada K9J 7B8
E-mail address: [email protected]
1991 Mathematics Subject Classification. 03.
Preface v
Introduction 1
Computability 5
Chapter 10. Turing Machines 7
Chapter 11. Variations and Simulations 13
Chapter 12. Universal Turing Machines and the Halting Problem 17
Chapter 13. Computable and Non-Computable Functions 25
Chapter 14. Primitive Recursive Functions 29
Chapter 15. Recursive Functions 35
Incompleteness 41
Chapter 16. Preliminaries 43
Chapter 17. Coding First-Order Logic 45
Chapter 18. Defining Recursive Functions In Arithmetic 49
Chapter 19. The Incompleteness Theorem 53
Hints 57
Chapter 10. Hints 59
Chapter 11. Hints 61
Chapter 12. Hints 63
Chapter 13. Hints 65
Chapter 14. Hints 67
Chapter 15. Hints 69
iii
iv CONTENTS
Turing Machines
That is, M(s, c) = (b, d, t) means that if our machine is in state s (i.e.
executing instruction number s), scanning the ith cell, and ai = c (i.e.
cell i contains c), then the machine M should
• set ai = b (i.e. write b instead of c in the scanned cell), then
• move the scanner to ai+d (i.e. move one cell left if d = −1 and
one cell right if d = 1), and then
• enter state t (i.e. go to instruction t).
If our processor isn’t equipped to handle input c for instruction s (i.e.
M(s, a) is undefined), then the computation in progress will simply
stop dead.
Example 10.2. We will usually present Turing machines in the
form of a table, with a row for each state and a column for each possible
entry in the scanned cell. Instead of −1 and 1, we will usually use L
and R when writing such tables in order to make them more readable.
Thus the table
M 0 1
1 1R2 0R1
2 0L2
defines a Turing machine M with alphabet {1} and two states such that
M(1, 0) = (1, 1, 2), M(1, 1) = (0, 1, 1), and M(2, 0) = (0, −1, 2), but
M(2, 1) is undefined. (So M has domain { (1, 0), (1, 1), (2, 0) } and
range { (1, 1, 2), (0, 1, 1), (0, −1, 2) }.) If the machine M were faced
with the tape position
01001111 : 1 ,
it would, being in state 1 and scanning a cell containing 0,
• write a 1 in the scanned cell,
• move the scanner one cell to the right, and
• go to state 2.
This would give the new tape position
01011111 : 2 .
Since M doesn’t know what to do on input 1 in state 2, the computation
could go no further.
Problem 10.3. In each case, give the table of a Turing machine
M meeting the given requirement.
1. M has alphabet {x, y, z} and has three states.
2. M has alphabet {1} and changes 0 to 1 and vice versa in any
cell it scans.
3. M is as simple as possible. How many possibilities are there
here?
10. TURING MACHINES 11
3. The tape with all cells marked with 1s and cell 5 being scanned.
Problem 10.5. For which possible input tapes does the partial com-
putation of the Turing machine M of Example 10.2 eventually termi-
nate?
Problem 10.6. Find a Turing machine that (eventually!) fills a
blank input tape with the pattern xyyz3xyyz3xyyz3 . . . .
Problem 10.7. Find a Turing machine with alphabet {$, @}that
never halts, no matter what is on the tape.
Example 10.4. The Turing machine P given below is intended to
produce output 01m on input 01n 01m whenever n, m > 0.
P 0 1
1 0R2
2 1R3
3 0R4 0R3
4 0R4 0R5
5 0L8 1L6
6 0L6 1R7
7 1R4
8 0L8 1L9
9 1L9
Trace P ’s computation on, say, input 013 014 to see how it works.
Problem 10.8. In each case, find a Turing machine (with the al-
phabet of your choice) that:
1. Halts with output 014 on input 0.
2. Halts with output 01n 0 on input 00n 1.
3. Halts with output 012n on input 01n .
4. Halts with output 0(10)n on input 01n .
5. Halts with output 01m 01n on input 01m 0k 1n , if n, m, k > 0.
6. Halts with output 01m 01n 01k on input 01n 01k 01m , if n, m, k > 0.
7. Halts with output 01m 01n 01k 01m 01n 01k on input 01m 01n 01k , if
n, m, k > 0.
8. On input 01m 01n , where m, n > 0, halts with output 01 if m 6= n
and output 011 if m = n.
It is quite possible to find such machines with just {1} as an alphabet.
Note. It doesn’t matter what the machine you define in each case
does on other inputs, so long as it does the right thing on the given
one(s).
CHAPTER 11
M0 0 1
1 1R2 0R3
2 0L2 1L1
3 0L4 1L4
4 0L1
This machine is just like M except that in state 1 with input 1,
instead of moving the scanner to the left and going to state 1, the
machine moves the scanner to the right and goes to the new state 3.
States 3 and 4 do nothing between them except move the scanner two
cells to the left without changing the tape, thus putting it where M
would have put it, and then entering state 1, as M would have.
Problem 11.1. Compare the computations of the machines M and
M 0 of Example 11.1 on the input tapes
1. 0
2. 011
and explain why is it not necessary to define M 0 for state 4 on input 1.
Problem 11.2. Given a Turing machine M with an arbitrary al-
phabet Σ, explain in detail how to construct a machine M 0 that simu-
lates what M does on any input, but which moves the scanner only to
one of left or right in each state.
Problem 11.3. Given a Turing machine M with an arbitrary al-
phabet Σ, explain in detail how to construct a machine N with alphabet
{1} that simulates M.
To define Turing machines with two-way infinite tapes we need
only change the definition of the tape: instead of having tapes be se-
quences a = ha0, a1, a2, . . . i indexed by N, we let them be sequences
b = h. . . , b−2, b−1 , b0, b1 , b2, . . . i indexed by Z. In defining computa-
tions for machines with two-way infinite tapes, we adopt the same
conventions that we did for machines with one-way infinite tapes, such
as the scanner starts off scanning cell 0 on the input tape. The only
real difference is that a machine with a two-way infinite tape cannot
halt by running off the left end of the tape . . .
Example 11.2. Consider the following two-way infinite tape Tur-
ing machine with alphabet {1}:
T 0 1
1 1L1 0R2
2 0R2 1L1
The biggest problem in trying to emulate T with a one-way infinite
tape Turing machine O is representing a two-way infinite tape on a
11. VARIATIONS AND SIMULATIONS 15
2 00 R2 0S R2 00 R2 01 R2 S1 R3 10 L1 11 L1
3 01 R3 1S R3 01 R3 00 L4 S0 R2 11 R3 10 L4
4 00 L4 0S R2 00 L4 01 R3 S1 R3 10 L4 11 R3
States 1 and 3 are the upper- and lower-track versions, respectively,
of T ’s state 1; states 2 and 4 are the upper- and lower-track versions,
respectively, of T ’s state 2. We leave it to the reader to check that O
actually does simulate T . . .
Problem 11.4. Trace the (partial) computations of T , and their
counterparts for O, for each of the following input tapes for T , shown
with a bar over cell 0:
1. 0 (i.e. a blank tape)
2. 10
3. . . . 1111111 . . . (i.e. every cell marked with 1)
Problem 11.5. Explain in detail how, given a Turing machine N
with an arbitrary alphabet and a two-way infinite tape, one can con-
struct a Turing machine P with an one-way infinite tape that simulates
N.
Problem 11.6. Give a precise definition for Turing machines with
two tapes. Explain how, given any such machine, one could construct
a single-tape machine to simulate it.
16 11. VARIATIONS AND SIMULATIONS
Note that the only use of the 1 at the beginning of the represen-
tation of each cell is to mark the fact that a cell is being represented:
moving a scanner along the representation of a, one can identify the be-
ginning and end (if any) of the representation because one encounters
a 0 instead of a 1 marking the representation of another cell.
Problem 12.5. What are the representations of the following tape
positions for a 5-state Turing machine?
1. (0, 4, 11111)
2. (3, 1, 101011)
Problem 12.6. What tape positions are represented by the follow-
ing?
1. 0001100000110100100101101100100101100000
2. 00011111000101111101101101101101 . . .
Problem 12.7. Devise a more efficient way of representing tape
positions than that given in Definition 12.3.
We can now define our representation for M together with a tape
position (i, s, a). Except for inserting some extra 0s, this just amounts
to xMy followed by x(i, s, a)y.
Definition 12.4. Suppose M is an m-state Turing machine with
alphabet {1} and (i, s, a) is a tape position for M (so 1 ≤ s ≤ m). Then
the representation of the machine M together with the tape position
(i, s, a) is the sequence
xMy03m+33 x(i, s, a)y .
The 3m+33 0s interpolated in the middle are intended to be used for
“scratch space” in the simulation of M by the universal Turing machine
we will construct in the following series of problems. Depending on
how these are solved, it may be possible to reduce — or necessary to
increase! — that 3m + 33.
Note. The statements of Problems 12.8–12.13 below assume the
use of the representation schemes given in Definitions 12.2–12.4. If you
would rather use the methods you devised in Problems 12.4 and 12.7,
by all means adapt the statements of Problems 12.8–12.13 accordingly.
You may find it convenient to give the machines you build in these
problems alphabets other than {1}, but one need not do so. (Why
doesn’t it really matter if one does?)
Problem 12.8. Suppose M is an m-state Turing machine with al-
phabet {1}, (i, s, a) is a tape position for M, and d = ±1. Find a
12. UNIVERSAL MACHINES & THE HALTING PROBLEM 21
So far, the only substantial facts we have about what Turing ma-
chines can do is that they can be used to simulate other Turing ma-
chines, but cannot solve the Halting Problem. Neither fact is trivial,
but neither is really interesting unless Turing machines can also be
used to handle more natural computational problems. Arithmetic is a
common source of such problems in the real world; indeed, any notion
of computation that can’t handle it is unlikely to be of great use.
Similarly, all one needs to know about the k-place relation P can be
obtained from its characteristic function :
(
1 if P (n1 , . . . , nk ) is true;
χP (n1 , . . . , nk ) =
0 if P (n1 , . . . , nk ) is false.
P12 acts as follows: it moves to the right past the first block of 1s
without disturbing it, erases the second block of 1s, and then returns
to the left of first block and halts.
The projection function π22 : N2 → N given by π12(n, m) = m is also
computable: the Turing machine P of Example 10.4 does the job.
Problem 13.1. Find Turing machines that compute the following
functions and explain how they work.
1. O(n) = 0.
2. S(n) = n + 1.
3. Sum(n, m) =(n + m.
n−1 n≥ 1
4. Pred(n) = .
0 n=0
(
n−m n≥m
5. Diff(n, m) = .
0 n<m
6. π23(p, q, r) = q.
We will see how to build complex functions computable by Turing
machines out of simpler ones in the next chapter.
A non-computable function. In the meantime, it is worth ask-
ing whether or not every function on the natural numbers is com-
putable. No such luck!
Problem 13.2. Show that there is some 1-place function f which
is not computable by comparing the number of such functions to the
number of Turing machines.
The argument hinted at above is unsatisfying in that it tells us there
is a non-computable function without actually producing an explicit
example. We can have some fun on the way to one.
Definition 13.2 (Busy Beaver Competition). A machine M is an
n-state entry in the busy beaver competition if:
• M has a two-way infinite tape and alphabet {1};
• M has n + 1 states, but state n + 1 is used only for halting (so
both M(n + 1, 0) and M(n + 1, 1) are undefined);
• M eventually halts when given a blank input tape.
M’s score in the competition is the number of 1’s on the output tape of
its computation from a blank input tape. The greatest possible score
of an n-state entry in the competition is denoted by Σ(n).
Note that there are only finitely many possible n-state entries in the
busy beaver competition because there are only finitely many (n + 1)-
state Turing machines with alphabet {1}. Since there is at least one
28 13. COMPUTABLE AND NON-COMPUTABLE FUNCTIONS
1
The best score known to the author as of this writing by a 5-state entry in
the busy beaver competition is 4098. One of the two machines achieving this score
does so in a computation that takes over 40 million steps! The other requires only
11 million or so . . .
CHAPTER 14
Example 14.1. The constant function c11 , where c11 (n) = 1 for all
n, can be obtained by composition from the initial functions S and O.
For any n ∈ N,
c11 (n) = (S ◦ O)(n) = S(O(n)) = S(0) = 0 + 1 = 1 .
Problem 14.2. Suppose k ≥ 1 and a ∈ N. Use composition
to define the constant function cka , where cka (n1 , . . . , nk ) = a for all
(n1 , . . . , nk ) ∈ Nk , from the initial functions.
Proposition 14.3. Suppose that 1 ≤ k, 1 ≤ m, g is a Turing
computable m-place function, and h1, . . . , hm are Turing computable
k-place functions. Then g ◦ (h1 , . . . , hm ) is also Turing computable.
Unfortunately, one can’t do much else of interest using just the
initial functions and composition . . .
Proposition 14.4. Suppose f is a 1-place function obtained from
the initial functions by finitely many applications of composition. Then
there is a constant c ∈ N such that f(n) ≤ n + c for all n ∈ N.
Primitive recursion. Primitive recursion boils down to defining
a function inductively, using different functions to tell us what to do
at the base and inductive steps. Together with composition, it suffices
to build up just about all familiar arithmetic functions from the initial
functions.
Definition 14.3. Suppose that k ≥ 1, g is a k-place function, and
h is a k + 2-place function. Let f be the (k + 1)-place function such
that
1. f(n1 , . . . , nk , 0) = g(n1 , . . . , nk ) and
2. f(n1 , . . . , nk , m + 1) = h(n1 , . . . , nk , m, f(n1, . . . , nk , m)
for every (n1 , . . . , nk ) ∈ Nk and m ∈ N. Then f is said to be obtained
from g and h by primitive recursion.
That is, the initial values of f are given by g, and the rest are given
by h operating on the given input and the preceding value of f.
For a start, primitive recursion and composition let us define addi-
tion and multiplication from the initial functions.
Example 14.2. Sum(n, m) = n + m is obtained by primitive re-
cursion from the initial function π11 and the composition S ◦ π33 of initial
functions as follows:
• Sum(n, 0) = π11(n);
• Sum(n, m + 1) = (S ◦ π33 )(n, m, Sum(n, m)).
14. PRIMITIVE RECURSIVE FUNCTIONS 31
f(n1 , . . . , nk , m) = Πm
i=0 g(n1 , . . . , nk , i)
= g(n1 , . . . , nk , 0) · . . . · g(n1 , . . . , nk , m)
for any (k + 1)-tuple (n1 , . . . , nk , m).(
0 n 6= a
2. For any constant a ∈ N, χ{a}(n) =
1 n = a.
(
f(n1 , . . . , nk ) (n1 , . . . , nk ) 6= (c1 , . . . , ck )
3. h(n1 , . . . , nk ) = , if
a (n1 , . . . , nk ) = (c1 , . . . , ck )
f is a primitive recursive k-place function and a, c1, . . . , ck ∈ N
are constants.
Theorem 14.8. Every primitive recursive function is Turing com-
putable.
Be warned, however, that there are computable functions which are
not primitive recursive.
We can extend the idea of “primitive recursive” to relations by using
their characteristic functions.
Definition 14.5. Suppose k ≥ 1. A k-place relation P ⊆ Nk is
primitive recursive if its characteristic function
(
1 (n1 , . . . , nk ) ∈ P
χP (n1 , . . . , nk ) =
0 (n1 , . . . , nk ) ∈
/P
is primitive recursive.
Example 14.4. P = {2} ⊂ N is primitive recursive since χ{2} is
recursive by Problem 14.7.
Problem 14.9. Show that the following relations and functions are
primitive recursive.
1. ¬P , i.e. Nk \ P , if P is a primitive recursive k-place relation.
2. P ∨ Q, i.e. P ∪ Q, if P and Q are primitive recursive k-place
relations.
3. P ∧ Q, i.e. P ∩ Q, if P and Q are primitive recursive k-place
relations.
14. PRIMITIVE RECURSIVE FUNCTIONS 33
m1 m`
m = p1 . . . p` .
Parts of Problem 14.9 give us tools for representing finite sequences
of integers by single integers, as well as some tools for manipulating
these representations. This lets us reduce, in principle, all problems
involving primitive recursive functions and relations to problems in-
volving only 1-place primitive recursive functions and relations.
Theorem 14.10. A k-place g is primitive recursive if and only if
the 1-place function h given by h(n) = g(n1 , . . . , nk ) if n = pn1 1 . . . pnk k
is primitive recursive.
Note. It doesn’t matter what the function h may do on an n which
does not represent a sequence of length k.
Corollary 14.11. A k-place relation P is primitive recursive if
and only if the 1-place relation P 0 is primitive recursive, where
(n1, . . . , nk ) ∈ P ⇐⇒ pn1 1 . . . pnk k ∈ P 0 .
Computable non-primitive recursive functions. While primi-
tive recursion and composition do not suffice to build up all Turing com-
putable functions from the initial functions, they are powerful enough
that specific counterexamples are not all that easy to find.
Example 14.5 (Ackerman’s Function). Define the 2-place function
A from as follows:
• A(0, `) = S(`)
• A(S(k), 0) = A(k, 1)
• A(S(k), S(`)) = A(k, A(S(k), `))
Given A, define the 1-place function α by α(n) = A(n, n).
34 14. PRIMITIVE RECURSIVE FUNCTIONS
It isn’t too hard to show that A, and hence also α, are Turing
computable. However, though it takes considerable effort to prove it,
α grows faster with n than any primitive recursive function. (Try
working out the first few values of α . . . )
Problem 14.12. Show that the functions A and α defined in Ex-
ample 14.5 are Turing computable.
If you are very ambitious, you can try to prove the following theo-
rem.
Theorem 14.13. Suppose α is the function defined in Example
14.5 and f is any primitive recursive function. Then there is an n ∈ N
such that for all k > n, α(k) > f(k).
Corollary 14.14. The function α defined in Example 14.5 is not
primitive recursive.
. . . but if you aren’t, you can still try the following exercise.
Problem 14.15. Informally, define a computable function which
must be different from every primitive recursive function.
CHAPTER 15
Recursive Functions
Preliminaries
3. Quantifier: ∀
4. Equality: =
5. Variable symbols: v0, v2, v3, . . .
6. Constant symbol: 0
7. 1-place function symbol: S
8. 2-place function symbols: +, ·, and E.
The non-logical symbols of LN , 0, S, +, ·, and E, are intended
to name, respectively, the number zero, and the successor, addition,
multiplication, and exponentiation functions on the natural numbers.
That is, the (standard!) structure this language is intended to discuss
is N = (N, 0, S, +, ·, E).
Note. Notation for and the definitions of terms, formulas, sen-
tences, structures, interpretations, logical axioms, deductions, and so
on, of first-order languages, plus various conventions involving these,
are given in Chapters 5-8 of Volume I. Look them up as (and if) you
need to.
Completeness. The notion of completeness mentioned in the In-
completeness Theorem is different from the one mentioned in the Com-
pleteness Theorem.1 “Completeness” in the latter sense is a property of
a logic: it asserts that whenever Γ |= σ (i.e. the truth of the sentence σ
follows from that of the set of sentences Γ), Γ ` σ (i.e. there is a deduc-
tion of σ from Γ). The sense of “completeness” in the Incompleteness
Theorem, defined below, is a property of a set of sentences.
Definition 16.2. A set of sentences Σ of a first-order language L
is said to be complete if for every sentence τ either Σ ` τ or Σ ` ¬τ .
That is, a set of sentences, or non-logical axioms, is complete if it
suffices to prove or disprove every sentence of the langage in in question.
Problem 16.1. Show that a consistent set Σ of sentences of a first-
order language L is complete if and only if the theory of Σ,
Th(Σ) = { τ | τ is a sentence of L and Σ ` τ } ,
is maximally consistent.
1
Which, to confuse the issue, was also first proved by Gödel.
CHAPTER 17
more work, one could set things up so that no integer was the code of
more than one kind of thing.
We need to show that various relations and functions for recognizing
and manipulating Gödel codes are recursive.
Problem 17.1. Show that each of the following relations is prim-
itive recursive.
1. Term(n) ⇐⇒ n = ptq for some term t of LN .
2. Formula(n) ⇐⇒ n = pϕq for some formula ϕ of LN .
3. Sentence(n) ⇐⇒ n = pσq for some sentence σ of LN .
4. Logical(n) ⇐⇒ n = pγq for some logical axiom γ of LN .
Using these relations as building blocks, we will develop relations
and functions to handle deductions of LN . First, though, we need to
make “a computable set of formulas” precise.
Definition 17.3. A set ∆ of formulas of LN is said to be recursive
if the set of Gödel codes of formulas of ∆,
p∆q = { pδq | δ ∈ ∆ } ,
is recursive. Similarly, ∆ is said to be recursively enumerable if p∆q is
recursively enumerable.
Problem 17.2. Suppose ∆ is a recursive set of sentences of LN .
Show that each of the following relations is recursive.
1. Premiss∆ (n) ⇐⇒ n = pβq for some formula β of LN which
is either a logical axiom or in ∆.
2. Formulas(n) ⇐⇒ n = pϕ1 . . . ϕk q for some sequence ϕ1 . . . ϕk
of formulas of LN .
3. Inference(n, i, j) ⇐⇒ n = pϕ1 . . . ϕk q for some sequence
ϕ1 . . . ϕk of formulas of LN , 1 ≤ i, j ≤ k, and ϕk follows from ϕi
and ϕj by Modus Ponens.
4. Deduction∆ (n) ⇐⇒ n = pϕ1 . . . ϕk q for a deduction ϕ1 . . . ϕk
from ∆ in LN .
5. Conclusion∆ (n, m) ⇐⇒ n = pϕ1 . . . ϕk q for a deduction
ϕ1 . . . ϕk from ∆ in LN and m = pϕk q.
If p∆q is primitive recursive, which of these are primitive recursive?
It is at this point that the connection between computability and
completeness begins to appear.
Theorem 17.3. Suppose ∆ is a recursive set of sentences of LN .
Then pTh(∆)q is
1. recursively enumerable, and
2. recursive if and only if ∆ is complete.
17. CODING FIRST-ORDER LOGIC 47
Problem 18.7. Show that each of the following relations and func-
tions (first defined in Problem 14.9) is representable in Th(A).
1. Div(n, m) ⇐⇒ n | m
2. IsPrime(n) ⇐⇒ n is prime
3. Prime(k) = pk , where p0 = 1 and pk is the kth prime if k ≥ 1.
4. Power(n, m) = k, where k ≥ 0 is maximal such that nk | m.
5. Length(n) = `, where ` is maximal such that p` | n.
6. Element(n, i) = ni , where n = pn1 1 . . . pnk k (and ni = 0 if i > k).
Using the representable functions and relations given above, we can
represent the “history” function of any representable function . . .
Problem 18.8. Suppose f is a k-place function representable in
Th(A). Show that
f (n ,...,n ,0) f (n ,...,nk ,m)
F (n1, . . . , nk , m) = p1 1 k . . . pm+11
Ym
f (n ,...,n ,i)
= pi 1 k
i=0
that the theorems proved in mathematics are really true. This might
be considered as job security for philosophers of mathematics . . .
Truth and definability. A close relative of the Incompleteness
Theorem is the assertion that truth in N = (N, S, +, ·, E, 0) is not
definable in N. To make sense of this, of course, we first need to define
what “definable in N means.
Definition 19.1. A k-place relation is definable in N if there is a
formula ϕ of LN with at most v1, . . . , vk as free variables such that
P (n1 , . . . , nk ) ⇐⇒ N |= ϕ[s(v1|n1 ) . . . (vk |nk )]
for every assignment s of N. Such a formula ϕ is said to define P in
N.
A definition of “function definable in N” could be made in a similar
way, of course. Definability is a close relative of representability:
Proposition 19.8. Suppose P is a k-place relation which is rep-
resentable in Th(A). Then P is definable in N.
Problem 19.9. Is the converse to Proposition 19.6 true?
A counterpart for definability of the Entscheidungsproblem is the
question of whether the truth in N is a definable relation in N, i.e.
whether the set of Gödel codes of sentences of LN true in N,
pTh(N)q = { pσq | σ is a sentence of LN and N |= σ } ,
is definable in N.
Theorem 19.10 (Tarski’s Undefinability Theorem). pTh(N)q is
not definable in N.
56 19. THE INCOMPLETENESS THEOREM
Hints
CHAPTER 10
Hints
Hints
61
62 11. HINTS
CHAPTER 12
Hints
63
64 12. HINTS
CHAPTER 13
Hints
65
66 13. HINTS
CHAPTER 14
Hints
14.1. You only need to take care of the projection functions, and
these can be computed by Turing machines very similar to one another.
14.2. Generalize Example 14.1.
14.3. Use machines computing g, h1, . . . , hm as sub-machines of
the machine computing the composition. You might also find sub-
machines that copy the original input and various stages of the output
useful. It is important that each sub-machine get all the data it needs
and does not damage the data needed by other sun-machines.
14.4. Proceed by induction on the number of applications of com-
position used to define f from the initial functions.
14.5. 1. Exponentiation is to multiplication as multiplication is
to addition.
2. This is straightforward except for taking care of Pred(0) =
Pred(1) = 0.
3. Diff is to Pred as S is to Sum.
4. This is straightforward if you let 0! = 1.
14.6. Machines used to compute g and h are the principal parts
of the machine computing f, along with parts to copy, move, and/or
delete data on the tape between stages in the recursive process.
14.7. 1. f is to g as Fact is to the identity function.
2. Use Diff and a suitable constant function as the basic building
blocks.
3. This is a slight generalization of the preceding part.
14.8. Proceed by induction on the number of applications of prim-
itive recursion and composition.
14.9. 1. Use a composition including Diff, χP , and a suitable
constant function.
2. A suitable composition will do the job; it’s a little harder than
it looks.
67
68 14. HINTS
Hints
15.1. The strategy is obvious . . . Make sure that at each stage you
preserve a copy of the original input for use at later stages.
15.2. The primitive recursive function you define only needs to
check values of g(n1 , . . . , nk , m) for m such that 0 ≤ m ≤ h(n1 , . . . , nk ),
but it still needs to pick the least m such that g(n1 , . . . , nk , m) = 0.
15.3. This is very similar to Theorem 14.8.
15.4. This is virtually identical to Theorem 14.10.
15.5. This is virtually identical to Corollary 14.11.
15.6. In both cases, emulate Example 15.1.
15.7. Unwind Definition 15.5; you will need to do some factoring.
15.8. Find the codes of each of the positions in the sequence you
chose and then apply Definition 15.6.
15.9. 1. It will probably be convenient to first devise a function
which recognizes whether the input is of the correct form or not.
You may find it convenient to first show that following relation
is primitive recursive:
• TapePos, where TapePos(n) ⇐⇒ n is the code of a
tape position.
If the input is of the correct form, make the necessary changes
to n using the tools in Problem 14.9.
2. Piece TMM together by cases using the function Entry in each
case. You may wish to look back to the construction of an uni-
versal Turing machine in Chapter 12 for some idea of what needs
to be done.
3. You may find it convenient to first show that following relation
is primitive recursive:
• TapePosSeq, where TapePosSeq(n) ⇐⇒ n is the code
of a sequence of tape positions.
Use the function TMM to check that a sequence of tape positions
is a computation.
69
70 15. HINTS
15.10. The last part of Problem 15.9 and some unbounded mini-
malization are the key ingredients. You may also find Theorem 15.4
useful if you show that the following functions are recursive:
• Codek (n1 , . . . , nk ) = p(0, 1, 01n1 0 . . . 01nk )q for any fixed k ≥ 1.
• Decode(t) = n if t = p(i, k, 01n+1 )q (and anything you like
otherwise).
15.11. Take some creative inspiration from Definitions 15.5 and
15.6. Fpr example, if (s, i) ∈ dom(M) and M(s, i) = (j, d, t), you
could let the code of M(s, i) be
pM(s, i)q = 2s 3i 5j 7d+1 11t .
15.12. Much of what you need for both parts is just what was
needed for Problem 15.9. The additional ingredients mainly have to do
with using m = pMq properly.
15.13. Essentially, this is to Problem 15.12 as proving Theorem
15.10 is to Problem 15.9.
15.14. Use χP to help define a function f such that im(f) = P .
15.15. One direction is an easy application of Proposition 15.14.
For the other, given an n ∈ N, run the functions enumerating P and
N \ P concurrently until one or the other outputs n.
15.16. Consider the set of natural numbers coding (according to
some scheme you must devise) Turing machines together with input
tapes on which they halt.
15.17. See how far you can adapt your argument for Proposition
15.15.
CHAPTER 16
Hints
71
72 16. HINTS
CHAPTER 17
Hints
17.1. In each case, use Definitions 17.1 and 17.2, together with the
appropriate definitions from first-order logic and the tools developed
in Problem 14.9.
17.2. In each case, use Definitions 17.1 and 17.2, together with the
appropriate definitions from first-order logic and the tools developed
in Problems 14.9 and 17.1. (They’re all primitive recursive if p∆q is,
by the way.)
17.3. 1. Use unbounded minimalization and the relations in
Problem 17.2 to define a function which, given n, returns the
nth integer which codes an element of Th(∆).
2. If ∆ is complete, then for any sentence σ, either dσe or d¬σ
must eventually turn up in an enumeration of pTh(∆)q. The
other direction is really just a matter of unwinding the definitions
involved.
73
74 17. HINTS
CHAPTER 18
Hints
75
76 18. HINTS
CHAPTER 19
Hints
[1] Jon Barwise (ed.), Handbook of Mathematical Logic, North Holland, Amster-
dam, 1977, ISBN 0-7204-2285-X.
[2] C.C. Chang and H.J. Keisler, Model Theory, third ed., North Holland, Ams-
terdam, 1990.
[3] Martin Davis, Computability and Unsolvability, McGraw-Hill, New York, 1958;
Dover, New York, 1982, ISBN 0-486-61471-9.
[4] Martin Davis (ed.), The Undecidable; Basic Papers On Undecidable Propo-
sitions, Unsolvable Problems And Computable Functions, Raven Press, New
York, 1965.
[5] Herbert B. Enderton, A Mathematical Introduction to Logic, Academic Press,
New York, 1972.
[6] Douglas R. Hofstadter, Gödel, Escher, Bach, Random House, New York, 1979,
ISBN 0-394-74502-7.
[7] Jerome Malitz, Introduction to Mathematical Logic, Springer-Verlag, New
York, 1979, ISBN 0-387-90346-1.
[8] Yu.I. Manin, A Course in Mathematical Logic, Graduate Texts in Mathemat-
ics 53, Springer-Verlag, New York, 1977, ISBN 0-387-90243-0.
[9] Roger Penrose, The Emperor’s New Mind, Oxford University Press, Oxford,
1989.
[10] T. Rado, On non-computable functions, Bell System Tech. J. 41 (1962), 877–
884.
[11] Raymond M. Smullyan, Gödel’s Incompleteness Theorems, Oxford University
Press, Oxford, 1992, ISBN 0-19-504672-2.
79
80 BIBLIOGRAPHY
Index
A, 49 IsPrime, 33, 52
Con(Σ), 54 Length, 33, 52
p∆q, 46 Logical, 46
ϕ(S m1 0, . . . , S mk 0), 50 Mult, 31
f : Nk → N, 25 O, 27, 29, 51
iN , 26 Power, 33, 52
LN , 43 Pred, 27, 31
N, 25 Premiss∆ , 46
Nk \ P , 32 Prime, 33, 52
Nk , 25 Sentence, 46
N, 44 Sim, 39
P ∩ Q, 32 Subseq, 33
P ∪ Q, 32 Sub, 53
P ∧ Q, 32 Sum, 27, 30
P ∨ Q, 32 S, 27, 29, 51
S m 0, 50 TapePosSeq, 69
¬P , 32 TapePos, 69
πik , 29, 51 Term, 46
Th(N), 54 TM, 39
Th(Σ), 44 TMM , 38
A, 33 Ackerman’s Function, 33
α, 33 alphabet, 7, 13
Codek , 70 blank
Comp, 39 cell, 7
CompM , 38 tape, 7
Conclusion∆ , 46 bounded minimalization, 36
Decode, 70 busy beaver competition, 27
Deduction∆ , 46 n-state entry, 27
Diff, 27, 31 score, 27
Div, 33, 52
Element, 33, 52 cell
Entry, 38 blank, 7
Equal, 33 marked, 7
Exp, 31 scanned, 8
Fact, 31 characteristic function, 26
Formulas, 46 Church’s Thesis, 2
Formula, 46 code, 20
Inference, 46 sequence of tape positions, 37
81
82 INDEX
scanned cell, 8
scanner, 13
score
busy beaver competition, 27
state, 8, 9
successor
function, 29
tape position, 11
table
Turing machine, 10
tape, 7, 13
blank, 7
input, 11
output, 11
two-way infinite, 13, 14
tape position, 8
code of, 37
code of a sequence of, 37
representation of, 19
successor, 11
Tarski’s Undefinability Theorem, 55
theory
of N, 54
of a set of sentences, 44
TM, 9