0% found this document useful (0 votes)
12 views249 pages

Abstract Recursion & Complexity Analysis

The document discusses abstract recursion and intrinsic complexity, detailing its publication history and contents. It includes chapters on recursion, complexity theory, and various algorithms, along with their complexities and applications. The work serves as a comprehensive resource for understanding the mathematical foundations of recursion and complexity in computation.

Uploaded by

ckqrxzv6zd
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views249 pages

Abstract Recursion & Complexity Analysis

The document discusses abstract recursion and intrinsic complexity, detailing its publication history and contents. It includes chapters on recursion, complexity theory, and various algorithms, along with their complexities and applications. The work serves as a comprehensive resource for understanding the mathematical foundations of recursion and complexity in computation.

Uploaded by

ckqrxzv6zd
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

ABSTRACT RECURSION

AND INTRINSIC COMPLEXITY

Yiannis N. Moschovakis
Department of Mathematics
University of California, Los Angeles
ynm@[Link]

October 2018
iv

Abstract recursion and intrinsic complexity was first published by Cambridge


University Press as Volume 48 in the Lecture Notes in Logic, c Association
for Symbolic Logic, 2019. The Cambridge University Press catalog entry for
the work can be found at
[Link]
/logic-categories-and-sets
/abstract-recursion-and-intrinsic-complexity.
The published version can be purchased through Cambridge University
Press and other standard distribution channels. This copy is made available
for personal use only and must not be sold or redistributed.

This final prepublication draft of ARIC was compiled on November 30, 2018, 22:50
CONTENTS

Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 1

Chapter 1. Preliminaries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
1A. Standard notations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7
Partial functions, 9. Monotone and continuous functionals, 10. Trees, 12.
Problems, 14.
1B. Continuous, call-by-value recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 15
The where -notation for mutual recursion, 17. Recursion rules, 17. Problems, 19.
1C. Some basic algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 21
The merge-sort algorithm, 21. The Euclidean algorithm, 23. The binary (Stein)
algorithm, 24. Horner’s rule, 25. Problems, 25.
1D. Partial structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29
Φ-structures, 30. Substructures, 32. Diagrams, 32. Homomorphisms and em-
beddings, 33. Substructure generation, 33. Certificates, 34. Problems, 35.
1E. Partial equational logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 36
Syntax, 36. Semantics, 38. Explicit definability, 39. Problems, 42.

Part I. Abstract (first order) recursion

Chapter 2. Recursive (McCarthy) programs . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49


2A. Syntax and semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 49
A-recursive functions and functionals, 52. Problems, 55.
2B. Simple fixed points and tail recursion . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58
Simple fixed points, 58. Pointed structures, 59. Tail recursion, 60. Tail recursive
programs and functions, 61. Mutual tail recursion, 61. Relativization, 63. Problems,
64.
2C. Iterators . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 69
Reduction of iteration to tail recursion, 70. Explicit representation, 71. Turing
computability and recursion, 71. About implementations (I), 73. Problems, 73.
2D. The recursive machine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 74
Reduction of recursion to iteration, 78. Symbolic computation, 78. Problems,
80.
2E. Finite nondeterminism . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 82
Certificates and computations, 83. Fixed point semantics for nondeterministic
programs, 84. Pratt’s nuclid algorithm, 85. Problems, 86.

v
vi CONTENTS

2F. Some standard models of computation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 90


Finite register machines, 90. Straight line programs, 91. Random Access Ma-
chines (RAMs), 91. Problems, 93.
2G. Full vs. tail recursion (I) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 94
Examples where Tailrec0 (A) ( Rec0 (A), 95. Examples where Tailrec0 (A) should be
( Rec0 (A), 97. Problems, 98.
2H. What is an algorithm? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 99
About implementations (II), 100. Imperative vs. functional programming, 101.
Proofs of correctness, 101.

Chapter 3. Complexity theory for recursive programs . . . . . . . . . . . . . . . . . . . . 103


3A. The basic complexity measures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 103
The tree-depth complexity DEA (M ), 104. The sequential logical complexity Ls (M )
(time), 107. The parallel logical complexity Lp (M ), 108. The number-of-calls com-
plexity C s (Φ0 )(M ), 110. The depth-of-calls complexity C p (Φ0 )(M ), 111. Problems,
112.
3B. Complexity inequalities . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 115
Recursive vs. explicit definability, 115. Tserunyan’s inequalities, 117. Full vs. tail
recursion (II), 124. Problems, 125.

Part II. Intrinsic complexity

Chapter 4. The homomorphism method . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129


4A. Uniformity of algorithms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
Processes, 130. Uniform processes, 132. Uniformity Thesis, 132.
4B. Examples and counterexamples . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 133
An example of a non-uniform process, 134. Problems, 135.
4C. Complexity measures on uniform processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 136
Substructure norms, 136. The time complexity on RAMs, 138. Problems, 138.
4D. Forcing A and certification Ac . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 141
The connection with Pratt certificates for primality, 143. Problems, 144.
4E. Intrinsic complexities of functions and relations . . . . . . . . . . . . . . . . . . . . . . . . . 144
Homomorphism Test, 145. The output complexities, 146. Explicit (term) reduc-
tion and equivalence, 146. Problems, 147. Obstruction to calls(A, R, x ~ ) = 0, 147.
Obstruction to depth(A, R, x ~ ) = 0, 148.
4F. The best uniform process . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149
Optimality and weak optimality, 150. Problems, 151.
4G. Logical extensions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 152
The lower bound for comparison sorting, 153. Embedding Test, 154. Substruc-
ture norms on logical extensions, 155. Problems, 157.
4H. Deterministic uniform processes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158
Problems, 158.

Chapter 5. Lower bounds from Presburger primitives . . . . . . . . . . . . . . . . . . . . . 159


5A. Representing the numbers in Gm (Nd , a~ ) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 159
Problems, 162.
5B. Primality from Lind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 163
Using non-trivial number theory, 165. Problems, 166.
CONTENTS vii

5C. Good examples: perfect square, square-free, etc. . . . . . . . . . . . . . . . . . . . . . . . . 167


Problems, 167.
5D. Stein’s algorithm is weakly depth-optimal from Lind . . . . . . . . . . . . . . . . . . . . . 168
Problems, 170.

Chapter 6. Lower bounds from division with remainder . . . . . . . . . . . . . . . . . . . 171


6A. Unary relations from Lin0 [÷] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 171
Problems, 177.
6B. Three results from number theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 177
Problems, 181.
6C. Coprimeness from Lin0 [÷] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 183
Problems, 189.

Chapter 7. Lower bounds from division and multiplication . . . . . . . . . . . . . . . 191


7A. Polynomials and their heights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 191
7B. Unary relations from Lin0 [÷, ·] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196
Problems, 202.

Chapter 8. Non-uniform complexity in N . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203


8A. Non-uniform lower bounds from Lind . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 203
Problems, 205.
8B. Non-uniform lower bounds from Lin0 [÷] . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 205
Problems, 207.

Chapter 9. Polynomial nullity (0-testing) . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209


9A. Preliminaries and notation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 209
The Substitution Lemma, 210.
9B. Generic {·, ÷}-optimality of Horner’s rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 211
Counting identity tests along with {·, ÷}, 216.
9C. Generic {+, −}-optimality of Horner’s rule . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218
Counting identity tests along with {+, −}, 225. Counting everything, 226. Prob-
lems, 226.

References . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 229
Symbol index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 237
General index . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239
INTRODUCTION

This is the (somewhat polished) present state of an evolving set of lecture


notes that I have used in several courses, seminars and workshops, mostly
at UCLA and in the Graduate Program in Logic and Algorithms (MPLA) at
the University of Athens. The general subject is the theory of abstract (first-
order) recursion and its relevance to the foundations of the theory of algorithms
and computational complexity, but the work on this broad project is very
incomplete and so the choice of topics that are covered is somewhat eclectic.
The preliminary Chapter 1 gives a brief, elementary exposition of some
basic facts and examples and helps make the material which follows accessible
to students and researchers with varying backgrounds. After that, the book
naturally splits into two, roughly equal parts according to the title: Part I
(Chapters 2 – 3) on abstract recursion and Part II (Chapters 4 – 9) on intrinsic
complexity.
– Chapter 2 introduces recursive (McCarthy) programs on abstract struc-
tures and develops their elementary theory. There is little that is new here,
other than Vaughan Pratt’s very interesting nondeterministic algorithm for
coprimeness in Section 2E, but I do not know of another easily accessible,
self-contained and reasonably complete source for this material.
– Chapter 3 introduces the natural complexity measures for recursive pro-
grams and establishes their basic properties. There is some novelty in ap-
proach, especially as the complexity measures are defined directly for the
programs and so are independent of any particular “implementation of re-
cursion”; and there are also some new results, most notably Theorems 3B.9
and 3B.12 which are due to Anush Tserunyan and have (I think) substantial
foundational significance.
Part II is about the derivation of robust and widely applicable lower bounds
for problems (especially) in arithmetic and algebra, and perhaps the simplest
way to introduce my take on this is to give a fairly precise formulation of a
fundamental conjecture about an ancient object of mathematical study.
The Euclidean algorithm (on the natural numbers, using division) can be
specified succinctly by the recursive equation
(
x, if y = 0,
ε : gcd(x, y) =
gcd(y, rem(x, y)), otherwise,
2 Introduction

where rem(x, y) is the remainder in the division of x by y. It computes the


greatest common divisor of x and y when x, y ≥ 1 and it is an algorithm from
(relative to) the remainder function rem and the relation eq0 of equality with
0: meaning that in its execution, ε has access to “oracles” which provide on
demand the value rem(s, t) for any s and t 6= 0 and the truth value of eq0 (s).
It is not hard to prove that
(∗) cε (x, y) ≤ 2 log y ≤ 2 log x (x ≥ y ≥ 2),

where cε (x, y) is the number of divisions (calls to the rem-oracle) required for
the computation of gcd(x, y) by the Euclidean and logarithms are to the base
2. Much more is known about cε (x, y), but this upper bound suggests one
plausible formulation of the Euclidean’s (worst-case) weak optimality:
Main Conjecture. For every algorithm α from rem and eq0 which computes
gcd(x, y) when x, y ≥ 1, there is a number r > 0, such that for infinitely many
pairs (x, y) with x > y ≥ 1,
cα (x, y) > r log x,
where cα (x, y) is the number of calls to the rem-oracle that α makes in the
computation of gcd(x, y).
This is a classical fact about the Euclidean algorithm, taking for example
the pairs (Fn+3 , Fn+2 ) of successive Fibonacci numbers, cf. Problems x1C.8,
x1C.9. The general case is open, probably not easy and certainly not precise
as it stands, without specifying what algorithms it is about and what it means
for an algorithm to call an oracle in the course of a computation.
Now, there are Turing machines which compute gcd(x, y) making no oracle
calls at all, simply because gcd(x, y) is Turing computable—so that’s not it.
In fact, there is no generally accepted, rigorous definition of what algorithms
are. This is not a problem when we study particular algorithms, which are
typically specified precisely in some form or other without any need to investi-
gate whether all relevant algorithms can be similarly specified. In Complexity
Theory—and especially when we want to establish lower bounds for some mea-
sure of computational complexity—the standard methodology is to ground
proofs on rigorously defined models of computation, such as Turing machines,
register or random access machines, decision trees, straight line programs,
etc., and sometimes also on specific representations of the input, e.g., unary
or binary notation for natural numbers, adjacency matrices for graphs, etc.
There is a problem with this practice, when we try to compare lower bound
results obtained for different models, typically attacked by establishing simu-
lations of one model by another, cf. van Emde Boas [1990]; and this problem
becomes acute when we want to prove absolute (or at least widely applicable)
lower bounds which are small, polynomial or even linear (in the length of the
Introduction 3

input) as in the Main Conjecture, generally less complex than the standard
simulations.
So there are two equally important aims of research in this area:
One is to derive lower bounds for mathematical problems; the other is to
develop a foundational framework in which one may be able to prove (or at
least argue convincingly) that these bounds are absolute, that they restrict all
relevant algorithms. The first of these naturally requires mathematical tools
from the area in which the problems arise; and the second inevitably involves
logic.
Recursion gets in the picture because there are both foundational arguments
and mathematical results which support the view that all elementary1 algo-
rithms can be faithfully expressed by recursive programs, so that lower bounds
established for them should be absolute, cf. Moschovakis [1984], [1989a],
[1998], [2001]. This connection has motivated much of the work reported
here, but it is not our topic.
Here I will take a different approach to the derivation and justification of
robust lower bounds, which is more widely applicable and does not tie us to
any specific foundational view of what algorithms are.
In Chapter 4, which is the heart of this book, we formulate three simple
axioms about algorithms in the style of abstract model theory. These are
bundled into the notion of a uniform process of an arbitrary (first order) struc-
ture: all concrete algorithms specified by computation models induce uniform
processes, as do their usual nondeterministic versions. Uniform processes can
“compute” functions that are not computable, they are not about that; but
they carry a rich complexity theory which, when applied to concrete algo-
rithms yields non-trivial lower bounds, in some cases optimal, absolutely or
up to a multiplicative constant.
For a sample result, suppose
A = (A, R1A , . . . , RkA , φ1A , . . . , φlA ) = (A, Υ)
is a first order structure on the vocabulary Φ = {R1 , . . . , Rk , φ1 , . . . , φl },
suppose P ⊆ An is an n-ary relation on A and let Φ0 ⊆ Φ. From these data,
we will define a function
c = calls(Φ0 )(A, P) : An → N ∪ {∞} = {0, 1, . . . , ∞},

1 There are algorithms whose implementations print output (or drop bombs), ask “the user” if

she prefers business or coach class and may never terminate. In this book we confine ourselves to
pure, finitary algorithms which compute partial functions or decide relations from given partial
functions and relations, for which complexity theory is most fully developed. The extension of
most of what we say to algorithms with side effects or interaction requires combining the methods
we will use with classical domain theory, introduced by Scott and Strachey [1971] and richly
developed by Scott and many others since then, especially the early Plotkin [1977], [1983]. It is
not as different from what we will be doing as one might think, but we will not go into it here.
4 Introduction

the intrinsic calls(Φ0 )-complexity function of P, such that if α is any (deter-


ministic or nondeterministic) algorithm from Υ which decides P, then for all
~ ∈ An ,
x
(∗) x ) ≤ the number of calls to primitives in Υ0
c(~
that α must execute to decide P(~
x ) from Υ.
This is a theorem if α is expressed by a concrete algorithm from Υ so that,
in particular, the complexity measure on the right is precisely defined; it will
be made plausible for all algorithms, by a brief conceptual analysis of what
it means (minimally) to compute from primitives; and it is not trivial, e.g., we
will show that if x⊥⊥ y is the coprimeness relation on N and
⊥ ) : N2 → N,
c = calls(rem)((N, rem, eq0 ), ⊥
then for infinitely many pairs (a, b) with a > b,
1
(∗∗) c(a, b) > log log a.
10
This follows from the (much stronger) Theorem 6C.5, an abstract version
of one of the main results in van den Dries and Moschovakis [2004]. It
gives a (very) partial result towards the Main Conjecture, one log below what
we would like to prove—but Vaughn Pratt’s nondeterministic algorithm for
coprimeness in Theorem 2E.2 suggests that the conjecture may hold only for
deterministic algorithms.
The main tool for defining the intrinsic complexities and deriving lower
bounds for them is the homomorphism method, an abstract and mildly extended
version of the embedding method developed in van den Dries and Moschovakis
[2004], [2009]. We will use it in Chapters 5 – 8 to get somewhat strengthened
versions of some of the lower bound results about arithmetic in these two
papers and then again in Chapter 9 to get similar results in algebra. Few of
these applications in the last two Parts are new: my main aim here is to explain
the homomorphism method, illustrate its applicability in two different areas
and (primarily) to identify some basic notions of the theory of computational
complexity which (perhaps) have not been noticed.
Notice that this is not a textbook on computability and complexity, a core
part of Computer Science which is covered in many excellent books including
the classical Papadimitriou [1994]; it is not a textbook on Turing computability
and recursion on N, a huge subject amply covered in classical texts like Kleene
[1952], Davis [1958] and Rogers [1967] and many more recent ones; and it
is definitely not a textbook on arithmetic and algebraic complexity, not even a
good introduction to these vast research areas about which I really know very
little. It is natural to assume for some of the discussion that the reader knows
something about these subjects, but the rigorous development of the material
is substantially self-contained and limited to a few results which (I hope)
Introduction 5

throw some light on the central problem of deriving and justifying absolute
lower complexity bounds.
The exposition is elementary, aimed at advanced undergraduates, graduate
students and researchers in mathematics and computer science with some
knowledge of logic, a good understanding of the basic facts about algorithms
and computability and an interest in foundational questions. Many of the
(roughly) 250 problems are very easy, to test understanding, but there are also
more challenging ones, sometimes marked with an asterisk ∗ and a few that I
cannot do, marked “Open Problem”.
I have tried hard to assign results to those who proved them and to give
correct and useful references to the literature, but this is not the place to look
for a history of recursion and its interaction with computability—another vast
and complex topic which is way out of my expertise and certainly not of the
moment.

Yiannis N. Moschovakis
Santa Monica, CA and Paleo Faliro, Greece

Acknowledgments.

My greatest debt is to Lou van den Dries, whose insights in van den Dries
[2003] led to a fruitful (and very pleasant) collaboration that produced van
den Dries and Moschovakis [2004], [2009] and ultimately led to Part II of this
book.
I am grateful to Vaughan Pratt and Anush Tserunyan for letting me include
in this book unpublished results of theirs; to Vasilis Paschalis and Tyler Arant
for chasing errors and typos in Parts I and II respectively—and I know they
must have missed some, it’s OK; and to my wife, always, and for many things
other than her help with this book.
To go farther than this, I would need to put down the many logicians,
philosophers and computer scientists who have informed my understanding of
logic, recursion, algorithms and the connections among these subjects, includ-
ing Stephen Kleene, John McCarthy, Dana Scott and many, many others—too
long a list to put down here and certainly not unique to me.
Finally, I want to thank the hundreds of students who have taken courses or
wrote [Link]. or Ph.D. Theses with me on these topics, mostly at UCLA and the
University of Athens, including the Graduate Program in Logic, Algorithms
and Computation (MPLA). It is sometimes said that we learn more from our
students than they learn from us and perhaps this is true of me; in any case,
there is no doubt that I have enjoyed the process, very much.
CHAPTER 1

PRELIMINARIES

We collect here some basic facts we need from set theory, recursion theory,
logic and arithmetic, primarily to fix terminology and notation, and we also
describe some simple examples of algorithms to which we can refer later.
Most readers of this book will know most of these facts and should peruse
this chapter quickly, coming back to it later, as needed. One exception is the
“where” notation in Section 1B for definitions by mutual recursion which we
will use extensively, and another might be the treatment of equational logic of
partial terms in Section 1E: there are several ways to approach this topic, but
only one works well with recursive equations and it is important to get it right
early on.

1A. Standard notations

As usual, N = {0, 1, . . . } is the set of natural numbers,


Z = {. . . , −2, −1, 0, 1, 2, . . . }
is the set of integers, Q is the set of fractions and R, C are the sets of real and
complex numbers respectively. We will use the same symbols 0, 1, +, −, ·, ÷ for
the corresponding objects and functions in all these sets—and in all rings and
fields, in fact. We also set
· ·
S(x) = x + 1, x− y = if (x < y) then 0 else x − y, Pd(x) = x − 1
for the successor, arithmetic subtraction and predecessor functions on N, and
log(x) = the unique real number y such that 2y = x (x ∈ R, x > 0).
This is the “true”, binary logarithm function. We will sometimes compose it
with one of the functions
bxc = the largest integer ≤ x (the floor of x),
dxe = the least integer ≥ x (the ceiling of x)
to get an integer value.

7
8 1. Preliminaries

By the Division Theorem (for arithmetic), if x, y ∈ N and y > 0, then there


exist unique numbers q and r such that
(1A-1) x = yq + r and 0 ≤ r < y;
if x < y, then q = 0 and r = x, while if x ≥ y, then q ≥ 1. We refer to (1A-1)
as the correct division equation (cde) for x, y, and we set
(1A-2) iq(x, y) = q, rem(x, y) = r (y > 0),
with the unique q and the r for which it holds. We also put
iqm (x) = iq(x, m), remm (x) = rem(x, m) (m ≥ 2), parity(x) = rem2 (x).
For the divisibility relation, we write
y | x ⇐⇒ (∃q)[x = yq], so if y 6= 0, y | x ⇐⇒ rem(x, y) = 0.
Two positive numbers are relatively prime or coprime if their only common
divisor is 1,
⊥ y ⇐⇒ x, y ≥ 1 & (∀d > 1)[d - x ∨ d - y].
x⊥
We also call n numbers x1 , . . . , xn relatively prime if they are all positive and
no number other than 1 divides all of them.
The greatest common divisor of two natural numbers is what its name
means,2
(1A-3) gcd(x, y) =df the largest d ≤ max(x, y) such that d | x and d | y.
Thus,
⊥ y ⇐⇒ x, y ≥ 1 & gcd(x, y) = 1.
x⊥
The most commonly used notations for comparing the growth rate of unary
functions on N are the Landau symbols:
f(n)
f(n) = o(g(n)) ⇐⇒ limn→∞ =0
g(n)
f(n) = O(g(n)) ⇐⇒ (∃K, C )(∀n ≥ K )[f(n) ≤ Cg(n)]
f(n) = Θ((g(n)) ⇐⇒ f(n) = O(g(n)) & g(n) = O(f(n))
f(n) = Ω(g(n)) ⇐⇒ (∃K, r)(∀n ≥ K )[f(n) ≥ rg(n))
where the constants K, C ∈ N while r is a positive fraction. We will also use
the notation
f(n)
f(n) ∼∞ g(n) ⇐⇒ limn→∞ = 1,
g(n)

2 This definition gives gcd(x, 0) = 0 (even when x = 0), silly values that we do not care about;

but it is useful to have gcd(x, y) defined for all x, y, and these values simplify some equations.
1A. Standard notations 9

most notably by appealing in a few critical places to Stirling’s formula,


(1A-4) log(n!) ∼∞ n log n.
Products and relations. The (Cartesian) product of n sets is the set
X1 × · · · × Xn = {(x1 , . . . , xn ) : x1 ∈ X1 , . . . , xn ∈ Xn }
of all sequences from them, set by convention to X1 if n = 1 and to I = {∅}
when n = 0, for which we assume (by convention, if you wish) that
X1 × · · · × Xk × I × Y1 × · · · × Yl = X1 × · · · × Xk × Y1 × · · · × Yl .
As usual, X n = X · · × X} with X 0 = I.
| × ·{z
n times
We fix a two-element set
(1A-5) B = {tt, ff}
for the truth values, and with each relation R ⊆ X = X1 × · · · × Xn on the sets
X1 , . . . , Xn we associate its characteristic function
(
tt, if R(~x ),
(1A-6) ÷R (~
x) = (~
x ∈ X = X1 × · · · × Xn );
ff, otherwise.
we identify R ⊆ X with ÷R : X → B, so
(1A-7) x ) ⇐⇒ R(~
R(~ x ) = tt, x ) ⇐⇒ R(~
¬R(~ x ) = ff.
Most often we will be considering n-ary relations R ⊆ An on a single set,
subsets of A if n = 1.
The cardinal number of a set X is denoted by |X |, so that for distinct
x1 , . . . , xn , |{x1 , . . . , xn }| = n.
Partial functions. For any two sets X, W , a partial function3 f : X * W is
a function f : Df → W , where Df ⊆ X is the domain of convergence of f.
We call X and W the input and output sets of f and for f, g : X * W and
x ∈ X , we set
f(x)↓ ⇐⇒ x ∈ Df (f(x) converges),
f(x) ↑ ⇐⇒ x ∈
/ Df (f(x) diverges),
Graphf (x, w) ⇐⇒ f(x) = w,
f v g ⇐⇒ (∀x ∈ X, w ∈ W )[f(x) = w =⇒ g(x) = w]
⇐⇒ Graphf ⊆ Graphg ,

3 A partial function f : X * W comes “tagged” with its input and output sets, which means

that “given f” implies that we are also given X and W —and we will often use this, especially in
definitions. On the other hand, if Df ⊆ X 0 and W ⊂ W 0 , then there is exactly one f 0 : X 0 * W 0
which agrees with f on their common domain of convergence, and it is natural to use the same
name for it—which we will often do.
10 1. Preliminaries

read “f is a subfunction of g”. If f : X * W and h : Y * W , then

(1A-8) f(x) = h(y)


⇐⇒ [f(x) ↑ & h(y) ↑] or [f(x)↓ & h(y)↓ & f(x) = h(y)],
i.e., two possibly undefined expressions are equal if they are both undefined
or they are both defined and equal. On occasion (especially in definitions) we
also use the ungrammatical “f(x) = ↑” which is synonymous with “f(x) ↑”.4
Partial functions compose strictly, they “call their arguments” by value
in computer science terminology: if gi : X * Wi for i = 1, . . . , m and
f : W1 × · · · × Wm * W , then

(1A-9) f(g1 (x), . . . , gm (x)) = w


⇐⇒ (∃w1 , . . . , wm )[g1 (x) = w1 & · · · & gm (x) = wm
& f(w1 , . . . , wm ) = w],
so that in particular,
f(g1 (x), . . . , gm (x))↓ =⇒ g1 (x)↓ , . . . , gm (x)↓ .
Monotone and continuous functionals. For any two sets Y and W , (Y * W )
is the space of all partial functions p : Y * W . A functional is a partial
function
(1A-10) f : X × (Y1 * W1 ) × · · · × (Yk * Wk ) * W
which takes members of X and partial functions (on various sets) as argu-
ments and gives a value in some set W when it converges; f is monotone if

f(x, p1 , . . . , pk )↓ & p1 v q1 & · · · & pk v qk


=⇒ f(x, p1 , . . . , pk ) = f(x, q1 , . . . , qk );
and it is continuous if it is monotone and compact, i.e.,

f(x, p1 , . . . , pk )↓
=⇒ (∃ finite p10 v p1 , . . . , pk0 v pk )[f(x, p10 , . . . , pk0 ) = f(x, p1 , . . . , pk )],
where a partial function is finite if it has finite domain of convergence.
Partial functions are (degenerate) continuous functionals, with the conven-
tional understanding of (1A-10) and these notions when k = 0.
Typical (and most basic) continuous functionals are the applications,
(1A-11) apn (x1 , . . . , xn , p) = p(x1 , . . . , xn ) (n ≥ 1),
usually with x1 , . . . , xn ranging over some set A and p : An * W .

4 This is Kleene’s strong equality between “partial values” often denoted by “'”.
1A. Standard notations 11

Notation gets messy when we work with functionals and we certainly do


not want to have to repeat or refer to (1A-10) to specify their input and output
sets every time we use them. Sometimes
we will write f(x, p
~ ) when we mean f,
which is convenient if logically inappropriate, as it confuses “function value”
with “function”.5
Sections and ë-abstractions. Putting this convention to work, we define the
x-section and the ëx-abstraction of a functional f(x, y, p~ ) by
fx (y, p
~ ) = f(x, y, p
~ ),
(ëx)f(x, y, p
~ )(x) = f(x, y, p
~ ).
More precisely (for once), if f : X × Y × P * W with P a (possibly empty)
product of partial function spaces, then the first of these defines for each
x ∈ X a functional fx : Y × P * W and the second defines an operation
fX : Y × P → (X * W ) which takes partial functions as values. Notice
that by our convention on the empty product above, every partial function
f : X × Y * W is a functional, the definitions apply and fx : Y * W ,
fX : Y → (X * W ).
Operations on functionals. From the many operations on functionals we
will use, we list here just four, for easy reference.6
Substitution: from g(t1 , . . . , tk , ~r) and hi (~
x , ~r) (i = 1, . . . , k), define
(1A-12) x , ~r) = g(h1 (~
f(~ x , ~r), . . . , hk (~
x , ~r), ~r).
ë-substitution: from g(~
u, x ~ ) and h(~
~, p y , q, ~r), define
(1A-13) f(~
x, y ~ , ~r) = h(~
~, p y , (ë~
u )g(~
u, x ~ ), ~r).
~, p
Branching: from g0 (~
x , ~r) with output set B and g1 (~
x , ~r), g2 (~
x , ~r) with the same
output set, define
(1A-14) x , ~r) = if g0 (~
f(~ x , ~r) then g1 (~
x , ~r) else g2 (~x , ~r)

 g1 (~x , ~r), if g0 (~
x , ~r) = tt,
= g2 (~ x , ~r), if g0 (~
x , ~r) = ff,

↑ otherwise.
Mangling: from g(u1 , . . . , uk , r1 , . . . , rl ), define
(1A-15) f(x1 , . . . , xn , r1 , . . . rm ) = g(xð(1) , . . . , xð(k) , ró(1) , . . . , ró(l ) ),
where ð : {1, . . . , k} → {1, . . . , n}, ó : {1, . . . , l } → {1, . . . , m}.
5 When the error was once pointed out to Kleene by a student, he responded that the distinction

between “function” and “function value” is surely important, but if he could not handle it he was
probably in the wrong field.
6 It is assumed that the input and output sets of the given functionals and the ranges of the

variables fit, so that the definitions make sense.


12 1. Preliminaries

A more dignified name for mangling might be adding, permuting and identi-
fying variables, but that is way too long; whatever you call it, it is a very useful
operation, it provides for definitions of the form
f(x, y, p, r) = h(x, x, r, p, p),
and combined with the three operations preceding it justifies complex explicit
definitions, e.g.,
f(x, y, p, r) = h(x, g1 (x, y, p), (ë~
u )g2 (u, x, u), p, r).
1A.1. Proposition. If a class of functionals F is closed under mangling (1A-15),
then F is closed under substitution (1A-12) if and only if it is closed under com-
position
(1A-16) f(~
x, y ~ , ~r) = g(h(~
~, p ~ ), y
x, p ~ , ~r).

Proof is left for Problem x1A.2. a

Strings. For any set L, L∗ = L<ù is the set of strings (words, finite se-
quences) from L and we will use mostly standard notations for them:
(1A-17) nil = ( ) (the empty string),
|(u0 , . . . , um−1 )| = m, (u0 , . . . , um−1 )i = ui (i < m),
head((u0 , . . . , um−1 )) = (u0 ) (with head(nil) = nil),
tail((u0 , . . . , um−1 )) = (u1 , . . . , um−1 ) (= nil if m ≤ 1),
cons(u, (v0 , . . . , vm−1 )) = ((u)0 , v0 , . . . , vm−1 )
(u0 , . . . , um−1 ) ∗ (v0 , . . . , vn−1 ) = (u0 , . . . , um−1 , v0 , . . . , vn−1 ),
u v v ⇐⇒ (∃w)[u ∗ w = v], (the initial segment relation),
/ v ⇐⇒ u v v & u 6= v.
uv
These definitions of head(u) and cons(u, v) in effect identify a member t of L
with the string (t) ∈ L∗ , which simplifies in some ways dealing with strings.
Sometimes we denote strings by simply listing their elements
u0 u1 · · · vm−1 ≡ (u0 , u1 , . . . , um−1 ),
especially when we think of them as words from some alphabet L of symbols;
and in such cases, we typically use “≡” to denote the equality relation on
words, since “=” is often one of the symbols in the alphabet.
Trees. For our purposes, a (finite, non-empty, rooted, N-labelled) tree on a

set X is any finite set T ⊂ (N × X ) of non-empty finite sequences (nodes)
from N × X which has a unique node of length 1, its root and is closed under
initial segments,
∅=
6 u v v ∈ T =⇒ u ∈ T .
1A. Standard notations 13

The children of a node u ∈ T are all one-point extensions u ∗ (y) ∈ T and


u is splitting if it has at least two children.
The (out-) degree of T is the maximal number of children that any node
has—unless T = {root}, in which case (by convention) degree(T ) = 1.
A node v is below a node u if v = u or there is a (necessarily unique)
non-empty w such that v = u ∗ w.
The depth of T is the largest m such that there is a sequence of nodes
u1 , . . . , um with each ui+1 strictly below ui , so that depth(T ) = 0 exactly when
T = {root}; and the splitting depth of T is the largest m such that there
is a sequence of splitting nodes u1 , . . . , um with each ui+1 below ui , so that
spdepth(T ) = 0 exactly when degree(T ) = 1.
The size of a tree is the number of its nodes, size(T ) = |T |.
A node is a leaf if it has no children, leaves(T ) is the set of all leaves of T
and it is easy to check by induction on spdepth(T ) that
(1A-18) |leaves(T )| ≤ degree(T )spdepth(T ) ≤ degree(T )depth(T ) ,
cf. Problem x1A.4.
For each u = (u0 , . . . , un ) ∈ T , let

Tu = {(un ) ∗ v ∈ (N × X ) : u ∗ v ∈ T }.
This is the subtree of T below u, with root un , so that in particular,
Pn o
(1A-19) Troot = T , |T | = 1 + |Tu | : u is a child of root .

For each tree T , let


T 0 = {u ∈ T : u is not a leaf}.
This is empty if T has only one node, but it is a tree if |T | > 0, the derived
(pruned) subtree of T and
depth(T 0 ) = depth(T ) − 1.
In dealing with these trees, we will think of them as sets of sequences from
X , mostly disregarding the labels: their only purpose is to allow a node to
have several “identical” children which are counted separately. For example,
we will want to draw the tree
x

x1 R x2

and assume it has this structure (with a root which has two children) even if
it happens that x1 = x2 ; so formally, we need to set
T = {((0, x)), ((0, x), (0, x1 )), ((0, x), (1, x2 ))},
14 1. Preliminaries

but we will indicate this by the simpler


T = {(x), (x, x1 ), (x, x2 )}.
For example, if z ∈ X and T , T1 , . . . , Tk are trees on X , then Top(z, T1 , . . . , Tk )
is the tree with root z and T1 , . . . , Tk immediately below it. We will draw the
result of this operation as if
(1A-20) Top(z, T1 , . . . , Tk )
= {(z, x1 , . . . , xn ) | for some i = 1, . . . , k, (x1 , . . . , xn ) ∈ Ti };
the formal definition, with the labels, is the more formidable
Top(z, T1 , . . . , Tk ) = {((0, z), (hi, j1 i, x1 ), . . . , (hi, jn i, xn ))
| i = 1, . . . , k, ((j1 , x1 ), . . . , (jn , xn )) ∈ Ti },
i+1 j+1
where hi, ji = 2 3 is an injection of N × N into N \ {0}.

Problems for Section 1A

x1A.1. Problem. Verify that (X * W ) with the subfunction relation v is a


Scott domain whose maximal points are the total functions, i.e.,
(1) For all f, g, h : X * W ,
f v f, [f v g v h] =⇒ f v h, [f v g v f] =⇒ f = g.
(2) Every f : X * W is the least upper bound of the set of its finite
subfunctions.
(3) If I ⊆ (X * W ) and every pair {f, g} ⊆p I has an upper bound, then
I has a least upper bound.
(4) If f : X → W is total and f v g, then f = g.
x1A.2. Problem. Prove Proposition 1A.1, that if F is a class of functionals
closed under mangling (1A-15), then F is closed under substitution, (1A-12)
if and only if it is closed under composition, (1A-16).
x1A.3. Problem. Prove that if F is a class of functionals closed under all
four schemes of explicit definition on page 11, then it is also closed under the
scheme
f(x, y, p, r) = h(x, g1 (x, y, p), (ë~
u )g2 (u, x, u), p, r).
x1A.4. Problem. Suppose T is a finite tree.
(1) Prove (1A-18) and (1A-19).
(2) Prove that if degree(T ) = 1, then |T | = depth(T ) + 1.
(3) Prove that if degree(T ) ≥ 2, then
|T | ≤ degree(T )depth(T )+1 − 1 < degree(T )depth(T )+1 .
1B. Continuous, call-by-value recursion 15

1B. Continuous, call-by-value recursion

From recursion theory, we will need the following, fundamental result which
justifies recursive definitions:
1B.1. Theorem (The Fixed Point Lemma). (1) For every continuous func-
tional f : X × (X * W ) * W , the recursive equation
(1B-1) p(x) = f(x, p)
has a v-least solution p : X * W , characterized by the conditions
(FP) p(x) = f(x, p) (x ∈ X ),
(MIN) if (∀x)[f(x, q)↓ ⇒ f(x, q) = q(x)], then p v q (q : X * W ).
We say that p is the canonical solution of (1B-1) and we write
(1B-2) p(x) = f(x, p) >> p.
(2) Similarly, every system of mutual continuous recursive equations
(1B-3) p1 (x1 ) = f1 (x1 , p1 , . . . , pK ), . . . , pK (xK ) = fK (xK , p1 , . . . , pK )
(with input and output sets for f1 , . . . , fK matching so that the equations
make sense) has a v-least (canonical) solution tuple p1 , . . . , pK characterized
by the conditions
(FP) pi (xi ) = f(xi , p1 , . . . p K ) (i = 1, . . . , K, xi ∈ Xi ),
(MIN) if for (i = 1, . . . , K, and all xi ∈ Xi )
 
f(xi , q1 , . . . , qK )↓ =⇒ fi (xi , q1 , . . . , qK ) = qi (xi ) ,
then p1 v q1 , . . . , pK v qK ,
and we write

 p1 (x1 ) = f1 (x1 , p1 , . . . , pK )
 p1
(1B-4) .. ..
 . >> .

pK (xK ) = fK (xK , p1 , . . . , pK ) pK .
(3) Moreover, if the given functionals have additional partial function argu-
ments ~r = (r1 , . . . , rm ) and p1 (~r), . . . , pK (~r) are defined for each ~r by (2) so
that

 p1 (x1 ) = f1 (x1 , p1 , . . . , pK , ~r)
 p1 (~r)
(1B-5) .
.. ..
 >> .

pK (xK ) = fK (xK , p1 , . . . , pK , ~r) p K (~r),
then the functionals
gi (xi , ~r) = pi (~r)(xi ) (i = 1, . . . , K )
are continuous.
16 1. Preliminaries

Outline of proof. (1) For the one-equation case, define by recursion on N


the iterates

p0 (x) = ↑ (i.e., p0 is the totally undefined partial function on X to W ),


pk+1 (x) = f(x, pk );

prove by induction, using monotonicity, that pk v pk+1 , so that

p0 v p1 v p2 v · · · ;
S
and set p = {pk : k ∈ N}, i.e.,

p(x) = w ⇐⇒ (∃k)[p k (x) = w].

If p(x) = w, then, for some k,

pk+1 (x) = f(x, pk ) = w

by the definition, and hence f(x, p) = w, by monotonicity, since pk v p.


On the other hand, if f(x, p) = w, then there is a finite q v p such that
f(x, q) = w, by continuity, and then there is some k such that q v p k ;
thus, by monotonicity, f(x, pk ) = pk+1 (x) = w, and so p(x) = w, which
completes the proof that, for all x,

f(x, p) = p(x).

To verify the minimality of p, suppose that

(∀x)[f(x, q)↓ =⇒ f(x, q) = q(x)],

and show (by an easy induction on k, using monotonicity) that pk v q, so


that in the end p v q.
(3) For the one-equation case

p(x) = f(x, p, ~r) >> p(~r),

check by an easy induction on k that if

g k (x, ~r) = pk (~r)(x) (k ∈ N)

is defined as in the proof of (1) for each fixed ~r, then g k is continuous.
(2) and the full statement (for systems) of (3) are proved by the same
argument with some added (messy) notation. a
We refer to (FP) and (MIN) in Part (1) of the Fixed Point Lemma as
the fixed point and the minimality properties of the recursive definition—and
similarly with the corresponding conditions in Part (2).
1B. Continuous, call-by-value recursion 17

The where -notation for mutual recursion. To express and prove properties
of recursive definitions, we now introduce the following two notations for
mutual recursion: given a continuous system of recursive equations and their
solutions

 p1 (x1 ) = f1 (x1 , p
 ~ , ~r) p1 (~r)
.. ..
 . >> .

pk (xk ) = fk (xk , p
~ , ~r) pk (~r)
as in (1B-5) (with p ~ = p1 , . . . , pk , ~r = r1 , . . . , rm ) and a continuous functional
f0 (y, p
~ , ~r) (with y varying over some set Y ), we set
n o
(1B-6) f0 (y, p ~ , ~r) where p1 (x1 ) = f1 (x1 , p ~ , ~r), . . . , pk (xk ) = fk (xk , p
~ , ~r)
n o
= f0 (y, p ~ , ~r) where pi (xi ) = fi (xi , p ~ , ~r) : 1 ≤ i ≤ k
=df f0 (y, p1 (~r), . . . , pk (~r), ~r).
A functional f(y, ~r) is defined by recursion from given continuous functionals
f0 , f1 , . . . , fk (with suitable input and output sets) if

(1B-7) f(y, ~r)


n o
= f0 (y, p
~ , ~r) where p1 (x1 ) = f1 (x1 , p
~ , ~r), . . . , pk (xk ) = fk (xk , p
~ , ~r) .

The first of the two notations in (1B-6) is useful for giving succinct recursive
definitions of specific functionals while the second simplifies the statement of
general rules for mutual recursion, as in the next result:
1B.2. Theorem (Recursion rules). If f, f0 , . . . , g, g0 , . . . are all continuous
~ = p1 , . . . , pk , q~ = q1 , . . . , qt , ~r = r1 , . . . , rm , then:
and p
n o
(subst) f(g(x, ~r), y, ~r) = f(q(x), y, ~r) where q(x) = g(x, ~r)

(ë-subst) f(x, (ë~


u )g(~
u , y, ~r), ~r)
n o
= f(x, (ë~
u )q(~ u , y) = g(~
u , y), ~r) where q(~ u , y, ~r)

n o
~ , q~, ~r) where pi (xi ) = fi (xi , p
(head) f0 (x, p ~ , q~, ~r) : 1 ≤ i ≤ k
n o
where qj (yj ) = gj (yj , q~, ~r) : 1 ≤ j ≤ t
n
= f0 (x, p ~ , q~, ~r) where pi (xi ) = fi (xi , p ~ , q~, ~r) : 1 ≤ i ≤ k,
o
qj (yj ) = gj (yj , q~, ~r) : 1 ≤ j ≤ t
18 1. Preliminaries
n
(Bekič-Scott) f0 (x, q, p ~ , ~r) where pi (xi ) = fi (xi , q, p ~ , ~r) : 1 ≤ i ≤ k,
n oo
q(y) = g0 (y, q, q~, p~ , ~r) where qj (yj ) = gj (yj , q, q~, p ~ , ~r) : 1 ≤ j ≤ t
n
= f0 (x, q, p
~ , ~r) where pi (xi ) = fi (xi , q, p ~ , ~r) : 1 ≤ i ≤ k,
o
q(y) = g0 (y, q, q~, p ~ , ~r), qj (yj ) = gj (yj , q, q~, p~ , ~r) : 1 ≤ j ≤ t

Proof. The (head) and (Bekič-Scott) rules are stated for the record in very
general forms which are hard to understand, and it helps to read the proof for
a special case of (head) below and to work out a special case for (Bekič-Scott)
in Problem x1B.9. Basically, these rules allow us to “flatten” nested recursions,
simply remove all the “ where s” and all the braces except the outermost ones.
(ë-subst). There is only one recursive definition in this identity, which is in
fact trivial,
u , y) = g(~
q(~ u , y, ~r) >> q(~r).
The FP property for it gives
q(~r)(~
u , y) = g(~
u , y, ~r),
so that the right-hand side of (ë-subst) has the value
u )q(~r)(~
f(x, (ë~ u , y), ~r) = f(x, (ë~
u )g(u, y, ~r), ~r);
which is the same as the value of its left-hand side.
(head). For the simple case with k = t = 1 and suppressing the dependence
on ~r which does not enter in the argument, we need to show
 n o n o
(1B-8) f0 (x, p, q) where p(u) = f1 (u, p, q) where q(v) = g1 (v, q)
n o
= f0 (x, p, q) where p(u) = f1 (u, p, q), q(v) = g1 (v, q) .
There are three recursive definitions involved in this equation:
(A) q(v) = g1 (v, q) >> q

(B) p(u) = f1 (u, p, q) >> p(q)


(
p(u) = f1 (u, p, q) pe
(C) >>
q(v) = g1 (v, q) qe
From the definitions, what we need to show is that
f0 (x, p(q), q) = f0 (x, p,
e qe),
and for this it suffices to prove that
(1B-9) q = qe, p(q) = p.
e
1B. Continuous, call-by-value recursion 19

(1) By the FP property on the second equation of (C), we have (for every
v), qe(v) = g1 (v, qe), and then the MIN property on (A) gives q v qe .
(2) The FP property on the first equation of (C) gives p(u)
e = f1 (u, p,
e qe),
and then the MIN property on (B) gives p(e q ) v pe .
(3) Consider now the two partial functions p(q) and q which by the FP
properties on (B) and (A) satisfy both equations of (C); the MIN property on
(C) then implies that pe v p(q), qe v q .
The boxed inequalities imply first that q = qe, and then
pe v p(q) = p(e
q ) v p,
e
so that all these partial functions are equal and we have p(q) = p.
e
Proof of the general case of (head) is only a notational variant of this and
the Substitution (subst) and Bekič-Scott rules (Bekič-Scott) in the theorem
are proved similarly and we leave them for the problems. a
Monotone recursion. It is well known that Theorems 1B.1 and 1B.2 hold
for monotone functionals which need not be continuous, cf. Theorem 7.36
and the problems for Chapter 7 in Moschovakis [2006]. These are classical
results of elementary set theory whose proofs require definition by transfinite
recursion and we will not need them here.

Problems for Section 1B

To solve a recursive equation (1B-1) or a system (1B-3) means to identify


the canonical solution(s) in explicit terms. For example, the solution of
(1B-10) f(x, y) = if (y = 0) then x else S(f(x, Pd(y)))
in N is the sum function g(x, y) = x + y: because
(1) every solution of (1B-10) is total by an easy induction on y, and
(2) addition satisfies (1B-10),
so f v g and hence f = g since f is total.
In the problems which follow, individual variables vary over N and function
variables vary over partial functions on N (of various arities).
x1B.1. Problem. Solve in N the recursive equation
f(x, y) = if (y = 0) then 0 else f(x, Pd(y)) + x.
x1B.2. Problem. Solve in N the recursive equation
f(x, y) = if (y = 0) then 0
else if (y = 1) then x
else 2 · f(x, iq2 (y)) + f(x, parity(y)).
20 1. Preliminaries

x1B.3. Problem. Consider the following recursive equation in N:




 r, if x = y = 0,



2f(iq2 (x), iq2 (y), 0),
 ow., if parity(x) + parity(y) + r = 0,
f(x, y, r) = 2f(iq2 (x), iq2 (y), 0) + 1, ow., if parity(x) + parity(y) + r = 1,



 2f(iq2 (x), iq2 (y), 1), ow., if parity(x) + parity(y) + r = 2,


2f(iq (x), iq (y), 1) + 1, ow,
2 2

and let f be its least solution. Prove that f(x, y, r) = x + y + r if r ≤ 1 so


that that f(x, y, 0) = x + y.
x1B.4. Problem. Solve in N the recursive equation
f(x, y) = if (φ(x, y) = 0) then y else f(x, y + 1),
2
where φ : N * N is some fixed, given partial function. Hint: Compute
f(x, x) when φ(x, y) = 0 ⇐⇒ Prime(y) & Prime(y + 2).
x1B.5. Problem (Morris, per Manna [1974]). Solve in N the recursive equa-
tion
f(x, y) = if (x = 0) then 1 else f(Pd(x), f(x, y)).
x1B.6. Problem. Solve in L∗ the recursive equation
f(u) = if (u = nil) then nil else f(tail(u)) ∗ head(u).
x1B.7. Problem. If you are not already familiar with the Fixed Point Lemma
1B.1, work out the details of the proof.
x1B.8. Problem. Prove the substitution rule (subst) in Theorem 1B.2.
x1B.9. Problem. Prove the following special case of the Bekič-Scott rule in
Theorem 1B.2:
n
f0 (x, q, p1 , p2 ) where p1 (x1 ) = f1 (x1 , p1 , p2 ), p2 (x2 ) = f2 (x2 , p1 , p2 ),
n oo
q(y) = g0 (y, r, q, p1 , p2 ) where r(u) = g1 (u, r, q, p1 , p2 )
n
= f0 (x, q, p1 , p2 ) where p1 (x1 ) = f1 (x1 , p1 , p2 ), p2 (x2 ) = f2 (x2 , p1 , p2 ),
o
q(y) = g0 (y, r, q, p1 , p2 ), r(u) = g1 (u, r, q, p1 , p2 ) .

The next problem is another very special (but important) case of the Bekič-
Scott rule; a version of this is known in classical recursion theory as the First
Recursion Theorem:
x1B.10. Problem. Let f : X × (X * W ) * W be a functional defined by
a recursion
n o
f(x, p) = f0 (x, p, q) where q(y) = f1 (y, p, q)
1C. Some basic algorithms 21

where f0 , f1 are continuous, so that f is also continuous, and suppose


p(x) = f(x, p) >> p;
prove that
n o
p(x) = p(x) where p(x) = f0 (x, p, q), q(y) = f1 (y, p, q) .

1C. Some basic algorithms

We review here briefly some classical examples of algorithms from specified


primitives, primarily to illustrate how recursive equations can be interpreted
as instructions for the computation of their least fixed points. This process
will be made precise in the next chapter.
The merge-sort algorithm. Suppose L is a set with a fixed total ordering ≤
on it. A string
v = v0 v1 · · · vn−1 = (v0 , . . . , vn−1 ) ∈ L∗
is sorted (in non-decreasing order) if v0 ≤ v1 ≤ · · · ≤ vn−1 , and for each
u ∈ L∗ , sort(u) is the sorted “rearrangement” of u,
(1C-1) sort(u) =df the unique, sorted v ∈ L∗ such that for some
permutation ð : {0, . . . , n − 1} 
→ {0, . . . , n − 1},
v = (uð(0) , uð(1) , . . . , uð(n−1) ).
The efficient computation of sort(u) is important in many computing appli-
cations and many sorting algorithms have been studied. We consider here just
one of these algorithms, which is easily expressed by a system of two, simple,
recursive equations.
The merge-sort uses as a “subroutine” an algorithm for merging two strings
specified as follows:
1C.1. Proposition. The equation
(1C-2) merge(w, v) = if (|w| = 0) then v
else if (|v| = 0) then w
else if (w0 ≤ v0 ) then (w0 ) ∗ merge(tail(w), v)
else (v0 ) ∗ merge(w, tail(v))
determines a value merge(w, v) for all strings w, v ∈ L∗ , and if w and v are
both sorted, then
(1C-3) merge(w, v) = sort(w ∗ v).
Moreover, the value merge(w, v) can be computed by successive applications
·
of (1C-2), using no more than |w| + |v| − 1 comparisons.
22 1. Preliminaries

Proof. That (1C-2) determines a function and that (1C-3) holds are both
trivial, by induction on |w| + |v|. For the comparison counting, notice first
that (1C-2) computes merge(w, v) using no comparisons at all, if one of w or
v is nil; if both |w| > 0 and |v| > 0, we make one initial comparison to decide
whether w0 ≤ v0 , and no more than |w| + |v| − 2 additional comparisons after
that (by the induction hypothesis, in either case), for a total of |w| + |v| − 1.a
In the next Chapter 2, we will make precise what it means to compute
merge(w, v) by repeated applications of (1C-2), but it is really quite obvious:
for example, when L = N with the natural ordering:
merge((3, 1), (2, 4)) = (2) ∗ merge((3, 1), (4))
= (2, 3) ∗ merge((1), (4))
= (2, 3, 1) ∗ merge(( ), (4))
= (2, 3, 1, 4).
For each sequence u with |u| = m > 1 and k = b m2 c the integer part of 21 |u|,
let:
(1C-4) half1 (u) = (u0 , . . . , uk−1 ), half2 (u) = (uk , . . . , um−1 ),
and for |u| ≤ 1, set
(1C-5) half1 (nil) = half2 (nil) = nil, half1 ((x)) = nil, half2 ((x)) = (x),
so that in any case
u = half1 (u) ∗ half2 (u)
and each of the two halves of u has length within 1 of 12 |u|.
1C.2. Proposition. The sort function satisfies the equation
(1C-6) sort(u) = if |u| ≤ 1 then u
else merge(sort(half1 (u)), sort(half2 (u)))
and it can be computed from (1C-2) and (1C-6) using no more than |u| log |u|
comparisons.
Proof. The validity of (1C-6) is immediate, by induction on |u|. To prove
the bound on comparisons, also by induction, note that it is trivial when
|u| ≤ 1, and suppose that dlog |u|e = k + 1, so that (easily) both halves of u
have length ≤ 2k . Thus, by the induction hypothesis and Proposition 1C.1,
we can compute sort(u) using no more than
k2k + k2k + 2k + 2k − 1 < (k + 1)2k+1
comparisons. a
By a basic, classical result, the merge-sort is optimal (in a very strong sense)
for the number of comparisons required to sort a string, cf. Theorem 4G.1.
1C. Some basic algorithms 23

The Euclidean algorithm. Euclid actually defined the subtractive version of


the algorithm which works by iterating the classical anthyphairesis operation
on unordered pairs, {a, b} 7→ {min(a, b), max(a, b) − min(a, b)}, The recur-
sive specification of the version with division fits better with what we will be
doing—and we could argue that it is implicit in Euclid.
1C.3. Lemma. The greatest common divisor function on N (defined by (1A-3))
satisfies the following recursive equation, which determines it:
(1C-7) gcd(x, y) = if (y = 0) then x else gcd(y, rem(x, y)).
Proof. If y 6= 0 and y - x, then the pairs {x, y} and {y, rem(x, y)} have
the same common divisors. a
Equation (1C-7) yields a procedure for computing gcd(x, y) for all x, y
using rem and eq0 :
if y = 0 give output x, else set x := y, y := rem(x, y) and repeat.
For example:
gcd(165, 231) = gcd(231, 165) cde: 165 = 231 · 0 + 165
= gcd(165, 66) cde: 231 = 165 · 1 + 66
= gcd(66, 33) cde: 165 = 66 · 2 + 33
= gcd(33, 0)
= 33.
The computation required three divisions in this case. In general, we set
c{rem} (ε, x, y) = the number of divisions required to compute
gcd(x, y) using (1C-7),
so that, directly from (1C-7), for x ≥ y ≥ 1,
(1C-8) c{rem} (ε, x, y) = if (y = 0) then 0 else 1 + c{rem} (ε, y, rem(x, y)).
1C.4. Proposition. For all x ≥ y ≥ 2, c{rem} (ε, x, y) ≤ 2 log y.
Proof is by (complete) induction on y, and we must consider three cases
(with c(x, y) = c{rem} (ε, x, y)):
Case 1, y | x; now rem(x, y) = 0 and c(x, y) = 1 + c(y, 0) = 1 ≤ 2 log y,
since y ≥ 2 and so log y ≥ 1.
Case 2, x = q1 y + r1 with 0 < r1 < y but r1 | y. Now
c(x, y) = 1 + c(y, r1 ) = 2 ≤ 2 log y since y ≥ 2.
Case 3, y = q2 r1 + r2 with 0 < r2 < r1 . If r2 = 1, then c(x, y) =
2 + c(r1 , 1) = 3, but y > r1 > r2 , so y ≥ 3 and 3 ≤ 2 log 3 ≤ 2 log y. If r2 ≥ 2,
then the induction hypothesis applies and it gives
c(x, y) = 2 + c(r1 , r2 ) ≤ 2 + 2 log r2 = 2 log(2r2 );
24 1. Preliminaries

on the other hand,


y = q2 r1 + r2 ≥ r1 + r2 > 2r2 , so 2 log y > 2 log(2r2 ) ≥ c(x, y). a

The lower bounds for the complexity measure c{rem} (ε, x, y) are best ex-
pressed in terms of the classical Fibonacci sequence, defined by the recursion

(1C-9) F0 = 0, F1 = 1, Fk+2 = Fk + Fk+1 ,


so that F2 = 0 + 1 = 1, F3 = 1 + 1 = 2, F4 = 3, F5 = 5, etc. We leave them
for the problems.
Coprimeness by the Euclidean. In the formal terminology that we will in-
troduce in the next chapter, the Euclidean is a recursive algorithm of the
structure (N, rem, eq0 ). If we use it to check the coprimeness relation, we also
need to test at the end whether gcd(x, y) = 1, so that as a decision method for
coprimeness, the Euclidean is a recursive algorithm of the structure
(1C-10) Nε = (N, rem, eq0 , eq1 ).
As we mentioned in the Introduction, it is not known whether the Euclidean
algorithm is optimal (in any natural sense) among algorithms from its natural
primitives, either for computing the gcd or for deciding coprimeness. One of
our main aims is to make these questions precise and establish the strongest,
known partial results about them.
The binary (Stein) algorithm. This modern algorithm computes gcd(x, y)
and decides x⊥ ⊥ y in O(log x + log y) steps, from “linear” operations, which
are much simpler than division.
1C.5. Proposition (Stein [1967], Knuth [1981], Sect. 4.5.2). The gcd satisfies
the following recursive equation for x, y ≥ 1, by which it can be computed in
O(log x + log y) steps:


 x if x = y,



 2 gcd(x/2, y/2) otherwise, if parity(x) = parity(y) = 0,


gcd(x/2, y) otherwise, if parity(x) = 0, parity(y) = 1,
gcd(x, y) =

 gcd(x, y/2) otherwise, if parity(x) = 1, parity(y) = 0,



 ·
gcd(x − y, y) otherwise, if x > y,


 ·
gcd(x, y − x) otherwise.
Proof. That the gcd satisfies these equations and is determined by them is
trivial. To check the number of steps required, notice that (at worst) every
other application of one of the clauses involves halving one of the arguments—
the worst case being subtraction, which, however must then be immediately
followed by a halving, since the difference of two odd numbers is even. a
1C. Some basic algorithms 25

Anticipating again terminology from the next chapter, the Stein is a recur-
sive algorithm of the structure
·
(1C-11) Nst = (N, parity, em2 , iq2 , − , =, <)
whose primitives are Presburger functions, cf. page 44.
Horner’s rule. For any field F , Horner’s rule computes the value
VF (a0 , . . . , an , x) = ÷(x) = a0 + a1 x + · · · + an x n (n ≥ 1)
of a polynomial ÷(x) of degree n using no more than n multiplications and n
additions in F as follows:
÷0 (x) = an ,
÷1 (x) = an−1 + x÷0 (x) = an−1 + an x
..
.
÷j (x) = an−j + x÷j−1 (x) = an−j + an−j+1 x + · · · + an x j
..
.
÷(x) = ÷n (x) = a0 + x÷n−1 (x) = a0 + a1 x + · · · + an x n .
This is an example of a simple but important straight line algorithm from the
field primitives of F . It can also be used to decide the (plausibly simpler)
nullity relation of degree n on F ,
(1C-12) NF (a0 , . . . , an , x) ⇐⇒ a0 + a1 x + · · · + an x n = 0,
from the primitives of (the expansion of F by the identity relation on) F,
F = (F, 0, 1, +, −, ·, ÷, =)
by adding a last line7
NF (x) = eqF (÷n (x), 0) = eqF (a0 + a1 x + · · · + an x n , 0).
It is known that Horner’s rule is optimal for many fields and inputs, both
for the number of multiplications and the number of additions that are needed
to compute VF (~ a , x) or to decide NF (~
a , x), in fact the earliest results on this
(from the 1960s) were the first significant lower bounds for natural problems
in algebra. We will establish some of them in Chapter 9.

Problems for Section 1C

x1C.1. Problem. Prove that if x > v0 > v1 > · · · > vn−1 , then the compu-
tation of merge((x), v) by (1C-2) will require n comparisons.
In the next two problems we define and analyze a simple algorithm for
sorting, which is much less efficient than the merge-sort.
7 We sometimes use eq (x, y) rather than x = y, especially when the infix notation x = y
A
might cause confusion.
26 1. Preliminaries

x1C.2. Problem. Prove that the equation


(1C-13) insert(x, u) = if (|u| = 0) then (x)
else if x ≤ u0 then (x) ∗ u
else (u0 ) ∗ insert(x, tail(u))
determines a value insert(x, u) ∈ L∗ for any x ∈ L and u ∈ L∗ , and if u is
sorted, then
(1C-14) insert(x, u) = sort((x) ∗ u).
Moreover, insert(x, u) can be computed from (1C-13) using no more than |u|
comparisons.
x1C.3. Problem (The insert-sort algorithm). Prove that the sort function
satisfies the equation
(1C-15) sort(u) = if |u| ≤ 1 then u
else insert(u0 , sort(tail(u))),
and can be computed from (1C-15) and (1C-13) using no more than 12 |u|(|u|−
1) comparisons. Illustrate the computation with some examples, and show
also that if u is inversely ordered, then this computation of sort(u) requires
exactly 21 |u|(|u| − 1) comparisons.
To see the difference between the merge-sort and the insert-sort, note that
when |u| = 64 = 26 , then the insert-sort may need as many as 2016 compar-
isons, while the merge-sort will need no more than 384. On the other hand,
as the next two problems show, there is nothing wrong with the idea of sort-
ing by repeated inserting—it is only that (1C-13) expresses a very inefficient
algorithm for insertion.
x1C.4∗ . Problem (Binary insertion). Prove that the equation
binsert(x, u) = if (|u| = 0) then (x)
else if (x ≤ half2 (u)0 )
then binsert(x, half1 (u)) ∗ half2 (u)
else half1 (u) ∗ (half2 (u)0 ) ∗ binsert(x, tail(half2 (u)))
determines a value binsert(x, u) ∈ L∗ for every x ∈ L and u ∈ L∗ , and if u is
sorted, then
binsert(x, u) = insert(x, u) = sort((x) ∗ u).
Moreover, binsert(x, u) can be computed using (for |u| > 0) no more than
b(|u|) comparisons, where
(
log m + 1, if m is a power of 2,
b(m) =
dlog me, otherwise.
1C. Some basic algorithms 27

x1C.5∗ . Problem (Binary-insert-sort). Prove that the sort function satisfies


the equation

(1C-16) sort(u) = if |u| ≤ 1 then u


else binsert(u0 , sort(tail(u))),

and can be computed from (1C-16) and the equation in Problem x1C.4∗ using
no more than s(|u|) comparisons, where for m > 0,

(1C-17) s(m) = dlog((m − 1)!)e + (m − 1) ≤ log((m − 1)!) + m.

x1C.6∗ . Problem. For the function s(m) defined in (1C-17), prove that
s(m)
limm→∞ log(m!)
= 1.

By Stirling’s formula (1A-4), m log m ∼∞ log(m!), and so the merge-sort


and the binary-insert-sort algorithms are asymptotically equally efficient for
the required number of comparisons.
We next turn to some problems related to the Euclidean algorithm.
Recall the definition of the Fibonacci sequence {Fk }k in (1C-9).

x1C.7. Problem. Prove that if ϕ = 12 (1 + 5) is the positive root of the
quadratic equation x 2 = x + 1, then for all k ≥ 2,

ϕ k−2 ≤ Fk ≤ ϕ k .
√ √
x1C.8. Problem. Prove that if ϕ = 1+2 5 and ϕ̂ = 1−2 5 are the two roots
of the quadratic equation x 2 = x + 1, then 1 < ϕ < 2, |ϕ̂| < 1. and for all k,

ϕ k − ϕ̂ k ϕk
Fk = √ ≥ √ − 1.
5 5
Hint: Use induction on k for the equation, and infer the inequality from the
ϕ̂ k
fact that √ < 1.
5
x1C.9. Problem. Prove that successive Fibonacci numbers Fk , Fk+1 with
k ≥ 2 are relatively prime, and c{rem} (ε, Fk+1 , Fk ) = k − 1.

x1C.10. Problem (Lamé’s Lemma). Prove that if y ≤ Fk with k ≥ 2, then,


for every x ≥ y, c(ε, x, y) ≤ k − 1. Hint: Use induction on k ≥ 2, checking
separately (by hand) the two basis cases k = 2, 3 and imitating the argument
in the proof of Proposition 1C.4.
28 1. Preliminaries

Lamé’s Lemma predicts the following upper bounds for c(ε, x, y) for small
values of y (and any x ≥ y):
Values of y c(ε, x, y)
1 1
2 2
3 3
4-5 4
6-8 5
9 - 13 6
These are a bit better than the simple 2 log y bound. The next two problems
clarify the situation, but require some arithmetic (of the sort that we will often
“leave for an exercise”):
x1C.11. Problem. Prove that if x ≥ y ≥ 2, then

log( 5y)
c(ε, x, y) ≤ ,
log ϕ
where ϕ is the positive root of x + 1 = x 2 .
x1C.12∗ . Problem. Prove that for all real numbers y ≥ 16,

log( 5y)
< 2 log y.
log ϕ
Hint: Check the inequality by hand for y = 16, and then check (using the
Mean value Theorem) that the function

log( 5y)
f(y) = 2 log y −
log ϕ
on R is increasing for y > 0.
x1C.13. Problem (Bezout’s Lemma). Prove that for all natural numbers
x, y ≥ 1, there exist integers α, â ∈ Z such that
gcd(x, y) = αx + ây.
In fact, we can set α = α(x, y), â = â(x, y) where the functions
α, â : N × N → Z = {. . . , −2, −1, 0, 1, 2, . . . }
are the least solutions of the following system of recursive equations, for
x ≥ y ≥ 1:
α(x, y) = if (y | x) then 0 else â(y, rem(x, y)),
â(x, y) = if (y | x) then 1
else α(y, rem(x, y)) − iq(x, y)â(y, rem(x, y)).
Use this recursion to express gcd(231, 165) as an integer, linear combination
of 231 and 165.
1D. Partial structures 29

x1C.14. Problem. Prove that two numbers x, y ≥ 1 are coprime if and only
if there exist integers α, â ∈ Z such that 1 = αx + ây.
x1C.15. Problem. For positive numbers, show: if x⊥
⊥ a and x | ab, then
x | b.
x1C.16. Problem. Prove that for all x ≥ y ≥ 1, there are infinitely many
choices of integers α and â such that
gcd(x, y) = αx + ây,
y
but only one choice such that 0 ≤ α < .
gcd(x, y)
x1C.17∗ . Problem. Define an algorithm from the primitives of a field F
which decides the nullity relation (1C-12) of degree n using no more than
n − 1 additions, along with multiplications and equality tests, and count how
many multiplications and equality tests it uses. Hint: Consider separately the
cases where the characteristic of F is 2 or 6= 2 and show first that you can test
whether a + bx = 0 using no additions or subtractions, just multiplications
and equality tests.

1D. Partial structures

To use the basic notions of equational logic in the study of recursion and
computation, we must introduce two small wrinkles: allow the interpretations
of function symbols by partial functions, since computations often diverge,
and add branching (conditionals) to the term-formation rules. We deal with
the first of these here and will move to the second in the next section.
(Many-sorted, partial) structures. A pair (S, Φ) is a vocabulary if the set of
sorts S is not empty, containing in particular the boolean sort boole and at
least one other sort, and Φ is a finite set of function symbols, each with an
assigned type of the form
type(φ) = (s1 , . . . , sn , sort(φ))
where s1 , . . . , sn ∈ S \ {boole} and sort(φ) ∈ S.
A (partial) (S, Φ)-structure is a pair
(1D-1) A = ({As }s∈S , Υ) = ({As }s∈S , {φ A }φ∈Φ ),
where each As is a set; and for each φ ∈ Φ,
if type(φ) = (s1 , . . . , sn , s), then φ A : As1 × · · · × Asn * As .
For s 6= boole, the convergent objects φ A with type(φ) = (s) are the distin-
guished elements of sort s of A.
30 1. Preliminaries

Φ-structures. Most often there is just one sort ind (other than boole): we
describe these structures as in model theory, by identifying the universe (of
individuals) A = Aind , listing Υ, and letting the notation suggest
type(φ) = (ind, . . . , ind, s)
| {z }

for every φ ∈ Φ—now called the vocabulary. The number nφ is the arity of
φ, and we allow arity(φ) = 0, in which case φ is a (boolean or individual,
perhaps diverging) constant.
A structure is relational if all its primitives are of boolean sort, e.g., if
A = (A, ≤) is an ordering.
Typical are the basic structures of unary and binary arithmetic
(1D-2) Nu = (N, 0, S, Pd, eq0 ), Nb = (N, 0, parity, iq2 , em2 , om2 , eq0 ),
where
em2 (x) = 2x, om2 (x) = 2x + 1
are the operations of even and odd multiplication by 2. More generally, for any
k ≥ 3, the structure of k-ary arithmetic is
(1D-3) Nk-ary = (N, 0, mk,0 , . . . , mk,k−1 , iqk , remk , eq0 ),
where mk,i (x) = kx + i, iqk (x) = iq(x, k) and remk (x) = rem(x, k). These
are total structures, as is the standard structure of Peano arithmetic
(1D-4) N = (N, 0, 1, +, ·, =),
as is the Lisp structure of strings (or lists) from a set L,
(1D-5) L∗ = (L∗ , nil, eqnil , head, tail, cons),
defined on page 12 (with each x ∈ L identified with the string (x)).
The Euclidean structure
(1D-6) Nε = (N, rem, eq0 , eq1 )
is partial, because rem(x, y) converges only when y 6= 0, and so is any field
F = (F, 0, 1, +, −, ·, ÷, =)
(including the reals R and the complexes C) because the quotient x ÷ y
converges only when y 6= 0.
There are many interesting examples of many-sorted structures, e.g., a vector
space V over a field F
V = (V, F, 0F , 1F , +F , −F , ·F , ÷F , 0V , +V , −V , ·)
where the last primitive · : F × V → V is scalar-vector multiplication and
the other symbols have their natural meanings. On the other hand, dealing
1D. Partial structures 31

directly with many sorts is tedious, and we will work with one-sorted Φ-
structures. The more general versions follow by “identifying” a many-sorted
A as in (1D-1) with the single-sorted
(1D-7) (]s∈S 0 As , {A0s : s ∈ S 0 }, Υ) (S 0 = S \ {boole}),
S
where ]s∈S 0 As = {(s, x) : s ∈ S 0 & x ∈ As } is the disjoint union of the
basic universes of A, A0s (t, x) ⇔ [t = s & x ∈ As ] for s 6= boole, and the
primitives in Υ are defined in the obvious way and diverge on arguments not of
the appropriate kind. We will often assume this representation of many-sorted
structures without explicit mention.
Caution! Contrary to the usual assumption in logic, we have allowed the
empty Φ-structure A = (∅, {φ A }φ∈Φ ), in which every φ A is an “empty func-
tion”. The empty structure is of no interest, of course, but it comes up in
constructions of families of structures, where At = {s ∈ B : P(s, t)} with
some P(s, t) for which it is difficult (perhaps effectively impossible) to check
whetherAt is empty. The convention is unusual but does not cause any prob-
lems.
Unified notation for functions and relations. There are still two sorts in Φ-
structures, ind and boole, and we will need to deal with both partial functions
and relations of all arities on their universe. Typically we will just call all these
objects (partial) functions and write
(1D-8) f : An * As (s ∈ {ind, boole}, Aind = A, Aboole = B),
most often skipping the tiresome side notation which explains what this “s”
stands for.
Restrictions. If A = (A, Υ) is a Φ-structure and U ⊆ A = Aind , we set
A  U = (U, {φ A  U }φ∈Φ ),
where, for any f : An * As ,
f  U (x1 , . . . , xn ) = w ⇐⇒ x1 , . . . , xn ∈ U, w ∈ Us & f(x1 , . . . , xn ) = w.
Expansions and reducts. An expansion of a Φ-structure A is obtained by
adding new primitives to A,
(A, Φ) = (A, Υ ∪ Φ).
Conversely, the reduct A  Φ0 of a structure8 A = (A, Υ) to a subset Φ0 ⊆ Φ
of its vocabulary is defined by removing all the operations in Υ \ Υ0 . For
example, the reduct of the field of real numbers to {0, +, −} is the additive
group on R,
R  {0, +, −} = (R, 0, +, −).
8 It will be convenient to allow on occasion an infinite vocabulary Φ; and in these (clearly

identified) cases, claims about Φ-structures can be interpreted, as usual, as claims about their
reducts A  Φ0 to finite subsets of Φ.
32 1. Preliminaries

Notice that we use the same symbol  for restriction to a subset and to
a sub-vocabulary, but there is no danger of confusion, even though we will
sometimes combine these two operations:
(1D-9) A  Φ0  U = (A  Φ0 )  U,
so that, for example, R  {0, 1, +, −, ·}  Z = (Z, 0, 1, +, −, ·), the ring of
integers.
Substructures. A (partial) substructure U ⊆p A of a Φ-structure A is a
structure of the same vocabulary Φ, such that U ⊆ A and for every φ ∈ Φ,
φ U v φ A , i.e.,
 
~ ∈ U n & w ∈ Us & φ U (~
x x ) = w =⇒ φ A (~
x ) = w.
A substructure U is strong (or induced) if in addition, for all φ ∈ Φ,
 
x~ ∈ U n & w ∈ Us & φ A (~x ) = w =⇒ φ U (~ x ) = w,
in which case U = A  U .
Notice that we do not require of a substructure U ⊆p A that it be closed under
the primitives of A—in particular, it need not contain all the distinguished
elements of A. This is contrary to the usual terminology in mathematics and
logic, where, for example, a subfield of a field F must (by definition) contain
0, 1 and be closed under +.−, · and ÷.
Diagrams. The (equational) diagram of a Φ-structure A is the set
eqdiag(A) = {(φ, x ~ ∈ An , w ∈ Asort(φ) and φ A (~
~ , w) : φ ∈ Φ, x x ) = w},
where for nullary φ, the entry in eqdiag(A) is (φ, φ A ).
For example, we might have
(1D-10) eqdiag(U) = {2 + 1 = 3, 2 + 3 = 5, 2 ≤ 5, 5 6≤ 1},
where U ⊆p (N, 0, 1, +, ·, ≤) with 2, 1, 3 ∈ U ; and we have used here the
obvious conventions, to write
x ) = w, R(~
φ(~ x ), ¬R(~
x)
rather than the more pedantic
(φ, x
~ , w), (R, x
~ , tt), (R, x
~ , ff)
and to use “infix notation”, i.e., write x + y rather than +(x, y).
Structures are most easily specified by giving their universe and their equa-
tional diagram—especially if they are finite; and clearly,
U ⊆p A ⇐⇒ U ⊆ A & eqdiag(U) ⊆ eqdiag(A).
Sometimes we will specify a structure A by just giving its diagram, the impli-
cation being that its universe A comprises those members of A which occur in
eqdiag(A).
1D. Partial structures 33

Homomorphisms and embeddings. A homomorphism ð : U → V of one


Φ-structure into another is any mapping ð : U → V such that
(1D-11) φ U (~
x ) = w =⇒ φ V (ð(~
x )) = ð(w) (φ ∈ Φ),
where ð(~ x ) = (ð(x1 ), . . . , ð(xn )) and, by convention ð(tt) = tt, ð(ff) = ff, so
that for partial relations it insures
RU (~
x ) =⇒ RV (ð(~
x )), ¬RU (~
x ) =⇒ ¬RV (ð(~
x )).
A homomorphism is an embedding ð : U  V if it is injective (one-to-one),
and it is an isomorphism ð : U  → V if it is a surjective embedding and, in
addition, the inverse map ð−1 : U 
→ V is also an embedding. Clearly
U ⊆p V ⇐⇒ U ⊆ V and the identity idU : U  V is an embedding.
If ð : U → A is a homomorphism, then ð[U] is the substructure of A with
universe ð[U ] and
eqdiag(ð[U]) = {(φ, ð(~
x ), ð(w)) : (φ, x
~ , w) ∈ eqdiag(U)}.
This construction is especially useful when ð : U  A is an embedding, in
which case ð : U 
→ ð[U] is an isomorphism.
These notions of structures and homomorphisms are natural in our context,
but they have unfamiliar-looking consequences; e.g., there are (obviously) no
homomorphisms ð : N → N of the Peano structure other than the identity,
but there are many (peculiar but ultimately useful) embeddings ð : U → N of
finite substructures of N into N, cf. Problem x1D.1.
Substructure generation. For a fixed Φ-structure A and any X ⊆ A, we set
G0 [X ] = X,
S
Gm+1 [X ] = Gm [X ] {w ∈ A : for some u~ ∈ Gm [X ]n and φ ∈ Φ, w = φ A (~
u )},
S
G∞ [X ] = m Gm [X ].
Gm [X ] is the subset of A generated in A by X in m steps, and by a simple
induction on m,
(1D-12) Gm+k [X ] = Gm [Gk [X ]].
The substructure of A generated by X in m steps is
(1D-13) Gm [X ] = A  Gm [X ],
so that

eqdiag(Gm [X ]))
= {(φ, u1 , . . . , uni , w) ∈ eqdiag(A) : u1 , . . . , uni , w ∈ Gm [X ] ∪ B}.
34 1. Preliminaries

~ = (x1 , . . . , xn ) ∈ An , we write
For a tuple x
S
Gm (~
x ) = Gm [{x1 , . . . , xn }], G∞ (~
x) = m Gm (~
x ),
Gm (~
x ) = A  Gm [{x1 , . . . , xn }], G∞ (~
x ) = A  G∞ [X ],
and if the structure in which these sets and substructures are computed is not
obvious from the context, we write Gm (A, x ~ ), Gm (A, x ~ ), etc.
A structure A is generated by x ~ if A = G∞ (A, x ~ ), so that if it is also finite,
then A = Gm (A, x ~ ) for some m.
Certificates. A (Φ-)certificate is a pair (U, x~ ), such that
(1D-14) ~ ∈ U n , and U = G∞ (U, x
U is a finite Φ-structure, x ~ );
and it is a certificate of or in a Φ-structure A if, in addition, U ⊆p A.
Notice that if (U, x ~ ) is a certificate, then U = Gm (U, x
~ ) for some finite m.
We will motivate the terminology in Section 4D but, basically, we will use
certificates (U, x~ ) to model computations on the input x ~.
Certificates carry some natural measures of “size” or complexity, e.g.,
depth(U, x
~ ) = min{m : U = Gm (U, x
~ )},
values(U, x
~ ) = |{w ∈ U : (φ, u~ , w) ∈ eqdiag(U) for some φ, u~ }|,
calls(U, x
~ ) = |eqdiag(U)|.
Notice that depth(U, x ~ ) depends on both U and x ~ , while values(U, x
~ ) and
calls(U, x
~ ) depend only on U.
The meanings of the first and last of these measures are obvious, and the
intermediate values(U, x ~ ) counts the number of distinct values of entries in
eqdiag(U); it may be smaller than the universe U or the number of entries in
eqdiag(U), for example if (U, (2, 3)) is the certificate of the Peano structure N
with
U = {2, 3, 5, 6}, eqdiag(U) = {2 + 3 = 5, 3 + 2 = 5, 3 + 3 = 6},
cf. Problem x1D.6.
We also need the depth of an element below a tuple,
(1D-15) depth(w; A, x
~ ) = min{m : w ∈ Gm (A, x
~ )}, (w ∈ G∞ (A, x
~ )),
and by convention,
depth(tt; A, x
~ ) = depth(ff; A, x
~ ) = 0.
~ ) = 0, and if φ A (u1 , . . . , unφ )↓ , then
Clearly, depth(xi ; A, x
depth(φ A (u1 , . . . , unφ ); A, x
~ ) ≤ max{depth(ui ; A, x
~ ) : i = 1, . . . , nφ } + 1.
The inequality is strict if sort(φ) = boole or
m = max{depth(ui ; A, x
~ ) : i = 1, . . . , nφ } =⇒ φ(~
u ) ∈ Gm (A, x
~ ).
1D. Partial structures 35

1D.1. Proposition. If (U, x


~ ) is a certificate of A and w ∈ U , then

(1D-16) depth(w; A, x
~ ) ≤ depth(w; U, x
~)
≤ depth(U, x
~ ) ≤ values(U, x
~ ) ≤ calls(U, x
~ ).
Proof is easy and we leave it for Problem x1D.7. a

Problems for Section 1D

x1D.1. Problem. (1) Give an example of an embedding φ : U  V of one


Φ-structure into another which is bijective but not an isomorphism.
(2) Let U be the finite substructure of the Peano structure N with universe
U = {1, 2, 4} and eqdiag(U) = {1 + 1 = 2, 2 · 2 = 4}, define ð : U → N by
ð(1) = 2, ð(2) = 4, ð(4) = 16, and prove that ð : U → N is an embedding.
x1D.2. Problem. Let A = (A, φ, ø) where φ is total, unary of sort ind and
ø is total, unary of sort boole, and suppose x, y, u are distinct elements of A
such that
φ(x) = u, φ(y) = x, φ(u) = x, ø(x) = ø(y) = ø(u) = tt.
Compute G0 (x, y), G1 (x, y), G2 (x, y) and G∞ (x, y) by giving their uni-
verses and equational diagrams.
~ ∈ An and m,
x1D.3. Problem. Prove that for every Φ-structure A, x

U = Gm (A, x
~ ) ⇐⇒ U = Gm (A, x
~)
 
u ∈ U k , φ ∈ Φ) φ A (~
& (∀~ u )↓ =⇒ φ A (~
u) ∈ U ∪ B .

Infer that for all m, Gm (A, x


~ ) ⊆p Gm+1 (A, x
~ ).
x1D.4. Problem. Let U be the finite substructure of the Peano structure N
specified by
U = {1, 2, 4, 8, 24}, eqdiag(U) = {1 + 1 = 2, 4 + 4 = 8, 2 · 4 = 8, 24 6= 8}.
(1) Prove that G∞ (U, {1}) (p U, so that U is not generated by {1}.
(2) Prove that G∞ (U, {1, 4}) (p U, so that U is not generated by {1, 4}.
(3) Prove that G1 (U, {1, 4, 24}) = G∞ (U, {1, 4, 24}) = U, so {1, 4, 24}
generates U.
(4) Set ð(1) = a, ð(4) = b, ð(24) = c, where a, b, c are any numbers.
What conditions must be satisfied by a, b, c so that ð can be extended to a
homomorphism ð : U → N? In particular, can a 6= 1?
x1D.5. Problem. Prove that for every certificate (U, x
~ ),
values(U, x
~ ) ≤ |U | ≤ values(U, x
~ ) + |{x1 , . . . , xn }|,
36 1. Preliminaries

(where |{x1 , . . . , xn }| may be smaller than n, because the xi ’s need not be


distinct).
x1D.6. Problem. Let U be the substructure of the Peano structure N speci-
fied by
U = {2, 3, 5, 6}, eqdiag(U) = {2 + 3 = 5, 3 + 2 = 5, 3 + 3 = 6}.
Prove that (U, (2, 3)) is a certificate in N and compute |U |, depth(U, (2, 3)),
values(U, (2, 3)) and calls(U, (2, 3)).
x1D.7. Problem. Prove Proposition 1D.1.
For some constructions with equational diagrams, it is useful to think of
them as sequences (rather than sets), as in the following
x1D.8. Problem. Prove that if (U, x
~ ) is a certificate, then we can enumerate
its diagram
 
eqdiag(U) = (φ0 , u~0 , w0 ), . . . , (φm , u~m , wm ) ,

so that each t in u~0 is xj for some j, and for each s < m, each t in the tuple
u~s+1 occurs in the sequence x ~ , u~0 , w0 , u~1 , w1 , . . . , u~s , ws ; in particular, each
structure Us with
 
eqdiag(Us ) = (φ0 , u~, w0 ), . . . , (φs , u~s , ws )

~ and so (Us , x
is generated by x ~ ) is a certificate.
x1D.9. Problem. Prove that for every (finite) vocabulary Φ, there is a num-
~ ∈ An and every m,
ber a such that for every Φ-structure A, every x
am
x )| ≤ C 2
|Gm (~ (C = n + |Φ|).
Give an example of a structure A where |Gm (x)| cannot be bounded by a
single exponential in m.

1E. Equational logic of partial terms with conditionals

With each Φ-structure A, we associate a formal language of terms, an exten-


sion of the classical language of equational logic by a branching (conditional)
construct.
Syntax. The Φ-terms with parameters from A (or A-terms) are defined by
the structural recursion

(A-terms) E :≡ tt | ff | x (x ∈ A)
| vi | φ(E1 , . . . , Enφ ) | if E0 then E1 else E2 ,
1E. Partial equational logic 37

where v0 , v1 , . . . is a fixed sequence of formal individual variables of sort ind


and φ(E1 , . . . , Enφ ) ≡ φ when nφ = 0; in other words, the terms comprise the
smallest set of strings which contains tt, ff, every x ∈ A and every variable vi
(as strings of length 1), and is closed under the formation rules for application
and branching.9 There are obvious type restrictions: for branching, for
example, it is required that sort(E0 ) ≡ boole, sort(E1 ) ≡ sort(E2 ), and then
sort(if E0 then E1 else E2 ) ≡ sort(E1 ) ≡ sort(E2 ).
The parameters of an A-term term E are the members of A which occur
in it. A term E is pure—a Φ-term—if it has no parameters, and closed if no
individual variables occur in it.
The length of a term E (as a string of symbols) and its subterms and proper
subterms are defined as usual.
We will also need the terms without conditionals, which we will now call
algebraic A-terms. They are defined by the simpler recursion

(Algebraic A-terms) E :≡ tt | ff | vi | x | φ(E1 , . . . , Enφ ).

Notice that these include terms of sort boole, e.g., tt, ff and R(E1 , . . . , En ) if
R ∈ Φ is of boolean sort, so they are more general than the usual terms of
logic which are all of sort ind.
The depth of an algebraic term is defined by the recursion

depth(tt) = depth(ff) = depth(vi ) = depth(x) = 0,


depth(φ(E1 , . . . , En )) = max{depth(E1 ), . . . , depth(En )} + 1.

Misspellings and abbreviations. Following common practice, we will sim-


plify notation by “misspelling” (or “abbreviating”) terms to help understand-
ing: we will omit (or add) parentheses, use x, y, x1 , . . . x, y, y1 , . . . rather than
the formal variables v0 , v1 , . . . , sometimes use infix notation

E + M :≡ +(E, M )

for binary function symbols, etc. We also define the propositional connectives
on terms of boolean sort using the conditional:

(1E-1) ¬ E :≡ if E then ff else tt,


E1 & E2 :≡ if E1 then E2 else ff,
E1 ∨ E2 :≡ if E1 then tt else E2 ,
E1 → E2 :≡ ¬E1 ∨ E2 , E1 ↔ E2 :≡ (E1 → E2 ) & (E2 → E1 ).

9 We do not allow variables of boolean sort, a convenient choice which does not affect in any

serious way the breadth of applicability of the results we will prove.


38 1. Preliminaries

Semantics. For a fixed Φ-structure A, we define


den : {closed A-terms} * A ∪ B
by the obvious recursive clauses:
den(tt) = tt, den(ff) = ff, den(x) = x (x ∈ A),
A
den(φ(M1 , . . . , Mnφ )) = φ (den(M1 ), . . . , den(Mnφ ))

den(M1 ), if den(M0 ) = tt,

den(if M0 then M1 else M2 ) = den(M2 ), if den(M0 ) = ff


↑, otherwise.
We call den(M ) the denotation of the closed A-term M (if den(M )↓ ), and in
that case, clearly
sort(M ) = boole =⇒ den(M ) ∈ B, sort(M ) = ind =⇒ den(M ) ∈ A.
When we need to exhibit the structure in which the denotation is computed,
we write den(A, M ) or we use model-theoretic notation,
(1E-2) A |= E = M ⇐⇒df den(A, E) = den(A, M ) (E, M closed).
Partiality introduces some complications which deserve notice. For exam-
ple, if we view subtraction as a partial function on N, then for all x, y, z ∈ N,
(N, 0, 1, +, −) |= (x + y) − y = x;
but if x < y, then
(N, 0, 1, +, −) 6|= (x − y) + y = x
because (x − y) ↑—and then, by the strictness of composition, (x − y) + y ↑
also. On the other hand,
den(M0 ) = tt =⇒ den(if M0 then M1 else M2 ) = den(M1 ),
whether den(M2 ) converges or not.
Extended terms. An extended term of arity n is a pair
E(x1 , . . . , xn ) :≡ (E, (x1 , . . . , xn ))
of a term E and a sequence of distinct variables which includes all the variables
that occur in E. The notion provides a useful notation for substitution: if
M1 , . . . , Mn are terms of sort ind, then
E(M1 , . . . , Mn ) :≡ E{x1 :≡ M1 , . . . , xn :≡ Mn }
= the result of replacing every occurrence of each xi in E by Mi
which is also (easily) a term. In particular, if x1 , . . . , xn ∈ A, then
E(x1 , . . . , xn ) ≡ E{x1 :≡ x1 , . . . , xn :≡ xn }
is the closed A-term constructed by replacing each xi by xi .
1E. Partial equational logic 39

Extended terms provide a notational convention which facilitates dealing


with substitutions and the pedantic distinction between “terms” and “ex-
tended terms” is not always explicitly noted: we will sometimes refer to “a
term E(~x)”, letting the notation indicate that we are specifying both a term E
and a list ~x = (x1 , . . . , xn ) of distinct variables, or refer to “a term E” when
we mean an extended term E(~x), assuming that the variable list ~x is supplied
by the context. The default is that by “term” we mean “extended term”.
We extend the notation in (1E-2) to terms which need not be closed by
(1E-3) A |= E = F ⇐⇒ (∀~
x )[A |= E(~
x ) = M (~
x )],
where ~x is any list of (distinct) variables which includes all the variables that
occur in E or M (where the choice of ~x does not matter, easily), and
(1E-4) |= E = M ⇐⇒ (∀A)[A |= E = M ].
Explicit definability. A partial function f : An * As is explicitly defined or
just explicit in A if for some extended, pure Φ-term E(~x),
(1E-5) x ) = den(A, E(~
f(~ x )) x ∈ An );
(~
and sometimes we will save some dots, by calling f : An * Am of arity n
and co-arity m explicit in A, if f(~
x ) = (f1 (~
x ), . . . , fm (~
x )) with A-explicit
f1 , . . . , fm .
More generally, a functional
(1E-6) f : An × (An1 * As1 ) × · · · × (Ank * Ask ) * As
on the set A is explicit in A if
(1E-7) x , r1 , . . . , rk ) = den((A, r1 , . . . , rk ), E(~
f(~ x )),
where E(~x) is now a (pure, extended) Φ ∪ {r1 , . . . , rk }-term in the expansion
of the vocabulary Φ by fresh10 function symbols ~r of the appropriate arities
and sorts, so that it can be evaluated in arbitrary expansions (A, r1 , . . . , rk ) of
A. We set
Expl(A) = the class of all A-explicit partial functions and functionals.
Notice that not all the variables in the list ~x need occur in E(~x) in (1E-5),
(1E-7) so that, for example, the projection functions
(1E-8) Pin (x1 , . . . , xn ) = xi (1 ≤ i ≤ n)
are explicit in every structure. Combined with the strict understanding of
composition of partial functions in (1A-9), this implies that Expl(A) does not
10 The notion of a fresh object (or sequence of objects) is deep and hard to make precise—but

well-understood and routinely used in mathematical discourse: roughly, the objects x1 , . . . , xn


(of any kind) are fresh if they are different from each other and from any other object which has
been specified in the current context.
40 1. Preliminaries

have nice properties when A is not sufficiently rich, e.g., it need not be closed
under composition, cf. Problem x1E.9.
1E.1. Proposition. For every Φ-structure A, Expl(A) is the smallest class E of
functionals on A (as in (1E-6)) which contains all n-ary functions x
~ 7→ tt, x
~ 7→ ff
and all projections Pin and is closed under the following operations:
(1), Mangling, as in (1A-15),
f(x1 , . . . , xn , r1 , . . . rm ) = h(xð(1) , . . . , xð(k) , ró(1) , . . . , ró(l ) ).
(2), Substitution into the primitives, f(~ x , ~r) = φ A (h1 (~ x , ~r), . . . , hm (~
x , ~r)).
(3), Substitution into applications, f(~ x , p, ~r) = p(h1 (~ x , ~r), . . . , hm (~x , ~r)).
(4), Branching, f(~ x , ~r) = if h1 (~
x , ~r) then h2 (~ x , ~r) else h3 (~ x , ~r).
Proof. To prove that Expl(A) is closed under (1) – (4), we need to verify
some simple, natural closure properties of the set of terms; and the proof that
if E has these properties, then it contains every explicit f is by induction on the
term E which defines f. Both arguments are simple exercises in using the de-
finition and properties of the denotation function (especially Problem x1E.4)
and we skip them, except for one small part which we put in Problem x1E.8.a
1E.2. Proposition. Every A-explicit functional is continuous.
Proof. It is enough to check that the collection of continuous functionals
on A is closed under definitions (1) – (4) in Proposition 1E.1. To take just one
case which explains the (obvious) idea, suppose
f(x, r) = φ A (h1 (x, r), h2 (x, r))
with continuous h1 (x, r), h2 (x, r).
To verify first that f(x, r) is monotone, assume that r v r 0 and compute:
φ A (h1 (x, r), h2 (x, r)) = w
=⇒ h1 (x, r)↓ & h2 (x, r)↓ & φ A (h1 (x, r), h2 (x, r)) = w,
but, by the hypothesis, h1 (x, r 0 ) = h1 (x, r) & h2 (x, r 0 ) = h2 (x, r),
and so φ A (h1 (x, r 0 ), h2 (x.r 0 )) = φ A (h1 (x, r), h2 (x.r)) = w.
For the compactness of f(x, r), similarly,
φ A (h1 (x, r), h2 (x, r)) = w
=⇒ h1 (x, r)↓ & h2 (x, r)↓ & φ A (h1 (x, r), h2 (x, r)) = w;
by the assumed compactness and monotonicity of h1 , h2 , there are finite r1 v r
and r2 v r such that
h1 (x, r) = h1 (x, r1 ) = h(x, r1 ∪ r2 ), h2 (x, r) = h2 (x, r2 ) = h2 (x, r1 ∪ r2 ),
where r1 ∪ r2 is the finite “union” of r1 and r2 and
φ A (h1 (x, r), h2 (x, r)) = φ A (h1 (x, r1 ∪ r2 ), h2 (x, r1 ∪ r2 )). a
1E. Partial equational logic 41

By Problem x1E.9, Expl(A) is not, in general, closed under substitutions


and ë-substitutions. The next Proposition is about the best result we can prove
in this direction, and we will need it:
1E.3. Proposition (Immediate ë-substitution). If h(~y , ~r1 , q, ~r2 ) is explicit in
A, then so is the functional
(1E-9) f(~ ~ , p, ~r1 , ~r2 ) = h(~
x, y y , ~r1 , (ë~
u )p(~ ~ ), ~r2 ).
x , u~ , y

Proof is by checking that the class of functionals h for which the Propo-
sition holds satisfies the hypothesis of Proposition 1E.1, and it is trivial in all
cases except (3) when the variable q is involved: i.e., with k = 2 and skipping
~r1 , ~r2 which do not enter the argument,
y , q) = q(h1 (~
h(~ y , q), h2 (~
y , q)).
We compute:

f(~
x, y
~ , p)
 
= (ëu, v)p(~
x , u, v) h1 (~ y , (ëu, v)p(~x , u, v)), h2 (~
y , (ëu, v)p(~x , u, v)
 
=p x ~ , h1 (~
y , (ëu, v)p(~x , u, v)), h2 (~
y , (ëu, v)p(~x , u, v))
= p(~
x , f1 (~ ~ , p), f2 (~
x, y x, y
~ , p))
with explicit f1 , f2 by the induction hypothesis, so f(~ ~ , p) is explicit.
x, y a

Such appeals to Proposition 1E.1 are most often the simplest way to verify
properties of all A-explicit functionals, but sometimes it is just simpler to use
directly their definition. A case in point is the following easy and useful result:
1E.4. Proposition. If the vocabulary Φ has a relation symbol R of arity k > 0
and A is a Φ-structure such that RA : Ak → B is total, then Expl(A) is closed
under the substitution operation (1A-12) and ë-substitution (1A-13):
x , ~r) = g(h1 (~
f(~ x , ~r), . . . , hk (~
x , ~r), ~r), f(~
x, y ~ , ~r) = h(~
~, p y , (ë~
u )g(~
u, x ~ ), ~r).
~, p
Proof. For substitution, with k = 2 and suppressing ~r which does not enter
the argument, we need to prove that if
x ) = g(h(~
f(~ x ))
and h(~
x ), g(u) are A-explicit, then so is f(~
x ).
Fix pure, extended terms M (~x) and E(u) such that
x ) = den(M (~
h(~ x )), g(u) = den(E(u)).
Supposing that R is unary, let
F (x) :≡ if R(M (x)) then E(M (x)) else E(M (x))
42 1. Preliminaries

and appeal to Problem x1E.4 to check that


x ) = den(F (~
f(~ x ));
and if R is not unary, replace R(M (x)) by R(M (x), M (x), . . . , M (x)) in the
definition of F (~x).
The argument for ë-substitutions is easier, by appealing to Proposition 1E.1
and we leave it for Problem x1E.11. a

Problems for Section 1E

x1E.1. Problem (Parsing for terms). Prove that for any Φ-structure A, every
A-term E satisfies exactly one of the following conditions.
1. E ≡ tt, or E ≡ ff, or E ≡ x for some x ∈ A, or E ≡ v for a variable v.
2. E ≡ φ(E1 , . . . , En ) for a uniquely determined φ ∈ Φ and uniquely
determined terms E1 , . . . , En .
3. E ≡ if E0 then E1 else E2 for uniquely determined E0 , E1 , E2 .
x1E.2. Problem. Prove that if ð : A → B is an isomorphism between two
Φ-structures, then for every extended Φ-term E(~x),
x ) = w ⇐⇒ B |= E(ð(~
A |= E(~ x )) = ð(w), (x1 , . . . , xn , w ∈ A).
x1E.3. Problem. Give an example of two (extended) terms E1 (x) and E2 (x)
such that for every x ∈ A, den(E1 (x)) = den(E2 (x)), but if M is closed and
den(M ) ↑, then den(E1 (M )) 6= den(E2 (M )).
x1E.4. Problem. Prove that for every term E(x) and closed term M ,
den(M ) = w =⇒ den(E(M )) = den(E(w)).
x1E.5. Problem. Prove that for any two terms E1 (x), E2 (x), if M is closed,
den(M )↓ and den(E1 (x)) = den(E2 (x)) for every x ∈ A, then
den(E1 (M )) = den(E2 (M )).
These results extend trivially to simultaneous substitutions.
x1E.6. Problem (Homomorphism property). Prove that if ð : A → B is a
homomorphism of one Φ-structure into another, then for every Φ-term M (~x)
~ ∈ An ,
and all x
if den(A, M (~
x ))↓ , then ð(den(A, M (~
x )) = den(B, M (ð(~
x )))
where, naturally, ð(x1 , . . . , xn ) = (ð(x1 ), . . . , ð(xn )).
x1E.7. Problem. For each of the following (and with the definitions in (1E-1),
(1E-4)) determine whether it is true or false for all terms of boolean sort:
(1) |= if φ then ø1 else ø2 = if ¬φ then ø2 else ø1 .
1E. Partial equational logic 43

(2) |= ¬(φ & ø) = (¬φ) ∨ (¬ø).


(3) |= ¬(φ & ø) ↔ (¬φ) ∨ (¬ø) = tt.
(4) |= φ & ø = ø & φ.
x1E.8. Problem. Prove that if h1 (x, r) and h2 (x, r) are continuous function-
als on A and
f(x, p, r) = p(h1 (x, r), h2 (x, r)),
then f(x, p, r) is also continuous. (This is one part of the proof of Proposi-
tion 1E.1.)
x1E.9. Problem. Let A = (A, φ) where A is any non-empty set, φ : A * A
is not total, and for some ordering ≤ on A,
φ(x)↓ =⇒ x < φ(x).
(1) Let tt1 (x) = tt be the explicit, total unary function with constant value
tt and check that the composition
f(x) = tt1 (φ(x))
is not explicit.
(2) Prove that with P12 (x, y) = x, the (explicit) projection on the first vari-
able, there are explicit partial functions h1 (x), h2 (x) such that the composition
f(x) = P12 (h1 (x), h2 (x))
is not A-explicit.
(3) Prove that there is an A-explicit functional g(x, p) (with p binary) and
an A-explicit partial function h(u, v) such that the partial function f(x) =
g(x, (ëu, v)h(u, v)) is not A-explicit.
Hint: The only pure terms of sort boole are tt and ff, and the only terms
of sort ind are x, φ(x), φ(φ(x)), . . . .
x1E.10. Problem. Prove that if A is total, then the composition
x ) = g(h1 (~
f(~ x ), . . . , hm (~
x ))
of A-explicit functions is also A-explicit. Hint: Apply Problem x1E.4 to the
term that defines g(w)
~ by (1E-5).
x1E.11. Problem. Prove that if the vocabulary Φ has a relation symbol R
of arity k > 0 and A is a Φ-structure such that RA : Ak → B is total, then
Expl(A) is closed under ë-substitutions (1A-13).
x1E.12∗ . Problem (Explicit expansions). Suppose the vocabulary Φ has a
relation symbol R of arity k > 0 and A is a Φ-structure such that RA : Ak → B
is total. Suppose f : An * A is explicit in A. Let f be a fresh function symbol
and let (A, f) be the expansion of A in which f is interpreted by f. Define a
mapping
M 7→ M ∗
44 1. Preliminaries

which assigns to each term M in the vocabulary Φ ∪ {f} a Φ-term M ∗ with


the same variables, so that
y )) = den(A, M ∗ (~
den((A, f), M (~ y )).
Infer that Expl(A, f) = Expl(A), which extends and implies the result in
Problem 1E.4.
Prove also by a counterexample that the hypothesis about R cannot be
removed.
~ ∈ An ,
x1E.13. Problem. Prove that for every m and x

Gm (A, x
~ ) = {den(A, E(~
x )) : E(~x) is pure, algebraic,
sort(E) = ind and depth(E) ≤ m},
by the definition of “depth” for algebraic terms on page 37.
x1E.14. Problem. Prove that a partial function f : An * As is A-explicit if
and only if there are pure, algebraic terms Ci (~x) of boolean sort and algebraic
terms Vi (~x) such that


 den(V0 (~ x )) if den(C0 (~ x )) = tt,



 den(V 1 (~
x )) ow., if den(C 0 (~
x ))↓ & den(C1 (~
x )) = tt,
f(~x) = .
..



 den(Vk (~ x )) ow., if den(Ck−1 (~ x ))↓ & den(Ck (~
x )) = tt,


den(Vk+1 (~ x )) ow., if den(Ck (~x ))↓ .
Infer that for a total structure A, a relation R ⊆ An is A-explicit if and only if
it is definable by a quantifier-free formula, as these are defined in (1E-1).
This representation of explicit functions and relations is especially interest-
ing (and has been much studied) for the Presburger structure11
·
(1E-10) NPres = (N, 0, 1, +, − , <, eqN , {remm , iqm }m≥2 ),
where remm (x) = rem(x, m), iqm (x) = iq(x, m). This is because a total
function f : Nn → N is explicit in NPres —a Presburger function—exactly when
its graph is definable in additive arithmetic
N+ = (N, 0, 1, +, eqN ),
a corollary of the classical quantifier elimination result for Presburger arith-
metic, cf. Enderton [2001]. The Presburger functions are piecewise linear in
the following, precise sense:
x1E.15∗ . Problem. Prove that if f : Nn → N is a Presburger function,
then there is a partition of Nn into disjoint sets D1 , . . . , Dk ⊆ Nn which are

11 The Presburger structure has an infinite vocabulary, see Footnote 8 on page 31.
1E. Partial equational logic 45

definable by quantifier free formulas of NPres , such that for each i = 1, . . . , k,


and suitable rational numbers q0 , q1 , . . . , qn ,
x ) = q0 + q1 x1 + · · · + qn xn
f(~ (~
x ∈ Di ).
Hint: Check that the result holds for the primitives of NPres and that the
class of functions which satisfy it is closed under composition. Notice that
f(~x ) ∈ N in this expression, although some of the qi ∈ Q may be proper,
positive or negative fractions.
The claims in the next three problems will follow from results that we will
prove later, but perhaps there are elementary proofs of them that can be given
now—I do not know such easy proofs:
x1E.16∗ . Problem. Prove that the successor function S : N → N is not
explicit in binary arithmetic Nb .
x1E.17∗ . Problem. Prove that the parity relation
parity(x) ⇐⇒ 2 | x
is not quantifier-free definable in unary arithmetic Nu , and the successor
relation
S(x, y) ⇐⇒ x + 1 = y
is not quantifier-free definable in binary arithmetic Nb .
x1E.18∗ . Problem. Prove that the divisibility relation
x | y ⇐⇒ y 6= 0 & rem(x, y) = 0
is not quantifier-free definable in the Presburger structure NPres .
Part I. Abstract (first order) recursion
CHAPTER 2

RECURSIVE (McCARTHY) PROGRAMS

Recursive programs are deterministic versions of the classical Herbrand-Gödel-


Kleene systems of recursive equations and they can be used to develop very
elegantly the classical theory of recursive (computable) functions and function-
als on the natural numbers. Here we will study them on arbitrary (partial)
structures, and we will use them primarily to introduce in the next chapter
some natural and robust notions of complexity for algorithms which compute
functions from specified primitives.
We will also introduce and establish the basic properties of (finitely) nonde-
terministic recursive programs in Section 2E.
Recursive programs were introduced in McCarthy [1963], a fundamental
contribution to the foundations of the theory of computation. It extended the
earlier McCarthy [1960] and introduced many ideas and techniques which we
take for granted today. Much of what we do in this chapter can be read as an
exposition of the theory developed in McCarthy [1963], except that we take
least-fixed-point recursion to be the fundamental semantic notion.12

2A. Syntax and semantics

Programs. A (deterministic) recursive program on the vocabulary Φ (or the


Φ-structure A) is a syntactic expression
n o
(2A-1) E ≡ E0 where p1 (~x1 ) = E1 , . . . , pK (~xK ) = EK

which satisfies the following conditions:

12 This work of McCarthy is not as well known or appreciated as it should be: there are al-

most no citations of it in early textbooks and articles on the theory of computation by computer
scientists, with the notable exception of Manna [1974] whose last chapter on the Fixpoint Theory
of Programs explains (and extends considerably) McCarthy’s ideas; and the logicians who devel-
oped abstract (and higher type) recursion theory starting in the late 1950s worked in complete
ignorance of McCarthy’s work—including the author of Moschovakis [1989a] who will forever
be embarrassed by this.

49
50 2. Recursive (McCarthy) programs
(1) p1 , . . . , pK are distinct function symbols not in Φ, the recursive variables
of E.
(2) Each Ei (0 ≤ i ≤ K ) is a pure term in the program vocabulary
voc(E) = Φ ∪ {p1 , . . . , pK }.
(3) Each ~xi (1 ≤ i ≤ K ) is a list of distinct individual variables which
includes all the individual variables that occur in Ei .
(4) The arities and sorts of the recursive variables p1 , . . . , pK and the sorts
of the parts Ei of E are such that the equations within the braces make
sense.
The term E0 is the head of E, the system of equations
(2A-2) p1 (~x1 ) = E1 , . . . , pK (~xK ) = EK
within the braces is its body, and we allow K = 0 in this definition, so that
every pure Φ-term is identified with a program with empty body,
E ≡ E where { }.
A program with non-empty body will be interpreted as a mutual recursive
definition, a formal version of the where -notation introduced in Section 1B.
We allow arity(pi ) = 0, in which case the equation for pi in (2A-1) has
the form “pi = Ei ,” the list of variable ~xi is empty and Ei is a pure, closed
voc(E)-term, i.e., a nullary constant φ or function variable pj of either sort.
Free and bound occurrences of variables. All occurrences of the recursive
variables p1 , . . . , pK and all occurrences of individual variables in the body of
a program E are bound in E; the free variables of E (if any) are the individual
variables which occur in the head term E0 .
In general, we think of recursive programs as generalized pure Φ-terms
and we define extended Φ-programs as we did for terms: if the list of distinct
variables ~x ≡ x1 , . . . , xn includes all the free individual variables of E (those
which occur in the head E0 ), then
n o
(2A-3) E(~x) ≡df (E,~x) ≡ E0 (~x) where p1 (~x1 ) = E1 , . . . , pK (~xK ) = EK .

As with terms, we will often refer ambiguously to “the program E(~x)” or


“the program E”, letting the notation and the context specify whether we are
talking about a “plain” or an extended program, but the default is “extended”.
We set
sort(E) = sort(E0 ), arity(E(~x)) = arity(E(x1 , . . . , xn )) = n.
All the recursive equations and systems of equations in the problems of Sec-
tions 1A and 1C are really extended recursive programs, just not sufficiently
formalized. Problem x1C.13, for example, determines two programs on the
2A. Syntax and semantics 51

structure (Z, 0, 1, +, −, ·, rem, iq, eq0 ), one for each of the needed coefficients
in Bezout’s Lemma: the first is
n
α(x, y) where α(x, y) = if (rem(x, y) = 0) then 0 else â(y, rem(x, y)),
â(x, y) = if (rem(x, y) = 0) then 1
o
else α(y, rem(x, y)) − iq(x, y) · â(y, rem(x, y))

and the second is obtained from this by changing the head to â(x, y). Both
programs have the binary recursive variables α and â.
In some cases we express algorithms by a single recursive equation, e.g.,
gcd(x, y) = if (y = 0) then x else gcd(y, rem(x, y))
for the Euclidean, and then we need to add a trivial head term to accord with
the “official” definition: so the formal recursive program which expresses the
Euclidean is

(2A-4) Eε (x, y) ≡ p(x, y) where


n o
p(x, y) = if eq0 (y) then x else p(y, rem(x, y)) .

We will assume that this addition of a head term is done when needed.13
Semantics. Fix an extended recursive program E(~x) on the vocabulary Φ
as in (2A-3) and a Φ-structure A, let p
~ = (p1 , . . . , pK ) and set
f0 (~ ~ ) = den((A, p
x, p ~ ), E0 (~
x )),
(2A-5)
fi (~ ~ ) = den((A, p
xi , p ~ ), Ei (~
xi )) (i = 1, . . . , K ).
These functionals are continuous by Proposition 1E.2, so we can set

(2A-6) den(A, E(~ x )) = denA


E(~x) (~
x)
n o
=df f0 (~ ~ ) where p1 (~
x, p x1 ) = f1 (~ ~ ), . . . , pK (~
x1 , p xK ) = fK (~ ~)
xK , p

using the where construct introduced in Section 1B.


We say that the partial function denA E(~x)
: An * As is defined (or computed)
in A by E(~x) and den(A, E(~ x )) is the denotation of E(~x) in A at x
~ . We also use
model–theoretic notation,
(2A-7) x ) = w ⇐⇒df den(A, E(~
A |= E(~ x )) = w.
If E ≡ E0 is a program with no body, then this agrees with the definition of
den(E0 ) in Section 1E.

13 Notice that the variables x, y occur both free (in the head) and bound (in the bodies) of these

examples, a practice that is sometimes not allowed in formal languages but is very convenient in
the formal study of recursive equations.
52 2. Recursive (McCarthy) programs
More generally, if~r = r1 , . . . , rm is a list of distinct function symbols (other
than the pj ) and every Ei is a pure term in
voc(E) = Φ ∪ {p1 , . . . , pK , r1 , . . . , rm },
then (2A-3) is an extended recursive program on Φ with parameters (or free
function variables) ~r which is naturally interpreted in expansions
(A, ~r) = (A, Υ, r1 , . . . , rk )
of a Φ-structure A. The parts of E(~x) define now functionals
f0 (~ ~ , ~r) = den((A, p
x, p ~ , ~r), E0 (~
x )),
(2A-8)
fi (~ ~ , ~r) = den((A, p
xi , p ~ , ~r), Ei (~
xi )) (i = 1, . . . , K )

and E(~x) defines (or computes) in A the functional

(2A-9) denA
E(~x) (~
x , ~r)
n o
=df f0 (~ ~ , ~r) where p1 (~
x, p x1 ) = f1 (~ ~ , ~r), . . . , pK (~
x1 , p xK ) = fK (~ ~ , ~r) .
xK , p

A-recursive functions and functionals. A functional f(~


x , ~r) on A is recursive
in A or recursive from (or in) the primitives Υ = {φ A : φ ∈ Φ} of A, if it is
defined by some A-recursive program with function parameters, i.e., if

(2A-10) x , ~r) = f0 (~
f(~ ~ , ~r)
x, p
n o
where p1 (~ x1 ) = f1 (~ ~ , ~r), . . . , pK (~
x1 , p xK ) = fK (~ ~ , ~r)
xK , p

with A-explicit functionals f0 , . . . , fK . We set


(2A-11) Rec(A) = the set of all A-recursive functionals,
and to state results for partial functions only,
(2A-12) Rec0 (A) = the set of all A-recursive partial functions.

The classical example is the (total) structure Nu = (N, 0, S, Pd, eq0 ) of unary
arithmetic whose recursive partial functions and functionals are exactly the
Turing computable ones, an elegant characterization of Turing computability
due to McCarthy [1963], cf. Proposition 2C.3.14
2A.1. Theorem (The First Recursion Theorem). The class Rec(A) is closed
under recursive definitions: i.e., if (2A-10) holds with A-recursive functionals
f0 , . . . fk , then f is also A-recursive.

14 More precisely, these are the classical deterministic recursive functionals on N; we will intro-

duce the nondeterministic ones in Section 2E.


2A. Syntax and semantics 53

Proof is by induction on the number of functionals in (2A-10) which are


not explicit.
If the head f0 (~ ~ , ~r) in (2A-10) is not explicit, then
x, p
n o
f0 (~ ~ , ~r) = g0 (~
x, p x, p~ , ~r, q~) where q1 (~
y1 ) = g(~ ~ , ~r, q~), . . .
x, p

with suitable explicit functionals g0 , g1 , . . . ; so


n o
f(~ x , ~r) = f0 (~ ~ , ~r) where p1 (~
x, p x1 ) = f1 (~ x1 , p~ , ~r), . . . ,
 n o
= g0 (~ x, p ~ , ~r, q~) where q1 (~ y1 ) = g(~ x, p~ , ~r, q~), . . .
n o
where p1 (~ x1 ) = f1 (~ x1 , p ~ , ~r), . . . ,
n o
= g0 (~
x, p ~ ,~r, q~) where q1 (~ y1 ) = g(~ ~ , ~r, q~), . . . , p1 (~
x, p x1 ) = f1 (~ x1 , p ~ , ~r), . . . , ,

the last step by the (head) rule of Theorem 1B.2, and this recursive definition
of f involves one fewer functional which is not explicit.
If f0 (~ ~ , ~r) is explicit, we can simplify the definition of f by applying
x, p
in the same way the (Bekič-Scott) rule of Theorem 1B.2 to some fi , cf.
Problem x2A.4. a
In effect, the (head) and (Bekič-Scott) rules allow us to remove from n any
expression with nested occurrences of the where-construct all the braces and
o
other than the first and last without changing the value—messy to write up
in full generality but basically trivial and easy to apply in specific recursive
definitions.
The name of the theorem comes from the special case
n o
(2A-13) x ) = p(~
f(~ x ) where p(~x ) = f1 (~
x , p)

by which the least fixed point of every recursive functional is recursive and which
is often dubbed the First Recursion Theorem, at least for Nu .
The First Recursion Theorem combines easily with the recursive rules in
Theorem 1B.2 to yield the elementary closure properties of Rec(A):
2A.2. Corollary. Every A-explicit functional is recursive in A, and Rec(A) is
closed under the elementary operations on functionals in (1A-12) – (1A-15):
(Substitution) f(~ x , ~r) = g(h1 (~ x , ~r), . . . , hk (~
x , ~r), ~r)
(ë-substitution) f(~
x, y ~, p ~ , ~r) = h(~ x , (ë~ u )g(~u, y~, p~ ), ~r)
(Branching) f(~ x , ~r) = if h(~ x , ~r) then g1 (~ x , ~r) else g2 (~
x , ~r)
(Mangling) f(x1 , . . . , xn , r1 , . . . , rm )
= h(xð(1) , . . . , xð(k) , ró(1) , . . . , ró(l ) ).
54 2. Recursive (McCarthy) programs
Proof. For a simple case of mangling which illustrates the trivial argument
that works in general, suppose

f(x, r1 , r2 ) = h(x, x, r1 ),
n o
with h(u1 , u2 , q) = h0 (u1 , u2 , p, q) where p(w) = h1 (w, p, q)

and explicit h0 , h1 ; it follows that


n o
f(x, r1 , r2 ) = h0 (x, x, p, r1 ) where p(w) = h1 (w, p, r1 )

and so f is recursive because the class of explicit functionals is closed under


mangling by Problem x1E.8.
The argument for branching is equally trivial.
Substitution. Suppressing the variables ~r which do not enter the argument,
we start with the obvious

x ) = g(h1 (~
f(~ x ), . . . , hk (~
x )) = p(q1 (~
x ), . . . , qk (~
x ))
n o
where q1 (~ x ) = h1 (~
x ), . . . , qk (~
x ) = hk (~
x ), p(~
y ) = g(~
y)

and then apply the First Recursion Theorem 2A.1.


ë-substitution. Suppressing again the variables p
~ , ~r, we start with

(2A-14) f(~ ~ ) = h(~


x, y x , (ë~
u )g(~ ~ ))
u, y
n o
= h(~
x , (ë~
u )p(~ ~ )) where p(~
u, y ~ ) = g(~
u, y ~) .
u, y

To simplify the notation further, suppose that the given recursive definition
of h(~
x , q) has only one equation in its body and rewrite it to insert a dummy
dependence of the recursive variable r on x ~ ,15
~, y
n o
h(~x , q) = h0 (~x , r, q) where r(~z ) = h1 (~z , r, q)
n o
= h0 (~x , (ë~
z )r(~z, x ~ ), q) where r(~z , x
~, y ~ ) = h1 (~z , (ë~z )r(~z , x
~, y ~ ), q) ;
~, y

if we now set q = (ë~


u )p(~
u, x ~ ) in this equation, we get
~, y

x , (ë~
h(~ u )p(~
u, x ~ )) = h0 (~
~, y x , (ë~z )r(~z , x ~ ), (ë~
~, y u )p(~ u, x
~, y~ ))
n o
where r(~ z, x
~, y~ ) = h1 (~z , (ë~z )r(~z , x ~ ), ë(u)p(~
~, y u, x ~) ;
~, y

15 This maneuver of adding dummy variables is needed because we did not allow the functionals

fi (xi , p
~ , ~r) in the body of a recursive definition (1B-7) with head f0 (y, p
~ , ~r) to depend on the
variable y—which complicates this proof, but simplifies considerably the formulation of the
recursion rules in Theorem 1B.2.
2A. Syntax and semantics 55

and if we use this expression in (2A-14), we get



f(~ ~ ) = h0 (~
x, y x , (ë~
z )r(~
z, x ~ ), (ë~
~, y u )p(~
u, x~, y~ ))
n o
where r(~ z, x
~, y~ ) = h1 (~z , (ë~z )r(~z , x ~ ), ë(u)p(~
~, y u, x ~)
~, y
n o
where p(~ u, x
~, y~ ) = g(~ ~) .
u, y
The functional h0 (~x , (ë~
z )r(~
z, x ~ ), (ë~
~, y u )p(~
u, x ~ )) is explicit (and hence re-
~, y
cursive) by Proposition 1E.3 and all the other functionals on the right-hand
side in this equation are recursive by the hypothesis; so the First Recursion
Theorem 2A.1 applies and f(~ x, y~ ) is recursive. a

Problems for Section 2A

In the first five problems we formulate precisely some simple properties of


the semantics of recursive programs which follow easily from the definitions.
x2A.1. Problem (Change of order in the body). Prove that for any Φ-struct-
ure A, any extended Φ-program E(~x) with E as in (2A-1) and any permutation
ð : {1, . . . , K } 
→ {1, . . . , K }, if
n o
E 0 ≡ E0 where pð(1) (~xð(1) ) = Eð(1) , . . . , pð(K ) (~xð(K ) ) = Eð(K ) ,
then for all x x )) = den(A, E 0 (~
~ , den(A, E(~ x )).
x2A.2. Problem (Localization). Prove that for any Φ-structure A and ex-
tended Φ-program E(~x),
x ) = w ⇐⇒ G∞ (A, x
A |= E(~ ~ ) |= E(~
x ) = w.
x2A.3. Problem (Invariance under isomorphisms). Prove that if ð : A 
→B
is an isomorphism between two Φ-structures and E(~x) is an extended Φ-
program, then
x ) = w ⇐⇒ B |= E(ð(~
A |= E(~ x )) = ð(w) x ∈ An ).
(~
x2A.4. Problem. Prove the missing case in the proof of Theorem 2A.1,
where some part other the head in (2A-10) is not explicit.
x2A.5. Problem (Transitivity). Prove that if g is A-recursive and f is (A, g)-
recursive, then f is A-recursive. It follows that if (A, Φ) is an expansion of A
by partial functions which are A-recursive, then
Rec(A, Φ) = Rec(A).
x2A.6. Problem. Prove that every structure A has an expansion by a total,
unary relation (A, R) such that Rec(A) = Rec(A, R) and Expl(A, R) is closed
under substitution (1A-12). Hint: Use Problem 1E.4.
56 2. Recursive (McCarthy) programs
x2A.7. Problem. Let A = (A, 0, ·, eq0 ) be a structure with · binary, and
define x n for x ∈ A and n ≥ 1 by x 1 = x, x n+1 = x · x n . Define f : A2 * A
by
f(x, y) = x k where k = the least n ≥ 1 such that y n = 0,
and prove that f is A-recursive.
x2A.8. Problem. Prove that the following functions on L∗ (from (1A-17),
(1C-4) and (1C-5)) are recursive in the Lisp structure L∗ defined in (1D-5):
u ∗ v, half1 (u), half2 (u),
and for each i ∈ N, u 7→ (ui ), set to nil if i ≥ |u|. Infer that for every ordering
≤ of L, the functions merge(u, v) and sort(u) are (L∗ , ≤)-recursive.
x2A.9. Problem. Prove that S ∈
/ Rec(N, 0, Pd, eq0 ). Hint: Use Prob-
lem x2A.2.
It is also true that Pd ∈ / Rec(N, 0, S, eq0 ), but (perhaps) this is not so
immediate at this point, see Problem x2D.6.
x2A.10. Problem. True or false: S and Pd are recursive in the Euclidean
structure Nε = (N, rem, eq0 , eq1 ) or its expansion (Nε , 0, 1) with the constants
0 and 1.
In the next few problems we consider the special cases of recursion in the
structures Nu , Nb , Nk-ary , N and their expansions by total functions, for which
elementary recursion was first developed,
·
x2A.11. Problem. Prove that arithmetic subtraction x − y is Nu -recursive,
by verifying the identity
· ·
(2A-15) x− y = if (y = 0) then x else Pd(x − Pd(y)).
x2A.12. Problem. Prove that
Rec(Nu ) = Rec(Nb ) = Rec(Nk-ary ) = Rec(N, 0, S, =) = Rec(N),
where k-ary arithmetic Nk-ary and the standard (Peano) structure N are defined
in (1D-3) and (1D-4).
x2A.13. Problem (Primitive recursion). Suppose A = (Nu , Φ) is an expan-
sion of Nu , g : Nn * N and h : Nn+2 * N are A-recursive, and f : Nn * N
satisfies the following two equations:
~ ) = g(~
f(0, x x ),
(2A-16)
f(y + 1, x
~ ) = h(f(y, x
~ ), y, x
~ ).
Prove that f is A-recursive. Verify also that f(y, x
~ )↓ =⇒ (∀i < y)[f(i, x
~ )↓ ].
2A. Syntax and semantics 57

Recall that the class of primitive recursive functions on N is the smallest class
of (total) functions on N which contains the successor S, the n-ary constant
functions C0n (~x ) = 0 and the projection functions Pin (~ x ) = xi , and which is
closed under composition and primitive recursion. By the last two problems,
every primitive recursive function f : Nn → Ns is Nu -recursive.
Primitive recursive functions have been studied extensively, especially be-
cause of their applications to proof theory—the most basic of these stemming
from the fact that they are all provably recursive in Peano arithmetic.

x2A.14. Problem (Minimalization). Prove that if g : Nn+1 * N is recursive


in some expansion A = (Nu , Ψ) of Nu , then so is the partial function

(2A-17) x ) = ìy[g(y, x
f(~ ~ ) = 0]
=df the least y such that (∀i < y)(∃w)[g(i, x
~ ) = w + 1 & g(y, x
~ ) = 0].

Hint: Check out Problem x1B.4.

Combined with classical results (for example in Kleene [1952]), these last
two problems imply easily that a partial function f : Nn * N is Nu -recursive
exactly when it is Turing-computable. We will formulate a version of this for
functionals in Proposition 2C.3.

x2A.15∗ . Problem (Rózsa Péter). A function f : Nn+1 → N is defined by


nested recursion from g, h and ô1 , . . . , ôn if it satisfies the following equations:
~ ) = g(~
f(0, y y ),
(2A-18)
f(x + 1, y
~ ) = h(f(x, ô1 (x, y), . . . , ôn (x, y
~ )), x, y
~ ).

(1) Prove that if f is defined by nested recursion from (Nu , Υ)-recursive


functions, then it is (Nu , Υ)-recursive. (This is easy.)
(2) Prove that if f is defined from primitive recursive functions by nested
recursion, then it is primitive recursive. (This is not so easy.)

x2A.16. Problem (Double recursion). A function f : N2+n → N is defined


by double recursion from g, h1 , ó, h2 if it satisfies the following equations for all
x, y, ~z :
f(0, y, ~z ) = g(y, ~z ),
(2A-19) f(x + 1, 0, ~z ) = h1 (f(x, ó(x, ~z ), ~z ), x, ~z ),
f(x + 1, y + 1, ~z ) = h2 (f(x + 1, y, ~z ), x, y, ~z ).

Prove that if f is defined by double recursion from (Nu , Φ)-recursive functions,


then it is (Nu , Φ)-recursive.
58 2. Recursive (McCarthy) programs
x2A.17∗ . Problem (The Ackermann-Péter function). Consider the system
of equations
A(0, x) = x + 1
(2A-20) A(n + 1, 0) = A(n, 1)
A(n + 1, x + 1) = A(n, A(n + 1, x)),
on a function A : N2 → N.
(1) Verify that this defines A(n, x) by double recursion.
(2) Prove that the Ackermann-Péter function is not primitive recursive.
Hint: For (2), prove first that every Ackermann section
An (x) = A(n, x)
is primitive recursive and then show that for every primitive recursive function
f(~x ) there is some m such that
(2A-21) x ) < Am (max x
f(~ x ∈ Nn ).
~ ) (~
This requires establishing some basic inequalities about these functions, in-
cluding
An (x) ≥ 1, x < y =⇒ An (x) < An (y),
n < m =⇒ An (x) < Am (x), An (An (x)) < An+2 (x)
which are also needed for the punchline—that A(n, x) is not primitive recur-
sive.

2B. Simple fixed points and tail recursion

One would expect that various restrictions on the general form (2A-10) of
recursive definitions yield A-recursive functions and functionals with spe-
cial properties, and there are many results of this kind in what is called
schematology, cf. Greibach [1975] (and references given there) and the ear-
lier Péter [1951] for recursion on N. This is not our topic, but it is worth
discussing here two notions of restricted recursion which are important for
the theory of recursive programs.
Simple fixed points. A partial function f : An * A is a simple fixed point
of A if it is the canonical (least) solution of a single equation
x ) = g(~
p(~ x , p)
with an A-explicit g(~
x , p), so
n o
(2B-1) x ) = p(~
f(~ x ) where p(~
x ) = g(~
x , p) .
2B. Simple fixed points and tail recursion 59

Addition, for example, is a simple fixed point of Nu by (1B-10) as is arithmetic


subtraction by (2A-15) in Problem x2A.11. One might think that every A-
recursive partial function f : An * A is a simple fixed point and this is almost
true—but not exactly, even in Nu :
2B.1. Proposition (Moschovakis [1984]). If A = (Nu , Υ) is an expansion of
the unary numbers by any finite set Υ = (φ1 , . . . , φk ) of total functions, then
there exists a total function f : N → N which is A-recursive but is not a simple
fixed point of A.
A proof of this is outlined in Problems x2B.3 - x2B.5.
On the other hand, the A-recursive partial functions are very close to the
simple fixed points of A, as follows:
Pointed structures. An element a ∈ A in the universe of a Φ-structure A
is strongly explicit if some closed Φ-term denotes a and the equality-with-a
relation
(2B-2) eqa (x) ⇐⇒ x = a
is A-explicit; and A is pointed if it has at least two strongly explicit elements.
For example, Nu , Nb and every field are pointed with a = 0, b = 1 and every
expansion of a pointed structure is also pointed.
2B.2. Proposition. If A is pointed and f : An * As , then f is A-recursive if
and only if there is a simple fixed point g : Am+n * As of A such that
(2B-3) x ) = g(~
f(~ x ∈ An , a~ = a, . . . , a ).
~ ) (~
a, x
| {z }
m times

When this equation holds, we say that f is a section of g by explicit constants.


Proof. In a simple case when
n o
x ) = f0 (~
f(~ x , p1 , p2 ) where p1 (~
x1 ) = f1 (~
x1 , p1 , p2 ), p2 (~
x2 ) = f2 (~
x2 , p1 , p2 ) ,

let r be the solution of the recursive equation

r(s, t, x
~1 , x ~ ) = if (s = t = a)
~2 , x
then f0 (~
x , (ë~
x1 )r(a, a, x
~1 , x ~ ), (ë~
~2 , x x2 )r(a, b, x
~1 , x ~ ))
~2 , x
else if (s = a & t = b)
then f1 (~
x1 , (ë~
x1 )r(a, a, x
~1 , x ~ ), (ë~
~2 , x x2 )r(a, b, x
~1 , x ~ ))
~2 , x
else f2 (~
x2 , (ë~
x1 )r(a, a, x
~1 , x ~ ), (ë~
~2 , x x2 )r(b, a, x
~1 , x ~ ))
~2 , x
and check by an easy fixed-point-argument that for all x ~1 and x
~, x ~2 ,

f1 (~
x1 ) = r(a, b, x
~1 , x ~1 ),
~2 , x f2 (~
x2 ) = r(b, a, x
~1 , x ~ ),
~2 , x
and so f(~
x ) = r(a, a, x
~1 , x ~ ).
~2 , x
60 2. Recursive (McCarthy) programs
It follows that if a~1 , a~2 are sequences of respective lengths those of x
~1 and x
~2 ,
then

x ) = r(a, a, a
f(~ ~1 , a ~ ).
~2 , x

For recursive definitions with K + 1 parts, we replace (s, t) by a suitably


~ and ~b of length k
long (s1 , . . . , sk ) so that 2k ≥ K + 1 and then use tuples a
to combine the equations in the system in one. a
The minimal (“free”) pointed extension of A is the structure

(2B-4) A[a, b] = (A ∪ {a, b}, Υa,b , a, b, eqa , eqb ),

where a, b are distinct objects not in A, for each f : An * As ,


(
a,b f(x), if x ∈ An ,
(2B-5) f (x) = (x ∈ A[a, b]n ),
↑ otherwise

and Υa,b = {φ a,b : φ ∈ Υ}.


2B.3. Proposition. For every structure A and f : An * As ,

f ∈ Rec(A) ⇐⇒ f a,b ∈ Rec(A[a, b]).

Taken together, these two Propositions say that every A-recursive partial
function is a section of a fixed point, except that to realize this, we may need to
add two strongly explicit points to A. This is an important fact about abstract
recursion, but we will not need it, and so we leave its (technically messy) proof
and a variation of it for Problems x2B.1∗ , x2B.2.
McColm [1989] has also shown that multiplication is not a simple fixed
point of Nu , along with several other results in this classical case. The general
problem of characterizing in a natural way the simple fixed points of a structure
A is largely open and it is not clear what (if any) their algebraic or foundational
significance might be, cf. Problem x2B.6.
Tail recursion. A partial function p : Ak * As is defined by tail recursion
from test : Ak * B, output : Ak * As and ó : Ak * Ak if it is the (canonical,
least) solution of the recursive equation

(2B-6) u ) = if test(~
p(~ u ) then output(~
u ) else p(ó(~
u )).

Typical is the definition of gcd(x, y) in (1C-7) by tail recursion from

test(x, y) = eq0 (rem(x, y)), output(x, y) = y, ó(x, y), = (y, rem(x, y)).

Tail recursion captures the notion of explicit iteration, perhaps best ex-
pressed by this
2B. Simple fixed points and tail recursion 61

2B.4. Proposition. The canonical, least solution of the tail recursive equa-
tion (2B-6) is given by
(2B-7) x ) = output(ó m (~
p(~ x )) where m = ìk test(ó k (~
x ))
=df output(ó m (~
x )) where m is least such that
(∀i < m)[test(ó i (~
x )↓ ] & test(ó m (~
x )).
Proof. We use the construction of p(~ x ) in the proof of the Fixed Point
Lemma 1B.1, which starts with the totally undefined p0 (~
x ) and sets
pk+1 (~
x ) = if test(~ x )) else pm (ó k (~
x ) then output(~ x )).
By induction on k, we get
(
k+1 output(ó m (~
x )) where m ≤ k is least such that test(ó m (~
x )),
p (~ x) =
↑ if no such m ≤ k exists,
and then p = limk pk easily satisfies (2B-7). a
Tail recursive programs and functions. An extended Φ-program is tail recur-
sive if it is of the form
(2B-8) E(~x) ≡ p(input(~x))
n o
where p(~u) = if test(~u) then output(~u) else p(ó(~u))
with Φ-explicit terms input, test, output, ó of suitable sorts, arities and co-
arities; and a partial function f : An * As is tail recursive in a Φ-structure A
if it is computed in A by a tail recursive program, i.e., if
(2B-9) x ) = p(input(~
f(~ x ))
n o
where p(~ u ) = if test(~
u ) then output(~
u ) else p(ó(~
u )) ,
with A-explicit input, test, output, ó.We set
Tailrec0 (A) = {f : An * As : n ≥ 0 and f is tail recursive in A}.
In general, this is not a well-behaved class, cf. Problem x2B.7. If A is pointed,
however, it is a very natural, well-structured class of partial functions, espe-
cially because it is then closed under definitions by
Mutual tail recursion. A system of mutual tail recursion in a structure A is
a set of equations
n o
(2B-10) E : p1 (~ x1 ) = f1 (~ ~ ), . . . , pK (~
x1 , p xK ) = fK (~ ~)
xK , p
where each fi (~ ~ ) is in one of the following two forms, with A-explicit
xi , p
testi (~
xi ), outputi , óij (~
xi ) and ôik (~
xi ):
(tail call) fi (~
xi ) = if testi (~
xi ) then outputi (~ xi ) else pj (óij (~
xi ))
(branching call) fi (~xi ) = if testi (~
xi ) then pj (óij (~
xi )) else pk (ôik (~
xi )).
62 2. Recursive (McCarthy) programs
2B.5. Theorem. If A is pointed and p1 , . . . , pn are the solutions of a system
of mutual tail recursion (2B-10), then each p i is tail recursive in A.
Proof. If all the equations in (2B-10) are branching calls, then their solu-
tions are the partial functions with empty domains of convergence; and if they
are all tail calls, then the proof is simple and we leave it for Problem x2B.10.
So we may assume that there is an L such that 1 ≤ L < K , every fi (~ xi ) is
a tail call for i ≤ L and every fi (~ xi ) is a branching call when L < i ≤ K . We
will also simplify notation by
writing x for x
~1 , . . . , x
~n
and pretending for the moment that A has K strongly explicit constants,
1, . . . , K . With these conventions, we put
W
W
test(i, x) ⇐⇒df 1≤j≤L [i = j & testi (~
xi )]
⇐⇒ [i = 1 & test1 (~
xi ] ∨ · · · ∨ [i = L & testL (~
xL ],


output1 (~
 x1 ) if i = 1,
..
output(i, x) =df .


output (~
L xL ) otherwise, if i ≥ L.

We look for a similar definition by cases of an explicit ñ(i, x) of appropriate


co-arity so that the single tail recursive equation
(2B-11) r(i, x) = if test(i, x) then output(i, x) else r(ñ(i, x))
is equivalent to E, in the following strong sense: for each i = 1, . . . , K and
all x = x ~K ,
~1 , . . . , x
(2B-12) p i (~
xi ) = r(i, x) = r(i, x
~1 , . . . , x K ).
This gives pi (~xi ) = r(~1, x
~i , ~2) with suitably long sequences ~1 and ~2, and so pi
is tail recursive.
With the notation conventions in (2B-10) and the specification of tail and
branching calls below it, we set first
ñ(i, x) = (j, x{~
xi := óij (~
xi )}) (i ≤ L),
where x{~xj := óij (~
xi )} is obtained from x by replacing x
~j by óij (~
xi ). For
i > L, we put
ñ(i, x) = if test(i, x) then (j, x{~
xj := óij (~
xi )}) else (k, x{~
xk := ôik (~
xi )}).
We now prove (2B-12) by showing that for all i, x,
r t (i, x) = pti (~
xi )
for all the iterates that build up the solutions pi , r in the proof of the Fixed
Point Lemma, Theorem 1B.1.
2B. Simple fixed points and tail recursion 63

This is certainly true at t = 0, when all these partial functions have empty
domain of convergence.
In the induction step, first for i ≤ L,

r t+1 (i, x) = if test(i, x) then output(i, x) else r t (ñ(i, x))


= if testi (~ xi ) else r t (j, x{~
xi ) then outputi (~ xj := óij (~
xi )})
= if testi (~ xi ) else p tj (óij (~
xi ) then outputi (~ xi )) (ind. hyp.)
= pt+1
i (~xi ).

For i > L, test(i, x) is never true, so:

r t+1 (i, x) = r t (ñ(i, x))


= if test(i, x) then r t (j, x{~ xi )}) else r t (k, x{~
xj := óij (~ xk := ôik (~
xi )})
= if test(i, x) then ptj (óij (~
xi )) else ptk (ôik (~
xi )) (ind. hyp.)
= pt+1
i (~xi ).

To remove the assumption that A has K strongly explicit constants, we


replace 1, . . . , K by sufficiently long sequences of two constants, as in the
proof of Proposition 2B.2. a
Problems x2B.9 – x2B.17 develop (with generous hints) the basic properties
of Tailrec0 (A) on pointed structures, including the fact that for every expansion
(Nu , Υ) of the unary numbers by total functions,

(2B-13) Rec0 (Nu , Υ) = Tailrec0 (Nu , Υ).

This is an important fact about (classical) recursion on the natural numbers,


a version of the Normal Form Theorem, Kleene [1952][Theorem IX]. It holds
for many “rich” structures but not generally: there are interesting examples
of total, pointed structures in which Rec0 (A) 6= Tailrec0 (A) and others where
every A-recursive function can be computed by a tail recursion but at a cost
in “efficiency”. We will describe some of these examples in Section 2G and on
page 124.
Relativization. A functional f(~ x , ~r) is a simple fixed point of a structure A
if
n o
(2B-14) f(~x , ~r) = p(~
x ) where p(~ x ) = g(~x , p, ~r)

with an A-explicit functional g(~ x , p, ~r), i.e., if f satisfies the relativized version
of (2B-1) in which we allow the given g to depend on the arbitrary parameters
~r. In the same way, f(~ x , ~r) is tail recursive in A if for suitable A-explicit
64 2. Recursive (McCarthy) programs
h1 , . . . , hk , test, output,

(2B-15) x , ~r) = p(h1 (~


f(~ x , ~r), . . . , hk (~
x , ~r)) where
n o
u ) = if test(~
p(~ u , ~r) then output(~ u , ~r) else p(ó1 (~
u ), . . . , ók (~
u )) ,

and Tailrec(A) is the family of A-tail recursive functionals. Most of the


basic properties of simple fixed points and tail recursive partial functions can
be extended to functionals, basically by relativizing their proofs, inserting the
parameters ~r wherever this makes sense.
The process of relativizing definitions and proofs is a standard tool of
recursion theory and we will sometimes appeal to it to simplify arguments,
when it can be applied routinely—which is most of the time.

Problems for Section 2B

x2B.1∗ . Problem (Adding points, 1). Prove Proposition 2B.3: that for every
A and every f : An * As ,
f ∈ Rec(A) ⇐⇒ f a,b ∈ Rec(A[a, b]),
with A[a, b] and f a,b defined by (2B-4) and (2B-5). Hint: For the non-
trivial direction (⇐=), we need to code an arbitrary A[a, b]-explicit recursive
equation by a (long) system of A-explicit equations; it is clear that this can be
done in some way, and the trick is to formulate a precise lemma which gives it
and which can be proved “by induction”, i.e., by appealing to Proposition 1E.1.
x2B.2. Problem (Adding points, 2). Define A[a, b]∗ like A[a, b], except that
each φ ∈ Φ is now interpreted by
φ ∗ (x1 , . . . , xn ) = if x1 , . . . , xn ∈ A then φ(x1 , . . . , xn ) else a,
so that if A is a total structure, then so is A[a, b]∗ . Prove that for any partial
function f : An * As , f ∈ Rec(A) ⇐⇒ f a,b ∈ Rec(A[a, b]∗ . Hint: Use
Problem x2B.1∗ , do not repeat its proof.
The next three problems lead to a proof of Proposition 2B.1.
x2B.3. Problem. Suppose F (x, p) is a continuous functional whose fixed
point p : N → N is a total, unary function, and let
(2B-16) stage(x) = stageF (x) = the least k such that p k (x)↓ −1
in the notation of Lemma 1B.1. Prove that for infinitely many x,
stage(x) ≤ x.
2B. Simple fixed points and tail recursion 65

x2B.4. Problem. Suppose ø : N → N is strictly increasing, i.e.,


x < y =⇒ ø(x) < ø(y),
and set by recursion on N,
ø 0 (x) = x, ø n+1 (x) = ø(ø n (x)).
A unary partial function f : N * N is n-bounded (relative to ø, for n > 0) if
f(x)↓ =⇒ f(x) ≤ ø n (x);
and a functional F (x, p) (with p a variable over unary partial functions) is
`-bounded (relative to ø), if for all p and n ≥ 1,
if p is n-bounded, then for all x, F (x, p) ≤ ø `n (x).
Suppose A = (N, {φ A }φ∈Φ ) is a total Φ-structure and every primitive
A
φ : Nn → N is bounded by some fixed ø as above, in the sense that
x ) ≤ ø(max x
φ(~ ~ ).
Prove that for every term E(x, p) in the vocabulary Φ ∪ {p}, there is an ` such
that the functional
F (x, p) = den(E(x, p))
is `-bounded. Hint: You will need to verify that ø(x) ≥ x, because ø is
increasing, and hence, for all `, ` 0
0
` ≤ ` 0 =⇒ ø ` (x) ≤ ø ` (x).
(This is also needed in the next problem.)
x2B.5. Problem. Prove Proposition 2B.1.
x2B.6. Open problem. Prove that if A = (Nu , Υ) is an expansion of the
unary numbers with any set Υ = (φ1 , . . . , φk ) of total, Nu -recursive functions,
then there exists a total relation R : N → B which is recursive but not a simple
fixed point of A.
x2B.7. Problem. As in Problem x1E.9, let A = (A, φ) where A is any non-
empty set, φ : A * A is not total, and for some ordering ≤ on A,
φ(x)↓ =⇒ x < φ(x).
Prove that f : A * B is tail recursive in A if either f(x) is explicit or f(x) ↑
for every x. Infer that Tailrec0 (A) is not closed under composition.
x2B.8. Problem. Prove that f : An * As satisfies (2B-9) in a Φ-structure
A exactly when it is computed by the procedure
set u~ := input(~
x );
while ¬test(~
u ), set u~ := ó(~
u );
return output(~ u ).
as this is customarily understood.
66 2. Recursive (McCarthy) programs
In Problems x2B.9 – x2B.17 we outline briefly the elementary theory of tail
recursion (mostly) in a pointed structure; this includes closure properties of
Tailrec(A) for pointed A which mirror those for Rec(A) in Problems x2A.5 –
x2A.14 but are not quite as easy to prove.
x2B.9. Problem. Prove that Tailrec0 (A) is closed under mangling and ex-
plicit substitutions, f(~
x ) = g(h(~
x )) with A-explicit h(~
x ) of suitable co-arity.
x2B.10. Problem. Prove Theorem 2B.5 for systems of mutual tail recursion
in which all the equations are tail calls. Hint: The needed construction is a
“reduct” of the argument we gave for the general case.
x2B.11∗ . Problem. Prove that if A is pointed, then Tailrec0 (A) is closed
under substitutions
x ) = g(h(~
f(~ x )) = g(h1 (~
x ), . . . , hm (~
x )).
Hint: With m = 1, for simplicity, we are given representations
g(u) = pg (inputg (u)), x ) = ph (inputh (~
h(~ x )),
where pg (~
v ), p h (u) are the solutions of the two recursive equations
pg (~
v ) = if testg (~
v ) then outputg (~
v ) else pg (óg (~
v ))
ph (u) = if testh (u) then outputh (u) else ph (óh (u)).
Replace the second equation by
qh (u) = if testh (u) then pg (inputg (outputh (u)) else qh (óh (u))
and prove that for the resulting system of mutual tail recursion,
q h (u) = g(ph (u)),
which then yields g(h(~
x )) = g(ph (inputh (~
x ))) = q h (inputh (~
x )).
x2B.12∗ . Problem. Prove that if A is pointed, then Tailrec0 (A) is closed
under branching
x ) = if f1 (~
f(~ x ) then f2 (~
x ) else f3 (~
x ).
Hint: This is quite simple when f1 (~ x ) is explicit. In the general case, we
are given three tail recursive definitions

fi (~
x ) = pi (inputi (~
x ))
n o
where pi (ui ) = if testi (ui ) then outputi (ui ) else pi (ói (ui )

for i = 1, 2, 3, where ui varies over some product Aki and all the twelve partial
functions in them are explicit in A.
2B. Simple fixed points and tail recursion 67

Let q 1 , q 11 , r, q 2 , q 21 , q 3 , q 31 be the solutions of the following system E of


mutual tail recursion:

q1 (~
x ) = q11 (~
x , input1 (~
x ))
q11 (~
x , u) = if test1 (u) then r(~
x , u) else q11 (~
x , ó1 (u))
x , u) = if output1 (u) then q2 (~
r(~ x ) else q3 (~
x)
q2 (~
x ) = q21 (~
x , input2 (~
x ))
q21 (~
x , v) = if test2 (v) then output2 (v) else q21 (~
x , ó2 (~
x ))
q3 (~
x ) = q31 (~
x , input3 (~
x ))
q31 (~
x , w) = if test3 (w) then output3 (w) else q31 (~
x , ó3 (w)).

By Proposition 2B.4,

x , v) = output2 (ó2m (v)) with m least such that test2 (ó2m (v))
q 21 (~

and so

x ) = output2 (ó2m (input2 (~


q 2 (~ x ))
with m least such that test2 (ó2m (input2 (~
x ))) = f2 (~
x ),

and similarly q 3 (~
x ) = f3 (~
x ). It takes just a bit more work to show that

q 1 (~
x ) = if f1 (~
x ) then f2 (~
x ) else f3 (~
x ) = f(~
x ).

x2B.13∗ . Problem. Prove that if A is pointed, then Tailrec0 (A) is closed


under tail recursion.
Hint: By Problem x2B.11∗ , it is enough to prove that if
n o
f(x) = p(x) where p(x) = if test(x) then output(x) else p(ó(x))

and for some A-explicit inputi , testi , outputi , ói on suitable products of A

test(x) = p1 (input1 (x))


n o
where p1 (u) = if test1 (u) then output1 (u) else p1 (ó1 (u)) ,
output(x) = p2 (input2 (x))
n o
where p2 (v) = if test2 (v) then output2 (v) else p2 (ó2 (v)) ,
ó(x) = p3 (input3 (x))
n o
where p3 (w) = if test3 (w) then output3 (w) else p3 (ó3 (w)) .
68 2. Recursive (McCarthy) programs
Let q 1 , q 11 , r, q 2 , q 21 , q 3 , q 31 be the solutions of the following system E of
mutual tail recursion:
q1 (x) = q11 (x, input1 (x))
q11 (x, u) = if test1 (u) then r(x, u) else q11 (x, ó1 (u))
r(x, u) = if output1 (u) then q2 (x) else q3 (x)
q2 (x) = q21 (x, input2 (x))
q21 (x, v) = if test2 (v) then output2 (v) else q21 (x, ó2 (x))
q3 (x) = q31 (x, input3 (x))
q31 (x, w) = if test3 (w) then q1 (output3 (w)) else q31 (x, ó3 (w)).
The key fact about this system is that
q 1 (x) = if test(x) then q 2 (x) else q 3 (x),
which is easy to check using Proposition 2B.4; together with the simpler
q 2 (x) = output(x), q 3 (x) = q 1 (ó(x)),
it gives
q 1 (x) = if test(x) then output(x) else q 1 (ó(x))
= output(ó m (x)) where m is least such that test(ó m (x)) = f(x).
x2B.14. Problem (Tailrec0 transitivity). Prove that if A is pointed and ø :
Ak * As is tail recursive in A, then Tailrec0 (A, ø) = Tailrec0 (A).
x2B.15. Problem. Prove that if f : Nn+2 → N is defined by primitive recur-
sion from Nu -tail recursive functions, then f is tail recursive in Nu . Infer that
every primitive recursive function on N is Nu -tail recursive.
Hint: It suffices to prove that if f(y, x
~ , w) is defined by
~ , w) = w,
f(0, x f(y + 1, x
~ , w) = h(f(y, x ~)
~ , w), y, x
with h(u, y, x ~ ) tail recursive in A then f(y, x
~ , w) is tail recursive in A. Let
~ , w) be the canonical solution to the recursive equation
p(i, j, x
·
~ , w) = if (i = 0) then w else p(i −
p(i, y, x 1, y + 1, x ~ )).
~ , h(w, y, x
This is tail recursive in (Nu , h) and hence tail recursive in Nu , so it suffices to
prove that f(y, x ~ , w) = p(0, y, x~ , w). Skipping the parameters x ~ which do
not enter the argument, this follows from
p(i, y, f(y, w)) = f(i + y, w).
x2B.16. Problem. Prove that if g(y, x
~ ) is Nu -tail recursive, then so is
x ) = ìy[g(y, x
f(~ ~ ) = 0],
cf. (2A-17).
2C. Iterators 69

S ó T
ó s
input - s ó
z output W
- f(x)
··· 
X x 0
?

Figure 1. Total iterator computing f : X * W .

x2B.17. Problem. Prove that if (Nu , Υ) is an expansion of Nu by total func-


tions, then Rec0 (Nu , Υ) = Tailrec0 (Nu , Φ).
Hint: By the classical Normal Form Theorem of Kleene,
x ) = U (ìy[g(y, x
f ∈ Rec(Nu , Υ) =⇒ f(~ ~ ) = 0])
with suitable U, g which are primitive recursive in Υ. This takes some compu-
tation to prove, which cannot be avoided here.

2C. Iterators (sequential machines, computation models)

All the standard deterministic models of computation for partial functions


f : X * W on one set to another are captured by the following, well-known,
general notion16 : for any two sets X and W , a (partial) iterator or sequential
machine
i:X W
is a quintuple (input, S, ó, T, output), satisfying the following conditions:
(I1) S is a non-empty set, the set of states of i;
(I2) input : X * S is the input function of i;
(I3) ó : S * S is the transition function of i;
(I4) T ⊆ S is the set of terminal states of i, and s ∈ T =⇒ ó(s) = s;
(I5) output : T * W is the output function of i.
Most often—and most usefully—the iterator i is total, i.e., input(x), ó(s) and
output(s) are all total, but it is useful to have around the general case.
A partial computation of i is any finite sequence (s0 , . . . , sn ) of states such
that for all i < n, si is not terminal and ó(si ) = si+1 , and it is convergent if,
in addition, sn ∈ T . Note that (with n = 0), this includes every one-term

16 Cf. van Emde Boas [1990, 1.2].


70 2. Recursive (McCarthy) programs
sequence (s), and (s) is convergent if s ∈ T . We write
(2C-1) s →∗i s 0 there is a convergent computation (s0 , . . . , sn )
with s0 = s, sn = s 0 ,
and we say that i computes a partial function f : X * W if
(2C-2) f(x) = w ⇐⇒ (∃s ∈ T )[input(x) →∗i s & output(s) = w].
It is clear that there is at most one convergent computation starting from
any state s0 , and so exactly one partial function i : X * W is computed by i.
The computation of i on x is the finite sequence
(2C-3) Compi (x) = (input(x), s1 , . . . , sn , output(sn )) (x ∈ X, i(x)↓ ),
such that (input(x), s1 , . . . , sn ) is a convergent computation, and its length
(2C-4) Timei (x) = n + 2
is the natural time complexity of i.
There is little structure to this definition of course, and the important prop-
erties of specific computation models derive from the judicious choice of the
set of states and the transition function, but also the input and output func-
tions. The first two depend on what operations (on various data structures)
are assumed as given (primitive) and regulate how the iterator calls them,
while the input and output functions often involve representing the members
of X and W in some specific way, taking for example numbers in unary or
binary notation if X = W = N.
We will review the definitions of some of the most commonly used compu-
tation models in Section 2F.
Reduction of iteration to tail recursion. Fix an iterator i and let
Ai = X ] W ] S
be the disjoint union (as in (1D-7)) of its input set, its output set and the set of
its states. We identify, as usual, each Z ⊆ Ai with its characteristic function
Z : Ai → B and we set
(2C-5) Ai = (Ai , X, W, S, input, ó, T, output),
where X, W, S are viewed as subsets of Ai and input(x), ó(s), output(s) are
the functions of the iterator, viewed now as partial functions on Ai which
return their argument when it is not in the appropriate input set. This is the
structure of i, it is a total structure when i is a total iterator, and the extended
tail recursive program associated with i is
(2C-6) Ei (x) ≡ q(input(x)) where
n o
q(s) = if T (s) then output(s) else q(ó(s)) .
2C. Iterators 71

2C.1. Theorem. For all x ∈ X , i(x) = den(Ai , Ei (x)).


In particular, the partial function computed by an iterator i : X W is tail
recursive in the associated structure Ai .
This follows easily from Proposition 2B.4 and we leave its proof for Prob-
lem x2C.2. Its significance is that it reduces computability, as it is captured
by any specific computation model i, to tail recursiveness relative to the data
structures and primitives of i. It is sometimes more interesting in the following
version, “internal” to a structure A.
Explicit representation. A bijection ð : S → Ak is an explicit representation
of an iterator
i = (input, S, ó, T, output) : An * As
in a Φ-structure A with universe A, if there are (necessarily unique) A-explicit
partial functions
inputð : An * Ak , óð : Ak * Ak , Tð : Ak * B, outputð : Ak * As
such that

inputð (~
x ) = ð(input(~
x )), óð (ð(s)) = ð(ó(s)),
Tð (ð(s)) = T (s), outputð (ð(s)) = output(s).
2C.2. Theorem. For any structure A, a partial function f : An * As is tail
recursive in A if and only if it is computed by an iterator i which is explicitly
representable in A.
This, too is an easy consequence of Proposition 2B.4 and we leave it for
Problem x2C.3, but it is the main tool for relating computability and com-
plexity theory developed (as is usual) using computation models to abstract
recursion. For example:
2C.3. Proposition (Turing computability and recursion). Every deterministic
Turing machine which operates on natural numbers using their binary expansions
is explicitly representable in the structure Nb = (N, 0, parity, iq2 , em2 , om2 , eq0 )
of binary arithmetic.
As a consequence, a functional f(~ x , ~r) on N is computable by a deterministic
Turing machine if and only if it is tail recursive in Nb —which is equivalent to f
being recursive in Nb or Nu .
Outline of proof. The second claim follows from the general theory of tail
recursion we developed in Section 2B and some unavoidable Turing machine
programming.
For a detailed proof of the main claim, we would need to settle on one of
a myriad of precise specifications of Turing machines and do a lot of coding,
which is not of the moment. We explain, instead, the simple idea which is
72 2. Recursive (McCarthy) programs
needed using a toy example and leave for Problem x2C.4 the argument for a
more general, reasonably realistic case.
Suppose a Turing machine M has only one two-way infinite tape, only
one symbol in its alphabet, 1, (internal) states Q0 , . . . , Qk (with Q0 declared
initial), and computes a unary partial function f : N * N by operating on
the unary (tally) representation of numbers
n = |1 ·{z
· · 1},
n+1

so that 0 = 1, 1 = 11, etc. If we use 0 to denote the blank square, then the
“complete configuration” of M at a stage in a computation is a triple (Qj , ô, i),
where ô : Z → {0, 1}, ô(l ) = 0 for all but finitely many l ’s, and i ∈ Z is the
location of the scanned cell; and if we then write ô as a pair of sequences
emanating from the scanned cell y0
· · · x3 x2 x1 x0 y 0 y 1 y 2 y 3 · · ·

one “growing” to the left and the other to the right, we can code (ô, i) by the
pair of numbers
P P
(x, y) = ( k xk 2k , k yk 2k )
and code the complete configuration of M by the triple of numbers (j, x, y).
So we can identify the set S of states of the iterator defined by M with N3 ,
and then output(j, x, y) = y and the set T of terminal states is defined by
cases on j, keeping in mind that the numbers 0, . . . , k are all strongly explicit
in Nb —as are all numbers.
To check that the transition function ó : N3 → N3 is also explicit in Nb ,
notice first that y0 = parity(y) so that the scanned symbol can be computed
from x and y by Nb -operations. The input configuration for the number n
is coded by the triple (Q0 , 0, y) where n is the binary expansion of y, i.e.,
y = 1 + 2 + · · · + 2n = 2n+1 − 1; and all machine operations correspond to
simple Nb -explicit functions on these codes. For example:
move to the right : x 7→ 2x + parity(y), y 7→ iq2 (y),
move to the left : x 7→ iq2 (x), y 7→ 2y + parity(x),
print 1 on the scanned square : x 7→ x, y 7→ 1 + em(iq2 (y)) = om(iq2 (y)),
where, with the notation of (1D-2),
2x + parity(y) = if (parity(y) = 0) then em2 (x) else om2 (x).
Using these functions, it is quite simple to construct an explicit definition of
ó (setting ó(j, x, y) = (j, x, y) if j > k).
If M has two symbols 1 and a and we want it to receive the input in binary
notation, which is typical, then the scanned symbol can be any one of blank,
2C. Iterators 73

0, 1 or a, we code these by the four pairs 00, 10, 01 and 11 respectively, and
we “pad” the tapes so that they have even length and they can be read as
sequences of these symbols. If, for example, the input is 4, which is 001 in
binary, then the initial configuration is (0, 0, y) where the binary expansion of
y is 101001 so y = 1 + 22 + 25 = 1 + 4 + 32 = 37. It is again easy to check that
the elementary operations of M are explicit in Nb —and the same well-known
technique of using binary sequences of fixed length to code any finite number
of symbols and padding the tapes works in general. a
About implementations (I). An implementation of a “program” or “algo-
rithm” which computes a partial function f : X * W is—at a minimum—an
iterator i : X W which also computes f, it is correct. They come in
many varieties and are classified in many ways, especially by whether they are
sequential or parallel and by what resources (e.g., space) they use.
None of this is precise, of course, as there is no general agreement on what
“programs” (in general) or “algorithms” are, and it is certainly not enough:
no one would argue that the merge-sort and the insert-sort have the same
implementations, even though they both compute the sorting function from
the same primitives. On the other hand, these terms are intuitively understood
quite well, they are widely used and there are few arguments about whether a
particular iterator is an implementation of a specific algorithm, whether it is
parallel or sequential, etc.
We will define a (classical) sequential implementation of recursive programs
in the next section and we will also discuss briefly the (difficult) problem of
making these notions and claims about them precise in Section 2H; other than
that, we will use these terms loosely, with their customary, intuitive meaning
when they help explain or motivate what we want to do or have done. For
example, we can read Theorem 2C.1 as claiming (in part) that an iterator i
implements the tail recursive program
n o
Ei : p(input(~x)) where p(~u) = if test(~u) then output(~u) else p(ó(~u))

which expresses it in Ai , but it is clear from the proof that much more than
that is established about the connection between i and Ei , cf. Problem x3A.3.

Problems for Section 2C

x2C.1. Problem. True or false: every partial function f : X * W is com-


putable by a total iterator i : X W.

x2C.2. Problem (Theorem 2C.1). Prove that the partial function computed
by an iterator i : X W is tail recursive in Ai .
74 2. Recursive (McCarthy) programs
x2C.3. Problem (Theorem 2C.2). Prove that f : An * As is tail recursive
in a structure A exactly when it is computed by an iterator i which is explicitly
representable in A.
x2C.4. Problem. Outline a proof of Proposition 2C.3 for a Turing machine
M which computes a functional f(x, y, p) on N with p ranging over unary
partial functions, has K symbols in its alphabet and uses two two-way tapes—
one of them to call the “oracle” for p.

2D. The recursive machine

We associate here with each Φ-structure A and each extended Φ-program


E(~x) an iterator which computes the denotation of E(~x) in A. This is one of
the classical implementations of recursion and an important tool for studying
the connection between recursion and computation.
An (A, E)-term is a closed term
(2D-1) M ≡ N (y1 , . . . , ym ),
where N (~y) is an extended term such that N is a subterm of one of the parts Ei
of E and y1 , . . . , ym ∈ A. These are voc(E)-terms with parameters from A,
but not all such: the (A, E)-terms are constructed by substituting parameters
from A into the finitely many subterms of E.
The states of i = i(A, E(~x)) are all finite sequences s of the form
a0 · · · am−1 : b0 · · · bn−1
where the elements a0 , . . . , am−1 , b0 , . . . , bn−1 of s satisfy the following con-
ditions:
• Each ai is a function symbol in Φ, or one of p1 , . . . , pK , or the special
symbol ?, or an (A, E)-term, and
• each bj is a parameter from A or a truth value, i.e., bj ∈ A ∪ B.
The special separator symbol ‘:’ has exactly one occurrence in each state, and
the sequences a~ , ~b are allowed to be empty, so that the following sequences
are states (with x ∈ A ∪ B):
x: :x :
The terminal states of i are the sequences of the form
:w
i.e., those with no elements on the left of ‘:’ and just one constant on the right;
the output function of i simply reads this constant w, i.e.,
output( : w) = w;
2D. The recursive machine 75

(pass) a~ x : ~b → a~ : x ~b (x ∈ A)

(e-call) ~ ~b → a~ : φiA (~
a~ φi : x x ) ~b

(i-call) ~ ~b → a~ Ei (~
~ pi : x
a x , ~p) : ~b

(comp) a~ h(F1 , . . . , Fn ) : ~b → a~ h F1 · · · Fn : ~b

~ if F then G else H : ~b → a~ G H ? F : ~b
(br) a
(br0) a~ G H ? : tt ~b → a~ G : ~b
(br1) a~ G H ? : ff ~b → a~ H : ~b

• The underlined words are those which trigger a transition and are
changed by it.
• In (pass), x ∈ A ∪ B.
• In the external call (e-call), x~ = x1 , . . . , xn , φi ∈ Φ, and arity(φi ) = n.
• In the internal call (i-call), pi is an n-ary recursive variable of E defined
by the equation pi (~x) = Ei (~x, ~p).
• In the composition transition (comp), h is a (constant or variable) func-
tion symbol in voc(E) with arity(h) = n.

Table 1. Transition Table for the recursive machine i(A, E).

and the input function uses the head term E0 (~x) of E(~x),
input(~
x ) ≡ E0 (~
x) :

The transition function of i is defined by the seven cases in the Transition


Table 1, i.e.,
(
s 0 , if s → s 0 is a special case of some line in Table 1,
ó(s) =
s, otherwise,

and it is a partial function, because for a given s (clearly) at most one transition
s → s 0 is activated by s. Notice that only the external calls depend on the
structure A and only the internal calls depend on the program E—and so, in
particular, all programs with the same body share the same transition function.
76 2. Recursive (McCarthy) programs
An illustration of how these machines compute is given in Figure 2 on
page 77.
The next result is a trivial but very useful observation:
2D.1. Lemma (Transition locality). If s0 , s1 , . . . , sn is a partial computation
of i(A, E) and a~ ∗ , ~b ∗ are such that the sequence a~ ∗ s0 ~b ∗ is a state, then the
sequence
a~ ∗ s0 ~b ∗ , a
~ ∗ s1 ~b ∗ , . . . , a
~ ∗ sn ~b ∗
is also a partial computation of i(A, E).
2D.2. Theorem (Implementation correctness). (1) Suppose A is a Φ-struct-
ure, E(~x) is an extended Φ-program with recursive variables p1 , . . . , pK , the
partial functions p1 , . . . , pK are the mutual fixed points in A of the system in
the body of E(~x)
(2D-2) pi (~
xi ) = den((A, p1 , . . . , pK ), Ei (~
xi )) (i = 1, . . . , K )
and M is an (A, E)-term. Then for every w ∈ A ∪ B,
(2D-3) den((A, p1 , . . . , pK ), M ) = w ⇐⇒ M : →∗i(A,E(~x)) : w.
In particular, with M ≡ E0 (~
x ),
den(A, E(~ x ) →∗i(A,E(~x)) : w,
x )) = w ⇐⇒ E0 (~
and so the extended program E(~x) and the recursive machine i(A, E(~x)) compute
the same partial function in A.
(2) Similarly for functionals: if E(~x) is an extended Φ program with para-
x , ~r) on A, then, for every
meters ~r ≡ r1 , . . . , rk which computes a functional f(~
~r, the recursive machine i((A, ~r), E(~x)) associated with E(~x) and ~r computes
f(~x , ~r).
Outline of proof. With A and E(~x) fixed, we write i = i(A, E(~x)).
(1) First we define the partial functions computed by i,
pei (~ xi ) : →∗i : w
xi ) = w ⇐⇒ pi (~ (i = 1, . . . , K )
and show by an easy induction on the closed term F that
(2D-4) den((A, pe1 , . . . , peK ), F ) = w ⇐⇒ F : →∗i : w.
When we apply this to the terms Ei (~
xi ), we get
den((A, pe1 , . . . , peK ), Ei (~ xi ) →∗i w ⇐⇒ pei (~
xi )) = w ⇐⇒ Ei (~ xi ) = w;
which then means that the partial functions p
e1, . . . , peK satisfy the system (2D-2).
Next we show that for any closed term F as above and any system p1, . . . , pK of
solutions of (2D-2),
F : →∗i w =⇒ den((A, p1 , . . . , pK ), F ) = w.
2D. The recursive machine 77

f(2, 3) : (comp)
f23 : (pass, pass)
f : 2 3 (i-call)
if (2 = 0) then 3 else S(f(Pd(2), 3)) : (br)
3 S(f(Pd(2), 3)) ? eq0 (2) : (comp, pass, e-call)
3 S(f(Pd(2), 3)) ? : ff (br2)
S(f(Pd(2), 3)) : (comp)
S f(Pd(2), 3) : (comp)
S f Pd(2) 3 : (pass)
S f Pd(2) : 3 (comp)
S f Pd 2 : 3 (pass)
S f Pd : 2 3 (e-call)
Sf : 1 3 (i-call)
S if (1 = 0) then 3 else S(f(Pd(1), 3)) : (br), (comp many times)
S S f Pd(1) 3 : (pass)
S S f Pd(1) : 3 (comp)
S S f Pd 1 : 3 (pass)
S S f Pd : 1 3 (e-call)
SSf : 0 3 (i-call)
S S if (0 = 0) then 3 else S(f(Pd(0), 3)) : (br), (comp many times), (pass)
S S 3 S f(Pd(0), 3) ? eq0 (0) :
S S 3 S f(Pd(0), 3) ? : tt (br0)
SS3 : (pass)
SS : 3 (e-call)
S : 4 (e-call)
: 5

Figure 2. The computation of 2 + 3 by the program


f(i, x) = if eq0 (i) then x else S(f(Pd(i), x)).

This is done by induction of the length of the computation which establishes


the hypothesis; and when we apply it with F ≡ pi (~ xi ) (i = 1, . . . , K ), it yields
pe1 v p1 , . . . , peK v pK . It follows that pe1 , . . . , peK are the least solutions
of (2D-2),i.e., pei = pi , which completes the proof.
Both arguments appeal repeatedly to the simple but basic Lemma 2D.1.
78 2. Recursive (McCarthy) programs
(2) is proved by “relativizing” the proof of (1), i.e., by entering in every
step the parameters ~r which are treated like primitives and do not enter the
argument. a
Reduction of recursion to iteration. Theorem 2D.2 reduces recursion to it-
eration, much as Theorem 2C.1 reduces iteration to (tail) recursion. Notice,
however, that the recursive machine i = i(A, E(~x)) runs in the structure Ai
which is richer than A—its universe is a set of finite sequences (which contains
all sequences from A) and it has additional primitives needed to manipulate
these stacks. In many cases, Ai can be suitably “interpreted” in A and then
Rec(A) = Tailrec(A), cf. Problems x2B.17 for the classical case and Prob-
lem x2D.4∗ below for a reasonably general result. We will consider structures
where Tailrec(A) ( Rec(A) in Section 2G.
We should also mention here that rigorous semantics of recursive definitions
were first given in terms of implementations (like the recursive machine).
Symbolic computation. The symbolic recursive machine is = is (Φ, E) asso-
ciated with a vocabulary Φ and a Φ-program E is defined as follows.
The states of is are all finite sequences s of the form
a0 . . . am−1 : b0 . . . bn−1
where the elements a0 , . . . , am1 , b0 , . . . , bn−1 of s satisfy the following condi-
tions:
• Each ai is a function symbol in Φ or one of p1 , . . . , pK , or a pure voc(E)-
term, or the special symbol ?, and
• each bj is a pure, algebraic Φ-term.
The transitions of is are those listed for the recursive machine in Table 1,
except that the following three are modified as follows:

(e-call) a~ φi : ~x ~b → a~ : φi (~x) ~b
(br0) a~ G H ? : b0 ~b → a~ G : ~b (if b0 = tt)
(br1) a~ G H ? : b0 ~b → a~ H : ~b (if b0 = ff)

In the last two commands, b0 is a pure, algebraic Φ-term (perhaps with


variables in it), and the conditions b0 = tt or b0 = ff cannot be checked,
unless b0 is one of tt or ff. The computations of is are defined relative to an
environment, a set of boolean conditions
E = {tt = tt, P0 = tt, P1 = tt, . . . , Pm−1 = tt,
ff = ff, N0 = ff, N1 = ff, . . . , Nn−1 = ff},
where the Pi and Nj are pure, algebraic Φ-terms of boolean sort. We say that E
activates (or justifies) the transition (br0) if (b0 = tt) ∈ E, and E activates (br1)
2D. The recursive machine 79

if (b0 = ff) ∈ E. A computation relative to an environment E is a sequence


of states s0 , s1 , . . . , sn , where for each i < n the Table and the environment
justifies the transition si → si+1 .
Take, for example, the program which computes 2x in Nu ,

E ≡ p(u, u) where {p(u, v) = if eq0 (v) then u else S(p(u, Pd(v)))}

and consider the symbolic computation starting with the head p(u, u) :

p(u, u) : → if eq0 (u) then u else S(p(u, Pd(u))) :


→ u S(p(u, Pd(u))) ? eq0 (u) :
→ u S(p(u, Pd(u))) ? eq0 u : → u S(p(u, Pd(u))) ? eq0 : u
→ u S(p(u, Pd(u))) ? : eq0 (u)

If the environment does not decide the term eq0 (u), then the computation
cannot go any further, it stalls. If the environment has the condition eq0 (u) =
ff, then (br1) is activated and we continue:

u S(p(u, Pd(u)) ? : eq0 (u) → S(p(u, Pd(u))) : → S p(u, Pd(u)) :


→ S p u, Pd(u) : → S p u, Pd u :
→ S p u, Pd : u → S p u : Pd(u) → S p : u Pd(u)
→ S if eq0 (Pd(u)) then u else S(p(u, Pd2 (u))) : → · · ·

The next time that ? will show up, we will need to have one of the two conditions

eq0 (Pd(u)) = tt or eq0 (Pd(u)) = ff

in the environment to continue, etc. The computation will go on forever unless


the environment has a condition eq0 (Pdn (u)) = tt for some n, which will then
turn it around so that eventually it stops in the state

: S n (u)

which gives the correct answer for u = n.


We will not do much with symbolic computation and we have left for Prob-
lem x2D.5 its basic—quite obvious—property; but it is one of the basic notions
of computation theory and it has some (perhaps ineluctable) applications, e.g.,
Problem x2D.6.
80 2. Recursive (McCarthy) programs
Problems for Section 2D

x2D.1. Problem. Consider the following three extended Nu -programs:


E1 (x) ≡ p(x) where {p(x) = S(p(x))},
E2 (x) ≡ p(x) where {p(x) = p(q(x)), q(x) = x},
E3 (x) ≡ p(x, y) where {p(x, y) = q(p(x, y), y), q(x, y) = x}.
Determine the partial functions computed by them and discuss how their
computations by the recursive machine differ.
x2D.2. Problem. Let A be a Φ-structure where Φ contains the binary func-
tion constant φ and the unary function constant ø which are interpreted by
total functions in A. Let
f(x) = φ A (ø A (x), ø A (x)) (x ∈ A).
(1) Check that the recursive machine for the (explicit) program
E ≡ φ(ø(x), ø(x))
which computes f(x) in A will make two calls to ø in its computations.
(2) Construct a better recursive program E which computes f(x) in A using
only one call to ø.
x2D.3∗ . Problem (Stack discipline). (1) Prove that for every program E in
a total structure A, and every (A, E)-term M , there is no computation of
i(A, E) of the form
(2D-5) M : → s1 → · · · → sm
which is stuck, i.e., the state sm is not terminal and there is no s 0 such that
s → s 0.
(2) Prove that if A is a partial structure, M is an (A, E)-term and the finite
computation (2D-5) is stuck, then its last state sm is of the form
a~ φj : y1 , . . . , yn ~b
j

where φj is a primitive function of A of arity nj and φj (y1 , . . . , ynj ) ↑.


Hint (Clinton Conley): Prove that if (2D-5) holds and there is no s 0 such
that sm → s 0 , then either sm is terminal or the conclusion of (2) holds.
x2D.4∗ . Problem (Pairing schemes). A pairing scheme on a pointed struc-
ture A is a triple of total functions
(2D-6) pair : A2 → A, first : A → A, second : A → A
such that
(2D-7) pair : A2  A \ {0} is an injection, and
first(pair(x, y)) = x, second(pair(x, y)) = y (x, y ∈ A).
2D. The recursive machine 81

(1) Prove that if a pointed structure A admits an explicit pairing scheme,


then R(A) = Tailrec(A). Hint: Consider the system of mutual tail recursion
n
p(x) = if (x = 0) then tt else q(x),
o
q(x) = if (first(x) = 0) then p(second(x)) else q(x)
whose solutions p, q are tail recursive by Theorem 2B.5, and set
NA = {x ∈ A : p(x)↓ } = {0, pair(0, 0), pair(0, (0, 0)), . . . }.
This is an infinite set and if S A , PdA are the restrictions to NA of the functions
pair(0, x) and second(x), then (NA , 0, S A , PdA , eq0 ) is isomorphic with Nu .
Next use the techniques of solving Problems x2B.15 and x2B.16 to prove that
Tailrec(A) is closed under definitions by primitive recursion and minimaliza-
tion, with n varying over NA ; and finally, use Theorem 2D.2 to adapt any of
the classical proofs of Kleene’s Normal Form Theorem to prove that every
A-recursive partial function satisfies an equation of the form
x ) = U (ìn ∈ NA [ô(n, x
f(~ ~ ) = 0])
with suitable tail recursive U and ô.17
(2) Infer that R(A) = Tailrec(A) if A admits a tail recursive pairing scheme,
i.e., one in which the functions tail(x, y), first(z) and second(z) are all tail
recursive. Hint: Use Problem x2B.14.
x2D.5. Problem (Symbolic Computation). Fix a Φ-structure and a Φ-pro-
gram E, and suppose that
N (x1 , . . . , xn ) : → s1 → · · · → : w
is a computation of the recursive machine of E which computes the value of
the (A, E) term N (x1 , . . . , xn ) with the indicated parameters. Make precise
and prove the following: there is an environment E in the distinct variables
x1 , . . . , xn which is sound for x1 , . . . , xn in A, such that the given computation
is obtained from the symbolic computation relative to E and starting with
N (x1 , . . . , xn ) by replacing each xi in it by xi .
There are many applications of symbolic computation, including the fol-
lowing simple fact for which there is no obvious, more elementary proof:
x2D.6. Problem. Prove that Pd(x) is not (N, 0, S, eq0 )-recursive.
17 The argument is fussy and perhaps not worth working out, but it is interesting to note what

(I think) are the minimal, known hypotheses on A which guarantee that R(A) = Tailrec(A)—
they are satisfied, for example, when A is a proper, elementary extension of A. They also imply
reasonable versions of the Enumeration and Snm theorems, so that a decent part of classical
recursion theory can be developed for these structures. (And as far as I know, it was Jon Barwise
who first noticed this, for the corresponding problem in the theory of inductive definability on an
arbitrary A.)
82 2. Recursive (McCarthy) programs
2E. Finite nondeterminism

Much of the material in Section 2C can be extended easily to (finitely)


non-deterministic computation models, in which the (typically total) transition
function allows a finite number of choices of the next state. We will not study
nondeterminism in any serious way, but it is important to give the precise
definition of nondeterministic recursive programs, as they are covered by the
intrinsic complexity lower bound results in Part II.
Beyond this, our main aim in this section is to define and analyze Pratt’s
nondeterministic algorithm for the gcd in Theorem 2E.2 which is relevant to
the Main Conjecture on page 2.
A (finitely) nondeterministic iterator18 i : X W is a tuple
i = (input, S, ó1 , . . . , ók , T, output)
which satisfies (I1) – (I5) in Section 2C except that (I3) is replaced by the
obvious
(I30 ) for every i = 1, . . . , k, ói : S * S.
So i has k transition functions and a partial computation of i is any finite
sequence (s0 , . . . , sn ) of states such that for every i < n, si is not terminal
and for some j = 0, . . . , k, si+1 = ój (si ), and it is convergent if sn ∈ T .
This allows the possibility that the machine may produce more than one value
on some input, and we must be careful in specifying what it means for i to
compute some f : X * W . The formal definitions are as before: we set

(2E-1) s →∗i s 0
⇐⇒ there is a convergent computation (s0 , . . . , sn ) with s0 = s, sn = s 0
and we say that i computes f : X * W if
(2E-2) f(x) = w ⇐⇒ (∃s ∈ T )[input(x) →∗i s & output(s) = w],
but they must be read more carefully now: i : X W computes f if whenever
f(x)↓ , then at least one convergent computation starting with input(x) produces
the value f(x) and no convergent computation from input(x) produces a different
value. Divergent computations are disregarded.
Nondeterministic recursive programs are defined exactly as before, except
that we allow multiple definitions for each recursive variable. For example, in

18 Note. By “iterator”, we always mean “deterministic iterator”, while by “nondeterministic

iterator” we mean some i which may be deterministic, and the same for programs; in other words,
“deterministic” is the default, even if sometimes, for emphasis, we refer to a “deterministic”
iterator or program.
2E. Finite nondeterminism 83

(N, 0, S, φ), we might have


n o
(2E-3) E ∗ ≡ φ(p(~x),~x) where p(~x) = 0, p(~x) = S(p(~x)) .
The recursive machine i(A, E(~x)) associated with a nondeterministic ex-
tended program is now nondeterministic: if
p(~x) = E 1 (~x) and p(~x) = E 2 (~x)
are both in the body of E, then i(A, E(~x)) allows both transitions
~ → E 1 (~
p:x ~ → E 2 (~
x ) : and p : x x) :
And, again, we say that E(~x) defines or computes f : An * As in a Φ-structure
A if (2E-2) holds for the iterator i(A, E(~x)), and then we write
(2E-4) x ) = w ⇐⇒df f(~
A |= E(~ x ) : →∗i(A,E) : w.
x ) = w ⇐⇒ E0 (~
We also put
(2E-5) c s (Φ0 )(A, E(~x ))

= min number of external calls to φ ∈ Φ0

in any convergent computation of i(A, E) on the input x
~ ,
where a call to φ in a computation by the recursive machine is a state of the form
a~ φ : w1 · · · wn ~b. This is the only complexity measure on nondeterministic
programs that we will need (for now).
The definitions extend naturally to nondeterministic programs with function
parameters which compute functionals, we set
Recnd (A) = the set of nondeterministically A-recursive functionals
and as for deterministic recursion, we let Rec0nd (A) be the set of all partial
functions in Recnd (A).
It is well known that Rec0 (A) = Rec0nd (A) when A is a total expansion of
Nu , but this fails for expansions by partial functions—and for functionals, it
even fails for Nu . We have included in Problems x2E.7 – x2E.10∗ some basic,
elementary results of this type.
Certificates and computations. The next Proposition makes precise the con-
nection between certificates and computations to which we have alluded, still
leaving the motivation for the term “certificate” for Section 4D.
2E.1. Proposition. If E(~x) is an extended nondeterministic Φ-program,
(2E-6) c = (E0 (~
x ) : , . . . , : w)
is a convergent computation of the recursive machine for E in a Φ-structure A
and Uc ⊆p A is the structure with
~ φ : u~ ~b → a~ : v ~b occurs in c},
eqdiag(Uc ) = {(φ, u~ , v) : a transition a
84 2. Recursive (McCarthy) programs
then (Uc , x
~ ) is a certificate, i.e., Uc = Gm (U, x
~ ) for some m.
Conversely, every certificate (U, x
~ ) is (Uc , x
~ ) for some computation c of a
nondeterministic program E(~x) as above.
Proof. The universe U of U comprises all the parameters from A which
occur in eqdiag(U); so if s0 = E0 (~ x ) : , . . . , sm = : w enumerates the
states in c, then by an easy induction on k ≤ m, every parameter which
occurs in s0 , . . . , sk is in G∞ (U, x
~ ); so U = G∞ (U, x ~ ), and since it is finite,
U = Gm (U, x ~ ) for some m.
For the converse, given (U, x
~ ), choose by Problem x1D.8 an enumeration
 
eqdiag(U) = (φ0 , u~0 , w0 ), . . . , (φm , u~m , wm ) ,

so each t in u~0 is xj for some j, and for each s < m, each t in the tuple u~s+1
occurs in the sequence x ~ , u~0 , w0 , u~1 , w1 , . . . , u~s , ws . Define the program
n
E ≡ p0 (~x, φ0 (~u0 )) where p0 (~x, y) = p1 (~x, φ1 (~u1 )),
o
p1 (x, y) = p2 (~x, φ2 (~u2 )), . . . , pm (~x, y) = φm (~um )

with suitably chosen tuples of variables ~ui so that if we set~x := x ~ , then ~u0 = u~0 ,
~u1 = u~1 , . . . , ~um = u~m ; and finally check that if c is the computation of the
recursive machine for E on the input E0 (~ x ) = p0 (~
x , φ0 (~
u )), then U = Uc . a
Fixed point semantics for nondeterministic programs. It is also useful to
characterize the denotations of nondeterministic programs using a natural
least-fixed-point operation, if for no other reason than to verify that the
definitions we gave do not depend on the specific choice of the recursive
machine as a “preferred” implementation—as there are many others. We
define here the notions we need and leave for Problems x2E.14∗ and x2E.15∗
the precise formulation and (easy) proofs of the relevant correctness results.
A partial multiple valued (pmv) function f : X *mv W assigns to each
x ∈ X a (possibly empty) subset of W . We write
f(x) →mv w ⇐⇒ w ∈ f(x),
f(x)↓ ⇐⇒ f(x) 6= ∅,
Gf (x, w) ⇐⇒ f(x) →mv w (the graph of f),
and we put on the space (X →mv W ) of all pmv functions on X to W the
partial ordering induced by their graphs,
f ⊆ g ⇐⇒ Gf ⊆ Gg ⇐⇒ (∀x, w)[f(x) →mv w =⇒ g(x) →mv w].
Every partial function f : X * W can be viewed as a pmv function whose
values are empty or singletons, f(x) = {f(x)} = {w : f(x) = w}, and the
basic operations on partial functions we introduced in Section 1A (easily and
2E. Finite nondeterminism 85

naturally) extend to pmv functions. For example: the composition and the
conditional operations on pmv functions are defined by

f(g1 (x), . . . , gm (x)) →mv w


⇐⇒ (∃w1 , . . . , wm )[g1 (x) →mv w1 & · · · gm (x) →mv wm
& f(w1 , . . . , wm ) →mv w],
if f(x) then g(x) else h(x) →mv w
⇐⇒ [f(x) →mv tt & g(x) →mv w] ∨ [f(x) →mv ff & h(x) →mv w].
The definitions extend directly to pmv functionals, cf. Problem x2E.14∗ .
For any vocabulary Φ, a pmv Φ-structure is a tuple A = (A, {φ A }φ∈Φ ),
where each φ ∈ Φ of arity n and sort s ∈ {ind, boole} is interpreted by a
pmv function φ A : An *mv As ; and, again, every Φ-structure can be viewed
as a pmv Φ-structure.
Next we turn to the following important result of Vaughn Pratt.19
2E.2. Theorem (Pratt’s nuclid algorithm). Consider the following non-deter-
ministic recursive program EP in the structure Nε of the Euclidean defined
in (1C-10):
n
EP ≡ nuclid(a, b, a, b) where
nuclid(a, b, m, n) = if (n 6= 0) then nuclid(a, b, n, rem(choose(a, b, m), n))
else if (rem(a, m) 6= 0) then nuclid(a, b, m, rem(a, m))
else if (rem(b, m) 6= 0) then nuclid(a, b, m, rem(b, m))
else m, o
choose(a, b, m) = m, choose(a, b, m) = a, choose(a, b, m) = b .

If a ≥ b ≥ 1, then Nε |= EP (a, b) = gcd(a, b).


Proof. Fix a ≥ b ≥ 1, and let
(m, n) → (m 0 , n 0 )

⇐⇒ n 6= 0 & m 0 = n

& [n 0 = rem(m, n) ∨ n 0 = rem(a, n) ∨ n 0 = rem(b, n)]
 
∨ n = 0 & rem(a, m) 6= 0 & m 0 = m & n 0 = rem(a, m)
 
∨ n = 0 & rem(b, m) 6= 0 & m 0 = m & n 0 = rem(b, m) .

19 This theorem and Problems x2E.16 – x2E.19 are in Pratt [2008] which has not been published.

They are included here with Vaughan Pratt’s permission.


86 2. Recursive (McCarthy) programs
This is the transition relation of the nondeterministic iterator associated with
EP (with a, b and the “housekeeping” details of the recursive machine sup-
pressed in the notation) and it obviously respects the property m > 0. The
terminal states are
T (a, b, m, n) ⇐⇒ n = 0 & m | a & m | b,
and the output on a terminal (a, b, m, 0) is m.
It is obvious that there is at least one computation which outputs gcd(a, b),
because one of the choices at each step is the one that the Euclidean would
make. To see that no convergent computation produces any other value, we
observe that directly from the definition,
If x divides a, b, m and n and (m, n) → (m 0 , n 0 ), then x divides m 0 and n 0 .
This implies that every common divisor of a and b divides every output m;
and because of the conditions on the terminal state, every output m divides
both a and b, so that the only output is gcd(a, b). a
In fact, EP does not have any divergent computations, see Problem x2E.16.
Pratt’s algorithm allows at each stage to replace
the Euclidean’s (m, n) → (n, rem(m, n)) by
(m, n) → (n, rem(a, n)) or (m, n) → (n, rem(b, n)),
which does not lose any common divisors of a and b, and then simply adds
a check at the end which insures that the output is not some random divisor
of (say) a which does not also divide b. The important thing about it is
that in some cases this guessing can produce a much faster computation
of gcd(a, b): see Problems x2E.17 – x2E.19 which outline a proof that for
successive Fibonacci numbers it can compute gcd(Ft+1 , Ft ) using only
O(log t) = O(log log(Ft ))
calls to the remainder function, thus beating the Euclidean on its worst case.
A complete analysis of the inputs on which it does better than the Euclidean
does not appear to be easy.
We will discuss briefly the relevance of these results of Pratt for the Main
Conjecture in Corollary 6C.7 on page 188.

Problems for Section 2E

x2E.1. Problem. Prove that the following are equivalent for a Φ-structure
A and a nondeterministic extended Φ-program E(~x):
(a) E(~x) computes a partial function in A.
(b) E(~x) computes a partial function in every substructure U ⊆p A.
(c) E(~x) computes a partial function in every finite substructure U ⊆p A.
2E. Finite nondeterminism 87

x2E.2. Problem (The homomorphism property for Recnd ). Prove that if A


is a Φ-structure, E(~x) an n-ary nondeterministic extended program which
computes a partial function in A, U, V ⊆p A and ð : U → V is a homomor-
phism, then
(2E-7) x ) = w =⇒ V |= E(ð(~
U |= E(~ x )) = ð(w) x ∈ U n ).
(~
Hint: For each computation c of the recursive machine which proves that
U |= E(~x ) = w as in (2E-6), define a sequence of states ð(c) by replacing
every parameter u ∈ A which occurs in c by ð(u), and verify that ð(c) is
a computation of the recursive machine which proves that V |= E(ð(~ x )) =
ð(w).
It is also useful to notice the version of this fact for isomorphisms, which is
proved the same way:
x2E.3. Problem. Prove that if ð : A → B is an isomorphism between two Φ-
structures and E(~x) is an extended, nondeterministic Φ-program which com-
putes a partial function in A, then E(~x) computes a partial function in B and
x ) = w ⇐⇒ B |= E(ð(~
A |= E(~ x )) = ð(w).
x2E.4. Problem (The finiteness property for Recnd ). Prove that if A is a Φ-
structure and E(~x) is an n-ary nondeterministic extended program which
computes a partial function in A, then
(2E-8) x ) = w =⇒ (∃m)[Gm (A, x
A |= E(~ ~ ) |= E(~
x ) = w].
Moreover, if E(~x) is a program with empty body (a pure Φ-term), then
(∃m)(∀~ x ) = w =⇒ Gm (A, x
x , w)[A |= E(~ ~ ) |= E(~
x ) = w].
x2E.5. Problem. Prove for Recnd (A) the closure properties listed for Rec(A)
in Corollary 2A.2.
x2E.6. Problem. Formulate for Recnd (A) and prove the properties of Rec(A)
in Problems x2A.5, x2A.13 and x2A.14.
x2E.7. Problem. Prove that if Υ is a set of total functions on N, then
Rec0nd (Nu , Υ) = Rec0nd (Nb , Υ) = Rec0 (Nu , Υ).
Hint: Appeal to the classical result, that a partial function f(~ x ) is recursive in
Υ if and only if its graph is semirecursive in Υ, i.e., if for some partial g(~x , w)
which is recursive in Υ,
x ) = w ⇐⇒ g(~
f(~ x , w)↓ .

x2E.8 . Problem. Prove that if A is pointed and admits a tail recursive
pairing scheme (as in Problem x2D.4∗ ), then Rec0 (A) = Rec0nd (A). Hint: The
tedious argument for Problem x2D.4∗ works for this too—it being an abstract
version of Kleene’s Normal Form Theorem which was originally proved for
the nondeterministic Gödel-Herbrand-Kleene programs.
88 2. Recursive (McCarthy) programs
x2E.9. Problem. Prove that the functional
f(p) = if (p(0)↓ or p(1)↓ ) then 0 else ìy[y = y + 1]
is nondeterministically Nu -recursive but not Nu -recursive. Hint: Consider
the computation of some deterministic Nu -program with parameter p which
might compute f(p).
x2E.10∗ . Problem. Give an example of a partial function φ : N2 * N such
that
Rec0 (Nu , φ) ( Rec0nd (Nu , φ).
x2E.11. Problem. For the program E ∗ defined in (2E-3), prove that
x ) = w ⇐⇒ (∃n)[φ A (n, x
denE ∗ (~ ~ ) = w]
provided that
(∀n, m, u, v)[φ A (n, x
~ ) = u & φ A (m, x
~ ) = v] =⇒ u = v};
if this condition does not hold, then E ∗ does not compute a partial function
in (N, 0, S, φ). Define also a related nondeterministic program E ∗∗ which
computes in the same structure (N, 0, S, φ) a partial function denE ∗∗ such that
x )↓ ⇐⇒ (∃n)[φ A (n, x
denE ∗∗ (~ ~ )↓ ].
x2E.12. Problem. Prove that the basic fact in Problem x2A.9 holds for any
A and any f ∈ Recnd (A), and infer that S ∈
/ Recnd (N, 0, Pd, eq0 ).
x2E.13. Problem (Symbolic computation). Prove a version of Problem x2D.5
for nondeterministic programs and use it to show that
Pd ∈
/ Recnd (N, 0, S, eq0 ).

x2E.14 . Problem. Define what it means for a pmv functional
(2E-9) f : X × (Y1 *mv W1 ) × · · · (Yk *mv Wk ) *mv W
to be monotone and continuous by extending the definitions starting on page 10;
formulate and prove the pmv version of the Fixed Point Lemma 1B.1—that
systems of equations of continuous pmv functionals have least fixed points.
x2E.15∗ . Problem (nd-implementation correctness). Suppose A is a pmv
Φ-structure, E(~x) is an extended nondeterministic Φ-program with recursive
variables p1 , . . . , pK , the pmv functions p1 , . . . , pK are the mutual fixed points
in A of the system in the body of E(~x)
pi (~
xi ) = den((A, p1 , . . . , pK ), Ei (~
xi )) (i = 1, . . . , K ),
and M is an (A, E)-term. Prove that for every w ∈ A ∪ B,
den((A, p1 , . . . , pK ), M ) →mv w ⇐⇒ M : →∗i(A,E(~x)) : w.
2E. Finite nondeterminism 89

Infer that, with M ≡ E0 (~


x ),
den(A, E(~ x ) →∗i(A,E(~x)) : w,
x )) →mv w ⇐⇒ E0 (~
and so the nondeterministic extended program E(~x) and the nondeterministic
recursive machine i(A, E(~x)) compute the same pmv function in A. Hint:
Follow closely the argument in the proof of Theorem 2D.2, making all the
necessary (technical and notational) adjustments.
The results in the remaining problems in this section are due to Vaughan
Pratt.
x2E.16. Problem. Prove that the program EP in Theorem 2E.2 has no di-
vergent (infinite) computations. Hint: Check the claim by hand for the cases
where one of a, b is 0. For a, b ≥ 1, prove convergence of the main loop by
induction on max(m, n) and within this by induction on n.
The complexity estimate for Pratt’s algorithm depends on some classical
identities that relate the Fibonacci numbers.
x2E.17. Problem. Prove that for all t ≥ 1 and m ≥ t,
(2E-10) Fm (Ft+1 + Ft−1 ) = Fm+t + (−1)t Fm−t .
Hint: Prove in sequence, by direct computation, that
1 √ 1 √
ϕ ϕ̂ = −1; ϕ + = 5; ϕ̂ + = − 5; Ft+1 + Ft−1 = ϕ t + ϕ̂ t .
ϕ ϕ̂
x2E.18. Problem. (1) Prove that for all odd t ≥ 2 and m ≥ t,
(2E-11) rem(Fm+t , Fm ) = Fm−t .
(2) Prove that for all even t ≥ 2 and m ≥ t,
(2E-12) rem(Fm+t , Fm ) = Fm − Fm−t ,
(2E-13) rem(Fm , (rem(Fm+t , Fm ))) = Fm−t .
Hint: For (2E-13), check that for t ≥ 2, 2Fm−t < Fm .

x2E.19. Problem. Fix t ≥ 2. Prove that for every s ≥ 1 and every u such
that u ≤ 2s and t − u ≥ 2, there is a computation of Pratt’s algorithm which
starts from (Ft+1 , Ft , Ft+1 , Ft ) and reaches a state (Ft+1 , Ft , ?, Ft−u ) doing no
more than 2s divisions.
Infer that for all t ≥ 3,
(2E-14) c s (rem)(Nε , EP (Ft+1 , Ft )) ≤ 2dlog(t − 2)e + 1 = O(log log(Ft )).
Hint: The measure c s (Φ0 )(A, E(~x )) for nondeterministic recursive programs
is defined in (2E-5). For (2E-14), you also need Problem x1C.7.
90 2. Recursive (McCarthy) programs
2F. Some standard models of computation

We collect here the definitions of some computation models—other than


Turing machines—which are commonly used to express and analyze algo-
rithms, especially in arithmetic and algebra.20
Finite register machines. These are the simplest “structured” iterators which
capture tail recursion in pointed structures in a useful way.
A (finite) register program P in the vocabulary Φ, of sort s and k > 0
registers is a sequence of lines or commands consecutively numbered from 0 to
some L ≥ 0 and satisfying the following conditions.
(1) Each line is in one of the following forms, where
Pl (~u) ≡ Pl (u1 , . . . , uk )
is a pure, extended Φ-term:
l. ui := Pl (~u), goto l 0 (Assignment)
l. if Pl (~u) then goto to l 0 else goto l 00 (Branching)
l. halt, return Pl (~u). (Halting)
(2) If l is an assignment, then sort(Pl ) = ind; if l is a branching command,
then sort(Pl ) = boole; and if l is a halting command, then Pl is a term of the
fixed sort s of P.
Each finite register program P defines an iterator
iP = (input, S, ó, T, output) : Ak * As
on every Φ-structure A in the obvious way:
S = {l, u~ ) : l ≤ L, u~ ∈ Ak }, input(~
u ) = (0, u~ ),
(l, u~ ) ∈ T ⇐⇒ l is a halting command, output(l, u~ ) = den(A, Pl (~
u )),
and the transition function is defined by cases on the form of each line:
if l is an assignment, ó(l, u~ ) = (l 0 , u~ {ui := den(A, Pl (~
u ))}),
u ) then (l 0 , u~ ) else (l 00 , u~ ),
if l is a branching, ó(l, u~ ) = if Pl (~
if l is a halt, ó(l, u~ ) = (l, u~ ).
A partial function f : An * As is register computable in A if
(2F-1) x ) = iP (g(~
f(~ x ))
for some register program P and with some A-explicit g : An * Ak .
2F.1. Proposition. If A is pointed, then f : An * As is register computable
exactly when it is tail recursive.
This is an easy Corollary of Theorem 2C.2 and we leave it for Problem x2F.1.
20 We will stick with deterministic models, for clarity, but all these schemes have natural

nondeterministic versions which are defined as in Section 2E.


2F. Some standard models of computation 91

Primitive register machines. We chose this definition of register programs


because it makes it easy to prove register computability—first to check this
Proposition, and then to develop the basic theory of tail recursiveness that we
outlined in Problems x2B.9 –x2B.17 using much easier arguments, at least for
those who are adept at imperative programming. To prove that some specific
function or relation is not register computable, we often need to restrict severely
the terms Pl of the program, as follows:
A register program P is primitive if all the terms in its specification are
prime, algebraic terms in the variables u1 , . . . , uk ,
Pl :≡ tt | ff | ui | φ(uð(1) , . . . , uð(ni ) )
where φ ∈ Φ and ð : {1, . . . , n} → {0, . . . , k}; and f : An * As is com-
putable by a primitive P in a pointed A if (2F-1) holds with
(2F-2) g(x1 , . . . , xn ) = (x1 , . . . , xn , an+1 , . . . , ak ) (k ≥ n)
with some ai which are strongly explicit in A.
Every f : An * As which is register computable in a pointed A is com-
putable in A by a primitive register program, cf. Problem x2F.3.
Decision trees. These are finite register programs which satisfy two, addit-
sional restrictions:
(1) All the goto clauses point to lines further down in the program, i.e.,
if l. ui := Ml (~u), goto l 0 is a line, then l 0 > l,
if l. if Ml (~u) then goto to l 0 else goto l 00 is a line, then l 0 , l 00 > l.
(2) Every line other than 0 is pointed to by a goto from exactly one (earlier)
line.
The terminology is chosen because the goto relation defines a tree on the
set of all symbolic computations of iP and each actual computation for a
specific input in a structure A follows (exactly) one of the branches of this
tree. These computations are now all finite, of length ≤ L, and the partial
functions computed on A by iP are all explicit. Decision trees are mostly
used in arithmetic or algebraic complexity theory, where the explicit terms are
polynomials, rational functions, inequalities, etc. They also come in many
varieties, e.g., in some cases the most interesting questions are best expressed
using primitive decision trees.
Simplest among these are the straight line programs (or computation se-
quences), primitive decision trees with no branching commands; they are used
extensively in arithmetic and algebraic complexity.
Random Access Machines (RAMs). We give a very general and rather ab-
stract definition of these computation models, quite far removed from both
the original definition in Cook and Reckhow [1973] and most of the numerous
variations discussed in van Emde Boas [1990]; there are good reasons for the
92 2. Recursive (McCarthy) programs
abstraction, which we will discuss in Section 4G, and we will soon explain
how the Cook-Reckhow version is covered by this definition.
Fix an infinite, pointed Φ-structure A = (A, Υ). An n-ary random access
machine (RAM) over A of sort s ∈ {ind, boole} and k > n accumulators is
an iterator
i = (input, S, ó, T, output) : An * As
such that the following conditions hold with some L ∈ N.
(1) The set of states of i is
= {(l, u~ , R) : l ≤ L, u~ ∈ Ak , R : A → A}.
(2) input(~
x ) = (0, (0, x1 , . . . , xn , 0, . . . , 0), R0 ) where R0 = (ët)0.
(3) If the sort s of the RAM is ind, then output(l, u~ , R) = u0 , and if
s = boole, then output(l, u~ , R) = eq0 (u0 ).
(4) The transition function and the terminal states of i are defined by a
RAM program over A, a sequence of lines or commands numbered from 0 to
L of the following form, where
Pl (~u) ≡ Pl (u1 , . . . , uk ) and Cl (t)
are pure, extended Φ-terms of sorts ind and boole respectively, 0 ≤ i, j ≤ k
and R ranges over (A → A):
l. ui := Pl (~u), goto l 0 (Accumulator assignment)
0
l. if Cl (ui ) then uj := R(ui ), goto l , else halt (Application)
0
l. if Cl (ui ) then R(ui ) := uj , goto l , else halt (Indirect application)
0 00
l. If Pl (~u) then goto l else goto l (Branching)
l. Halt
We leave for the problems the precise specification of the transition function
of a RAM iterator as well as the trivial proof of the following (half) analog of
Proposition 2F.1:
2F.2. Proposition. If a partial function f : An * As is tail recursive in an
infinite, pointed structure A, then f is tail recursive in the two-sorted structure
(2F-3) RAM(A) = (A, (A → A), ÷A , R0 , ap, indap),

where ÷A is the characteristic function of A by (1A-6) and (with u, v, t, ∈ A and


R : A → A)
R0 (t) = 0, ap(R, u) = R(u),
indap(R, u, v)(t) = if (t = u) then R(v) else R(t).
2F. Some standard models of computation 93

The last primitive indap : (A → A) × A2 → (A → A) is used to make


precise the Indirect application command: its effect on a state (l, u~ , R) is
either to declare it halting, if ¬Cl (ui ), or to move it to the state (l 0 , u~ , R0 )
where
(
uj , if [t = ui ],
R0 (t) = indap(R, ui , uj )(t) =
R(t), otherwise.
As we described it here, a RAM is basically a machine with finitely many
registers, what we have called now accumulators, enriched by the addition of
potentially infinite memory coded in some function R : A → A; notice that the
direct and indirect application commands allow us to implement commands
of the form
R(ui ) := R(R(uj )) or R(R(ui )) := R(uj )
by setting (for the first of these) in sequence
uj := R(uj ), uj := R(uj ), R(ui ) := uj .
The tests Cl (uj ) can be used to restrict the values of R(t) which are relevant:
if Cl (t) = tt for all t ∈ A, then R : A → A is unrestricted; if, on the other
hand,
Cl (t) = ÷N (t) for some explicit N ⊂ A, e.g., N,
then the computation halts when it is asked either to read R(ui ) or to update
R(ui ) for some ui ∈
/ N . This is the case with the simplest RAMs defined
by Cook and Reckhow [1973], which (as we set things up) are over the structure
(2F-4) ACR = (Z, N, 0, 1, eq0 , +, −).

Problems for Section 2F

x2F.1. Problem. Prove Proposition x2F.1, that if A is pointed, then the


register computable partial functions are exactly the tail recursive ones.
x2F.2. Problem. Prove that if f : An * As is register computable in a
pointed structure A, then there is a register program P with k ≥ n such that
x ) = iP (x1 , . . . , xn , an+1 , . . . , ak )
f(~
with some ai which are strongly explicit in A.
x2F.3. Problem. Prove that if f : An * As is computed in a pointed
structure A by a register program, then it is also computed in A by a primitive
one. Hint: Apply Problem x2F.2, and then use induction on the number of
terms in P which are not prime; you will need to do some elementary but fussy
“register machine programming”.
94 2. Recursive (McCarthy) programs
x2F.4∗ . Problem (Bounded stacks characterization). Prove that if a struc-
ture A is pointed, then a partial function f : An * As is tail recursive in A
if and only if there is an extended recursive program E(~x) which computes f
and satisfies the following bounded stacks condition: there is a number K such
that every state
a0 . . . am−1 : b0 · · · bn−1
which occurs in a computation of the recursive machine i(A, E(~x)) on input(~
x)
has length m + n + 1 ≤ K .
Hint: For the more interesting “if” direction, define an iterator whose
states are the states of the recursive machine i(A, E(~x)) of length K + 1 and
those ai which are not elements of A (tt, ff,terms, ?, etc. ) are coded by
(sequences of) constants.
x2F.5. Problem. Specify a straight line program which computes the value
of the polynomial a0 + a1 x + a2 x 2 in a field F = (F, 0, 1, +, −, ·, ÷, =) from
the input a0 , a1 , a2 , x using Horner’s rule on page 25.
x2F.6. Problem. Specify a primitive decision tree which decides the nullity
relation (1C-12) for degree n = 2 in F = (F, 0, 1, +, −, ·, ÷, =) using Horner’s
rule.
x2F.7. Problem. Suppose F = (F, 0, 1, +, −, ·, ÷, =) is a field of character-
istic 6= 2. Specify a primitive decision tree which decides the nullity relation
NF (a0 , a1 , x) ⇐⇒ a0 + a1 x = 0 of degree 1 in the reduct (F, 0, 1, ·, =), i.e.,
using no additions, subtractions or divisions.
x2F.8. Problem. Prove Proposition 2F.2.
x2F.9. Problem. Prove that for every pointed structure A = (A, Υ) and
every A-explicit N ⊆ A, the equality relation eqN on N is decidable by a
RAM machine over A in which Cl (t) = ÷N (t) in every direct or indirect
application.
Infer that the converse of Proposition 2F.2 is not true for all pointed A.21
Hint: To decide if u = v, set R(u) := 1, t := R(v) and check if t = 0.

2G. Full vs. tail recursion (I)

We discuss here some of the many important results on the relation between
full and tail recursion. It is an interesting and difficult subject, but not central

21 This does not affect the Cook-Reckhow RAMs over the structure A
CR in (2F-4), in which
eqN is obviously explicit.
2G. Full vs. tail recursion (I) 95
to our concerns, and so we will focus on just a few, characteristic facts and
mostly skip proofs.22
Examples where Tailrec0 (A) ( Rec0 (A). Perhaps the first example of a
structure where some recursive function is not tail recursive is the following
2G.1. Theorem (Patterson and Hewitt [1970], Lynch and Blum [1979]).
There is a total, pointed, countable structure
T = (T, 0, 1, s, d, leaf, red, eq0 , eq1 )
with s, d : T → T and leaf, red, eq0 , eq1 : T → B, such that
Tailrec0 (T) ( Rec0 (T),
in fact some total relation on T is recursive but not tail recursive.
Proof. For each n ≥ 0, let
Tn = {(n, t0 , . . . , ti−1 ) : i ≤ n & (∀j ≤ (i − 1))[tj ≤ 1]},
viewed as the complete binary tree of sequences of length ≤ (n + 1), with the
root labelled n and all the other nodes labelled 0 or 1. It carries the obvious
son, daughter and leaf functions
s(u) = u ∗ {0}, d (u) = u ∗ {1} (|u| < n + 1),
leaf(u) ⇐⇒ |u| = n + 1,
where |(n, t0 , . . . , ti−1 )| = i + 1 as in (1A-17) and s(u) = d (u) = u if leaf(u).
It has 2n leaves and 2n+1 − 1 nodes.
A (restricted) coloring of Tn assigns to each node white or red, so that all the
nodes which are not leaves are white and all but at most one leaf are painted
red; so there are 2n + 1 colored trees of depth n, say
Tn,1 , . . . , Tn,2n +1 with Tn,1 the tree where all leaves red.
The (disjoint) union
S
T = n,1≤j≤2n +1 Tn,j
is the universe of T, and the functions and relations on it are those inherited
from the individual trees, with the constants 0 and 1 respectively naming the
leaves (1, 0), (1, 1) of the tree T1,1 .
The unary (total) relation
(2G-1) Red(u) ⇐⇒ all the leaves below u are red
is recursive in T—in fact a simple fixed point—since it is (easily) the unique
solution of the recursive equation
 
p(u) = if leaf(u) then red(u) else p(u ∗ {0}) & p(u ∗ {1}) .

22 I am indebted to Siddharth Bhaskar for advising me on what to include from this area in

which I am anything but expert—but, of course, the blame for what is left out is entirely mine.
96 2. Recursive (McCarthy) programs
To complete the proof, it suffices to prove that Red(u) is not tail recursive, or
equivalently by Proposition 2F.1 and the discussion on page 91, that Red(u) is
not decided by a primitive register program; so assume towards a contradiction
that some primitive register program P of T with k registers and L+1 commands
decides Red(u), so that by (2F-2)
Red(u) ⇐⇒ P starting on (0, u, a~ ) returns tt
with suitable constants a
~ = a2 , . . . , ak . We consider the computations of P
on inputs of the form
(2G-2) u = (n) ∈ Tn,j , where n ≥ 2 & 1 ≤ j ≤ 2n + 1,
and we leave for Problem x2G.1 the proofs of three simple lemmas about them:
Lemma 1. If a state (l, x1 , . . . , xk ) occurs in the computation of P starting
with (2G-2), then every xi is either a constant or a node in Tn .
Call two states
s = (l, x1 , . . . , xk ) and s 0 = (l 0 , x10 , . . . , xk0 )
in a computation by P equivalent if the following conditions hold:
(i) l = l 0 .
(ii) For i = 1, . . . , k,
xi = 0 ⇐⇒ xi0 = 0, xi = 1 ⇐⇒ xi0 = 1, red(xi ) ⇐⇒ red(xi0 ).
(iii) For i = 1, . . . , k, |xi | = the length of the node xi = |xi0 |.
Notice that by (i),
if s is equivalent with s 0 , then [s is halting ⇐⇒ s 0 is halting].
Lemma 2. If s and s 0 are equivalent and the transition function of P takes s
to s and s 0 to s 0 , then s and s 0 are also equivalent.
Lemma 3. The number of equivalence classes of states in a computation of P
starting with (2G-2) is bounded by (L + 1)23k (n + 1)k .
Granting these lemmas, consider now the computation
(0, (n), a
~ ), (l1 , x
~1 ), . . . , (lm , x
~m )
of P with shape (sequence of addresses) (0, . . . , lm ) where
2n > k(L + 1)23k (n + 1)k
and (n) is the root of Tn,1 , the copy of Tn in which all leaves are red. The state
(lm , x
~m ) is halting and returns tt, and no previous state is halting; this means,
by Lemma 2, that
m < (L + 1)23k (n + 1)k < 2n ,
since otherwise some (li , x
~i ) would be equivalent with some (li+k , x
~i+k ), and
then
li = li+k = li+2k , . . . ,
2G. Full vs. tail recursion (I) 97
and the computation would diverge. It follows that at least one leaf of Tn,1 does
not occur in any of the registers during the computation, since the number of
nodes which are “seen” is ≤ k(L + 1)23k (n + 1)k < 2n ; and this means that
“the same” computation is executed by P if we start with (n) the root of the
tree Tn,i in which this leaf is white, which then returns the wrong value. a
Patterson and Hewitt [1970] was written at a time when a central problem
was the logic of programs, the search for natural conditions which insure that
two program schemas compute the same partial function on all structures of
a fixed vocabulary, cf. Walker and Strong [1973]. This influenced the formu-
lation of results, including Theorem 2 of Patterson and Hewitt [1970] which
claims only that a specific recursive program is not logically equivalent to any
finite register program. Lynch and Blum [1979] define a specific structure in
which some recursive function is not tail recursive as in Theorem 2G.1, which
we proved here by a slight modification of the Patterson-Hewitt construction.
Many better examples were given later, including Stolboushkin and Tait-
slin [1983] which starts with a Burnside group, not quite trivial to construct
and especially Tiuryn [1989], which also gives many references to the extensive
literature on the problem and related results on the difference between the ex-
pressive power between deterministic and nondeterministic register programs.
The Tiuryn example is simple to describe and it includes the identity relation
among the primitives—which makes the proof of the version of Lemma 3 that
is needed much more difficult. We will discuss some of this work in Problems
x2G.2 – x2G.4, but we will not reproduce Tiuryn’s proof.
Examples where Tailrec0 (A) should be ( Rec0 (A). Jones [1999] proves that
Tailrec0 (L–b ) ( Rec0 (L–b ) ⇐⇒ LOGSPACE 6= PTIME,
where L–b = ({0, 1}∗ , nil, eqnil , head, tail) is the cons-free reduct of the Lisp
structure L∗ on binary strings. He proves many other things in this seminal
paper, and in the subsequent Jones [2001] he obtains similar characteriza-
tions of the distinction between full and tail recursion for some higher type
structures.23
Bhaskar [2018] uses one of Jones’ methods to show that
Tailrec0 (NPd ) ( Rec0 (NPd ) ⇐⇒ EXPTIME 6= LINSPACE,
where predecessor arithmetic NPd = (N, 0, 1, Pd, eq0 ) is the successor-free
reduct of unary arithmetic Nu . A more interesting (and substantially more
difficult) result in this paper is the equivalence
Tailrec0 (Fp ) ( Rec0 (Fp ) ⇐⇒ EXPTIME 6= LINSPACE (p prime),

23 Some results of this type were also cited in Tiuryn [1989] about the related distinction between

deterministic and nondeterministic dynamic logic.


98 2. Recursive (McCarthy) programs
where Fp is the algebraic closure of the finite, prime field of characteristic p.
Bhaskar’s analysis uses the crucial fact that both NPd and Fp are locally finite
and suggests that it may be possible to characterize usefully the difference
between full and tail recursion in a structure A in terms of model-theoretic
properties of A, cf. Open Problem x2G.5.

Problems for Section 2G

x2G.1. Problem. Prove the three lemmas in the proof of Theorem 2G.1.
Hint: The commands in the primitive register program P are all in one of the
forms
xi := xj ; goto l 0 , xi := s(xj ); goto l 0 , xi := d (xj ); goto l 0
if test(xi ) goto l 0 else goto l 00 , halt, return output(xi ),
where test and output are leaf, red, eq0 , or eq1 . Taking cases on this list verifies
easily Lemmas 1 and 2, and Lemma 3 is also easily proved by a counting
argument.
x2G.2. Problem. Let for each n ≥ 0
Tn = {(n, t0 , . . . , ti−1 ) : i ≤ n & (∀j ≤ (i − 1))[tj ≤ 1]},
as in the proof of Theorem 2G.1, and consider the forest
S
Ts = ( n Tn , 0, 1, s, d, =)
as before but without the colors and with the addition of =. Prove that the
relation
(2G-3) B(u, v) ⇐⇒ u v v (v is equal to or below u)
is recursive in Ts .
Tiuryn [1989] proves that B(u, v) is not tail recursive in Ts .
x2G.3. Problem. Prove that in the structure T of Theorem 2G.1, the (par-
tial) function
White(u) = if there exists a white leaf below u then tt else ↑
is computed by a nondeterministic register program but not by any determi-
nistic one. Hint: Use a variation of the proof of Theorem 2G.1.
The corresponding problem for total functions is (as far as I know) open:
x2G.4. Open problem. Define a total, pointed structure A and a total func-
tion f : An → B which is computed by a nondeterministic register program
but not by any deterministic one.
2H. What is an algorithm? 99

x2G.5. Open problem (Bhaskar). Find model-theoretic conditions on a to-


tal structure A which characterize the strict inclusion Tailrec0 (A) ( Rec0 (A).
x2G.6. Open problem. For A = (Nε , 0, 1) = (N, rem, eq0 , eq1 , 0, 1), the
pointed expansion of the Euclidean structure, is every recursive function tail
recursive? A negative answer would produce an interesting Tiuryn-type ex-
ample (with a binary primitive), while a positive one might have a bearing on
the Main Conjecture on page 2.

2H. What is an algorithm?

We have already mentioned in the Introduction the basic foundational prob-


lem of defining algorithms24 and placed it outside the scope of this book. It
is, however, worth including here a brief discussion of the question, mostly to
point to the (few) publications that have tried to deal with it.
With the notation of Section 1E, we will focus on algorithms that compute
partial functions and relations
(2H-1) f : An * As (s ∈ {ind, boole})
from the primitives of a (partial) Φ-structure
A = (A, {φ A }φ∈Φ ).
The most substantial part of this restriction is that it leaves out algorithms
with side effects and interaction, cf. the footnote on page 3 and the relevant
Section 3B in Moschovakis [1989a].
Equally important is the restriction to algorithms from specified primitives,
especially as the usual formulations of the Church-Turing Thesis suggest that
the primitives of a Turing machine are in some sense “absolutely computable”
and need not be explicitly assumed or justified. We have noted in the Intro-
duction (and several other places) why this is not a useful approach when
we want to formulate, derive and justify robust lower complexity bounds for
mathematical problems; but in trying to understand computability and the
meaning of the Church-Turing Thesis, it is natural to ask whether there are
absolutely computable primitives and what those might be. See Sections 2 and
8 of Moschovakis [2014] for a discussion of the problem and references to rele-
vant work, especially the eloquent analyses in Gandy [1980] and Kripke [2000].

24 Using imprecise formulations of the Church-Turing Thesis and vague references to Church

[1935], [1936] and Turing [1936], it is sometimes claimed naively that algorithms are Turing
machines. This does not accord with the original formulations of the Church-Turing Thesis, cf. the
discussion in Section 1.1 of Moschovakis [2014] (which repeats points well known and understood
by those who have thought about this matter); and as we mentioned in the Introduction, it is not
a useful assumption.
100 2. Recursive (McCarthy) programs
There is also the restriction to first-order primitives, partial functions and
relations. This is necessary for the development of a conventional theory of
complexity, but recursion and computability from higher type primitives have
been extensively studied: see Kleene [1959], Kechris and Moschovakis [1977]
and Sacks [1990] for the higher-type recursion which extends directly the
first-order notion we have adopted, and Longley and Normann [2015] for a
near-complete exposition of the many and different approaches to the topic.25
Once we focus on algorithms which compute partial functions (2H-1) from
the primitives of a Φ-structure, then the problem of defining them rigorously
comes down basically to choosing between iterative algorithms specified by
computation models as in Section 2C and elementary recursive algorithms
expressed directly by recursive programs; at least this is my view, which I have
explained and defended as best I can in Section 3 of Moschovakis [1998].
The first of these choices—that algorithms are iterative processes—is the
standard view, explicitly or implicitly adopted (sometimes with additional re-
strictions) by most mathematicians and computer scientists, including Knuth
in Section 1.1 of his classic Knuth [1973]. More recently (and substantially
more abstractly, on arbitrary structures), this standard view has been devel-
oped, advocated and defended by Gurevich and his collaborators, cf. Gure-
vich [1995], [2000] and Dershowitz and Gurevich [2008]; see also Tucker and
Zucker [2000] and Dužı́ [2014].
I have made the second choice, that algorithms (which compute partial
functions from the primitives of a Φ-structure A) are directly expressed by
recursive programs, and I have developed and defended this view in several
papers, most carefully in Moschovakis [1998].
With the notation in Section 2A, my understanding of the algorithm ex-
pressed by an extended recursive Φ-program
n o
E(~x) ≡ E0 (~x) where p1 (~x1 ) = E1 , . . . , pK (~xK ) = EK
in a Φ-structure A is that it calls for solving in A the system of recursive
equations in the body of E(~x) and then plugging the solutions in its head to
compute for each x ~ ∈ An the value den(A, E(~ x )); how we find the canoni-
cal solutions of this system is not part of the elementary recursive algorithm
expressed by E(~x) in this view, and this raises some obvious questions:
About implementations (II). To compute den(A, E(~ x )) in specific cases, we
might use the method outlined in the proof of the Fixed Point Lemma 1B.1, or
the recursive machine defined in Section 2C or any one of several well known
and much studied implementations of recursion. These are iterative algorithms
which (generally) use fresh primitives and should satisfy additional properties,
25 See also Moschovakis [1989a]—which is about recursion on structures with arbitrary

monotone functionals for primitives—and the subsequent Moschovakis [1989b] where the rele-
vant notion of algorithm from higher-type primitives is modeled rigorously.
2H. What is an algorithm? 101

cf. the discussion on page 73; so to specify the admissible implementations of a


recursive program is an important (and difficult) part of this approach to the
foundations of the theory of algorithms, cf. Moschovakis [1998] and (espe-
cially) Moschovakis and Paschalis [2008] which includes a precise definition
and some basic results.
Imperative vs. functional programming. This “incompleteness” of elemen-
tary recursive algorithms is surely a weakness of this view and an important
advantage of the standard view that asks for a specific iterative process rather
than the (more difficult) identification of all admissible implementations of
a recursive program. Some of this advantage disappears, however, when we
want to understand algorithms which are not expressed by tail recursive pro-
grams (page 61): for example, what is the iterative program which expresses
the merge-sort as it is specified in Proposition 1C.2? There are many, and it
seems that we can understand “the merge-sort” and reason about it better by
looking at this proposition rather than by focussing on choosing a specific
implementation of it.
Moreover, there are also some advantages to this incompleteness of elemen-
tary recursive algorithms:
Proofs of correctness. In Proposition 1C.2, we claimed the correctness of
the merge-sort—that it sorts—by just saying that
The sort function satisfies the equation . . .
whose proof was too trivial to deserve more than the single sentence
The validity of (1C-6) is immediate, by induction on |u|.
To prove the correctness of an iterator that “expresses the merge-sort”, you
must first design a specific one and then explain how you can extract from all
the “housekeeping” details necessary for the specification of iterators a proof
that what is actually being computed is the sorting function; most likely you
will trust that a formal version of (1C-6) is implemented correctly by some
compiler or interpreter of whatever higher-level language you are using, as we
did for the recursive machine.
Simply put, whether correct or not, the view that algorithms are faithfully
expressed by systems of recursive equations separates proofs of their correct-
ness, which involve only purely mathematical facts from the relevant subject
and standard results of fixed-point-theory, from proofs of implementation cor-
rectness for programming languages which are ultimately necessary but have
a very different flavor.
What we will not do in this book is to give a precise (set-theoretic) definition
of the algorithm on a Φ-structure expressed by a Φ-recursive program; several
versions of this are given in the several papers already cited, it is neither simple
nor as definitive as I would want it to be—and we do not need it.
CHAPTER 3

COMPLEXITY THEORY FOR RECURSIVE PROGRAMS

Suppose Π is a class of extended programs which compute (in some precise


sense) partial functions and relations on a set A. In the most general terms, a
complexity measure for Π associates with each n-ary E ∈ Π which computes
f : An * As an n-ary partial function
(3-2) CE : An * N
which intuitively assigns to each x
~ such that f(~
x )↓ a cost of some sort of the
computation of f(~ x ) by E.
We introduce here several natural complexity measures on the (determi-
nistic) recursive programs of a Φ-structure A, directly from the programs,
i.e., without reference to the recursive machine. These somewhat abstract,
“implementation-independent” (logical) definitions help clarify some ques-
tions about complexity, and they are also useful in the derivation of upper
bounds for recursive programs and robust lower bounds for problems. Much
of what we will say extends naturally to nondeterministic programs, but the
formulas and arguments are substantially more complex and it is better to
keep matters simple by dealing first with the more important, deterministic
case.

3A. The basic complexity measures

Suppose A is a structure, E(~x) is an n-ary, extended, A-program and M is


an (A, E)-term as these were defined in (2D-1), i.e.,
M ≡ N (y1 , . . . , ym ) with N a subterm of E and y1 , . . . , ym ∈ A.
Extending the notation of (2A-5), we set
(3A-1) M = den(A, E, M ) = den((A, p1 , . . . , pK ), M ),
(3A-2) Conv(A, E) = {M : M is an (A, E)-term and M ↓ },
where p1 , . . . , pK are the recursive variables of E and p1 , . . . , pK their mutual
fixed points.

103
104 3. Complexity theory for recursive programs

Normally we will use the simpler M rather than den((A, p1 , . . . , pK ), M ),


since A and E will be held constant in most of the arguments in this section.
The tree-depth complexity DEA (M ). With each convergent (A, E)-term M ,
we will associate a computation tree T (M ) which represents an abstract, paral-
lel computation of M using E. The tree-depth complexity of M is the depth of
T (M ), but it is easier to define DEA (M ) first and T (M ) after that, by recursion
on DEA (M ).
3A.1. Lemma. Fix a structure A and an A-program E. There is exactly one
function D = DEA which is defined for every M ∈ Conv(A, E) and satisfies the
following conditions:
(D1) D(tt) = D(ff) = D(x) = D(φ) = 0 (if arity(φ) = 0 and φ A ↓ ).
(D2) D(φ(M1 , . . . , Mm )) = max{D(M1 ), . . . , D(Mm )} + 1.
(D3) If M ≡ if M0 then M1 else M2 , then
(
max{D(M0 ), D(M1 )} + 1, if M 0 = tt,
D(M ) =
max{D(M0 ), D(M2 )} + 1, if M 0 = ff.

(D4) If p is a recursive variable of E,26 then


D(p(M1 , . . . , Mm )) = max{D(M1 ), . . . , D(Mm ), dp (M 1 , . . . , M m )} + 1,
where dp (w)
~ = D(Ep (w)).
~
The tree-depth complexity in A of an extended program E(~x) is that of its
head term,
(3A-3) dE (~
x ) = d (A, E(~
x )) =df D(E0 (~
x )) (den(A, E(~
x ))↓ ).

Proof. If M = den((A, p1 , . . . , pK ), M )↓ , then there is some k such that


k
(3A-4) M = den((A, pk1 , . . . , pkK ), M )↓ ,

where pk1 , . . . , pkK are the iterates of the system that defines M as in the proof
of the Fixed Point Lemma, Theorem 1B.1. We define D(M ) by recursion on
k
(3A-5) stage(M ) = the least k such that M ↓ ,
and recursion on the length of terms within this. We consider cases on the
form of M .
(D1) If M is tt, ff, x ∈ A or a convergent, nullary constant, set D(M ) = 0.
(D2) If M ≡ φ(M1 , . . . , Mm ) for some φ ∈ Φ and M ↓ , then
stage(M ) = max{stage(M1 ), . . . , stage(Mm )},

26 If p ≡ p is a recursive variable of E, we sometimes write E ≡ E for the term which defines


i p i
p in E. It is a useful convention which saves typing double subscripts.
3A. The basic complexity measures 105

and these subterms are all smaller than M , so we may assume that D(Mi ) is
defined for i = 1, . . . , m; we set
D(M ) = max{D(M1 ), . . . , D(Mm )} + 1.
(D3) If M ≡ if M0 then M1 else M2 and M ↓ , then either M 0 = tt, M 1 ↓
and stage(M ) = max{stage(M0 ), stage(M1 )} or the corresponding conditions
hold with M0 and M2 . In either case, the terms M0 , Mi are proper subterms
of M , and we can assume that D is defined for them and define D(M )
appropriately as in case (D2).
(D4) If M ≡ p(M1 , . . . , Mm ) with a recursive variable p of E, M ↓ and
k = stage(M ), then
k k k
M = pk (M 1 , . . . , M m )↓ ,
and so stage(Mi ) ≤ k and we can assume that D(Mi ) is defined for i =
1, . . . , n, since these terms are smaller than M . Moreover, if M 1 = w1 , . . . ,
M m = wm , then
pk (w1 , . . . , wm ) = den((A, pk−1
1 , . . . , pk−1
K ), Ep (w1 , . . . , wm ))↓

by the definition of the iterates in the proof of Lemma 1B.1, and so


(3A-6) k ≥ stage(p(w1 , . . . , wm )) = stage(Ep (w1 , . . . , wm )) + 1;
so we may assume that D(Ep (w1 , . . . , wm )) is defined, and define D(M ) so
that (D4) in the lemma holds.
The uniqueness of D is proved by a simple induction on stage(M ), following
the definition. a
There is no reasonable way to implement recursive programs so that the
number of steps required to compute M is D(M ). For example, to attain
D(p(M )) = max{D(M ), D(Ep (M ))} + 1,
we need to compute in parallel the value M of M and the value of Ep (M ),
but we cannot start on the second computation until we complete the first, so
that we know M . We can imagine a nondeterministic process which “guesses”
the correct M and works with that; but if A is infinite, then this amounts to
infinite nondeterminism, which is not a useful idealization.
In any case, our methods do not yield any interesting lower bounds for
tree-depth complexity, but it is a very useful tool for defining rigorously and
analysing many properties of recursive programs.
The computation tree. The computation tree T (M ) = T (A, E, M ) for
M ∈ Conv(A, E) is defined by recursion on D(M ) using the operation Top
in (1A-20), see Figure 3. We take cases, corresponding to the definition of
D(M ):
(T 1) If M is tt, ff, x ∈ A or a nullary constant φ, set T (M ) = {(M )}.
106 3. Complexity theory for recursive programs

tt ff x φ φ(M1 , . . . , Mn )

  ^ q
M1 M2 ... Mn

if M0 then M1 else M2 (M 0 = tt) if M0 then M1 else M2 (M 0 = ff)

= ^ R
M0 M1 M0 M2

p(M1 , . . . , Mn )

) = s z
?
M1 M2 ... Mn Ep (M 1 , . . . , M n )

Figure 3. Computation trees.

(T 2) If M ≡ φ(M1 , . . . , Mm ), set T (M ) = Top(M, T (M1 ), . . . , T (Mm )).


(T 3) If M ≡ if M0 then M1 else M2 , set
(
Top(M, T (M0 ), T (M1 )) if M 0 = tt,
T (M ) =
Top(M, T (M0 ), T (M2 )) if M 0 = ff.

(T 4) If M ≡ p(M1 , . . . , Mm ), set
T (M ) = Top(M, T (M1 ), . . . , T (Mm ), T (Ep (M 1 , . . . , M m ))).

3A.2. Proposition. For every M ∈ Conv(A, E),


D(M ) = depth(T (M )).

Proof is trivial, by induction on D(M ). a


3A. The basic complexity measures 107

The sequential logical complexity Ls (M ) (time). For a fixed Φ-structure A


and a Φ-program E, the sequential logical complexity
Ls (M ) = Ls (A, E, M ) (M ∈ Conv(A, E))
is defined by the following recursion on D(M ):
(Ls 1) Ls (tt) = Ls (ff) = Ls (x) = 0 (x ∈ A) and Ls (φ) = 1.
(Ls 2) Ls (φ(M1 , . . . , Mn )) = Ls (M1 ) + Ls (M2 ) + · · · + Ls (Mn ) + 1.
(Ls 3) If M ≡ if M0 then M1 else M2 , then
(
s Ls (M0 ) + Ls (M1 ) + 1 if M 0 = tt,
L (M ) =
Ls (M0 ) + Ls (M2 ) + 1 if M 0 = ff.

(Ls 4) If p is a recursive variable of E, then

Ls (p(M1 , . . . , Mn )) = Ls (M1 ) + · · · + Ls (Mn )


+ Ls (Ep (M 1 , . . . , M n )) + 1.

The sequential logical complexity in A of an extended program E(~x) is that of


its head term
(3A-7) lEs (~
x ) = l s (A, E(~
x )) =df Ls (E0 (~
x )) (denA
E (~
x )↓ ).

Intuitively, Ls (M ) counts the number of steps required for the computation


of M using “the algorithm expressed by” E and it should be a good approxi-
mation of the time complexity of any implementation of E. We cannot prove
this in general absent a precise definition of implementations, but it can be
verified for specific cases: for example, if

(3A-8) TimeA,E (M ) = the length of the computation


of the recursive machine for A and E on M :

then there is a number C (depending only on the program E) such that


(3A-9) Ls (M ) ≤ Time(M ) ≤ Ls (M ) + C (for all M ∈ Conv(A, E)),
cf. Problem x3A.2∗ . This implies that
lEs (~ x ) ≤ lEs (~
x ) ≤ TimeA,E (~ x) + C (A |= E(~
x )↓ ),
and we would expect that for every iterator i which implements E(~
x ) on A, at
least
lEs (~ x ) = O(lEs (~
x ) ≤ Timei (~ x) + C )
for some constant C .
108 3. Complexity theory for recursive programs

The parallel logical complexity Lp (M ). For a fixed Φ-structure A and a


Φ-program E, the parallel logical complexity
Lp (M ) = Lp (A, E, M ) (M ∈ Conv(A, E))
is defined by the following recursion on D(M ):
(Lp 1) Lp (tt) = Lp (ff) = Lp (x) = 0 (x ∈ A) and Lp (φ) = 1.
(Lp 2) Lp (φ(M1 , . . . , Mn )) = max{Lp (M1 ), . . . , Lp (Mn )} + 1.
(Lp 3) If M ≡ if M0 then M1 else M2 , then
(
p max{Lp (M0 ), Lp (M1 )} + 1, if M 0 = tt,
L (M ) =
max{Lp (M0 ), Lp (M2 )} + 1, if M 0 = ff.

(Lp 4) If p is a recursive variable of E, then

Lp (p(M1 , . . . , Mn )) = max{Lp (M1 ), . . . , Lp (Mn )}


+ Lp (Ep (M 1 , . . . , M n )) + 1;
and again, we put
(3A-10) lEp (~
x ) = l p (A, E(~
x )) =df Lp (E0 (~
x )) (denA
E (~
x )↓ ).
Intuitively, Lp (M ) counts the minimal number of steps that must be exe-
cuted in sequence in any computation of M by the algorithm expressed by E.
No chance to prove this rigorously, of course, but it seems that the difference
between Ls (M ) and Lp (M ) measures (in some vague sense) how “parallel”
the algorithm expressed by E is. It is no more than exponential with base one
more than the total arity of the program

(3A-11) ` = `(E(~x)) = max{arity(E(~x)), max{arity(φ) : φ ∈ Φ},


max{arity(pi ) : i = 1, . . . , K }}.
3A.3. Theorem. For every Φ-structure A, every Φ-program E of total arity
` ≥ 1 and every M ∈ Conv(A, E),
(1) Ls (M ) ≤ |T (M ))|,
(2) depth(T (M )) ≤ Lp (M ),
p
(3) Ls (M ) ≤ (` + 1)L (M )+1 − 1,
p
(4) Ls (M ) ≤ (` + 1)L (M ) ,
~ such that pE (~
and hence, for all x x )↓ ,
p
x ) ≤ (` + 1)lE (~x ) .
lEs (~
Proof. (1) and (2) are verified by simple inductions on D(M ), and (3)
follows from (1) and (3) of Problem x1A.4, because degree(T (M )) = ` + 1.
(These inequalities are basically obvious from the tree pictures in Figure 3.)
3A. The basic complexity measures 109

(4) is somewhat stronger than (3) and simpler, which makes it (perhaps)
worth proving, although this involves some seemingly unavoidable computa-
tions.
By Problem x3A.11 a stronger inequality holds when ` = 1, so we assume
that ` ≥ 2 and proceed again by induction on D(M ).
Case 1. D(M ) ≤ 1. In this case M is tt, ff, a parameter x ∈ A or a nullary
p
constant φ, so that Lp (M ) = Ls (M ) ≤ 1 ≤ (` + 1)L (M ) .
Case 2, M ≡ φ(M1 , . . . , Mn ). The induction hypothesis gives us the result
for M1 , . . . , Mn , and we compute:
Ls (M ) = Ls (M1 ) + · · · + Ls (Mn ) + 1
p p
(M1 ) (Mn )
≤ (` + 1)L + · · · + (` + 1)L +1
≤ `(` + 1)A + 1 (A = max{Lp (M1 ), . . . , Lp (Mn )})
p
(M )
≤ `(` + 1)A + (` + 1)A = (` + 1)A+1 = (` + 1)L .
Case 3, M ≡ if M0 then M1 else M2 . The argument is very similar to Case
2 and we skip it.
Case 4, M ≡ p(M1 , . . . , Mn ). Now
Ls (M ) = Ls (M1 ) + · · · + Ls (Mn ) + Ls (Ep (M 1 , . . . , M n )) + 1.
If Lp (M1 ) = · · · = Lp (Mn ) = 0, then each Mi is a truth value or a parameter
x, so their sequential logical complexities are also = 0, and then, using the
induction hypothesis:
Ls (M ) = Ls (Ep (M 1 , . . . , M n )) + 1
p
(Ep (M 1 ,... ,M n ))
≤ (` + 1)L +1
Lp (Ep (M 1 ,... ,M n ))+1 p
(M )
≤ (` + 1) = (` + 1)L .
In the opposite case, setting
A = max{Lp (M1 ), . . . , Lp (Mn )} ≥ 1, B = Lp (Ep (M 1 , . . . , M n )),
we can compute as above:
Ls (M ) = Ls (M1 ) + · · · + Ls (Mn ) + Ls (Ei (M 1 , . . . , M n )) + 1
p p
≤ (` + 1)L (M1 ) + · · · + (` + 1)L (Mn )
+ (` + 1)B + 1
≤ `(` + 1)A + (` + 1)B+1 ,
and it suffices to prove that for all A ≥ 1 and all B ∈ N,
`(` + 1)A + (` + 1)B+1 ≤ (` + 1)A+B+1 ;
but this inequality is equivalent to
` 1
+ ≤ 1,
(` + 1)B+1 (` + 1)A
110 3. Complexity theory for recursive programs

which is obvious when A ≥ 1. a


Next we define two complexity measures on recursive programs which dis-
regard the logical steps and count only calls to the primitives.
The number-of-calls complexity C s (Φ0 )(M ). Fix a Φ-structure A, a subset
Φ0 ⊆ Φ of the vocabulary and an extended Φ-program E(~x). The number of
calls to Φ0
C s (Φ0 )(M ) = C s (Φ0 )(A, E(~x), M )
of any M ∈ Conv(A, E) is defined by the following recursion on D(M ):
(C s 1) C s (Φ0 )(tt) = C s (Φ0 )(ff) = C s (Φ0 )(x) = 0 (x ∈ A); and for nullary
constants, C s (Φ0 )(φ) = 0 if φ ∈ / Φ0 , and C s (Φ0 )(φ) = 1 if φ ∈ Φ0 .
(C s 2) If M ≡ φ(M1 , . . . , Mn ), then
(
s C s (Φ0 )(M1 ) + · · · + C s (Φ0 )(Mn ) + 1, if φ ∈ Φ0 ,
C (Φ0 )(M ) =
C s (Φ0 )(M1 ) + · · · + C s (Φ0 )(Mn ), otherwise.
(C s 3) If M ≡ if M0 then M1 else M2 , then
(
s C s (Φ0 )(M0 ) + C s (Φ0 )(M1 ), if M 0 = tt,
C (Φ0 )(M ) =
C s (Φ0 )(M0 ) + C s (Φ0 )(M2 ), if M 0 = ff.
(C s 4) If M ≡ p(M1 , . . . , Mn ) with p a recursive variable of E, then

C s (Φ0 )(M ) = C s (Φ0 )(M1 ) + · · · + C s (Φ0 )(Mn )


+ C s (Φ0 )(Ep (M 1 , . . . , M n )).
The number of Φ0 -calls complexity in A of E(~x) is that of its head term,
(3A-12) c s (Φ0 )(~
x ) = c s (Φ0 )(A, E(~
x )) =df C s (Φ0 )(A, E(~x), E0 (~
x )),
and it is defined exactly when denA
E (~
x )↓ . We also set
(C s , c s ) C s (M ) = C s (Φ)(M ), c s (~
x ) = c s (Φ)(~
x)
when we want to count the calls to all primitives.
This is a very natural complexity measure: C s (Φ0 )(M ) counts the number of
calls to the primitives in Φ0 which are required for the computation of M using
“the algorithm expressed” by the program E and disregarding the “logical
steps” (branching and recursive calls) as well as calls to primitives not in Φ0 .
It does not distinguish between parallel and sequential implementations of E,
although it is more directly relevant to the second—so we will sometimes refer
to it as the sequential calls complexity.
Notice that E may (stupidly) call many times for the same value of one of
the primitives, and all these calls will be counted separately by C s (Φ0 )(M ).
Most of the lower bounds of algebraic problems that we will derive are about
3A. The basic complexity measures 111

a somewhat smaller measure which counts only the number of distinct calls
to the primitives in Φ0 .
C s (M ) can be easily read off the computation tree T (M ) and also off the
computation of the recursive machine starting with M : , Problems x3A.13
and x3A.14.
The depth-of-calls complexity C p (Φ0 )(M ). Fix again a Φ-structure A, a
subset Φ0 ⊆ Φ of the vocabulary and an extended Φ-program E(~x). The
depth of calls to Φ0
C p (Φ0 )(M ) = C p (Φ0 )(A, E, M )
of any M ∈ Conv(A, E) is defined by the following recursion on D(M ):
(C p 1) C p (Φ0 )(tt) = C p (Φ0 )(ff) = C p (Φ0 )(x) = 0 (x ∈ A); and for
nullary constants, C p (Φ0 )(φ) = 0 if φ ∈ / Φ0 , and C p (Φ0 )(φ) = 1
if φ ∈ Φ0 .
(C p 2) If M ≡ φ(M1 , . . . , Mn ), then
(
max{C p (Φ0 )(M1 ), . . . , C p (Φ0 )(Mn )} + 1, if φ ∈ Φ0 ,
C p (Φ0 )(M ) =
max{C p (Φ0 )(M1 ), . . . , C p (Φ0 )(Mn )}, otherwise.
(C p 3) If M ≡ if M0 then M1 else M2 , then
(
max{C p (Φ0 )(M0 ), C p (Φ0 )(M1 )}, if M 0 = tt,
C p (Φ0 )(M ) =
max{C p (Φ0 )(M0 ), C p (Φ0 )(M2 )}, if M 0 = ff.
(C p 4) If M ≡ p(M1 , . . . , Mn ) of E with p a recursive variable of E, then
C p (Φ0 )(M ) = max{C p (Φ0 )(M1 ), . . . , C p (Φ0 )(Mn )}
+ C p (Φ0 )(Ep (M 1 , . . . , M n )
The depth of calls to Φ0 of E in A is that of its head term,
(3A-13) c p (Φ0 )(~
x ) = c p (Φ0 )(A, E(~
x )) =df C p (Φ0 )(A, E0 (~
x )),
and again, we skip the subscript when it is Φ,
(C p , c p ) C p (M ) = C p (Φ))(M ), c p (~
x ) = c p (Φ)(~
x ).
Intuitively, the number C p (Φ0 )(M ) counts the maximal number of calls
to the primitives in Φ0 that must be executed in sequence in any computation
of M by (any implementation of) E. It is more directly relevant to parallel
implementations—which is why we will sometimes call it the parallel calls
complexity. It is not as easy to read it from T (M ), however, which assumes
not only parallelism but (potentially infinite) nondeterminism. In the key
recursive calls p(M1 , . . . , Mn ), for example, we put the children on the same
level,
M1 , . . . , Mn , Ep (M 1 , . . . , M n )
112 3. Complexity theory for recursive programs

so that the depth of the tree is one more than the maximum of the depths
of the trees for these terms; but M 1 , . . . , M n must be computed before the
computation of the rightmost child can be (realistically) started,27 which is
why we set
C p (Φ0 )(p(M1 , . . . , Mn ))
= max{C p (Φ0 )(M1 ), . . . , C p (Φ0 )(Mn )} + C p (Φ0 )(Ep (M 1 , . . . , M n )).
C p (Φ0 )(M ) is also not easy to read off the computation of the recursive
machine starting with M : , for a different reason: it is a measure of parallel
complexity and the recursive machine is decidedly sequential.
The complexity measure c p (~ x ) is majorized by all natural complexity mea-
sures of all reasonable implementations of recursive programs, and so lower
bound results about it have wide applicability. Most of the lower bounds for
problems in arithmetic we will derive in Part II are for a related “intrinsic”
complexity measure, somewhat smaller than c p (~ x ).

Problems for Section 3A

x3A.1. Problem. Make precise and prove that all five of the complexity
functions we introduced for recursive programs are preserved under isomor-
phisms.
For example, if ð : A  → B is an isomorphism of one Φ-structure onto
another, N (~y) is a pure voc(E)-term and y ~ ∈ An , then

A |= N (~
y ) = w =⇒ B |= N (ð(~ y )) = ð(w)

& C s (Φ0 )(A, E, N (~
y )) = C s (Φ0 )(B, E, N (ð(~
y ))) .
Hint: Prove this first for the tree-depth complexity D(M ).
x3A.2∗ . Problem. Prove (3A-9), that for each program E, there is a number
C = CE such that for every M ∈ Conv(A, E),
Ls (M ) ≤ TimeA,E (M ) ≤ Ls (M ) + C.
Hint: For the second, non-trivial inequality, prove that for every pure,
~ ∈ Am ,
extended voc(E)-term N (~y), there is a number CN such that for all y
y )↓ =⇒ Ls (M ) ≤ Time(M ) + CN .
M = N (~
The next problem is a more detailed version of Theorem 2C.1, which re-
lates the time complexity of an iterator in (2C-4) with the sequential calls-
complexity of the associated tail recursive program.
27 This leaves out so-called call-by-need implementations, a variety of call-by-name implemen-

tations which are outside the scope of this book.


3A. The basic complexity measures 113

x3A.3. Problem. Prove that for each iterator i and the associated recursive
program E ≡ Ei on A = Ai and for all x ∈ X ,
i(x) = den(Ai , Ei (x)),
s
c (Ai , Ei (x)) = 2 Timei (x) − 1.
Hint: Prove that if
n o
p(input(~x)) where p(~u) = if test(~u) then output(~u) else p(ó(~u))

is the tail recursive program which computes i(x) in Ai , then for every state s
of i and n ≥ 1,
p(s) : ↓ & C s (p(s)) = 2n
⇐⇒ there is a convergent computation (s1 , . . . , sn ) of i with s = s1 .
This exact relation between the time complexity of i and the number-of-
calls complexity of the associated recursive program Ei reflects some specific
choices we made in how we count Timei and it is not of any particular interest;
on the other hand, we would expect that any “natural” complexity measure
Ti (x) of an iterator i is “coded” in Ei , in the sense that
Ti (x) = Θ(C (Ai , Ei (x)))
for some “natural” complexity measure on recursive programs. This is one
version of the claim that algorithms can be faithfully expressed by recursive
programs on which we have been harping.
x3A.4. Problem. Prove that for each extended Φ-program with empty body
E(~x) ≡ E(~x) where { } (a Φ-term), there is a number CE such that for every
Φ-structure A and x~ ∈ An ,
x )↓ =⇒ lEs (~
A |= E(~ x ) ≤ CE .
Hint: Take CE to be any reasonable definition of the length of E.
x3A.5. Problem. Prove that the following are equivalent for any structure
A and M ∈ Conv(A, E):
(i) C p (M ) = 0.
(ii) Ls (M ) = 0.
(iii) The value M is independent of the primitives of A, i.e., for any Φ-
structure A0 = (A, Υ0 ) with the same universe
den(A, E, M ) = den(A0 , E, M ).
(iv) There are no Φ-nodes in the computation tree T (M ).
We will sometimes appeal silently to this simple observation to simplify
formulas, for example by dividing by c p (A, E(~ x )) or using it in the form
x )) ≥ 1 when the value denA
c p (A, E(~ E (~
x ) obviously depends on the primitives
of A.
114 3. Complexity theory for recursive programs

x3A.6. Problem. Prove that for any term M ∈ Conv(A, E),


(3A-14) D(M ) ≤ Lp (M ).

x3A.7. Problem. Compute (up to a multiplicative constant) cEp (x, y) for


the program defined (informally) in Problem x1B.1.
x3A.8. Problem. Compute (up to a multiplicative constant) cEp (x, y) for
the program defined (informally) in Problem x1B.2.
x3A.9. Problem. Compute (up to a multiplicative constant) c p (x, y) for
the program in Problem x1B.3.
x3A.10. Problem. Give an example of a structure A, a recursive program
of total arity 0 and, for any n, a term M ∈ Conv(A, E) such that Ls (M ) = n,
(so (3) or Theorem 3A.3 fails for ` = 0).
x3A.11. Problem. Prove that if A is a Φ-structure and E(x) is an extended
Φ-program of total arity 1, then for every M ∈ Conv(A, E),
p p
(M ) (M )
Ls (M ) ≤ 2L − 1 < 2L .
x3A.12. Problem. Consider the program E with the single equation
p(x) = if (x = 0) then 0 else p(Pd(x)) + p(Pd(x))
in the structure (N, 0, 1, Pd, +, eq0 ). Determine the function denE (x) com-
puted by this program, and verify that for some r > 1 and all sufficiently
large x,
p p
lEs (x) ≥ r lE (x) , cEs (x) ≥ r cE (x) .
A node (u0 , . . . , ui ) in a computation tree T (M ) is a Φ0 -node if ui ≡
φ(N1 , . . . , Nn ) for some φ ∈ Φ0 .
x3A.13. Problem. Prove that C s (Φ0 )(A, E, M ) is the number of Φ0 -nodes
in T (M ). Hint: Use induction on D(M ).
x3A.14. Problem. Prove that C s (Φ0 )(A, E, M ) is the number of external
calls a~ φ : w1 · · · wn ~b with φ ∈ Φ0 in the computation of the recursive
machine for A which starts with M : .
Note that with M ≡ E0 (~ x ), this agrees with the definition of c s (Φ0 )(A, E(~
x ))
in (2E-5) for the more general case, when E may be nondeterministic. Hint:
Use induction on D(M ) (with frequent appeals to Lemma 2D.1).
x3A.15. Open problem (vague). Is there a conceptually simple and techni-
cally useful way to read C p (Φ0 )(A, E, M ) from the tree T (M ) or from the
computation of the recursive machine for A which starts with M : , similar to
the characterization of C s (Φ0 )(A, E, M ) in the preceding two problems?
3B. Complexity inequalities 115

3B. Complexity inequalities

Next we derive the expected inequalities among these complexity measures.


3B.1. Proposition. For each Φ-structure A, each extended Φ-program E(~x)
of total arity ` ≥ 1 and each M ∈ Conv(A, E):
p
(M )
C s (M ) (` + 1)L
≤ ≤ ≤
p s
C (M ) L (M )
≤ ≤ ≤
D(M ) ≤ L (M ) p
(` + 1)D(M )+1
~ such that den(A, E(~
and, in particular, for all x x ))↓ ,
p
(~
x)
c s (~
x) (` + 1)l
≤ ≤ ≤
c p (~
x) l s (~
x)
≤ ≤ ≤
x ) ≤ l p (~
d (~ x) (` + 1)d (~x )+1 .
Proof. The five inequalities on the left are very easy to check by induction
on D(M ) and the top one on the right is Theorem 3A.3. The bottom one on
the right holds because
Ls (M ) ≤ |T (M )| (by (1) of Theorem 3A.3)
< degree(T (M ))depth(T (M ))+1 (by (3) of Problem x1A.4)
≤ (` + 1)depth(T (M ))+1 (because degree(T (M )) ≤ ` + 1)
≤ (` + 1)D(M ))+1 ,
the last by Proposition 3A.2. a
Together with Problem x3A.12, Theorem 3A.3 gives the expected relation
between the sequential and parallel logical complexities: lEs (~ x ) is bounded
by an exponential function of lEp (x) and in some cases it requires this rate of
growth—although we have not established that (` + 1) is the smallest base for
this.
Recursive vs. explicit definability. This last inequality bounds l s (~x ), the
largest of the four basic complexity functions associated with a recursive pro-
gram by an exponential of its tree-depth complexity d (~ x ). It implies a simple
characterization of explicit definability in terms of tree-depth complexity, in
“reasonable” structures:
3B.2. Theorem. Suppose Φ has a relation symbol R of arity m > 0 and A is
a Φ-structure such that RA : Am → B is total.
116 3. Complexity theory for recursive programs

Then: for any f : An * As and S ⊆ {~ x ) ↓ } the following are equiva-


x : f(~
lent:
(1) There is an A-explicit f ∗ : An * As such that
x ) = f ∗ (~
~ ∈ S =⇒ f(~
x x ).
(2) There is an extended Φ-program E(~x) and a number C such that for every
~ ∈ S,
x
x ) = denA
f(~ E (~
x ) and d (~
x ) = d (A, E(~
x )) ≤ C.
Proof. (1) =⇒ (2) follows immediately from (x3A.4), taking E(~x) to be
any program (with empty body) that computes f ∗ (~ x ) on S.
For the converse, assume (2) for a program E(~x) with recursive variables
p1 , . . . , pK and look back at the proof of Lemma 3A.1: the tree-depth com-
plexity D(M ) of M ∈ Conv(A, E) was defined in terms of
k
M = den((A, pk1 , . . . , pkK ), M ),
where pk1 , . . . , pkK are the iterates of the system that defines M as in the proof
of the Fixed Point Lemma, Theorem 1B.1.
Lemma 1. For every M ∈ Conv(A, E),
k
D(M ) ≥ the least k such that M ↓ = stage(M ).
Proof is by induction on the definition of D(M ), and it is very easy, except
perhaps for Case (D4),
D(p(M1 , M2 )) = max{D(M1 ), D(M2 ), D(Ep (M 1 , M 2 ))} + 1,
taking m = 2 to keep the notation simple. By (3A-6)
stage(p(M 1 , M 2 )) = stage(Ep (M 1 , M 2 )) + 1;
and so, using the induction hypothesis,
D(p(M 1 , M 2 )) ≥ max{stage(M1 ), stage(M2 ), stage(p(M 1 , M 2 )) − 1} + 1
≥ stage(p(M 1 , M 2 )). a (Lemma 1)

Lemma 2. For each k and each (A, E)-term M ≡ N (~ x ), there is an A-explicit


function fN,k (~
x ) (depending only on N and k) such that
k k
(3B-1) M ↓ & D(M ) ≤ k =⇒ M = fN,k (~
x ).
Proof. This is where we will use the hypothesis about A, which ensures that
Expl(A) is closed under substitutions by Proposition 1E.4.
We define fN,k by recursion on D(M ), skipping the verifications of (3B-1)
which are all routine.
(D1) D(M ) = 0, so M ≡ N (~ x ) with N (~x) one of tt, ff, xi ; we set fN,0 (~
x ) to
one of tt, ff, xi accordingly.
3B. Complexity inequalities 117

(D2) M ≡ φ(M1 , . . . , Mm ) ≡ N (~
x ) with N (~x) ≡ φ(N1 (~x), . . . , Nm (~x)).
Now D(Mi ) < k = D(M ), so we can set
x ) = φ A (fN1 ,k−1 (~
fN,k (~ x ), . . . , fN2 ,k−1 (~
x )).
(D3) where M is defined by branching is handled similarly.
(D4) Taking m = 2 again,
M ≡ p(M1 , M2 ) ≡ p(N1 (~
x ), N2 (~
x ))
for a recursive variable p of E and
M = den(A, Ep (M 1 , M 2 ));
now D(M1 ), D(M2 ), D(Ep (M 1 , M 2 )) < D(M ), so we can use the induction
hypothesis and set
fN,k (~
x ) = fEp ,k−1 (fN1 ,k−1 (~
x ), fN2 ,k−1 (~
x )). a (Lemma 2)
To prove (1) with f(~ x ) = den(A, E(~
x )), we note that a uniform bound on
d (~
x ) gives a uniform bound k for stage(~x ) for x
~ ∈ S by Lemma 1; and then
Lemma 2 gives an explicit definition for f(~ x ) on S. a
Tserunyan’s inequalities. The constants in Proposition 3B.1 depend only on
Φ and the total arity of a program which computes some f : An * As in any
Φ-structure A, and their proofs were quite simple. Less obvious is that for any
program E, there are constants Ks , Kp such that for every Φ-structure A, if
den(A, x ~ )↓ , then
(3B-2) (a) lEs (~
x ) ≤ Ks + Ks cEs (~
x ), (b) lEp (~
x ) ≤ Kp + Kp cEp (~
x ),
i.e., in both the sequential and the parallel measures, counting the logical steps
in addition to the calls to the primitives produces at most a linear increase in
complexity. From the point of view of deriving lower bounds, the significance
of these inequalities becomes evident if we reverse them:
1 s 1 p
(3B-3) (a) cEs (~
x) ≥ (l (~
x ) − Ks ), (b) cEp (~
x) ≥ (l (~
x ) − Kp ).
Ks E Kp E
Here (a) means that the high sequential complexity of a f : An * As from
specified primitives is not caused by the large number of logical operations
that we must execute to compute f(~ x )—i.e., (literally) by the “computational
complexity” of f—but is due to the large number of calls to the primitives
that are necessary to compute f(~ x ), at least up to a linear factor. Ditto for
the parallel complexity lEp (~
x ) and its “calls-counting” counterpart cEp (~x ). It
is another manifestation of the fact that lower bound results are most often
proved by counting calls to the primitives, which is well known and little
understood; and, incidentally, it emphasizes the importance of identifying all
the (non-logical) primitives that are used by an algorithm which computes a
particular function.
118 3. Complexity theory for recursive programs

The proofs of these inequalities require some new ideas and are due to
Anush Tserunyan.28
We fix a Φ-structure A and a recursive program E with recursive variables
p1 , . . . , pK and total arity ` = `(E) ≥ 1. We can insure that

the number of free and bound variables in E ≤ `

by making innocuous alphabetic changes to the bound variables of E. It


follows that if

t = t(E) = the number of distinct subterms of the terms in E,


H = H (E) = t` ` ,

then H is an overall upper bound to the number of terms that can be con-
structed by a single assignment of parameters to the variables in all the sub-
terms of E.
We start with some preliminary estimates which are needed for the proofs
of both inequalities in (3B-2).
3B.3. Lemma. If M ∈ Conv(A, E) and C p (M ) = 0, then either M ∈ B or
M occurs in M .

Proof is by an easy induction on D(M ). a

3B.4. Lemma. Suppose M ∈ Conv(A, E).


(a) If (M1 , . . . , Mk ) ∈ T (M ), then Mk ∈ Conv(A, E).
(b) If (M1 , . . . , Mk ) ∈ T (M ) and the parameters in every Mi occur in M ,
then k ≤ H .
Proof. (a) is immediate by the construction of T (M ).
(b) Suppose x1 , . . . , xm is a list of the parameters in M1 ≡ M , so m ≤ `.
Each Mi is an (A, E)-term whose parameters are among x1 , . . . , xm , and
there are at most H distinct such terms; so if k > H , then Mi ≡ Mj for some
1 ≤ i < j ≤ k, and then M 1 ↑. a
It is clear from the construction of the computation tree that new parameters
enter the tree only by Case (T 4), in the term Ep (M 1 , . . . , M m ), and then only
if some M i does not occur in the parent node. Isolating and counting these
critical nodes is the main new tool we need.

28 The results in the remainder of this section are due to Anush Tserunyan, Part (3) of her

Ph.D. Thesis, Tserunyan [2013].


3B. Complexity inequalities 119

Splitting. A term M ∈ Conv(A, E) is splitting, if M ≡ p(M1 , . . . , Mn )


with a recursive variable p of E and
max1≤j≤n C p (Mj ) > 0, C p (Ei (M 1 , . . . , M n )) > 0.
By Problem x3A.5, these conditions are equivalent to their version with C s
rather than C p .
3B.5. Lemma. If (M1 , . . . , Mk ) ∈ T (M ) = T (M1 ) and no Mi is splitting,
then k ≤ 2H .
Proof. If the parameters in every Mi occur in M1 ≡ M , then we apply (b)
of Lemma 3B.4. Otherwise, let i be least such that Mi+1 has parameters that
do not occur in M1 . Now i ≤ H by Lemma 3B.4 again, and by the definition
of T (M ),
Mi ≡ p(N1 , . . . , Nn ), and Mi+1 ≡ Ep (N 1 , . . . , N n ).
Moreover, max{C p (Nj ) : 1 ≤ j ≤ n} > 0 since otherwise, each N j occurs in
Nj and hence N j ∈ Mi by Lemma 3B.3, contradicting the choice of i. But
Mi is not splitting, so C p (Mi+1 ) = C p (Ep (N 1 , . . . , N n )) = 0. Hence for all
j ≥ i + 1, C p (Mj ) = 0 and then by Lemma 3B.3 again, all parameters in Mj
occur in Mi+1 , and the length of (Mi+1 , . . . , Mk ) is ≤ H ; which means that
k = i + (k − i) ≤ H + H = 2H . a
Let
n o
v(M ) = (M1 , . . . , Mn ) ∈ T (M ) : ∀i, Mi is not splitting .

This is the empty set if M is splitting and a subtree of T (M ) if it is not. By


Lemma 3B.5 and the fact that degree(T (M )) ≤ (` + 1),
(3B-4) |v(M )| ≤ V, where V = (` + 1)2H .
3B.6. Lemma. If C p (M ) = 0, then Ls (M ) ≤ |v(M )|.
Proof. If C p (M ) = 0, then there are no splitting terms below M , and so
v(M ) = T (M ) and the inequality follows from (a) of Theorem 3A.3. a
For the proof of (a) in (3B-2), we need the sequential splitting complexity of
a (convergent) (A, E)-term:
(3B-5) F s (M ) = the number of splitting nodes in T (M ),
where (M0 , . . . , Mk ) ∈ T (M0 ) is splitting if Mk is splitting. This satisfies
some obvious recursive conditions which we will introduce and use in the
proof of the next lemma. It is clear, however, that
C p (M ) = 0 =⇒ F s (M ) = 0;
because if C p (M ) = 0, then C p (N ) = 0 for every N in T (M ) and so no such
term can be splitting.
120 3. Complexity theory for recursive programs

3B.7. Lemma. For every M ∈ Conv(A, E),


F s (M ) ≤ C s (M ) −
·
1.
Proof is by induction on D(M ), as usual, and it is trivial in all cases
except when M is splitting. If M ≡ p(M1 , . . . , Mm ) is splitting, let Mm+1 ≡
Ep (M 1 , . . . , M m ) and compute:
F s (M ) = F s (M1 ) + · · · + F s (Mm ) + F s (Mm+1 ) + 1
≤ (C s (M1 ) −
·
1) + · · · + (C s (Mm ) −
·
1) + (C s (Mm+1 ) −
·
1) + 1
≤ C s (M1 ) + · · · + C s (Mm ) − 1 + C s (Mm+1 ) − 1 + 1
= C s (M ) − 1.
The only thing we used here is that if M is splitting, then C s (Mi ) ≥ C p (Mi ) >
0 for at least one i, and similarly C s (Mm+1 ) > 0. a
3B.8. Lemma. If M ∈ Conv(A, E), then there is a (possibly empty) se-
quence of splitting terms N0 , . . . , Nk−1 in T (M ) such that
P P
(3B-6) F s (M ) = i<k F s (Ni ), Ls (M ) ≤ i<k Ls (Ni ) + |v(M )|.
Proof. If M is splitting, we take just one N0 ≡P M , and if there are no
splitting terms in T (M ) we set k = 0 and understand i<k Ls (Ni ) = 0, so that
T (M ) = v(M ) by definition and (3B-6) follows from (a) of Theorem 3A.3.
The lemma is proved in the general case by induction on D(M ), and the
argument is trivial in most of the cases. We consider only the case of a
non-splitting recursive call
M ≡ p(M1 , . . . , Mm ).
Set Mm+1 ≡ Ep (M 1 , . . . , M m ). The induction hypothesis gives us (a possibly
empty) sequence N0i , . . . , Nki i of splitting terms in each T (Mi ) such that, to
begin with,
Ls (M ) = Ls (M1 ) + · · · + Ls (Mm ) + Ls (Mm+1 ) + 1
P P
≤ j<k1 Ls (Nj1 ) + |v(M1 )| + · · · + j<km Ls (Njm ) + |v(Mm )|
P
+ j<km+1 Ls (Njm+1 ) + |v(Mm+1 )| + 1
P
≤ 1≤i≤m+1,j<ki Ls (Nji ) + |v(M1 )| + · · · + |v(Mm+1 )| + 1.
S
Now v(M ) = i=1,... ,m+1 v(Mi ) ∪ {M } because M is not splitting, and so
|v(M1 )| + · · · + |v(Mm+1 )| + 1 = |v(M )|.
P
Moreover, F (Mi ) = j<ki Nji by the induction hypothesis, and so
s

P
F s (M ) = F s (M1 ) + · · · + F s (Mm+1 ) = 1≤i≤m+1,j<ki F s (Nji )
as required, again because M is not splitting. a
3B. Complexity inequalities 121

3B.9. Theorem (Tserunyan [2013]). For every Φ-structure A, every Φ-program


E and every M ∈ Conv(A, E), if V is the constant defined in (3B-4), then:
(a) If M is splitting, then Ls (M ) ≤ ((` + 1)V + 1)F s (M ).
(b) If M is not splitting, then Ls (M ) ≤ ((` + 1)V + 1)F s (M ) + V .
It follows that Ls (M ) ≤ V + ((` + 1)V + 1)C s (M ), and so
(3B-7) lEs (~
x ) ≤ Ks + Ks cEs (~
x ) (denE (~
x )↓ )
with Ks = (` + 1)V + 1, a constant which depends only on the program E.
Proof. The main result (3B-7) follows from (a) and (b) by taking M ≡
E0 (~
x ) and appealing to Lemma 3B.7.
We prove (a) and (b) together by induction on D(M ), noting that (b) is a
weaker inequality than (a) and so we can use it whether M is splitting or not
when we invoke the induction hypothesis.
Case 1, M ≡ p(M1 , . . . , Mm ) is splitting. Set Mm+1 ≡ Ep (M 1 , . . . , M m )
as above and compute:
Ls (M ) = Ls (M1 ) + · · · + Ls (Mm+1 ) + 1
≤ ((` + 1)V + 1)[F s (M1 ) + · · · + F s (Mm+1 )] + (` + 1)V + 1
= ((` + 1)V + 1)[F s (M1 ) + · · · + F s (Mm+1 ) + 1]
= ((` + 1)V + 1)F s (M ),
because F s (M ) = F s (M1 ) + · · · + F s (Mm+1 ) + 1 for splitting M .
Case 2, M is not splitting. Choose splitting terms N0 , . . . , Nk−1 by Lemma
3B.8 so that
P P
F s (M ) = i<k F s (Ni ), Ls (M ) ≤ i<k Ls (Ni ) + |v(M )|
and compute using the result from Case 1:
P
Ls (M ) ≤ i<k Ls (Ni ) + |v(M )|
P
≤ ((` + 1)V + 1) i<k F s (Ni ) + V = ((` + 1)V + 1)F s (M ) + V
as required. a
We now turn to the proof of (b) in (3B-2), and for this we need a count
F p (M ) of the splitting terms which parallels the way in which C p (M ) counts
“the depth” of calls to the primitives. This is easiest to define by induction on
D(M ):
(F p 1) F p (tt) = F p (ff) = F p (x) = 0 (x ∈ A).
(F p 2) If M ≡ φ(M1 , . . . , Mm ), then
F p (M ) = max{F p (M1 ), . . . , F p (Mm )}.
122 3. Complexity theory for recursive programs

(F p 3) If M ≡ if M0 then M1 else M2 , then


(
p max{F p (M0 ), F p (M1 )}, if M 0 = tt,
F (M ) =
max{F p (M0 ), F p (M2 )}, if M 0 = ff.
(F p 4) If M ≡ p(M1 , . . . , Mm ) of E, let Mm+1 ≡ Ep (M 1 , . . . , M m ) and set
(
p max{F p (M1 ), . . . , F p (Mm )} + F p (Mm+1 ), if M is not splitting,
F (M ) =
max{F p (M1 ), . . . , F p (Mm )} + F p (Mm+1 ) + 1, if M is splitting.
Notice that if M is not splitting, then
F p (M ) = max{F p (M1 ), . . . , F p (Mm ), F p (Mm+1 )},
since one of max{F p (M1 ), . . . , F p (Mm )} and F p (Mm+1 ) is 0, so that the sum
of these two numbers is the same as their maximum.
With this splitting complexity, the proof of (b) in (3B-2) is only a minor
modification (a parallel version) of the proof of Theorem 3B.9.
3B.10. Lemma. For every M ∈ Conv(A, E),
F p (M ) ≤ C p (M ) −
·
1.
Proof is by induction on D(M ) and it is again trivial in all cases except
when M is splitting. In this case, if M ≡ p(M1 , . . . , Mm ) and we set Mm+1 ≡
Ep (M 1 , . . . , M m ), then
F p (M ) = max{F p (M1 ), . . . , F p (Mm )} + F p (Mm+1 ) + 1
≤ max{(C p (M1 ) −
·
1), . . . , (C p (Mm ) −
·
1)} + C p (Mm+1 ) −
·
1+1
≤ max{C p (M1 ), . . . , C p (Mm )} − 1 + C p (Mm+1 ) − 1 + 1
= C p (M ) −
·
1.
As in the proof of Lemma 3B.7, the only thing we use here is that if M is
splitting, then C p (Mi ) > 0 for at least one i, and similarly C p (Mm+1 ) > 0. a
3B.11. Lemma. If M ∈ Conv(A, E), then there is a term N in T (M ) which
is either a leaf or splitting and such that
(3B-8) Lp (M ) ≤ Lp (N ) + |v(M )|.
Proof is by induction on D(M ), as usual, and the result is trivial if M is a
leaf or splitting, taking N ≡ M .
If M ≡ φ(M1 , . . . , Mm ), then Lp (M ) = Lp (Mi ) + 1 for some i, and the
induction hypothesis gives us a leaf or splitting term N in T (Mi ) such that
Lp (Mi ) ≤ Lp (N ) + |v(Mi )|.
It follows that
Lp (M ) = Lp (Mi ) + 1 ≤ Lp (N ) + |v(Mi )| + 1 ≤ Lp (N ) + |v(M )|
3B. Complexity inequalities 123
S
since M is not splitting and so v(M ) = j=1,...M v(Mj ) ∪ {M }.
The argument is similar for conditional terms.
If M is a non-splitting recursive call
M ≡ p(M1 , . . . , Mm ),
set again Mm+1 ≡ Ep (M 1 , . . . , M m ) and choose i such that Lp (Mi ) =
max{Lp (M1 ), . . . , Lp (Mm )}. If C p (Mi ) = 0, then then Lp (Mi ) ≤ |v(Mi )|
by Lemma 3B.6, and if we choose N ∈ T (Mm+1 ) by the inductive hypothesis
so that Lp (Mm+1 ) ≤ Lp (N ) + |v(Mm+1 |, then
Lp (M ) = Lp (Mi ) + Lp (Mm+1 ) + 1
≤ |v(Mi )| + Lp (N ) + |v(Mm+1 )| + 1 = Lp (N ) + |v(M )|.
If C p (Mi ) > 0, then C p (Mm+1 ) = 0, since M is not splitting, and we can
repeat the argument with Mi and Mm+1 interchanged. a
3B.12. Theorem (Tserunyan [2013]). For every Φ-structure A, every Φ-program
E and every M ∈ Conv(A, E), if V is the constant defined in (3B-4), then:
(a) If M is splitting, then Lp (M ) ≤ (2V + 1)F p (M ).
(b) If M is not splitting, then Lp (M ) ≤ (2V + 1)F p (M ) + V .
It follows that Lp (M ) ≤ V + (2V + 1)C p (M ) and
(3B-9) lEp (~
x ) ≤ Kp + Kp cEp (~
x) (denE (~
x )↓ )
with Kp = 2V + 1, which depends only on the program E.
Proof is a minor adaptation of the proof of Theorem 3B.9, with (3B-9)
following from (a) and (b) by appealing to Lemma 3B.10. We prove (a) and
(b) together by induction on D(M ).
Case 1, M ≡ p(M1 , . . . , Mm ) is splitting. Set Mm+1 ≡ Ep (M 1 , . . . , M m )
as above and compute:
Lp (M ) = max Lp (Mi ) + Lp (Mm+1 ) + 1
1≤i≤m

≤ (2V + 1) max F p (Mi ) + V + (2V + 1)F p (Mm+1 ) + V + 1


1≤i≤m
 
= (2V + 1) max F p (Mi ) + F p (Mm+1 ) + 2V + 1
1≤i≤m
 
= (2V + 1) max F p (Mi ) + F p (Mm+1 ) + 1 = (2V + 1)F p (M ),
1≤i≤m

because F (M ) = max1≤i≤m F p (Mi ) + F p (Mm+1 ) + 1 for splitting M .


p

Case 2, M is not splitting. There is nothing to prove if M is a leaf. If it


is not, choose a leaf or splitting term N in T (M ) by Lemma 3B.11 such that
Lp (M ) ≤ Lp (N ) + |v(M )|. If N is a leaf, then Lp (N ) = 0 and so Lp (M ) ≤
|v(M )| ≤ V ≤ (2V + 1)F (M ) + V by (3B-4). If N is splitting, then the
124 3. Complexity theory for recursive programs

induction hypothesis applies to it since it is not M and hence D(N ) < D(M ),
and we have
Lp (M ) ≤ Lp (N ) + |v(M )| ≤ (2V + 1)F p (N ) + V
by (3B-4) again, as required. a
3B.13. Corollary. (1) For every Φ-program E, there is are constants K1 , K2
such that for every Φ-structure A, if (denA
E (~
x )↓ ), then
p p
(~
x) (~
x)
(3B-10) x ) ≤ K1c
c s (~ x ) ≤ K2c
and l s (~ .
(2) If an extended Φ-program E(x) ~ computes f : An * As in a structure
A and one of the complexities d (~ x ), c p (~
x ), c s (~
x ), l p (~
x ), l s (~
x ) is bounded on
the domain of convergence of f, then they are all bounded—and Theorem 3B.2
applies, so f(~ x ) is explicit if A is reasonably well behaved.
Proof. (1) Notice that these inequalities hold with any K > 0 if c p (~ x ) = 0,
because in that case l s (~ x ) = 0 by Problem x3A.5, and then c s (~ x ) = 0 because
c s (~ x ). So we fix a structure A and we compute, assuming denA
x ) ≤ l s (~ E (~
x )↓
p
and c (~ x ) > 0:
For the second inequality,
p
(~
x)
l s (~
x ) ≤ (` + 1)l (Theorem 3A.3)
Kp +Kp c p (~
x)
≤ (` + 1) (Theorem 3B.12)
 c p (~x )
≤ (` + 1)2Kp ;
and for the first, we start with c s (~
x ) ≤ l s (~
x ) and use the second one.
(2) If d (~
x ) is bounded, then all five complexities are bounded by Propo-
sition 3B.1; and if c p (~
x ) is bounded, then l s (~ x ) is bounded by (1) and then
d (~
x ) is bounded by Proposition 3B.1 again. This covers all possibilities. a
Full vs. tail recursion (II). In Section 2G we described several examples of
(pointed) structures in which not every recursive function is tail recursive. A
related—perhaps more interesting—question is about the relative complexities
of full and tail recursive definitions of the same function, and the best result I
know about this is the following:
3B.14. Theorem (Bhaskar [2017]). For every function g : N → N, there is
an increasing function ã : N → N with the following properties, where
n
A = (NPd , ã) = (N, 0, 1, Pd, eq0 , ã) and f(n, x) = ã 2 (x).
(1) Tailrec0 (A) = Rec0 (A).
(2) There is an extended recursive program E which computes f in A with
sequential logical complexity (time)
l s (A, E(n, x)) = O(2n ).
(3) The function f is tail recursive in A.
3B. Complexity inequalities 125

(4) For every extended tail recursive program F of A which computes f, there
are increasing sequences {ni }, {xi } such that for all i,
l s (A, F (ni , xi )) ≥ g(ni ).
Questions about intensional—especially complexity—differences between
programs which compute the same function from the same primitives were an
important part of schematology from the very beginning. My own interest in
these problems was stimulated by the remarkable theorem in Colson [1991],
whose call-by-value version (due to Fredholm [1995]) and with the natural
understanding of the terminology has the following, dramatic consequence:
3B.15. Colson’s Corollary. If a primitive recursive definition of the minimum
function on N is expressed faithfully in a programming language, then one of
the two computations of min(1, 1000) and min(1000, 1) will take at least 1000
steps.
The point is that the simple (tail) recursive program which computes
min(x, y) in Nu in time O(min(x, y)) cannot be matched in efficiency by a
primitive recursive one, even though min(x, y) is a primitive recursive func-
tion; and so, as a practical and (especially) a foundational matter, we need to
consider “recursive schemes” more general than primitive recursion, even if,
ultimately, we are only interested in primitive recursive functions.
Moschovakis [2003] extends the results of Colson and Fredholm to primi-
tive recursive programs from arbitrary Presburger primitives using gcd(x, y)
rather than min(x, y) and then asks if the same gap in efficiency occurs between
tail and full recursion in the Presburger structure (1E-10), cf. Open Prob-
lem x3B.2.29 The corresponding question about Nu in Open Problem x3B.3 is
(I think) the most important problem in this area.

Problems for Section 3B

x3B.1. Open problem. Can a complexity gap like that in Theorem 3B.14 be
realized by a relation R rather than a function f : N2 → N? For a precise
version: is there a total, pointed structure A and an n-ary relation R on A
such that the following hold:
(1) Tailrec0 (A) = Rec0 (A).
(2) R is tail recursive in A.
(3) Some extended program E decides R in A so that for every tail recursive
F which also decides R, there is a sequence {~
x }n of inputs such that
limn→∞ l s (A, F (~
xn )) = ∞ & (∀n)[l s (A, F (~ xn )))2 ].
xn )) ≥ (l s (A, E(~
29 van den Dries [2003] answered another question in this paper, and this started the collabo-

ration which led to van den Dries and Moschovakis [2004], [2009] and eventually to many of the
results in Chapters 5 – 8 of this book.
126 3. Complexity theory for recursive programs

x3B.2. Open problem. Can a complexity gap between tail and full recursion
like that in Theorem 3B.14 or Open Problem x3B.1 be realized in the Presburger
structure?
x3B.3. Open problem. Can a complexity gap between tail and full recursion
like that in Theorem 3B.14 or Open Problem x3B.2 be realized in unary
arithmetic Nu or in the List structure L∗ ?
Part II. Intrinsic complexity
CHAPTER 4

THE HOMOMORPHISM METHOD

Most of the known lower bound results in the literature are established for
specific computation models and the natural complexity measures associated
with them, and so any claim that they are absolute—or even that they hold
for a great variety of models—must be inferred from the proofs. The results
about recursive programs in van den Dries and Moschovakis [2004], [2009]
are somewhat more robust: they are proved directly from the abstract def-
initions of complexities in Chapter 3 using basically nothing more than the
homomorphism and finiteness properties in Problems x2E.2, x2E.4, without
reference to the recursive machine or any other implementations of recursive
programs. They imply lower bounds for most computation models, because
of the representation of iterators by tail recursive programs in Theorem 2C.1,
the complexity refinement of it in Problem x3A.3 (and the discussion after it)
and what comes next.
Our main aim in this chapter is to extract from the homomorphism and
finiteness properties of nondeterministic recursive programs in Problems x2E.2
and x2E.4 a general, algebraic method for deriving robust lower bounds for
algorithms from specified primitives assuming very little about what these
objects are.30
The key notions are those of a uniform process and certification in Sec-
tions 4B and 4D and the main result is the Homomorphism Test, Lemma 4E.3.
We will start, however, with a brief discussion of “algorithms from primitives”
which motivates our choice of notions without assuming any specific, rigorous
definition of “what algorithms are”.

4A. Axioms which capture the uniformity of algorithms

The basic intuition is that an n-ary algorithm of sort s from the primitives of
a structure A = (A, Υ) computes (in some one or in many different ways) an
30 Itis sometimes doubted whether it makes sense to talk of nondeterministic algorithms from
specified primitives, and with good reason. Here, it is useful to assume that it does: the precise
results will be stated about nondeterministic recursive programs and are not affected by surrounding
loose talk.
129
130 4. The homomorphism method

n-ary partial function


α = α A : An * As (with Aboole = {tt, ff}, Aind = A)
using the primitives in Υ as oracles. We understand this to mean that in the
course of a computation of α(~ x ), the algorithm may request from the oracle
for any φ A any particular value φ A (u1 , . . . , unφ ), where each ui is either given
by the input or has already been computed; and that if the oracles cooperate
and respond to all requests, then this computation of α(~ x ) is completed in a
finite number of steps.
The three axioms we formulate in this section capture part of this mini-
mal understanding of how algorithms from primitives operate in the style of
abstract model theory.
The crucial first axiom expresses the possibility that the oracles may choose
not to respond to a request for φ A (u1 , . . . , unφ ) unless
u1 , . . . , un ∈ U & φ U (u1 , . . . , un ) ∈ Us
for some fixed, arbitrary substructure U ⊆p A: the algorithm will still compute
a partial function, which simply diverges on those inputs x ~ for which no
computation of α(~ x ) by α can be executed “inside” U (as far as calls to the
oracles are involved).
A process of a structure A of arity n and sort s is an operation
α : U → αU (U ⊆p A, α U : U n * Us )
which assigns to each U ⊆p A a partial function α U : U n * Us . We call α U
the partial function defined by α on U, and we write
x ) = w ⇐⇒ x
U |= α(~ ~ ∈ U n & α U (~
x ) = w,
U |= α(~x )↓ ⇐⇒ (∃w)[U |= α(~x ) = w];
in particular, α defines (on A) the partial function α A : An * As .
I. Locality Axiom. Every algorithm of a structure A induces a process α of
A of the same arity and sort which defines the partial function computed by the
algorithm.31
For example, if E(~x) is a nondeterministic recursive program which com-
putes a partial function in A, then the process αE induced in A by E(~x) is
defined by setting for each U ⊆p A,
αU
E (~
x ) = w ⇐⇒df U |= E(~
x) = w
in the notation of (2E-4). It is important for this definition, of course, that if
E(~x) computes a partial function in A, then it computes a partial function in
every U ⊆p A, Problem x2E.1.
31 The Locality Axiom is much stronger than it might appear, because of the very liberal

definition of substructures on page 32: it is possible that w ∈ U, φ(w) ∈ U but still φ U (w) ↑.
4A. Uniformity of algorithms 131

The second axiom tries to capture the uniformity of algorithms, that they
follow “the same” procedure on any two inputs x ~ ∈ An . We would expect—
~, y
at the least—that an isomorphism ð : U  → V between two substructures
of A induces an isomorphism between the computations of α U and those
of α V ; we postulate something which is weaker, in that it does not refer
to “computations” but stronger in that it requires uniformity for arbitrary
homomorphisms, which need not be injective or surjective:
II. Homomorphism Axiom. If α is the process induced by an algorithm of A
and ð : U → V is a homomorphism of one substructure of A into another, then

(4A-1) x ) = w =⇒ V |= α(ð(~
U |= α(~ x )) = ð(w) x ∈ U n ).
(~

In particular, by applying this to the identity embedding idU : U  A,

U ⊆p A =⇒ α U v α A = α.

The idea here is that the oracle for each φ A may consistently respond to each
request for φ U (~
u ) by delivering φ V (ð(~
u )). This transforms any computation
U
of α (~x ) into one of α V (ð(~x )), which in the end delivers the value ð(w) =
ð(α U (~
x )).
This argument is convincing for the identity embedding idU : U  V
and works for nondeterministic recursive programs, Problem x2E.2. It is not
quite that simple in full generality, because algorithms may employ in their
computations complex data structures and rich primitives, e.g., stacks, queues,
trees, the introduction of higher type objects by ë-abstraction and subsequent
application of these objects to suitable arguments, etc. The claim is that any
homomorphism ð : U → V lifts naturally to these data structures, and so the
image of a convergent computation of α U (~ x ) is a convergent computation of
α V (ð(~
x )). Put another way: if some ð : U → V does not lift naturally to a
mapping of the relevant computations, then the algorithm is using essentially
some hidden primitives not included in A and so it is not an algorithm from
{φ A }φ∈Φ . It is clear, however, that the Homomorphism Axiom demands
something more of algorithms (and how they use oracles) than the Locality
Axiom, and we will discuss it again in Section 4G.
The Homomorphism Axiom is at the heart of this approach to the derivation
of lower bounds.
III. Finiteness Axiom. If α is the process induced by an algorithm of A, then

(4A-2) x ) = w =⇒ U |= α(~
A |= α(~ x) = w

for some finite U ⊆p A which is generated by x
~ ;
132 4. The homomorphism method

or, equivalently, using the certificates defined on page 34,



(4A-3) A |= α(~ x ) = w =⇒ U |= α(~ x) = w

for some certificate (U, x
~ ) of A .

This combines two ingredients of the basic intuition: first, that in the course
of a computation the algorithm may only request of the oracles values φ A (~ u)
for arguments in the input x ~ or that it has already computed from x ~ , and
second, that computations are finite. A suitable U is then determined by
putting in eqdiag(U) all the calls made by the algorithm in the computations of
α(~x ).
The Finiteness Axiom implies, in particular, that partial functions com-
puted by an A-algorithm take values in the substructure generated by the
input, since for any process of A which satisfies Axiom III,
α A (~
x ) = w =⇒ w ∈ G∞ (A, x
~ ) ∪ B.
By Problems x2E.2 and x2E.4, axioms I – III are satisfied by nondetermin-
istic recursive algorithms. They also hold for all concrete algorithms expressed
by computation models, e.g., Turing machines, finite register programs, Random
Access machines, decision trees . . . , and their nondeterministic versions; this
can be proved by applying Theorem 2C.1, Proposition 2C.3 and their natural
extensions to the nondeterministic versions of these models, cf. Problem x4B.2.
We can express succinctly the claim that all algorithms satisfy these axioms in
terms of the following basic notion:
A process α of A is uniform if it has the homomorphism and finiteness
properties (4A-1), (4A-2); a partial function f : An * As is uniform in A if it
is defined by a uniform process of A; and we set
n o
Unif(A) = f : An * As : f is uniform in A .

Uniformity Thesis. Every algorithm which computes a partial function f :


An * As from the primitives of a Φ-structure A induces a uniform process α of
A which defines f.
This is a weak Church-Turing-type assumption about algorithms which, of
course, cannot be established rigorously absent a precise definition of algo-
rithms. It limits somewhat the notion of “algorithm”, but not in any novel way
which yields new undecidability results. We will show, however, that it can be
used to derive absolute lower bounds for many, natural complexity measures
on decidable relations, very much like the Church-Turing Thesis is used to
establish absolute undecidability.
We record for easy reference the part of the Uniformity Thesis which is an
immediate consequence of Problems x2E.2 and x2E.4:
4B. Examples and counterexamples 133

4A.1. Proposition. Every nondeterministic Φ-program E(~x) induces on each


Φ-structure A the uniform process αE = αEA defined by
(4A-4) αU
E (~
x ) = w ⇐⇒df U |= E(~
x) = w (U ⊆p A).

4B. Examples and counterexamples

We will be using consistently for processes the notations


x ) = w ⇐⇒ x
U |= α(~ ~ ∈ U n & α U (~
x ) = w,
U |= α(~x )↓ ⇐⇒ (∃w)[U ` α(~x ) = w]
introduced above, and it is also useful to set
x ) = w ⇐⇒ (U, x
U |=c α(~ ~ ) is a certificate and U |= α(~
x ) = w,
U |=c α(~x )↓ ⇐⇒ (∃w)[U |=c α(~ x ) = w].
In this notation, the finiteness property takes the simple form
(4B-1) x ) = w =⇒ (∃U ⊆p A)[U |=c α(~
α(~ x ) = w].
If we read “|=c ” as computes, then this form of the axiom suggests that the
triples (U, x
~ , w) such that U |=c α(~x ) = w play the role of (very abstract)
computations for uniform processes—which, however, is very misleading.
We have shown in Proposition 4A.1 that Rec0nd (A) ⊆ Unif(A) and we
have argued that every algorithm from specified primitives induces a uniform
process. The converse, however, is far from true: nothing in the homo-
morphism and finiteness properties suggests that A-uniform functions are
“computable” from the primitives of A in any intuitive sense, and in general,
they are not:
4B.1. Proposition. If a Φ-structure A is generated by the empty tuple, then
every f : An * As is defined by some uniform process of A.
In particular, every f : Nn * Ns is uniform in A = (N, 0, ΦA ) if ΦA
includes either the successor function S or the primitives of binary arithmetic
em2 (x) = 2x and om2 (x) = 2x + 1.
Proof. Let Gm = Gm (A, ∅) be the set generated in ≤ m steps by the empty
set, so that G0 = ∅, G1 comprises the distinguished elements of A, etc. Let
d (~
x , w) = min{m : x1 , . . . , xn , w ∈ Gm ∪ B},
and define α by setting for each U ⊆p A,
α U (~
x ) = w ⇐⇒ f(~
x ) = w & Gd (~x ,w) ⊆p U.
The finiteness property is immediate taking U = Gd (~x ,w) , and α has the
homomorphism property because if Gm ⊆p U, then every homomorphism
ð : U → V fixes every u ∈ Gm . a
134 4. The homomorphism method

The axioms aim to capture the uniformity of algorithms—that they compute


all their values following “the same procedure”— but surely do not capture
their effectiveness.
An example of a non-uniform process. Consider the standard structure of
Peano arithmetic N = (N, 0, 1, +, ·, =), and let α be the “procedure” which
“computes” the function
(4B-2) f(x) = (x + 1)2 = x 2 + 2x + 1
using the first or the second of these two expressions for f(x) accordingly as
x is odd or even. We can view this as a unary process α as follows: first we
define for each x ∈ N a finite substructure Ux ⊆p N by giving its equational
diagram as on page 32,
eqdiag(Ux )

2
{(1, 1), (+, x, 1, x + 1), (·, x + 1, x + 1, (x + 1) )}, if x is odd,

= {(1, 1), (·, x, x, x 2 ), (+, x, x, 2x),


(+, 2x, 1, 2x + 1), (+, x 2 , 2x + 1, (x + 1)2 )}, if x is even;
and then we define α U : U * U for each U ⊆p N by setting
α U (x) = w ⇐⇒ w = (x + 1)2 & Ux ⊆p U.
This operation α is a process, it has the nice property
U ⊆p V =⇒ α U ⊆p α V (monotonicity),
it satisfies the Finiteness Axiom III directly from its definition, and it defines
the map x 7→ (x + 1)2 in N since, obviously, α N (x) = (x + 1)2 . It is not
uniform, however, because it fails to satisfy the Homomorphism Axiom II, as
follows: if

eqdiag(U) = eqdiag(U3 ) = {(1, 1), (+, 3, 1, 4), (·, 4, 4, 16)},


ð(3) = 4, ð(1) = 1, ð(4) = ð(3) + ð(1) = 5, ð(16) = ð(4) · ð(4) = 25,
and V = ð[U] so eqdiag(V) = {(1, 1), (+, 4, 1, 5), (·, 5, 5, 25)},
then ð : U → V is a homomorphism, ð(3) = 4, but α V (4) ↑, because U4 6⊆p V.
What spoils the homomorphism property is that α uses exactly one of two
different algorithms to compute α(x) depending on whether x is odd or even
without checking first which of the cases applies, and, in fact, we would not
consider it an algorithm for computing x 7→ (x + 1)2 in N for exactly this
reason.
One might argue that the remarks following (4B-2) describe intuitively a
nondeterministic algorithm which computes the function x 7→ (x + 1)2 , and
this is sort-of true: we can put down a nondeterministic recursive program of
N which chooses whether to compute (x + 1)2 or x 2 + 2x + 1 but makes this
4B. Examples and counterexamples 135

choice autonomously, independently of whether x is even or odd. The process â


induced by this program is
U
(4B-3) â (x) = w ⇐⇒ w = (x + 1)2

& either {(1, 1), (+, x, 1, x+1), (·, x+1, x+1, (x+1)2 )} ⊆ eqdiag(U)

or {(1, 1), (+, x, x, 2x), (+, 2x, 1, 2x+1), (+, x 2 , 2x+1, x+1)2 )} ⊆ eqdiag(U) ,
and it is uniform, cf. Problem x4B.3.

Problems for Section 4B

x4B.1. Problem. (1) Suppose F = (F, 0, 1, +, −, ·, ÷, =) is a field,


NF (a0 , a1 , a2 , x) ⇐⇒ a0 + a1 x + a2 x 2 = 0
is the nullity relation of degree 2 on F defined by (1C-12) and α is the process
(of sort boole and four arguments) defined by
α U (a0 , a1 , a2 , x) = w ⇐⇒ [w = tt ⇐⇒ a0 + a1 x + a2 x 2 = 0]
& {(·, a2 , x, a2 x), (+, a1 , a2 x, a1 + a2 x)
(·, x, a1 + a2 x, a1 x + a2 x 2 ),
(+, a0 , a1 x + a2 x 2 , a0 + a1 x + a2 x 2 ),
(0, 0), (=, a0 + a1 x + a2 x 2 , 0)} ⊆ eqdiag(U).
Prove that α is uniform and defines the nullity relation of degree 2.
(2) Define the uniform process on F (of sort boole and arity n + 2) which
is induced by the Horner Rule described on page 25.
x4B.2. Problem. For each (possibly nondeterministic) iterator i which com-
putes a partial function f : X * W , define the uniform process αi which is
induced by i in the associated structure Ai and prove that it defines f.
x4B.3. Problem. Prove that the process â defined by (4B-3) is uniform and
defines the map x 7→ (x + 1)2 in N.
x4B.4∗ . Problem. Prove that if f : Ak * As is uniform in A, then so is
every g ∈ Unif(A, f). Hint: If
(A,f)
u ) = α A (~
f(~ u ) and g(~
x) = â (~
x)
with uniform processes α of A and â of (A, f), then the process
(U,f  U k )
ã U (~
x) = â (~ ~ ∈ U n)
x ) (U ⊆p A, x
of A defines g. The proof that it is uniform requires some computation.
136 4. The homomorphism method

x4B.5. Problem. Prove that if f ∈ Unif(A) and ñ : A 


→ A is an automor-
phism of A, then f(ñ(~
x )) = ñ(f(~x )) (f(~
x )↓ ).
x4B.6. Problem. Give an example of a finite structure A and a unary relation
P ⊆ A which is respected by all automorphisms of A but is not uniform in A.
Hint: Use a structure (A, E) where E is an equivalence relation on A with
suitable properties.
x4B.7. Problem. Characterize the total functions f n : A → As which are
uniform in A = (A) (with no primitives), where A is infinite.
x4B.8∗ . Problem. Suppose A = (A, R1 , . . . , RK ) is a structure whose prim-
itives are total relations on A. What are the (total) relations P ⊆ An which
are uniform in A?

4C. Complexity measures on uniform processes

A substructure norm on a Φ-structure A is an operation ì which assigns to


every certificate (U, x
~ ) in A a number ì(U, x
~ ) and respects isomorphisms, i.e.,

(4C-1) U = Gm (U, x
~ ) ⊆p A & ð : U 
→ V ⊆p A
~ ) = ì(V, ð(~
=⇒ ì(U, x x )).
Typical examples are32
depth(U, x
~ ) = min{m : U = Gm (U, x
~ )},
values(U, x
~ ) = |{w ∈ U : (φ, u~ , w) ∈ eqdiag(U) for some φ, u~ }|,
calls(Φ0 )(U, x
~ ) = |eqdiag(U  Φ0 )| (Φ0 ⊆ Φ)
which we introduced on page 34 (with Φ0 = Φ for the last one). By Proposi-
tion 1D.1,
(4C-2) depth(U, x
~ ) ≤ values(U, x
~ ) ≤ calls(U, x
~ ).
If ì is a substructure norm on A and α is a uniform process of A, then the
ì-complexity measure of α is the partial function
(4C-3) ~ ) =df min{ì(U, x
ì(α, x ~ ) : U |=c α(~
x )↓ },
defined on the domain of convergence of α A . By using the norms above, we
get three natural complexity measures on uniform processes,
(4C-4) depth(α, x
~ ), values(α, x
~ ), calls(Φ0 )(α, x
~ ).

32 The depth and values norms can also be relativized to arbitrary Φ ⊆ Φ, but it is te-
0
dious, we have no interesting results about them, and we leave the relativization for depth for
Problem x4C.8∗ .
4C. Complexity measures on uniform processes 137

The first and last of these three correspond to familiar complexity measures
with roughly similar names for concrete algorithms but not exactly:33
– The “sequential” measure calls(Φ0 )(α, x ~ ) intuitively counts the least num-
ber of distinct calls to primitives in Φ0 required to define α(~ x ) by the process α,
where (φ, u~ , w) and (φ 0 , u~ 0 , w 0 ) are distinct if either φ 6≡ φ 0 or u~ 6= u~ 0 ;
– the “parallel” measure depth(α, x ~ ) counts the least number of distinct calls
to the primitives of A which must be executed in sequence to define α(~ x ); and
– the less familiar middle measure values(α, x ~ ) counts the least number of
points in A that α must compute from x ~ to define α(~ x ).
These measures are typically lower than their versions for concrete algorithms,
because they count distinct calls and points, while an algorithm may (stupidly
or by design, e.g., to simplify the code) make the same call many times, cf.
Problem x4C.6.
4C.1. Lemma. For every uniform process α of a Φ-structure A and all x ~, w
such that α(~ x ) = w,
(4C-5) depth(α(~
x ); A, x
~ ) ≤ depth(α, x
~ ) ≤ values(α, x
~ ) ≤ calls(α, x
~ ),
where, by our convention, depth(tt, A) = depth(ff, A) = 0.
Proof. The first inequality is trivial if w ∈ B and immediate for w ∈ A,
because if U |=c α(~
x ) = w, then w ∈ U and so
depth(w; A, x
~ ) ≤ depth(w; U, x
~ ) ≤ depth(U, x
~ ).
For the third claimed inequality, suppose α(~ x ) = w and choose a certifi-
cate (U, x~ ) of A with least |eqdiag(U)| such that U |=c α(~ x ) = w, so that
calls(α, x
~ ) = |eqdiag(U)|. Now values(U, x ~ ) ≤ |eqdiag(U)| by (1D-16) in
Proposition 1D.1, and since (U, x ~ ) is among the certificates in A considered
in the definition of values(α, x
~ ), we have
values(α, x
~ ) ≤ |eqdiag(U)| = calls(α, x
~ ).
The second inequality is proved by a similar argument. a
We record for easy reference the relation between these complexity measures
and the complexity measures for programs we studied in Chapter 3, in the two
cases that are most important for the applications:
4C.2. Proposition. Let αE be the uniform process induced on a Φ-structure
A by a nondeterministic extended program E(~x).
(1) If Φ0 ⊆ Φ and den(A, E(~ x ))↓ , then
(4C-6) ~ ) ≤ c s (Φ0 )(A, E(~
calls(Φ0 )(αE , x x )),
33 There are, of course, many other substructure norms which induce useful complexity mea-

sures, including those which come by combining the three basic ones: for example
~ ) · 6depth(U,~x )
~ ) = values(U, x
ì(U, x
comes up naturally in the proof of Theorem 8B.2!
138 4. The homomorphism method

where c s (Φ0 )(A, E(~


x )) is defined for nondeterministic programs by (2E-5) and
agrees with the definition (3A-12) when E is deterministic by Problem x3A.14.
(2) If E is deterministic and den(A, E(~ x ))↓ , then
(4C-7) ~ ) ≤ c p (A, E(~
depth(αE , x x )) and depth(αE , x
~ ) ≤ d (A, E(~
x )).

Proof is easy and we leave it for Problems x4C.4, x4C.6 and x4C.7. a

The time complexity on RAMs. The requirement that substructure norms


respect isomorphisms is weak but not trivial, cf. Problems x4C.11 and x4C.12∗ ;
the first of these implies that the (most natural) time complexity T (n) on
Random Access Machines in Cook and Reckhow [1973] is not induced by a
substructure norm. This can be handled in many ways, of course, but we will
not go into it here.

Problems for Section 4C

x4C.1. Problem. Prove that depth(U, x ~ ), values(U, x


~ ) and calls(Φ0 )(U, x
~)
are preserved by isomorphisms, as in (4C-1).
x4C.2. Problem. Prove that if U ⊆p V and (U, x
~ ), (V, x
~ ) are both certifi-
cates of a structure A, then
calls(U, x
~ ) ≤ calls(V, x
~ ), values(U, x
~ ) ≤ values(V, x
~ ).
The point of the next problem is that there is no similar, useful relation
between the depth complexity and the substructure relation:
x4C.3. Problem. (1) Give an example of two certificates (U, x
~ ) and (V, x
~)
of the same structure A, such that U ⊆p V and
depth(U, x) < depth(V, x).
(2) Give an example of two certificates (U, x
~ ) and (V, x
~ ) of the same struc-
ture A, such that U ⊆p V but
depth(U, x) > depth(V, x).
Hint: Use the vocabulary {φ, ø} with both φ, ø unary of sort ind.
x4C.4. Problem. Prove that if αE is the uniform process induced by a non-
deterministic recursive program in A by (4A-4) and c s (Φ0 )(A, E(~
x )) is the
calls-complexity for E in A as defined in (2E-5), then
(4C-8) ~ ) ≤ c s (Φ0 )(A, E(~
calls(Φ0 )(αE , x x )) (α(~
x )↓ ).
There is no useful bound of c s (Φ0 )(~
x ) in terms of calls(Φ0 )(αE , x
~ ) which
holds generally, even for deterministic programs:
4C. Complexity measures on uniform processes 139

x4C.5. Problem. Consider the following deterministic, extended program


E(x) in unary arithmetic Nu :
n
p(x) where p(x) = if x = 0 then 0 else q(p(Pd(x)), p(Pd(x))),
o
q(u, v) = u .
Prove that if αE is the uniform process induced by E(x) in Nu , then
calls(Pd)(αE , x) = x, c s (Pd)(Nu , E(x)) = 2x (x ≥ 1).
x4C.6. Problem. Let αE be the uniform process induced by a deterministic
~ ∈ An
extended program E(~x) in a Φ-structure A by (4A-4). Prove that for all x
such that denE (~
x )↓ ,
(4C-9) ~ ) ≤ c p (A, E(~
depth(αE , x x ))
as c p (A, E(~
x )) is defined by (3A-13), and give an example where the inequality
is strict.
Hint: Prove the following refinement of Problems x2E.2 and x2E.4 for de-
terministic programs: If M ∈ Conv(A, E), X ⊆ A contains all the parameters
which occur in M , m = C p (A, M ) and U = Gm (A, X ), then
U = Gm (U, X ) and U |= M = w.
This implies (4C-9) directly from the definitions.
x4C.7. Problem. Let αE be the uniform process induced by a deterministic
~ ∈ An
extended program E(~x) in a Φ-structure A by (4A-4). Prove that for all x
such that denE (~
x )↓ ,
(4C-10) depth(αE , x
~ ) ≤ d (A, E(~
x ))
as d (A, E(~
x )) is defined by (3A-3). Hint: Appeal to Proposition 3A.2.
x4C.8∗ . Problem (depth(Φ0 )(U, x
~ )). For a Φ-structure A, any X ⊆ A and
any Φ0 ⊆ Φ, define depth(Φ0 )(Gm (A, X )) by the following recursion on m
(skipping A):
depth(Φ0 )(G0 (X )) = 0,


 depth(Φ0 )(Gm (X )) + 1,

 if for some φ ∈ Φ , u~ and w,
0
depth(Φ0 )(Gm+1 (X ) =

 (φ, ~ , w) ∈ eqdiag(Gm+1 (X )) \ eqdiag(Gm (X )),
u


depth(Φ0 )(Gm (X )), otherwise.
(1) Prove that depth(Φ0 )(U, x
~ ) is invariant under isomorphisms.
(2) Prove that if αE is the uniform process induced by a deterministic
program E(~x), then
~ ) ≤ cΦp 0 (A, E, x
depth(Φ0 )(αE , x ~) (denE (~
x )↓ ).
140 4. The homomorphism method

Hint: Formulate and prove a Φ0 -version of the hint in Problem x4C.6.


x4C.9. Problem. Prove that if the successor S is a primitive of a structure
A = (N, 0, Υ), then every f : Nn * Ns is defined by some uniform process α
of A such that
calls(α, x
~ ) ≤ max{~ x )} (f(~
x , f(~ x )↓ )
where max{~
x , w} = max{~
x } if w ∈ B. Hint: Look up the proof of Lemma
4B.1.
x4C.10. Problem. Prove that if 0, 1 and the binary primitives em2 (x) = 2x,
om2 (x) = 2x + 1 are among the primitives of A = (N, Υ), then every f :
Nn * Ns is defined by some uniform process α of A with
calls(α, x
~ ) ≤ 2 max{blog(x1 )c, . . . , blog(xn )c, blog(f(~
x ))c} (f(~
x )↓ ).
x4C.11. Problem. Fix a Φ-structure A.
(1) Prove that the function
ì1 (U, x
~ ) = the cardinality of the set {x1 , . . . , xn }
is a substructure norm on A.
(2) Prove that if weight : Φ → N assigns a “weight” to every function
symbol in Φ, then
P
ì2 (U, x
~ ) = {weight(φ) : (φ, u~ , w) ∈ eqdiag(U)};
is a substructure norm on A.
(3) Prove that if f : A → N and
~ ) = f(x1 )
í(U, x (U ⊆p A),
then í is not a substructure norm on A unless f is constant.
x4C.12∗ . Problem. Prove that for every Φ-structure A and every substruc-
ture norm ì on A, there is some Kn,m ∈ N, such that for every certificate (U, x
~)
~ ∈ An ,
of A with x
calls(U, x
~ ) ≤ m =⇒ ì(U, x
~ ) ≤ Kn,m .
Briefly, without specifying the constant involved,
~ ) = O(calls(U, x
ì(U, x ~ )).
Hint: For any two certificates (U, x
~ ) and (V, y
~ ) of A with x ~ ∈ An , set
~, y

(U, x
~ ) ≈ (V, y
~ ) ⇐⇒ |eqdiag(U)| = |eqdiag(V)|
& (∃ an isomorphism ð : U  x) = y
→ V)[ð(~ ~ ],
and prove that ≈ is an equivalence relation with finitely many equivalence
classes.
A A
4D. Forcing and certification c 141

U f(x) ð
ð(f(x))
f f
ð
x ð(x)

Figure 4. ð : U → A respects f : A * A at x.

A A
4D. Forcing and certification c

Suppose A is a Φ-structure, f : An * As (with s ∈ {ind, boole}), U ⊆p A,


and f(~
x )↓ . A homomorphism ð : U → A respects f at x ~ if

(4D-1) ~ ∈ U n & f(~


x x ) ∈ Us & ð(f(~
x )) = f(ð(~
x )).

The definition takes a particularly simple form when R : An → B is a total


relation, Problem x4D.1: ð : U → A respects R at x
~ if
 
(4D-2) ~ ∈ U n & R(~
x x ) ⇐⇒ R(ð(~x )) .

Next come forcing and certification, the two basic notions of this chapter:
A
U x ) = w ⇐⇒ f(~
f(~ x) = w
& every homomorphism ð : U → A respects f at x
~,
A A
U c x ) = w ⇐⇒ U is finite, generated by x
f(~ ~ &U x ) = w,
f(~
A A
U c x )↓ ⇐⇒ (∃w)[U
f(~ c x ) = w].
f(~

A
If U c x )↓ , we call (U, x
f(~ ~ ) a certificate for f at x
~ in A,
A
U certifies f at x
~ in A ⇐⇒ U c x )↓ .
f(~
A A
We will sometimes write and c for and c when the relevant Φ-
structure is clear from the context and also

U x ) for U
R(~ x ) = tt,
R(~ U x ) for U
¬R(~ x ) = ff
R(~

when R : U n * B is a partial relation.


142 4. The homomorphism method

Example: the Euclidean algorithm. To illustrate the notions, consider once


more the Euclidean algorithm for coprimeness, specified by the extended
recursive program
ε(x, y) ≡ (x 6= 0 & y 6= 0 & gcd(x, y) = 1) where
{gcd(x, y) = if (y = 0) then x else gcd(y, rem(x, y))}
on the structure Nε . Given x, y ≥ 1, the Euclidean computes gcd(x, y) by
successive divisions and 0-tests (calls to the rem- and eq0 -oracles)
rem(x, y) = r1 , r1 6= 0, rem(y, r1 ) = r2 , r2 6= 0,
. . . , rn+1 6= 0, rem(rn , rn+1 ) = rn+2 , rn+2 = 0
until the remainder 0 is obtained, at which time it is known that gcd(x, y) =
rn+1 ; and to decide if x⊥⊥ y, it must then do one last check to test whether
rn+1 = 1. Suppose x⊥ ⊥ y and collect all these calls into a substructure U0 ,
writing u 6= 0, u = 1 for eq0 (u) = ff, eq1 (u) = tt as above:
eqdiag(U0 ) = {rem(x, y) = r1 , r1 6= 0, rem(y, r1 ) = r2 , r2 6= 0,
. . . , rn+1 6= 0, rem(rn , rn+1 ) = rn+2 , rn+2 = 0, rn+1 = 1};
it is now easy to check that

U0 c ⊥ y,
x⊥
because if ð : U0 → Nε is a homomorphism, then
(4D-3) rem(ð(x), ð(y)) = ð(r1 ), ð(r1 ) 6= 0,
rem(ð(y), ð(r1 )) = ð(r2 ), ð(r2 ) 6= 0,
. . . , ð(rn+1 ) 6= 0, rem(ð(rn ), ð(rn+1 )) = ð(rn+2 ), ð(rn+2 ) = 0,
ð(rn+1 ) = 1,
and this in turn guarantees that ð(x)⊥
⊥ ð(y), so that ð respects the coprimeness
relation at x, y. This is how certificates for functions and relations can be
constructed from computations, and it is the basic method of applying uniform
process theory to the derivation of lower bounds for concrete algorithms, cf.
Problem 2E.1.
On the other hand, U0 is not a minimal substructure of Nε which certifies
that x⊥⊥ y. Let
(4D-4) U1 = {rem(x, y) = r1 , rem(y, r1 ) = r2 ,
. . . , rem(rn , rn+1 ) = rn+2 , rn+1 = 1},
be the substructure of U0 with all the 0-tests deleted. We claim that U1
is also a certificate for x⊥
⊥ y, and to see this suppose that ð : U1 → Nε
is a homomorphism. To verify that ð respects x⊥ ⊥ y, check first that for
A A
4D. Forcing and certification c 143
i = 1, . . . , n + 1, ð(ri ) 6= 0; otherwise rem(ð(ri−1 ), ð(ri )) would not be
defined (with r0 = y), since rem requires its second argument to be non-zero,
and so ð would not be totally defined in U1 . So the homomorphism property
for ð guarantees that

rem(ð(x), ð(y)) = ð(r1 ), ð(r1 ) 6= 0, rem(ð(y), ð(r1 )) = ð(r2 ), ð(r2 ) 6= 0,


. . . , ð(rn+1 ) 6= 0, rem(ð(rn ), ð(rn+1 )) = ð(rn+2 ), ð(rn+1 ) = 1.

The last two of these equations mean that for some q,

ð(rn ) = q · 1 + ð(rn+2 ), 0 ≤ ð(rn+2 ) < 1

so that we must have ð(rn+2 ) = 0; and then all the equations in (4D-3) hold
and we have the required ð(x)⊥ ⊥ ð(y).
This is typical: although computations by concrete algorithms define cer-
tificates, they generally do not give minimal certificates.
The connection with Pratt certificates for primality. To the best of my knowl-
edge, certificates were first introduced in Pratt [1975] in his proof that primality
is NP and they have been used extensively since then, primarily to design non-
deterministic algorithms for primality. We are using the term in a related but
different way.
With our terminology, a Pratt certificate for primality in a structure A =
(N, Υ) with universe N is a nondeterministic program E(p) such that

(4D-5) den(A, E(p))↓ ⇐⇒ Prime(p) (p ∈ N);

and then each convergent computation c of E(p) defines by Proposition 2E.1 a


certificate (Uc , p) in our sense. However: (Uc , p) depends only on c and p, and
it is possible for two different Pratt certificates E1 (p) and E2 (p) to determine
the same certificate (Uc , p); and there is no requirement that (4D-5) should
hold for any p0 other than the one used to define (Uc , p), unless p0 = ð(p) for
a homomorphism ð : U → A.
What may be the most substantial difference between these two notions is
how they are used: a Pratt certificate is as good as the Turing complexity of
verifying (4D-5), which should be polynomial in log p and as small as possible,
while the specific choice of the primitives Υ does not matter; our certificates
depend essentially on the choice of primitives in Υ and they should be as
large as possible under various complexity measures, since they will be used to
derive intrinsic (absolute) lower bounds for primality (in this case).
144 4. The homomorphism method

Problems for Section 4D

x4D.1. Problem. Prove that if R : An → B is a total relation on A, U ⊆p A


and ð : U → A is a homomorphism, then
 
ð respects R at x
~ ⇐⇒ x ~ ∈ U n & R(~ x ) ⇐⇒ R(ð(~ x )) .

x4D.2. Problem. Prove that if P(~


x ) and Q(~
x ) are n-ary partial relations on
A, then
A A
U c x ) & Q(~
P(~ x ) ⇐⇒ U c x) & U
P(~ c x ),
Q(~
and similarly for ¬P(~
x ), ¬Q(~
x ).
x4D.3. Problem. Prove that if U ⊆p V ⊆p A, then
A A
U x ) = w =⇒ V
f(~ x ) = w.
f(~
x4D.4. Problem. Prove that for any coprime x ≥ y ≥ 1, the structure
U1 defined in (4D-4) is a minimal certificate of x⊥
⊥ y in Nε , i.e., no proper
substructure of U1 certifies x⊥
⊥ y. Hint: For example, if we delete the last
equation rn+1 = 1 from eqdiag(U1 ), then the function ð(u) = 2u defines a
homomorphism on the resulting substructure such that gcd(ð(x), ð(y)) = 2.

4E. Intrinsic complexities of functions and relations

If ì is a substructure norm on a Φ-structure A and f : An * As , set


A
(4E-1) ~ ) = min{ì(U, x
ì(A, f, x ~) : U c x )↓ }
f(~ (f(~
x )↓ ),

where, as usual, min(∅) = ∞. This is the intrinsic ì-complexity (of f, in


A, at x~ ). It records the ì-smallest size of a substructure of A that is needed
to determine the value f(~ x ), and its significance derives from the following,
trivial
4E.1. Proposition. If a uniform process α defines f : An * As in a Φ-
structure A, then for any substructure norm ì on A,
(4E-2) ~ ) ≤ ì(α, x
ì(A, f, x ~) (f(~
x )↓ ).

Proof is immediate, because


A
(4E-3) x ) = w =⇒ U
U |=c α(~ c x ) = w,
f(~
directly from Axioms II and III for uniform processes and the definition of
certification. a
4E. Intrinsic complexities of functions and relations 145

4E.2. Corollary. If f : An * As is computed by a nondeterministic extended


program E(~x) in a Φ-structure A, then

~ ) ≤ c p (A, E(~
depth(A, f, x x )) (f(~
x )↓ ),

and for every Φ0 ⊆ Φ,

~ ) ≤ c s (Φ0 )(A, E(~


calls(Φ0 )(A, f, x x )) (f(~
x )↓ ).

Proof is immediate from Problems x4C.6, x4C.4 and the Proposition. a

The key point here is that ì(A, f, x


~ ) is defined directly from A, ì and f,
but it provides a lower bound for the ì-complexity of any (deterministic or
nondeterministic) algorithm which might compute f in A; provably for algo-
rithms specified by nondeterministic recursive programs by Proposition 4A.1
and Problem 4A.1 (and hence for all the computation models we discussed in
Section 2F), and plausibly for all algorithms from the primitives of A by the
Uniformity Thesis on page 132. The situation is most interesting, of course,
when ì(A, f, x~ ) matches the corresponding complexity of some known algo-
rithm which computes f in A, at least up to a multiplicative constant.
Moreover, the definitions yield a purely algebraic method for deriving these
intrinsic lower bounds:
4E.3. Lemma (Homomorphism Test). If ì is a substructure norm on a Φ-
structure A, f : An * As , f(~
x )↓ , and

(4E-4) for every certificate (U, x


~ ) of A,
 
x ) ∈ Us & ì(U, x
f(~ ~ ) < m =⇒ (∃ð : U → A)[f(ð(~
x )) 6= ð(f(~
x ))],

~ ) ≥ m.
then ì(A, f, x
Other than the definitions, this is the main—in fact the only—tool we will
use in the sequel to derive intrinsic lower bounds from specified primitives.
The results will be (primarily) about the most important intrinsic complexity
measures, when ì(U, x ~ ) is depth(U, x
~ ), values(U) or calls(Φ0 )(U, x
~ ). We will
use two notations for them:
depthf (A, x~ ) = depth(A, f, x~) = min{depth(U, x~) : U A c f(~ x )↓ },
valuesf (A, x~ ) = values(A, f, x~) = min{values(U) : U A c f(~x )↓ },
callsf (Φ0 )(A, x ~ ) = min{calls(U  Φ0 ) : U A
~ ) = calls(Φ0 )(A, f, x c f(~ x )↓ }.

As usually, callsf (A, x


~ ) = callsf (Φ)(A, x
~ ), so that by(1D-16), as in the
proof of Lemma 4C.1,

(4E-5) depthf (A, x


~ ) ≤ valuesf (A, x
~ ) ≤ callsf (A, x
~ ).
146 4. The homomorphism method

The output complexities. Note that for any f : An * As and x


~ ∈ An ,
(4E-6) depth(f(~
x ); A, x
~ ) = min{m : f(~
x ) ∈ Gm (A, x
~ )} ≤ depthf (A, x
~ ),

because if U ⊆p A is chosen so that depth(A, f, x


~ ) = depth(U, x
~ ), then
A
U c f(~ x )↓ , so f(~
x ) ∈ U and
depth(f(~
x ); A, x
~ ) ≤ depth(f(~
x ); U, x
~ ) ≤ depth(U, x
~ ) = depthf (A, x
~ ).
Similarly for the number of calls to the primitives needed to construct f(~
x ),

(4E-7) calls(w; A, x
~ ) = min{|eqdiag(U, x
~ )| : U ⊆p A, w ∈ U }
≤ calls(A, f, x
~ ),
cf. Problem x4E.11.
These output complexities provide lower bounds for any reasonable notion
of algorithmic complexity measure which counts (among other things) the
applications of primitives that must be executed (in sequence or altogether),
simply because an algorithm must (at least) construct from the input the value
f(~ x ). This is well understood and used extensively to derive lower bounds
in arithmetic and algebra which are clearly absolute.34 We will consider
some results of this type in Section 5A and also in Chapter 9. The more
sophisticated complexity measure depthf (A, x ~ ) is especially useful when f
takes simple values, e.g., when f is a relation: in this case calls(f(~
x ); A, x
~) = 0
and (4E-6), (4E-7) do not give any information.
Explicit (term) reduction and equivalence. Intrinsic complexities are very
fine measures of information. Sometimes, especially in algebra, we want to
know the exact value ì(A, f, x ~ ), which might be the degree of a polynomial
or the dimension of a space. In other cases, especially in arithmetic, we
may try to computes ì(A, f, x ~ ) up to a factor (a multiplicative constant),
either because the exact value is too difficult to compute or because we only
care for asymptotic estimates of computational complexity. The next, simple
proposition gives a trivial way to relate the standard complexity measures of
two structures when the primitives of one are explicitly definable in the other.
A structure A = (A, Υ) is explicitly reducible to a structure A0 = (A, Φ)
on the same universe if Υ ⊆ Expl(A0 ), and explicitly equivalent to A0 if in
addition Φ ⊆ Expl(A).

34 The
most interesting result of thistype that I know is Theorem 4.1 in van den Dries and

Moschovakis [2009], an O log log a -lower bound on depth(gcd(a + 1, b), A, a, b) with A =
(N, 0, 1, +, −, ·, ÷) and (a, b) a Pell pair, cf. page 177. This is due to van den Dries, and it is
the largest lower bound known for the gcd on infinitely many inputs from primitives that include
multiplication. It is not known whether it holds for coprimeness, for which the best known result
is a log log log-lower bound for algebraic decision trees in Mansour, Schieber, and Tiwari [1991a].
4E. Intrinsic complexities of functions and relations 147

4E.4. Proposition (Explicit reduction). If A = (A, Υ) is explicitly reducible


to A0 = (A, Φ), then there is constant K ∈ N such that for every f : An * As
and each of the standard complexities ì = depth, values, calls,
ì(A0 , f, x
~ ) ≤ K ì(A, f, x
~) (f(~
x )↓ ).
It follows that if A and A0 are explicitly equivalent, then for suitable rational
constants K, r > 0, every f : An * As and ì = depth, values, calls,
~ ) ≤ ì(A0 , f, x
r ì(A, f, x ~ ) ≤ K ì(A, f, x
~) (f(~
x )↓ ).

Proof is fairly simple and we will leave it for Problem x4E.10∗ . a

Problems for Section 4E

The first problem says, in effect, that for any substructure norm, ì(A, f, x
~)
is determined by the value f(~ x ) and the isomorphism type of the substructure
G∞ (A, x~ ) of A generated by x~.
x4E.1∗ . Problem. Suppose that A is a Φ-structure, x ~ ∈ An , and there is
~, y
an isomorphism
ð : G∞ (A, x
~) 
→ G∞ (A, y
~)
such that ð(~
x) = y
~ . Prove that for every substructure norm ì on A and every
f : An * As ,
~ ) = ì(A, f, y
ì(A, f, x ~ ).
Hint: Use the fact that substructure norms are respected by isomorphisms
and that the hypothesis is symmetric in x
~ and y
~.
x4E.2. Problem. Prove that every Φ-structure A and f : An * As ,
depth(A, f, x
~ ) ≤ calls(A, f, x
~ ) (f(~
x )↓ ).
x4E.3. Problem (Obstruction to calls(A, R, x ~ ) = 0). Suppose R(~x ) is a (to-
tal) n-ary relation on the universe of a Φ-structure A and for some tuple x~ ∈ An
of distinct elements of A, calls(A, R, x~ ) = 0. Prove that R is constant, i.e.,
either (∀~
y )R(~
y ) or (∀~
y )¬R(~
y ).
This allows us in most cases to see immediately that callsf (A, x ~ ) > 0:
for example, calls(A, Prime, x) > 0 for every A with A = N and for every
x, simply because there are primes and composites. There is no equally
simple, general test for depth(A, f, x
~ ) > 0, but it is worth putting down some
sufficient conditions which are easy to verify in special cases—we will need
them in Chapters 5 – 8 when we want to divide by depth(A, f, x ~ ).
148 4. The homomorphism method

x4E.4. Problem (Obstruction to depth(A, R, x ~ ) = 0). Suppose R(~ x ) is a to-


tal n-ary relation on the universe of a Φ-structure A, x ~ = (x1 , . . . , xn ) and
~ = (y1 , . . . , yn ∈ An are tuples of distinct elements of A, and the following
y
conditions hold:
(1) The map xi 7→ yi respects all the primitives of A of sort boole.
(2) No xi is the value of some primitive of A on members of {x1 , . . . , xn }.
(3) R(~x ) is true, but ¬R(~ y ).
Prove that depth(A, R, x ~ ) > 0. Infer that
depth(A, Prime, p) > 0 and depth(A, ⊥
⊥ , x, y) > 0 (Prime(p), x⊥
⊥ y),
when A is one of Nu , Nb , N or their expansions by = and/or <.
x4E.5. Problem. Prove that for the coprimeness relation,
depth(Nε , ⊥
⊥ , x, y) ≤ 2 log(min(x, y)) + 1 (x, y ≥ 1).
x4E.6∗ . Problem (Upper bound for poly 0-testing). Let
NF (a0 , . . . , an , x) ⇐⇒ a0 + a1 x + · · · + an x n = 0,
be the nullity relation (of degree n ≥ 1) on a field F = (F, 0, 1, +, −, ·, ÷, =)
and prove the following inequalities:
calls(·, ÷)(F, NF , a~ , x) ≤ n,
calls(·, ÷, =)(F, NF , a~ , x) ≤ n + 1,
calls(+, −)(F, NF , a~ , x) ≤ n − 1,
calls(+, −, =)(F, NF , a~ , x) ≤ n + 1.
Hint: Use Horner’s Rule and Problem x1C.17∗ (for the last two claims).
Recall from page 9 that for f : An * A
Graphf (~ x ) = w.
x , w) ⇐⇒ f(~
x4E.7∗ . Problem. Suppose that A is a Φ-structure and f : An * A.
(1) Prove that for any U ⊆p A and all x
~ , w,
U x ) = w ⇐⇒ U
f(~ Graphf (~
x , w) = tt.
(2) Prove that for any U ⊆p A,
U c x ) = w =⇒ U
f(~ c Graphf (~
x , w) = tt,
but the converse is not always true.
(3) Infer that for any substructure norm ì,
ì(A, Graphf , x x )) ≤ ì(A, f, x
~ , f(~ ~ ).
(4) Give an example where
depth(A, Graphf , x, w) < depth(A, f, x) < ∞.
4F. The best uniform process 149

Hint: For the counterexamples in (2) use a structure where Graphf is among
the primitives; and for (4), you need a specific such example which keeps
~ ) finite.
ì(A, f, x
x4E.8. Problem. Prove that for the coprimeness relation, some K and all
t ≥ 3,
depth(Nε , ⊥
⊥ , Ft+1 , Ft ) ≤ K (log t) = O(log log Ft ),
where F0 , F1 , . . . is the Fibonacci sequence. Hint: Use Pratt’s algorithm.
x4E.9∗ . Problem. Prove that if f : An * As is explicit in a Φ-structure A
and ì is any substructure norm on A, then there is a number K such that
~) ≤ K
ì(A, f, x (f(~
x )↓ ).
Hint: Use Proposition x1E.14 to prove that for explicit f, there is an m
such that
x ) = w =⇒ (∃U)[U |=c f(~
f(~ x ) = w & |eqdiag(U)| ≤ m],
and then appeal to Problem x4C.12∗ .
x4E.10∗ . Problem. Prove Proposition 4E.4. Hint: Start by appealing to
Problem x4E.9∗ to set
Kφ = max{ì(A0 , φ A , x
~ ) : φ ∈ Φ}.
x4E.11. Problem. Prove (4E-7).
x4E.12. Open problem (vague). For a (total) structure A and a function
f : An → As , do any of the complexity functions ì(A, f, x
~ ) encode interesting
model theoretic properties of A? Perhaps when ì is one of depth, values or
calls and f(~
x ) codes an invariant of some substructure of A determined by
~ —a degree, dimension, etc.
x

4F. The best uniform process

Is there a “best algorithm” which computes a given f : An * As from


specified primitives on A? The question is vague, of course—and the answer
is almost certainly negative in the general case, no matter how you make it
precise. The corresponding question about uniform processes has a positive
(and very simple) answer.
For given f : An * As , set
U A
(4F-1) â f,A (~
x ) = w ⇐⇒ U x) = w
f(~ (U ⊆p A).
4F.1. Theorem. The following are equivalent for any Φ-structure A and any
partial function f : An * As , s ∈ {ind, boole}.
(i) Some uniform process α of A defines f.
150 4. The homomorphism method
 
(ii) (∀~ x )↓ =⇒ (∃U ⊆p A)[U A
x ) f(~ c f(~
x )↓ ] .
(iii) â f,A is a uniform process of A which defines f.
Moreover, if these conditions hold, then
~ ) = ì(A, f, x
ì(â f,A , x ~ ) ≤ ì(α, x
~) (f(~
x )↓ ),
for any substructure norm ì and uniform process α of A which defines f.
Proof. (iii) =⇒ (i) is immediate and (i) =⇒ (ii) follows from (4E-3).
U
(ii) =⇒ (iii). The operation (U 7→ â f,A ) satisfies the Finiteness Axiom III
by (ii). To verify the Homomorphism Axiom II, suppose
A
U x) = w & ð : U → V
f(~
n
so that ð(~
x ) ∈ V , ð(w) ∈ Vs and (since ð : U → V is a homomorphism),
f(ð(~x )) = ð(w). Let ñ : V → A be a homomorphism. The composition
ñ ◦ ð : U  A is also a homomorphism, and so by (ii) it respects f at x
~ , i.e.,
x )) = ñ(ð(f(~
f(ñ(ð(~ x )) = ñ(ð(w)) = ñ(f(ð(~
x ))).
So ñ respects f at ð(~
x ), and since it is arbitrary, we have the required
A
V x )) = ð(w).
f(ð(~
The second claim follows from the definition of â f,A and (4E-3). a
Optimality and weak optimality. The best uniform process â f,A is clearly
optimal (for f, from the primitives of A) by any natural measure of efficiency,
but it is not reasonable to expect that it is induced by a nondeterministic
program for any specific, interesting f—much less a deterministic one. We
formulate here three, natural notions of (partial, worst-case) optimality which
will help understand and discuss the intrinsic lower bounds we will derive in
the sequel.
Suppose A is an infinite Φ-structure, f : An * As and ì is a substructure
norm on A.
(1) A uniform process α on A is ì-optimal for f on D ⊆ An , if
 
(4F-2) ~ ∈ D =⇒ f(~
x x ) = α(~
x )↓ & ì(α, x ~ ) = ì(A, f, x
~) .
The optimality results about Horner’s rule in Chapter 9 are of this sort,
typically with D the set of generic (algebraically independent) inputs.
The next weaker notion allows a multiplicative factor:
(2) A uniform process α on A is weakly ì-optimal for f on D ⊆ An , if for
some K > 0,
 
(4F-3) x~ ∈ D =⇒ f(~ x ) = α(~x )↓ & ì(α, x ~ ) ≤ Kì(A, f, x
~) .
Almost all the results for arithmetical problems in Chapters 5 – 8 establish
the weak optimality of simple programs for various norms—mostly depth.
4F. The best uniform process 151

For some of these results, the set D is not of any particular interest and we
abstract it away:
(3) A uniform process α on A is weakly ì-optimal for f if it is weakly-ì-
optimal on some D ⊆ An such that
(4F-4) sup{ì(A, f, x
~) : x
~ ∈ D} = ∞.
One precise version of the Main Conjecture on page 2 claims something
stronger than the weak calls(rem)-optimality of (the process) ε (induced by)
the Euclidean in Nε : it asks for a set D ⊆ N2 and a K > 0 such that

(4F-5) (x, y) ∈ D =⇒
 
calls(rem)(ε, x, y) ≤ L(x, y) ≤ K calls(rem)(A, gcd, x, y)

where L(x, y) = 2 log(max(x, y)); which then satisfies (4F-3) and (4F-4)
by (∗) on page 2. Most of the results in Chapters 5 – 8 establish the weak depth-
optimality of some recursive algorithms which compute various arithmetical
functions and relations from various primitives in this enhanced form, proving
that
 
~ ∈ den =⇒ ì(α, x
x ~ ) ≤ KL(~
x ) ≤ ì(A, f, x
~) (K > 0)
p
with some interesting L(~ x )— log(x), log log(x), log log(x), etc.
Other than that, weak optimality looks like a very weak condition on
processes, but it is not, cf. Problem x4F.3∗ .

Problems for Section 4F

x4F.1. Problem. Prove that if α is a uniform process of A which defines


f : An * As , D ⊆ An is contained in the domain of convergence of f and
for some substructure norm on A
sup{ì(α, x
~) : x
~ ∈ D} < ∞ and min{ì(A, f, x
~) : x
~ ∈ D} > 0,
then α is weakly ì-optimal for f on D.
Infer that
(1) Every α which defines f in A is weakly ì-optimal on every finite sub-
set D of the domain of convergence of f which contains some x ~ such that
ì(A, f, x~ ) > 0.
(2) If f is A-explicit, then f is defined by some uniform process which is
ì-optimal on the entire domain of convergence of f, for every substructure
norm ì.
Hint: For (2), appeal to Problem x4E.9∗ .
152 4. The homomorphism method

x4F.2. Problem. Prove that if α is (the process induced by) the Euclidean
algorithm in Nε , then
(for infinitely many x, y)[x > y & calls(rem)(x, y) ≤ 1].
(This trivial fact is why the definition of weak optimality demands (4F-4) of
D.)
x4F.3∗ . Problem. Suppose α is a uniform process of A which defines a total
function f : An * As . Prove that if α is not weakly ì-optimal for f, then for
every rational r > 0, there exists a set E ( An and a number m such that
(4F-6) sup{ì(α, x
~) : x
~ ∈ E} ≤ m & (∀~
x∈ ~ ) ≤ rì(α, x
/ E)[ì(A, f, x ~ )].

4G. Logical extensions

We introduce here a relation between structures which helps express and


prove the robustness of intrinsic complexities and the complexities of recursive
programs that we studied in Chapter 3.
A (Φ ∪ Ψ)-structure B = (B, {φ B }φ∈Φ , {ø B }ø∈Ψ ) is a logical extension35 of
the Φ-structure A = (A, {φ A }φ∈Φ ) (or logical over A) if
(LE1) A ⊆ B,
(LE2) each φ B : B n * Bs has the same domain of convergence as φ A and
agrees with φ A on it, and
(LE3) every permutation ðA : A  → A has an extension ðB : B  → B such
B
that for every “fresh” primitive ø : B n * Bs and all x ~ ∈ Bn,
(4G-1) ðB (ø B (x1 , . . . , xn )) = ø B (ðB (x1 ), . . . ðB (xn )).
If B = A, we call B = (A, {φ A }φ∈Φ , {ø B }ø∈Ψ ) a logical expansion of A.
For example, the expansion (L∗ , ≤) of the Lisp structure on a set L by
an ordering of L and the structure RAM(A) over a Φ-structure A are logical
extensions of (L, ≤) and A respectively, cf. Problems x4G.5 and x4G.9∗ .
For every A, the expansion (A, =A ) by the identity relation on A is logical,
trivially, taking ðB = ðA , so logical expansions may compute functions on A
which are not A-recursive; on the other hand, we will show that on the level
of uniformity (rather than recursiveness), adding the identity relation on A is
the only way to enlarge Unif(A) by adding new, logical primitives: if =A is
uniform in A, then every f : An * As which is uniform in some logical extension
of A is already uniform in A. The central result of this section is a complexity
35 These were called inessential extensions in van den Dries and Moschovakis [2004], although

the connection with the logical notions in Tarski [1986] was pointed out in a footnote. The
definition and (a version of) Lemma 4G.2 below are due to Itay Neeman and they were used to
simplify considerably both the statements and the proofs of the lower bound results about RAMs
in that paper, but the notion deserves the fancier name—it has legs.
4G. Logical extensions 153

version of this fact: we will show (in part) that if =A is among the primitives
of A, then lower bounds for intrinsic complexities which hold in A persist in all
its logical extensions—in a precise and very general way.
First, however, we prove a very simple application of logical extensions
which uses nothing but their definition:
The lower bound for comparison sorting. One of the few lower bound
results that is regularly taught in undergraduate courses on algorithms is
that “Ω(n log n) comparisons are [on some input] necessary for sorting n ele-
ments” in the eloquent formulation of Dasgupta, Papadimitriou, and Vazi-
rani [2011, 2.3], which also notes that [their] “neat argument applies only to
algorithms that use comparisons”. We give here a version of the usual proof
which is based on a precise definition of the “comparison algorithms” for
which it works in terms of logical extensions.
4G.1. Theorem (Lower bound for sorting). Suppose
• ≤ is a linear ordering of a set L which has at least n ≥ 2 elements;
• B = (B, ≤, {ø B }ø∈Ψ ) is a logical extension of (L, ≤) which contains the
set of strings from L, L∗ ⊆ B;
• E(u) is an extended (deterministic) recursive program in the vocabulary
of B which computes sort≤ (u) for every u ∈ L∗ ; and
• c s (≤)(u) = c s (≤)(B, E(u)) is the number of ≤-calls complexity of E(u)
in B;
then there is some u ∈ L∗ of length n such that c s (≤)(u) ≥ log(n!).
Proof is by way of two Lemmas:
Lemma 1. For every ordering ≤0 of L, E(v) computes
sort≤0 : Ln → Ln
in every structure B0 = (B, ≤0 , {ø B }ø∈Ψ ) derived from B by replacing ≤ by ≤0 .
Proof. Fix a set X ⊆ L with exactly n members and let ð : L 
→ L be the
unique permutation of L such that
s, t ∈ X =⇒ s ≤ t ⇐⇒ ð(s) ≤0 ð(t) and s ∈
/ X =⇒ ð(s) = s.
Since B is a logical extension of (L, ≤), ð can be extended to a permutation of
B which respects the fresh primitives, and so it is an isomorphism
→ (B, ≤0  X, {ø B }ø∈Ψ ) = B0 .
ð : B = (B, ≤  X, {ø B }ø∈Ψ ) 
The hypothesis on the extended program E(u) is that
B |= E(u) = sort≤ (u);
so Problem x3A.1 implies that if u ∈ X n , then
B0 |= E(ð(u)) = ð(sort≤ (u)) = sort≤0 (ð(u));
154 4. The homomorphism method

and if we set in this u = ð−1 (v) for any v ∈ X n , we get the required
(4G-2) B0 |= E(v) = ð(sort≤ (ð−1 (v)) = sort≤0 (v). a (Lemma 1)

Problem x3A.1 also gives the following equation on the complexity mea-
sures,
(4G-3) c s (≤0 )(B0 , E(v)) = c s (≤)(B, E(ð−1 (v))),
which we now use:
Lemma 2. Fix a tuple v = (v1 , . . . , vn ) ∈ X n of distinct members of X and
consider the computations of the recursive machine for E(v) with respect to all
orderings ≤ of X ; there is at least one such ≤ for which
c s (≤)(B, E(v)) ≥ log(n!).

Proof. For each ordering ≤ of X , let s0≤ , . . . , sm≤ be the computation of


the recursive machine for the structure B which computes sort(v), The set
of all these computations is a tree (on the states) with degree = 2 and n!
leaves, one for each permutation of X which returns sort≤ (v). By (1A-18),
n! ≤ 2spdepth(T ) , so spdepth(T ) ≥ log(n!); and so there must be one of these
computations, corresponding to some ≤, and the splitting nodes are precisely
the calls to ≤ which we wanted to count. a (Lemma 2)

If we now set u = ð−1 (v), then (4G-3) gives


c s (≤)(B, E(u)) = c s (≤0 )(B0 , E(v)) ≥ log(n!),
which completes the proof of the theorem. a

The log(n!) lower bound does not hold for non-deterministic programs, cf.
Problem x4G.6.
Embedding Test. The most important applications of logical extensions to
complexity theory derive from the following basic fact:
4G.2. Lemma (Neeman, cf. Footnote 35). If B is logical over an infinite
structure A, V ⊆p B, and
(4G-4) U = V  Φ  A ⊆p A,
then for every finite X ⊆ U and every k,
(1) Gk (V, X ) ∩ A = Gk (U, X ), and
(2) if ðA : A  → A and ðB  → B are as in (LE3) above and ðA fixes every
B
s ∈ Gk (U, X ), then ð fixes every t ∈ Gk (V, X ).
~ ∈ An ,
It follows that for all x
(4G-5) (V, x
~ ) is a certificate in B =⇒ (U, x
~ ) is a certificate in A.
4G. Logical extensions 155

Proof. We prove (1) and (2) together by induction on k, the basis being
trivial since
G0 (U, X ) = G0 (V, X ) = X.
At the induction step, we assume (1) and (2) for k.
To prove (2) first at k + 1, suppose ðA fixes every s ∈ Gk+1 (U, X ) and
t ∈ Gk+1 (V, X ). If
t = φ V (z1 , . . . , zn ) = φ B (~z ) with φ ∈ Φ and z1 , . . . , zn ∈ Gk (V, X ),
then z1 , . . . , zn ∈ A, since φ B (~z ) = φ A (~z ) ↓ ; so z1 , . . . , zn ∈ Gk (U, X ) by
(1) of the induction hypothesis; so t ∈ Gk+1 (U, X ) and ðB fixes it by the
hypothesis. If
t = ø V (~
z ) = ø B (~z ) with z1 , . . . , zn ∈ Gk (V, X ),
then using the properties of ðB and (2) for k,
ðB (t) = ðB (ø B (~z )) = ø B (ðB (~z )) = ø B (~z ) = t.
To prove (1) at k + 1, suppose there is some t ∈ Gk+1 (V, X ) ∩ A such that
t∈/ Gk+1 (U, X ), so it must be that t = ø V (z1 , . . . , zn ) with a fresh primitive
and z1 , . . . , zn ∈ Gk (V, X ). Choose a permutation ðA : A  → A which fixes
every member of Gk (A, X ) but moves t—which exists since Gk (A, X ) is finite
while A is infinite; now ðB (t) = ðA (t) 6= t, which contradicts (2) at k + 1.
Proof of (4G-5). If V = Gk (V, x ~ ) and X = {x1 , . . . , xn }, then
V = Gk (V, x
~ ) = Gk (V, X ), U = Gk (U, x
~ ) = Gk (U, X ),
and the two structures U = Gk (V, x ~ )  Φ  A and Gk (U, x
~ ) have the same
universe Gk (V, x
~ ) ∩ A = Gk (U, x
~ ) by (1). They are both Φ-structures; and
for every φ ∈ Φ,
V  Φ  A |= φ(~z ) = w ⇐⇒ U |= φ(~z ) = w,
because φ = φ A , and so the restrictions of these two partial functions to the
B

same set are identical, i.e., U = Gk (U, x


~ ) and so (U, x
~ ) is a certificate. a
Substructure norms on logical extensions. If B is logical over an infinite
structure A and ì is a substructure norm on A, set
(4G-6) ìB (V, x
~ ) = ì(V  Φ  A, x x ∈ An , (V, x
~ ) (~ ~ ) a certificate in B).
This makes sense for x~ ∈ An by (4G-5) and specifies the only values of ìB
that we care about, but it is quite trivial to extend it so it is a full substructure
norm on B, cf. Problem x4G.8).
For example, if U = V  Φ  A, then
depthB (V, x
~ ) = min{k : U = Gk (U, k)} ≤ min{k : V = Gk (V, k)}
by Lemma 4G.2. If
c = (E0 (~
x ) : , . . . , : w)
156 4. The homomorphism method

is a (recursive machine) computation of a non-deterministic program E(~x)


of B which computes f(~ x ) ∈ As on some input x ~ ∈ An and (Vc , x ~ ) is the
certificate in B with
eqdiag(Vc ) = {(÷, u~ , v) : a transition a~ ÷ : u~ ~b → a~ : v ~b occurs in c},
then calls(Φ0 )B (Vc , x
~ ) is the number of calls in c to primitives in Φ0 .
4G.3. Lemma (Embedding Test). Suppose A is an infinite Φ-structure, ì is
a substructure norm on A, f : An * As and f(~ x )↓ . If

(4G-7) for every certificate (U, x


~ ) of A,
 
x ) ∈ Us & ì(U, x
f(~ ~ ) < m =⇒ (∃ð : U  A)[f(ð(~
x )) 6= ð(f(~
x ))],

then for every logical extension B of A, ìB (B, f, x


~ ) ≥ m.
The difference between the Embedding and the Homomorphism tests is that
the hypothesis of the first supplies an embedding ð : U  A which does not
respect f at x
~ when ì(U, x ~ ) < m, and the injectivity of ð suffices to guarantee
that m is a lower bound for ìB (B, f, x~ ) in every logical extension of A.
Proof. By the Homomorphism Test, to prove ìB (B, f, x ~ ) ≥ m it is enough
to show that for every certificate (V, x
~ ) of B,
ìB (V, x
~ ) < m =⇒ (∃ñ : V → B)[f(ñ(~
x )) 6= ñ(f(~
x ))],
so assume the hypothesis of this implication for (V, x
~ ) and let U = V  Φ  A.
By (4G-5), (U, x
~ ) is a certificate of A,
~ ) = ìB (V, x
ì(U, x ~ ) < m,
and so the hypothesis of the lemma supplies an embedding ð : U  A which
does not respect f at x ~ . Since U and ð[U ] have the same (finite) cardinality,
there is a permutation ðA : A  → A which extends ð; and since B is a logical
extension of A, there is an extension ðB : B  → B of ðA which respects the
fresh primitives. It is now easy to check that
ñ = ðB  V : V  B
and ñ does not respect f at x ~ (since it agrees with ð on U ), which completes
the argument. a
The version for depth is important for complexity in arithmetic, because
in the proofs in Chapters 5 – 8 we will actually construct embeddings, and so
the lower bounds we will derive apply to all logical extensions of the relevant
structures. The version for calls yields the expected lower bound for RAMS
in Problem x4G.9∗ , and also has robustness implications for the lower bounds
in algebra that we will derive in Chapter 9.
4G.4. Corollary. If =A is uniform in A and f : An * As is uniform in some
logical extension B of A, then f is already uniform in A.
4G. Logical extensions 157

Proof. We may assume by Problem x4B.4∗ that = is a primitive of A.


Suppose B is a logical extension of A, f : An * As is uniform in B and
x )↓ , so there is a certificate (V, x
f(~ ~ ) of B such that every ð : V → B respects
f at x
~ . If we set U = V  Φ  A, then (U, x ~ ) is a certificate in A, by (4G-5);
and then—easily—so is (U∗ , x ~ ) where the universe U of U∗ is the same as the
universe of U and
eqdiag(U∗ ) = eqdiag(U) ∪ {x 6= y : x, y ∈ U }.
Now every homomorphism ð∗ : U∗ → A is an embedding and it can be
exended to some ð : V  B, as in the proof of the Embedding Test, so it
respects f at x
~. a

Problems for Section 4G

x4G.1. Problem. Prove that if B is logical over A and C is logical over B,


then C is logical over A.
x4G.2. Problem. Prove that (A, Pin ) is logical over A, if Pin (~
x ) = xi .
x4G.3. Problem. Prove that if
apn (x1 , . . . , xn , p) = p(x1 , . . . , xn )
is the n-ary application functional, then
B = (A, (An * As ), Υ, apn ) = (A ] (An * As ), Υ, apn )
is logical over (A, Υ).
x4G.4. Problem. True or false:
(1) If ø(x) = w0 is a constant function on A, then (A, ø) is a logical
expansion of A.
(2) If ø(x) = φ A (x) is a primitive of A, then (A, ø) is logical over A.
x4G.5. Problem. Prove that if ≤ is a linear ordering of a set L, then
(L∗ , ≤) = (L∗ , nil, eqnil , head, tail, cons, ≤)
is a logical extension of (L, ≤).
x4G.6. Problem. Construct an extended nondeterministic recursive pro-
gram which sorts in (L∗ , ≤) every string of length n > 1 using n − 1 compar-
isons. Infer that
calls(≤)((L∗ , ≤), sort, s) ≤ |s| −
·
1 (s ∈ S ∗ ).
Hint: Use your favorite sorting algorithm, guessing whether a ≤ b without
calling the comparison function, and then output the one string you have
constructed which is, in fact sorted. For the second claim, use Problems x4C.4
and 4E.1.
158 4. The homomorphism method

x4G.7∗ . Problem. Prove that if ≤ is a linear ordering of a set L with at least


two members and A = (A, ≤, Υ) is a logical extension of (L, ≤) such that
L∗ ⊆ A, then for every s = (s1 , . . . , sn ) ∈ L∗ with length |n| > 1
VV
1≤i<j≤n [si 6= sj ] =⇒ calls(≤)(A, sort, s) = n − 1.
Hint: Problem x4G.6 for the upper bound.
x4G.8. Problem. Prove that every substructure norm ì on a Φ-structure A
can be extended to a substructure norm ìB on any logical extension of A so
~ ∈ An .
that (4G-6) holds when x
x4G.9∗ . Problem. Prove that the structure RAM(A) associated by (2F-3)
with an infinite, pointed structure A is a logical extension of A. Infer that if a
RAM over a structure A computes f : An * As , then
calls(A, f, x
~ ) ≤ 2 Time(~
x ) − 1 (f(~
x )↓ ),
where Time(~ x ) is the time complexity of the RAM when we view it as an iter-
ator, cf. (2C-4). (This is not the most natural complexity measure for RAMs
introduced in Cook and Reckhow [1973], cf. the comment on page 138.) Hint:
For the second claim use Problem x3A.3.

4H. Deterministic uniform processes

An n-ary uniform process of a structure A is deterministic if it satisfies the


following, stronger form of the Finiteness Axiom as expressed in (4B-1):

(4H-1) α(~ x ) = w =⇒ (∃U ⊆p A) U |=c α(~ x ) = w]

& (for all V ⊆p A)[V |=c α(~
x ) = w =⇒ U ⊆p V] ,
i.e., if whenever α(~x ) ↓ , then there is a unique, ⊆p -least “abstract compu-
tation” of α(~ x ) by α. The notion is natural and interesting. I record it
here for completeness, but I have no real understanding of deterministic uni-
form processes and no methods for deriving lower bounds for them which are
greater than the lower bounds for all uniform processes which define the same
function.

Problems for Section 4H

x4H.1. Problem. Prove that the uniform process αE induced by a determi-


nistic recursive A-program is deterministic.
x4H.2∗ . Problem. Give an example of a total, finite structure A and a
unary relation R on A such that for some a, depth(A, R, a) = 1, but for every
deterministic uniform α which defines R in A, depth(α, a) > 1.
CHAPTER 5

LOWER BOUNDS FROM PRESBURGER PRIMITIVES

We establish here log-lower bounds for depthf (Nd , x


~ ) of various functions on
the natural numbers, where

·
Nd = (N, Lind ) with Lind = {0, 1, . . . , d, +, − , iqd , =, <}.

The structure Nd is clearly explicitly equivalent to its reduct without = and


the constants 2, . . . , d , but including these among the primitives simplifies
some of the formulas below. Lower bounds for Nd have wide applicability:
binary arithmetic Nb and the Stein structure Nst are explicitly reducible to N2 ,
·
and every expansion of (N, 0, 1, +, − , <, =) by finitely many Presburger prim-
itives is explicitly equivalent with some Nd , cf. Problems x5A.1 and x5A.3∗ .
The results in this chapter are interesting on their own, but they also illus-
trate the use of the Homomorphism Test 4E.3 in a very simple context, where
the required arithmetic is trivial. They are mostly from van den Dries and
Moschovakis [2004], [2009].

5A. Representing the numbers in Gm (Nd , a~ )

To illustrate the use of the primitives of Lind , consider the following.


5A.1. Lemma. There is a recursive program E which computes the product
x · y from Lin2 with parallel complexity

cEp (x, y) ≤ 3 log(min(x, y)) (x, y ≥ 2).

Proof. The idea (from Problem x1B.2) is to reduce multiplication by x to


multiplication by 2 and iq2 (x) (and addition), using the identity

(2x1 + r) · y = 2(x1 · y) + r · y,

159
160 5. Lower bounds from Presburger primitives

which means that the multiplication function satisfies and is determined by


the recursive equation
f(x, y) = if (x = 0) then 0
else if (x = 1) then y
else if (parity(x) = 0) then 2(f(iq2 (x), y))
else 2(f(iq2 (x), y)) + y.
Now, obviously,
cfp (0, y) = 1, cfp (1, y) = max{1, 1} = 1,
and with a careful reading of the equation, for x ≥ 2,
cfp (x, y) ≤ cfp (iq2 (x), y) + 2.
To get an explicit form for an upper bound to cfp (x, y), we prove by (complete)
induction the inequality
cfp (x, y) ≤ 3 log(x) (x ≥ 2),
the basis being trivial, since cfp (2, y)
= cfp (1, y) + 2 = 3 = 3 log 2, directly
from the definition. In the inductive step,
x x
cfp (x, y) ≤ cfp (iq2 (x), y) + 2 ≤ 3 log( ) + 3 = 3(log( ) + 1) = 3 log x.
2 2
Finally, to complete the proof, we add a head equation which insures that the
first argument of f is the minimum of x and y:
g(x, y) = if (y < x) then f(y, x) else f(x, y);
the resulting program E has the claimed complexity bound. a
The basic tool for the derivation of lower bounds in Nd is a canonical
representation of numbers in Gm (Nd , a~ ).
For a fixed d and each tuple of natural numbers a~ = (a1 , . . . , an ), let
nx + x a + · · · + x a
0 1 1 n n
(5A-1) Bm (~ a ) = Bmd (~
a) = ∈N
dm o
: x0 , . . . , xn ∈ Z and |xi | ≤ d 2m , i ≤ n .

The members of Bm (~
a ) are natural numbers. In full detail:
x ∈ Bm (~
a ) ⇐⇒ x ∈ N and there exist x0 , . . . , xn ∈ Z
x0 + x1 a 1 + · · · + xn a n
such that x = ,
dm
and for i = 0, . . . , n, |xi | ≤ d 2m .
5A.2. Lemma (Lind -inclusion). For all a~ ∈ Nn and all m:
(1) a1 , . . . , an ∈ Bm (~
a ) ⊆ Bm+1 (~
a ).
5A. Representing the numbers in Gm (Nd , a~ ) 161
(2) For every primitive φ : Nk → N in Lind ,
x1 , . . . , xk ∈ Bm (~
a ) =⇒ φ(x1 , . . . , xk ) ∈ Bm+1 (~
a ).
(3) Gm (~
a ) = Gm (Nd , a~ ) ⊆ Bm (~
a ).
Proof. We take n = 2 to simplify the formulas, the general argument being
only a notational variant.
d m ai
(1) The first inclusion holds because ai = m and the second because
d
x0 + x1 a 1 + x2 a 2 dx0 + dx1 a1 + dx2 a2
=
dm d m+1
and |dxi | ≤ d · d 2m < d 2(m+1) .
(2) Clearly 0, . . . , d ∈ Bm (~
a ) for every m ≥ 1, and so the constants stay in
Bm (~
a ) once they get in.
For addition, let x, y ∈ Bm (~ a ), so
x0 + x1 a 1 + x2 a 2 y0 + y1 a 1 + y2 a 2
x+y = +
dm dm
d (x0 + y0 ) + d (x1 + y1 )a1 +1 +d (x2 + y2 )an
=
d m+1
and the coefficients in the numerator satisfy
|d (xi + yi )| ≤ d (d 2m + d 2m ) ≤ dd 2m+1 = d 2m+2 .
The same works for arithmetic subtraction. Finally, for integer division by d ,
if i = remd (x) < d , then
1 (x0 − id m ) + x1 a1 + x2 a2
iqd (x) = (x − i) = for some 1 ≤ i < d
d d m+1
and this number is in Bm+1 (~a ) as above.
(3) follows immediately from (2), by induction on m. a
5A.3. Proposition (Multiplication from Lind ). For every number a ≥ 2,
1  a2 
depth(a 2 ; Nd , a) ≥ log .
log d a+1
Proof. It is enough to show that for a ≥ 2,
1  a2 
a 2 ∈ Gm (Nd , a) =⇒ m ≥ log ,
log d a+1
so assume that a 2 ∈ Gm (a). By Lemma 5A.2, there exist x0 , x1 ∈ Z such that
|x0 |, |x1 | ≤ d 2m and
x0 + x1 a
a2 = ,
dm
162 5. Lower bounds from Presburger primitives

from which we get d m a 2 = |x0 + x1 a| ≤ d 2m + d 2m a; thus a 2 ≤ d m + d m a,


which yields the required
a2
dm ≥ . a
a+1
Similar arguments can be used to establish output-depth lower bounds from
Lind for all functions which grow faster than x.

Problems for Section 5A

x5A.1. Problem. Prove that the structures

Nb = (N, 0, parity, iq2 , em2 , om2 , eq0 ),


·
Nst = (N, parity, em2 , iq2 , − , =, <)
of binary arithmetic and the Stein algorithm are explicitly reducible to N2 .
x5A.2. Problem. Prove that remd (x) is explicit in Nd .
x5A.3∗ . Problem. Prove that for all m, n ≥ 2:
(i) iqm ∈ Expl(Nmn );
·
(ii) iqmn ∈ Expl(N, 0, 1, . . . , d, +, − , iqm , iqn , =, <).
Infer that if Υ is any finite set of Presburger primitives, then the structure
·
(N, 0, 1, +, − , <, =, Υ)
is explicitly equivalent with some Nd . (For the definition of Presburger func-
tions see (1E-10).)
x5A.4. Problem. Specify a system of two recursive equations
q(x, y) = Eq (x, y, q, r)
r(x, y) = Er (x, y, q, r),
in the vocabulary Lin2 ∪ {q, r}, such that in N2 ,
q(x, y) = iq(x, y), r(x, y) = rem(x, y),
and the corresponding complexities are O(log(x)), i.e., for some B and all
sufficiently large x,
cqp (x, y) ≤ B log x, crp (x, y) ≤ B log x.
(With the appropriate head equations, this system defines two programs from
Lin2 , one for iq(x, y) and the other for rem(x, y).)
x5A.5. Problem. Prove that the recursive program for the integer quotient
function in Problem x5A.4 is weakly depth-optimal from Lind , for any d ≥ 2.
5B. Primality from Lind 163

x5A.6∗ . Problem. Prove that for every d ≥ 2, there is an r > 0 and infinitely
pairs of numbers (a, b) such that for every d ≥ 2,
depth(rem(a, b); Lind , a, b) > r log(max(a, b)).
Infer that the recursive program for rem(x, y) in Problem x5A.4 is weakly
depth-optimal for rem(x, y) in every Nd . Hint: Use the pairs (a 3 + a, a 2 ).
(Note: It is possible to give an easier proof of an O(log max(a, b)) lower bound
for depthrem (Nd , a, b) using the Homomorphism Test, see Problem x5B.1.
The proof suggested here uses output-depth complexity and requires a simple
divisibility argument. It is due to Tim Hu.)
x5A.7. Problem. Define a weakly depth-optimal program from Lind which
computes the exponential function f(x, y) = x y (with 00 = x 0 = 1).

5B. Primality from Lind

To establish lower bounds from Lind for decision problems, we need to


complement Lemma 5A.2 with a uniqueness result.
a
5B.1. Lemma (Lind -Uniqueness). If xi , yi ∈ Z, |xi |, |yi | < and ë ≥ 1,
2
then
x0 + x1 ëa = y0 + y1 ëa ⇐⇒ [x0 = y0 & x1 = y1 ],
x0 + x1 ëa > y0 + y1 ëa ⇐⇒ [x1 > y1 ∨ (x1 = y1 & x0 > y0 )].
Proof. It is enough to prove the result for ë = 1, since a ≤ ëa, and so the
general result follows from the special case applied to ëa.
The second equivalence implies the first, and it follows from the following
fact applied to (x0 − y0 ) + (x1 − y1 )a:
If x, y ∈ Z and |x|, |y| < a, then
x + ya > 0 ⇐⇒ [y > 0] ∨ [y = 0 & x > 0].
Proof. This is obvious if y = 0; and if y 6= 0, then |x| < a ≤ |ya|, so that
x + ya has the same sign as ya, which has the same sign as y. a
5B.2. Lemma (Lind -embedding). Suppose d 2m+2 < a, and let ë > 1 be any
number such that d m+1 | ë − 1; then there exists an embedding
ð : Gm (Nd , a)  Nd ,
such that ða = ëa.
Proof. By Lemma 5B.1 and part (3) of Lemma 5A.2, the equation
 x + x a  x + x ëa x0 + x1 a
0 1 0 1
ð m
= m
(|x0 |, |x1 | ≤ d 2m , ∈ Gm (a))
d d dm
164 5. Lower bounds from Presburger primitives

defines a map ð : Gm (Nd , a) → Q, since


a
d 2m < d 2m+1 <
2
by the hypothesis. This map takes values in N, because
(5B-1) x0 + ëx1 a = x0 + x1 a + (ë − 1)x1 a,
so that if d m | (x0 + x1 a), then also d m | (x0 + ëx1 a) since d m | (ë − 1) by
the hypothesis. It is injective and order-preserving, by Lemma 5B.1 again,
applied to both a and ëa.
To check that it preserves addition when the sum is in Gm (a) = Gm (Nd , a),
suppose that X, Y, X + Y ∈ Gm (a), and write
x0 + x1 a y0 + y1 a z0 + z1 a
X = , Y = , X +Y =Z =
dm dm dm
with all |xi |, |yi |, |zi | ≤ d 2m . Now
(x0 + y0 ) + (x1 + y1 )a
Z= ,
dm
a
and |x0 + y0 |, |x1 + y1 | ≤ 2 · d 2m ≤ d 2m+1 < , and so by the Uniqueness
2
Lemma 5B.1,
x0 + y 0 = z 0 , x1 + y 1 = z 1 ,
which gives ðX + ðY = ðZ.
The same argument works for arithmetic subtraction.
Finally, for division by d , suppose
x0 + x1 a
X = = d iqd (X ) + i (i < d )
d
where |x0 |, |x1 | ≤ d 2m as above, so that
1  x0 + x1 a  x − id m + x a
0 1 z0 + z1 a
iqd (X ) = m
−i = =Z=
d d d m+1 dm
for suitable z0 , z1 with |z0 |, |z1 | ≤ d 2m , if Z ∈ Gm . These two representations
a
of Z must now be identical since |dzi | ≤ dd 2m = d 2m+1 < , and
2
|x0 − id m | ≤ d 2m + id m < d 2m + d m+1
a
= d m (d m + d ) ≤ d m d m+1 = d 2m+1 < .
2
So x0 − id m = dz0 and x1 = dz1 . These two equations imply that
x0 + x1 ëa z0 + z1 ëa
m
=d + i,
d dm
5B. Primality from Lind 165

which means that


z0 + z1 ëa
iq2 (ðX ) = = ð(Z) = ð(iqd (X ))
dm
as required. a
5B.3. Theorem. For every prime number p,
1
depthPrime (Nd , p) ≥ log p.
4 log d
Proof. Let m = depthPrime (Nd , p) and suppose that
(5B-2) d 2m+2 < p.
Lemma 5B.2 guarantees an embedding
ð : Gm (Nd , p)  Nd
m+1
with ë = 1 + d such that ð(p) = ëp, and this ð does not respect the
primality relation at p, which is absurd. So (5B-2) fails, and so (taking
logarithms and using the fact that m ≥ 1 by Problem x4E.4),
4m log d ≥ (2m + 2) log d ≥ log p. a

Using non-trivial number theory. The proof of Theorem 5B.3 used nothing
but the definition of prime numbers, and none of the results about intrinsic
lower bound of number-theoretic relations in the sequel will require much
more. One might expect that truly significant results about primality depend
on deep properties of primes, and it is worth stating here one example of this.
5B.4. Theorem. There are infinitely many primes p, such that every number
whose binary expansion differs from that of p in any one digit is composite.
This was proved by Cohen and Selfridge [1975] and Sun [2000], Tao [2011]
extended it to expansions of numbers relative to any k > 1, and all three
of these papers established much stronger results about the form of primes
with this property, various transformations (other than flipping a digit) which
spoils their primeness, their density relative to the density of primes, etc. Sun
and Tao also observed the obvious complexity implications of the theorem:
to decide correctly whether x is prime, an algorithm which is given its input
x in binary form (and basically nothing else) must read all the digits of x, on
infinitely many inputs. This is usually made precise in terms of boolean circuit
complexity which we have not defined, but a strong version of it is a fact about
the intrinsic calls-complexity of primality in the appropriate structure.
P
If x = j xj 2j (with xi < 2) is the binary expansion of x > 0, let
biti (x) = xi , length(x) = max{i : biti (x) > 0} + 1,
bitboundi (x) ⇐⇒ i ≥ length(x) − 1,
166 5. Lower bounds from Presburger primitives

and consider the structure:36


Bits = (N, 0, 1, {biti }i∈N , {bitboundi }i∈N , =).
Let Υbits = {{biti }i∈N }.
5B.5. Proposition. (1) For every x > 0,
calls(Υbits )Prime (Bits, x) ≤ length(x).
(2) For infinitely many primes p and every logical extension B of Bits,
calls(Υbits )Prime (B, p) ≥ length(p).
Unwinding the technical terms, (1) says that there is a uniform process
of Bits which defines Prime(x) using no more than length(x) calls to the bit
primitives; and (2) says that every uniform process of a logical extension B of
Bits which defines Prime(p)—and so every nondeterministic recursive program of
B which decides Prime(p)—makes at least length(p) calls to the bit primitives,
on infinitely many primes.
Proof. (1) For any x > 0 with length(x) = n + 1, let U ⊆p Bits be the
structure with universe {x, 0, 1} and
eqdiag(U) = {bit0 (x) = x0 , . . . , bitn (x) = xn , bitboundn (x) = tt}.
Every homomorphism ð : U → Bits fixes all the bits and the length of x,
so ð(x) = x and (trivially) ð respects the relation Prime(x); so (U, x) is a
certificate of Prime(x) or ¬Prime(x), whichever of these is true, and hence
calls(Υbits )Prime (Bits, x) ≤ calls(Υbits )(U, x) = n + 1.
(2) By the Embedding Test 4G.3, it is enough to check that if p is any of the
primes guaranteed by Theorem 5B.4, U ⊆p Bits is finite, generated by p and
calls(Υbits )(U) < n + 1 = length(p), then there is an embedding ð : U  Bits
such that ð(p) is composite. The hypothesis on U means that there is an
i < n + 1 such the condition (biti , p, biti (p)) is not in eqdiag(U); and if x is
the composite number produced by flipping biti (p) and we set
ð(p) = x, ð(0) = 0, ð(1) = 1,
then ð : U  B is an embedding which does not respect Prime(p). a

Problems for Section 5B

x5B.1. Problem. Suppose e ≥ 2, set


|e (x) ⇐⇒ e | x ⇐⇒ reme (x) = 0
and assume that e⊥
⊥ d.
36 The vocabulary of Bits is infinite, see Footnote 8 on page 31.
5C. Good examples: perfect square, square-free, etc. 167

(a) Prove that for all a which are not divisible by e,


1
depth|e (Nd , a) ≥ log a.
4 log d
(b) For some r > 0 and all a which are not divisible by e,
depth(Nd , iqe , a) > r log a, depth(Nd , reme , a) > r log a.
In particular, if e is coprime with d , then the relation |e (x) is not explicit
in Nd ; the divisibility relation x | y is not explicit in any Nd ; and the recursive
programs for iq(x, y) and rem(x, y) in Problem x5A.4 are weakly depth-
optimal in N2 and in every Nd (such that 2 | d , so they can be expressed).
Hint: Use the fact that if x⊥ ⊥ y, then there are constants A ∈ Z and B ∈ N
such that 1 = Ax − By.
x5B.2. Problem. If you know what boolean circuits are, check that they
can be viewed as recursive programs of Bits and so (2) of Proposition 5B.5
applies—albeit the complexity measure calls(Υbits )Prime (B, p) on logical ex-
tensions of Bits is not close to the measures usually studied in boolean circuit
theory.

5C. Good examples: perfect square, square-free, etc.

The method in the preceding section can be easily adapted to derive lower
bound results for many unary relations on N. Some of these are covered by
the next, fairly general notion.
A unary relation R(x) is a good example if for some polynomial
(5C-1) ë(ì) = 1 + l1 ì + l2 ì2 + · · · + ls ìs
with coefficients in N, constant term 1, and degree > 0 and for all ì ≥ 1,
(5C-2) R(x) =⇒ ¬R(ë(ì)x).
For example, primality is good, taking ë(ì) = 1 + ì, and being a power of
2 is good with ë(ì) = 1 + 2ì. We leave for the problems several interesting
results of this type.

Problems for Section 5C

x5C.1. Problem. Design a weakly depth-optimal recursive program from


Lind for the relation
P(x) ⇐⇒ (∃y)[x = 2y ].
168 5. Lower bounds from Presburger primitives

x5C.2. Problem (van den Dries and Moschovakis [2004]). Prove that if R(x)
is a good example, then for all a ≥ 2,
1
R(a) =⇒ depthR (Nd , a) ≥ log a.
4 log d
x5C.3. Problem. Prove that if m > 0, then (1+m 2 )n 2 is not a perfect square.
Hint: Prove first that 1 + m 2 is not a perfect square, and then reduce the result
to the case where m⊥ ⊥ n.
x5C.4. Problem. Prove that the following two relations are good examples:
R1 (a) ⇐⇒ a is a perfect square
R2 (a) ⇐⇒ a is square-free.
x5C.5. Problem. Prove that if ë(ì) is as in (5C-1), then there is a constant
C such that
(5C-3) log ë(ì) ≤ C log ì (ì ≥ 2).
The next problem gives a logarithmic lower bound for depthR (Nd , a) with
good R at many points where R(a) fails to hold.
x5C.6. Problem. Suppose R(x) is a good example with associated polyno-
mial ë(ì). Prove that there is a rational constant r > 0, such that for all a ≥ 2
and m ≥ 1,
R(a) =⇒ depthR (Nd , ë(d m+1 )a) ≥ r log(ë(d m+1 )a).

5D. Stein’s algorithm is weakly depth-optimal from Lind

We extend here (mildly) the methods in the preceding section so they apply
to binary functions, and we show the result in the heading.
For the remainder of this section, a, b, c range over N and x, y, z, xi , yi , zi
range over Z.
5D.1. Lemma. Suppose a > 2 and set b = a 2 − 1.
a
(1) a⊥⊥ b, and if |xi |, |yi | < for i = 0, 1, 2 and ë ≥ 1, then
4
x0 + x1 ëa + x2 ëb = y0 + y1 ëa + y2 ëb ⇐⇒ x0 = y0 & x1 = y1 & x2 = y2 ,
x0 + x1 ëa + x2 ëb > y0 + y1 ëa + y2 ëb
⇐⇒ [x0 > y0 & x1 = y1 & x2 = y2 ]
∨ [x1 > y1 & x2 = y2 ] ∨ [x2 > y2 ].
(2) If d 2m+3 < a and ë = 1 + d m+1 , then there is an embedding
ð : Nd  Gm (a, b)  Nd
such that ða = ëa, ðb = ëb.
5D. Stein’s algorithm is weakly depth-optimal from Lind 169

Proof. (1) The identity 1 = a · a − b witnesses that a⊥ ⊥ b.


The second equivalence clearly implies the first, and it follows from the
following proposition applied to (x0 − y0 ), (x1 − y1 ), (x2 − y2 ).
a
If |x|, |y|, |z| < and ë ≥ 1, then x + yëa + zëb > 0 if and only if either
2
x > 0 and y = z = 0; or y > 0 and z = 0; or z > 0.
Proof. If z = 0, then the result follows from Lemma 5B.1, so assume z 6= 0
and compute:
x + yëa + zëb = x + yëa + zë(a 2 − 1) = (x − ëz) + yëa + zëa 2 .
Now
x a2
(x − ëz) + yëa = ë ( − z) + ya < ë(a + ) < ëa 2 ≤ ë|z|a 2 ,
ë 2
2
and so x + yëa + zëb and ëza have the same sign, which is the sign of z.
(2) Assume d 2m+3 < a, set ë = 1 + d m+1 , and notice that d 2m < 14 a, so as
in Lemma 5B.2, we can define the required embedding by
 x + x a + x b  x + x ëa + x ëb
0 1 2 0 1 2
ð =
dm dm
x0 + x1 a + x2 b
(|x0 |, |x1 |, |x2 | ≤ d 2m , ∈ Gm (a, b)),
dm
using now (1) instead of Lemma 5B.1. a
5D.2. Theorem (van den Dries and Moschovakis [2004]). For all a > 2,
2 1 2
depth⊥⊥ (Nd , a, a − 1) > 10 log d log(a − 1).
2
Proof. Let m = depth⊥ ⊥ (N0 , a, a − 1) for some a > 2. Since ëa and
ë(a 2 − 1) are not coprime, part (2) of the preceding Lemma 5D.1 and the
Embedding Test 4G.3 imply that
d 2m+3 ≥ a;
taking the logarithms of both sides and using the fact that m ≥ 1 (by Prob-
lem x4E.4), we get
5m log d ≥ (2m + 3) log d ≥ log a;
2
which with log(a − 1) < 2 log a gives the required
1
5m log d > log(a 2 − 1). a
2
5D.3. Corollary. Let E be the recursive program of N2 which decides a⊥
⊥b
by adding to the Stein algorithm one step checking gcd(a, b) = 1. For each
d ≥ 2, there is a constant K > 0 such that for all a > 2,
lEs (a, a 2 − 1) ≤ K depth⊥ 2
⊥ (Nd , a, a − 1).
170 5. Lower bounds from Presburger primitives

In particular, the Stein algorithm is weakly optimal for coprimeness from


Presburger primitives, for both the depth and calls complexity measures.
Proof. Choose K1 such that
lEs (a, b) ≤ K1 (log a + log b) (a, b > 2),
and compute for a > 2:
lEs (a, a 2 − 1) < 2K1 log(a 2 − 1) < 20 log dK1 depth⊥ 2
⊥ (a, a − 1). a

Problems for Section 5D

Problem x5A.4 defines a recursive program from N2 which computes rem(x, y)


with O(log) complexity. The next problem claims that it is weakly depth-
optimal from Presburger primitives—and a little more.
x5D.1. Problem. Prove that for each d ≥ 2, there is a rational r > 0, such
that
for infinitely many pairs (x, y), x | y and depth | (Nd , x, y) ≥ r log y.
Infer that the recursive program for the remainder in Problem x5A.4 is weakly
depth-optimal from Lind .
Hint: Prove that when a, b, ë and ì satisfy suitable conditions, then the
mapping
x0 + x1 a + x2 b x0 + x1 ëa + x2 ìb
7→
dm dm
is an embedding on Nd  Gm (a, b).
Busch [2007], [2009] has used “asymmetric” embeddings of this kind to
derive lower bounds for several problems in number theory and algebra that
are related to the Stein algorithm.
CHAPTER 6

LOWER BOUNDS FROM DIVISION WITH REMAINDER

We now add to the basic primitives of the Presburger structures division with
remainder, i.e., the integer quotient and remainder operations. Set:
·
Lin0 = {0, 1, =, <, +, − }, N0 = (N, Lin0 ),
·
Lin0 [÷] = Lin0 ∪ {iq, rem} = {0, 1, =, <, +, − , iq, rem},
·
N0 [÷] = (N, Lin0 [÷]) = (N, 0, 1, =, <, +, − , iq, rem).
Every expansion of a Presburger structure by division with remainder is obvi-
ously explicitly equivalent to N0 [÷], and so all the results of this chapter apply
to these richer structures with only inessential changes in the constants.
The derivations of absolute lower bounds for unary relations from Lin0 [÷]
is similar to those from Lind in Sections 5B and 5C and we will consider it
first. For binary relations, however, like coprimeness, we need some new ideas
as well as some elementary results from number theory.

6A. Unary relations from Lin0 [÷]

We start with a representation of the numbers in Gm (N0 [÷], a~ ) similar to that


for Gm (Nd , a
~ ) in Lemma 5A.2, except that we cannot keep the denominators
independent of a~ .
For each tuple a~ = (a1 , . . . , an ) of numbers and for each h ≥ 1, we let
nx + x a + · · · + x a
0 1 1 n n
(6A-1) C (~ a ; h) = ∈ N : x0 , . . . , xn+1 ∈ Z,
xn+1
o
xn+1 > 0 and |x0 |, . . . , |xn+1 | ≤ h .

The numbers in C (~ a ; h) are said to have height (no more than) h with respect
to a~ , and, trivially,
x ≤ h =⇒ x ∈ C (a; h), h ≤ h 0 =⇒ C (~ a ; h 0 ).
a ; h) ⊆ C (~
We need to estimate how much the height is increased when we perform various
operations on numbers. The results are very simple for the primitives in Lin0 :

171
172 6. Lower bounds from division with remainder

6A.1. Lemma. For all a~ = (a1 , . . . , an ), h ≥ 2 and every k-ary operation in


Lin0 ,
X1 , . . . , Xk ∈ C (~ a ; h 3 ).
a ; h) =⇒ f(X1 , . . . , Xk ) ∈ C (~

Proof is by direct computation. For example (taking n = 2 to keep the


notation simple),
x0 + x1 a + x2 b y0 + y1 a + y2 b
+
x3 y3
(y3 x0 + x3 y0 ) + (y3 x1 + x3 y1 )a + (y3 x2 + x3 y2 )b
= ,
x3 y 3
and for the typical coefficient,
|y3 x0 + x3 y0 | ≤ h 2 + h 2 = 2h 2 ≤ h 3 . a

There is no simple, general result of this type for division with remainder,
and in this section we will consider only the simplest case n = 1, when C (a; h)
comprises the numbers of height h with respect to a single a. We start with
the appropriate version of Lemma 5B.1.
6A.2. Lemma (Lin0 [÷]-Uniqueness). If |xi |, |yi | ≤ h for i ≤ 2, ë ≥ 1 and
2h 2 < a, then:
x0 + x1 ëa y0 + y1 ëa
= ⇐⇒ y2 x0 = x2 y0 & y2 x1 = x2 y1 ,
x2 y2
x0 + x1 ëa y0 + y1 ëa
> ⇐⇒ [y2 x1 > x2 y1 ] ∨ [y2 x1 = x2 y1 & y2 x0 > x2 y0 ].
x2 y2
In particular, if x ∈ C (a; h) and 2h 2 < a, then there are unique x0 , x1 , x2
with no common factor other than 1 such that
x0 + x1 a
(6A-2) x= (|x0 |, |x1 |, |x2 | ≤ h).
x2
Proof of the two equivalences is immediate from Lemma 5B.1, since
x0 + x1 a y0 + y1 a
> ⇐⇒ y2 x0 + y2 x1 a > x2 y0 + x2 y1 a.
x2 y2
The uniqueness of relatively prime x0 , x1 , x2 which satisfy (6A-2) and these
equivalences requires a simple divisibility argument, Problem x6A.1. a

We will sometimes save a few words by referring to (6A-2) as the canonical


representation of x in C (a; h), when 2h 2 < a.
6A.3. Lemma. If x, y ∈ C (a; h), x ≥ y > 0, h ≥ 2 and h 9 < a, then
iq(x, y), rem(x, y) ∈ C (a; h 6 ).
6A. Unary relations from Lin0 [÷] 173

Proof. The hypothesis implies that 2h 2 < a, and so we have canonical


representations
x0 + x1 a y0 + y1 a
x= , y=
x2 y2
of x and y in C (a; h). Suppose
x = yq + r (0 ≤ r < y)
and consider two cases.
y0
Case 1, y1 = 0. Now y = ≤ h, and so
y2
r = rem(x, y) < h.
Solving for q (and keeping in mind that r ∈ N), we have
y 2 h x0 + x1 a i y (x − x r) + x a
2 0 2 1
q = iq(x, y) = · −r = ·
y0 x2 y0 x2
and the (potentially) highest coefficient in this expression is
|y2 x0 − y2 x2 r| ≤ h 2 + h 2 h ≤ 2h 3 ≤ h 4 < h 6 .
Case 2, y1 6= 0. We must now have y1 > 0, otherwise y < 0 by Lemma 6A.2.
Moreover,
2y0 x1 y2 + 2y1 x1 y2 a x0 + x1 a
y · (2x1 y2 ) = > ≥ yq
y2 x2
by the same lemma, because |y2 x1 | < 2|x2 y1 x1 y2 |, and the lemma applies
since (for the potentially largest coefficient),
2|2y1 x1 y2 |2 ≤ 23 h 6 ≤ h 9 < a.
It follows that
q = iq(x, y) ≤ 2x1 y2 ≤ h 3 ,
and then solving the canonical division equation for r, we get
(y2 x0 − x2 y1 q) + (y2 x1 − x2 y1 q)a
r = rem(x, y) = .
x2 y 2
The (potentially) highest coefficient in this expression is
|y2 x0 − x2 y1 q| ≤ h 2 + h 2 h 3 ≤ h 6 . a

6A.4. Lemma. For every m, if


m+2
26 < a and Gm (a) = Gm (N0 [÷], a),
6m
then Gm (a) ⊆ C (a; 2 ).
174 6. Lower bounds from division with remainder
0
Proof is by induction on m, the basis being trivial since 26 = 2 and
m
G0 (a) = {a} ⊆ C (a; 2). For the induction step, set h = 26 to save typing
exponents, and notice that h ≥ 2, and
 m 9 m m+2
h 9 = 26 = 29·6 < 26 < a.
Thus by Lemmas 6A.1 and 6A.3, the value of any operation in Lin0 [÷] with
arguments in C (a; h) is in C (a; h 6 ), and
 m 6 m+1
h 6 = 26 = 26 . a

6A.5. Lemma (Lin0 [÷]-embedding). If Gm (a) = Gm (N0 [÷], a),


m+3
26 < a and a! | (ë − 1),
then there is an embedding
ð : N0 [÷]  Gm (a)  N0 [÷]
such that ð(a) = ëa.
Proof. Set
m+1
h = 26 ,
2
so that from the hypothesis (easily), 2h < a, and then by Lemma 6A.2, each
x ∈ C (a; h) can be expressed uniquely in the form
x0 + x1 a
x=
x2
with all the coefficients ≤ h. We first set
 x + x a  x + x ëa
0 1 0 1
ñ(x) = ñ = (x ∈ C (a; h)).
x2 x2
The values of ñ(x) are all in N, since
x0 + x1 ëa = x0 + x1 a + (ë − 1)x1 a,
so that for any x2 ≤ h ≤ a,
x2 | x0 + x1 ëa ⇐⇒ x2 | x0 + x1 a,
by the hypothesis that a! | (ë − 1). By another appeal to Lemma 6A.2, we
verify that ñ is an injection, and it is order-preserving.
The required embedding is the restriction
ð = ñ  Gm (a),
and the verification that it respects all the operations in Lin0 follows along
familiar lines. For addition, for example, set
m
h1 = 26 ,
6A. Unary relations from Lin0 [÷] 175

and consider canonical representations


x0 + x1 a y0 + y1 a
x= , y=
x2 y2
of two numbers in C (a; h1 ). Adding the fractions, we get
x0 + x1 a y0 + y1 a (y2 x0 + x2 y0 ) + (y1 x1 + x2 y1 )a
x+y = + = ,
x2 y2 x2 y 2
and we notice that the expression on the right is a canonical representation of
x + y in C (a; h), since, with a typical coefficient,
|y2 x0 + x2 y0 | ≤ h15 < h16 = h.
This means that
(y2 x0 + x2 y0 ) + (y1 x1 + x2 y1 )ëa
ð(x + y) = = ð(x) + ð(y),
x2 y 2
as required.
The argument that ð respects the integer quotient and remainder operations
is a bit more subtle, primarily because these are defined together: we need to
show that
if iq(x, y) ∈ Gm (a), then ñ(iq(x, y)) = iq(ñ(x), ñ(y)),
even if rem(x, y) ∈
/ Gm (a), but we cannot define one without the other. This
is why we introduced ñ, which is defined on the larger set C (a; h) ⊇ Gm+1 (a),
and we proceed as follows.
Assume again canonical representations of x and y in C (a; h1 ), and also
that x ≥ y ≥ 1, and consider the correct division equation
x = yq + r (0 ≤ r < y)
as in the proof of Lemma 6A.3. Recall the two cases in that proof.
Case 1, y2 = 0. Now r ≤ h1 , and
(y2 x0 − y2 x2 r) + y2 x1 a
q = iq(x, y) =
x2 y 0
with all the coefficients ≤ h15 < h16 = h, so that this is the canonical represen-
tation of q in C (a; h). It follows that
(y2 x0 − y2 x2 r) + y2 x1 ëa
ñ(r) = r, ñ(q) = ,
x2 y 0
so that, by direct computation,
(6A-3) ñ(x) = ñ(y)ñ(q) + ñ(r).
Moreover, ñ is order-preserving, so
0 ≤ ñ(r) < ñ(y),
176 6. Lower bounds from division with remainder

and (6A-3) is the correct division equation for ñ(x), ñ(y). Thus

ñ(q) = iq(ñ(x), ñ(y)), ñ(r) = rem(ñ(x), ñ(y))),

whether or not iq(x, y) ∈ Gm (a) or rem(x, y) ∈ Gm (a); but if it happens that


iq(x, y) ∈ Gm (a), then

ð(iq(x, y)) = ñ(iq(x, y)) = iq(ñ(x), ñ(y)) = iq(ð(x), ð(y)),

independently of whether rem(x, y) ∈ Gm (a) or not. The same argument


works for ð(rem(x, y)) and completes the proof in this case.
Case 2 is handled in the same way, and we skip it. a
Recall the definition of good examples in Section 5C.
6A.6. Theorem. If R(x) is a good example, then for all a ≥ 2

1
R(a) =⇒ depthR (N0 [÷], a) > log log a.
12
Proof. Suppose R(a), let m = depthR (N0 [÷], a), and assume that
m+3
26 < a.

If ë(ì) is the polynomial which witnesses the goodness of R and

ë = ë(a!),

then Lemma 6A.5 guarantees an embedding

ð : N0 [÷]  Gm (a)  N0 [÷],

with ða = ëa; and since ¬R(ëa), the Homomorphism Test 4E.3 yields a
contradiction, so that
m+3
(6A-4) 26 ≥ a.

Taking logarithms twice, we get from this


log log a
m+3≥ ;
log 6

and since m ≥ 1 by Problem x4E.4, 4m ≥ m + 3, so that we get the required


log log a log log a
m≥ > . a
4 log 6 12
6B. Three results from number theory 177

Problems for Section 6A

x6A.1. Problem. Prove that if x ∈ C (a; h) and 2h 2 < a, then (6A-2)


holds for uniquely determined, relatively prime x0 , x1 , x2 . Hint: By an (easy)
extension of Bezout’s Lemma, Problem x1C.13,
gcd(x0 , x1 , x2 ) = αx0 + âx1 + ãx2 (for some α, â, ã ∈ Z).
Use this and the equivalences in Lemma 6A.2.

6B. Three results from number theory

We review in this section three elementary results from diophantine ap-


proximation, which give us just what we need to establish an analog of the
Lin0 [÷]-Uniqueness Lemma 6A.2 for canonical forms involving two numbers
when these satisfy certain conditions. Those with some knowledge of num-
ber theory know these—in fact they probably know better proofs of them,
which establish more; they should peruse the section quickly, just to get the
terminology that we will be using—especially the definition of difficult pairs
on page 181 which is not standard.
6B.1. Theorem (Pell pairs). The pairs (xn , yn ) ∈ N2 defined by the recursion
(6B-1) (x1 , y1 ) = (3, 2), (xn+1 , yn+1 ) = (3xn + 4yn , 2xn + 3yn )
satisfy Pell’s equation
(6B-2) xn2 − 2yn2 = 1,
and the inequalities
(6B-3) 2n ≤ 2 · 5n−1 ≤ yn < xn ≤ 7n+1 ,
xn √ 1
(6B-4) 0< − 2< .
yn 2yn2
Proof. Equation (6B-2) is true for n = 1, and inductively:
2 2
xn+1 − 2yn+1 = (3xn + 4yn )2 − 2(2xn + 3yn )2 = xn2 − 2yn2 = 1.
For (6B-3), we first check that 2n ≤ 2 · 5n−1 by a trivial induction on n ≥ 1,
and then, inductively again,
yn+1 = 2xn + 3yn ≥ 5yn ≥ 5 · 2 · 5n−1 = 2 · 5n .
The last part of the triple inequality is proved similarly:
xn+1 = 3xn + 4yn ≤ 7xn ≤ 7 · 7n = 7n+1 .
178 6. Lower bounds from division with remainder

The crucial, last inequality (6B-4) holds for any pair of positive numbers
which satisfies Pell’s equation. To see this, suppose x 2 − 2y 2 = 1, and notice
first that since
x2 1
2
= 2 + 2 > 2,
y y
x √
we have > 2, and hence
y
x √ √
+ 2 > 2 2 > 2;
y
now
x √ x √ 1
( − 2)( + 2) = 2
y y y
yields the required
x √ 1 1
0< − 2= x √ < .
y ( y + 2)y 2 2y 2 a

In fact, the pairs (xn , yn ) defined in (6B-1) comprise all positive solutions
of Pell’s equation, cf. Problem x6B.1.
Good approximations of irrationals. A pair of numbers (a, b) (or the proper
a
fraction ) is a good approximation of an irrational number î, if a⊥ ⊥ b and
b
a 1
(6B-5) −î < 2.
b b
Theorem√ 6B.1 asserts in part that there are infinitely many good approxi-
mations of 2. This is true of all irrational numbers, and it is worth under-
standing it in the context of what we are doing, although we will never need it
in its full generality.
6B.2. Theorem (Hardy and Wright [1938] Thm. 188). For every irrational
number î > 0, there are infinitely many pairs (x, y) of relatively prime natural
numbers such that
x 1
î− < 2.
y y
Of the many proofs of this result, we outline one which (according to Hardy
and Wright) is due to Dirichlet.
Proof. For any real number î, let
bîc = the largest natural number ≤ î
be the house of î and î − bîc its fractional part, so that
0 ≤ î − bîc < 1.
6B. Three results from number theory 179

If we divide the half-open (real) unit interval into n disjoint, equal parts,
1 1 2 n−1
[0, 1) = [0, ) ∪ [ , ) ∪ · · · ∪ [ , 1),
n n n n
then for every î, the fractional part î − bîc will belong to exactly one of these
subintervals. Now fix a number
n ≥ 1,
and apply this observation to each of the n + 1 numbers
0, î, 2î, . . . , nî;
at least two of their fractional parts will be in the same subinterval of [0, 1),
so that, no matter what the n ≥ 1, we get
0≤j<k≤n
such that
1
jî − bjîc − (kî − bkîc) < ;
n
and setting y = k − j, x = bkîc − bjîc, we get
1
x − yî < .
n
We may assume that x and y are relatively prime in this inequality, since if we
divide both by gcd(x, y) the inequality persists. Moreover, since 0 < y < n,
we can divide the inequality by y to get
x 1 1
−î < < 2.
y ny y
Notice that if n = 1, then this construction gives y = 1, x = bîc, and the
rather trivial good approximation
bîc 1
− î < 2.
1 1
However, we have not yet used the fact that î is irrational, which implies that
x
0< −î ,
y
so that there is a number
1
m> .
| xy − î|
We now repeat the construction with m instead of n, to get x1 , y1 such that
x1 1 x1 1 1 x
− î < 2 and −î < ≤ < −î ,
y1 y1 y1 my1 m y
180 6. Lower bounds from division with remainder
x1
so that is a better, good approximation of î; and repeating the construction
y1
indefinitely, we get infinitely many, distinct good approximations. a
Next comes the most important result we need, which says, in effect, that
algebraic irrational numbers cannot have “too good” approximations.
6B.3. Theorem (Liouville’s Theorem). Suppose î is an irrational root of an
irreducible (over Q) polynomial f(x) with integer coefficients and of degree
n ≥ 2, and let

c = dsup{|f 0 (x)| | |x − î| ≤ 1}e.

It follows that for all pairs (x, y) of relatively prime integers,


x 1
î− > n.
y cy
In particular, for all relatively prime (x, y),
√ x 1
2− > .
y 5y 2
Proof. We may assume that |î − xy | ≤ 1, since the desired inequality is
trivial in the opposite case. Using the fact that f(î) = 0 and the Mean Value
Theorem, we compute, for any xy within 1 of î,
x x x
|f( )| = |f(î) − f( )| ≤ c|î − |.
y y y
Moreover, f( xy ) 6= 0, since f(x) does not have any rational roots, and y n f( xy )
is an integer, since all the coefficients of f(x) are integers and the degree of
f(x) is n; thus
x x
1 ≤ |y n f( )| ≤ y n c|î − |,
y y
from which we get the desired inequality (noticing that it must be strict, since
î is not rational). √
For the special case î = 2, we have f(x) = x 2 − 2, so that f 0 (x) = 2x
and
√ √
c = dsup{2x | | 2 − x| ≤ 1}e = d2( 2 + 1)e = 5. a

Liouville’s Theorem implies that good approximations of a non-rational alge-


braic number cannot be too well approximated by fractions with a much smaller
denominator. We formulate precisely the special case of this general fact that
we need.
6B. Three results from number theory 181

Difficult pairs. A pair of numbers (a, b) is difficult if a⊥


⊥ b,
(6B-6) 2 ≤ b < a < 2b,
and for all y, z,
b a y 1
(6B-7) 0 < |z| < √ =⇒ − > .
10 b z 10z 2

6B.4. Lemma. (1) Every good approximation of 2 other than 1 is a difficult
pair; in particular, every solution (a, b) of Pell’s equation is a difficult pair.
(2) If (a, b) is a difficult pair, then for all y, z,
b b
(6B-8) 0 < |z| < √ =⇒ |za + yb| > .
10 10|z|

Proof. (1) Let (a, b) be a good approximation of 2 with b ≥ 2. Then
(6B-6) follows from
√ 1 √ 1 a √ 1 √ 1
1 < 2 − ≤ 2 − 2 < < 2 + 2 ≤ 2 + < 2.
4 b b b 4
b
To prove (6B-7), suppose 0 < |z| < √ , and use Liouville’s Theorem 6B.3:
10
a y y √ a √
− ≥ | − 2| − | − 2|
b z z b
1 1 1 1 1
> 2− 2 > 2− = .
5z b 5z 10z 2 10z 2
The result holds for all solutions of Pell’s equation because the proof
of (6B-4) was based only on the hypothesis x 2 = 1 + 2y 2 .
(2) is very useful and easy: assuming the hypothesis of (6B-8),
a y 1 b
|za + yb| = |z|b + > |z|b = .
b z 10z 2 10|z| a
We leave for the problems the similar proof that pairs (Fk+1, Fk ) of successive
Fibonacci numbers with k ≥ 3 are also difficult.

Problems for Section 6B

x6B.1. Problem. Prove that the pairs of numbers (xn , yn ) defined in the
proof of Theorem 6B.1 comprise all the positive solutions of the Pell equation
a 2 = 2b 2 + 1.
Recall from Problem x1C.8 that if
√ √
1+ 5 1− 5
ϕ= , ϕ̂ =
2 2
182 6. Lower bounds from division with remainder

are the two solutions of the quadratic equation x + 1 = x 2 , then


1 < ϕ < 2, ϕ̂ < 0, |ϕ̂| < 1,
and the Fibonacci numbers are explicitly defined in terms of these,
ϕ k − ϕ̂ k
Fk = √ .
5
x6B.2. Problem. Prove that for k ≥ 1,
Fk+1 Fk+1
if k is even, then ϕ < , and if k is odd, then < ϕ.
Fk Fk
Hint: Use the equation
k+1
Fk+1 1 − ϕϕ̂ k+1
= ϕR(k) where R(k) = k
,
Fk 1 − ϕϕ̂ k
and compute the sign and size of R(k) for odd and even k.
x6B.3. Problem. Prove that for all n ≥ 1,
(6B-9) Fn+1 Fn−1 − Fn2 = (−1)n .
Infer that
Fn+1 1
−ϕ < 2 (n ≥ 1).
Fn Fn
x6B.4. Problem. Prove that for every n ≥ 3, the pair (Fn+1 , Fn ) is a difficult
pair.
Hint: The golden mean ϕ is a root of the polynomial f(x) = x 2 − x − 1.
Use Liouville’s Theorem 6B.3 to show that for all coprime x, y,
x 1
−ϕ > ,
y 5y 2

and then imitate the proof of (1) of Lemma 6B.4 with ϕ in place of 2.
The
√ definition of difficult pair is tailor made for the good approximations
of 2, and it is only a coincidence that it also applies to pairs of successive
Fibonacci numbers. It is, however, quite easy to fix the constants hard-wired
in it so that it applies to the good approximations of any quadratic irrational,
and then use it to extend the results in the next section to this more general
case, cf. Problems x6B.5 and x6C.1∗ .
x6B.5. Problem. Suppose î > 1 is irrational, C > 0, a⊥
⊥ b, 2 ≤ b and
1 a 1
(∗) < î− < 2.
Cb 2 b b
Let bîc = M ≥ 1, so that
1 ≤ M < î < M + 1.
6C. Coprimeness from Lin0 [÷] 183

Prove that:
(1) a < (M + 2)b.
(2) For all z, y ∈ Z,
b a y 1 b
0 < |z| < √ =⇒ − > 2
=⇒ |za − yb| > .
2C b z 2Cz 2C |z|
Prove also that for every quadratic irrational î > 1, (∗) holds for infinitely
many coprime pairs a, b.
Beyond this, it is not clear whether the notion (or suitable adaptations of it
to arbitrary algebraic real numbers) has any number-theoretic uses. But it is
exactly what we need for the next, basic result.

6C. Coprimeness from Lin0 [÷]

We can now combine the methods from Sections 5D and 6A, to derive
a double-log lower bound for coprimeness from Lin0 [÷]. The key is the
following Uniqueness Lemma for linear combinations of a difficult pair.
6C.1. Lemma. Suppose (a, b) is a difficult pair, 1 ≤ ë ∈ N, and

b
|x3 yi |, |y3 xi | < √
2 10
for i = 0, 1, 2, 3 with x3 , y3 > 0. Then

x0 + x1 ëa + x2 ëb y0 + y1 ëa + y2 ëb
=
x3 y3
⇐⇒ [y3 x0 = x3 y0 & y3 x1 = x3 y1 & y3 x2 = x3 y2 ],

x0 + x1 ëa + x2 ëb y0 + y1 ëa + y2 ëb
>
x3 y3
⇐⇒ [y3 (x1 a + x2 b) > x3 (y1 a + y2 b)]

or [y3 (x1 a + x2 b) = x3 (y1 a + y2 b)]

& y 3 x0 > x 3 y 0 .

Proof. The claimed equivalences follow from the following two facts, ap-
plied to (y3 x0 − x3 y0 ) + (y3 x1 − x3 y1 )ëa + (y3 x2 − x3 y2 )ëb.

b
(1) If x + zëa + yëb = 0 and |x|, |y|, |z| < √ , then x = y = z = 0.
10
184 6. Lower bounds from division with remainder

Proof. Assume the hypothesis of (1). The case y = z = 0 is trivial, and if


z = 0 and y 6= 0, then

b
b ≤ ë|y|b = |x| < √ ,
10
which is absurd. So we may assume that z 6= 0. Now the assumed bound on
z and (6B-8) implies
b
|zëa + yëb| ≥ |za + yb| > ≥ |x|
10|z|
the last because
√ √
b b b
|xz| ≤ √ √ = ;
10 10 10
and this contradicts the hypothesis |zëa + yëb| = | − x|.

b
(2) If |x|, |y|, |z| < √ , then
10
x + zëa + yëb > 0 ⇐⇒ [za + yb > 0] ∨ [x > 0 & z = y = 0].
Proof. If z = 0, then the equivalence follows from Lemma 5B.1; and if
z 6= 0, then |zëa + yëb| > |x| as above, and so adding x to zëa + yëb cannot
change its sign. a
6C.2. Lemma. Suppose (a, b) is a difficult pair, h ≥ 2, X, Y ∈ C (a, b; h),
and h 28 ≤ b. Then iq(X, Y ), rem(X, Y ) ∈ C (a, b; h 12 ).
Proof. Let us notice immediately that (by a simple computation, using
2 ≤ h) the assumption h 28 ≤ b implies that

2 b
(6C-1) h < √ .
2 10
This allows us to appeal to Lemma 6C.1 in several parts of the argument, and
the more outrageous-looking h 28 ≤ b will be needed for one more, specific
application of the same Lemma. In effect, we just need to assume that h is
sufficiently smaller than b to justify these appeals to Lemma 6C.1, and the
28th power is what makes this particular argument work.
It is enough to prove the result when X ≥ Y > 0, since it is trivial when
X < Y . Suppose
x0 + x1 a + x2 b y0 + y1 a + y2 b
X = , Y = ,
x3 y3
where all |xi |, |yi | ≤ h and x3 , y3 > 0, and consider the correct division
equation
x0 + x1 a + x2 b y0 + y1 a + y2 b
(6C-2) = Q+R (0 ≤ R < Y ).
x3 y3
6C. Coprimeness from Lin0 [÷] 185

We must show that Q, R ∈ C (a, b; h 12 ).


Case 1, y1 a + y2 b = 0. Now (6C-2) takes the form
x0 + x1 a + x2 b y0 y0
= Q + R (0 ≤ R < ),
x3 y3 y3
so that R < h. Solving (6C-2) for Q, we get in this case
y3 (x0 − x3 R) + x1 a + x2 b
(6C-3) Q= ∈ C (a, b; h 4 ).
y0 x3
Case 2, y1 a + y2 b 6= 0. Then y1 a + y2 b > 0, by Lemma 6C.1, since Y > 0,
using (6C-1). We are going to show that in this case
(6C-4) h9Y > X
so that Q ≤ h 9 . Assuming this, we can solve the division equation (6C-2) for
R, to get
(x0 y3 − y0 x3 Q) + (x1 y3 − y1 x3 Q)a + (x2 y3 − y2 x3 Q)b
(6C-5) R= ;
x3 y 3
and from this, easily, R ∈ C (a, b; h 12 ).
We show (6C-4) by separately comparing the “infinite parts” (those involv-
ing a and b) of X and Y with b. Compute first:
(6C-6) y3 (x1 a + x2 b) ≤ |y3 x1 |a + |y3 x2 |b ≤ h 2 2b + h 2 b = 3h 2 b ≤ h 4 b,
using a < 2b. On the other hand, if y2 = 0, then y1 > 0 and so
x3 (y1 a + y2 b) = x3 y1 a > b;
and if y2 6= 0, then by (6B-8),
b
(y1 a + y2 b) > , so that 10|y1 |(y1 a + y2 b) > b,
10|y1 |
and hence (since 10 < 24 ), in either case,
(6C-7) h 5 (y1 a + y2 b) > b.
Now (6C-6) and (6C-7) imply that
h 9 x3 (y1 a + y2 b) > h 4 h 5 (y1 a + y2 b) > h 4 b ≥ y3 (x1 a + x2 b),
and we can finish the proof of (6C-4) with an appeal to Lemma 6C.1, provided
that the coefficients of h 9 Y and X in canonical form satisfy the hypotheses of
this Lemma. For the worst case, the required inequality is

9 b
|x3 h yi | ≤ √ ,
2 10
and it is implied by

b
h 11 ≤ √ ;
2 10
186 6. Lower bounds from division with remainder

if we square this and simplify (using that 40 < 26 ), we see that it follows from
the assumed h 28 ≤ b. a
6C.3. Lemma (Inclusion). Suppose (a, b) is a difficult pair, and for any m,
let Gm (a, b) = Gm (N0 [÷], a, b); it follows that
4m+5 4m
if 22 ≤ a, then Gm (a, b) ⊆ C (a, b; 22 ).
Proof is by induction on m, the case m = 0 being trivial. To apply
Lemmas 6A.1 and 6C.2 at the induction step, we need to verify (under the
hypothesis on a and m) the following two inequalities.
 4m 12 4(m+1)
(1) 22 ≤ 22 . This holds because
 4m 12 4m 4 4m 4(m+1)
22 = 212·2 < 22 ·2 = 22 .
 4m 28
(2) 22 ≤ b. So compute:
 4m 28 4m 5 4m 4m+5
22 = 228·2 < 22 ·2 = 22 ≤ a. a
4m+6
6C.4. Lemma. Suppose (a, b) is a difficult pair, 22 ≤ a, and set ë = 1+a!.
Then there is an embedding
4m
ð : N0 [÷]  C (a, b; 22 )  N0 [÷]
such that ð(a) = ëa, ð(b) = ëb.
Proof. To simplify notation, let
4m
h = 22 .
As in the proof of Lemma 6A.5, we will actually need to define the embedding
on the larger substructure N0 [÷]  C (a, b; h 12 ), so let’s first verify that the
assumed bound on h is good enough to insure unique canonical forms in
C (a, b; h 12 ). By Lemma 6C.1, we need to check that
 2 √
12 b
h < √ ,
2 10
which is equivalent to
(6C-8) 4 · 10h 48 < b;
and this is true, because
 4m 55 6 4m 4m+6
4 · 10h 49 < 22 · 24 h 49 ≤ h 55 = 22 < 22 ·2 = 22 < a,

by the hypothesis, and it yields (6C-8) when we divide both sides by h.


Using Lemma 6C.1 now, we define
ñ : C (a, b; h 12 ) → N,
6C. Coprimeness from Lin0 [÷] 187

in the expected way,


 x + x a + x b  x + x ëa + x ëb
0 1 2 0 1 2
ñ = ,
x3 x3
and we verify as in the proof of Lemma 6A.5 that this is a well-defined, order-
preserving injection, with values in N (since h < a, and so x3 | ë − 1), and it
respects all the operations in Lin0 . We let
ð = ñ  Gm (a, b),
and all that remains is to show that ð respects iq(x, y) and rem(x, y) when
they are defined in Gm (a, b). The key fact is that by Lemma 6C.2 and the
bound on h 12 ,
X, Y ∈ Gm (a, b) =⇒ iq(X, Y ), rem(X, Y ) ∈ C (a, b; h 12 ).
Thus it is enough to show that if
X = YQ + R (0 ≤ R < Y )
is the correct division equation for X, Y , then
(6C-9) ñX = ñY · ñQ + ñR (0 ≤ ñR < ñY )
is the correct division equation for ñX, ñY . We distinguish two cases, following
the proof of Lemma 6C.2.
y0
Case 1, y1 a + y2 b = 0. Then 0 ≤ R < Y = ≤ h, so ñR = R
y3
and ñY = Y . Now ñR < ñY since ñ is order-preserving. The explicit
formula (6C-3) for Q yields
y3 (x0 − x3 R) + x1 ëa + x2 ëb
ñQ = ,
y0 x3
and a direct computation with these expressions for ñR, ñY and ñQ yields
(6C-9).
Case 2, y1 a + y2 b > 0. Now Q ≤ h 9 , which implies ñQ = Q. The explicit
formula (6C-5) for R yields
(x0 y3 − y0 x3 Q) + (x1 y3 − y1 x3 Q)ëa + (x2 y3 − y2 x3 Q)ëb
ñR = ;
x3 y 3
with these expressions for ñR and ñQ we get again (6C-9) by direct computa-
tion. a
6C.5. Theorem (van den Dries and Moschovakis [2004]). For all difficult pairs
(a, b),
1
(6C-10) depth⊥
⊥ (N0 [÷], a, b) > 10 log log a.
188 6. Lower bounds from division with remainder

Proof. Let m = depth⊥


⊥ (N0 [÷], a, b) for some difficult pair (a, b). If
4m+6
22 ≤ a,
then Lemma 6C.4 provides an embedding ð which does not respect coprime-
ness at (a, b) since ða = ëa and ðb = ëb, with some ë. This contradicts the
choice of m, and so
4m+6
22 > a;
in other words
4m + 6 ≥ log log a;
and since m ≥ 1 by Problem x4E.4,
10m ≥ 4m + 6 ≥ log log a,
as required. a
6C.6. Corollary. For every difficult pair (a, b),
1
depthgcd (N0 [÷], a, b) ≥ log log a.
10
Proof. For any U, every embedding ð : U  N0 [÷] which respects
gcd(a, b) also respects a⊥
⊥ b, so
depth⊥
⊥ (N0 [÷], a, b) ≤ depthgcd (N0 [÷], a, b). a

6C.7. Corollary. Pratt’s algorithm is weakly calls-optimal for coprimeness in


N0 [÷].

Proof is immediate from Problem x2E.19. a

This corollary implies that Theorem 6C.5 is best possible (except, of course,
for the specific constant 10), because the absolute lower bound it gives for
all difficult pairs is matched by the Pratt algorithm on pairs of successive
Fibonacci numbers. Note, however, that it does not rule out the possibility
that the Main Conjecture in the Introduction holds for all uniform processes
of Nε , even if we formulate it for coprimeness rather than the gcd—because
it might hold with another, more restrictive or different notion of “difficult
pair” which excludes pairs of successive Fibonacci umbers; in other words, we
may have the wrong proof.
The most exciting possibility would be that the conjecture holds for de-
terministic uniform processes—or just deterministic programs—which would
exhibit the distinction between determinism and nondeterminism in a novel
context. I have no idea whether this holds or how to go about proving it.
6C. Coprimeness from Lin0 [÷] 189

Problems for Section 6C

x6C.1∗ . Problem (van den Dries and Moschovakis [2004], [2009]). For
every quadratic irrational î > 1, there is a rational number r > 0 such
that for all but finitely many good approximations (a, b) of î,
(6C-11) depth(N[÷], ⊥
⊥ , a, b) ≥ r log log a.
Hint: Use Problem x6B.5 to adjust the argument for difficult pairs in this
section.
The O(log log) bound in this problem is best possible, because of Pratt’s
algorithm.
CHAPTER 7

LOWER BOUNDS FROM DIVISION AND


MULTIPLICATION

The arithmetic becomes substantially more complex—and a little algebra


needs to be brought in—when we add both division with remainder and
multiplication to the primitives of Lin0 . We will only derive here lower bounds
for unary functions and relations from
·
Lin0 [÷, ·] = Lin0 ∪ {iq, rem, ·} = {0, 1, =, <, +, − , iq, rem, ·},
leaving the general problem open.

7A. Polynomials and their heights

We review briefly some elementary, basic results about the ring K [T ] of


unary polynomials over a field K , and we also derive some equally simple
facts about the ring Z[T ] of polynomials over the integers.
To fix terminology, a polynomial in the indeterminate (variable) T over a
ring K is a term
X = x0 + x1 T + x1 T 2 + · · · + xn T n ,
where xi ∈ K and xn 6= 0 together with the zero polynomial 0. It is sometimes
useful to think of X as an infinite sum of monomials xi T i , in which xi 6= 0
for only finitely many i; however we do this, the degree of a non-zero X is the
largest power of T which appears in X with a non-zero coefficient, and it is 0
when X = x0 is just an element of K . We do not assign a degree to the zero
polynomial.37
Two polynomials are equal if they are literally identical as terms, i.e., if the
coefficients of like powers are equal.

37 The usual convention is to set deg(0) = −∞, which saves some considerations of cases in

stating results.

191
192 7. Lower bounds from division and multiplication

The sum, difference and product of two polynomials are defined by the
performing the obvious operations on the coefficients and collecting terms:
P
X + Y = i (xi + yi )T i , deg(X + Y ) ≤ max(deg(X ), deg(Y ))
P i
−X = i (−xi )T , deg(−X ) = deg(X )
P  Pi=k 
k
XY = k i=0 xi yk−i T deg(XY ) = deg(X ) + deg(Y ).
The last formula illustrates the occasional usefulness of thinking of a polyno-
mial as an infinite sum with just finitely many non-zero terms.
With these operations, the set K [T ] of polynomials over a ring K is a
(commutative) ring over K . For the more interesting division operation, we
need to assume that K is a field.
7A.1. Theorem (The Division Theorem for polynomials). If K is a field,
and X, Y ∈ K [T ] such that deg(X ) ≥ deg(Y ) and Y 6= 0, then there exist
unique polynomials Q, R ∈ K [T ] such that
(7A-1) X = YQ + R and R = 0 or deg(R) < deg(Y ).
Proof is by induction on the difference d = n − m of the degrees of the
given polynomials, n = deg(X ), m = deg(Y ).
At the basis, if m = n, then
xn
X =Y +R
yn
with R defined by this equation, so that either it is 0 or its degree is less than
xn
n, since X and Y have the same highest term xn T n .
yn
In the induction step, with d = n − m > 0, first we divide X by YT d , the
two having the same degree:
X = YT d Q1 + R1 (R1 = 0 or deg(R1 ) < n).
If R1 = 0 or deg(R1 ) < m, we are done; otherwise deg(R1 ) ≥ deg(Y ) and we
can apply the induction hypothesis to get
R1 = YQ2 + R2 (R2 = 0 or deg(R2 ) < deg(Y )).
We now have
X = Y (T d Q1 + Q2 ) + R2 (R2 = 0 or deg(R2 ) < deg(Y )),
which is what we needed.
We skip the proof of uniqueness, which basically follows from the construc-
tion. a
We call (7A-1) the correct division equation (cde) for X, Y .
This basic fact does not hold for polynomials in Z[T ]: for example, if X = 3
and Y = 2, then there are no Q, R which satisfy (7A-1), simply because 2
does not divide 3 in Z. To get at the results we need, it is most convenient to
7A. Polynomials and their heights 193

work with the larger ring Q[T ], but study a particular “presentation” of it, in
which the concept if height is made explicit.
The height of a non-zero integer polynomial is the maximum of the absolute
values of its coefficients,
height(x0 + x1 T + · · · + xn T n ) = max{|xi | | i = 0, . . . , n} (xi ∈ Z).
To extend the definition to Q[T ], we let for each n, h ∈ N,
nx + x T + x T2 + · · · + x Tn
0 1 2 n
(7A-2) Qn (T ; h) = |
x∗ o
x0 , . . . , xn , x ∗ ∈ Z, x ∗ > 0 and |x0 |, . . . , |xn |, |x ∗ | ≤ h .

This is the set of polynomials in the indeterminate T over Q, with degree n and
height no more than h. When the degree is not relevant, we skip the subscript,
S
Q(T ; h) = n Qn (T ; h);
and in computing heights, it is sometimes convenient to use the abbreviation
X : h ⇐⇒ X ∈ Q(T ; h).
The canonical form (7A-2) gives a unique height(X ) if the coefficients xi
have no common factor with x ∗ , but this is not too important: most of the
time we only care for an upper bound for height(X ) which can be computed
without necessarily bringing X to canonical form. Notice however, that (as a
polynomial over Q),
3 + 2T 1 1
X = = + T,
6 2 3
1
but the height of X is neither 3 nor ; it is 6.
2
It is very easy to make “height estimates” for sums and products of polyno-
mials:
7A.2. Lemma. If X, Y are in Q[T ] with respective degrees n and m and
X : H, Y : h, then
X + Y : 2Hh, XY : (n + m)Hh.
Proof. For addition,
(y ∗ x0 + x ∗ y0 ) + (y ∗ x1 + x ∗ y1 )T + · · ·
X +Y = ,
x∗y ∗
and every term in the numerator clearly has absolute value ≤ 2Hh. For
multiplication,
Pn+m  Pi=k 
k=0 i=0 x i y k−i Tk
XY = .
x∗y∗
194 7. Lower bounds from division and multiplication

For k < n + m, the typical coefficient in the numerator can be estimated by


Pi=k Pi=k
i=0 xi yk−i ≤ i=0 Hh ≤ (k + 1)Hh ≤ (n + m)Hh;

and if k = n + m, then
Pi=n+m
i=0 xi yk−i = |xn ym | ≤ Hh < (n + m)Hh
since xi = 0 when i > n and yj = 0 when j > m. a
The next result is a version of the Division Theorem 7A.1 for Q[T ] which
supplies additional information about the heights.
7A.3. Lemma (Lemma 2.3 of Mansour, Schieber, and Tiwari [1991b]). Sup-
pose X and Y are polynomials with integer coefficients,
deg(X ) = n ≥ m = deg(Y ), X : H, Y : h,
and X = YQ + R with R = 0 or deg(R) < deg(Y ).
Then
Q1 R1
Q= , R= ,
ymd +1 ymd +1
where d = n − m and Q1 , R1 are in Z[T ] with height ≤ H (2h)d +1 . It follows
that
Q, R : H (2h)d +1 .
Proof is by induction on d .
Basis, deg(X ) = deg(Y ) = n. In this case
xn
X =Y +R
yn
with R defined by this equation, so that either it is 0 or it is of degree < n.
xn
Now Q1 = has height ≤ H , and
yn
R 1 = y n X − xn Y
so that the typical coefficient of R1 is of the form yn xi − xn yi , and the absolute
value of this is bounded by 2Hh = H (2h)0+1 .
Induction Step, d = deg(X ) − deg(Y ) = n − m > 0. Consider the
polynomial
(7A-3) Z = ym X − xn YT d
whose degree is < n = m + d since the coefficient of T n in it is ym xn − xn ym .
If Z = 0 or deg(Z) < m, then
xn T d Z xn ymd T d yd Z
X =Y + =Y d +1
+ md +1
ym ym ym ym
7A. Polynomials and their heights 195

is the cde for X, Y , and it follows easily that

Q1 = xn ymd T d : Hh d < H (2h)d +1 ,


R1 = ymd Z = ymd +1 X − xn ymd YT d : H (2h)d +1 .
This proves the lemma for this case. If deg(Z) ≥ m, then the Induction
Hypothesis applies to the pair Z and Y since, evidently,
deg(Z) − deg(Y ) < n − m = d.
Now
height(Z) ≤ hH + Hh = H (2h),
and so the Induction Hypothesis yields
Q2 R2
(7A-4) Z=Y d + d,
ym ym
with
Q2 , R2 : H (2h)(2h)d = H (2h)d +1 .
Solving (7A-3) for X , we get
1 xn d
X = Z+ T Y
ym ym
1  Q2 R 2  xn d
= Y d + d + T Y
ym ym ym ym
Q2 + xn ymd T d R2
= d +1
Y + d +1
ym ym
which is the cde for X, Y . We have already computed that R2 : H (2h)d +1 .
To verify that Q2 + xn ymd T d : H (2h)d +1 , notice that deg(Q2 ) < d , since the
opposite assumption implies with (7A-4) that deg(Z) ≥ m + d = n, which
contradicts the definition of Z; thus the coefficients of Q2 + xn ymd T d are
the coefficients of Q2 and xn ymd , and they all have height ≤ H (2h)d +1 , as
required. a
7A.4. Theorem. If X, Y : h, deg(X ) ≥ deg(Y ) and (7A-1) holds, then
Q, R : (2h)2n+5 .
Proof. Theorem 7A.3 applied to y ∗ X and x ∗ Y (with height ≤ h 2 ) yields
Q R
y ∗X = x∗Y ∗ + ∗
(x ym )d +1 (x ym )d +1
with Q, R : h 2 (2h 2 )d +1 < (2h)2d +4 ; and if we divide by y ∗ , we get that
x∗Q R
X =Y ∗ ∗ + ∗ ∗ ,
y (x ym )d +1 y (x ym )d +1
196 7. Lower bounds from division and multiplication

which is the cde for X, Y , and such that (with d ≤ n)


x∗Q R
, : (2h)2n+5 .
y ∗ (x ∗ y m)
d +1 y ∗ (x ∗ ym )d +1 a

7B. Unary relations from Lin0 [÷, ·]

We establish here suitable versions of Lemma 6A.5 and Theorem 6A.6 for
the structure
·
N0 [÷, ·] = (N0 , Lin0 [÷, ·]) = (N, 0, 1, =, <, +, − , iq, rem, ·)

with a log log bound.
Set, for any a, n, h ∈ N,
n x + x a + x a2 + · · · + x an
0 1 2 n
(7B-1) Qn (a; h) = ∈N
x∗ o
| x0 , . . . , xn , x ∗ ∈ Z, x ∗ > 0 and |x0 |, . . . , |xn |, |x ∗ | ≤ h .

These are the values for T := a of polynomials in Qn (T ; h), but only those
which are natural numbers; and they are the sort of numbers which occur
(with various values of h) in Gm (a) = Gm [(N0 [÷, ·], a). To simplify dealing
with them, we will be using the standard notations
x0 + x1 a + x2 a 2 + · · · + xn a n
(7B-2) x = f(a) = ,
x∗
y0 + y1 a + y2 a 2 + · · · + ym a m
y = g(a) = ,
y∗
where it is assumed that xn , ym 6= 0 (unless, of course, x = 0, in which case,
by convention, n = 0 and x0 = 0). It is also convenient to set xi = 0 for i > n,
and similarly for yj , and to use the same abbreviations we set up for Qn (T ; h),
especially
S
Q(a; h) = n Qn (a; h), x : h ⇐⇒ x ∈ Q(a; h).
7B.1. Lemma. With x and y as in (7B-2), if h ≥ 2 and x, y ∈ Qn (a; h), then
x + y, x −·
y ∈ Qn (a; h 3 ), and xy ∈ Q2n (a; nh 3 ).
Proof. These are all immediate, using Lemma 7A.2. a
The analogous estimates for iq(x, y) and rem(x, y) are substantially more
complex, and we need to establish first the uniqueness of the representa-
tions (7B-2) when h is small relative to a.
7B.2. Lemma. (1) With all xi ∈ Z and a > 2, if |xi | < a for i ≤ n, then
x0 + x1 a + · · · + xn a n = 0 ⇐⇒ x0 = x1 = · · · = xn = 0;
7B. Unary relations from Lin0 [÷, ·] 197

and if, in addition, xn 6= 0, then


x0 + x1 a + · · · + xn a n > 0 ⇐⇒ xn > 0.
(2) With x and y as in (7B-2) and assuming that 2h 2 < a:
x = y ⇐⇒ m = n & (∀i ≤ n)[y ∗ xi = x ∗ yi ],
x > y ⇐⇒ (∃k ≤ n)[(∀i > k)[xi = yi ] & xk > yk ].
In particular,
x > 0 ⇐⇒ xn > 0.
Proof. (1) If xn 6= 0, then

|x0 + x1 a + · · · xn−1 a n−1 | ≤ (a − 1)(1 + a + a 2 + · · · + a n−1 )


an − 1
= (a − 1) = a n − 1 < a n ≤ |xn |a n ,
a−1
and so adding x0 + x1 a + · · · xn−1 a n−1 to xn a n cannot change its sign or yield
0.
(2) follows immediately from (1). a
7B.3. Lemma. Let c ≥ 61, d ≥ 33, and assume that h ≥ 2 and h c(n+1) < a.
If x, y ∈ Qn (a; h) and x ≥ y > 0, then iq(x, y), rem(x, y) ∈ Qn (a; h d (n+1) ).
Proof. How large c and d must be will be determined by the proof, as
we put successively stronger conditions on h to justify the computations. To
begin with, assume
(H1) c ≥ 3, so that 2h 2 ≤ h 3 ≤ h c(n+1) < a,
and Lemma 7B.2 guarantees that the canonical representations of x an y in
Qn (a; h) are unique. By the same lemma,
n = deg(f(T )) ≥ deg(g(T )) = m,
and so we can put down the correct division equation for these polynomials
in Q[T ],

(7B-3) f(T ) = g(T )Q(T ) + R(T )


(R(T ) = 0 or deg(R(T )) < deg(g(T )).
We record for later use the heights from Lemma 7A.4,
(7B-4) Q(T ), R(T ) : (2h)2n+5 ≤ h 4n+10 .
From (7B-3) we get
(7B-5) f(a) = g(a)Q(a) + R(a) (R(a) = 0 or R(a) < g(a)),
198 7. Lower bounds from division and multiplication

where the condition on R(a) is trivial if R(a) ≤ 0, and follows from the
corresponding condition about degrees in (7B-3) by Lemma 7B.2, provided
that the height of R(a) is sufficiently small, specifically
 2
2 h 4n+10 < a;
so here we assume
 2
(H2) c ≥ 21, so that 2 h 4n+10 ≤ hh 8n+20 = h 8n+21 < h 21(n+1) < a.

However, (7B-5) need not be the correct division equation for the numbers
f(a), g(a), because Q(a) might not be integral or R(a) might be negative.
For an example where both of these occur, suppose
f(a) = a 2 − 1, g(a) = 2a with a odd,
in which case (7B-3) and (7B-5) take the form
T a
T 2 − 1 = 2T ( ) − 1, a 2 − 1 = 2a( ) − 1.
2 2
To correct for this problem, we consider four cases.
Case 1, Q(a) ∈ N and R(a) ≥ 0. In this case (7B-5) is the cde for f(a) and
g(a), and from (7B-4),
Q(a), R(a) : h 4n+10 ;
thus we assume at this point
(H3) d ≥ 10, so that h 4n+10 ≤ h d (n+1) .

Case 2, Q(a) ∈ N but R(a) < 0. From (7B-5) we get


f(a) = g(a)[Q(a) − 1] + g(a) + R(a),
| {z }
and we contend that this is the cde for f(a), g(a) in N, if c is large enough.
We must show that
(1) 0 ≤ g(a) + R(a) and (2) g(a) + R(a) < g(a),
and (2) is immediate, because R(a) < 0. For (1), notice that the leading
coefficient of g(T ) + R(T ) is the same as the leading coefficient of g(T )
(because deg(R(T ) < deg(g(T )), and that it is positive, since g(a) > 0. To
infer from this that g(a) + R(a) > 0 using Lemma 7B.2, we must know that
2height(g(a) + R(a))2 < a,
and from Lemma 7B.1,
 2
2height(g(a) + R(a))2 ≤ h (h 4n+10 )3 = h 24n+61 ,
7B. Unary relations from Lin0 [÷, ·] 199

and so for this case we assume that


(H4) c ≥ 61, so that h 24n+61 ≤ h c(n+1) < a.
Using Lemma 7B.1, easily (and overestimating again grossly)
Q(a) − 1, g(a) + R(a) : (h 4n+10 )3 = h 12n+30 ≤ h 30(n+1) ;
and so we also assume
(H5) d ≥ 30, so that h 30(n+1) ≤ h d (n+1) .

Q1 (a)
Case 3, Q(a) = / N, and Q1 (a) ≥ z > 1. We note that

z
Q1 (a) : h 4n+10 , z ≤ h 4n+10 ,
and both Q1 (a) and z are positive, and so we can put down the cde for them
in N:
Q1 (a) = zQ2 + R2 (0 < R2 < z),
where we know that R2 > 0 by the case hypothesis. From this it follows that
Q1 (a) − R2  4n+10 3
R2 < z ≤ h 4n+10 , and Q2 = : h = h 12n+30
z
by Lemma 7B.1 again. Replacing these values in (7B-5), we get
R2
(7B-6) f(a) = g(a)Q2 + g(a) + R(a)
| z {z }
and the number above the underbrace is in Z, as the difference between two
numbers in N. This number is the value for T := a of the polynomial
R2
g(T ) + R(T )
z
whose leading coefficient is that of g(T )—since deg(R(T )) < deg(g(T ))—
and hence positive. We would like to infer from this that
R2
g(a) + R(a) > 0,
z
using Lemma 7B.2, and so we make sure that its height is suitably small.
From the two summands, the second has the larger height, h 4n+10 , and so by
Lemma 7B.1, the height of the sum is bounded by

h 4n+10 )3 = h 12n+30 ;

and to apply Lemma 7B.2, we must insure that


2(h 12n+30 )2 = 2h 24n+60 < a,
200 7. Lower bounds from division and multiplication

and so for this step we assume that


(H6) c ≥ 61, so that 2h 24n+60 ≤ h 24n+61 ≤ h c(n+1) .
This number is also less than g(a), again because its leading coefficient is
R2
that of g(a) multiplied by < 1. It follows that this is the correct division
z
equation for f(a), g(a), so it is enough to compute the height of the quotient
(above the underbrace) since we have already computed that
Q2 : h 12n+30 ≤ h 30(n+1) ;
using the known heights on g(a), R2 , z and R(a), it is easy to check that
R2
g(a) + R(a) : ((h)4n+11 )3 = h 12n+33 ,
z
so at this point we assume that
(H7) d ≥ 33, so that h 12n+30 , h 12n+33 ≤ h d (n+1) .
Q1 (a)
Case 4, Q(a) = / N, and Q1 (a) < z. Since Q1 (a) > 0, this case

z
hypothesis implies that deg(Q1 (T )) = 0, so that deg(f(T )) = deg(g(T )). By
now familiar arguments, this means that
y ∗ xn
f(a) ≤ ∗ g(a)
x yn
and so the quotient of these two numbers is some number
y ∗ xn
Q ≤ ∗ ≤ h 2.
x yn
Thus (7B-5) takes the form
f(a) = g(a)Q + R with 0 ≤ Q ≤ h 2 ,
from which it follows immediately that
R = f(a) − g(a)Q : (h 5 )3 = h 15 ,
and the hypotheses we have already made on d insure h 15 ≤ h d (n+1) , so that
we need not make any more.
In fact then, the lemma holds with
c ≥ 61, d ≥ 33. a
7B.4. Lemma (Lin0 [÷, ·]-embedding). Let e = 61 and for any m,
Gm (a) = Gm (N0 [÷, ·], a).
e(m+1)2 em 2
(1) If 22 < a, then Gm (a) ⊆ Q2m (a; 22 ).
e(m+2)2
2
(2) If 2 < a and a! | (ë − 1), then there is an embedding
ð : N0 [÷, ·]  Gm (a)  N0 [÷, ·]
7B. Unary relations from Lin0 [÷, ·] 201

such that ð(a) = ëa.


Proof of (1) is by induction on m, the basis being trivial. To apply Lem-
mas 7B.1 and 7B.3 at the induction step, we need the inequalities
 em2 3 e(m+1)2
 em2 61(2m +1)
2m 22 ≤ 22 , 22 < a,
 em2 33(2m +1) e(m+1)2
22 ≤ 22 ,
and these are easily verified by direct computation.
(2) is proved very much like Lemma 6C.4, the only subtlety being that we
need to start with an injection
ñ : Gm+1 (a)  N
on the larger set, which (by (1)) contains iq(x, y) and rem(x, y) for all x, y ∈
Gm (a). The stronger hypothesis on m and a imply that the numbers in
Gm+1 (a) have unique canonical forms in
e(m+1)2
Q2m+1 (a; 22 );
m
and so we can set (with n = 2 )
 x + x a + · · · x a n  x + x ëa + · · · x ëa n
0 1 n 0 1 n
ñ = ,
x∗ x∗
take ð = ñ  Gm (a) and finish the proof as in Lemma 6C.4. a
7B.5. Theorem. (Mansour, Schieber, and Tiwari [1991b], van den Dries
and Moschovakis [2009]). If R(x) is a good example, then for all a ≥ 2
1p
R(a) =⇒ depthR (N0 [÷, ·], a) > log log a.
24
Proof. By the Homomorphism Test 4E.3 and the preceding Lemma, we
know that if m = depthR (N0 [÷, ·], a), then
e(m+2)2
22 > a,
with e = 61. Taking logarithms twice, then the square root and finally using
the fact that 3m ≥ m + 2 by Problem x4E.4, we get the required
r
log log a 1p
3m ≥ m + 2 ≥ ≥ log log a,
e 8
√ √
the last step justified because e = 61 < 8. a
Mansour, Schieber, and Tiwari [1991b] √ express their results using specific
computation models and they establish O( log log a) lower bounds for deci-
sion trees and RAMS, for a class of unary relations which includes square-free;
Meidânis [1991] derives a similar lower bound for primality. The methods used
202 7. Lower bounds from division and multiplication

in these papers are very different from the direct applications of the Embed-
ding Test that we have been using, which makes it very difficult to compare
their results with ours.
As we mentioned in Footnote 34 on page 146, Mansour, Schieber, and
Tiwari [1991b] also derive (for their models) a triple-log lower bound for
coprimeness from Lin0 [÷, ·] on infinitely√many inputs, and van den Dries has
proved (using output complexity) an O( log log)-lower bound for computing
gcd(x, y) on infinitely many inputs. We list as an open problem what would
be the best (intrinsic) relevant result.

Problems for Section 7B

x7B.1. Open problem. Prove that for some infinite set of pairs A ⊂ N × N
and some r > 0,
q
(a, b) ∈ A =⇒ depth⊥
⊥ (N 0 [÷, ·], a, b) > r log log max(a, b).
CHAPTER 8

NON-UNIFORM COMPLEXITY IN N

A computer has finite memory, and so it can only store and operate on a finite
set of numbers. Because of this, complexity studies which aim to be closer to
the applications are often restricted to the analysis of algorithms on structures
with universe the finite set
[0, 2N ) = {x ∈ N : x < 2N }
of N -bit numbers for some fixed (large) N , typically restrictions to [0, 2N ) of
expansions of Nd or N0 , e.g., N0 [÷], N0 [÷, ·], etc. The aim now is to derive
lower bounds for the worst case behavior of such algorithms as functions of
N ; and the field is sometimes called non-uniform complexity theory, since, in
effect, we allow for each N the use of a different algorithm which solves a
given problem in A  [0, 2N ).
For each structure A = (N, Υ) with universe N, each relation R ⊆ Nn and
each N , let
n o
(8-7) depthR (A, 2N ) = max depthR (A  [0, 2N ), x ~ ) : x1 , . . . , xn < 2N

and similarly for valuesR (A, 2N ), callsR (A, 2N ). These are the intrinsic (worst
case) non-uniform bit complexities of R from the primitives of A, at least those
of them for which we can derive lower bounds. As it turns out, the results
and the proofs are essentially the same for Nd , except for the specific con-
stants which are now functions of N (and somewhat smaller). For N0 [÷]
and N0 [÷, ·], however, we need a finer analysis and we can only derive lower
bounds for the larger complexity valuesR (A, 2N ), primarily because there is
“less room” in [0, 2N ) for embeddings which exploit the uniformity assump-
tion in the definition of intrinsic complexities. It is this new wrinkle in the
proofs that is most interesting in this brief chapter.

8A. Non-uniform lower bounds from Lind

We will show here that the intrinsic lower bounds from Lind of Chap-
ter 5 hold also in the non-uniform case, with somewhat smaller constants.

203
204 8. Non-uniform complexity in N

This means (roughly) that for these problems, the lookup algorithm in Prob-
lem x8A.1 is weakly optimal for depth intrinsic bit complexity in Nd .
8A.1. Theorem (van den Dries and Moschovakis [2009]). If N ≥ 3, then
N
depthPrime (Nd , 2N ) > .
5 log d
Proof. Suppose p < 2N is prime and let
m = depthPrime (Nd  [0, 2N ), p), ë = 1 + d m+1 .
If
x0 + x1 ëp
(a) d 2m+2 < p and (b) < 2N for all |x0 |, |x1 | ≤ d 2m ,
dm
then the proof of Lemma 5B.2 would produce an embedding
ð : Gm (Nd  [0, 2n ), p)  Nd  [0, 2N )
which does not respect the primality of p, yielding a contradiction. So for
every prime p < 2N , one of (a) or (b) must fail. To exploit this alternative,
we need to apply it to primes not much smaller than 2N , but small enough so
that (b) holds, and to find them we appeal to Bertrand’s Postulate, Hardy and
Wright [1938, Theorem 418]; this guarantees primes between l and 2l when
l ≥ 3. So choose p such that
2N −1 < p < 2N ,
which exists because 2N −1 > 3 when N ≥ 3.
Case 1, d 2m+2 ≥ p, and so d 2m+2 > 2N −1 . Using as always the fact that
N
m ≥ 1, this gives easily m > 5 log d.

Case 2, for some x0 , x1 with |x0 |, |x1 | ≤ d 2m , we have


x0 + x1 (1 + d m+1 )p
≥ 2N .
dm
Compute (with m ≥ 1):

x0 + x1 (1 + d m+1 )p d 2m + d 2m (1 + d m+1 )2N


m
<
d dm
< d + d m d m+2 2N ≤ d 2m+3 2N ≤ d 5m 2N
m

N
and so the case hypothesis implies that m > 5 log d again, as required. a
Similar mild elucidations of the proofs we have given extend all the lower
bound results about Nd in Chapter 5 to intrinsic bit complexity, and they are
simple enough to leave for the problems.
8B. Non-uniform lower bounds from Lin0 [÷] 205

Problems for Section 8A

x8A.1. Problem (The lookup algorithm). If n ≥ 1, then every n-ary rela-


tion R on N can be decided for inputs x1 , . . . , xn < 2N by an explicit Nb -term
E N (~
x ) of depth ≤ N . It follows that
depthR (Nb , 2N ) ≤ N.
Hint: Set Eqi (x) ⇐⇒ x = i, prove that this relation is defined by an Nb -
term of depth ≤ N when i < 2N and build (by induction on N ) a “table” of
data from which a decision procedure for any relation on [0, 2N ) can read-off.
Recall the definition of good examples in Subsection 5C.
x8A.2. Problem (van den Dries and Moschovakis [2009]). Suppose R is a
good example such that for some k and all sufficiently large m, there exists
some x such that
R(x) & 2m ≤ x < 2km .
Prove that for all d ≥ 2 there is some r > 0 such that for sufficiently large N ,
depthR (Nd , 2N ) > rN,
and verify that all the good examples in Problem x5C.4 satisfy the hypothesis.
x8A.3. Problem (van den Dries and Moschovakis [2009]). Prove that for some
r > 0 and all sufficiently large N ,
N
depth⊥
⊥ (Nd , 2 ) > rN.

8B. Non-uniform lower bounds from Lin0 [÷]

The methods of the preceding section do not extend immediately to N0 [÷],


because the constant ë = 1 + a! that we used in the proof of Lemma 6A.5 is
too large: a direct adaptation of that proof to the non-uniform case leads to a
log log N lower bound for depthPrime (N0 [÷], 2N ) which is way too low. In fact,
it does not seem possible to get a decent lower bound for depthPrime (N0 [÷], 2N )
with this method, but a small adjustment yields a lower bound for the values-
and hence the calls- intrinsic bit complexities.
We start with the required modification of Lemma 6A.5.
8B.1. Lemma. Suppose U ⊆p N0 [÷] is generated by a, m = depth(U, a),
m+3 m+2
and í = values(U, a). If 26 < a, then there is a number ë ≤ 2í6 and an
embedding ð : U  N0 [÷] such that ð(a) = ëa.
206 8. Non-uniform complexity in N

Proof. As in the proof of Lemma 6A.5, the assumed inequality on m


implies that each x ∈ U ⊆ Gm (N0 [÷], a) can be expressed uniquely as a
proper fraction of the form
x0 + x1 a m+1
(8B-1) x= (|xi | ≤ 26 ),
x2
and we can set
m+1
denom(x) = the unique x2 ≤ 26 such that (8B-1) holds (x ∈ U ).
We claim that the conclusion of the lemma holds with
Q Q
(8B-2) ë = 1 + x∈U denom(x) = 1 + x∈U,x6=a denom(x)
 m+1 í m+2
≤ 1 + 26 < 2í6 ,

where the two products are equal because denom(a) = 1 and values(U, a) =
|U | − 1. To prove this we follow very closely the proof of Lemma 6A.5: we set
 x + x a  x + x ëa
0 1 0 1
ñ(x) = ñ = ;
x2 x2
check that this is a well defined injection on U which takes values in N, because
x ∈ U =⇒ denom(x) | (ë − 1);
and finally verify that it is an embedding from U to N0 [÷] exactly as in the
proof of Lemma 6A.5. a
8B.2. Theorem (van den Dries and Moschovakis [2009]). If N ≥ 8, then
1
(8B-3) valuesPrime (N0 [÷], 2N ) > log N.
10
Proof. Let k = b N2 c − 1 so that
N N
k+1≤ < k + 2 and so k > − 2.
2 2
The hypothesis on N yields 2k > 4, so Bertrand’s Postulate insures that there
exists some prime p such that 2k < p < 2k+1 . This is the prime we want. Let
A = N0 [÷]  [0, 2N ) (to simplify notation) and choose U ⊆p A so that
A
U c Prime(p), valuesPrime (A, p) = values(U, p),
and set m = depth(U, p). (It could be that m > depthPrime (A, p).) Let
Q Q
ë = 1 + x∈U denom(x) = 1 + x∈U,x6=p denom(x)
as above. If
m+3 x0 + x1 ëp m+1
26 < p and < 2N whenever |xi | ≤ 26 ,
x2
8B. Non-uniform lower bounds from Lin0 [÷] 207
m+2
then ë < 2í6 and the argument in the proof of Lemma 8B.1 produces an
embedding ð : U  A which does not respect the primality of p, contrary to
the choice of U; so one of the two following cases must hold.
m+3
Case 1: 26 ≥ p > 2k . This gives 6m+3 > k > N2 − 2, and this easily
implies (with m ≥ 1) that í ≥ m > log10N in this case, cf. Problem x8B.1.
m+1
Case 2: For some x0 , x1 , x2 with |xi | ≤ 26 ,
x0 + x1 ëp
≥ 2N .
x2
Compute:
x0 + x1 ëp m+1 m+1 m+2 N m+1 m+2 N
≤ 26 + 26 · 2í6 · 2 2 ≤ 2 · 26 +í6 · 2 2
x2
m+2 N m+2 N
≤ 22í6 +1
· 2 2 ≤ 23í6 ·22.
m+2 N
So the case hypothesis gives 23í6 · 2 2 ≥ 2N which gives 3í6m+2 ≥ N2 and
then í6m+3 ≥ N . This is the basic fact about the non-uniform, intrinsic bit
·
complexity of primality from {=, <, +, − , iq, rem} and it can be used to derive
a lower bound for the measure induced by the substructure norm
ì(U, a) = values(U, a) · 6depth(U,a)+3 .
To derive an easier to understand lower bound for the values complexity,
we compute: 6í 6í+3 ≥ í6m+3 ≥ N ; so 62í+3 ≥ N ; so (2í + 3) log 6 ≥ log N ,
and since í > 0, as usual, 5í ≥ 2í + 3 and so
1 1
í≥ log N > log N. a
5 log 6 10

It should be clear that the numerology in this proof was given in detail
mostly for its amusement value, since from the first couple of lines in each
of the cases one sees easily that í > r log N for some r. Moreover, one
1
can certainly bring that 10 up quite a bit, with cleverer numerology, a more
judicious choice of p, or by weakening the result to show that (8B-3) holds
only for very large N . The problems ask only for these more natural (if slightly
weaker) results and leave it up to the solver whether they should indulge in
manipulating numerical inequalities.

Problems for Section 8B


N
x8B.1. Problem. Prove that if m ≥ 1, N ≥ 1 and 6m+3 > 2 − 2, then
m > log10N . Hint: Check that 66m ≥ 65m+1 > 2 · 6m+3 + 4 > N .
208 8. Non-uniform complexity in N

x8B.2. Problem. Suppose R is a good example with the property that for
some k and every m ≥ 1, there is some x such that R(x) and
m km
26 < x < 26 .
Prove that for some r > 0 and sufficiently large N ,
valuesR (N[÷], 2N ) > r log N.
Verify also that the good examples in Problem x5C.4 satisfy the hypothesis.
x8B.3. Problem (van den Dries and Moschovakis [2009]). Prove that for some
r > 0 and all sufficiently large N ,
N
values⊥
⊥ (N[÷], 2 ) > r log N.
√ N
Hint: Use the largest good approximation (a, b) of 2 with a < 2 2 .
x8B.4. Open problem. Prove that for some r > 0 and all sufficiently large N ,
N
depth⊥
⊥ (N[÷], 2 ) > r log N.
x8B.5. Problem. Derive a lower bound for valuesR (Lin0 [÷, ·], 2N ) when R
is a good example or ⊥
⊥.
CHAPTER 9

POLYNOMIAL NULLITY (0-TESTING)

The complexity of polynomial evaluation


(9-4) VF (x0 , . . . , xn , y) = x0 + x1 y + · · · + xn y n
in a field is perhaps the simplest problem in algebraic complexity and it has
been much studied since its formulation by Ostrowski [1954]. Our (limited)
aim in this chapter is to prove some intrinsic lower bound results about the
(plausibly simpler) nullity (or 0-testing) relation
(9-5) NF (z, x1 , . . . , xn , y) ⇐⇒ z + x1 y + · · · + xn y n = 0,
all of them establishing the intrinsic Calls-optimality of Horner’s rule from
various primitives on generic inputs; the upper bounds on these complexities
are listed in Problem x4E.6∗ .38
Recall from the discussion on page 25, that “officially” a field F is a structure
F = (F, 0, 1, +, −, ·, ÷, =)
satisfying the standard axioms. It is a partial structure, because x ÷ 0 is not
defined; and we will usually talk of a field F rather than F, using the structure
notation only when it is important, for example when we need to refer to
partial substructures U ⊆p F which are not fields.

9A. Preliminaries and notation

For any field F and indeterminates u~ = u1 , . . . , uk , F [~


u ] is the ring of all
polynomials with coefficients in F and F (~
u ) is the field of all rational functions
in u~ with coefficients in F . The terms in a sequence a~ = (a1 , . . . , ak ) in
some field K ⊃ F are algebraically independent (or generic) over F , if for all
x1 , . . . , x k ∈ F ,
x1 a1 + x2 a2 + . . . + xk a k = 0 =⇒ (x1 = . . . = xk = 0);

38 I am grateful to Tyler Arant for checking and correcting many errors in the first draft of this

chapter; and, of course, I am fully responsible for the inevitable remaining errors.

209
210 9. Polynomial nullity (0-testing)
and in that case, the extensions F [~ a ], F (~
a ) ⊆ K are naturally isomorphic
with F [~
u ] and F (~
u ) respectively by the relabelling isomorphism determined by
ai 7→ ui , for i = 1, . . . , k. Similarly, if K1 , K2 ⊃ F and a~ ∈ K1n , ~b ∈ K2n
are algebraically independent over F , then the relabelling ai 7→ bi induces an
isomorphism
ë : F (~ → F (~b)
a)  (ë(ai ) = bi , i = 1, . . . n)
a ] and F [~b]. We will
which fixes F , and similarly for the polynomial rings F [~
often establish some facts about one of these rings or fields and then quote
them for the other, often without explicit mention, and we will also use the
same terminology for these isomorphic structures: if, for example, a, b are
complex numbers which are algebraically independent (over the prime field
Q), then the members of Q(a, b) are “the rational functions of a, b”.
A partial ring homomorphism
ð : F1 * F2
on one field to another is a partial function whose domain of convergence
Domain(ð) is a subring R1 of F1 (with 1) and which respects as usual the ring
operations, including ð(1) = 1. Notice that for every U ⊆p F1 ,
 
(9A-1) if ð is total on U and 0 6= x ∈ U =⇒ ð(x) 6= 0 ,
then ð  U : U → F2 is a homomorphism,
i.e., ð  U preserves not only the ring operations, but also all divisions in
eqdiag(U). This is because if (÷, u, v, w) ∈ eqdiag(U), then ð(u), ð(v), ð(w)
are all defined and v 6= 0, so ð(v) 6= 0 by the hypothesis of (9A-1); and since
vw = u, we have ð(v)ð(w) = ð(u), which then gives ð(w) = ð(u) ð(v)
.
If F (v, u~ ) ⊆ K for some field K and α ∈ K , then the substitution v 7→ α
induces a partial ring homomorphism
 ÷ (v, u~ )  ÷ (α, u~ )  ÷ (v, u~ ) 
n n n
(9A-2) ñα = ∈ F (v, u~ )
÷d (v, u~ ) ÷d (α, u~ ) ÷d (v, u~ )
with
n ÷ (v, u~ ) o
n
Domain(ñα ) = : ÷d (α, u~ ) 6= 0 ⊆ F (v, u~ ).
÷d (v, u~ )
Notice that F [v, u~ ] ⊂ Domain(ñα ) and ñα (ui ) = ui . We will sometimes call
ñα “the substitution” (v 7→ α), and the only homomorphisms we will need
are compositions of such substitutions.
9A.1. The Substitution Lemma. Suppose F, K are fields, v, u~ are indetermi-
nates, U is a finite subset of F (v, u~ ), K ⊇ F (v, u~ ) and {αt }t∈I is an infinite
set of distinct elements of K . It follows that for all but finitely many t ∈ I , the
9B. Generic {·, ÷}-optimality of Horner’s rule 211

partial ring homomorphism ñt : F * K induced by the substitution v 7→ αt is


total and injective on U .
Proof. It is convenient to prove first a
Sublemma. If U 0 ⊂ F [v, u~ ] is any finite set of polynomials, then for all but
finitely many t ∈ I ,
 
÷(v, u~ ) ∈ U 0 and ÷(v, u~ ) 6= 0 =⇒ ÷(ñt (v), u~ ) 6= 0.
Proof of the Sublemma. Write each ÷(v, u~ ) ∈ U 0 as a polynomial in v,
÷(v, u~ ) = ÷0 (~
u ) + ÷1 (~ u )v l ,
u )v + · · · + ÷l (~
so that if a1 , . . . , ak are its roots in K , then
÷(v, u~ ) = (v − a1 ) · · · (v − ak )φ(v, u~ ) (φ(v, u~ ) 6= 0, for all v ∈ K ).
Now ñt (÷(v, u~ )) = (αt − a1 ) · · · (αt − al )φ(αt , u~ ), and this can only be 0 if
αt = ai for some i. The conclusion then holds for any t such that αt is not a
root ai in K of a non-0 polynomial in U 0 . a (Sublemma)
We now fix a specific representation of the form
÷n (v, u~ )
(9A-3) ÷(v, u~ ) = (÷d (v, u~ ) 6= 0)
÷d (v, u~ )
for each ÷(v, u~ ) ∈ U , and we apply this sublemma to the finite set U 0 com-
prising all polynomials in one of the forms
(i) ÷d (v, u~ ), (ii) ÷n (v, u~ )÷d0 (v, u~ ) − ÷n0 (v, u~ )÷d (v, u~ )
with ÷(v, u~ ), ÷ 0 (v, u~ ) ∈ U . a

9B. Generic {·, ÷}-optimality of Horner’s rule

Several versions of the {·, ÷}-optimality of Horner’s rule for polynomial


evaluation were proved by Pan [1966], who established his result for algorithms
expressed by computation sequences (page 91) and introduced the method of
substitution, i.e., the use of partial ring homomorphisms induced by substitu-
tions as above.
9B.1. Theorem (Bürgisser and Lickteig [1992]).39 If F is a field of charac-
teristic 0, n ≥ 1, and z, x1 , . . . , xn , y ∈ F are algebraically independent (over
Q), then (with x~ = x1 , . . . , xn ),
(9B-1) calls(·, ÷)(F, NF , z, x
~ , y) = n.
In particular, (9B-1) holds for the reals R and the complexes C with alge-
braically independent z, x
~ , y.
39 The proof in Bürgisser and Lickteig [1992] is for algebraic decision trees, what we called

primitive decision trees for fields on page 91.


212 9. Polynomial nullity (0-testing)
This follows from the upper bounds in Problem x4E.6∗ , the Homomorphism
Test 4E.3 and the following
9B.2. Lemma. If F is a field of characteristic 0, n ≥ 1, z, x ~ , y are alge-
braically independent, U ⊆p F is finite, generated by (U ∩ Q) ∪ {z, x~ , y} and
calls(·, ÷)(U, z, x
~ , y) < n,
then there is a partial ring homomorphism ð : F * F which is the identity on
Q(y), it is total and injective on U , and it satisfies
ð(z) + ð(x1 )y 1 + · · · + ð(xn )y n = 0.
We will derive this from a substantially stronger result which is shown by
induction on n; the appropriate lemma is an elaboration of the construction
in Winograd [1967], [1970], which extends and generalizes Pan’s results.
For U ⊆p F(z, x~ , y), we will denote entries in eqdiag(U) using infix notation,
a + b = c for (+, a, b, c), a · b = c for (·, a, b, c), etc. We write {·, ÷} for
multiplications and divisions, and we define the trivial {·, ÷} (with respect to
y) by the following rules:
a · b = c is trivial if a ∈ F or b ∈ F or a, b ∈ F (y);
a ÷ b = c is trivial if b ∈ F or a, b ∈ F (y).
All additions, subtractions and inequations in F(z, x ~ , y) are also trivial.
9B.3. Lemma. Suppose F is an infinite field, n ≥ 1, z, x ~ = x1 , . . . , xn , y are
indeterminates, U ⊆p F(z, x ~ , y) is finite, ø1 , . . . , øn ∈ F (y) and the following
conditions hold :
(1) U is generated by (F ∩ U ) ∪ {z, x ~ , y}.
(2) For any f1 , . . . , fn ∈ F ,
f1 ø1 + · · · + fn øn ∈ F =⇒ f1 = · · · = fn = 0.
(3) There are no more than n − 1 non-trivial {·, ÷} in eqdiag(U).
Then there is a partial ring homomorphism
ð : F (z, x
~ , y) * F (~
x , y)
which is the identity on F (y), it is total and injective on U , and it satisfies
(9B-2) ð(z) = ð(x1 )ø1 + · · · + ð(xn )øn .
It follows that ð  U : U  F(~
x , y) is an embedding which satisfies (9B-2).
Proof is by induction on n, but it is useful to consider first a case which
covers the basis and also arises in the induction step.
Preliminary case: there are no non-trivial {·, ÷} in U. It follows that every
X ∈ U is uniquely of the form
P
(9B-3) X = f0 z + 1≤i≤n fi xi + φ(y)
9B. Generic {·, ÷}-optimality of Horner’s rule 213

with fi ∈ F, φ(y) ∈ F (y). If ð is the partial ring homomorphism induced by


the substitution
P
z 7→ 1≤i≤n xi øi ,
then ð is the identity on F (~x , y) and it is total on U , because the only divisions
in eqdiag(U) are with both arguments in F (y) or the denominator in F . So it is
enough to check that it is injective on the set of all elements of the form (9B-3)
and that it satisfies (9B-2).
To check injectivity, suppose that
P  P
ð(X ) = f0 1≤i≤n xi øi + 1≤i≤n fi xi + φ(y)
P  P
= f00 1≤i≤n x i ø i + 1≤i≤n fi0 xi + φ 0 (y) = ð(X 0 )

so that
P P
(f0 − f00 ) xi øi + 1≤i≤n (fi − fi0 )xi + (φ(y) − φ 0 (y))
1≤i≤n
P  
= 1≤i≤n (f0 − f00 )øi + (fi − fi0 ) xi + (φ(y) − φ 0 (y)) = 0.

This yields φ(y) = φ 0 (y) and for each i, (f0 − f00 )øi + (fi − fi0 ) = 0; and
since no øi is in F by (2) of the hypothesis, this implies that f0 = f00 , and
finally that fi − fi0 for each i.
The identity (9B-2) is trivial because ð(z) = x1 ø1 + · · · + xn øn and ð(xi ) =
xi .
Basis, n = 1. This is covered by the preliminary case.
Induction Step, n > 1. If the preliminary case does not apply, then there
is at least one non-trivial {·, ÷} in eqdiag(U); so there is a least m > 0 such
that some ÷ ∈ Gm (U, z, x ~ , y) is a non-trivial product or quotient of elements
of Gm−1 (U, z, x~ , y) in which all {·, ÷} are trivial; and so there is at least one
non-trivial {·, ÷} in eqdiag(U) of the form
P P
(9B-4) (f00 z + 1≤i≤n fi0 xi + φ 0 (y)) ◦ (f0 z + 1≤i≤n fi xi + φ(y)) = ÷
where ◦ is · or ÷. We consider cases on how this can arise.
Case 1: There is some i ≥ 1 such that fi 6= 0, and the first factor in (9B-4) is
not in F . We assume without loss of generality that f1 6= 0, and then dividing
the equation by f1 we put the second factor in the form
P
(9B-5) f0 z + x1 + 2≤i≤n fi xi + φ(y).

By the Substitution Lemma 9A.1, there is some f ∈ F such that the substitu-
tion
P
ñ1 (x1 ) = f − f0 z − 2≤i≤n fi xi − φ(y)
214 9. Polynomial nullity (0-testing)
induces an isomorphism
ñ1  U : U 
→ ñ1 [U] = U1 ⊆p F(z, x2 , . . . , xn , y).
Notice that ñ1 does not introduce any new non-trivial multiplication or divi-
sion (because it is the identity on F (y)), and it turns the chosen operation in
U into a trivial one since
P
ñ1 (f0 z + x1 + 2≤i≤n fi xi + φ(y)) = f.
So there are fewer than n − 1 {·, ÷} in eqdiag(U1 ), and U1 is generated by
z, x2 , . . . , xn , y and {f} ∪ (F ∩ U ).
Applying Lemma 9A.1 again, fix some g ∈ F such that the substitution
1  
ñ2 (z) = (f − φ(y))ø1 + gz
1 + f0 ø1
induces an isomorphism
ñ2  U1 : U1 
→ ñ2 [U1 ] = U2 ⊆p F(z, x2 , . . . , xn , y).
This too does not introduce any non-trivial multiplications or divisions, and
U2 is generated by z, x2 , . . . , xn , y and F ∩ U2 . The required partial ring
homomorphism is the composition
ð = ó ◦ ñ2 ◦ ñ1 : F (z, x
~ , y) * F (~
x , y)
of the three substitutions, where ó is guaranteed by the induction hypothesis
so that ó  U2 : U2  F(x2 , . . . , xn , y) and
P
gó(z) = 2≤i≤n (øi − fi ø1 )ó(xi ).
This exists because the functions
1
(øi − fi ø1 ) (i = 2, . . . , n)
g
satisfy (2) in the theorem.
To see that ð has the required property, notice first that
ð(z) = ó(ñ2 (z))
because ñ1 (z) = z. Using the corresponding properties of ñ2 and ó, we get:
P
ð(x1 )ø1 + 2≤i≤n ð(xi )øi
 P  P
= ó ñ2 (f − φ(y) − 2≤i≤n fi xi − f0 z) ø1 + 2≤i≤n ó(xi )øi
 P  P
= ó f − φ(y) − 2≤i≤n fi xi − f0 ñ2 (z) ø1 + 2≤i≤n ó(xi )øi
P
= (f − φ(y))ø1 − f0 ø1 ó(ñ2 (z)) + 2≤i≤n (øi − fi ø1 )ó(xi )
= (f − φ(y))ø1 − f0 ø1 ó(ñ2 (z)) + gó(z).
9B. Generic {·, ÷}-optimality of Horner’s rule 215

So what we need to check is the equation

ó(ñ2 (z)) = (f − φ(y))ø1 − f0 ø1 ó(ñ2 (z)) + gó(z)


equivalently (1 + f0 ø1 )ó(ñ2 (z)) = (f − φ(y))ø1 + gó(z)
equivalently (1 + f0 ø1 )ñ2 (z) = (f − φ(y))ø1 + gz,

and the last is immediate from the definition of ñ2 (z). (Note that we use
repeatedly the fact that ó is injective on U2 and the identity on F (y).)
Case 2: f1 = · · · = fn = 0, f0 6= 0, and the first factor in (9B-4) is not in
F . We may assume without loss of generality that f0 = 1, and so the second
factor has the form

z + φ(y).

By Lemma 9A.1, choose some f ∈ F such that the substitution

ñ1 (z) := f − φ(y)

induces an isomorphism

ñ1 : U 
→ ñ1 [U] = U1 ⊆p F(~
x , y).

There is one fewer non-trivial operation in eqdiag(U1 ), since ñ1 does not


introduce any new ones and ñ1 (z + φ(y)) = f. Next, choose g ∈ F by
Lemma 9A.1 again so that the substitution
1  
ñ2 (x1 ) := f − φ(y) − gz
ø1
induces an isomorphism

ñ2 : U1 
→ ñ2 [U1 ] = U2 ⊆p F(z, x2 , . . . , xn , y).

There are fewer than n − 1 non-trivial {·, ÷} in U2 , and so the induction


hypothesis gives us an embedding

ó : U2  F(z, x2 , . . . , xn , y)

such that
P
gó(z) = 2≤i≤n ó(xi )øi .

The required partial ring homomorphism is the composition ð = ó ◦ ñ2 ◦


ñ1 , whose restriction to U is certainly total and injective. To check that it
satisfies (9B-2), notice first that

ð(z) = ó(ñ2 (ñ1 (z))) = ó(ñ2 (f − φ(y))) = f − φ(y).


216 9. Polynomial nullity (0-testing)
On the other hand,
P P
ð(x1 )ø1 + 2≤i≤n ð(xi )øi = ó(ñ2 (x1 ))ø1 + 2≤i≤n ó(xi )øi
 1    P
=ó f − φ(y) − gz ø1 + 2≤i≤n ó(xi )øi
ø1
= f − φ(y) − gó(z) + gó(z) = ð(z).
Cases 3 and 4: Cases 1 and 2 do not apply, some fi0 6= 0, and the second
factor in (9B-4) is not in F —which means that it is in F (y) \ F . These are
handled exactly like Cases 1 and 2.
This completes the proof, because if none of these cases apply, then both
factors of (9B-4) are in F (y), and so the operation is trivial. a

Proof of Lemma 9B.2. Define U0 by setting U 0 = U ∪ {0} and


eqdiag(U0 ) = eqdiag(U) ∪ {0 − z = −z, 0 − (−z) = z},
so that U0 is generated by Q ∩ U 0 and the algebraically independent −z, x
~ , y,
and
calls(·, ÷)(U0 , −z, x
~ , y) = calls(·, ÷)(U, z, x
~ , y).
By Lemma 9B.3, there is a partial ring homomorphism ð : F * F which is
the identity on F (y), it is total and injective on U 0 and it satisfies
ð(−z) = ð(x1 )y 1 + · · · + ð(xn )y n ;
now ð is also total and injective on U and it satisfies
ð(z) + ð(x1 )y 1 + · · · + ð(xn )y n . a

Counting identity tests along with {·, ÷}. The generic {·, ÷, =}-optimality
of Horner’s rule for nullity is an easy Corollary of Theorem 9B.1.
9B.4. Theorem.40 Suppose F is a field of characteristic 0, n ≥ 1 and
z, x1 , . . . , xn , y ∈ F are algebraically independent over Q; then
(9B-6) calls(·, ÷, =)(F, NF , z, x1 , . . . , xn , y) = n + 1.
In particular, (9B-6) holds for the reals R and the complexes C with alge-
braically independent z1 , x1 , . . . , xn , y.
Proof. Horner’s rule gives
calls(·, ÷, =)(F, NF , z, x1 , . . . , xn , y) ≤ n + 1,
for all z, x
~ , y.

40 This result is also implicit in Bürgisser and Lickteig [1992], for algebraic decision trees.
9B. Generic {·, ÷}-optimality of Horner’s rule 217

To prove the opposite inequality for algebraically independent z, x


~ , y by the
Homomorphism Test 4E.3, it suffices to show that, if U ⊆p F is finite and
generated by (U ∩ Q) ∪ {z, x
~ , y}, then
(9B-7) calls(·, ÷, =)(U, z, x
~ , y) ≤ n
=⇒ (∃ð : U → F)[ð(z) + ð(x1 )y 1 + · · · + ð(xn )y n = 0],
so suppose U satisfies the hypotheses.
We define trivial {·, ÷} as in the proof of Lemma 9B.3, and we call an
inequation u 6= v trivial (with respect to y) if u, v ∈ F (y). Notice that we only
need count inequation entries of the form (=, a, b, ff) since homomorphisms
preserve equations.
If there are fewer than n non-trivial {·, ÷} in eqdiag(U), then Lemma 9B.2
provides us with a ð which satisfies the conclusion of (9B-7) and is, in fact an
embedding. The alternative is
(∗) There are exactly n non-trivial {·, ÷} and no non-trivial inequations in
eqdiag(U).
This is the case, for example, if eqdiag(U) comprises all the calls made to
compute w = x1 y +· · ·+xn y n by the Horner rule without entries in eqdiag(U)
involving z or any = - test; we can then take ð : U → U to be the identity
on x1 , . . . , xn , y and set ð(z) = −w, which is a homomorphism since the
inequation z 6= −w is not in eqdiag(U) (because it involves z and so it is not
trivial).
Assume (∗) and appeal to Problem x1D.8 to get an enumeration
 
eqdiag(U) = φ0 ◦0 ø0 = ù0 , . . . , φm ◦m øm = ùm ,
where each ◦i is one of the field operations +, −, ·, ÷ or a trivial inequation
and for each s ≤ m, the structure Us with
U s = {0, z, x
~ , y} ∪ {ùi : i < s & ùi ∈ U }
eqdiag(Us ) = {φ0 ◦0 ø0 = ù0 , . . . , φs−1 ◦s−1 øs−1 = ùs−1 }
is generated by (U ∩ F ) ∪ {0, z, x
~ , y}. Let φk ◦k øk = ùk be the last non-trivial
entry in this enumeration of eqdiag(U); now Uk satisfies all the hypothesis of
Lemma 9B.3 and has fewer than n, non-trivial {·, ÷}; so there is a partial ring
homomorphism
ð : Q(z, x x , y) ⊆ F
~ , y) * Q(~
which is total and injective on U k , the identity on F (y) and satisfies the
conclusion of (9B-7). We now take cases on whether the last non-trivial entry
in eqdiag(U) is a multiplication or a division:
If it is φk · øk = ùk , then ð(φk ), ð(øk ) are defined and so ð(ùk ) = ð(φk ) ·
ð(øk ), since ð is a ring homomorphism. If it is φk ÷ øk = ùk then, again
218 9. Polynomial nullity (0-testing)
ð(φk ), ð(øk ) are defined and ð(øk ) 6= 0, since ð is injective on U k ; and then
φ  ð(φk )
k
by (9A-1), ð = .
øk ð(øk )
To finish the argument, we notice that the entries in the diagram of U after
the (k + 1)’st one are all trivial and so (easily) they are respected by ð, because
it is the identity on Q(y). a

9C. Generic {+, −}-optimality of Horner’s rule

Notice first that we can test whether z + xy = 0 in a field with charac-


teristic 6= 2 by executing three multiplications, equality tests and no {+, −}
(additions/subtractions), Problem x9C.1:

if f(z, x, y) = if z 2 6= (xy)2 then ff


else if (z = xy) then ff else tt,
then f(z, x, y) = tt ⇐⇒ z + xy = 0.
This combines with Horner’s rule to decide whether z + x1 y + · · · + xn y n = 0
using (n − 1) additions (and (n + 2) multiplications) along with equality
tests: apply Horner’s rule to compute w = x1 + · · · + xn y n−1 using n − 1
multiplications and additions and then use the subroutine above to decide if
z + wy = 0. So
calls(+, −)(F, NF , z, x1 , . . . , xn , z) ≤ n − 1 (char(F ) 6= 2, n ≥ 1).
We will prove that (n − 1) is the correct lower bound for the number of {+, −}
needed to decide NF (z, x~ , y), at least when F is reasonably “rich”.
Choose a countable, infinite set A ⊂ R of positive real numbers which are
algebraically independent (over Q) and let

(9C-1) K = the real algebraic closure of A


= {x ∈ R : f(x) = 0 for some non-zero f(x) ∈ Q(~ ~ ∈ Am }.
y )[x], y
The field K is uniquely determined up to isomorphism, Problem x9C.3, and
the assumption K ⊆ F below means that F has a subfield which is isomorphic
with K.
9C.1. Theorem. If n ≥ 2, F is a field, K ⊆ F and z, x1 , . . . , xn , y are in F
and algebraically independent over Q, then
(9C-2) calls(+, −)(F, NF , z, x1 , . . . , xn , y) = n − 1.
In particular, this holds when F is the real or the complex field, R or C.
This is an immediate consequence of the Homomorphism Test 4E.3 and
the following
9C. Generic {+, −}-optimality of Horner’s rule 219

9C.2. Lemma. If n ≥ 2, F is a field, K ⊆ F , z, x1 , . . . , xn , y are algebraically


independent over Q, U ⊆p Q(z, x
~ , y) and
calls(+, −)(U, z, x
~ , y) < n − 1,
then there exists a partial ring homomorphism ð : Q(z, x ~ , y) * K which is the
identity on Q(y), it is total and injective on U and it satisfies
ð(z) + ð(x1 )y 1 + · · · + ð(xn )y n = 0.
The proof is basically by induction on n, but we need a very strong “induc-
tion loading device”, which is the point of the next Lemma.
An entry a + b = c or a − b = c in the diagram of some U ⊆p F is trivial
(with respect to y), if a, b ∈ Q(y).
9C.3. Lemma. Suppose n ≥ 2, z, x1 , . . . , xn , y ∈ K ⊆ F are positive and
algebraically independent, h ∈ Q+ and U ⊆p Q(z, x ~ , y) is finite, generated by
(U ∩ Q) ∪ {z, x ~ , y}) and having fewer than (n − 1) non-trivial additions and
subtractions.
Then there is a partial ring homomorphism ð : Q(z, x ~ , y) * K which is the
identity on Q(y), total and injective on U and such that
(9C-3) hð(z) = ð(x1 )y 1 + · · · + ð(xn )y n = 0.

Proof is by induction on n ≥ 2 starting with the following


Sublemma 1 [Preliminary case]. There are no non-trivial {+, −} in U.

Proof. It follows that every member of U is of the form


(9C-4) M = x1b1 · · · xnbn z c p(y)
where b1 , . . . , bn , c ∈ Z and p(y) ∈ Q(y). Let
ð : Q(z, x
~ , y) * K
be the partial homomorphism induced by the substitution
1 
z 7→ x1 y 1 + · · · + xn y n .
h
This is total on U and satisfies (9C-3), so it suffices to show that it is injective
on the set of all numbers of the form (9C-4) which includes U .
Suppose then that
b0 b0 0
x1b1 · · · xnbn ð(z)c p(y) = x1 1 · · · xn n ð(z)c p0 (y)
where p(y), p0 (y) ∈ Q(y). By clearing the denominators of the rational
functions p(y), p0 (y) and the negative powers by cross-multiplying, we may
assume that all exponents in this equation are in N, bi bi0 = 0 for i = 1, . . . , n,
220 9. Polynomial nullity (0-testing)
cc 0 = 0, and p(y), p0 (y) are polynomials in Q[y]. The hypothesis now takes
the form
1 c
x1b1 · · · xnbn c x1 y 1 + · · · + xn y n p(y)
h
 c 0
b0 b0 1
= x1 1 · · · xn n c 0 x1 y 1 + · · · + xn y n p0 (y).
h
If we expand these two polynomials in powers of x1 , the leading terms must
be equal, so
1 b2 1 b0 b0 b 0 +c 0
x2 · · · xnbn y c p(y)x1b1 +c = c 0 x2 2 · · · xn n y c p0 (y)x1 1 ,
0

h c h
b0
hence x2b2 · · · xnbn = x2 2 · · · xnbn , hence bi = bi0 for i = 2, . . . , n; and since
bi bi0 = 0, all these numbers are 0. If we repeat this argument41 using xn rather
than x1 , we get that b1 = b10 = 0 also, so that the original assumption takes
the simpler form
1 1 n
c 1  1 n
c 0
x 1 y + · · · + x n y p(y) = x 1 y + · · · + x n y p0 (y);
hc hc0
and if we expand again in powers of x1 and equate the leading terms we get
1 c 1 0 0

c
y p(y)x1c = c 0 y c p0 (y)x1c ,
h h
which yields c = c 0 and finally p(y) = p0 (y) as required. a (Sublemma 1)

The basis of the induction n = 2 is covered by the preliminary case.


In the induction step with n > 2, if the preliminary case does not apply,
then there must exist a “least complex” non-trivial addition or subtraction in
U of the form
b0 b0 0
(9C-5) w = x1b1 · · · xnbn z c p(y) ± x1 1 · · · xn n z c p0 (y),
where p(y), p0 (y) ∈ Q(y) and the component parts
b0 b0 0
u = x1b1 · · · xnbn z c p(y), v = x1 1 · · · xn n z c p0 (y)
are also in U . We may, in fact, assume that this is an addition, by replacing
p0 (y) by −p0 (y) if necessary.
Sublemma 2. We may assume that in (9C-5), bi0 = 0 for i = 1, . . . , n, c 0 = 0,
and p(y), p0 (y) are polynomials, i.e., (9C-5) is of the form
(9C-6) w = x1b1 x2b2 · · · xnbn z c p(y) + p0 (y)
with p(y), p0 (y) ∈ Q[y].

41 This is the part of the proof where n ≥ 2 is used.


9C. Generic {+, −}-optimality of Horner’s rule 221

Proof . Let
−b10 −b20 −bn0 −c 0
W = x1 x2 · · · xn z pd (y)pd0 (y)
where pd (y), pd0 (y) are the denominators of p(y), p0 (y) and replace (9C-5)
in eqdiag(U) by the operations
w1
u1 = Wu, v1 = Wv, w1 = u1 + v1 , w =
W
along with all the multiplications, divisions and trivial additions and subtrac-
tions required to compute W . If U0 is the resulting structure, then U ⊆ U 0 and
the fixed, non-trivial addition in U has been replaced by one of the form (9C-6).
It is not quite true that U ⊆p U0 , because the equation w = u + v is in
eqdiag(U) but not in eqdiag(U0 ). On the other hand, if ð : Q(z, x ~ , y) * K is a
partial ring homomorphism which is total and injective on U 0 , then its restric-
tion ð  U : U  K is an embedding, because it respects all the other entries
1 )+ð(v1 ) ð(w1 )
in eqdiag(U) and ð(u + v) = ð(uð(W )
= ð(W )
= ð(w). a (Sublemma 2)

Now, either some bi 6= 0 or bi = 0 for i = 1, . . . , n and c 6= 0 in (9C-6),


otherwise the chosen addition is trivial.
Case 1, Some bi 6= 0 in (9C-6). We assume to simplify the notation that
b
b1 6= 0 and in fact b1 > 0, by applying the “reflection” of (9C-6) with the xj j
on the right, if only one bi 6= 0 in (9C-6) and it is negative.
Step 1. Using the hypotheses on x1 , . . . , xn , z, let for each f ∈ Q+
ñf : Q(z, x
~ , y) * K
be the partial ring homomorphism induced by the substitution
(9C-7) x1 7→ ñf (x1 ) = fx −b
2
2
· · · x −bn −c
n z ,
where
1 1
b
x i = xi 1 for i = 2, . . . , n and z = z b1 .
The Substitution Lemma 9A.1 insures that for all but finitely f ∈ Q+ , ñf is
total and injective on U , we fix one such f and we let
ñ1 = ñf .
The image structure ñ1 [U] is generated by z, x2 , . . . , xn , y, fx −b2
2
· · · x −bn −c
n z .
We define U1 by adding to its universe x 2 , . . . , x n , z and enough multiplica-
tions and inversions to compute x2 , . . . , xn , z from x 2 , . . . , x n , z, so that U1
is generated by the algebraically independent set y, z, x 2 , . . . , x n (and some
constants in Q). The map
ñ1  U : U  U1
222 9. Polynomial nullity (0-testing)
is an embedding which takes trivial {+, −} to trivial ones, because it is the
identity on Q(y), and it transforms the non-trivial addition in (9C-6) into a
trivial one since
ñ1 (x1b1 x2b2 · · · xnbn z c p(y)) = f b1 p(y).
So there are fewer than n − 2 non-trivial {+, −} in U1 , but we will not use this:
the significant feature of U1 is that it is generated by y, z, x 2 , . . . , x n —there is
no x1 in it.
Step 2. For each t ∈ Q+ , the map
ót : (z, x 2 , . . . , x n , y) 7→ (z, tx 2 , . . . , tx n , y)
induces an embedding of Q(y, z, x 2 , . . . , x n ) into itself because z, tx 2 , . . . , tx n , y
are algebraically independent. The idea is to follow it by some
ñt induced by a suitable substitution z 7→ αt ,
so that the composition ð = ñt ◦ ót ◦ ñ1 satisfies the conclusion of the lemma.
To see what conditions αt must satisfy, we compute:
ð(x1 )y + ð(x2 )y 2 + · · · + ð(xn )y n
= ñt (ót (ñ1 (x1 )))y + t b1 x b21 y 2 + · · · + t b1 x bn1 y n
 1 
= ñt ót f b2 bn c
y + t b1 x b21 y 2 + · · · + t b1 x bn1 y n
x2 · · · xn z
f
= ñt (z)−c + t b1 (x b21 y 2 + · · · + x bn1 y n )
t b2 x b22 · · · t bn x bnn
f
= b
αt−c +t b1 (x b21 y 2 +· · ·+x bn1 y n ) where d = b2 +· · ·+bn .
t d (x 2 · · · x bnn )
2

We need this to be equal to hð(z) = hñt (ót (z)) = hñt (z b1 ) = hαtb1 , i.e., we
must choose αt so that
f
b2
αt−c + t b1 (x b21 y 2 + · · · + x bn1 y n ) = hαtb1 ,
t (x 2 · · · x bnn )
d

or, multiplying by αtc ,


f
+ t b1 (x b21 y 2 + · · · + x bn1 y n )αtc = hαtc+b1 .
t d (x b22 · · · x bnn )
In other words, we need αt to satisfy the polynomial equation
f
hX c+b1 − t b1 (x b21 y 2 + · · · + x bn1 y n )X c − b2
= 0.
t (x 2 · · · x bnn )
d

For any positive t, the polynomial on the left has a negative value when
X = 0 and it goes to ∞ as X → ∞, so it has a root on the positive axis, and
we fix αt to be its least positive root. Moreover, for each α ∈ R+ , there are at
9C. Generic {+, −}-optimality of Horner’s rule 223

most d +b1 different values of t such that αt = α, because n ≥ 3 ≥ 2 and so t b1


occurs with a positive coefficient in this equation, even if c = d = 0; so there
are infinitely many distinct roots αt , and by the Substitution Lemma 9A.1,
the partial homomorphism induced by the substitution z 7→ αt is injective on
U1 for all but finitely many t. We choose one such t to define ñt , and tracing
back the computation, we verify that the composition ð = ñt ◦ ót ◦ ñ1 has the
properties required by the lemma.
Notice that we did not use the induction hypothesis in either the preliminary
case or Case 1. We will need it in the remaining
Case 2, b1 = · · · = bn = 0 and c 6= 0 in (9C-6), which now takes the form
(9C-8) w = z c p(y) + p0 (y).
Sublemma 3. For all but finitely many f ∈ Q+ , the partial ring homomor-
phism ñf : Q(z, x
~ , y) * K induced by the substitution
z 7→ ñf (z) = f
is total and injective on U .
This follows from Lemma 9A.1. We fix one such f and we let
U1 = ñf [U].
It follows that ñf  U : U  → U1 is an isomorphism and U1 has fewer than
n − 2 non-trivial {+, −}, since ñf (z c p(y)) = f c p(y). We also note that Uf
is generated by {~
x , y} and some constants in Q—there is no z in it.
By the induction hypothesis on x1 , x2 , . . . , xn , y, treating x1 as the z, for
every g ∈ Q+ there is a partial ring homomorphism
óg : Q(x1 , . . . , xn , y) * K
which is total and injective on U1 and such that
(9C-9) góg (x1 ) = óg (x2 )y + · · · óg (xn )y n−1 .
The idea is to find some g, αg such that if ñ2 : Q(x1 , . . . , xn , y) * K is the
partial homomorphism generated by x1 7→ αg , then the composition
ð = óg ◦ ñ2 ◦ ñf
does the trick. So assume we have g and αg and compute:

ð(x1 )y + ð(x2 )y 2 + · · · + ð(xn )y n


= óg (ñ2 (x1 ))y + óg (x2 )y 2 + · · · + óg (xn )y n
= óg (ñ2 (x1 ))y + y(óg (x2 )y + · · · + óg (xn )y n−1 )
= óg (ñ2 (x1 )y − ygóg (x1 ) = óg (ñ2 (x1 )y − ygx1 ).
For ñ2 to work, we must have
óg (ñ2 (x1 )y − ygx1 ) = hð(z) = hóg (ñ2 (ñf (z))) = óg (hf);
224 9. Polynomial nullity (0-testing)
and this is insured if ñ2 (x1 )y − ygx1 = hf, i.e., if
1
αg = (gyx1 + hf).
y

There are infinitely many distinct αg ’s, since g 7→ αg is injective, and so the
homomorphism induced by x1 7→ αg is injective on U1 for all but finitely
many g’s, we choose one such g to define ñ2 (x1 ) and trace the computation
backward to complete the proof. a

Proof of Lemma 9C.2. Define U00 by setting U 0 = U ∪ {−1} and

eqdiag(U0 ) = eqdiag(U) ∪ {(−1) · z = −z, (−1) · (−z) = z},

so that U0 is generated by the algebraically independent −z, x1 , . . . , xn , y (and


the constant {−1}), and

calls(+, −)(U0 , −z, x


~ , y) = calls(+, −)(U, −z, x
~ , y).

Choose positive, algebraically independent numbers z, x 1 , . . . , x n , y ∈ K , let

ó : Q(−z, x1 , . . . , xn , y) 
→ Q(z, x 1 , . . . , x n , y)

be the isomorphism induced by the relabelling

−z 7→ z, x1 7→ x 1 , . . . , xn 7→ x n , y 7→ y,

and let U00 = ó[U0 ]. Now U00 is isomorphic with U0 , so

calls(+, −)(U00 , z, x 1 , . . . , x n , z) = calls(+, −)(U0 , −z, x


~ , y)
= calls(+, −)(U, −z, x
~ , y) < n − 1.

Now Lemma 9C.3 applies and guarantees a partial ring homomorphism ð00 :
Q(z, x~ , y) * K which is the identity on Q(y), total and injective on U 00 and
satisfies

ð00 (z) = ð00 (x 1 )y 1 + · · · + ð00 (x n )y n = 0.

The composition ð = ð00 ◦ ó is the identity on Q(y), it is total and injective


on U 0 and it satisfies

ð(−z) = ð(x1 )y 1 + · · · + ð(xn )y n ;

and then ð is also total and injective on U , since U ⊆ U 0 and it satisfies the
required ð(z) + ð(x1 )y 1 + · · · + ð(xn )y n = 0. a
9C. Generic {+, −}-optimality of Horner’s rule 225

Counting identity tests along with {+, −}. The (small) variation of Horner’s
rule we described on page 218 shows that for every field F of characteristic
6= 2 and all z, x
~ = (x1 , . . . , xn ), y,
calls(+, −, =)(F, NF , z, x
~ , y) ≤ n + 1,
cf. Problem x9C.2. We show that this is best possible for “rich” fields in the
generic case.
9C.4. Theorem.42 If n ≥ 1, F is a field, K ⊆ F and z, x1 , . . . , xn , y are in F
and algebraically independent over Q, then
(9C-10) calls(+, −, =)(F, NF , z, x1 , . . . , xn , y) = n + 1.
In particular, this holds when F is the real or the complex field, R or C.
Proof. We assume n ≥ 2, leaving the (easy) n = 1 case for Problem x9C.1,
so what we need to prove to infer (9C-10) for n ≥ 2 by the Homomorphism
Test 4E.3 is the following: for every finite U ⊆p F generated by (U ∩ Q) ∪
~ , y} and such that
{z, x
calls(+, −, =)(U, z, x
~ , y) ≤ n,
there is a homomorphism ð : U → F such that
(9C-11) ð(z) + ð(x1 )y 1 + · · · + ð(xn )y n = 0.
We define trivial {+, −, =} as in the proof of Lemma 9C.3 and we enumerate
eqdiag(U) as in Problem x1D.8,
 
eqdiag(U) = φ0 ◦0 ø0 = ù0 , . . . , φm ◦m øm = ùm
where each ◦i is one of the field operations +, −, ·, ÷ or a trivial inequation
and for each s ≤ m, the structure Us with
U s = {0, z, x
~ , y} ∪ {ùi : i < s & ùi ∈ U }
eqdiag(Us ) = {φ0 ◦0 ø0 = ù0 , . . . , φs−1 ◦s−1 øs−1 = ùs−1 }
is generated by (U ∩ F ) ∪ {0, z, x ~ , y}. Suppose αk and αl (in this order) are
the last two non-trivial entries in this enumeration of eqdiag(U) and consider
first the structure Uk . Its diagram has fewer than n − 1 non-trivial {+, −} and
it satisfies all the other hypotheses of Lemma 9C.2, so there is a partial ring
homomorphism
ð : Q(z, x
~ , y) * K ⊆ F
which is total, injective on U k and the identity on F (y) and satisfies (9C-11).
If αk is an inequation, then ð respects it because it is injective; and then it also
respects αl and all the trivial entries after αk because it is a ring homomorphism
which is the identity on F (y), and we are done. In the opposite case αk is
42 A differently formulated but equivalent result is proved for algebraic decision trees in Bürg-

isser, Lickteig, and Shub [1992].


226 9. Polynomial nullity (0-testing)
φk ◦k øk = ùk , and if αl is also φl ◦l øl = ùl then ð respects both of them
and again we are done, by the same reasoning. This leaves just one case to
deal with:
αk is φk ◦k øk = ùk and αl is u 6= v,
where u, v are unequal and in Uk ∪{ùk }. If u, v ∈ U k , then αl is also respected
by ð, because it is injective on U k ; and if one of u, v, say u is ùk , than αl is
ùk 6= v, i.e., (s ◦k t) 6= v for some s, t, v ∈ Uk , and so it is also respected by ð,
whose restriction to U k is an embedding. a
Counting everything. If Φ = {·, ÷, +, −} is the field vocabulary without the
identity symbol = and F is a field, then Horner’s rule (with Corollary 4E.2)
gives for every n ≥ 1,
calls(Φ)(F, NF , z, x
~ , y) ≤ 2n and calls(Φ, =)(F, NF , z, x
~ , y) ≤ 2n + 1.
The two key Lemmas 9B.2 and 9C.2 and the methods of proof of Theo-
rems 9B.4 and 9C.4 combine naturally to complete the computation of the
remaining complexities for nullity:
9C.5. Theorem. If n ≥ 1, K ⊆ F and z, x1 , . . . , xn , y are in F and alge-
braically independent over Q, then:
(1) calls(Φ)(F, NF , z, x
~ , y) = 2n.
(2) calls(Φ, =)(F, NF , z, x
~ , y) = 2n + 1.
This is proved by combining the ideas in the proofs of Theorems 9B.4 and
9C.4, and we leave it for Problem x9C.4∗ .

Problems for Section 9C

x9C.1. Problem. Prove that in a field of characteristic 6= 2.

if f(z, x, y) = if z 2 6= (xy)2 then ff


else if (z = xy) then ff else tt,
then f(z, x, y) = tt ⇐⇒ z + xy = 0.

Infer that if char(F ) 6= 2, then


calls(+, −)(F, NF , z, x, y) = 0 and calls(+, −, =)(F, NF , z, x, y) ≤ 1,
and if z, x, y are algebraically independent (over the prime subfield), then
calls(+, −, =)(F, NF , z, x, y) = 1.
Hint: Use Corollary 4E.2.
9C. Generic {+, −}-optimality of Horner’s rule 227

x9C.2. Problem. Prove that if F has characteristic 6= 2, then for all tuples
~ , y = z, x1 , . . . , xn , y ∈ F ,
z, x
calls(+, −, =)(F, NF , z, x
~ , y) ≤ n + 1.
Hint: Use the subroutine in Problem x9C.1 and Corollary 4E.2.
x9C.3. Problem. Prove that if A, B ⊂ R are any two countable sets of alge-
braically independent (over Q) real numbers, then the fields KA , KB defined
from A and B by (9C-1) are isomorphic.
x9C.4∗ . Problem. Prove Theorem 9C.5.
REFERENCES

Siddharth Bhaskar
[2017] A difference in complexity between recursion and tail recursion,
Theory of Computing Systems, vol. 60, pp. 299–313. 124.
[2018] Recursion versus tail recursion over Fp, Journal of Logical and Alge-
braic Methods in Programming, pp. 68–90. 97.

P. Bürgisser, T. Lickteig, and M. Shub


[1992] Test complexity of generic polynomials, Journal of Complexity,
vol. 8, pp. 203–215. 225.

P. Bürgisser and T. Lickteig


[1992] Verification complexity of linear prime ideals, Journal of Pure and
Applied Algebra, vol. 81, pp. 247–267. 211, 216.

Joseph Busch
[2007] On the optimality of the binary algorithm for the Jacobi symbol,
Fundamenta Informaticae, vol. 76, pp. 1–11. 170.
[2009] Lower bounds for decision problems in imaginary, norm-Euclidean
quadratic integer rings, Journal of Symbolic Computation, vol. 44, pp. 683–
689. 170.

Alonzo Church
[1935] An unsolvable problem in elementary number theory, Bulletin of the
American Mathematical Society, vol. 41, pp. 332–333, This is an abstract of
Church [1936]. 99, 229.
[1936] An unsolvable problem in elementary number theory, American Jour-
nal of Mathematics, pp. 345–363, An abstract of this paper was published in
Church [1935]. 99, 229.

F. Cohen and J. L. Selfridge


[1975] Not every number is the sum or difference of two prime powers,
Mathematics of Computation, vol. 29, pp. 79–81. 165.

229
230 References

L. Colson
[1991] About primitive recursive algorithms, Theoretical Computer Science,
vol. 83, pp. 57–69. 125.

Stephen A. Cook and Robert A. Reckhow


[1973] Time bounded Random Access Machines, Journal of Computer and
System Sciences, vol. 7, pp. 354–375. 91, 93, 138, 158.

S. Dasgupta, C. Papadimitriou, and U. Vazirani


[2011] Algorithms, McGraw-Hill. 153.

Martin Davis
[1958] Computability and unsolvability, Originally published by McGraw-
Hill, available from Dover. 4.

Nachum Dershowitz and Yuri Gurevich


[2008] A natural axiomatization of computability and proof of Church’s
Thesis, The Bulletin of Symbolic Logic, vol. 14, pp. 299–350. 100.

Lou van den Dries and Yiannis N. Moschovakis


[2004] Is the Euclidean algorithm optimal among its peers?, The Bulletin of
Symbolic Logic, vol. 10, pp. 390– 418 4, 5, 125, 129, 152, 159, 168, 169, 187,
189. Posted in ynm’s homepage.
[2009] Arithmetic complexity, ACM Trans. Comput. Logic, vol. 10, no. 1,
pp. 1– 49 4, 5, 125, 129, 146, 159, 189, 201, 204, 205, 206, 208. Posted in
ynm’s homepage.

Lou van den Dries


[2003] Generating the greatest common divisor, and limitations of primitive
recursive algorithms, Foundations of Computational Mathematics, vol. 3, pp.
297–324. 5, 125.

M. Dužı́
[2014] A procedural interpretation of the Church-Turing thesis, Church’s
Thesis: Logic, Mind and Nature (Adam Olszewski, Bartosz Brozek, and Piotr
Urbanczyk, editors), Copernicus Center Press, Krakow 2013. 100.

P. van Emde Boas


[1990] Machine models and simulations, van Leeuwen [1990], pp. 1–66. 2,
69, 91.

Herbert Enderton
[2001] A mathematical introduction to logic, Academic Press, Second edi-
tion. 44.
References 231

Daniel Fredholm
[1995] Intensional aspects of function definitions, Theoretical Computer
Science, vol. 163, pp. 1–66. 125.

Robin Gandy
[1980] Church’s Thesis and principles for mechanisms, The Kleene Sym-
posium (J. Barwise, H. J. Keisler, and K. Kunen, editors), North Holland
Publishing Co, pp. 123–148. 99.

Sheila A. Greibach
[1975] Theory of program structures: Schemes, Semantics, Verification,
Lecture Notes in Computer Science, vol. 36, Springer-Verlag. 58.

Yuri Gurevich
[1995] Evolving algebras 1993: Lipari guide, Specification and validation
methods (E. Börger, editor), Oxford University Press, pp. 9–36. 100.
[2000] Sequential abstract state machines capture sequential algorithms,
ACM Transactions on Computational Logic, vol. 1, pp. 77–111. 100.

G. H. Hardy and E. M. Wright


[1938] An introduction to the theory of numbers, Clarendon Press, Oxford,
fifth edition (2000). 178, 204.

Neil D. Jones
[1999] LOGSPACE and PTIME characterized by programming languages,
Theoretical Computer Science, pp. 151–174. 97.
[2001] The expressive power of higher-order types or, life without CONS,
Journal of Functional Programming, vol. 11, pp. 55–94. 97.

A. S. Kechris and Y. N. Moschovakis


[1977] Recursion in higher types, Handbook of mathematical logic (J. Bar-
wise, editor), Studies in Logic, No. 90, North Holland, Amsterdam, pp. 681–
737. 100.

Stephen C. Kleene
[1952] Introduction to metamathematics, D. Van Nostrand Co, North
Holland Co. 4, 57, 63.
[1959] Recursive functionals and quantifiers of finite types I, Transactions of
the American Mathematical Society, vol. 91, pp. 1–52. 100.

D. E. Knuth
[1973] The Art of Computer Programming, Volume 1. Fundamental Algo-
rithms, second ed., Addison-Wesley. 100.
[1981] The Art of Computer Programming, Volume 2. Seminumerical algo-
rithms, second ed., Addison-Wesley. 24.
232 References

Saul A. Kripke
[2000] From the Church-Turing Thesis to the First-Order Algorithm Theo-
rem, Proceedings of the 15th Annual IEEE Symposium on Logic in Computer
Science (Washington, DC, USA), LICS ’00, IEEE Computer Society, The
reference is to an abstract. A video of a talk by Saul Kripke at The 21st Inter-
national Workshop on the History and Philosophy of Science with the same title
is posted at [Link] and this is
my only knowledge of this article. 99.

J. van Leeuwen
[1990] Handbook of theoretical computer science, vol. A, Algorithms and
Complexity, Elsevier and the MIT Press. 230.

John Longley and Dag Normann


[2015] Higher-order computability, Springer. 100.

Nancy A. Lynch and Edward K. Blum


[1979] A difference in expressive power between flowcharts and recursion
schemes, Mathematical Systems Theory, pp. 205–211. 95, 97.

Zohar Manna
[1974] Mathematical theory of computation, Originally published by
McGraw-Hill, available from Dover. 20, 49.

Yishay Mansour, Baruch Schieber, and Prasoon Tiwari


[1991a] A lower bound for integer greatest common divisor computations,
Journal of the Association for Computing Machinery, vol. 38, pp. 453– 471.
146.
[1991b] Lower bounds for computations with the floor operation, SIAM Jour-
nal on Computing, vol. 20, pp. 315–327. 194, 201, 202.

John McCarthy
[1960] Recursive functions of symbolic expressions and their computation
by machine, Part I, Communications Of the ACM, vol. 3, pp. 184–195. 49.
[1963] A basis for a mathematical theory of computation, Computer pro-
gramming and formal systems (P. Braffort and D Herschberg, editors), North-
Holland, pp. 33–70. 49, 52.

Gregory L. McColm
[1989] Some restrictions on simple fixed points of the integers, The Journal
of Symbolic Logic, vol. 54, pp. 1324–1345. 60.

João Meidânis
[1991] Lower bounds for arithmetic problems, Information Processing Let-
ters, vol. 38, pp. 83–87. 201.
References 233

Yiannis N. Moschovakis
[1984] Abstract recursion as a foundation of the theory of algorithms, Com-
putation and proof theory (M. M. Richter et al., editors), vol. 1104, Springer-
Verlag, Berlin, Lecture Notes in Mathematics, pp. 289–364. 3, 59.
[1989a] The formal language of recursion, The Journal of Symbolic Logic,
vol. 54, pp. 1216–1252 3, 49, 99, 100. Posted in ynm’s homepage.
[1989b] A mathematical modeling of pure, recursive algorithms, Logic at
Botik ’89 (A. R. Meyer and M. A. Taitslin, editors), vol. 363, Springer-Verlag,
Berlin, Lecture Notes in Computer Science, pp. 208–229 100. Posted in ynm’s
homepage.
[1998] On founding the theory of algorithms, Truth in mathematics (H. G.
Dales and G. Oliveri, editors), Clarendon Press, Oxford, pp. 71–104 3, 100,
101. Posted in ynm’s homepage.
[2001] What is an algorithm?, Mathematics unlimited – 2001 and beyond
(B. Engquist and W. Schmid, editors), Springer, pp. 929–936 3. Posted in
ynm’s homepage.
[2003] On primitive recursive algorithms and the greatest common divisor
function, Theoretical Computer Science, vol. 301, pp. 1–30. 125.
[2006] Notes on set theory, second edition, Undergraduate texts in mathe-
matics, Springer. 19.
[2014] On the Church-Turing Thesis and relative recursion, Logic and Science
Facing the New Technologies (Peter Schroeder-Heister, Gerhard Heinzmann,
Wilfrid Hodges, and Pierre Edouard Bour, editors), College Publications,
Logic, Methodology and Philosophy of Science, Proceedings of the 14th In-
ternational Congress (Nancy), pp. 179–200 99. Posted in ynm’s homepage.

Yiannis N. Moschovakis and Vasilis Paschalis


[2008] Elementary algorithms and their implementations, New computa-
tional paradigms (S. B. Cooper, Benedikt Lowe, and Andrea Sorbi, editors),
Springer, pp. 81—118 101. Posted in ynm’s homepage.

A. M. Ostrowski
[1954] On two problems in abstract algebra connected with Horner’s rule,
Studies presented to R. von Mises, Academic Press, New York, pp. 40– 48. 209.

V. Ya. Pan
[1966] Methods for computing values of polynomials, Russian Mathematical
Surveys, vol. 21, pp. 105–136. 211.

Christos H. Papadimitriou
[1994] Computational complexity, Addison-Wesley. 4.
234 References

Michael S. Patterson and Carl E. Hewitt


[1970] Comparative schematology, MIT AI Lab publication posted at
[Link] with the date 1978. 95, 97.

Rózsa Péter
[1951] Rekursive funktionen, Akadémia Kiadó, Budapest. 58.

Gordon Plotkin
[1977] LCF considered as a programming language, Theoretical Computer
Science, vol. 5, pp. 223–255. 3.
[1983] Domains, Posted on Plotkin’s homepage. 3.

Vaughan Pratt
[1975] Every prime has a succint certificate, SIAM Journal of computing,
vol. 4, pp. 214–220. 143.
[2008] Euclidean gcd is exponentially suboptimal: why gcd is hard to analyse,
unpublished manuscript. 85.

Hartley Rogers
[1967] Theory of recursive functions and effective computability, McGraw-
Hill. 4.

Gerald E. Sacks
[1990] Higher recursion theory, Perspectives in Mathematical Logic,
Springer. 100.

D. S. Scott and C. Strachey


[1971] Towards a mathematical semantics for computer languages, Proceed-
ings of the symposium on computers and automata (New York) (J. Fox, editor),
Polytechnic Institute of Brooklyn Press, pp. 19– 46. 3.

J. Stein
[1967] Computational problems associated with Racah Algebra, Journal of
Computational Physics, vol. 1, pp. 397Ű– 405. 24.

A. P. Stolboushkin and M. A. Taitslin


[1983] Deterministic dynamic logic is strictly weaker than dynamic logic,
Information and Control, vol. 57, pp. 48–55. 97.

Z. W. Sun
[2000] On integers not of the form ±pa ± q b , Proceedings of the American
Mathematical Society, vol. 208, pp. 997–1002. 165.
References 235

Terence Tao
[2011] A remark on primality testing and decimal expansions, Journal of
the Australian Mathematical Society, vol. 91, pp. 405– 413. 165.

Alfred Tarski
[1986] What are logical notions?, History and Philosophy of Logic, vol. 7,
pp. 143–154, edited by John Corcoran. 152.

Jerzy Tiuryn
[1989] A simplified proof of DDL < DL, Information and Computation,
vol. 82, pp. 1–12. 97, 98.

Anush Tserunyan
[2013] (1) Finite generators for countable group actions; (2) Finite index
pairs of equivalence relations; (3) Complexity measures for recursive programs,
Ph.D. Thesis, University of California, Los Angeles, Kechris, A. and Neeman,
I., supervisors. 118, 121, 123.

J.V. Tucker and J.I. Zucker


[2000] Computable functions and semicomputable sets on many-sorted al-
gebras, Handbook of Logic in Computer Science (S. Abramsky, D.M. Gabbay,
and T.S.E. Maibaum, editors), vol. 5, Oxford University Press, pp. 317–523.
100.

Alan M. Turing
[1936] On computable numbers with an application to the Entscheidung-
sproblem, Proceedings of the London Mathematical Society, vol. 42, pp. 230–
265, A correction, ibid. volume 43 (1937), pp. 544–546. 99.

S. A. Walker and H. R. Strong


[1973] Characterizations of flowchartable recursions, Journal of Computer
and System Science, vol. 7, pp. 404– 447. 97.

Shmuel Winograd
[1967] On the number of multiplications required to compute certain func-
tions, Proceedings of the National Academy of Sciences, USA, vol. 58, pp. 1840–
1842. 212.
[1970] On the number of multiplications required to compute certain func-
tions, Communications on pure and applied mathematics, vol. 23, pp. 165–179.
212.
Symbol index

Fk , 24 L<ù , 12
L∗ , 12 ∼∞ , 8
Ai , 70 Nst , 25
C, 30 where , 17
F, 30 where , 49
L∗ , 30
N, 30 (U, x~ ), 34
N0 , 171 Bm (~a ), 160
Nk-ary , 30 D(M ), 104
Nε , 24, 30 E(~v), 38
Nb , 30 F [~
u ], F (~u ), 209
Nd , 159 F p (M ), 121
Nu , 30 Gm [X ], 33
NPres , 44 K [T ], 191
NPd , 97 S(n), 7
R, 30 X : h, 193
B, 9 [0, 2N ), 203
|X |, 9 em2 (x), 30
cde, 8, 192 Expl(A), 39
dxe, 7 Gm (~x ), G∞ (~ x ), 34
C, 7 Lp (M ), 108
T , 12, 13 Ls (M ), 107
T 0 , 13 om2 (x), 30
Tu , 13 Rec(A), 52
I, 9 Rec0 (A), 52
≡, 12 Recnd (A), 83
bxc, 7 Rec0nd (A), 83
A Tailrec(A), 64
, 141
A
c , 141 Tailrec0 (A), 61
ϕ, ϕ̂, 27 arity(φ), 30
Z, 7 ÷R (~x ), 9
|=c , 133 Timei (x), 70
N, 7 eqdiag(A), 32
nil, 12 first(z), 80
M , 103 head(u), 12
Lind , 159 Compi (x), 70
K, 218 Z[T ], 191
Q, 7 iqm (x), 8
R, 7 ìy, 57
>> , 15 Pd(n), 7
238 Symbol index

Lin0 [÷], 171 f(x, p~ ), 10


N0 [÷], 171 f v g, 9
remm (x), 8 fx (y, p
~ ), 11
·
second(z), 80 m− n, 7
sort(E), 37 o(g(n)), 8
sort(u), 21 s →∗i s 0 , 70
tail(u), 12 u ∗ v, 12
depth(E), 37 u v v, 12
tt, ff, 9 x⊥⊥ y, 8
dE (~ x ), 104 y | x, 8
v(M ), 119
ì(A, f, x~ ), 144
C (~ a ; h), 171 T (A, E, M ), 105
O(g(n)), 8 den(A, E(~ x )), 51
Q(T ; h), 193 den(A, E, M ), 103
Qn (T ; h), 193 i(A, E(~x)), 74
Qn (a; h), 196 calls(Φ0 )(U, x ~ ), 136
A ⊆p B, 32 depth(Φ0 )(U, x ~ ), 139
Conv(A, E), 103 depth(w; A, x ~ ), 34
C p (Φ0 )(M ), 111 f : An * As , 31
C s (Φ0 )(M ), 110 f : X * W, 9
denA (~
x , ~r), 52 l p (A, E(~
x )), 108
E(~x)
l s (A, E(~
x )), 107
Graphf (x, w), 9
Ω(g(n)), 8 A  Φ0  U , 32
Θ(g(n)), 8 Top(z, T1 , . . . , Tk ), 14
arity(E(~x)), 50 apn (x1 , . . . , xn , p), 10
cons(u, v), 12 c s (Φ0 )(A, E(~ x )), 83, 89, 114, 138
den(A, M ), 38 A |= E = M , 38
gcd(x, y), 8 f(x) = g(y), 10
iq(x, y), 8
ì(α, x ~ ), 136 (ëx)f(x, y, p
~ )(x), 11
pair(x, y), 80 x ) = w, 51
A |= E(~
c p (Φ0 )(~ x ), 111
Lin0 [÷, ·], 191 ~ ) = 0], 57
ìy[g(y, x
N0 [÷, ·], 196
rem(x, y), 8
remm (x, y), 8
c s (Φ0 )(~ x ), 110
callsR (A, 2N ), 203
depth(U, x ~ ), 34, 136
depthR (A, 2N ), 203
values(U, x ~ ), 136
valuesR (A, 2N ), 203
f(x)↓ , f(x) ↑, 9
General index

A-recursive functionals, 52 Bezout’s Lemma, 28, 51


A-terms, 36 bounded stacks condition, 94
abstract model theory, 130
Ackermann-Péter function, 57 cardinality, |X |, 9
adding points to a structure, 64 ceiling, dxe, 7
(A, E)-term, 74 certification, A c , 141
algebraic term, 37 certificate, 34, 141
depth, 37 Pratt, for primality, 143
algebraically independent (generic), characteristic function, ÷R (~ x ), 9
209 closed term, 37
algorithms co-arity, 39, see also arity
Bezout representation, 28 Colson’s Corollary, 125
binary (Stein), 24 complexity
Euclidean, 23, 142 bounded vs. explicit, 115
lookup, 205 depth-of-calls, c p (Φ0 )(~
x ), 111
nondeterministic, 129 intrinsic, 144
Pratt’s nuclid, 85 non-uniform (bit), 203
proofs of correctness, 101 number-of-calls, c s (Φ0 )(~x ), 110
sorting of a uniform process, ì(α, x ~ ),
binary-insert-sort, 27 136
insert-sort, 26 output, 146
lower bound, 153 parallel logical, l p (A, E(~ x )),
merge-sort, 21 108
nondeterministic, 157 parallel splitting, F p (M ), 121
what are they?, 99 sequential logical, l s (A, E(~x )),
algorithms from specified primitives, 107
21, 49, 99, 117 sequential splitting, F s (M ), 119
axioms, 129–133 tree-depth, D(M ), 104
I. Locality, 130 complexity inequalities, 115
II. Homomorphism, 131 for uniform processes, 137
III. Finiteness, 131 intrinsic vs. uniform process,
nondeterministic, 129 144
anthyphairesis, 23 Tserunyan, 124
arithmetic subtraction, x − ·
y, 7 Tserunyan 1, 121
arity Tserunyan 2, 123
of a function symbol, 30 computation model, see iterator
of an extended program, 50 computation models, 90–93
of an extended term, 38 computation sequences, 91
total, 108 computation tree, T (A, E, M ), 105
continuous, see functional
Bertrand’s Postulate, 204, 206 coprime, x⊥ ⊥ y, 8
best uniform process, 149 correct division equation, cde, 8
240 General index

correctness of algorithms, 101 First Recursion Theorem, 52


Fixed Point Lemma, 15
decision trees, 91 floor, bxc, 7
primitive, 91 forcing, A , 141
defaults fresh object, 39
program functional, 10
deterministic over nd, 82 A-recursive, 52
extended over plain, 50 continuous, 10
term explicit in A, 39
extended over plain, 39 monotone, 10
den(A, E(~ x )), 51 multiple valued (pmv), 84
depth-of-calls complexity, operations, 11
c p (Φ0 )(~
x ), 111 immediate, 41
diagram, see structure branching, 11
difficult pairs, 181, 182, 189 composition, 12
disjoint union, 31, 70 ë-substitution, 11
divides, y | x, 8 mangling, 11
Division Theorem substitution, 11
for N, 8 simple fixed point, 63
for Q[T ], with height bounds, tail recursive, 63
194
for K [T ], 192 generic, same as algebraically in-
double recursion, 57 dependent, 209
golden mean, ϕ, 27, 182
Embedding Test good approximation, 178
for logical extensions, 154
for substructure norms, 156 height
equational logic of partial terms of X ∈ C (~ a ; h), 171
with conditionals, 36 of a polynomial in Q[T ], 193
semantics, 38 hidden primitives, 131
syntax, 36–37 homomorphism property
explicit definability, 39 for explicit terms, 42
explicit iteration, 60 for nd programs, 87
explicit reduction and equivalence, for processes, 131
146 Homomorphism Test, 145
extended term, 38 homomorphisms, embeddings, 33
Horner’s rule, 25, 148
Fibonacci numbers, Fk , 24 optimality
properties, 27, 89, 182, 188 for {·, ÷}, 211
finite register machines (programs), for {·, ÷, =}, 216
90 for {+, −}, 218
primitive, 91 for {+, −, =}, 225
finiteness property
for nd programs, 87 imperative vs. functional program-
for processes, 131 ming, 101
General index 241

implementations, 73, 100 open problem, 65, 98, 99, 114, 125,
input, output sets, 9 126, 202, 208
intrinsic complexities, 144 operations on functionals, see func-
iterator, 69–70 tional
explicit representation, 71 optimality and weak optimality, 150–
nondeterministic, 82 151
output complexity, 146
Kleene strong equality, ', 10
pairing scheme, 80
ë-abstraction, 11 parallel calls complexity,
Lamé’s Lemma, 27 see depth-of-calls complex-
Liouville’s Theorem, 180 ity 111
logic of programs, 97 parallel logical complexity, 108
logical extension, 152 partial function, f : X * W , 9,
lookup algorithm, 205 see also functional
finite, 9
Main Conjecture, 2, 151 RAM computable, 91
mangling, see functional register computable, 90
many-sorted structure, see struc- strict composition, 10
ture partial multiple valued (pmv) func-
minimalization, ìy, 57 tion, 84, see also func-
monotone, see functional tional
Morris example, 20 partial ring homomorphism, 210
mutual tail recursion, 61 partial structure, see structure
Pell pairs, 177, 181
N -bit numbers, 203 Pell’s equation, 177
natural numbers, N, 7 Φ-structure, same as structure, 30
nd, same as nondeterministic Φ-terms, 36
nested recursion, 57 pointed structure, 59
non-uniform (bit) complexity, 203 minimal pointed extension, 60
nondeterministic iterator, see iter- polynomial evaluation, 25, 209
ator Pratt certificate, see certificate
nondeterministic programs, see re- Pratt’s nuclid algorithm, 85, 188
cursive programs predecessor arithmetic, 97
nondeterministic recursive machine, predecessor, Pd(x), 7
see recursive machine Presburger structure NPres , 44
Normal Form Theorem, 63 primitive recursion, 56, 68, 125
nullity, 0-testing, 25, 209 process, 130, see also uniform process
number-of-calls complexity, induced by a program, 130
c s (Φ0 )(~
x ), 110 example of non-uniform, 133
products, 9
obstruction to calls(A, R, x
~ ) = 0, programs, see recursive programs
147 pure term, 37
obstruction to depth(A, R, x~ ) = 0,
148 random access machines, 91
242 General index

time complexity, 138, 158 sort


recursion of an explicit term, 37
continuous, 15 splitting, see trees
double, 57 splitting term, 119
fixed point property, 16 Stirling’s formula, 9
minimality property, 16 straight line programs, 91
monotone, 19 strings, 12
nested, 57 structure, 30
primitive, 56 diagram, 32
recursive equation, 15 disjoint union, 31
canonical solution, 15 expansions and reducts, 31
system, 15 explicitly equivalent with an-
to solve, 19 other, 146
recursion rules, 17 explicitly reducible to another,
recursive machine, 74–75 146
nondeterministic, 83 many-sorted, 30
symbolic, 78 as one-sorted, 31
recursive programs, 49–51 pointed, 59
nondeterministic, 82 restrictions, 31
semantics, 84 substructure, A ⊆p B, 32
optimal, weakly optimal, 150 certificate, 34
semantics, 51 generated, Gm [X ], Gm (~x ), 33
syntax, 49 strong (induced), 32
extended, 50 total, 30
reduction substructure norm, 136
explicit, of one structure to bounded by K calls, 140
another, 146 symbolic computation, 78, 88
of iteration to tail recursion, syntactic (word) equality, ≡, 12
70
of recursion to iteration, 78 Tailrec(A), 64
relabelling isomorphism, 210 closure properties, 69
relatively prime, 8 Tailrec0 (A), 61
relativization, 63 tail recursion, 60
mutual, 61
schematology, 58 vs. full recursion, 94, 97–99,
Scott domain, 14 124, 126
section (of a functional), 11 vs. nd tail recursion, 98
sequential calls complexity, see number- tail recursive
of-calls complexity equation, 61
sequential logical complexity (time), function, 61
107 bounded stacks characteri-
sequential machine, see iterator zation, 94
sequential splitting complexity, 119 functional, 63
simple fixed points, 58 program, 61
General index 243

extended, 61
terms, 36
the binary (Stein) algorithm, 24
the binary-insert-sort algorithm, 27
the Euclidean algorithm, 23
coprimeness by the Euclidean,
24
the insert-sort algorithm, 26
the merge-sort algorithm, 21
tree-depth complexity, D(M ), 104
trees, 12
v below u, u v v, 13
children, 13
degree, 13
depth, 13
splitting depth, 13
leaf, 13
nodes, 12
root, 12
size, 13
splitting, 13
subtree, 13
Tserunyan’s first theorem, 121
Tserunyan’s second theorem, 123

unified notation for functions and


relations, f : An * As ,
31
uniform process, 132
best, 149
complexity, 136
deterministic, 158
induced by an nd program, 133
optimal, weakly optimal, 150–
151
Uniformity Thesis, 132

vocabulary, 29
infinite, 31

weakly optimal , see optimality

You might also like