On the Semantics of Intensionality

arXiv:1712.09302v1 [cs.LO] 26 Dec 2017

and Intensional Recursion

G. A. Kavvos
St John’s College
University of Oxford

A thesis submitted for the degree of
Doctor of Philosophy
Trinity Term 2017

This thesis is dedicated to my father, John G. Kavvos (1948–2015), who
taught me to persist in the face of all adversity.

Acknowledgements
A thesis in the making is a process of controlled deconstruction of its
author’s character. This fact in itself suffices to warrant a rich list of
acknowledgees.
First and foremost, I would like to thank my doctoral supervisor, Samson Abramsky, sine qua non. Not only did he suggest the—admittedly
unusual—topic of this thesis, but his unfailingly excellent advice and his
unparalleled wit were vital ingredients in encouraging me to plough on,
even when it seemed futile to do so. I shall never forget the time he quoted
the experience of J. E. Littlewood on the development of chaos theory:
“For something to do we went on and on at the thing with no
earthly prospect of “results”; suddenly the whole vista of the
dramatic fine structure of solutions stared us in the face.”
It was a pleasure to work for a few short years next to a scientist of his
stature, who also happens to be a kind man with a wonderful sense of
humour.
I also want to thank my examiners, Luke Ong and Martin Hyland, who
examined this work in detail, and provided many enlightening comments
and suggestions.
I am grateful to the UK Engineering and Physical Sciences Research Council (EPSRC) for their financial support. I am also greatly indebted to the
Department of Computer Science, the European Cooperation in Science
and Technology (COST) framework, and St John’s College, for generously
funding the trips involved in presenting my work to the wider community.
I would also like to thank all those who reviewed parts of this work before its completion. These include quite a few anonymous reviewers; John
Longley, who toiled over the first version of the manuscript on which this
thesis is based; Neil Jones, with whom I have had many interesting discussions during and after his visits to Oxford, and who also read many

parts of this thesis in detail; and my interim assessors within the department, Sam Staton and Hongseok Yang. This thesis could hardly have
been completed without their support and encouragement.
Many thanks to the fellow scientists around me: Kohei Kishida, for many
interesting discussions, for providing help and advice at a moment’s notice,
and for translating and transliterating the title of [Kiselyov, 2015]; Martin
Berger, for inviting me to Sussex to present my work, and for the numerous
exchanges that followed; and Sean Moss, who was eager to discuss all sorts
of interesting categorical diversions. Many thanks to Geraint Jones for
allowing me to use his macros for Eindhoven-style calculations.
I also want to thank my fellow students: Mario Alvarez, to whom I wish
the best of luck in his ongoing attempt to ‘debunk’ this thesis; Amar
Hadzihasanovic, for many discussions on higher category theory and its
applications; and Matthijs Vákár and Norihiro Yamada, who were always
eager to discuss categories, logic, and semantics.
Finally, I would like to thank Andrew Ker, who was my tutor during
my time as an undergraduate at University College, and my employer
thereafter. I learned an enormous amount from him as a student, and
even more whilst teaching under his supervision. I am indebted to him
for his wise advice, and all the things that he has inadvertently taught
me over a cup of coffee in the Senior Common Room. One would be
hard-pressed to find better guidance or more generosity.

4

Abstract
Intensionality is a phenomenon that occurs in logic and computation. In the
most general sense, a function is intensional if it operates at a level finer than
(extensional) equality. This is a familiar setting for computer scientists, who
often study different programs or processes that are interchangeable, i.e. extensionally equal, even though they are not implemented in the same way, so
intensionally distinct. Concomitant with intensionality is the phenomenon of
intensional recursion, which refers to the ability of a program to have access
to its own code. In computability theory, intensional recursion is enabled by
Kleene’s Second Recursion Theorem.
This thesis is concerned with the crafting of a logical toolkit through which
these phenomena can be studied. Our main contribution is a framework in
which mathematical and computational constructions can be considered either
extensionally, i.e. as abstract values, or intensionally, i.e. as fine-grained descriptions of their construction. Once this is achieved, it may be used to analyse
intensional recursion.
To begin, we turn to type theory. We construct a modal λ-calculus, called Intensional PCF, which supports non-functional operations at modal types. Moreover, by adding Löb’s rule from provability logic to the calculus, we obtain a
type-theoretic interpretation of intensional recursion. The combination of these
two features is shown to be consistent through a confluence argument.
Following that, we begin searching for a semantics for Intensional PCF. We
argue that 1-category theory is not sufficient, and propose the use of P-categories
instead. On top of this setting we introduce exposures, which are P-categorical
structures that function as abstractions of well-behaved intensional devices. We
produce three examples of these structures, based on Gödel numberings on
Peano arithmetic, realizability theory, and homological algebra.
The language of exposures leads us to a P-categorical analysis of intensional
recursion, through the notion of intensional fixed points. This, in turn, leads
to abstract analogues of classic intensional results in logic and computability,
such as Gödel’s Incompleteness Theorem, Tarski’s Undefinability Theorem, and
Rice’s Theorem. We are thus led to the conclusion that exposures are a useful
framework, which we propose as a solid basis for a theory of intensionality.
In the final chapters of the thesis we employ exposures to endow Intensional
PCF with an appropriate semantics. It transpires that, when interpreted in the
P-category of assemblies on the PCA K1 , the Löb rule can be interpreted as
the type of Kleene’s Second Recursion Theorem.

Contents
1 Introduction
1.1
1.2

1.3

1.4

1.5

1

Intensionality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
Objectives . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

1
2

1.2.1

Intensional Programming . . . . . . . . . . . . . . . . . . . . .

3

1.2.2

Reflective Programming . . . . . . . . . . . . . . . . . . . . .

4

1.2.3
1.2.4

Higher-Order Non-Functional Computation . . . . . . . . . . .
Recursion in Type Theory . . . . . . . . . . . . . . . . . . . .

5
7

Quoting is Impossible . . . . . . . . . . . . . . . . . . . . . . . . . . .

8

1.3.1

Tale 1: Quoting is Not Definable . . . . . . . . . . . . . . . .

9

1.3.2 Tale 2: Quoting Collapses Observational Equivalence . . . . .
Intensionality and Types: Modality-as-Intension . . . . . . . . . . . .

10
11

1.4.1

Modality-as-Intension . . . . . . . . . . . . . . . . . . . . . . .

11

1.4.2

A Puzzle: Intensional Recursion . . . . . . . . . . . . . . . . .

13

. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

15

2 Kleene’s Two Kinds of Recursion
2.1 Intensionality and Computability . . . . . . . . . . . . . . . . . . . .

18
19

2.2

2.3

A Road Map

2.1.1

The Space of All Programming Languages . . . . . . . . . . .

20

2.1.2

The Second Recursion Theorem . . . . . . . . . . . . . . . . .

23

2.1.3
2.1.4

Intensional Recursion . . . . . . . . . . . . . . . . . . . . . . .
Applications of Intensional Recursion . . . . . . . . . . . . . .

25
27

Extensional Recursion and the FRT . . . . . . . . . . . . . . . . . . .

31

2.2.1

Effective Operations . . . . . . . . . . . . . . . . . . . . . . .

31

2.2.2 Partial Recursive Functionals and Pure Oracles . . . . . . . .
FRT vs. SRT . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

36
38

2.3.1

Effective Operations and the SRT . . . . . . . . . . . . . . . .

38

2.3.2

Partial Recursive Functionals and the SRT . . . . . . . . . . .

42

i

3 iPCF: An Intensional Programming Language

44

3.1

Introducing Intensional PCF . . . . . . . . . . . . . . . . . . . . . . .

45

3.2

Metatheory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
3.2.1 Structural Theorems & Cut . . . . . . . . . . . . . . . . . . .

46
46

3.2.2

Free variables . . . . . . . . . . . . . . . . . . . . . . . . . . .

48

Consistency of Intensional Operations . . . . . . . . . . . . . . . . . .

50

3.3.1
3.3.2

Adding intensionality . . . . . . . . . . . . . . . . . . . . . . .
Reduction and Confluence . . . . . . . . . . . . . . . . . . . .

50
55

3.4

Some important terms . . . . . . . . . . . . . . . . . . . . . . . . . .

61

3.5

Two intensional examples . . . . . . . . . . . . . . . . . . . . . . . . .

62

3.5.1
3.5.2

‘Parallel or’ by dovetailing . . . . . . . . . . . . . . . . . . . .
A computer virus . . . . . . . . . . . . . . . . . . . . . . . . .

63
64

Open Questions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

65

3.3

3.6

4 Categories and Intensionality
4.1

4.2

66

Categories are not intensional . . . . . . . . . . . . . . . . . . . . . .

67

4.1.1
4.1.2

Intension, Modality, and Categories . . . . . . . . . . . . . . .
PERs and P-categories . . . . . . . . . . . . . . . . . . . . . .

68
72

Exposures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .

77

4.2.1

Intensional Equality . . . . . . . . . . . . . . . . . . . . . . .

79

4.2.2
4.2.3

Cartesian and Product-Preserving Exposures . . . . . . . . . .
Comonadic Exposures . . . . . . . . . . . . . . . . . . . . . .

80
84

4.2.4

Idempotent Comonadic Exposures . . . . . . . . . . . . . . . .

86

4.2.5

Weakly Cartesian Closed Exposures . . . . . . . . . . . . . . .

93

5 Three Examples of Exposures
5.1

5.2

5.3

95

Exposures as Gödel Numbering . . . . . . . . . . . . . . . . . . . . .
5.1.1 The Lindenbaum P-category . . . . . . . . . . . . . . . . . . .

95
96

5.1.2

97

Numbering as Exposure . . . . . . . . . . . . . . . . . . . . .

Exposures in Realizability . . . . . . . . . . . . . . . . . . . . . . . . 100
5.2.1
5.2.2

Partial Combinatory Algebras . . . . . . . . . . . . . . . . . . 100
Assemblies and Modest Sets . . . . . . . . . . . . . . . . . . . 104

5.2.3

Passing to a P-category . . . . . . . . . . . . . . . . . . . . . 105

5.2.4

The Exposure . . . . . . . . . . . . . . . . . . . . . . . . . . . 107

5.2.5 Weak Extensionality and Naturality . . . . . . . . . . . . . . . 113
Exposures in Homological Algebra . . . . . . . . . . . . . . . . . . . . 115
5.3.1

The P-category Grp . . . . . . . . . . . . . . . . . . . . . . . 115
ii

5.3.2

Intensionality and Homomorphisms . . . . . . . . . . . . . . . 116

6 Intensional Recursion in P-Categories
6.1

118

Extensional and Intensional Fixed Points . . . . . . . . . . . . . . . . 119
6.1.1
6.1.2

Consistency, Truth and Provability: Gödel and Tarski . . . . . 120
Rice’s theorem . . . . . . . . . . . . . . . . . . . . . . . . . . 123

6.2

The relationship to Löb’s rule . . . . . . . . . . . . . . . . . . . . . . 124

6.3

Whence fixed points? . . . . . . . . . . . . . . . . . . . . . . . . . . . 129
6.3.1
6.3.2

6.4

Lawvere’s Theorem . . . . . . . . . . . . . . . . . . . . . . . . 129
An intensional Lawvere theorem . . . . . . . . . . . . . . . . . 132

Examples of Fixed Points . . . . . . . . . . . . . . . . . . . . . . . . 133
6.4.1

Fixed Points in Gödel numbering: the Diagonal Lemma . . . . 133

6.4.2

Fixed Points in Assemblies: Kleene’s Recursion Theorems . . 134

7 Intensional Semantics of iPCF I
138
7.1 Setting the scene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139
7.2

Distribution and naturality laws . . . . . . . . . . . . . . . . . . . . . 141

7.3

Fixed Points with Parameters . . . . . . . . . . . . . . . . . . . . . . 145
7.3.1
7.3.2

7.4

Extensional Fixed Points with Parameters . . . . . . . . . . . 146
Intensional Fixed Points with Parameters . . . . . . . . . . . . 149

A Parametric Intensional Lawvere Theorem . . . . . . . . . . . . . . 153

8 Intensional Semantics of iPCF II

156

8.1

iPCF v2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157

8.2
8.3

Interpreting iPCF v2.0 . . . . . . . . . . . . . . . . . . . . . . . . . . 162
Soundness . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165

8.4

Natural and Weakly Extensional Models . . . . . . . . . . . . . . . . 171
8.4.1

Natural iPCF v2.0 models . . . . . . . . . . . . . . . . . . . . 171

8.5

8.4.2 Weakly Extensional iPCF v2.0 models, or iPCF models . . . . 173
Building IPWPSs categorically . . . . . . . . . . . . . . . . . . . . . . 175

8.6

Asm(K1 ) as a model of iPCF v2.0 . . . . . . . . . . . . . . . . . . . . 180

9 Conclusions & Future Work

184

9.1

Is intensionality really just non-functionality? . . . . . . . . . . . . . 186

9.2

How expressive is iPCF? . . . . . . . . . . . . . . . . . . . . . . . . . 187
9.2.1 Metaprogramming . . . . . . . . . . . . . . . . . . . . . . . . 187
9.2.2

Higher-Order Computability . . . . . . . . . . . . . . . . . . . 189

iii

9.2.3

iPCF, iPCF v2.0, and their models . . . . . . . . . . . . . . . 189

9.3

Exposures vs. other theories of intensionality . . . . . . . . . . . . . . 191

9.4

9.3.1 An Idea for an Alternative Approach . . . . . . . . . . . . . . 194
Kleene’s mysterious Second Recursion Theorem . . . . . . . . . . . . 195

9.5

Concluding remarks . . . . . . . . . . . . . . . . . . . . . . . . . . . . 196

A iPCF v2.0 in Agda

197

A.1 Basics.agda . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 197
A.2 iPCF.agda . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201
A.3 iPCF2.agda . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 207
Bibliography

214

iv

List of Figures
1.1

Chapter dependencies . . . . . . . . . . . . . . . . . . . . . . . . . . .

17

3.1

Syntax and Typing Rules for Intensional PCF . . . . . . . . . . . . .

47

3.2
3.3

Reduction for Intensional PCF . . . . . . . . . . . . . . . . . . . . . .
Equational Theory for Intensional PCF . . . . . . . . . . . . . . . . .

53
54

3.4

Parallel Reduction . . . . . . . . . . . . . . . . . . . . . . . . . . . .

57

6.1

Types of Fixed Points (without parameters) . . . . . . . . . . . . . . 124

8.1

Syntax and Typing Rules for Intensional PCF v2.0 . . . . . . . . . . 158

8.2

Equational Theory for Intensional PCF v2.0 . . . . . . . . . . . . . . 161

8.3

Categorical Semantics for Intensional PCF v2.0 . . . . . . . . . . . . 164

This is the arXiv version of this thesis (identical to build 7049), and was compiled
on December 27, 2017.

v

Chapter 1
Introduction
This thesis concerns the computational phenomenon of intensionality.

1.1

Intensionality

To be intensional is to contain not only reference, but also sense. This philosophical
distinction was drawn by Frege; see Fitting [2015]. An intensional sign denotes an
external referent, yet inherently connotes more information—its elusive sense. The
classic example is that of the planet Venus, which may be referred to as either the
morning star, or the evening star.
In the most mathematically general sense, to be ‘intensional’ is to somehow operate
at a level finer than some predetermined ‘extensional’ equality. Intensionality is omnipresent in constructive mathematics, where the question of equality is non-trivial,
see e.g. Beeson [1985]. An example that dates back to the work of Bishop [1967]
on constructive analysis is that of real numbers, and their construction as Cauchy
sequences of rationals: two different Cauchy sequences of rationals may stand for the
same real number, thus being extensionally equal, yet intensionally distinct.
Most mainstream mathematics is extensional: we usually reason about some underlying, ‘ideal’ mathematical object, and not its concrete descriptions. The latter is
only a way to refer to the former. In this light, intensionality is merely a nuisance,
so common set theories assume some axiom of extensionality: sets are identified by
their members, and functions by their graphs. Glimpses of intensionality appear very
rarely, and usually only because we are interested in proving that some extensionality
axiom is independent from the rest of some logical theory: see e.g. Streicher [2015]
for a recent example.
This is a difficult-to-work-in setting for Computer Science, where intensionality is
the norm. In fact, the present author believes that it would be fair to say that many
1

branches of computer science are in essence the study of programs and processes seen
under some appropriate notion of equality. At one end of the spectrum, correctness of
programs is discussed in the context of some relation of observational equivalence, i.e.
indistinguishability of programs. Intermediately, complexity theory requires a slightly
stronger notion, which we could call complexity equivalence: this is observational
equivalence strengthened by some account of the resources the program consumes.
At the other extreme, computer viruses sometimes make decisions based strictly on
patterns of object code they encounter, disregarding the actual function of what
they are infecting; one could say they operate up to α-equivalence, i.e. syntactic
identity. Each of the aforementioned notions of equality is more intensional than the
one preceding it, and each level is interesting in its own right.
Thus, depending on our point of view, there are always two ways in which we
can see a computational process. There is an extensional level, which corresponds to
what may be computed. But there is also an intensional level, corresponding to the
programs and processes that carry out the computation. The shift between these two
viewpoints has been discussed by Moschovakis [1993] and Abramsky [2014]: computational processes may be understood by the ideal objects that they refer to (e.g.
functions), or their internal characteristics: length, structure, and, ultimately, the
algorithm they embody.
This thesis concerns the difficulties that arise when we are trapped between intension and extension, or description and behaviour.

1.2

Objectives

The main objective of this thesis is to answer the following question:
Is there a consistent, logical universe where the same mathematical objects
can be viewed both as intension, and extension?
This research programme is a suggestion of Abramsky [2014]; in his words:
The notions of intensionality and extensionality carry symmetric-sounding
names, but this apparent symmetry is misleading. Extensionality is enshrined in mathematically precise axioms with a clear conceptual meaning.
Intensionality, by contrast, remains elusive. It is a “loose baggy monster”
into which all manner of notions may be stuffed, and a compelling and
coherent general framework for intensional concepts is still to emerge.

2

Our discussion in the previous section hints at the fact that the choice of what is
extensional, and thereby what is intensional is entirely up to us. There are many
shades on the spectrum between ideal mathematical object and full symbolic description, and the choice of perspective depends on what we wish to study. However, the
design of a mathematical framework or universe where both the extensions and intensions of our choice co-exist harmoniously is the difficult and well-defined problem
with which this thesis is concerned.
The present author believes that such a framework will be instrumental in making
progress in providing answers to the following questions:
1. What is the meaning of intensional programming? Is there a logical interpretation of it?
2. What is the meaning of reflective programming? Is it possible to program
reflectively in a consistent way?
3. What is the meaning of intensional operations in a higher-order setting? How
can we have a non-functional operation without resorting to first-order manipulations of Gödel numbers?
4. How can we add recursion to type theory?
The theory developed in this thesis fully addresses the first two of these questions.
Considered as a toolkit, it is likely to be useful in answering the third one. The fourth
one is left for future work. Nevertheless, we shall now briefly consider all of them.

1.2.1

Intensional Programming

In the realm of functional computation, we can immediately distinguish two paradigms:
• The Extensional Paradigm. It has been exactly 50 years since Christopher
Strachey articulated the notion of functions as first-class citizens in his influential notes on programming [Strachey, 2000]. In a purely functional world, a
higher-order program can use a functional argument extensionally by evaluating
it at a finite number of points: this leads to a form of continuity, which is the
basis of domain theory [Abramsky and Jung, 1994].
• The Intensional Paradigm. This way of computing originated in computability theory [Cutland, 1980, Jones, 1997]: a program can compute with the source
code—or intension—of another program as an argument. It can edit, optimise,
call, or simulate the running of this code.
3

Whereas the first paradigm led to a successful research programme on the semantics of programming languages, the second is often reduced to symbolic evaluation.
This is one of the reasons for which the intensional paradigm has not reached the sophistication of its extensional counterpart. Yet, the question remains: what can the
intensional paradigm contribute to programming? What is the additional expressivity
or programming power afforded by intensionality?
This is a theme that is often discussed by the Lisp community. Indeed, certain
dialects of Lisp are the closest we have to a true paradigm of intensional programming,
both through Lisp macros [Graham, 1993] as well the construct of quoting [Bawden,
1999]. Either of these features can also be used for metaprogramming, which is the
activity of writing programs that write other programs.
The notion of intensional programming is also central to the work of the partial
evaluation community, which uses a rather extreme form of intensionality that is better known under the name programs-as-data: see Jones et al. [1993], Jones [1996,
1997]. Their work uses insights from computability theory and Gödel numberings to
build a metaprogramming-oriented methods for the automatic generation of compilers, all based on the power of the s-m-n theorem of computability theory: see §2.1.4
for more details and references. Even though Lisp-inspired, and never seriously considering non-functional operations, this is perhaps the closest anybody has come to
what we mean by intensional programming.
But, to this day, no satisfying theoretical account of intensionality in programming
has been produced. The present author believes that this has to do with the fact that
Lisp is an unstructured, untyped language. Hence, it is not amenable to any kind
of analysis, other than maybe that of the untyped λ-calculus [Barendregt, 1984]. See
also Wadler [1987] for an early critique of Scheme in programming methodology.
We shall introduce a new approach to intensional programming that is fundamentally typed in §3.

1.2.2

Reflective Programming

For a very long time, programmers and theoreticians have sought to understand
computational reflection, a concept introduced by Brian Cantwell Smith [1982, 1984].
Computational reflection is an obscure idea that has been used in a range of settings:
see Demers and Malenfant [1995] for a (slightly dated) survey. In broad strokes, it
refers to the ability of a program to access its own code, refer to its own description,
or examine its own internals.

4

The kind of reflection envisaged by Brian Cantwell Smith was to be implemented
by using reflective towers. The idea is that a program could be understood as running
on the topmost level of an infinity of interpreters. Reflective constructs then accept
code that is to be injected to the interpreter situated one level below, hence having
access to the complete state of the top-level interpreter, all its registers and variables,
and so on—to infinity. This is a rather mysterious construction with unclear semantics
that have been the subject of investigation by Friedman and Wand [1984], Wand and
Friedman [1988], and Danvy and Malmkjaer [1988]. This line of work eventually
concluded with a theorem of Wand [1998], which shows that there are no useful
semantic descriptions of the reflective tower. We will discuss Wand’s result in §1.3.2.
Despite its being poorly understood, computational reflection seems to be a recurring and useful concept. Demystifying it is a pressing problem, as many modern
programming languages have reflective or ‘introspective’ facilities that lead to pernicious bugs. The author suspects that a central theme of this thesis, the notion of
intensional recursion, will prove fundamental in obtaining a logical foundation for
reflection. To quote Polonsky [2011]:
Of course, they [the questions posed by Smullyan] are only a sliver in the
more global puzzle of understanding reflection as a distinct phenomenon.
There is still lacking a general concept, an all-inclusive definition through
which the common features of the constructions in Gödel’s theorem, computability, number theory (systems of arithmetic), and set theory could
be related. Finding such a concept remains a fascinating open problem.
We believe that the notion of intensional fixed points, to which we devote §6, is
precisely an abstract definition of (well-behaved) reflection. Our framework thereby
provides a candidate solution to the problem of Polonsky.

1.2.3

Higher-Order Non-Functional Computation

Over the past years, a new field of theoretical computer science has emerged under
the name of higher-order computability. As a subject, higher-order computability
has its roots in the 1950s, but the work of Longley [2005] has produced a unifying
account that overlaps significantly with the study of logic, λ-calculus, category theory,
realizability theory, and the semantics of programming languages; see the recent book
by Longley and Normann [2015].

5

In classical computability theory [Rogers, 1987, Cutland, 1980, Odifreddi, 1992]
there was a confluence of ideas [Gandy, 1988] in the 1930s, culminating in the ChurchTuring thesis, viz. that all ‘effectively calculable’ functions—whatever that might
mean—are partial recursive. In contrast, higher-order computability suffers from a
Church-Turing anti-thesis: there are multiple notions of computation at higher order,
and some of them can be shown to be strongly incompatible with each other. This situation generates a lot of debate regarding which notion of higher-order computability
is ‘more natural’ than the others: see the discussion in [Longley, 2005, §1]
Perhaps one of the most difficult challenges in higher-order computability is to
clarify what intensional, or non-functional higher-order computation is. This does
not only pertain to computation with the usual effects, like memory, exceptions,
or first-class continuations: such effects are well-understood, either through game
semantics [Abramsky and McCusker, 1996, Abramsky et al., 1998], or more abstractly
through the various theories of effects: see [Moggi, 1989, 1991, Plotkin and Power,
2004, Hyland and Power, 2007, Levy, 2003]. Instead, we consider more general nonfunctional computation, where the non-functional aspect arises from the ability of a
device to read the description or code of its higher-order argument.
A known example that is impossible to accommodate in an extensional setting is
the modulus of continuity functional. This is a type 3 functional,
Φ : ((N → N) → N) → N
Intuitively, when given a type 2 functional F : (N → N) → N, Φ(F ) returns an upper
bound n on the range of values F would examine of any argument given to it, so that
if f, g : N → N agree on those values, i.e.
∀i ∈ {0, . . . , n}. f (i) = g(i)
then F f = F g. It can be shown that one cannot define a modulus of continuity functional that is extensional. To compute Φ(F ) it is necessary to examine the internals
of F : we simulate its run on some function, and see what the maximum argument it
examines is. This can be computed in a language with side-effects: we call F (f♠ ),
where f♠ uses side-effects to record the maximum value at which it is called, and Φ(F )
then returns this recorded value. We can see that this is highly dependent on the
way F is implemented, and thus not extensional: see the blog post of Andrej Bauer
[2011]. The question we want to ask in this setting is this: can we make the modulus
of continuity computable, perhaps by admitting it at certain intensional types only,
but without generally violating neither extensionality nor freedom from side effects?
6

The main ways to understand such computation are either through a ‘highly
intensional,’ essentially untyped, first-order formulation, which suffers from a lack of
logical structure and useful properties; or through computational effects, which is even
less clear in terms of higher-order computability. One way out of this impasse has been
suggested by Longley [Longley, 2005, §6], and it employs realizability. Longley argues
that posing the question of whether a non-functional operation is definable amounts
to writing down a logical formula that specifies it, and then examining whether that
formula is realizable: see [Longley, 1999a] and the note [Longley, 1999b].
Whereas this is an informative approach, it does not smoothly lead us toward
the design of programming languages that harness these non-functional powers. We
propose, instead, the following research programme: we should first use the typetheoretic techniques proposed in this thesis to add intensionality to a λ-calculus.
Then, we shall be able to vary the intensional operations available, and study the
expressivity of the resulting systems.

1.2.4

Recursion in Type Theory

General recursive definitions are prohibited in most type theories, including MartinLöf type theory (MLTT) [Martin-Löf, 1998, 1984, Nordström et al., 1990]. This is
not an arbitrary design choice: MLTT features dependent types, i.e. types depend on
terms. Thus, its terms ought to be strongly normalising, so that the types themselves
are.
In that way, MLTT is logically well-behaved, but not ideal for programming. In
fact, writing down the definitions of many ordinary programs becomes a difficult
exercise. The intuitive reason is that every program we want to write must somehow
contain its own proof of termination. A lot of work has gone into regaining the lost
expressivity, from the results of Constable and Smith [1993] on partial types, to the
method of Bove and Capretta [2005], and all the way to the coinductive types of
Capretta [2005] and the delay monad. There is also recent work on the partiality
monad and higher inductive types: see Altenkirch et al. [2017].
In any case, working within MLTT has a fundamental disadvantage: an old theorem of Blum [1967] ensures that, no matter what kind of ‘blow-up factor’ we choose,
we will be able to write a program (in a partial, Turing-complete language) whose
shortest equivalent in a total programming language is larger by the given factor: see
the blog post of Harper [2014]. Thus, ultimately, there is no working around this
theorem: at some point we might have to add general recursion to type theory.

7

In the setting of simple types adding recursion is relatively easy. It was first done
by Scott [1993] and Plotkin [1977], who defined the prototypical fixed point language
PCF, a simply-typed λ-calculus of booleans, integers, and a fixed point combinator
Y : (A → A) → A. There is a long and rich literature on the models of PCF: the
reader may consult any of [Plotkin, 1977, Gunter, 1992, Mitchell, 1996, Abramsky
et al., 1996, Hyland and Ong, 2000, Streicher, 2006, Longley, 1995].
Merely throwing Y into the mixture is not advisable in more expressive type
theories, e.g. in System F or MLTT. If sum or Σ types are available (or are definable,
e.g. in System F), a theorem of Huwig and Poigné [1990] guarantees that the resulting
theory will be inconsistent: even the existence of the coproduct 1 + 1 is enough to
make a cartesian closed category with fixpoints degenerate to a preorder.
A short abstract by Plotkin [1993] proposes that we forget the cartesian setting,
and work in either a (second-order) intuitionistic linear type theory, or a relevant type
theory. The full manuscript for that abstract never appeared, but the linear type
system to which it refers (but without recursion) was studied in detail by Barber
[1996].
Further efforts went into defining a Linear PCF, based on these intuitions. Invariably, the type of Y or the rule for recursion has one of the following forms:
!(!A ( A) ( A
!(!A ( A)
A
!(!A ( A)

Braüner [1995, 1997]
Maraist et al. [1995], Bierman [2000]
Maraist et al. [1995]

!A
We will shortly see that this pattern is not accidental. We will develop a type-theoretic
approach to intensionality that will admit a slightly unusual kind of recursion, namely
intensional recursion. Its type-theoretic interpretation will be strongly reminiscent
of the pattern of these rules, but linearity will prove to be a red herring.

1.3

Quoting is Impossible

The first impression that one usually acquires regarding intensional phenomena is that
they can only spell trouble. After all, encoding programs or logical formulae as data
in the same language is the typical function of Gödel numbering. Such constructs
quickly lead to negative theorems that pinpoint the inherent limitations of logical
systems, e.g. Gödel’s First Incompleteness Theorem [Smullyan, 1992].

8

Our aim in this thesis is to tell a positive story, but we shall first recount the
negative tales of the past. We shall not engage in a foundational debate regarding
Gödel’s theorems and related results here, but a more in-depth discussion can be
found in §6, in the book of Smullyan [1992], and in [Girard, 2011, §2]. Instead, we
will focus on the negative repercussions on programming.

1.3.1

Tale 1: Quoting is Not Definable

Let Λ be the set of untyped λ-terms [Barendregt, 1984], and let
p·q : Λ → Λ
be a map on λ-terms. The intention is that, for each λ-term M , the term pM q
represents the program M as a datum in the λ-calculus. We call pM q the quote
of M . The properties of such (external) quoting functions p·q : Λ → Λ have been
systematically studied by Polonsky [2011], who also broadly surveys the sporadic
literature on such ‘meta-encodings’ of the λ-calculus into itself.
In standard accounts, e.g. [Barendregt, 1984], the quote function is a Gödel numbering, as known from the literature on Gödel’s theorems. To each term M one assigns
a number #M , and defines pM q to be the Church numeral for #M .
A fundamental question then arises: is quoting internally definable? The answer
is, of course, negative, as internal definability of quoting would lead to inconsistency.
The following argument is due to Barendregt [1991]: suppose there is a term Q ∈ Λ
such that
Q M =β pM q
It is a fact that Church numerals are in normal form. Hence, both pIq and pI Iq are
def

in normal form, where I = λx. x is the identity combinator. We have that
pIq =β Q I =β Q (I I) =β pI Iq
This amounts to equating two distinct normal forms. But it is known that the λcalculus is confluent, hence consistent! It follows that such a term Q cannot exist.
It is very important to notice that the crux of the argument essentially rests on
the confusion between the extension M , the intension pM q, and the ability to pass
from extension to intension. To obtain a consistent account of intensionality we ought
to forbid this possibility. However, let us seize the opportunity to remark that the
opposite direction is not only attainable, but a result of historical importance for
computability theory [Kleene, 1936, 1981]:
9

Theorem 1 (Kleene [1936]). There exists a term E ∈ Λ0 such that
E pM q β M
for all M ∈ Λ0 .
This is essentially the same result as the one obtained by Turing [1937], but for the
λ-calculus instead of the Turing Machine. See [Barendregt, 1984, §8.1.6] for a proof.

1.3.2

Tale 2: Quoting Collapses Observational Equivalence

Let us suppose that the above result does not deter us in our plans to add reflection
to the λ-calculus. All else failing, we can do so by postulating constants eval and
fexpr, along with the following reductions:
eval pM q −→ M
(fexpr V ) M −→ V pM q
where V is some notion of value (e.g. a weak head normal form). Then Q would be
definable as fexpr (λx. x).
One of the most interesting and well-studied notions in λ-calculus is that of observational equivalence. Two terms M, N are observationally equivalent, written M ∼
= N,
if they are interchangeable in all possible contexts, without any ‘observable changes.’
The notion of observable change is up for debate, and the exploration of different options leads to interesting variations—see e.g. Bloom and Riecke [1989] and Abramsky
[1990]. The usual choice is that we can observe normal forms at ground type (i.e.
different numerals and boolean values), or—equivalently—termination of evaluation
at ground type. If M =β N , then certainly M ∼
= N , but the converse is not normally
true: terms can be observationally equivalent, but the theory of equality (which is
only computably enumerable) is not strong enough to show that.
In this context, Wand [1998] showed the following theorem:
Theorem 2 (Wand). M ∼
= N if and only if M ≡α N
Wand’s definition of observation is termination at a weak head normal form, and his
quoting function p·q is a Scott-Mogensen encoding: see [Polonsky, 2011, Mogensen,
1992]. However, the result is strong and general, and puts the last nail in the coffin: there can be no semantic study of functional programming languages that are
so strongly reflective that they can internally define quoting. Such a language can
internally distinguish any two terms in the language, as long as they are not equal
up to renaming. This result concludes the long line of research on Smith’s reflective
towers that we mentioned in §1.2.2.
10

1.4

Intensionality and Types: Modality-as-Intension

The two negative tales we have just told are, fortunately, not the final word. If we take
a close look at the existing literature, e.g. at the chapters of [Barendregt, 1984] that
concern computability and diagonal arguments, we may see that some intensional
operations are indeed definable. For example, there are λ-terms gnum, app and E
such that
gnum pM q =β ppM qq
app pM q pN q =β pM N q
E pM q =β M
We mentioned E in the previous section, but the other two might come as a surprise:
they are indeed pure operations on syntax. The pattern that seems to be at work
here is that the only true restriction is quoting, and that everything else is admissible.
The standard way to enforce restriction in computation is to use types. Indeed,
the main contribution of this thesis is a detailed investigation and analysis of the
following idea:
Intensionality adheres to a typing discipline.
This is an old but not so well-known observation. To the best of our knowledge, it
was first formulated by Neil Jones,1 and led to his work on underbar types: see [Jones
et al., 1993, §16.2].

1.4.1

Modality-as-Intension

Given a type A, let us write Code(A) for the type of code of type A. We must certainly
have that, if M : A, then pM q : Code(A). Thus, if gnum pM q =β ppM qq, then it
must have the type
gnum : Code(A) → Code (Code(A))
This looks familiar! If we drop all pretense and write A for Code(A), we obtain the
following types:
gnum : A → A
app : (A → B) → A → B
E : A → A
1

Personal communication.

11

Surprisingly, there is an underlying Curry-Howard correspondence: the types of these
operations correspond to the axioms 4, K and T of the modal logic S4. This connection
to modal logic was drawn by Davies and Pfenning [1996, 2001], who used it to embed
two-level λ-calculi [Nielson and Nielson, 1992] in a modal λ-calculus, and to perform
binding-time analysis.
We will thus introduce and study the modality-as-intension interpretation. This
is an idea that pervades [Davies and Pfenning, 1996, 2001], and is even mentioned in
name in the conclusion of [Pfenning and Davies, 2001]. To quote:
One particularly fruitful interpretation of A is as the intensional type for
expressions denoting elements of type A. Embedding types of this form
in a programming language means that we can compute with expressions
as well as values. The term box M quotes the expression M , and the
construct let box u ⇐ M in N binds u to the expression computed by
M and then computes the value of N . The restrictions placed on the
introduction rule for A mean that a term box M can only refer to other
expression variables u but not value variables x. This is consistent with
the intensional interpretation of A, since we may not know an expression
which denotes a given value and therefore cannot permit an arbitrary value
as an expression.
The above excerpt refers to the modal type system introduced and used by Davies
and Pfenning, which is a dual-context λ-calculus, with judgements of the form
∆;Γ`M :A
where ∆ and Γ are two ordinary but disjoint contexts. The variables that occur in ∆
are to be thought of as modal variables, or variables that carry intensions or codes,
whereas the variables in Γ are ordinary (intuitionistic) variables. In this system, the
evaluator E : A → A exists as a variable rule, i.e. the ability to use a code variable
as if it were a value:
∆, u:A, ∆0 ; Γ ` u : A
The canonical terms of modal type are of the form box M , and they largely mimic
the Gödel numbering pM q. The shape of the introduction rule guarantees that all
the variables that occur in the ‘boxed term’ M are code variables, and not value
variables; we write · for the empty context:
∆;·`M :A
∆ ; Γ ` box M : A
12

And, as mentioned above, there is also a let box u ⇐ (−) in (−) construct that allows
for substitution of quoted terms for code variables:
∆ ; Γ ` M : A ∆, u:A ; Γ ` N : C
∆ ; Γ ` let box u ⇐ M in N : C
along with the reduction
let box u ⇐ box M in N −→ N [M/u]
The let box u ⇐ (−) in (−) construct secretly requires (A × B) ∼
= A × B, which
is just enough to define the app : (A → B) → A → B constant.
Finally, the 4 axiom is inherent in the system:
u:A ; · ` u : A
u:A ; · ` box u : A
· ; x : A ` x : A

u:A ; x : A ` box box u : A

· ; x : A ` let box u ⇐ x in box box u : A
The author has previously studied such dual-context systems in [Kavvos, 2017b].

1.4.2

A Puzzle: Intensional Recursion

We touched upon the subject of recursion in type theory in §1.2.4. To obtain recursion
in simple types, we have to add a fixed point combinator Y : (A → A) → A, and
obtain PCF. In contrast, recursion is definable in the untyped setting. This is the
conclusion of the First Recursion Theorem [Barendregt, 1984, §2.1, §6.1]:
Theorem 3 (First Recursion Theorem). ∀f ∈ Λ. ∃u ∈ Λ. u = f u.
Proof. Let
def

Y = λf.(λx.f (xx))(λx.f (xx))
Then Yf =β f (Yf ).
The FRT corresponds to extensional recursion, which is what most programming
languages support. When defining a recursive function definition, a programmer
may make a finite number of calls to the definiendum itself, in the same vein as
our description of the functional-extensional paradigm in §1.2.1. Operationally, this
leads a function to examine its own values at a finite set of points at which it has—
hopefully—already been defined.

13

However, as Abramsky [2014] notes, in the intensional paradigm, which we also
described in §1.2.1, a stronger kind of recursion is attainable. Instead of merely examining the result of a finite number of recursive calls, the definiendum can recursively
have access to a full copy of its own source code. This is embodied in the Second
Recursion Theorem (SRT), which was proved by Kleene [1938]. Here is a version of
the SRT in the untyped λ-calculus [Barendregt, 1984, §6.5]:
Theorem 4 (Second Recursion Theorem). ∀f ∈ Λ. ∃u ∈ Λ. u = f puq.
def

Proof. Given f ∈ Λ, set u = W pW q, where
def

W = λx. f (app x (gnum x))
where app and gnum are as above. Then
u ≡ W pW q
=β f (app pW q (gnum pW q))
=β f (app pW q ppW qq)
=β f (pW pW qq)
≡ f puq

It is not hard to see that, using Kleene’s interpreter for the λ-calculus (Theorem 1),
the SRT implies the FRT. It is not at all evident whether the converse holds. This
is because the FRT is a theorem that concerns higher-order computation, whereas
the SRT is very much grounded on first-order, diagonal constructions. The exact
relationship between these two theorems is the subject of §2.
The point that we wish to make is that, in the presence of intensional operations,
the SRT affords us with a much stronger kind of recursion. In fact, it allows for
exactly the sort of computational reflection that we discussed in §1.2.2.
Perhaps the greatest surprise to be found in this thesis is that the SRT admits a
type. Indeed, suppose that u : A. Then certainly puq : A, and it is forced that
f : A → A
The Curry-Howard reading of the SRT is then the following: for every f : A → A,
there exists a u : A such that u = f puq. This corresponds to Löb’s rule from
provability logic [Boolos, 1994]:
A → A
A
14

Löb’s rule is equivalent to adding the Gödel-Löb axiom,
(A → A) → A
to a modal logic. One of the punchlines of this thesis will be that
The type of the Second Recursion Theorem is the Gödel-Löb axiom.
Thus, to obtain reflective features, all we have to do is add a version of Löb’s rule to
the Davies-Pfenning modal λ-calculus.

1.5

A Road Map

The rest of this thesis consists of a thorough discussion of the above observations,
and the development of appropriate syntax and categorical semantics that capture
the aforementioned intuitions.
In §2, we dive back to find the origins of Kleene’s two Recursion Theorems. As
it happens, these correspond to the two ways in which we can define a mathematical
object by recursion: one can either use diagonalisation, or some kind of infinite (or
transfinite) iteration. The origin of both of these methods is lost in the mists of
time, but both find their first documented expressions in the work of Kleene [1952,
1938]. §2 states and proves these two theorems, and engages in a thorough discussion
regarding their similarities and differences. Whereas the SRT works by diagonalising
and is applicable to a first-order setting, the FRT requires a higher-order perspective.
In some cases both theorems are applicable, but one is stronger than the other: the
FRT always produces least fixed points, but this is not always the case with the SRT.
Nevertheless, an old result by Hartley Rogers Jr. bridges this gap. We also find the
opportunity to engage in some speculation regarding the possible applications of the
reflective features provided by the SRT.
In §3, we revisit the system of Pfenning and Davies [2001] that we described in
§1.4. After noting that it does not feature any actual intensional operations, we add
some to the system. We also take the hint from §1.4.2, and add a form of Löb’s
rule as well. The result is a programming language that is (a) intensional, exactly in
the sense described in §1.2.1, and (b) reflective, in the sense described in §1.2.2. A
confluence proof ensures that the resulting system, which we call Intensional PCF, is
consistent. It is evident that the central device by which everything comes together
is the modal types, which separate the two worlds of intension and extension, by way
of containing the former under the modality.
15

Following that, in §4 we begin to seek categorical semantics for intensionality. We
argue that 1-category theory is ill-suited for modelling intensionality. We are thus led
to consider the P-categories of Čubrić, Dybjer and Scott [Čubrić et al., 1998], which
are categories only up to a partial equivalence relation (PER). In this setting, we
introduce a new P-categorical construct, that of exposures. Exposures are very nearly
functors, except that they do not preserve the PERs of the P-category, but reflect
them instead. Inspired by the categorical semantics of S4 [Bierman and de Paiva,
2000], we begin to develop the theory of exposures.
To substantiate the discussion, §5 builds on the previous chapter by presenting
three concrete examples of exposures. The first example shows that, when built on
an appropriate P-category, an exposure is really an abstraction of the notion of a
well-behaved intensional device, such as a Gödel numbering. The second example is
based on realizability theory; it is also the motivating example for exposures, and is
later used to show that Kleene’s SRT is a form of intensional recursion. The final
example illustrates that intensionality and exposures may occur outside logic and
computability, and is related to basic homological algebra.
Then, in §6, we put on our P-categorical spectacles and examine intensional recursion. We find that it has a simple formulation in terms of exposures. We then
show that classic theorems of logic that involve intensional recursion, such as Gödel’s
First Incompleteness Theorem, Tarski’s Undefinability Theorem, and Rice’s Theorem,
acquire concise, clear formulations in the unifying framework of exposures. Moreover,
our theory ensures that each logical device or assumption involved in their proofs can
be expressed in the same algebraic manner. The chapter concludes by using exposures
to generalise a famous categorical fixed-point theorem of Lawvere [1969, 2006], which
roughly corresponds to a restricted version of the FRT. The resulting Intensional
Recursion Theorem is a categorical analogue of Kleene’s SRT.
At last, in §7 and §8, we bring Intensional PCF (§3) and exposures (§4) together,
by using the second to provide a semantics for the first. Intensional PCF is too
expressive for this endeavour, so we discuss a restriction of it, which we call Intensional
PCF v2.0. We find that a sound semantics for it consists of a cartesian closed Pcategory equipped with a product-preserving, idempotent comonadic exposure. We
then discuss in which cases we may lift some of these new restrictions of Intensional
PCF v2.0. We conclude by showing that Asm(K1 ) is a model of Intensional PCF
v2.0, with the intensional fixed points being interpreted by Kleene’s SRT.
Finally, in §9, we conclude our investigation by evaluating our contribution, and
delineating a number of future directions towards which this thesis seems to point.
16

Figure 1.1: Chapter dependencies
§1 (Introduction)

§3 (iPCF)

§4 (Categories and Intensionality)

§6 (Intensional Recursion)

§5 (Examples)

§7 (iPCF Semantics I)

§8 (iPCF Semantics II)
The figure presents a rough outline of the way the chapters of this thesis depend
on each other. §2 is not included in the diagram, as it functionally independent of the
developments in the thesis. Nevertheless, we recommend that the reader consult it in
order to understand the origins and importance of intensional recursion. The sequence
§1, §4, §6 may be read independently, hence constituting the basics of our ‘theory of
intensionality.’ Finally, the diagram does not capture two small further dependencies:
that of §6.4 on the examples developed in §5, and that of the construction of IFPs in
Asm(K1 ) in §8.6 on the definition of that P-category in §5.2.

17

Chapter 2
Kleene’s Two Kinds of Recursion1
It is well known that there are two ways to define a function by recursion.
One way is through a diagonal construction. This method owes its popularity to
Cantor, and forms the backbone of a large number of classic diagonalisation theorems.
Diagonal constructions are a very concrete, syntactic, and computational method of
obtaining fixed points, which we in turn use to obtain recursion.
Another way is through a least fixed point that is obtained as a result of some
kind of infinite (or even transfinite) iteration. This kind of construction is more
abstract and mathematical in style. It is a very common trope in the study of denotational semantics of programming languages, particularly those based on domain
theory [Abramsky and Jung, 1994]. The origins of this lattice-theoretic argument are
lost in the mists of time, but see Lassez et al. [1982] for a historical exposition.
Both of these ways were famously used by Stephen C. Kleene [Kleene, 1981] to define functions by recursion in computability theory. The least fixed point construction
is the basis of Kleene’s First Recursion Theorem (FRT) [Kleene, 1952], whereas the
diagonal construction is found at the heart of his Second Recursion Theorem (SRT)
[Kleene, 1938].
Nevertheless, it is not so well known that there is a slight mismatch between these
two theorems. This is mainly due to the context in which they apply: the FRT
is essentially a theorem about computation at higher types, whereas the SRT is a
first-order theorem of a syntactic nature.
Modulo the above mismatch, it so happens that the SRT is more general than
the FRT. Indeed, the SRT allows for a computationally ‘stronger’ kind of recursion—
namely intensional recursion—whereas the FRT has a more extensional flavour. However, there is a close yet slightly mysterious relationship between these two theorems,
1

A preprint is available as arXiv:1602.06220

18

the particulars of which we shall examine.
The SRT has numerous applications in computability, but it is deafeningly absent
in computer science. Abramsky [2014] has suggested further investigation, likening
the SRT to “the dog that didn’t bark” in the Sherlock Holmes story, and has also
discussed several related issues.
In the sequel we shall investigate both of these types of recursion, as well as
their intricate relationship. In §2.1 we discuss the notion of intensionality and its
relationship to computability; we state and prove the SRT, and discuss the extra
generality afforded by what we call intensional recursion; and we sketch a number of
speculative applications of intensional recursion. Subsequently, in §2.2, we move to
the discussion of higher types: we look at two slightly different notions of computation
at higher types, discuss their interaction, and prove the FRT for each one. Finally,
in §2.3, we investigate when each of the recursion theorems applies, and when the
resulting recursive constructions match each other.

2.1

Intensionality and Computability

In loose philosophical terms, to be intensional is to contain not only reference, but
also sense. The distinction between these two notions is due to Frege, see e.g. Fitting
[2015]. An intensional sign denotes an external referent, yet inherently connotes more
information—its elusive sense. The classic example is that of the planet Venus, which
may be referred to as either the morning star, or the evening star.
Most mainstream mathematics is rather extensional : we normally reason about
underlying, ‘ideal’ mathematical objects, and not their concrete descriptions; the
latter are, in a way, only there for our referential convenience. In most presentations
of set theory, for example, the axiom of extensionality equates any two sets whose
members are the same. Thus, in the mathematical sense, to be intensional is to be
finer than some presupposed ‘extensional equality.’
It is not difficult to argue that this setting is most inadequate for Computer Science. On a very rough level, extensions correspond to what may be computed, whereas
intensions correspond to the programs and processes that carry out the computation,
see e.g. Moschovakis [1993]. Once more, there is a distinction to be made: programs may be understood by the ideal objects that they refer to (e.g. functions), or
their internal characteristics: length, structure, and—ultimately—the algorithm they
express.

19

The former aspect—viz. the study of ideal objects behind programs—is the domain of Computability Theory (previously known as Recursion Theory), where the
object of study is ‘effectively computable’ functions over the natural numbers. Computability Theory began with the ‘confluence of ideas’ [Gandy, 1988] of multiple
researchers in the late 1930s in their attempt to characterise ‘automatic’ or ‘mechanical’ calculability. Remarkably, all roads led to Rome: different notions were shown
to coincide, leading to the identification of the class of partial recursive functions.
Subsequent to this fortuitous development, things took a decisive turn, as further
developments mostly concerned the study of the incomputable.2
So much for the extensional side. What about intensions? Here, we encounter a
diverse ecosystem. On one side, fixing the Turing Machine as one’s model of computation leads to Complexity Theory, which attempts to classify algorithmic problems
with a view to identifying the exact resources that one needs to solve a a problem.
This aspect is largely reliant on more combinatorial reasoning. Alternatively, adopting the λ-calculus as a point of reference leads to the study of programming languages,
which includes—amongst other things—type systems, semantics, program analysis,
and program logics. Here, the emphasis is on logical aspects. Finally, the subject of
concurrent and interactive computation unfolds as a bewildering, obscure, and diverse
landscape: see e.g. Abramsky [2006].

2.1.1

The Space of All Programming Languages

It is, however, a curious state of affairs that standard computability theory—as presented, for example, in the classic textbooks of Rogers [1987], Cutland [1980] and
Odifreddi [1992]—begins with a small set of abstract results that concern Gödel numberings of partial recursive functions. Even though they are the central pillar of an
extensional theory, these results have a decidedly intensional flavour.
These results begin by putting some very mild conditions on Gödel numberings.
Indeed, if one thinks of a Gödel numbering as a ‘programming language,’ then these
conditions comprise the absolute minimum that intuitively needs to hold if that programming language is ‘reasonable.’ A clear presentation of this part of the theory can
be found in the classic textbook of Odifreddi [1992, §II.5]. A more modern account
that is informed by programming language theory is that of Neil Jones [1997].
2

Harvey Friedman [1998] once made the following tongue-in-cheek recommendation to the Foundations of Mathematics (FOM) mailing list: “Why not rename recursion theory as: noncomputability
theory? Maybe that would make everybody happy.”

20

The story begins to unfold as soon as we encode programs-as-data, by assigning
partial recursive functions to natural numbers. Following tradition, we write φ for an
arbitrary numbering, and φp : N * N for the partial recursive function indexed by
p ∈ N under the numbering φ.
From a programming perspective, we may consider p to be a ‘program,’ and
φ : N → (N * N) a semantic function that maps programs to the functions they
compute. In practice, p ∈ N is usually a Gödel number that encodes the syntax of a
Turing Machine, or the instructions for a register machine, or even a λ-term.
Let us write e1 ' e2 for Kleene equality, viz. to mean that expressions e1 and e2
are both undefined, or both defined and equal in value. Of the numbering φ we shall
require the following conditions:
Turing-Completeness That for each partial recursive function f there exists a p
such that f = φp .
Universal Function That there is a program U such that φU (x, y) ' φx (y) for all
x, y ∈ N.
S-m-n That there is a total recursive function S such that φS(p,x) (y) ' φp (x, y) for
all x, y ∈ N.
That the first and second conditions are achievable was popularised by Turing
[1937], and the third is a result of Kleene [1938]. The first condition corresponds, by
the Church-Turing thesis, to the fact that our programming language is as expressive
as possible (in extensional terms). The second corresponds to the ability to write a
self-interpreter, under suitable coding. And the third allows us to computably ‘fix’
an argument into the source code of a two-argument program, i.e. that substitution
is computable (c.f. one-step β-reduction in the λ-calculus).
In logical terms, we may regard these as sanity conditions for Gödel numberings of
the partial recursive functions. The ‘sane’ numberings that satisfy them are variously
known as acceptable numberings [Rogers, 1987, Ex. 2.10], acceptable programming
systems [Machtey and Young, 1978, §3.1.1], or systems of indices [Odifreddi, 1992,
§II.5.1].
It was first shown by Rogers [1958] that acceptable numberings have very pleasant
properties.
Definition 1. For numberings φ and ψ, define
φ ≤R ψ

iff

∃t : N * N total recursive. ∀p ∈ N. φp = ψt(p)
21

We then say that φ Rogers-reduces to ψ, and ≤R is a preorder.
Hence, thinking of φ and ψ as different programming languages, φ ≤R ψ just if
every φ-program may be effectively translated—or compiled —to a ψ program. Then
def

≡R = ≤R ∩ ≥R is an equivalence relation. Quotienting by it yields the Rogers
semilattice under the extension of ≤R to the equivalence classes (see op. cit). More
specifically,
Theorem 5. The following are equivalent:
1. ψ is an acceptable numbering, as above.
2. ψ is a member of the unique top element of the Rogers semilattice.
3. ψ is an enumeration for which there is a universal function, and a total recursive
c : N * N such that
ψc(i,j) = ψi ◦ ψj
The first two equivalences are due to Rogers, see op. cit, and Odifreddi [1992,
§II.5.3], and the third is due to Machtey et al. [1978, Theorem 3.2]. Note that
one should exercise great caution with these equivalences, for their proofs liberally
invoke pairing tricks, loops, iterations, and other programming constructs. Finally,
the equivalence between (1) and (2) above was strengthened by Rogers [1958] to
Corollary 1 (Rogers’ Isomorphism Theorem). Any two acceptable enumerations are
recursively isomorphic.
The possible numberings of the partial recursive functions, whether acceptable
or pathological, as well as the various forms of SRTs that may or may not hold of
them, have been investigated by the school of John Case and his students: David
Riccardi [1980, 1981], James Royer [1987] and, more recently, Samuel Moelius III
[Case and Moelius, 2007, 2009a,b, Moelius, 2009]. For example, this community has
shown that there are numberings where certain known theorems, just as the s-mn theorem or Kleene’s second recursion theorem, are not ‘effective,’ or simply do
not hold. Earlier work on this front seems to have concentrated on enumerations of
subrecursive classes of functions, see e.g. Royer and Case [1994], whereas the later
work of Case and his students concentrated on the study of what they called control
structures, i.e. constructs which provide “a means of forming a composite program
from given constituent programs and/or data.”

22

2.1.2

The Second Recursion Theorem

The central intensional result of elementary computability theory is Kleene’s Second
Recursion Theorem (SRT), also first shown in [Kleene, 1938].
Theorem 6 (Kleene). For any partial recursive f : N × N * N, there exists e ∈ N
such that
∀y ∈ N. φe (y) ' f (e, y)
Proof. Consider the function defined by
δf : N × N * N
δf (y, x) ' f (S(y, y), x)
Since f is partial recursive, simple arguments concerning the computability of composition and substitution yield that δf is partial recursive. Hence δf = φp for some
def

p ∈ N. Consider e = S(p, p); then
φe (y) ' φS(p,p) (y) ' φp (p, y) ' δf (p, y) ' f (S(p, p), y) ' f (e, y)
The second Kleene equality follows by the s-m-n theorem, and the others are simply
by definition or construction.
In the above theorem, consider f (x, y) as a function that treats its first argument
as code, and its second argument as data. The equation φe (y) ' f (e, y) implies that
e is a program which, when run on some data, will behave like f with e being its first
argument. In slogan form,
We can always write a program in terms of its own source.

Indeed, the trick has become standard: f (e, y) is a ‘blueprint’ that specifies what
to do with its own code e, and we take its fixed point (c.f. the functionals in the
untyped λ-calculus to which we apply the Y combinator). Moreover, in much the
same way that the Y combinator is itself a term of the untyped λ-calculus, it so
happens that the construction used in the proof of the SRT is itself computable:
Theorem 7 (Constructive Kleene SRT). There is a total recursive h : N * N such
that, for every p ∈ N,
φh(p) (y) ' φp (h(p), y)

23

That is: in the original statement, we may calculate a code for δf from a code for f ,
and hence obtain e in an effective manner.
The Kleene SRT lies at the heart many proofs in computability, especially those
involving diagonalisation, or results pertaining to fixed points, self-reference and the
like. A smattering of more theoretical applications of this ‘amazing’ theorem has been
compiled by Moschovakis [2010].
The SRT is perhaps more familiar in the form popularised by Hartley Rogers Jr.
in his book [Rogers, 1987]. We state a slightly generalised version, and prove it from
Kleene’s version. We write e ↓ to mean that the expression e has a defined value.
Theorem 8 (Rogers SRT). For partial recursive f : N * N, there is a e ∈ N such
that, if f (e) ↓, then
φe = φf (e)
Proof. [Jones, 1997, Lemma 14.3.7] Define
df (x, y) ' φU (f (x), y)
Again, by standard arguments, df is partial recursive. By Kleene’s SRT, there is a
e ∈ N such that, for all y ∈ N,
φe (y) ' df (e, y) ' φU (f (e), y) ' φf (e) (y)
which is to say φe = φf (e) .
This result is equivalent to the previous formulation [Rogers, 1987, Ex. 11-4]. We
may summarise it in the following slogan:
Every computable syntactic program transformation
has a semantic fixed point.

Moreover, this version of the SRT comes in a ‘constructive’ variant as well—see
Rogers [1987, §11.2-II] or Cutland [1980, §11-3.1]:
Theorem 9 (Constructive Rogers SRT). There is a total recursive n : N * N such
that, for any z ∈ N such that φz is total,
φn(z) = φφz (n(z))

24

All of the above variants of the SRT are equivalent under the assumption that φ is
an acceptable enumeration. Nevertheless, if we relax the assumption of acceptability,
there are ways to compare and contrast them. Riccardi [1980] showed that there are
enumerations of the partial recursive functions for which there exist Rogers-type fixed
points, but not Kleene-type fixed points. In a rather technical section of his thesis,
Moelius [2009, §3] painstakingly compares the various entailments between different
formulations of the recursion theorem, and concludes that Kleene’s is the one that is
more natural and general.
No matter how enticing it may be, we shall not dwell on this particular line
of discussion. In fact, we shall avoid it as much as possible, because it does not
fit our view of programming. Any numbering that is not acceptable is somehow
pathological: by contraposition, it follows that either substitution is not computable
(and the s-m-n theorem does not hold), or that there is no self-interpreter (universal
function)—which, by Turing-completeness, means that the interpreter as a function is
not computable. Things are even more subtle if the language is not Turing-complete:
we then have a subrecursive indexing, as in [Royer and Case, 1994], and this is not a
path we would like to tread presently.

2.1.3

Intensional Recursion

From the point of view of programming languages, the very general and still rather
strange application of the SRT is the ability to define functions by intensional recursion. This means that a function can not only call itself on a finite set of points
during its execution—which is the well-known extensional viewpoint—but it may also
examine its own intension, insofar as the source code for a program is a finite and
complete representation of it.
Indeed, the SRT is the only basic tool available in standard (non-higher-order)
accounts of computability that enables one to make any ‘unrestricted’ recursive definition whatsoever. For example, if we define
(
1
if y = 0
f (x, y) '
y · φU (x, y − 1) otherwise
and apply Kleene’s SRT, we obtain a code e ∈ N such that φe is the factorial function.
However, the above use is slightly misleading, in that it is extensional : x is only
used as an argument to the universal function φU . Hence, the resulting behaviour
does not depend on the code x itself, but only on the values of the function φx for
which it stands. The following definition captures that phenomenon.
25

Definition 2. A total recursive f : N * N is extensional just if
φa = φb

=⇒

φf (a) = φf (b)

for any a, b ∈ N.
That is, f : N * N is extensional just if the program transformation it effects
depends solely on the extension of the program being transformed. By a classic result
of Myhill and Shepherdson [1955], such transformations correspond to a certain class
of functionals which we discuss in §2.2.1.
However, even if f : N * N is extensional, the paradigm of intensional recursion
strictly increases our expressive power. For example, suppose that we use the SRT
to produce a program e satisfying a recursive definition of the form
φe (x, y) ' . . . φU (e, g(x), y) . . .
for some g : N * N. We could then use the s-m-n function to replace this recursive
call by a specialisation of e to g(x), thereby obtaining another program e0 of the form
φe0 (x, y) ' . . . φS(e0 ,g(x)) (y) . . .
This is an equivalent program, in the sense that φe = φe0 . But if the s-m-n function
S(e, x) performs some optimisation based on the argument x—which it may sometimes do—then e0 may provide a more efficient definition, in that it the code for the
recursive call may be optimised for this particular recursive call. This line of thought
is the driving force of the partial evaluation community: there, the s-m-n function is
called a specialiser or a partial evaluator, and it is designed so that it optimises the
programs it is called to specialise; see §2.1.4 for more details.
But the SRT also allows for recursive definitions which are not functional, in that
the ‘blueprint’ of which we take a fixed point may not be extensional. For example,
one may be as daft as to define
(
x + 1 if x is even
f (x) '
x − 1 if x is odd
This f : N * N is total recursive, but decidedly not extensional. However, we may
still use Rogers’ theorem to obtain a fixed point e ∈ N such that φe = φf (e) , and
the resulting behaviour will depend on the parity of e (!). To this day, it is unclear
what the use of this is, except of course its underlying rôle in powerful diagonal
arguments—see e.g. Cutland [1980, §11.2]—as well as many kinds of reflection.
26

2.1.4

Applications of Intensional Recursion

Abramsky [2014] observed that the SRT, as well as other simple results on program
codes, are strangely absent from Computer Science. He comments:
“This reflects the fact which we have already alluded to, that while Computer Science embraces wider notions of processes than computability theory, it has tended to refrain from studying intensional computation, despite its apparent expressive potential. This reluctance is probably linked
to the fact that it has proved difficult enough to achieve software reliability even while remaining within the confines of the extensional paradigm.
Nevertheless, it seems reasonable to suppose that understanding and harnessing intensional methods offers a challenge for computer science which
it must eventually address.”
In many ways, we empathise with this programme. Consequently, we catalogue some
applications of such intensional ‘results about program codes,’ both within and on the
fringes of Computer Science, and then engage in some speculation regarding various
future directions.
Partial Evaluation
Kleene’s s-m-n theorem allows one to ‘specialise,’ or ‘partially evaluate’ a certain
program by fixing some of its arguments. It may appear simple and innocuous, but
this is deceptive: the s-m-n theorem is an essential result in computability.
The power afforded by the s-m-n theorem bestowed considerable success upon
the partial evaluation community, which began with the work of Futamura [1999]
and Ershov [1977, 1982] in the 1970s. Futamura observed that the ability to write
an interpreter for a language (i.e. a universal function), as well as the ability to
‘specialise’ an argument of a program (s-m-n function) followed by source-level optimisation yields an easy approach to generate a compiler, thus leading to the three
Futamura projections. Writing S = φs , where S is the s-m-n function, and U for the
program corresponding to the universal function, we have:
def

target code = φs (U, source code)
def

compiler = φs (s, U )
def

compiler generator = φs (s, s)

27

One can then verify that these equations do yield the desired behaviour, as shown in an
elementary fashion by Jones [1997]. This led to a successful programme of automatic
generation of compilers, first realised in Copenhagen. The results are documented in
Jones [1996], and the book of Jones et al. [1993].
Contrasting the simplicity of the s-m-n theorem with its success in the partial
evaluation community also led Jones to ponder whether the SRT, which is a much
more powerful result, could have interesting practical applications. Quoting from
[Jones, 1992]:
“While this theorem has many applications in mathematics, it is not yet
clear whether it will be as constructively useful in computer science as the
s-m-n theorem has turned out to be.”
Taking this as a point of departure, he has posed two significant questions:
• What is the exact relationship between the First Recursion Theorem (FRT)
and the Second Recursion Theorem (SRT)?
• If one implements the SRT, how can the accumulating layers of self-interpretation
be avoided?
Looking back at the literature on computability, we find that the first question has
been answered in a mostly satisfactory way. Regarding the second question, some
recent progress is documented in Kiselyov [2015].
A series of experiments with the SRT and further discussion are documented in
Hansen et al. [1989], and Jones [1992, 2013].
Abstract Computer Virology
Computer viruses rely heavily on the ability to propagate their own code, which is a
kind of reflection. This was noticed by Cohen [1989], who was the first to introduce
the term computer virus alongside an early Turing Machine model of viruses. A few
years later, his supervisor—Leonard Adleman [1990]—concocted his own model of
viruses that is based on elementary computability theory. In that model, viruses
are program transformations that ‘infect’ ordinary programs. This is also where the
connection with the SRT was made explicit, as Adleman invokes it to construct a
program that—under his own definition—is classified as a virus. He also proved a
result on his model that makes crucial use of the SRT for a diagonal construction.

28

These were the two cornerstones that laid the foundation of abstract computer
virology. In more recent years there have been further developments, owing to the
work of Bonfante et al. [2005, 2006, 2007], who discuss and classify different types of
viruses that correspond to multiple variants of the SRT. See also Marion [2012].
Computational Reflection & Reflective Towers
The concept of computational reflection was introduced in the context of programming languages by Brian Cantwell Smith [1982, 1984] in his voluminous thesis. The
underlying intuition is that a program may be considered to be running on an interpreter, which interpreter itself is running on another copy of this interpreter, and
so on A special construct that makes use of this structure is available in the programming language: it allows one to inject code in the interpreter that lies one level
below. Hence, a program has access not only to its code, but the entire state of the
interpreter that runs it, and even the interpreter that runs the interpreter. This is
embodied by the language 3-LISP, introduced in op. cit.
The resulting structure of reflective towers has captured the imagination of many,
but—while couched in colourful imagery—its construction is logically and computationally mysterious. A series of publications [Friedman and Wand, 1984, Wand and
Friedman, 1988, Danvy and Malmkjaer, 1988] have made partial attempts to explain
this ‘tower’ in more concrete terms.
Nevertheless, the concept of computational reflection seems to be a general recurring theme with broader scope, but is not well-understood. For the state of affairs up
to the mid-1990s, see the short comparative survey Demers and Malenfant [1995]. Demystifying reflection is a pressing concern, as many modern programming languages
have reflective or ‘introspective’ facilities, which are infamous for pernicious bugs, and
generally wreaking havoc.
Some ideas regarding reflection seem to be experiencing a resurgence of interest,
mainly because of the appearance of a new candidate foundation for reflection, namely
Barry Jay’s factorisation calculus: see Jay and Given-Wilson [2011], Jay and Palsberg
[2011], and Jay [2016].
As the SRT is a result with fundamental connections to reflection, we believe
that a better understanding of intensional recursion must be instrumental in laying
a logical foundation for reflective constructs.

29

Economics
This section concerns a speculative application of the SRT to economic modelling.
Historically, there has been a lot of discussion—especially in the years following the
Great Recession—regarding the foundational principles of economics, and whether
these are an adequate substrate for the science. Some of these critical approaches
touch on the self-referential aspects that are ignored by (neoclassical) economic theory. Winrich [1984] offers an early example of these criticisms; we give him the floor,
for the argument is compelling:
In order for preferences to be complete the choice set must include preferences themselves! But, as soon as you allow preferences within the choice
set you have preferences “talking” to preferences. In a world of preference
self-reference we can, if you will, produce a neoclassical liar. As an example let our liar be a smoker. In such a situation it is not uncommon to
hear a smoker say, “I dislike my desire to smoke.” What are we to make
of such a statement? In the static framework of neoclassical choice theory
this is a contradiction. But at the same time, it cannot be prevented. Not
only is the “act of smoking” an element in the choice set, but the “desire to
smoke” is itself an element in the choice set and also subject to discretion.
Continuously expanding the choice set by including not only commodities
but also social conditions in an attempt to explain invidious distinctions,
other individuals in an attempt to explain altruism, and so forth, neoclassicism has been able to “absorb” heterodox attacks within the atomic
individualistic perspective. However, the inclusion of choice itself is devastating to its own premise of consistency.
Let me make the point clear. Preference functions, preference orderings,
or preference rankings do not exist. [...]
Indeed, changes to an economic process originating from within an economic process
have been rather difficult to model in a reductionist fashion. Some early work that
attempted to model the ‘change of institutions’ in game theory was carried out by
Vassilakis [1989, 1992]. Moreover, there have even been approaches—even predating
algorithmic game theory—that approach economics with computational feasibility
in mind, see e.g. the work of Velupillai [2000] on computable economics. See also
Blumensath and Winschel [2013] for a recent attempt involving coalgebra.

30

2.2
2.2.1

Extensional Recursion and the FRT
Effective Operations

Suppose that we have some f : N * N that is total and extensional. It is not hard to
see that—by the definition of extensionality—f uniquely induces a very specific type
of functional. Let us write PR for the set of partial recursive functions.
Definition 3. A functional F : PR → PR is an effective operation, if there exists a
total, extensional f : N * N such that
F (φx ) = φf (x)
This is well-defined precisely because f is extensional. We are entering the realm
of higher types, by computing functions from functions. Nevertheless, we are doing
so in a computable and finitary sense: functions may be infinite objects, but this
computation occurs, or is tracked, on the level of program codes.
The Myhill-Shepherdson Theorem
Functionals such as the one defined above are perhaps one of the most straightforward
ways to define computability at higher order, namely as effective code transformations.
Surprisingly, Myhill and Shepherdson [1955] showed that the same functionals can be
defined in a much more abstract manner that dispenses with code transformations
entirely. In fact, anyone familiar with the domain-theoretic semantics of the λ-calculus
will recognise it immediately.
We first need to discuss the simple order-theoretic structure of the set P of unary
partial functions: its elements may indeed be ordered by subset inclusion:
ψ ⊆ χ iff ∀x, y ∈ N. ψ(x) ' y =⇒ χ(x) ' y
This makes P into a ω-complete partial order (ω-cpo), in that least upper bounds of
increasing chains always exist, and they are unions. We can now make the following
definition.
Definition 4. A functional F : P → P is effectively continuous just if it satisfies the
following properties:
Monotonicitity ψ ⊆ χ =⇒ F (ψ) ⊆ F (χ)

31

Continuity For any increasing sequence of partial functions,
f0 ⊆ f1 ⊆ f2 . . .
we have

!
G

F

fi

i

=

G

F (fi )

i

Effectivity on Finite Elements Given an encoding ˆ· of the graph of every finite
function θ : N * N as a number θ̂ ∈ N, there is a partial recursive gF : N × N *
N such that, for every finite θ : N * N, and for all x ∈ N,
F (θ)(x) ' gF (θ̂, x)
These are called recursive functionals by Cutland [1980] and Rogers [1987]: we beseech the reader to exercise caution, as terminology varies wildly.
Let us restate continuity, by using the following equivalent formulation, for which
see Odifreddi [1992, §II.2.23]:
Lemma 1 (Compactness). F : P → P is continuous if and only if
F (f )(x) ' y

⇐⇒

∃ finite θ ⊆ f. F (θ)(x) ' y

for all x, y ∈ N.
Putting these together, we see that effectively continuous functionals are indeed
very strongly computational and effective: the value of F (f )(x) only depends on a
finite part of the graph of f . In fact, we can show that the behaviour of F on finite
elements completely determines its behaviour on f :
Lemma 2 (Algebraicity). Let F : P → P be continuous. Then
G
F (f ) =
{ F (θ) | θ finite ∧ θ ⊆ f }
So, how do these functionals, which are computable in finite approximations, relate to
the aforementioned effective operations, which are based on computations on indices?
The answer is astonishingly simple:
Theorem 10 (Myhill-Shepherdson). An effective operation Feff : PR → PR can be
uniquely extended to an effectively continuous functional F : P → P (with Feff ⊆ F ).
Conversely, any effectively continuous functional, when restricted to the partial
recursive functions PR, is an effective operation.
See Cutland [1980, 10-§2], Rogers [1987, §15.3, XXIX], or Odifreddi [1992, §II.4.2] for
proofs.
32

A Turing Machine characterisation
Our discussion of functionals began with extensional operations on codes, as the most
natural definition of higher-order computation.
There is, however, an alternative, which some would argue is even more simple:
one may envisage the implementation of any functional F : P → P as a Turing
Machine which has access to an oracle for the argument of the functional. During a
computation, the machine may write a number x on a separate tape, and then enter
a special state, in order to query the oracle. The oracle then replaces x with f (x)
if f is defined at x. If it is not, the oracle does not respond, forcing the machine to
eternally wait for an answer, and the computation diverges.
Computation with oracles was first considered by Turing [1939], leading to the
intricate theory of Turing reducibility and relative computability. However, Turingtype oracles are fixed in relative computability, whilst we consider them as arguments
to a computation. This shift in perspective, as well as the first concrete results
involving higher types, are due to Kleene [1952].
In this context, subtle issues arise with non-determinism. It is well-known that
non-deterministic Turing Machines are equivalent to deterministic Turing machines
at the first order, but at higher order this is no longer true. In fact, the following
theorem was first shown—to the best of our knowledge—by Moschovakis [2010, §3],
even though it was simply labelled as the Myhill-Shepherdson theorem:
Theorem 11 (Moschovakis). A functional F : PR → PR is an effective operation if
and only if F (f ) is computable by a non-deterministic Turing machine with an oracle
for f .
Great care has to be taken in combining non-determinism with oracles: the machine should be designed so as to avoid the presence of two halting branches in
the same computation tree with different candidate outputs. Similar restrictions occur in defining what it means to non-deterministically compute a polynomial time
function—see e.g. Lewis and Papadimitriou [1997, §4.5.2]. However, in this case,
non-halting branches do not harm anyone; in fact, they are in some sense necessary
for the expressive power afforded by this model of computation.
The First Recursion Theorem
We have seen that effectively continuous functionals exhibit an impressive amount of
inherent order-theoretic structure. By the Myhill-Shepherdson theorem, this struc-

33

ture emerges automatically once a functional can be ‘realised’ on codes by an extensional operation on codes.
This order-theoretic structure is the basis of the proof of the First Recursion
Theorem (FRT). This fact was discovered by Dana Scott, who was the first one to
notice that the core argument in the proof of the FRT applies to all so-called simple
types.3 This discovery of Scott led to the development of domain theory, and the study
of PCF [Plotkin, 1977], both of which were the firstfruits of the field of programming
language semantics. Indeed, Scott acknowledged his debts; quoting from [Scott, 1975]:
“[...] It is rather strange that the present model was not discovered earlier,
for quite sufficient hints are to be found in the early paper of Myhill
and Shepherdson and in Rogers’ book (especially §§9.7-9.8). These two
sources introduce effective enumeration operators and indicate that there
is a certain amount of algebra about that gives these operators a pleasant
theory, but no one seemed ever to take the trouble to find out what it
was.”
The central result underlying the FRT is therefore this:
Theorem 12 (The Fixpoint Theorem). Let (D, v) be a ω-cpo with a least element
⊥ ∈ D, and let F : D → D be a continuous function. Then F has a least fixed point,
defined explicitly by
lfp(F ) =

G

F i (⊥)

i

This is largely considered a folk theorem: its origins are difficult to trace, and many
variants of it have been proved and used widely in Logic and Computer Science—see
Lassez et al. [1982] for a historical view. In op. cit the authors note that Kleene knew
of it at least as early as 1938; see also [Kleene, 1981].
In fact, it is high time that we show to the reader how it constitutes the first half of
Kleene’s FRT. But first, a caveat: the version of the FRT that we will presently prove
pertains to effective operations (à la Myhill and Shepherdson), and a proof similar
to ours may be found in the book by Cutland [1980, §10-3]. The original statement,
found in Kleene’s book [Kleene, 1952, §66], concerns partial recursive functionals,
which we discuss in §2.2.2; see also Odifreddi [1992, §II.3.15].
3

The simple types of PCF, as defined by Scott [1993], are generated by σ ::= B | N | σ → σ. B
is supposed to connote the booleans, and N the type of natural numbers.

34

Theorem 13 (First Recursion Theorem). Every effectively continuous functional
F : P → P has a least fixed point lfp(F ) : N * N, which is partial recursive.
Furthermore, let φq : N * N be an extensional function that realises F on the
partial recursive functions, i.e. F (φx ) = φφq (x) . Then, a p ∈ N such that φp = lfp(F )
may be computed effectively from any such q ∈ N.
Proof. The existence of the least fixed point follows from the fact (P, ⊆) is a ω-cpo,
and the Fixpoint Theorem.
By the Myhill–Shepherdson theorem, the functional F corresponds to some extensional φq : N * N. The proof of the Fixpoint Theorem constructs a chain,
f0 = ∅ ⊆ f1 ⊆ f2 . . .
where fi+1 = F (fi ), and the least fixed point is lfp(F ) =

F

i

fi . The fi may be

construed as increasingly defined ‘approximations’ to f . The key to this proof lies in
using the extensional φq to obtain indices that track each element of this chain:
p0 = (some index for the nowhere defined function)
p1 = φq (p0 )
..
.
so that pi+1 = φq (pi ) and hence, by induction, fi = φpi for all i ∈ N. Then, by
Church’s Thesis, we define p ∈ N by writing a program that performs the following
steps: on input n,
1. Set i := 0.
2. Begin a simulation of the program p0 running on n.
3. Loop:
(a) For each j ≤ i, simulate one step of pj on n.
(b) If any of these simulations have halted and produced a value m, halt and
output m.
(c) Otherwise, compute pi+1 = φq (pi ), and begin a simulation of pi+1 on input
n. Set i := i + 1.
Since the fi ’s are a chain, this program cannot accidentally produce two contradictory
F
values. But since lfp(F ) = i fi , if f (n) ' m, then fi (n) ' m for some i, so that
f = φp .
35

In the books of both Cutland [1980] and Odifreddi [1992], the above proof is
obtained after the recursively enumerable sets are characterised as the Σ01 sets in the
arithmetical hierarchy. We prefer the more primitive, ‘algorithmic version’ above,
because we can isolate the expressive power needed.
So, what do expressive power do we use? The program in the proof curiously calls
for countable dovetailing, i.e. the simulation of a slowly expanding yet potentially
infinite set of computations, of which we perform a few steps at each stage. This
requires access to the code q ∈ N of the relevant extensional function, so that we
can run it to obtain the rest of the codes pi . Furthermore, we require a handle on a
number of simulations we spawn, so that we can pause them, schedule some steps of
each, and possibly even discard some.
It is worth remarking once more that the output of this procedure is obviously
deterministic, but there is inherent non-determinism and parallelism in the method
we use to compute it. This is very much in line with Moschovakis’ version of the
Myhill–Shepherdson theorem (Theorem 11).

2.2.2

Partial Recursive Functionals and Pure Oracles

We have only discussed effective operations up to this point, and shown that they
correspond to effectively continuous functionals.
In our discussion leading to Theorem 11 we also mentioned a slightly different
paradigm, that of oracle computation. Theorem 11, however, guaranteed that nondeterministic oracle computation coincided with effective continuity. If, in contrast,
we adopt deterministic oracle computation as our notion of higher-order computation,
we are led to a different notion of computable functional. This kind of functional was
first discussed by Kleene [1952]:4
Definition 5. A functional F : P → P is a partial recursive functional if F (f ) can be
obtained from f : N * N and the initial functions by composition, primitive recursion,
and minimalisation. If its domain is restricted to the set F of total functions, such a
functional F : F → P is called a restricted partial recursive functional.
4

However, his definition was not identical to ours. Kleene defined his functionals through an
equation calculus. In this framework, even if the semantics of composition were understood to be
strict, multiple (and possibly inconsistent) defining equations were still allowed, leading to the nondeterminism observed by Platek [1966], which allowed parallel-or to be computable. We use the
definition that is widely believed that Kleene really intended to use, and found in later textbooks.
That this is the common interpretation I learned from John Longley, in personal communication.

36

Thus, if F (f ) = g, then we say that g is partial recursive uniformly in f .
An implementation of such a functional F would resemble a deterministic Turing
machine with an oracle for its argument. But notice that there is no non-determinism
in this case, and hence calls to the oracle have to happen in a predetermined way. As
soon as we decide to make a query at an undefined point, the computation diverges:
there is no other branch of the computation to save the day! Informally, we may say
that calls to the oracle may not be dovetailed. In effect, partial recursive functionals
deal with their arguments as pure extensions, whereas effectively continuous functionals interact in a more involved manner with the phenomenon of non-termination.
In the case of total inputs, the above connection was made precise by Kleene:
Theorem 14. [Kleene, 1952, §68, XXVIII] A functional F : F → P is a restricted
partial recursive functional if and only if it is computed by a deterministic Turing
machine with an oracle.
We are not aware of a plausible analogue of this theorem for partial recursive functionals and deterministic Turing machines.
The definition of partial recursive functionals has a lot of undesirable consequences: see the discussion in the thesis of Platek [1966, p. 128-130]. Thus, the
definition is often restricted to total inputs, for which the above characterisation
through Turing Machines exists. The underlying reason seems to be that, for total
inputs, we may enumerate the graph of the oracle, as no call to it will diverge.
Let us not forget this trivial but pleasant consequence:
Lemma 3. Let F : P → P be a partial recursive functional. If g ∈ PR, then
F (g) ∈ PR.
It is in this setting that Kleene obtained the First Recursion Theorem, which first
appeared in Kleene [1952, §66]:
Theorem 15 (FRT for Partial Recursive Functionals). Let F : P → P be a partial
recursive functional. Then F admits a partial recursive least fixed point.
Proof. See Odifreddi [1992, §II.3.15]. As before, the existence of the least fixed point
follows from the Fixpoint Theorem. The fact it is partial recursive follows from
Lemma 3: we conclude by induction that all the fi ’s are partial recursive; as the least
F
fixed point is f = i fi , we have that
f (x) ' y

⇐⇒

∃i ∈ N. fi (x) ' y

As the fi ’s are partial recursive, the predicate on the RHS of this equivalence is
recursively enumerable, and hence so is the graph of f .
37

Notice that the proof was rather abstract, and that all references to indices have
disappeared completely.
The following was shown by Uspenskii and Nerode, see Odifreddi [1992, §II.3.19]
for a proof:
Theorem 16. Every partial recursive functional is effectively continuous.
In particular, if we restrict a partial recursive functional to PR, it is an effective
operation. The converse was shown to fail by Sasso—see Odifreddi [1992, §II.3.20]:
Theorem 17. The functional
(
0
if f (2x) ' 0 or f (2x + 1) ' 0
F (f ) = λx.
undefined otherwise
is effectively continuous, but not partial recursive.
This clearly demonstrates, once more, that there is inherent parallelism or nondeterminism in effective operations, whilst partial recursive functionals are purely
sequential. In more detail, to compute the above functional we would have to concurrently query the argument f at two points by dovetailing the computations. A
deterministic Turing machine would have to either query f at either 2x or 2x + 1
first; if the first call were to an undefined point, it would diverge and never examine
the second. A non-deterministic Turing machine would deal with the same difficulty
by branching at the point where a choice between 2x and 2x + 1 is to be made.

2.3
2.3.1

FRT vs. SRT
Effective Operations and the SRT

Suppose we would like to construct a fixed point in a more simplistic manner than
the one employed in the proof of Theorem 13. All we need to do is use the MyhillShepherdson theorem to restrict an effectively continuous functional to an effective
operation and extract an extensional function from it, followed by applying the SRT.
Lemma 4. Given an effective operation F : PR → PR defined by an extensional
φp : N * N, we may effectively obtain a code for one of its fixed points from p ∈ N.
Proof. By Theorem 9, that code is n(p); for then,
φn(p) = φφp (n(p)) = F (φn(p) )
so that φn(p) is a fixed point of F .
38

So far, so good; but what sort of fixed point have we obtained? In particular, is it
minimal? The following construction, due to Rogers [1987, §11-XIII] demonstrates
that it is not.
Theorem 18. There is an extensional φm : N * N such that the fixed point obtained
by the SRT as in Lemma 4 is not minimal.
Proof. Use Church’s Thesis, Kleene’s SRT, and the function n from 9 to define m ∈ N
such that

(
x if x 6= n(m)
φm (x) '
t if x = n(m)

where t is an index for the constant zero function, i.e. φt (x) ' 0 for all x ∈ N.
Observe that, as n is total recursive, φm is total recursive. It is also extensional.
Essentially, φm asks: is the input my own Rogers fixed point? If yes, output code for
the constantly zero function; otherwise, echo the input. Thus, if x 6= n(m), we have
that φm (x) ' x, so that φφm (x) ' φx . Otherwise,
φφm (n(m)) ' φn(m)
as n(m) is a Rogers-style fixed point. In either case, φm is extensional, and defines
the identity functional. The least fixed point of it is the empty function. However,
the fixed point that results from the SRT has code n(m), and
φm (n(m)) ' t
so that φn(m) = φt , which is equal to the constantly zero function.
The key aspect of this construction seems to be that, unlike oracle computation,
an extensional function is able to syntactically inspect its input, thus creating a
‘singularity’ at one point. We maintain extensionality by arranging that the point
at which the ‘singularity’ is to be found is—incidentally—the extensional function’s
own fixed point! This is more evidence that effective operations really hide something
more than ‘pure extension’ under the hood.
The Standard Form
Can this mend this situation? The answer is positive: any extensional function can
be rewritten in a ‘standard form,’ which guarantees that the SRT really defines a
minimal fixed point. This is the exact sense in which the SRT implies the FRT.

39

The construction is due to Rogers [1987, §11-XIV]. The original statement is
horribly complicated, and involves multiple layers of enumeration; there is a lot of
concurrency happening here, and we cannot do much better than keep the description
informal.
For the following, we assume that there is also a standard way to enumerate the
graph of a partial recursive function given its index. This may be done by dovetailing
simulations of
φx (0), φx (1), . . .
and emitting pairs (i, φx (i)) as soon as the ith simulation halts. We do not care about
the exact details, but we do care that the exact same construction is used throughout.
Thus, let there be a effective operation F : PR → PR, and let f : N * N be
total and extensional, such that F (φx ) = φf (x) . We will define a total and extensional
hf : N * N, which is co-extensional with f , in the sense that
∀x ∈ N. φf (x) = φhf (x)
This hf will be in ‘standard’ form. Moreover, we may effectively compute an index
for hf from an index for f .
We use Church’s Thesis to define hf so that, on input y, it outputs a program
that performs the following instructions:
hf (y) ' “On input x, run the following processes in parallel:
1. One process enumerates the graphs of all finite functions N * N,
encoded as numbers:
θˆ0 = ∅, θˆ1 , θˆ2 , . . .
This may be done in many ways, but it is necessary that we begin
with the empty function (in order to include the covert base case in
the strong induction of the following theorem).
2. There is a total recursive d : N * N which turns a graph of a finite
function into an index for that function (by writing code that simply
checks if the input is in the graph, outputting the relevant value if so,
and diverging otherwise). The second process receives the encoded
graphs of the finite functions above, and enumerates codes,
d(θˆ0 ), d(θˆ1 ), d(θˆ2 ), . . .
with φd(θˆi ) = θi .
40

3. A third process receives messages from the second process, and applies f to those codes, outputting
f (d(θˆ0 )), f (d(θˆ1 )), . . .
with φf (d(θˆi )) = F (φd(θˆi ) ) = F (θi ). We thus obtain codes for all the
applications of the effective operation F on all the finite functions.
Beware: these functions φf (d(θˆi )) may now be infinite!
4. (This is the process where partiality enters the construction.) Enumerate, simultaneously, all the pairs in the graph of the function φy ,
as well as the pairs in the graphs of φf (d(θˆi )) = F (θi ). This can be
done using the method postulated above.
5. As soon as we find some t such that
F (θi )(x) ' t and θi ⊆ φy
we halt and output that t. This may be done by periodically checking whether x is defined in the enumeration of some F (θi ), and then
confirming that the entire graph of that θi is contained in the enumeration of φy .”
Notice that, in this construction, the code for f may be abstracted away. Using
the s-m-n theorem, we can then effectively produce code for it from any index of f .
Trivially, hf is total. Furthermore, notice that we needed to enumerate the φf (d(θˆi )) ,
for—in general—they will not be finite functions.
By the compactness of F , which follows from the theorem of Myhill and Shepherdson, we know that, F (φy )(x) ' t if and only if F (θi )(x) ' y for some finite θi ⊆ φy .
This construction will always find such a θi if there exists one. Hence hf defines the
same functional as f .
Now, using the SRT on hf will produce a minimal fixed point:
Theorem 19. If φv = hf , then n(v) is a code for the least fixed point of the effective
operation F : PR → PR defined by f : N * N.
Proof. We have that
φn(v) = φφv (n(v)) = φhf (n(v))
so that n(v) behaves exactly as hf (y) would if y were fixed to be its own code. That
is to say, we can read φn(v) wherever φy is occurs in the definition of hf , and the check
θi ⊆ φy
41

becomes
θi ⊆ φn(v)
which is to say that the program checks whether each finite function is a subset of its
own graph! By Lemma 4, this defines a fixed point for the functional F .
To prove that this fixed point is least, we proceed by strong induction on the
number of steps taken to enumerate the graph of φn(v) . That is, we shall show that
if we begin enumerating φn(v) using our standard enumeration procedure on the code
n(v), all the pairs produced will belong to the least fixed point, hence φn(v) ⊆ lfp(F ),
whence φn(v) = lfp(F ).
Begin enumerating φn(v) . This involves running the code n(v). One of the subprocesses in that code involves enumerating φn(v) itself, using the same procedure as
we are. Since this is a sub-computation of our enumeration, it is always shorter in
length. Hence, by the inductive hypothesis, we assume that the enumeration in the
sub-computation produces the least fixed point. Hence, if the check
θi ⊆ φn(v)
succeeds, we know that
θi ⊆ lfp(F )
By monotonicity, it follows that
F (θi ) ⊆ F (lfp(F )) = lfp(F )
Hence, when the check F (θi )(x) ' t succeeds and the pair (x, t) is output by the
enumeration, we know it belongs to the least fixed point. It follows that every pair
produced by the enumeration is in the least fixed point.

2.3.2

Partial Recursive Functionals and the SRT

In contrast with effective operations, the situation is simpler in the case of oracle
computation: because partial recursive functionals are decidedly extensional in their
behaviour, the problems that arose in the preceding section vanish. There is no
‘inherent’ parallelism in computing such a functional, and the SRT immediately yields
least fixed points.
The following theorem was shown by Odifreddi [1992, §II.3.16], who wrongly attributes it to Rogers:5
5

Rogers instead sketched the proof to our Theorem 19, which strictly concerns effective operations.

42

Theorem 20 (Odifreddi). Let F : P → P be a partial recursive functional, and
define
f (e, x) ' F (φe )(x)
Then f is partial recursive. Moreover, there exists q ∈ N such that f = φq , and the
function h : N * N of Theorem 7 produces a code h(q) such that φh(q) = lfp(F ).
Proof. As F is a partial recursive functional, it is also an effective operation on the
partial recursive functions, by Theorem 16. We define q ∈ N by Church’s thesis: on
input (e, x), process the code of e with the total extensional function associated to F
by Myhill-Shepherdson, and call the resulting code on x.
Let g = φh(q) . We have that
g(x) ' φh(q) (x) ' f (h(q), x) ' F (φh(q) )(x) ' F (g)(x)
for any x ∈ N, so that g is a fixed point of F .
It remains to show minimality. The proof is by strong induction on the length
of computations of F (g) on its arguments. Suppose F (g)(x) ' t. F is effectively
continuous, so there exists a finite θ ⊆ g such that
F (θ)(x) ' t
by compactness. Choose a minimal such θ, and let
θ = { (x1 , y1 ), . . . , (xn , yn ) }
By construction, the xi are exactly the ‘questions’ with which a Turing machine that
computes F would query the oracle, on input x.
By using Kleene’s SRT, we have replaced calls to the oracle by recursive calls
to another copy of itself. It follows that the computation of each F (g)(xi ) ' yi is
strictly shorter in length than the overall computation of F (g)(x) ' y. Hence, by the
induction hypothesis, (xi , yi ) ∈ lfp(F ) for all i, and θ ⊆ lfp(F ).
By monotonicity, F (θ) ⊆ lfp(F ), and since F (θ)(x) ' t, we have that (x, t) ∈
lfp(F ). Hence g ⊆ lfp(F ), and as g is also a fixed point, equality holds.

43

Chapter 3
iPCF: An Intensional Programming
Language1
This chapter concerns the elaboration of the modality-as-intension interpretation that
we introduced in §1.4. Our starting point will be the Davies-Pfenning calculus for S4,
which is a typed λ-calculus with modal types. The intuitive meaning of the modal
type A will be that of code, that—when evaluated—yields a value of type A. We
wish to use this calculus for intensional and reflective programming.
The Davies-Pfenning calculus already supports a notion of programs-as-data: to
each term M : A that uses only ‘code’ variables there corresponds a term box M : A
that stands for the term M considered as a datum. This is already considerably
stronger than ordinary higher-order functional programming with ‘functions as firstclass citizens,’ as it also entails a kind of homoiconicity, similar to the one present in
dialects of Lisp. But we want to go even further than that: in Lisp, a program is able
to process code by treating it as mere symbols, thereby disregarding its observable
behaviour.
The true spirit of intensionality is the ability to support operations that are, according to the extensional viewpoint, non-functional. This was not the case in the
work of Davies and Pfenning, who merely used their calculus for staged metaprogramming, which did not require non-functional operations. In this chapter we shall
mend this. We shall augment their calculus by adding intensional operations, and
intensional recursion. We shall call the resulting calculus Intensional PCF, after the
simply-typed λ-calculus with (extensional) fixed points studied by Scott [1993] and
Plotkin [1977].
1

This chapter is based on the paper [Kavvos, 2017d], which was presented at the 7th workshop on Intuitionistic Modal Logics and Applications (IMLA 2017). A preprint is available as
arXiv:1703.01288

44

There has been some previous work on adding intensional operations to the DaviesPfenning calculus. A complicated system based on nominal techniques that fleshed
out those ideas was presented by Nanevski [2002]. The notions of intensional and
extensional equality implicit in this system were studied using logical relations by
Pfenning and Nanevski Nanevski and Pfenning [2005]. However, none of these papers
studied whether the induced equational systems are consistent. We show that, no
matter the intensional mechanism at use, modalities enable consistent intensional
programming.
To our knowledge, this chapter presents (a) the first consistency proof for type-safe
intensional programming, and (b) the first type-safe attempt at reflective programming.

3.1

Introducing Intensional PCF

Intensional PCF (iPCF) is a typed λ-calculus with modal types. As discussed before,
the modal types work in our favour by separating intension from extension, so that
the latter does not leak into the former. Given the logical flavour of our observations
in §1.4 we shall model the types of iPCF after the constructive modal logic S4, in
the dual-context style pioneered by Pfenning and Davies [Pfenning and Davies, 2001,
Davies and Pfenning, 2001]. Let us seize this opportunity to remark that (a) there
are also other ways to capture S4, for which see the survey [Kavvos, 2016], and that
(b) dual-context formulations are not by any means limited to S4: they began in the
context of intuitionistic linear logic, but have recently been shown to also encompass
other modal logics; see Kavvos [2017b].
iPCF is not related to the language Mini-ML that is introduced by Davies and
Pfenning [2001]: that is a call-by-value, ML-like language, with ordinary call-byvalue fixed points. In contrast, ours is a call-by-name language with a new kind
of fixed point, namely intensional fixed points. These fixed points will afford the
programmer the full power of intensional recursion. In logical terms they correspond
to throwing the Gödel-Löb axiom (A → A) → A into S4. Modal logicians
might object to this, as, in conjunction with the T axiom A → A, it will make every
type inhabited. We remind them that a similar situation occurs in PCF, where the
YA : (A → A) → A combinator allows one to write a term YA (λx:A. x) at every
type A. As in the study of PCF, we care less about the logic and more about the
underlying computation: it is the terms that matter, and the types are only there to
stop type errors from happening.
45

The syntax and the typing rules of iPCF may be found in Figure 3.1. These are
largely the same as Pfenning and Davies’ S4, save the addition of some constants
(drawn from PCF), and a rule for intensional recursion. The introduction rule for the
modality restricts terms under a box (−) to those containing only modal variables,
i.e. variables carrying only intensions or code, but never ‘live values:’
∆;·`M :A
∆ ; Γ ` box M : A
There is also a rule for intensional recursion:
∆ ; z : A ` M : A
∆ ; Γ ` fix z in M : A
This will be coupled with the reduction fix z in M −→ M [box (fix z in M )/z]. This
rule is actually just Löb’s rule with a modal context, and including it in the Hilbert
system of a (classical or intuitionistic) modal logic is equivalent to including the GödelLöb axiom: see Boolos [1994] and Ursini [1979b]. We recommend the survey Litak
[2014] for a broad coverage of constructive modalities with a provability-like flavour.
Finally, let us record a fact noticed by Samson Abramsky, which is that erasing the
modality from the types appearing in either Löb’s rule or the Gödel-Löb axiom yields
the type of YA : (A → A) → A, as a rule in the first case, or axiomatically internalised
as a constant in the second (both variants exist in the literature: see Gunter [1992]
and Mitchell [1996].)

3.2

Metatheory

This section concerns the basic metatheoretic properties of iPCF. The expected structural rules are admissible. We also prove a theorem regarding the behaviour of free
variables, similar to the ones in [Kavvos, 2017b], which demonstrates how the different
layers of intension and extension are separated by the type system.

3.2.1

Structural Theorems & Cut

iPCF satisfies the expected basic results: structural and cut rules are admissible.
This is no surprise given its origin in the well-behaved Davies-Pfenning calculus. We
assume the typical conventions for λ-calculi: terms are identified up to α-equivalence,
for which we write ≡, and substitution [·/·] is defined in the ordinary, capture-avoiding
manner. Bear in mind that we consider occurrences of u in N to be bound in

46

Figure 3.1: Syntax and Typing Rules for Intensional PCF
::= Nat | Bool

Ground Types G

::= G | A → B | A

Types A, B

Terms M, N ::= x | λx:A. M | M N | box M | let box u ⇐ M in N |
n
b | true | false | succ | pred | zero? | ⊃G | fix z in M
Contexts Γ, ∆

::=

· | Γ, x : A

(b ∈ {true, false})

∆;Γ`n
b : Nat

∆ ; Γ ` b : Bool

∆ ; Γ ` zero? : Nat → Bool

∆ ; Γ ` f : Nat → Nat

(f ∈ {succ, pred})

∆ ; Γ ` ⊃G : Bool → G → G → G
∆ ; Γ, x:A, Γ0 ` x : A

(var)

∆ ; Γ, x:A ` M : B
∆ ; Γ ` λx:A. M : A → B
∆;·`M :A
∆ ; Γ ` box M : A

(→ I)

(I)

∆, u:A, ∆0 ; Γ ` u : A
∆;Γ`M :A→B

(var)

∆;Γ`N :A

∆ ; Γ ` MN : B
∆ ; Γ ` M : A

∆, u:A ; Γ ` N : C

∆ ; Γ ` let box u ⇐ M in N : C

∆ ; z : A ` M : A
∆ ; Γ ` fix z in M : A

47

(fix)

(→ E)

(E)

let box u ⇐ M in N . Contexts Γ, ∆ are lists of type assignments x : A. Furthermore, we shall assume that whenever we write a judgement like ∆ ; Γ ` M : A,
then ∆ and Γ are disjoint, in the sense that Vars (∆) ∩ Vars (Γ) = ∅, where
def
Vars (x1 : A1 , . . . , xn : An ) = {x1 , . . . , xn }. We write Γ, Γ0 for the concatenation of
disjoint contexts. Finally, we sometimes write ` M : A whenever · ; · ` M : A.
Theorem 21 (Structural & Cut). The following rules are admissible in iPCF:
1. (Weakening)

3. (Contraction)

∆ ; Γ, Γ0 ` M : A

∆ ; Γ, x:A, y:A, Γ0 ` M : A

∆ ; Γ, x:A, Γ0 ` M : A

∆ ; Γ, w:A, Γ0 ` M [w, w/x, y] : A
4. (Cut)

2. (Exchange)
∆ ; Γ, x:A, y:B, Γ0 ` M : C

∆;Γ`N :A

∆ ; Γ, x:A, Γ0 ` M : A

∆ ; Γ, Γ0 ` M [N/x] : A

∆ ; Γ, y:B, x:A, Γ0 ` M : C

Proof. All by induction on the typing derivation of M . Verified in the proof assistant
Agda: see Appendix A.2.
Theorem 22 (Modal Structural & Cut). The following rules are admissible:
1. (Modal Weakening)

3. (Modal Contraction)

∆, ∆0 ; Γ ` M : C

∆, x:A, y:A, ∆0 ; Γ ` M : C

∆, u:A, ∆0 ; Γ ` M : C

∆, w:A, ∆0 ; Γ ` M [w, w/x, y] : C
4. (Modal Cut)

2. (Modal Exchange)
∆, x:A, y:B, ∆0 ; Γ ` M : C

∆ ; · ` N : A ∆, u:A, ∆0 ; Γ ` M : C

∆, y:B, x:A, ∆0 ; Γ ` M : C

∆, ∆0 ; Γ ` M [N/u] : C

Proof. All by induction on the typing derivation of M . Verified in the proof assistant
Agda: see Appendix A.2.

3.2.2

Free variables

In this section we prove a theorem regarding the occurrences of free variables in welltyped terms of iPCF. It turns out that, if a variable occurs free under a box (−)
construct, then it has to be in the modal context. This is the property that enforces
that intensions can only depend on intensions.
48

Definition 6 (Free variables).
1. The free variables fv (M ) of a term M are defined by induction on the structure
of the term:
def

fv (x) = {x}
def

fv (M N ) = fv (M ) ∪ fv (N )
def

fv (λx:A. M ) = fv (M ) − {x}
def

fv (box M ) = fv (M )
def

fv (fix z in M ) = fv (M ) − {z}
def

fv (let box u ⇐ M in N ) = fv (M ) ∪ (fv (N ) − {u})
2. The unboxed free variables fv0 (M ) of a term are those that do not occur under
the scope of a box (−) or fix z in (−) construct. They are formally defined by
replacing the following clauses in the definition of fv (−):
def

fv0 (box M ) = ∅
def

fv0 (fix z in M ) = ∅
3. The boxed free variables fv≥1 (M ) of a term M are those that do occur under
the scope of a box (−) construct. They are formally defined by replacing the
following clauses in the definition of fv (−):
def

fv≥1 (x) = ∅
def

fv≥1 (box M ) = fv (M )
def

fv≥1 (fix z in M ) = fv (M ) − {z}
Theorem 23 (Free variables).
1. For every term M , fv (M ) = fv0 (M ) ∪ fv≥1 (M ).
2. If and ∆ ; Γ ` M : A, then
fv0 (M ) ⊆ Vars (Γ) ∪ Vars (∆)
fv≥1 (M ) ⊆ Vars (∆)
Proof.
1. Trivial induction on M .
49

2. By induction on the derivation of ∆ ; Γ ` M : A. We show the case for (I);
the first statement is trivial, so we show the second:
fv≥1 (box M )
= { definition }
fv (M )
= { (1) }
fv0 (M ) ∪ fv≥1 (M )
⊆ { IH, twice }
(Vars (∆) ∪ Vars (·)) ∪ Vars (∆)
= { definition }
Vars (∆)

3.3

Consistency of Intensional Operations

In this section we shall prove that the modal types of iPCF enable us to consistently
add intensional operations on the modal types. These are non-functional operations
on terms which are not ordinarily definable because they violate equality. All we
have to do is assume them as constants at modal types, define their behaviour by
introducing a notion of reduction, and then prove that the compatible closure of this
notion of reduction is confluent. A known corollary of confluence is that the equational
theory induced by the reduction is consistent, i.e. does not equate all terms.
There is a caveat involving extension flowing into intension. That is: we need to
exclude from consideration terms where a variable bound by a λ occurs under the
scope of a box (−) construct. These will never be well-typed, but—since we discuss
types and reduction orthogonally—we also need to explicitly exclude them here too.

3.3.1

Adding intensionality

Pfenning and Davies [2001] suggested that the  modality can be used to signify
intensionality. In fact, in [Davies and Pfenning, 1996, 2001] they had prevented reductions from happening under box (−) construct, “ [...] since this would violate its
intensional nature.” But the truth is that neither of these presentations included any
genuinely non-functional operations at modal types, and hence their only use was for
50

homogeneous staged metaprogramming. Adding intensional, non-functional operations is a more difficult task. Intensional operations are dependent on descriptions
and intensions rather than values and extensions. Hence, unlike reduction and evaluation, they cannot be blind to substitution. This is something that quickly came
to light as soon as Nanevski [2002] attempted to extend the system of Davies and
Pfenning to allow ‘intensional code analysis’ using nominal techniques.
A similar task was also recently taken up by Gabbay and Nanevski [Gabbay and
Nanevski, 2013], who attempted to add a construct is-app to the system of Davies
and Pfenning, along with the reduction rules
is-app (box P Q) −→ true
is-app (box M ) −→ false

if M is not of the form P Q

The function computed by is-app is truly intensional, as it depends solely on the
syntactic structure of its argument: it merely checks if it syntactically is an application
or not. As such, it can be considered a criterion of intensionality, albeit an extreme
one: its definability conclusively confirms the presence of computation up to syntax.
Gabbay and Nanevski tried to justify the inclusion of is-app by producing denotational semantics for modal types in which the semantic domain JAK directly involves
the actual closed terms of type A. However, something seems to have gone wrong

with substitution. In fact, we believe that their proof of soundness is wrong: it is not
hard to see that their semantics is not stable under the second of these two reductions:
take M to be u, and let the semantic environment map u to an application P Q, and
then notice that this leads to JtrueK = JfalseK. We can also see this in the fact that

their notion of reduction is not confluent. Here is the relevant counterexample: we

can reduce like this:
let box u ⇐ box (P Q) in is-app (box u) −→ is-app (box P Q) −→ true
But we could have also reduced like that:
let box u ⇐ box (P Q) in is-app (box u) −→ let box u ⇐ box (P Q) in false −→ false
This example is easy to find if one tries to plough through a proof of confluence: it is
very clearly not the case that M −→ N implies M [P/u] −→ N [P/u] if u is under a
box (−), exactly because of the presence of intensional operations such as is-app.
Perhaps the following idea is more workable: let us limit intensional operations
to a chosen set of functions f : T (A) → T (B) from terms of type A to terms
51

of type B, and then represent them in the language by a constant f˜, such that
f˜(box M ) −→ box f (M ). This set of functions would then be chosen so that they
satisfy some sanity conditions. Since we want to have a let construct that allows us
to substitute code for modal variables, the following general situation will occur: if
N −→ N 0 , we have
let box u ⇐ box M in N −→ N [M/u]
but also
let box u ⇐ box M in N −→ let box u ⇐ box M in N 0 −→ N 0 [M/u]
Thus, in order to have confluence, we need N [M/u] −→ N 0 [M/u]. This will only
be the case for reductions of the form f˜(box M ) → box f (M ) if f (N [M/u]) ≡
f (N )[M/u], i.e. if f is substitutive. But then a simple naturality argument gives
that f (N ) ≡ f (u[N/u]) ≡ f (u)[N/u], and hence f˜ is already definable by
λx : A. let box u ⇐ x in box f (u)
so such a ‘substitutive’ function is not intensional after all.
In fact, the only truly intensional operations we can add to our calculus will be
those acting on closed terms. We will see that this circumvents the problems that
arise when intensionality interacts with substitution. Hence, we will limit intensional
operations to the following set:
Definition 7 (Intensional operations). Let T (A) be the set of (α-equivalence classes
of) closed terms such that · ; · ` M : A. Then, the set of intensional operations,
F(A, B), is defined to be the set of all functions f : T (A) → T (B).
We will include all of these intensional operations f : T (A) → T (B) in our calculus,
as constants:
∆ ; Γ ` f˜ : A → B
with reduction rule f˜(box M ) → box f (M ), under the proviso that M is closed.
Of course, these also includes operations on terms that might not be computable.
However, we are interested in proving consistency of intensional operations in the
most general setting. The questions of which intensional operations are computable,
and which primitives can and should be used to express them, are both still open.

52

Figure 3.2: Reduction for Intensional PCF

(λx:A. M )N −→ M [N/x]

M −→ N
M P −→ N P

M −→ N

(−→ β)

λx:A. M −→ λx:A. N
P −→ Q

(app1 )

M P −→ M Q

let box u ⇐ box M in N −→ N [M/u]

fix z in M −→ M [box (fix z in M )/z]

M closed
f˜(box M ) −→ box f (M )

(fix)

(int)

let box u ⇐ M in P −→ let box u ⇐ N in P
P −→ Q
let box u ⇐ M in P −→ let box u ⇐ M in Q

(zero?1 )

succ n
b −→ n[
+1

(let-cong1 )

(let-cong2 )

zero? n[
+ 1 −→ false

(succ)

⊃G true M N −→ M

(app2 )

(β)

M −→ N

zero? b
0 −→ true

pred n
b −→ n[
´1

(⊃1 )

(congλ )

(zero?2 )

(pred)

⊃G false M N −→ N

53

(⊃2 )

Figure 3.3: Equational Theory for Intensional PCF

Function Spaces

∆;Γ`N :A

∆ ; Γ, x:A, Γ0 ` M : B

∆ ; Γ ` (λx:A.M ) N = M [N/x] : B

(→ β)

Modality

∆;·`M :A

∆, u : A ; Γ ` N : C

(β)

∆ ; Γ ` let box u ⇐ box M in N = N [M/x] : C
∆ ; z : A ` M : A
∆ ; Γ ` fix z in M = M [box (fix z in M )/z] : A

(fix)

· ; · ` M : A f ∈ F(A, B)
(int)
∆ ; Γ ` f˜(box M ) = box f (M ) : B
∆ ; Γ ` M = N : A

∆;Γ`P =Q:C

∆ ; Γ ` let box u ⇐ M in P = let box u ⇐ N in Q : B

(let-cong)

Remark. In addition to the above, one should also include (a) rules that ensure
that equality is an equivalence relation, (b) congruence rules for λ-abstraction and
application, and (c) rules corresponding to the behaviour of constants, as in Figure
3.2.

54

3.3.2

Reduction and Confluence

We introduce a notion of reduction for iPCF, which we present in Figure 3.2. Unlike
many studies of PCF-inspired languages, we do not consider a reduction strategy
but ordinary ‘non-deterministic’ β-reduction. We do so because are trying to show
consistency of the induced equational theory.
The equational theory induced by this notion of reduction is the one alluded to
in the previous section: it is a symmetric version of it, annotated with types. It can
be found in Figure 3.3. Note the fact that, like in the work of Davies and Pfenning,
we do not include the congruence rule for the modality:
∆;·`M =N :A
∆ ; Γ ` box M = box N : A

(cong)

In fact, the very absence of this rule is what will allow modal types to become intensional. Otherwise, the only new rules are intensional recursion, embodied by the rule
(fix), and intensional operations, exemplified by the rule (int).
We note that it seems perfectly reasonable to think that we should allow reductions
under fix, i.e. admit the rule
M −→ N
fix z in M −→ fix z in N
as M and N are expected to be of type A, which need not be modal. However,
the reduction fix z in M −→ M [box (fix z in M )/z] ‘freezes’ M under an occurrence
of box (−), so that no further reductions can take place within it. Thus, the above
rule would violate the intensional nature of boxes. We were likewise compelled to
def

define fv0 (fix z in M ) = ∅ in the previous section: we should already consider M to
be intensional, or under a box.
We can now show that
Theorem 24. The reduction relation −→ is confluent.
We will use a variant of the proof in [Kavvos, 2017b], i.e. the method of parallel
reduction. This kind of proof was originally discovered by Tait and Martin-Löf, and
is nicely documented in Takahashi [1995]. Because of the intensional nature of our
box (−) constructs, ours will be more nuanced and fiddly than any in op. cit. The
method is this: we will introduce a second notion of reduction,
=⇒ ⊆ Λ × Λ

55

which we will ‘sandwich’ between reduction proper and its transitive closure:
−→ ⊆ =⇒ ⊆ −→∗
We will then show that =⇒ has the diamond property. By the above inclusions, the
transitive closure =⇒∗ of =⇒ is then equal to −→∗ , and hence −→ is Church-Rosser.
In fact, we will follow Takahashi [1995] in doing something better: we will define for
each term M its complete development, M ? . The complete development is intuitively
defined by ‘unrolling’ all the redexes of M at once. We will then show that if M =⇒ N ,
then N =⇒ M ? . M ? will then suffice to close the diamond:
M
P

Q
M?

The parallel reduction =⇒ is defined in Figure 3.4. Instead of the axiom (refl) we
would more commonly have an axiom for variables, x =⇒ x, and M =⇒ M would
be derivable. However, we do not have a congruence rule neither for box (−) nor
for Löb’s rule, so that possibility would be precluded. We are thus forced to include
M =⇒ M , which slightly complicates the lemmas that follow.
The main lemma that usually underpins the confluence proof is this: if M =⇒ N
and P =⇒ Q, M [P/x] =⇒ N [Q/x]. However, this is intuitively wrong: no reductions
should happen under boxes, so this should only hold if we are substituting for a
variable not occurring under boxes. Hence, this lemma splits into three different
ones:
• P =⇒ Q implies M [P/x] =⇒ M [Q/x], if x does not occur under boxes: this is
the price to pay for replacing the variable axiom with (refl).
• M =⇒ N implies M [P/u] =⇒ N [P/u], even if u is under a box.
• If x does not occur under boxes, M =⇒ N and P =⇒ Q indeed imply
M [P/x] =⇒ N [Q/x]
But let us proceed with the proof.
Lemma 5. If M =⇒ N then M [P/u] =⇒ N [P/u].

56

Figure 3.4: Parallel Reduction

M =⇒ M

M =⇒ N

(refl)

P =⇒ Q

(λx:A. M )P =⇒ N [Q/x]
M =⇒ N

M =⇒ N
λx:A. M =⇒ λx:A. N
P =⇒ P 0
⊃G true P Q =⇒ P 0

(congλ )

P =⇒ Q

M P =⇒ N Q
Q =⇒ Q0

(⊃1 )

⊃G false P Q =⇒ Q0
M =⇒ N

let box u ⇐ box P in M =⇒ N [P/u]
M =⇒ M 0
fix z in M =⇒ M 0 [box (fix z in M )/z]
M closed
f˜(box M ) =⇒ box f (M )
M =⇒ N

(→ β)

(app)

(⊃2 )

(β)

(fix)

(int)

P =⇒ Q

let box u ⇐ M in P =⇒ let box u ⇐ N in Q

(let-cong)

Remark. In addition to the above, one should also include rules for the constants,
but these are merely restatements of the rules in Figure 3.2.

57

Proof. By induction on the generation of M =⇒ N . Most cases trivially follow, or
consist of simple invocations of the IH. In the case of (→ β), the known substitution
lemma suffices. Let us look at the cases involving boxes.
Case(β). Then M =⇒ N is let box v ⇐ box R in S =⇒ S 0 [R/v] with S =⇒
S 0 . By the IH, we have that S[P/u] =⇒ S 0 [P/u], so
let box v ⇐ box R[P/u] in S[P/u] =⇒ S 0 [P/u][R[P/u]/v]
and this last is α-equivalent to S 0 [R/v][P/u] by the substitution lemma.
Case(fix). A similar application of the substitution lemma.
Case(int). Then M =⇒ N is f˜(box Q) =⇒ box f (Q). Hence


f˜(box Q) [P/u] ≡ f˜(box Q) =⇒ box f (Q) ≡ (box f (Q)) [P/u]
simply because both Q and f (Q) are closed.

Lemma 6. If P =⇒ Q and x 6∈ fv≥1 (M ), then M [P/x] =⇒ M [Q/x].
Proof. By induction on the term M . The only non-trivial cases are those for M a
variable, box M 0 or fix z in M 0 . In the first case, depending on which variable M is,
use either (refl), or the assumption P =⇒ Q. In the latter two, (box M 0 )[P/x] ≡
box M 0 ≡ (box M 0 )[Q/x] as x does not occur under a box, so use (refl), and similarly
for fix z in M 0 .
Lemma 7. If M =⇒ N , P =⇒ Q, and x 6∈ fv≥1 (M ), then
M [P/x] =⇒ N [Q/x]
Proof. By induction on the generation of M =⇒ N . The cases for most congruence
rules and constants follow trivially, or from the IH. We prove the rest.
Case(refl). Then M =⇒ N is actually M =⇒ M , so we use Lemma 6 to infer
M [P/x] =⇒ M [Q/x].
Case(int). Then M =⇒ N is actually
f˜(box M ) =⇒ box f (M ). But M

and f (M ) are closed, so f˜(box M ) [P/x] ≡ f˜(box M ) =⇒ box f (M ) ≡
(box f (M )) [Q/x].
58

Case(⊃i ). Then M =⇒ N is ⊃G true M N =⇒ M 0 with M =⇒ M 0 . By the
IH, M [P/x] =⇒ M 0 [Q/x], so
⊃G true M [P/x] N [P/x] =⇒ M 0 [Q/x]
by a single use of (⊃1 ). The case for false is similar.
Case(→ β). Then (λx0 :A. M )N =⇒ N 0 [M 0 /x0 ], where M =⇒ M 0 and N =⇒
N 0 . Then
((λx0 :A. M )N ) [P/x] ≡ (λx0 :A. M [P/x])(N [P/x])
But, by the IH, M [P/x] =⇒ M 0 [Q/x] and N [P/x] =⇒ N 0 [Q/x]. So by (→ β)
we have
(λx0 :A. M [P/x])(N [P/x]) =⇒ M 0 [Q/x] [N 0 [Q/x]/x0 ]
But this last is α-equivalent to (M 0 [N 0 /x0 ]) [Q/x] by the substitution lemma.
Case(β). Then let box u0 ⇐ box M in N =⇒ N 0 [M/u0 ] where N =⇒ N 0 . By
assumption, we have that x 6∈ fv (M ) and x 6∈ fv≥1 (N ). Hence, we have by
the IH that N [P/x] =⇒ N 0 [Q/x], so by applying (β) we get
(let box u0 ⇐ box M in N )[P/x] ≡ let box u0 ⇐ box M [P/x] in N [P/x]
≡ let box u0 ⇐ box M in N [P/x]
=⇒ N 0 [Q/x][M/u0 ]
But this last is α-equivalent to N 0 [M/u0 ][Q/x], by the substitution lemma and
the fact that x does not occur in M .
Case(fix). Then fix z in M =⇒ M 0 [box (fix z in M )/z], with M =⇒ M 0 . As
x 6∈ fv≥1 (fix z in M ), we have that x 6∈ fv (M ), and by Lemma 9, x 6∈ fv (M 0 )
either, so
(fix z in M )[P/x] ≡ fix z in M
and
M 0 [fix z in M/z][Q/x] ≡ M 0 [Q/x][fix z in M [Q/x]/z] ≡ M 0 [fix z in M/z]
Thus, a single use of (fix) suffices.

We now pull the following definition out of the hat:
59

Definition 8 (Complete development). The complete development M ? of a term M
is defined by the following clauses:
def

x? = x
def

c? = c

(c ∈ {f˜, n
b, zero?, . . . })

(λx:A. M )? = λx:A. M ?

?
def
˜
f (box M ) = box f (M )
def

if M is closed

((λx:A. M ) N )? = M ? [N ? /x]
def

(⊃G true M N )? = M ?
def

(⊃G false M N )? = N ?
def

(M N )? = M ? N ?
def

(box M )? = box M
def

(let box u ⇐ box M in N )? = N ? [M/u]
def

(let box u ⇐ M in N )? = let box u ⇐ M ? in N ?
def

(fix z in M )? = M ? [box (fix z in M )/z]
def

We need the following two technical results as well.
Lemma 8. M =⇒ M ?
Proof. By induction on the term M . Most cases follow immediately by (refl), or by
the IH and an application of the relevant rule. The case for box M follows by (refl),
the case for fix z in M follows by (fix), and the case for f˜(box M ) by (int).
Lemma 9 (BFV antimonotonicity). If M =⇒ N then fv≥1 (N ) ⊆ fv≥1 (M ).
Proof. By induction on M =⇒ N .
And here is the main result:
Theorem 25. If M =⇒ P , then P =⇒ M ? .
Proof. By induction on the generation of M =⇒ P . The case of (refl) follows by
Lemma 8, and the cases of congruence rules follow from the IH. We show the rest.
Case(→ β). Then we have (λx:A. M )N =⇒ M 0 [N 0 /x], with M =⇒ M 0
and N =⇒ N 0 . By the IH, M 0 =⇒ M ? and N 0 =⇒ N ? . We have that
x 6∈ fv≥1 (M ), so by Lemma 9 we get that x 6∈ fv≥1 (M 0 ). Hence, by Lemma 7
we get M 0 [N 0 /x] =⇒ M ? [N ? /x] ≡ ((λx:A. M ) N )? .
60

Case(β). Then we have
let box u ⇐ box M in N =⇒ N 0 [M/u]
where N =⇒ N 0 . By the IH, N 0 =⇒ N ? , so it follows that
N 0 [M/u] =⇒ N ? [M/u] ≡ (let box u ⇐ box M in N )?
by Lemma 5.
Case(fix). Then we have
fix z in M =⇒ M 0 [box (fix z in M )/z]
where M =⇒ M 0 . By the IH, M 0 =⇒ M ? . Hence
M 0 [box (fix z in M )/z] =⇒ M ? [box (fix z in M )/z] ≡ (fix z in M )?
by Lemma 5.
Case(int). Similar.

As a result,
Corollary 2. The equational theory of iPCF (Figure 3.3) is consistent.

3.4

Some important terms

Let us look at the kinds of terms we can write in iPCF.
From the axioms of S4 First, we can write a term corresponding to axiom K, the
normality axiom of modal logics:
def

axK = λf : (A → B). λx : A. let box g ⇐ f in let box y ⇐ x in box (g y)
Then ` axK : (A → B) → (A → B). An intensional reading of this is
the following: any function given as code can be transformed into an effective
operation that maps code of type A to code of type B.
The rest of the axioms correspond to evaluating and quoting. Axiom T takes
code to value, or intension to extension:
def

` evalA = λx : A. let box y ⇐ x in y : A → A
and axiom 4 quotes code into code-for-code:
def

` quoteA = λx : A. let box y ⇐ x in box (box y) : A → A
61

Undefined The combination of eval and intensional fixed points leads to non-termination,
in a style reminiscent of the term (λx. xx)(λx. xx) of the untyped λ-calculus.
Let
def

ΩA = fix z in (evalA z)
Then ` ΩA : A, and
ΩA −→ evalA (box ΩA ) −→∗ ΩA
The Gödel-Löb axiom: intensional fixed points Since (fix) is Löb’s rule, we
expect to be able to write down a term corresponding to the Gödel-Löb axiom
of provability logic. We can, and it is an intensional fixed-point combinator :
def

YA = λx : (A → A). let box f ⇐ x in box (fix z in f z)
and ` YA : (A → A) → A. We observe that
YA (box M ) −→∗ box (fix z in (M z))
Notice that, in this term, the modal variable f occurs free under a fix z in (−)
construct. This will prove important in §8, where this occurrence will be prohibited.
Extensional Fixed Points Perhaps surprisingly, the ordinary PCF Y combinator
is also definable in the iPCF. Let
def

YA = fix z in λf : A → A. f (eval z f )
Then ` YA : (A → A) → A, so that
YA −→∗ λf : A → A. f (eval (box YA ) f ))
−→∗ λf : A → A. f (YA f )
Notice that, in this term, the modal variable z occurs free under a λ-abstraction.
This will prove important in §8, where this occurrence will be prohibited.

3.5

Two intensional examples

No discussion of an intensional language with intensional recursion would be complete
without examples that use these two novel features. Our first example uses intensionality, albeit in a functional way, and is drawn from the study of PCF and issues
related to sequential vs. parallel (but not concurrent) computation. Our second example uses intensional recursion, so it is slightly more adventurous: it is a computer
virus.
62

3.5.1

‘Parallel or’ by dovetailing

In [Plotkin, 1977] Gordon Plotkin proved the following theorem: there is no term
por : Bool → Bool → Bool of PCF such that por true M β true and por M true β
true for any ` M : Bool, whilst por false false β false. Intuitively, the problem is
that por has to first examine one of its two arguments, and this can be troublesome
if that argument is non-terminating. It follows that the parallel or function is not
definable in PCF. In order to regain the property of so-called full abstraction for the
Scott model of PCF, a constant denoting this function has to be manually added to
PCF, and endowed with the above rather clunky operational semantics. See [Plotkin,
1977, Gunter, 1992, Mitchell, 1996, Streicher, 2006].
However, the parallel or function is a computable partial recursive functional [Streicher, 2006, Longley and Normann, 2015]. The way to prove that is intuitively the
following: given two closed terms M, N : Bool, take turns in β-reducing each one for
a one step: this is called dovetailing. If at any point one of the two terms reduces to
true, then output true. But if at any point both reduce to false, then output false.
This procedure is not definable in PCF because a candidate term por does not
have access to a code for its argument, but can only inspect its value. However, in
iPCF we can use the modality to obtain access to code, and intensional operations
to implement reduction. Suppose we pick a reduction strategy −→ r . Then, let us
include a constant tick : Bool → Bool that implements one step of this reduction
strategy on closed terms:
M −→r N, M, N closed
tick (box M ) −→ box N
Also, let us include a constant done? : Bool → Bool, which tells us if a closed term
under a box is a normal form:
M closed, normal
M closed, not normal
done? (box M ) −→ true

done? (box M ) −→ false

It is not hard to see that these two intensional operations can be subsumed under
our previous scheme for introducing intensional operations: our proof still applies,
yielding a consistent equational system.
The above argument is now implemented by the following term:
por :≡ Y(λpor. λx : Bool. λy : Bool.
⊃Bool (done? x)

(lor (eval x)(eval y))
(⊃Bool (done? y)

(ror (eval x)(eval y))
(por (tick x)(tick y)))

63

where lor, ror : Bool → Bool → Bool are terms defining the left-strict and rightstrict versions of the ‘or’ connective respectively. Notice that the type of this term is
Bool → Bool → Bool: we require intensional access to the terms of boolean type
in order to define this function!

3.5.2

A computer virus

Abstract computer virology is the study of formalisms that model computer viruses.
There are many ways to formalise viruses. We will use the model of Adleman [1990],
where files can be interpreted either as data, or as functions. We introduce a data
type F of files, and two constants
in : (F → F ) → F

and out : F → (F → F )

If F is a file, then out F is that file interpreted as a program, and similarly for
in. We ask that out (in M ) −→ M , making (F → F ) a retract of F .2 This
might seem the same as the situation where F → F is a retract of F , which yields
models of the (untyped) λ-calculus, and is not trivial to construct [Barendregt, 1984,
§5.4]. However, in our case it is not nearly as worrying: (F → F ) is populated
by programs and codes, not by actual functions. Under this interpretation, the pair
(in, out) corresponds to a kind of Gödel numbering—especially if F is N.
Now, in Adleman’s model, a virus is a given by its infected form, which either
injures, infects, or imitates other programs. The details are unimportant in the
present discussion, save from the fact that the virus needs to have access to code that
it can use to infect other executables. One can hence construct such a virus from its
infection routine, by using Kleene’s SRT. Let us model it by a term
` infect : (F → F ) → F → F
which accepts a piece of viral code and an executable file, and it returns either the
file itself, or a version infected with the viral code. We can then define a term
def

` virus = fix z in (infect z) : F → F
so that
virus −→∗ infect (box virus)
which is a program that is ready to infect its input with its own code.
2

Actually, in §8.5 and §8.6 we will see it is very easy to construct examples for the apparently
more natural situation where in : (F → F ) → F , out : F → (F → F ), and out (in M ) −→
evalF →F M . Nevertheless, our setup is slightly more well-adapted to virology.

64

3.6

Open Questions

We have achieved the desideratum of an intensional programming language, with
intensional recursion. There are two main questions that result from this development.
Firstly, does there exist a good set of intensional primitives from which all others
are definable? Is there perhaps more than one such set, hence providing us with a
choice of programming primitives?
Secondly, what is the exact kind of programming power that we have unleashed?
Does it lead to interesting programs that we have not been able to write before?
We have outlined some speculative applications for intensional recursion in §2.1.4. Is
iPCF a useful tool when it comes to attacking these?
We discuss some more aspects of iPCF in the concluding chapter (§9.2).

65

Chapter 4
Categories and Intensionality1
We turn now to the discussion of the categorical modelling of intensionality.
We have discussed the importance of intensionality for Computer Science in §1.1.
One might therefore ask why the concept has not led to many exciting developments.
Abramsky [2014] suggests that it may simply be that the extensional paradigm is
already sufficiently challenging:
“ [...] while Computer Science embraces wider notions of processes than
computability theory, it has tended to refrain from studying intensional
computation, despite its apparent expressive potential. This reluctance is
probably linked to the fact that it has proved difficult enough to achieve
software reliability even while remaining within the confines of the extensional paradigm. Nevertheless, it seems reasonable to suppose that
understanding and harnessing intensional methods offers a challenge for
computer science which it must eventually address.”
But we believe that there is also a deeper reason: once we step outside extensionality,
there are no rules: one might even say that ‘anything goes:’ this is what Abramsky
means by the phrase “loose baggy monster” (quoted at the start of §1.2). A natural
reaction to this state of affairs is to turn to category theory in an attempt to find
some structure that can put things into perspective, or simply provide a language for
studying the interplay between the extensional and the intensional.
Surprisingly, very little has been said about intensionality in the categorical domain. Lawvere [1969, 2006] observes that there are categories which are not wellpointed, hence—in some sense—‘intensional.’ But if we only allow for slightly more
generality, this intensionality vanishes: there is only one notion of equality.
1
A preliminary form of the results in this chapter was first published as [Kavvos, 2017a], which
is available at Springer: https://dx.doi.org/10.1007/978-3-662-54458-7_32

66

We shall take the hint regarding the relationship between modal logic and intensionality from our discussion in §1.4. We already know that there is a deep connection
between logic, type theory, and category theory, namely the Curry-Howard-Lambek
correspondence. This makes it likely that attempting to transport the reading of
modality-as-intension to the realm of category theory could lay the foundation for a
basic theory of intensionality. We hence revisit the appropriate categorical semantics
of type theories in the spirit of S4, which was introduced by Bierman and de Paiva
[2000]. We find that it is not appropriate for our purposes, and we argue to that
effect in §4.1.
Taking all of these points into account, one can only surmise that there has to be
a radical shift in our perspective: we need to step outside classical 1-category theory.
Fortunately, this necessary groundwork has been laid by Čubrić et al. [1998] and their
discovery of P-category theory. We introduce P-category theory in §4.1.2, and discuss
its use in modelling intensionality.
All that remains is to introduce a new concept that ties intensionality and extensionality together under the same roof. This is the notion of an exposure, which we
introduce and study in §4.2.

4.1

Categories are not intensional

At the outset, things look promising: let there be a category C with a terminal object
1. Arrows of type x : 1 → C are called points of the object C. An arrow f : C → A
introduces a map
x:1→C

7−→

f ◦x:1→A

from points of C to points of A. In this setting, Lawvere [1969, 2006] observes that
we may have two distinct arrows f, g : C → A that induce the same map, i.e. such
that
∀x : 1 → A. f ◦ x = g ◦ x
all whilst f 6= g. In this case, we say that the category C does not have enough points,
or is not well-pointed.
Nevertheless, lack of enough points is not enough to have ‘intensionality,’ and the
discussion in [Awodey, 2010, §2.3] provides the necessary intuition. Up to now, we
have focused on points x : 1 → C. These can be construed as ‘tests’, in the sense that
we can look at each f ◦ x and infer some information about the arrow f : C → A, e.g.
its value at some ‘argument’ x : 1 → C. However, we can conceive of more involved

67

test objects T , and significantly more comprehensive ‘tests’ of type x : T → C which
we can call generalised points. Arrows f : C → A are completely distinguishable
if given arbitrary generalised points. The argument is dumbfoundingly trivial: the
most thorough ‘test object’ is C itself, and for that one there’s the generalised point
idC : C → C with the unfortunate property that f ◦ idC = f 6= g = g ◦ idC .
We can therefore draw the conclusion that categories cannot model intensionality:
there cannot be two distinct arrows f and g that are indistinguishable within the
category. Of course, we can always quotient C by some compatible equivalence relation
∼ to obtain C/ ∼. Then the intensional universe would be C, and its extensional
version would be C/ ∼. But that would entail that we are no longer operating within
a single mathematical universe, i.e. a single category!

4.1.1

Intension, Modality, and Categories

We thus return to the modality-as-intention interpretation of §1.4 to look for the answer. From a categorical perspective, all is well with the intuitions we have developed
there and in §3, save the punchline: the categorical semantics of the S4 box modality,
due to Bierman and de Paiva [2000] and Kobayashi [1997], specifies that
 : C −→ C
is part of a monoidal comonad (, , δ) on a cartesian closed category C. Let us define
some of these notions for the sake of completeness.
Definition 9. A comonad (Q, , δ) consists of an endofunctor
Q : C −→ C
and two natural transformations,
 : Q ⇒ IdC ,

δ : Q ⇒ Q2

such that the following diagrams commute:
QA

δA

QA

δQA

δA

Q2 A

Q2 A

QδA

δA

Q3 A

Q2 A

68

δA

idA
QA

Q2 A
QA

QA

In the cartesian case, monoidality requires the provision of morphisms
mA,B : QA × QB → Q(A × B)
m0 : 1 → Q1
natural in each pair of objects A, B ∈ C, which must also make certain diagrams
commute. We will be particularly interested in the case where the functor is strong
monoidal, i.e. mA,B and m0 are natural isomorphisms. It has been shown in the
technical report [Kavvos, 2017c] that this is the same as a product-preserving functor.
The transformations δ : Q ⇒ Q2 and  : Q ⇒ IdC are monoidal if the following
diagrams commute:
QA × QB

A ×B

A×B

1

mA,B

m0

Q(A × B)
QA × QB

δA ×δB

A×B

Q1

A×B

Q2 A × Q2 B

1
m0

mQA,QB

Q(QA × QB)

mA,B

1

1

Q1

m0

Q(m0 )
QmA,B

Q(A × B)

δA×B

Q1

Q2 (A × B)

δ1

Q2 1

Please refer to [Mac Lane, 1978, §XI.2] or [Melliès, 2009, §5] for more details, and the
missing commuting diagrams.
Now, as  : C −→ C is a functor, it will unfortunately trivially satisfy
f =g

=⇒

f = g

and will hence necessarily validate the congruence rule for the modality:
∆;·`M =N :A
∆ ; Γ ` box M = box N : A

(cong)

This does not conform to the ‘no reductions under box (−)’ restriction, and hence
disrupts the intensional nature of the modal types in iPCF.
As if this were not enough, we will now present another argument that provides the
last straw for the monoidal comonad interpretation. Intuitively, if A is to represent
code of type A, then there should be many more points 1 → A than points 1 → A:
there is more than one expression corresponding to the same value in any interesting
69

logical system. Under a very mild assumption, this desideratum fails. To show that,
suppose we have a monoidal comonad (, , δ). Furthermore, suppose the components
of δ : Q ⇒ Q2 satisfy the following definition:
Definition 10. The component δA : A → 2 A is reasonable quoting device at A
just if the following diagram commutes:
1

a

m0

1

A
δA

a

2 A

This equation may be type-theoretically expressed in iPCF as the following equation
for any ` M : A:
` let box u ⇐ M in box (box u) = box M : A
Then,
Proposition 1. If each component δA : A → 2 A of a monoidal comonad (, , δ)
is a reasonable quoting device, then there is a natural isomorphism
C(1, −) ∼
= C(1, (−))
Proof. We can define maps
in : C(1, A) → C(1, A)
x 7→ x ◦ m0
out : C(1, A) → C(1, A)
a 7→ A ◦ a
and then calculate:
out (in(x)) = A ◦ x ◦ m0 = x ◦ 1 ◦ m0 = x
where the last equality is because 1 is a terminal object. Similarly,
in (out(a)) = (A ◦ a) ◦ m0 = A ◦ a ◦ m0 = A ◦ δA ◦ a = a
where we have only used our ‘reasonable’ condition, and one of the comonad laws.
Naturality of the isomorphism follows by functoriality of  and naturality of .

70

Hence, in these circumstances, there are no more codes than values!
This definition of a reasonable quoting device is slightly mysterious. In fact,
it follows from the commutation of the following more general diagram, for each
f : QA → QB:
f

QA

QB

δA

δB

Q2 A

Qf

Q2 B

Indeed, given a : 1 → QA, consider a ◦ m−1
: Q1 → QA. Commutation of the
0
diagram them yields
−1
δA ◦ a ◦ m−1
0 = Q(a ◦ m0 ) ◦ δ1

Taking the m0 to the other side, we have
−1
δA ◦ a = Qa ◦ Qm−1
0 ◦ δ1 ◦ m0 = Qa ◦ Qm0 ◦ Qm0 ◦ m0 = Qa ◦ m0

by the monoidality of δ. In turn, commutation of this diagram for any f : A → B
corresponds to the comonad being idempotent.
Theorem 26 (Idempotence). Given a comonad (Q, , δ), the following are equivalent:
1. δ : Q ⇒ Q2 is an isomorphism.
2. δ ◦ Q : Q2 ⇒ Q2 is the identity natural transformation.
3. For all f : QA → QB, Qf ◦ δA = δB ◦ f .
If any one of these holds, we say that (Q, , δ) is idempotent.
Proof. We prove (2) ⇒ (3) ⇒ (1) ⇒ (2).
Case(2 ⇒ 3). We have
Qf ◦ δA
= { by (2) }
δB ◦ QB ◦ Qf ◦ δA
= { naturality of  }
δB ◦ f ◦ QA ◦ δA
= { comonad equation }
δB ◦ f
71

Case(3 ⇒ 1). We already know that Q ◦ δ = Id from the comonad equations,
so it remains to prove that δ ◦ Q is the identity natural transformation on Q.
δA ◦ QA
= { by (3) }
QQA ◦ δQA
= { comonad equation }
idQA
Hence δ −1 = Q .
Case(1 ⇒ 2). We have
δA ◦ QA
= { by (1) }
δA ◦ QA ◦ δA ◦ δA−1
= { comonad equation }
δA ◦ δA−1
= { δ iso }
idQ2 A

The behaviour of code will often be idempotent in the above sense: once something
is quoted code, it is in the realm of syntax, and more layers of quoting do not change
its quality as sense. Thus, the above argument delivers a fatal blow to the monoidal
comonad approach.

4.1.2

PERs and P-categories

The way out of this seeming impasse is to step outside 1-category theory. We shall
use the notion of P-category, which was introduced by Čubrić et al. [1998] precisely
so the authors could deal with a form of intensionality.2
P-category theory is essentially category theory up to a partial equivalence relation.
2

For the record, the gist of [Čubrić et al., 1998] is that the Yoneda embedding on the categorical
term model of typed λ-calculus is a key ingredient in normalisation by evaluation—with the proviso
that terms are not strictly identified up to βη equality!

72

Definition 11. A partial equivalence relation (PER) is a symmetric and transitive
relation.
Partial equivalence relations were introduced to Theoretical Computer Science
by Turing in an unpublished manuscript, and brought to the study of semantics by
Girard [1972] and Scott [1975]. Broadly speaking, we can view an equivalence relation
on a set as a notion of equality for that set. However, partial equivalence relations
might not be reflexive. Elements that are not related to themselves can be understood
as not being well-defined. We can, for example, define a PER ∼ between sequences
of rationals as follows: {xi } ∼ {yi } just if both sequences are Cauchy and converge
to the same real number. Sequences that are not Cauchy cannot be real numbers.
Definition 12. A P-set is a pair A = (|A| , ∼A ) consisting of a set |A| and a PER
∼A on A.
We will formally distinguish between elements x ∈ |A| of the P-set A, and points
x ∈ A of A: for the latter we will also require that x ∼A x, i.e. that they be
well-defined. Given a P-set A, its domain dom(A) is the set of its points.
The notion of operation will be instrumental in the development of our theory. An
operation is a transformation between the elements of P-sets that is not functional,
in that it need not respect the PERs on P-sets.
Definition 13 (Operation). Given two P-sets A = (|A| , ∼A ) and B = (|B| , ∼B ), an
operation, written
f : A 99K B
is a function f : |A| → |B| such that x ∼A x implies f (x) ∼B f (x).
I.e. an operation takes elements to elements, but when given a point (well-defined
element) also returns a point. Some operations are more well-behaved:
Definition 14. An operation f : A 99K B is a P-function, written
f :A→B
just if x ∼A y implies f (x) ∼B f (y).
We will later see that P-sets and P-functions form a cartesian closed P-category
(Theorem 27). The main ingredients needed for that theorem are the subject of the
first three of the following examples.
Example 1.
73

1. The P-set 1 is defined to be ({∗}, {(∗, ∗)}).
2. Given P-sets A = (|A| , ∼A ) and B = (|B| , ∼B ), we define the P-set A × B by
def

|A × B| = |A| × |B| and (a, b) ∼A×B (a0 , b0 ) just if a ∼A a0 and b ∼B b0 .
3. Given P-sets A = (|A| , ∼A ) and B = (|B| , ∼B ), the P-functions f : A → B
def

form a P-set B A = ( B A , ∼B A ) as follows: B A = { f | f : A 99K B }, and
f ∼B A g just if a ∼A a0 implies f (a) ∼B g(a0 ).
4. Given P-sets A = (|A| , ∼A ) and B = (|B| , ∼B ), the P-operations f : A 99K B
form a P-set A  B = ( B A , ∼AB ) with the same underlying set B A , but
with f ∼AB g just if f = g.

In the definition of the P-set of P-functions, it is evident that all operations f :
A 99K B are present as elements in B A . However, they are only in dom(B A )
if they are P-functions. This pattern of ‘junk’ being present amongst elements is
characteristic when it comes to PERs, and it is the reason we need the notion of points.
A P-point of the P-set A would be a P-function x : 1 → A, which is determined by
the point x(∗) ∈ dom(A). We will systematically confuse a P-point x : 1 → A with
the point x(∗) ∈ dom(A).
We can finally define what it means to be a
Definition 15 (P-category). A P-category (C, ∼) consists of:
• a set of objects ob(C);

• for any two objects A, B ∈ ob(C), a P-set C(A, B) = |C(A, B)| , ∼C(A,B) ;
• for each object A ∈ ob(C), a point idA ∈ C(A, A);
• for any three objects A, B, C ∈ ob(C), a P-function
cA,B,C : C(A, B) × C(B, C) → C(A, C)
def

for which we write g ◦ f = cA,B,C (f, g),
such that, for any point f ∈ C(A, B) we have
f ◦ idA ∼C(A,B) f
idB ◦ f ∼C(A,B) f
and for any f ∈ C(A, B), g ∈ C(B, C) and h ∈ C(C, D), we have
h ◦ (g ◦ f ) ∼C(A,D) (h ◦ g) ◦ f
74

In a P-category we have an ordinary set of objects, but only a P-set of morphisms.
We will say that f is an arrow of C with domain A and codomain B, and write
f : A → B, only whenever f is a well-defined morphism, i.e. f ∈ dom(C(A, B)).
Furthermore, we will variously refer to P-categories by Fraktur letters B, C, . . . ,
without mentioning the family of relations {∼C(A,B) }A,B∈C . Sometimes we might use
the same sets of morphisms |C(A, B)|, but with a different PER; we will then indicate
.
which PER we are using, by writing e.g. (C, ∼) or (C, =). When the types of two
morphisms f and g are evident, we will write f ∼ g without further ado.
We can think of the morphisms as intensional, and of the PER on them as describing extensional equality. That composition is a P-function encodes the requirement
that composition respects extensional equality: if f ∼ f 0 and g ∼ g 0 , then g◦f ∼ g 0 ◦f 0 .
As is expected, P-categories come with associated notions of functor and natural
transformation.
Definition 16 (P-functor). Let C, D be P-categories. A P-functor F : C −→ D from
C to D consists of a map assigning an object F X ∈ D for each object X ∈ C, and a
family of P-functions,
FA,B : C(A, B) → D(F A, F B)
for each pair of objects A, B ∈ C, such that
F (idA ) ∼ idF A
F (g ◦ f ) ∼ F g ◦ F f
for all pairs of arrows f : A → B and g : B → C.
Definition 17 (P-natural transformation). Let F, G : C −→ D be P-functors. A
P-natural transformation θ : F ⇒ G consists of an arrow θA : F A → GA in D for
each A ∈ C, such that for each f : A → B we have
θB ◦ F f ∼ Gf ◦ θA
Finally, the definitions of finite products and exponentials carry over smoothly.
The various components of the definitions are required to be unique with respect to
their universal property, but only up to the PERs.
Definition 18 (Terminal object). Let C be a P-category. An object 1 ∈ C is terminal
just if for every C ∈ C there is an arrow
!C : C → 1
such that !C ∼ !C , and for every arrow h : C → 1 we have h ∼ !C .
75

Definition 19 (Binary Product). Let C be a P-category, and let A, B ∈ C. The
object A × B ∈ C is a product of A and B if there are arrows
π

π

1
2
A ←−
A × B −→
B

and for any object C ∈ C, there is a P-function
h·, ·i : C(C, A) × C(C, B) → C(C, A × B)
such that for every f : C → A and g : C → B we have
π1 ◦ hf, gi ∼ f
π2 ◦ hf, gi ∼ g
and, for any h : C → A × B, we have hπ1 ◦ h, π2 ◦ hi ∼ h.
Of course, the usual calculational rules of products still hold, e.g.
hf, gi ◦ h ∼ hf ◦ h, g ◦ hi
(f × g) ◦ hh, ki ∼ hf ◦ h, g ◦ ki
and so on.
Definition 20. A cartesian P-category is a P-category that has a terminal object
and binary products.
Definition 21 (Exponential). Let C be a cartesian P-category, and let A, B ∈ C.
The object B A ∈ C is an exponential of A and B just if there is an arrow
evA,B : B A × A → B
such that, for each C ∈ C, there is a P-function
λC (−) : C(C × A, B) → C(C, B A )
such that, for any h : C × A → B and k : C → B A ,
evA,B ◦ (λC (h) × idA ) ∼ h
λC (evA,B ◦ (k × idA )) ∼ k
Definition 22 (P-ccc). A cartesian closed P-category, or P-ccc, is a P-category that
has a terminal object, binary products, and an exponential for each pair of objects.
Theorem 27 (Čubrić et al. [1998]). The P-category PSet of P-sets and P-functions
is a P-ccc.
We warn the reader that we might be lax with the prefix “P-” in the rest of this thesis,
as the overwhelming majority of it will solely concern P-categories.
76

4.2

Exposures

In this section we introduce a new P-categorical notion, that of an exposure. The aim
of exposures is to P-categorically capture the modality-as-intension interpretation.
An exposure is almost a functor : it is a map of objects and arrows of a P-category
into another, and it preserves identities and composition. It is not a functor because
it does not preserve the PERs on the hom-sets of the source P-category. Instead, it
reflects them. In that sense, it may expose the structure of a particular arrow by
uncovering its inner workings, irrespective of the extensional equality represented by
the PER. The inner workings are then represented as a well-defined arrow of some,
possibly the same, P-category.
Definition 23. An exposure Q : (B, ∼) # (C, ∼) consists of
(i) a map assigning to each object A ∈ B an object QA ∈ C, and
(ii) for each A, B ∈ C, an operation
QA,B : B(A, B) 99K C(QA, QB)
for which we simply write Qf when the source and target of f are known
such that
(i) Q(idA ) ∼ idQA ;
(ii) Q(g ◦ f ) ∼ Qg ◦ Qf , for any arrows f : A → B and g : B → C, and
(iii) QA,B reflects PERs: if Qf ∼ Qg then f ∼ g.
Like functors, exposures compose: it suffices to use reflection of PERs twice. There
is a close relationship between functors and exposures. In fact, if exposures were
functors, they would be faithful functors.
Lemma 10. A (P-)functor Q : (B, ∼) −→ (C, ∼) is an exposure if and only if it is
(P-)faithful.
Proof. If Q : (B, ∼) −→ (C, ∼) is also an exposure, then the morphism map QA,B :
B(A, B) → C(QA, QB) is a P-function which also reflects PERs, hence Q is a (P)faithful (P-)functor. The converse is similar.

77

Thus, the identity functor is an exposure IdB : (B, ∼) # (B, ∼). This lemma also
enables us to compose an exposure Q : (B, ∼) # (C, ∼) with a faithful functor in
either direction: if F : (A, ∼) −→ (B, ∼) is faithful then we can define the exposure
Q ◦ F : (A, ∼) # (C, ∼) by
def

(Q ◦ F )(A) = Q(F A)
(Q ◦ F )A,B : A(A, B) 99K C(Q(F A), Q(F B))
def

(Q ◦ F )A,B = f 7→ QA,B (FA,B (f ))
and similarly for pre-composition.
The notion of natural transformations also naturally carries over to the setting of
exposures:
•

Definition 24. A natural transformation of exposures t : F # G between two
exposures F, G : B # C consists of an arrow tA : F A → GA of C for each object
A ∈ B, such that, for every arrow f : A → B of B, the following diagram commutes
up to ∼:
FA

Ff

tA

FB
tB

GA

Gf

GB

Nevertheless, we must not be cavalier when adopting practices from 1-category theory.
For example, we cannot arbitrarily compose natural transformations of exposures with
•

other exposures. Let t : F # G be a natural transformation between two exposures
F, G : B # C. If R : A # B is an exposure, then we can define
def

(tR )A = tRA : F RA → GRA
•

These components form a natural transformation tR : F R # GR. The defining
diagram
F RA

F Rf

tRA

F RB
tRB

GRA

GRf

GRB
•

commutes, as it is the naturality square of t : F # G at Rf : RA → RB. But if we
instead have a P-functor L : C −→ D, we can define
•

Lt : LF # LG
def

(Lt)A = L(tA ) : LF A → LGA
78

We must have that L be a P-functor for this to be natural: the diagram we want is
commutative only if
L(tB ) ◦ LF f ∼ L(tB ◦ F f ) ∼ L(Gf ◦ tA ) ∼ LGf ◦ L(tA )
Whereas the first and last step would hold if L were merely an exposure, the middle
step requires that we can reason equationally ‘under L,’ which can only happen if L
preserves the PERs.

4.2.1

Intensional Equality

As exposures give a handle on the internal structure of arrows, they can be used to
define intensional equality: if the images of two arrows under the same exposure Q
are extensionally equal, then the arrows have the same implementation, so they are
intensionally equal. This is an exact interpretation of the slogan of Abramsky [2014]:
intensions become extensions.
Definition 25 (Intensional Equality). Let Q : (B, ∼) # (C, ∼) be an exposure. Two
arrows f, g : A → B of B are intensionally equal (up to Q), written
f ≈A,B
g
Q
just if Qf ∼ Qg.
We often drop the source and target superscripts, and merely write f ≈Q g. The fact
that exposures reflect PERs guarantees that
Lemma 11. Intensional equality implies extensional equality.
Proof. f ≈Q g : A → B is Qf ∼ Qg, which implies f ∼ g.
In some cases the converse is true, but not for general arrows A → B: we often need
some restrictions on A, perhaps that it is an intensional context i.e. of the form
Qn
3
i=1 QAi , or that it is simply a point. In that case, we use the following definition.
Definition 26. Let Q : (B, ∼) # (C, ∼) be an exposure.
3

Not to be confused with Voevodsky’s univalence axiom. When examining this thesis, Martin
Hyland strongly recommended that the name be changed. This will most likely happen before
subsequent publications.

79

1. Let A be a class of objects of B. An object U ∈ B is A-univalent (up to Q)
just if extensional equality implies intensional equality for arrows with domain
in A and codomain U , i.e. for every f, g : A → U with A ∈ A,
f ∼g

=⇒

f ≈Q g

2. If B has a terminal object 1, and U is {1}-univalent, we say that U is pointunivalent.
Intensional equality is a PER, as we have defined it through Q and extensional
equality, which is a PER itself. Replacing ∼ with ≈Q yields another P-category,
which is possibly ‘more intensional’ than (B, ∼).
Definition 27. Given an exposure Q : (B, ∼) # (C, ∼), we define the x-ray category
of (B, ∼) up to Q by replacing the hom-P-sets with
(|B(A, B)| , ≈A,B
Q )
We denote the x-ray category by (B, ≈Q ).
To show that this is a valid definition, we have to check that composition respects
intensional equality, and that the necessary axioms hold. If f ≈Q k and g ≈Q h, then
Q(g ◦ f ) ∼ Qg ◦ Qf ∼ Qh ◦ Qk ∼ Q(h ◦ k)
because exposures preserve composition; hence ◦ is indeed a well-defined P-function
◦ : (B, ≈Q )(A, B) × (B, ≈Q )(B, C) → (B, ≈Q )(A, C)
Similarly, the PER ≈Q hereditarily satisfies associativity of composition, and—as Q
preserves identities—also satisfies the identity laws.

4.2.2

Cartesian and Product-Preserving Exposures

Bare exposures offer no promises or guarantees regarding intensional equality. For
example, it is not a given that π1 ◦ hf, gi ≈Q f . However, from a certain viewpoint
one may argue there is no grand intensional content in projecting a component: it
is merely a structural operation and not much more. Requiring this of an exposure
strengthens the notion of intensional equality, and further reinforces the point that
exposures offer a stratified and modular view of equality.

80

Definition 28. Let B be a cartesian P-category, and let Q : B # C be an exposure.
We say that Q is cartesian just if for any arrows f : C → A, g : C → B, h : C →
A × B, and k : D → 1 we have
π1 ◦ hf, gi ≈Q f
π2 ◦ hf, gi ≈Q g
hπ1 ◦ h, π2 ◦ hi ≈Q h
k ≈Q !D
However, this is not enough to formally regain standard equations like hf, gi ◦ h ≈Q
hf ◦ h, g ◦ hi. This is because we cannot be certain that the pairing function h·, ·i
preserves the intensional equality ≈Q . We need something quite a bit stronger, which
is to ask for full extensional preservation of products.
Definition 29. A cartesian exposure Q : B # C of a cartesian P-category B in a
cartesian P-category C is product-preserving whenever the canonical arrows
∼
=

hQπ1 , Qπ2 i : Q(A × B) −
→ QA × QB
∼
=

!Q1 : Q1 −
→1
are (P-)isomorphisms. We write mA,B : QA × QB → Q(A × B) and m0 : 1 → Q1 for
their inverses.
∼
=

In essence, the isomorphism Q(A × B) −
→ QA × QB says that code for pairs is a pair
of codes, and vice versa. Amongst the exposures, the product-preserving are the only
ones that interact harmoniously with the product structure. In fact, preservation of
products forces the pairing function to preserve intensional quality, thus regaining all
the standard equations pertaining to products up to ≈Q . To show all that, we first
need the following proposition.
Proposition 2. In the above setting, the following diagram commutes up to ∼:
QC

hQf ,Qgi

QA × QB
mA,B

Qhf ,gi

Q(A × B)
i.e. mA,B ◦ hQf, Qgi ∼ Qhf, gi for f : C → A and g : C → B.

81

Proof. We compute
hQπ1 , Qπ2 i ◦ Qhf, gi
∼ { naturality }
hQπ1 ◦ Qhf, gi, Qπ2 ◦ Qhf, gii
∼ { Q is an exposure }
hQ(π1 ◦ hf, gi), Q(π2 ◦ hf, gi)i
∼ { Q is a cartesian exposure }
hQf, Qgi
def

and hence mA,B ◦ hQf, Qgi = hQπ1 , Qπ2 i−1 ◦ hQf, Qgi ∼ Qhf, gi.
One can easily easy to compute that the mA,B ’s satisfy a naturality property, similar
to the one for strong monoidal categories. That is,
Proposition 3. In the above setting, the following diagram commutes up to ∼:
QC × QD

Qf ×Qg

mC,D

Q(C × D)

QA × QB
mA,B

Q(f ×g)

Q(A × B)

i.e. mA,B ◦ (Qf × Qg) ∼ Q(f × g) ◦ mC,D for f : C → A and g : D → B.
Proof. Simple calculation as above, using the inverses of both mA,B and mC,D , as well
as the fact that Q : B # C is cartesian.
In monoidal 1-category theory this would simply be a natural isomorphism between
the functors Q(− × −) and Q(−) × Q(−). However, the product functor − × − is
not necessarily an exposure: we may have f × g ∼ h × k, yet it may be that f 6∼ h
or g 6∼ k. However, if the category is connected (all hom-P-sets are nonempty), then
the projections are epic, and hence − × − is faithful. By Lemma 10, this would then
allow us to compose it with Q to make an exposure. But since this is not the case in
general, we do not. However, the requisite naturality property follows from the fact
the m’s are the inverses of canonical arrows, so we are not seriously hampered.
We can also show that the following relationship holds between the projection
arrows and their ‘exposed’ version, given product-preservation:

82

Proposition 4. In the above setting, let
π A,B

π A,B

1
A ←−
−− A × B −−2−→ B

and

π QA,QB

π QA,QB

1
2
QA ←−
−−− QA × QB −−
−−→ QB

be product diagrams in B and C respectively. Then
QπiA,B ◦ mA,B ∼ πiQA,QB
Proof. πi ◦ m−1
A,B = πi ◦ hQπ1 , Qπ2 i ∼ Qπi
def

The product-preserving structure of Q : B # C then suffices to guarantee that taking
the mediating morphism hf, gi preserves not just extensional equality in f and g, as
it does by the definition of products in P-categories, but also intensional equality.
Hence, h·, ·i also induces products in the x-ray category (B, ≈Q ).
Proposition 5. If Q : B # C is a product-preserving exposure, then the function
h·, ·i : B(C, A) × B(C, B) → B(C, A × B)
preserves intensional equality ≈Q , and is thus a function
h·, ·i : (B, ≈Q )(C, A) × (B, ≈Q )(C, B) → (B, ≈Q )(C, A × B)
Proof. If f ≈Q h : C → A and g ≈Q k : C → B, then
Qhf, gi
∼ { Proposition 2 }
m ◦ hQf, Qgi
∼ { assumptions }
m ◦ hQh, Qki
∼ { Proposition 2 }
Qhh, ki
and hence hf, gi ≈Q hh, ki.

83

Note that in the above proof we used the ‘monoidality’ mA,B to ‘shift’ the exposure
Q exactly where we want it to be to use the assumptions f ≈Q h and g ≈Q k.
This result also implies that the standard equations for products hold up to ≈Q .4
Lemma 12.
1. If Q : B # C is a product-preserving exposure, then
hf, gi ◦ h ≈Q hf ◦ h, g ◦ hi
for f : C → A, g : C → B, and h : D → C.
2. If Q is a product-preserving exposure, then
(f × g) ◦ hh, ki ≈Q hf ◦ h, g ◦ ki
for f : C → A, g : D → B, h : E → C, k : F → D.

4.2.3

Comonadic Exposures

We can now revisit the failed categorical approach to modality-as-intension that
we discussed in §4.1.1. It turns out that all the categorical equipment used for
strong monoidal (= product-preserving) comonads have direct analogues in exposures. Throughout the rest of this section we fix a product-preserving endoexposure
Q : B # B.
If we have an interpreter that maps code to values at each type, then we can
present it as a (well-behaved) natural transformation from our selected exposure to
the identity exposure.
Definition 30. An evaluator is a transformation of exposures,
•

 : Q # IdB
such that the following diagrams commute up to ∼:
QA × QB

A ×B

A×B

mA,B

Q(A × B)

1
m0

A×B

A×B

4

Q1

1

1

In fact, even if we exclude hπ1 ◦ h, π2 ◦ hi ≈Q h from the definition of a cartesian exposure, we
can then regain it through product-preservation: in this sense, product-preservation is a strong extensionality principle that even implies the ‘η-rule’ for the x-ray category. One might even entertain
the idea that they can show the ‘β-rule’ π1 ◦ hf, gi ≈Q f simply by the existence of the isomorphism
mA,B , and without explicitly assuming Q to be cartesian, thus ostensibly reducing cartesian exposures to product-preserving ones. But the derivation of this requires Qπ1 ◦ m ∼ π1 , which seems to
only follow if the exposure is cartesian, making the apparently simple argument circular.

84

How about quoting, then? Given a point a : 1 → A, we define its quote to be the
point
Qa ◦ m0 : 1 → QA
•

The fact that  : Q # IdB lets us then calculate that
A ◦ Qa ◦ m0 ∼ a ◦ 1 ◦ m0 ∼ a
So, post-composing a component of an evaluator to a quoted point yields back the
point itself! The naturality is there to guarantee that the evaluator is defined ‘in
the same way’ at all objects. The two diagrams that are required to commute as
part of the definition would—in the context of monoidal functors—ensure that  is
a monoidal natural transformation. In the setting of exposures they are not only
necessary in the final step of the above calculation, but they also ensure that the
evaluators are compatible with products.5
Definition 31. A quoter is a transformation of exposures,
•

δ : Q # Q2
for which the following diagrams commute up to ∼:
QA × QB

δA ×δB

Q2 A × Q2 B

1
m0

mQA,QB

Q(QA × QB)

mA,B

m0

Q1
Qm0

QmA,B

Q(A × B)

δA×B

Q2 (A × B)

Q1

δ1

Q2 1

If we post-compose a component of a quoter to a quoted point, we get
δA ◦ Qa ◦ m0 ∼ Q2 a ◦ δ1 ◦ m0 ∼ Q2 a ◦ Qm0 ◦ m0 ∼ Q(Qa ◦ m0 ) ◦ m0
So a quoter maps a quoted point to its doubly quoted version. In this instance, the
diagram that would correspond to the transformation being monoidal is crucial in
obtaining this pattern.
All of these ingredients then combine to form a comonadic exposure.
5

Nevertheless, notice that—since we are in a cartesian setting and 1 is a terminal object—the
second diagram commutes automatically.

85

Definition 32. A comonadic exposure (Q, , δ) consists of an endoexposure
Q : (B, ∼) # (B, ∼),
•

•

along with an evaluator  : Q # IdB , and a quoter δ : Q # Q2 , such that the following
diagrams commute up to ∼:
QA

δA

Q2 A
δQA

δA

Q2 A

QδA

δA

QA
δA

Q3 A

idQA

Q2 A

QA

Q2 A
QA

QA

Comonadic exposures are the analogue of product-preserving (= strong monoidal)
comonads in the categorical semantics of S4. They will prove instrumental in our
analysis of intensional recursion (§6), and in the semantics of iPCF (§7, §8).

4.2.4

Idempotent Comonadic Exposures
•

If the components of δ : Q # Q2 are isomorphisms, we shall call the comonadic
exposure (Q, , δ) idempotent.
As we discussed before, if one is to take the interpretation of Q as ‘code’ seriously,
then there are clearly two ‘regions’ of data: that of static code, always found under
an occurrence of Q, and that of dynamic data. Intuitively, the notion of ‘code of code
of A,’ namely Q(QA), should be the same as ‘code of A.’ If something is code, it
is already intensional in a maximal sense: it can certainly be taken ‘one level up’
(Q(QA)), but that should not amount to very much.
We have seen that exposures are a very weak setting in calculational terms, as
they do not preserve equality. It is for this reason that we are forced to externally
impose equations, such as those for cartesian products in §4.2.2. However, we will
shortly see that the idempotence of a comonadic exposure is a particularly powerful
tool that immediately allows us to infer a lot about equality, especially intensional.
It follows, as in §4.1.1, that following diagram commutes for each f : QA → QB:
QA

f

δA

Q2 A

QB
δB

Qf

Q2 B

The proof is the same as before: nowhere in Theorem 26 did we use the ‘forbidden
principle’
f =g

=⇒ Qf = Qg
86

Furthermore, the argument we produced just before that theorem also still holds:
•

each component of δ : Q # Q2 is a ‘reasonable quoting device,’ in the sense that the
diagram
a

1

QA

m0

δA

Q1

Qa

Q2 A

commutes: the only time we used the ‘forbidden principle,’ namely the demonstration
that Qm0 ◦ Q(m−1
0 ) ∼ idQ1 , can be ‘simulated’ with idempotence as follows: we have
−1
Qm0 ◦ Q(m−1
0 ) ◦ δ1 ∼ δ1 ◦ m0 ◦ m0 ∼ δ1 ◦ idQ1 ∼ Q(idQ1 ) ◦ δ1

by using idempotence twice, so that cancelling the iso δQ1 then yields the result. We
will later see that this is due to a more general theorem.
So, even if this diagram commutes, where does the ‘degeneracy’ argument (Proposition 1) break down? The key lies precisely in the fact that Q does not respect the
PERs, and hence in : C(1, A) 99K C(1, QA) is now only an operation, not a P-function.
Hence, there is no natural isomorphism C(1, −) ∼
= C(1, Q−).
Let us, however, take a closer look: the function in is defined by
x:1→A

7−→

Qf ◦ m0 : 1 → QA

That is, the only occurrence of f is under Q, and the rest is simply pre-composition
with m0 . If f ≈Q f 0 , i.e. if Qf ∼ Qf 0 , then we have that in(f ) ∼ in(f 0 ). Hence, in
changes ≈Q to ∼, so it is actually more than an operation: it is a map
in : (C, ≈Q )(1, A) → (C, ∼)(1, QA)
Similarly, out is defined by
a : 1 → QA

7−→

A ◦ a : 1 → A

If a ∼ a0 , then δA ◦ a ∼ δA ◦ a0 , so Qa ◦ m0 ∼ Qa0 ◦ m0 . Cancelling the isomorphism
m0 gives us a ≈Q a0 . Thus, if we have a reasonable quoting device at A, QA is
point-univalent. For the time being, notice that this means that out takes ∼ to ≈Q ,
i.e. it is a map
out : (C, ∼)(1, QA) → (C, ≈Q )(1, A)
If we combine these facts with the previous calculations and naturality of Q, we obtain
a natural isomorphism
87

Proposition 6. (C, ≈Q )(1, −) ∼
= (C, ∼)(1, Q−)
That is: the intensional structure of the points, now visible in the x-ray category
(C, ≈Q ), is represented by the points 1 → QA under extensional equality.
In the rest of this section let us fix a product-preserving idempotent comonadic
exposure (Q, , δ) on B.
Equal Intensional Transformations are Intensionally Equal
A central result is the generalisation of the argument we used to define out, and it
is the following. Think of arrows f : QA → QB as intensional operations: these
transform code of type A to code of type B. It therefore should transpire that, if
f ∼ g : QA → QB, then f and g represent the same code transformation, and in fact
should be intensionally equal. If Q is idempotent, then this is exactly what happens.
Theorem 28. For any f, g : QA → QB,
f ∼g

=⇒

f ≈Q g

Proof. We have
Qf ◦ δA ∼ δB ◦ f ∼ δB ◦ g ∼ Qg ◦ δA
Pre-composing with the inverse of δA yields Qf ∼ Qg, and hence f ≈Q g.
Idempotence also implies another crucial piece of information regarding the product∼
=

preserving isomorphism mA,B : QA × QB −
→ Q(A × B). Even though we know mA,B
is an isomorphism up to ∼, we ostensibly do not have any information on its behaviour up to ≈Q : the hom-operations of Q do not preserve the PERs. However, in
the idempotent setting it always iso, even up to ≈Q .
∼
=

Lemma 13. mA,B : QA × QB −
→ Q(A × B) is an isomorphism up to ≈Q , i.e. it is
an isomorphism in the x-ray category (B, ≈Q ).

88

Proof. Calculate that
Qm ◦ QhQπ1 , Qπ2 i ◦ δ
∼ { Proposition 2 }
Qm ◦ m ◦ hQ2 π1 , Q2 π2 i ◦ δ
∼ { naturality of product bracket, δ natural }
Qm ◦ m ◦ hδ ◦ Qπ1 , δ ◦ Qπ2 i
∼ { product equation }
Qm ◦ m ◦ (δ × δ) ◦ hQπ1 , Qπ2 i
∼ { δ monoidal }
δ ◦ m ◦ hQπ1 , Qπ2 i
def

∼ { m−1 = hQπ1 , Qπ2 i }
δ
Since δ is an isomorphism, we can cancel it on both sides to yield m ◦ m−1 ≈Q id. The
calculation is similar in the opposite direction, and relies on post-composing with the
isomorphism m ◦ (δ × δ), and then cancelling it.
The same trick with m ◦ (δ × δ) also shows that Proposition 4 holds intensionally.
Lemma 14. QπiA,B ◦ mA,B ≈Q πiQA,QB .
These lemmas show that
Corollary 3. For any f, g :

Qn

i=1 QAi →

f ∼g

Qm

j=1

QBj ,

f ≈Q g

=⇒

Proof. Pre-and-post-compose with the appropriate isomorphisms m(n) (see §7.1), use
Theorem 28, and then use Lemma 13 to cancel the m(n) ’s.
Some more lemmas
In this section we prove some more lemmas that hold in the idempotent case. Firstly,
we can show that the comonadic diagrams commute intensionally.
Lemma 15. The comonadic diagrams
QA

δA

QδA

δA

QA

δQA

δA

Q2 A

Q2 A

δA

Q3 A

idQA

Q2 A
89

QA

Q2 AT
QA

QA

commute up to ≈Q .
Proof. Simple calculations that mainly follow by pre-composing δA and then cancelling it. For example,
Q2 A ◦ QδA ◦ δA ∼ Q2 A ◦ δQA ◦ δA ∼ δA ◦ QA ◦ δA ∼ δA
by the equations and the naturality of δ, which gives that QA ◦ δA ≈Q idQA .
Moreover, we have that
Lemma 16. A : QA → A is epic up to ≈Q .
Proof. If f ◦ A ≈Q g ◦ A : QA → B, then Qf ◦ QA ∼ Qg ◦ QA . Pre-composing δA
yields f ≈Q g.
The following lemma is also quite useful.
Lemma 17 (Quotation-Evaluation). For any f : QB → QA, the following diagram
commutes up to ∼:
δB

QB

Q2 B
Qf

f

QA

QA

Q2 A

Proof. We may calculate
QA ◦ Qf ◦ δB ∼ QA ◦ δA ◦ f ∼ f
by idempotence and the comonadic equations.
This has a simple corollary when it comes to quoted points:
Corollary 4. If (Q, δ, ) is a product-preserving idempotent comonadic exposure, then
Q(A ◦ a) ◦ m0 ∼ a
for any a : 1 → QA.
Proof. We may calculate
Q ◦ Qa ◦ m0 ∼ Q ◦ δA ◦ a ∼ a
by δ being reasonable and Q comonadic.
90

Coalgebras, Idempotence, and Univalence
Recall the definition of point-univalent objects (Definition 26): U is point-univalent if
x ∼ y : 1 → U implies x ≈Q y : 1 → U . Intuitively, U is point-univalent if extensional
and intensional equality coincide for its points, i.e. if none of them contain intensional
information. Now, the objects QA are supposed to contain intensions/codes corresponding to the ‘elements’ of A. It is no surprise then that we can prove that
Lemma 18. QA is point-univalent.
Proof. Suppose x ∼ y : 1 → QA. Then x ◦ 1 ∼ y ◦ 1 : Q1 → QA. Invoking Theorem
28 yields x ◦ 1 ≈Q y ◦ 1 . If only we establish that 1 ◦ m0 ≈Q id1 , then it would
suffice to pre-compose m0 . But Q is product-preserving, hence cartesian, with the
result that
1 ◦ m0 ≈Q !1 ≈Q id1

In fact, this is a special case of a more general
def

Theorem 29. Let Q = { QA | A ∈ B }. Then QA is Q-univalent.
This is just another way to state Theorem 28.
We would like to prove a kind of converse to this theorem, viz. that, with idempotence, every Q-univalent object A is closely related to QA. Unfortunately, there
is no systematic way to obtain an arrow A → QA from the Q-univalence of A. But
if we assume the existence of such an arrow—with appropriate equations—then it is
easy to show that it is an isomorphism. This arrow is, of course, an old friend:
Definition 33. A Q-coalgebra is an arrow
α : A → QA
such that the following diagrams commute up to ∼:
A

α

idA

A

QA
A

A

α

α

QA

91

QA
δA

Qα

Q2 A

In the modality-as-intension interpretation a Q-coalgebra has an intuitive meaning: the equation A ◦ α ∼ id states that α can ‘quote’ the elements of A, producing
an element of QA which—when evaluated—takes us back to where we started. The
•
second equation merely states that α cooperates well with the quoter δ : Q # Q2 .
Thus, a Q-coalgebra exists when we can internally quote the elements of an object.
Lemma 19. If A is Q-univalent, then a Q-coalgebra α : A → QA is an isomorphism,
with inverse A : QA → A.
Proof. This is the classic proof that given idempotence all coalgebras are isomorphisms. However, a crucial step of that proof would rely on Q preserving equality; in
this case, this is where Q-univalence steps in.
We calculate that
δA ◦ (α ◦ A ) ∼ Q(α ◦ A ) ◦ δA ∼ Qα ◦ QA ◦ δA ∼ Qα
by idempotence and the comonadic equations. If we post-compose QA to both sides
of this equation, we obtain
α ◦ A ∼ QA ◦ Qα ∼ Q(A ◦ α)
So, if we show that A ◦ α ≈Q idA , then we would obtain α ◦ A ∼ idQA . As we already
know that α ◦ A ∼ idQA , we would conclude that α−1 ∼ A . Since A ◦ α ∼ idA , we
obtain A ◦ α ◦ A ∼ A : QA → A. But A is Q-univalent, so
A ◦ α ◦ A ≈Q A
But A is epic up to ≈Q (Lemma 16), so A ◦ α ≈Q idA .
So, when is A univalent? Suppose that A ◦ α ≈Q idA , i.e. quoting and then
evaluating returns the same intensional construction with which one began. Then it
must be that A has no real intensional structure, and conversely.
Lemma 20. Let α : A → QA be a Q-coalgebra. Then A is Q-univalent if and only
if A ◦ α ≈Q idA .
Proof. The ‘only if’ part was shown in the preceding proof. As for the ‘if’ part, let
f ∼ g : QB → A. Then α ◦ f ∼ α ◦ g : QB → QA. By Theorem 29/28, α ◦ f ≈Q α ◦ g.
Post-composing with A and using the assumption gives f ≈Q g.
To sum, we can combine these facts to show the following
92

Theorem 30. If there is a Q-coalgebra α : A → QA such that A ◦ α ≈Q idA , then
∼
=

α:A−
→ QA is an isomorphism.
There is a partial converse, which is that
∼
=

Theorem 31. If Q is idempotent and there is an isomorphism α : A −
→ QA such
that δA ◦ α ∼ Qα ◦ α, then α : A → QA is a Q-coalgebra, with A ◦ α ≈Q idA .
Proof. We compute that
α ∼ QA ◦ δA ◦ α ∼ QA ◦ Qα ◦ α
by the comonadic equations and the assumption. Cancelling α yields A ◦ α ≈Q id,
and hence α is a Q-coalgebra.
Thus, either of the following data suffice to make A Q-univalent:
∼
=

1. an isomorphism A −
→ QA with the second Q-coalgebra equation; or
2. a Q-coalgebra with the first equation holding intensionally.

4.2.5

Weakly Cartesian Closed Exposures

We close this section with a notion of cartesian closure for exposures. Unlike the
situation with products, the relevant notion that will allow calculations under the
exposure will be weak. We pick the weak notion because our motivating example
of an exposure (see §5.2) is a weakly cartesian closed one. Whereas there is a good
argument for an exposure to distribute over products—i.e. products do not contain
any true intensional nature, they are simply pairs—exposures truly reveal the internal
structure of morphisms: it makes sense that η does not hold, cf. the age-old discussion
of the ordinary λ-theory λβ and the extensional theory λβη in e.g. Barendregt [1984].
Definition 34. A product-preserving exposure Q : B → C from a P-ccc B to a
cartesian P-category C is weakly cartesian closed just if
ev ◦ (λ(f ) × id) ≈Q f
for all f : C × X → Y .
These work as expected. For example, if for f : A → B we let


f
π2
def
pf q = λ 1 × A −→ A →
− B
as before, then
93

Lemma 21. For any a : C → A,
ev ◦ hpf q, ai ≈Q f ◦ a
Proof. All the necessary equations hold intensionally:
ev ◦ hpf q, ai ≈Q ev ◦ (pf q × id) ◦ hidC , ai ≈Q f ◦ π2 ◦ hidC , ai ≈Q f ◦ a

94

Chapter 5
Three Examples of Exposures1
Having introduced the basics of P-categories and exposures in the previous chapter, we
now seek to prove that they are indeed useful abstractions in the study of intensional
phenomena. Towards this goal, we shall present three examples of a P-category and
an endoexposure on it.
In §5.1 we will construct a P-category based on a first-order classical theory. In the
particular case of Peano Arithmetic (PA), it will become apparent that a well-behaved
Gödel numbering comprises an endoexposure.
Following that, in §5.2 we turn to realizability theory in order to obtain a handle on
intensionality in settings related to higher-order computability theory. The example
of a comonadic exposure constructed therein is particularly well-behaved, and is the
motivating example for the entire development of this thesis.
The third example is, we hope, somehow unfamiliar. Prompted by Abramsky
[2014], a natural question arises: is the phenomenon of intensionality only relevant
to logic and computation? We are prepared to entertain the idea that it may be a
more general mathematical pattern, which has hitherto been either a nuisance or—
more often—invisible, and whose categorical formulation will enable us to recognise
it in more settings. In §5.3, we present a simple example of intensionality found in
homological algebra, and submit it to the reader for further discussion.

5.1

Exposures as Gödel Numbering

Our first example of an exposure substantiates the claim that exposures can be considered as abstract analogues of Gödel numberings.
1

A preliminary form of the results in this chapter was first published as [Kavvos, 2017a], which
is available at Springer: https://dx.doi.org/10.1007/978-3-662-54458-7_32

95

Following Lawvere [1969, 2006], we will construct a P-category from a first-order
theory T. Then, we will sketch the proof that any sufficiently well-behaved Gödel
numbering defines an exposure over this theory. We omit the details, leaving them
as a (probably rather complicated) exercise in coding.

5.1.1

The Lindenbaum P-category

The construction in this section is called the Lindenbaum P-category of a first-order
theory T, and it is simpler than what one might imagine: we begin with three basic
objects,
1,

the terminal object

2,

the object of truth values

A,

the universe

The objects of the category will be the formal products of these three objects; we
write Γ for a generic product A1 , . . . , An of these objects. The arrows of type
Γ→2
will be construed as formulas, with free variables in Γ. Similarly, the arrows
Γ→A
will be construed as terms, once again with free variables in Γ. In this light, a formula
φ(x, y, z) in three free variables will be an arrow
φ(x, y, z) : A × A × A → A
with the three copies of A in the domain representing each free variable in a fixed
order—and similarly for terms.
However, this idea will be complicated by the presence of 2 in the domain. This
will represent a Boolean hole that may be filled by a formula. For example, consider
the expression
def

φ(x, P ) = ∀y. ∃z. (f (x, y) = z ∧ P )
is a formula with one free variable x, and one Boolean hole P , for which a formula
can be substituted. Hence, it will be an arrow
φ(x, P ) : A × 2 → 2
96

This is a generalisation that Lawvere introduced, and of which we shall be making
use. The interesting thing about it is that the Boolean connectives now appear as
arrows, e.g. ∧ : 2 × 2 → 2, and ¬ : 2 → 2. Of course, arrows Γ → A with 2 occurring
in Γ do not make particularly good sense: how could one have a Boolean hole in a
term?
Finally, we have the cases of 1 and products appearing in the codomain. In
the first case, there will be a unique arrow !Γ : Γ → 1. In the case of a product
def
∆ = B1 × · · · × Bn , arrows f : Γ → ∆ will be freely generated by brackets, i.e. they
will be
hf1 , . . . , fn i : Γ → ∆
where fi : Γ → Bi . Almost everything in sight will act component-wise on these.
We shall say that
f ∼ g : Γ → 2 just if T ` f ↔ g
That is, two arrows that are predicates are extensionally equal if and only if they can
be proven equivalent in the theory. The details are slightly more complicated than
in most presentations of first-order logic, since we also have to treat Boolean holes.
Similarly, two terms are extensionally equal if they can be proven equal in the theory,
i.e.
t ∼ s : Γ → A just if T ` t = s
On brackets, ∼ acts component-wise.
It is not hard to see that we obtain the following theorem, which—excluding the
P-categorical twist—is essentially due to Lawvere.
Theorem 32. The above construction is a cartesian P-category, called the Lindenbaum P-category Lind(T) of the first-order theory T.

5.1.2

Numbering as Exposure

Let us now concentrate on the case of Peano Arithmetic, which we denote by PA. A
Gödel numbering [Boolos, 1994, Smullyan, 1992] is obtained when one assigns to each
−
−
formula φ(→
x ) and each term t(→
x ) a Gödel number, denoted by
−
pφ(→
x )q,

−
pt(→
x )q

respectively. In the case of a first-order theory of arithmetic, the Gödel number of a
term or formula is supposed to represent the term or formula within the theory.
97

The notion of representation-within-the-theory is exactly what exposures are meant
to capture. Hence, we need to define the action of an exposure,
Q : Lind(PA) # Lind(PA)
on the Lindenbaum P-category of PA. This is where we need that the Gödel numbering
be well-behaved. Let us suppose that we have a formula φ(x, y) : A × A → A in two
free variables. We would like to map this to a formula Qφ(x, y), also in two free
variables, that respects substitution. Let us presume that we have functions
subwff,n (x, z1 , . . . , zn )
subt,n (x, z1 , . . . , zn )
that are definable in PA by a term (denoted by the same name), and moreover that
these functions define substitution for the Gödel numbering, in the sense that, for
example, if given—say—two closed terms t, s, we have
PA ` subwff,2 (pφ(x, y)q, ptq, psq) = pφ(t, s)q
We require more than most presentations of Gödel numberings. In particular, we
require that these behave well under substitution, e.g. we require that the terms
−
−
−
−
subwff,2 (pφ(x, y)q, subt,n (pt(→
z )q, →
w ), subt,n (ps(→
z )q, →
w ))
and
−
−
−
subwff,n (pφ (t(→
z ), s(→
z ))q, →
w)
be provably equal in PA. We can then define
def

Qφ(x, y) = subwff,2 (pφ(x, y)q, x, y)
Finally, in the case of a sentence ψ : 1 → 2, i.e. a closed formula, we shall define
Qψ : 1 → A to simply be the (numeral of the) Gödel number, i.e.
def

Qψ = pψq
This certainly respects substitution! We have elided the concept of Boolean holes,
but we believe that to be a not so difficult exercise. Identities are a little stranger;
the identity at A is the term that is a single free variable, i.e.
def

idA = x : A → A
98

and this is mapped to subt,1 (pxq, x) : A → A, which somehow needs to be provably
equal to x itself. This is a also strange requirement for a Gödel numbering, but we
are mostly willing to believe that it is a feasible desideratum. A similar situation
occurs when we examine the arrow
hQπ1 , Qπ2 i = hsubt,2 (pxq, x, y), subt,2 (pyq, x, y)i
For the exposure Q to be product-preserving, we would like this to be an isomorphism,
or—even better—the identity. And it would indeed be, if we could prove that, in
general,
−
PA ` subt,n (pzi q, →
z ) = zi
More rigorously, we define
def

Q1 = 1
def

Q(A) = A
def

Q(2) = A
def

Q(B1 × · · · × Bn ) = QB1 × · · · × QBn
def

and, of course, Qhf1 , . . . , fn i = hQf1 , . . . , Qfn i.
To complete the construction, we have to check the last axiom of exposures,
namely reflection of PERs. For that we need that
−
−
−
−
PA ` subwff,n (pφ(→
x )q, →
z ) = subwff,n (pψ(→
x )q, →
z)
implies
PA ` φ ↔ ψ
−
By substituting the Gödel numbers of variables →
y in the antecedent, we obtain that
−
−
PA ` pφ(→
y )q = pψ(→
y )q
and so it suffices for the Gödel numbering to be injective, in the sense that
−
−
pφ(→
y )q = pψ(→
y )q

=⇒

−
−
φ(→
y ) = ψ(→
y)

viz. that equality of Gödel numbers implies syntactic equality. In conclusion,
Theorem 33. If all of the above desiderata on Gödel numberings are feasiable, then
the construction is a product-preserving endoexposure,
Q : Lind(PA) # Lind(PA)
on the Lindenbaum P-category of PA.
99

5.2

Exposures in Realizability

In this section we study our central example of an exposure, which hails from realizability theory.
The basic objects in realizability are assemblies, i.e. sets of which every element
is associated with a set of realizers. The elements of the set can be thought of as the
elements of an abstract datatype, whereas the set of realizers of each element contains
its multiple machine-level representations. For example, realizers can range over the
natural numbers; then taking functions between assemblies which can be ‘tracked’ on
the level of realizers by partial recursive functions yields a category where ‘everything
is computable.’
In practice, the generalisation from natural numbers to an arbitrary partial combinatory algebra (PCA) is made. A PCA is an untyped ‘universe’ corresponding to
some notion of computability or realizability. There are easy tricks with which one
may encode various common first-order datatypes (such as booleans, integers, etc.) in
a PCA.2 Moreover, it is easy to show that, up to a simple representation of integers,
one may represent all partial recursive functions in a PCA. Before proceeding with
the construction, we recap in §5.2.1 the basics of PCAs. For the interested reader let
us mention that detailed discussions may be found in [Beeson, 1985, Longley, 1995,
Longley and Simpson, 1997, van Oosten, 2008, Longley and Normann, 2015].
Once a PCA—and hence a notion of computability—is fixed, defining a P-category
Asm(A) is reasonably straightforward: objects are assemblies, and morphisms are
functions which are ‘computable’ on the level of realizers. The arrows are pairs (f, r)
where f is a function on the underlying set of each assembly, and r is an element of
the PCA that tracks the function f . Two arrows are related if and only if they define
the same function on the underlying sets. Finally, to define an endoexposure all we
need to do is display the effect of each tracking element r on the realizers. It then
transpires that this exposure is a product-preserving idempotent comonadic exposure
on Asm(A).

5.2.1

Partial Combinatory Algebras

The definition of a PCA is deceptively simple:
2

Most of these tricks have their origins in untyped λ-calculus, and are hence found in Barendregt
[1984].

100

Definition 35. A partial combinatory algebra (PCA) (A, ·) consists of a carrier set
A and a partial binary operation · : A × A * A such that there exist K, S ∈ A with
the properties that
K · x ↓,

K · x · y ' y,

S · x · y ↓,

S · x · y · z ' x · z · (y · z)

for all x, y, z ∈ A.
The paradigmatic example comes from ordinary computability theory, as presented
by e.g. Cutland [1980], Odifreddi [1992], Rogers [1987]. It is not very difficult to use
the s-m-n theorem to cook up indices that behave like S and K, to the effect that
Theorem 34 (Kleene’s First Model). The applicative structure K1 = (N, · ), where
x · y ' φx (y)
is a partial combinatory algebra.
Combinatory Completeness
Even though the definition of a PCA is remarkably simple, there is more to it than
meets the eye. The structure of S and K suffice to obtain a property known as
combinatory completeness: every syntactic function on the PCA formed by variables,
applications and constants can be ‘internalised’ as an element of the PCA. This
results originates from combinatory logic, and is well-known in the study of untyped
λ-calculus—see Barendregt [1984].
Once combinatory completeness is obtained, standard tricks from untyped λcalculus can be used to represent first-order data, but also greatly simplify calculations. Nevertheless, let us remind the reader that not all the common rules of the
untyped λ-calculus hold in a PCA, so caution is advised. The particular presentation
in this section is due to Longley [1995].
Definition 36. Let V be an infinite set of variables. The set E(A) of terms or formal
expressions over a PCA (A, ·) is defined as the least set that satisfies the following
conditions:
A ⊆ E(A),

V ⊆ E(A),

s ∈ E(A) t ∈ E(A)
(s · t) ∈ E(A)

Conventionally, we will use e, s, t, u, v, . . . as metavariables ranging over E(A), and
we will write s[t/x] for the formal expression obtained by substituting t ∈ E(A) for
every occurrence of the variable x in the formal expression s ∈ E(A).
101

A formal expression is closed if it contains no variables. Write fv (e) for the set
of free variables of expression e ∈ E(A). Also, write e ↓ (“e denotes”), where e is a
closed formal expression, to mean that that, if the formal expression is interpreted as
an actual algebraic expression in the standard way, composition throughout is defined
and it denotes an element. This implies that all subexpressions also denote: if s · t ↓,
then s ↓ and t ↓. Otherwise, we write e ↑ to mean that partiality kicks in, and the
expression does not denote an element in the PCA.
We also notationally distinguish two equalities: the strict equality, s = t, where
both s ↓ and t ↓ and they denote the same element; and the Kleene equality, s ' t,
which holds when s and t are both undefined, or both defined and denote the same
element.
Finally, the above notions are straightforwardly extended to open terms, by substituting for all variables: let the variables of s, t ∈ E(A) be amongst x1 , . . . , xn ; then,
for example
e↓

just if ∀a1 , . . . , an ∈ A. e[~a/~x] ↓

s't

just if ∀a1 , . . . , an ∈ A. s[~a/~x] ' t[~a/~x]

for the obvious generalisation to simultaneous substitution. We can now λ-abstract:
Theorem 35 (Combinatory Completeness). Let (A, ·) be a PCA. For any e ∈ E(A),
there exists a formal expression λ∗ x.e ∈ E(A), where fv (λ∗ x.e) = fv (e) − {x}, such
that
λ∗ x.e ↓
and
(λ∗ x.e)a ' e[a/x]
for all a ∈ A.
Proof. Define
λ∗ x. x = S · K · K
def

λ∗ x. t = K · t
def

if t ∈ A ∪ V and t 6≡ x

λ∗ x. s · t = S · (λ∗ x.s) · (λ∗ x.t)
def

Then λ∗ x.e ↓ by the definedness conditions for S and K. The rest follows by induction.

102

Let us be pedantic and reiterate the warnings: Kleene equality is not respected
by the λ∗ x operation on terms, and the obvious β-rules do not hold—observe that
the operand above has to be a constant! Longley carefully develops correct β-rules
for this language of terms in [Longley, 1995, §1.1.2].
Some common encodings
We will need the following combinators:
def

I = SKK
B = λ∗ f.λ∗ g.λ∗ x.f (gx)
def

It is easy to define selection and pairs. Let
true = λ∗ ab.a
def

false = λ∗ ab.b
def

if = λ∗ xyz.xyz
def

pair = λ∗ xyz.zxy
def

fst = λ∗ p.p(true)
def

snd = λ∗ p.p(false)
def

We always have if x y ↓, and pair x y ↓. Furthermore, the following equalities hold:
fst (pair x y) = x
snd (pair x y) = y
if true y z = y
if false y z = z
Encoding numbers is not more difficult, and—like [Longley, 1995] and [Longley and
Simpson, 1997]—we use a trick due to Curry. Let
0=I
n + 1 = pair false n
def

Then we may let succ = λ∗ x. pair false x, so that succ n = n + 1. To check if a number
def
is zero, use iszero = fst so that
iszero 0 = I (true) = true

103

whereas
iszero n + 1 = fst (pair false n) = false
Finally, we can define the predecessor function by
pred = λ∗ x. if (iszero x) 0 (snd x)
def

5.2.2

Assemblies and Modest Sets

Definition 37. An assembly X on A consists of a set |X| and for each x ∈ |X| a
non-empty subset kxkX ⊆ A. If a ∈ kxkX , we say that a realizes x.
Definition 38. For two assemblies X and Y , a function f : |X| → |Y | is said to be
tracked by r ∈ A just if, for all x ∈ |X| and a ∈ kxkX , we have
r·a↓

and r · a ∈ kf (x)kY

Definition 39. An assembly X on A is a modest set just if no element of A realizes
two elements of |X|. That is,
x 6= x0

=⇒

kxkX ∩ kx0 kX = ∅

It is not hard to see that for each PCA A we can define a category Asm(A), with
objects all assemblies X on A, and morphisms f : X → Y being functions f : |X| →
|Y | that are tracked by some r ∈ A. In fact,
Theorem 36. Assemblies and trackable morphisms between them form a category
Asm(A) that is cartesian closed, has coproducts, as well as a natural numbers object.
It is not clear who originated the—admittedly very intuitive—definition of Asm(A),
and who first proved the above theorem. The identification of assemblies as the ¬¬separated objects of the effective topos can be found in the work of Hyland [1982].
Longo and Moggi [1991] refer to Asm(A) as the category of ω-sets, and so does Jacobs
[1999]. For more details, see [Longley, 1995] or [Longley and Simpson, 1997].
A special subcategory of assemblies is of particular interest:
Theorem 37. The full subcategory of Asm(A) consisting only of objects which are
modest sets, which we denote by Mod(A), inherits the cartesian closed, coproduct,
and natural number object structure from the category of assemblies.
The category of modest sets—or its equivalent presentation in terms of PERs on the
PCA A—seems to have originated in unpublished work by Turing, and later used by
Gandy [1956, 1959]: see [Hyland, 2016]. In semantics, PERs were used independently
by Scott [1976] and Girard [1972]. Accessible presentations may be found in Mitchell
[1996] or Crole [1993].
104

5.2.3

Passing to a P-category

The lack of intensionality in the category Asm(A) is blatant: to elevate a function
f : |X| → |Y | to a morphism f : X → Y , we only require that there exists a r ∈ A
that tracks it: as soon as this is witnessed, we throw away the witness. For all the
reasons discussed in §4.1 we have to move to P-categories to mend this.
The P-category of assemblies on A, denoted Asm(A), is defined as follows. Its
objects are once more all assemblies X on A. Given assemblies X and Y , the P-set
Asm(X, Y ) is defined by having underlying set
def

|Asm(X, Y )| = { (f : |X| → |Y | , r ∈ A) | r tracks f }
and
(f, r) ∼Asm(X,Y ) (g, s) just if f = g
For (f, r) : X → Y and (g, s) : Y → Z, we define composition by
def

(g, s) ◦ (f, r) = (g ◦ f, B · s · r)
Notice that for any x ∈ |X|, a ∈ kxkX implies p · a ∈ kf (x)kY , which implies
q · (p · a) ∈ kg(f (x))kZ , and as B · q · p · a ' q · (p · a) it follows that (g ◦ f, B · p · q)
is an arrow X → Z. It is easy to see that composition is a P-function: ∼ only refers
to the underlying ‘extensional’ functions. Composition of set-theoretic functions is
associative and the identity function is its unit. That said, we define the identity
idX : X → X to simply be (id|X| , I).
Finite Products
It is not hard to show that
Proposition 7. The category Asm(A) has binary products.
Proof. The construction essentially follows the underlying structure of products in
the category of sets, but augments it with tracking elements. For assemblies X and
Y , we define
def

def

|X × Y | = |X| × |Y | ,

k(x, y)kX×Y = { pair a b | a ∈ kxkX , b ∈ kykY }

The projections are the following arrows:
def

π1 = (π1 : |X| × |Y | → |X| , fst)
def

π2 = (π2 : |X| × |Y | → |Y | , snd)
105

Define the P-function h−, −i by
h(f, r), (g, s)i = (hf, gi, λ∗ c. pair (r c) (s c))
def

It is easy to see that this is a P-function. We compute that
π1 ◦ h(f, r), (g, s)i = (π1 ◦ f, B · fst · (λ∗ c. pair (r c) (s c))) ∼ (f, r)
def

and similarly for the other two equations.
Proposition 8. The P-category Asm(A) has a terminal object.
Proof. Define 1 ∈ Asm(A) by
def

def

|1| = {∗},

k∗k1 = {0}

def

and, for A ∈ Asm(A), let !A = (a 7→ ∗, K · 0) : A → 1, which is unique (up to ∼).
Hence,
Theorem 38. Asm(A) has finite products.
Exponentials
Given assemblies X and Y , we define
def

Y X = { f | (f, r) : X → Y } ,

def

kf kY X = { r | r tracks f }

Let
evX,Y = ((f, x) 7→ f (x), λ∗ p. (fst p) (snd p)) : Y X × X → Y
def

Define a P-function
λC : Asm(A)(C × X, Y ) → Asm(A)(C, Y X )
by
(f, r) 7→ (z 7→ (x 7→ f (z, x)), λ∗ c. λ∗ a. r(pair c a))
It is again easy to see that this is a P-function, and one can verify that this is the
exponential. Therefore,
Theorem 39. Asm(A) is cartesian closed.

106

The Lifted Assembly for K1
We only mention one other indispensable construction, which embodies partiality in
the computable setting of assemblies on K1 . Given an assembly X ∈ Asm(K1 ), the
lifted assembly X⊥ is defined to be
def

|X⊥ | = |X| + {⊥},

kxkX⊥

(
r r · 0 ↓ and r · 0 ∈ kxkX
= 
r r·0↑

def

for x ∈ |X|
for x = ⊥

for some chosen element of the PCA 0. Elements of X⊥ are either elements of X, or
the undefined value ⊥. Realizers of x ∈ |X| are ‘computations’ r ∈ A which, when
run (i.e. given the dummy value 0 as argument) return a realizer of x. A computation
that does not halt when run represents the undefined value.
Bear in mind that this definition of the lifted assembly is only useful in K1 . In
particular, it does not work at all if the PCA is total. There are other, more involved
ways of defining the lifted assembly: see Longley and Simpson [1997] for a rather
elegant and uniform method.

5.2.4

The Exposure

Theorem 40. There is an exposure
 : Asm(A) # Asm(A)
for any PCA A.
Proof. For an assembly X ∈ Asm(A), let X be the assembly defined by
def

|X| = { (x, a) | x ∈ |X| , a ∈ kxkX }
def

k(x, a)kX = { a }
Given (f, r) : X → Y , we define (f, r) = (fr , r) : X → Y where
fr : |X| −→ |Y |
(x, a) 7−→ (f (x), r · a)
Each element (x, a) ∈ |X| has a unique realizer, a. As a ∈ kxkX , and f is tracked
by r, we see that r · a ↓ and r · a ∈ kf (x)kY , so that (f (x), r · a) ∈ |Y |. It follows
that r tracks fr , and so (fr , r) is an arrow X → Y .

107

To prove that  preserves composites, observe that for arrows (f, r) : A → B and
(g, s) : B → C, we have
fr

gs

(x, a) 7−→ (f (x), r · a) 7−→ (g(f (x)), s · (r · a))
and as B · s · r · a ' s · (r · a), we have
gs ◦ fr = (g ◦ f )B·s·r
which is of course tracked by B · s · r. Hence (g ◦ f ) ∼ g ◦ f . Regarding identities,
notice that if idX : X → X is the identity arrow, then
(idX )

I
(x, a) 7−−−→
(x, I · a)

and as I · a ' a, the latter is equal to (x, a), so (idX )I = id|X| . Hence idX ∼ idX .
Finally, we need to show that intensional equality implies extensional equality.
Suppose (f, r) ∼ (g, s). That is equivalent to fr = gs , which in turn gives us both
f = g and also r · a ' s · a for all a ∈ kxkX . The first implies (f, r) ∼ (g, s).
Intensional Equality
When showing that  is an exposure, we inadvertently characterised intensional
equality up to :
Lemma 22. (f, r) ≈ (g, s) : X → Y precisely when fr = gs , i.e.
f =g

and ∀x ∈ |X| . ∀a ∈ kxkX . r · a ' s · a

This is indeed the meaning we expected of intensional equality: (f, r) and (g, s) are
not only equal extensionally, but they also have the same effect on realizers. Notice
that, unless we are in a highly extensional environment (which not all PCAs are),
this is very far from strict equality. Instead, it is something in between.
We can also use this characterisation of intensional equality to speak about the realizer structure of assemblies, in particular by characterising which objects of Asm(A)
are univalent (recall Definition 26).
Definition 40. An assembly X has unique realizers just if kxkX is a singleton, for
each x ∈ |X|.
Lemma 23. The univalent objects of Asm(A) are precisely those which have unique
realizers.
108

Proof. Suppose X is univalent. To each realizer a ∈ kxkX , there corresponds an
arrow
x̂a = (∗ 7→ x, λ∗ c. a) : 1 → X
def

But if a, b ∈ kxkX , then x̂a ∼ x̂b , as they share the same function component (∗ 7→ x).
As X is univalent, it follows that x̂a ≈ x̂b , so
a ' (λ∗ c. a) · 0 ' (λ∗ c. b) · 0 ' b
Conversely, suppose X has unique realizers. For any two extensionally equal arrows (f, r), (f, s) : Y → X, it is not very hard to see that fr = fs : we have that
π1 (fr (y, b)) = f (y) = π1 (fs (y, b)) for any b ∈ kykY . Thus, as f (y) is uniquely realized
by only one a, their second components are equal too, and (f, r) ≈ (f, s).
 is cartesian
It so happens that projections behave nicely under exposures.
Theorem 41.  : Asm(A) # Asm(A) is a cartesian exposure.
Recall that π1 ◦ h(f, r), (g, s)i = (f, d), where
d = B · fst · (λ∗ c. pair (r c)(s c))
def

so that the function component of (π1 ◦ h(f, r), (g, s)i) is fd (z, c) = (f (z), d · c). We
compute that
d · c = B · fst · (λ∗ c. pair (r c)(s c)) · c = r · c
which is to say that fd = fr , and hence (π1 ◦ h(f, r), (g, s)i) ∼ (f, r). The calculation is similar for the other projection.
For the third equation, it is easy to calculate that, for any arrow h : C → X × Y ,
the function component of hπ1 ◦ (h, r), π2 ◦ (h, r)i is hs , where
s = λ∗ c. pair (B · fst · r · c) (B · snd · r · c)
We proceed by calculating that
s · c = pair (B · fst · r · c) (B · snd · r · c) = pair (fst (r · c)) (snd (r · c))
so that
hs (z, c) = (h(z), pair (fst (r · c)) (snd (r · c)))

109

The argument would now be complete were our pairing surjective, but this is not
so in general PCAs. However, we know that c ∈ kzkC for some z ∈ |C|, so r · c ∈
k(x, y)kX×Y with h(z) = (x, y). Hence,
r · c = pair a b
for some a ∈ kxkX and b ∈ kykY , and hence
s · c = pair a b
as well. It follows that hs = hr , where r was the original tracking element of (h, r).
We have finally obtained that
hπ1 ◦ (h, r), π2 ◦ (h, r)i ∼ (h, r)
The final thing to check is that any arrow into the terminal object 1 is intensionally
equal to the canonical one; this follows, as 1 has only one element with a unique
realizer.
 is weakly cartesian closed
It is also the case that  : Asm(A) # Asm(A) is weakly cartesian closed (§4.2.5), in
the sense that the equation
ev ◦ (λ(f, r) × idX ) ≈ (f, r)
holds for any (f, r) : C × X → Y . To prove this one needs another tiring but easy
calculation like the one showing that  is cartesian: it is of no interest, save another
use of the fact that it uses the trick that any z ∈ k(c, x)kC×X is always of the form
z = pair i j for i ∈ kckC and j ∈ kxkX .
Preservation of Products
Define
def

m0 = (∗ 7→ (∗, 0), I) : 1 → 1
which maps the unique element of 1 to the pair of itself and its unique realizer, and
is realized by the identity combinator. This is a P-isomorphism with inverse
def

!1 = ((∗, 0) 7→ ∗, I) : 1 → 1

110

def

Also, define mA,B : A × B → (A × B) by mA,B = (wA,B , I), where
wA,B : |A| × |B| −→ |(A × B)|
((x, a), (y, b)) 7−→ ((x, y), pair a b)
The only realizer for the pair ((x, a), (y, b)) is pair a b, so the identity combinator
tracks wA,B . Then hπ1 , π2 i : (A × B) → A × B is equal to (vA,B , I), where
vA,B : |(A × B)| −→ |A| × |B|
((x, y), r) 7−→ ((x, fst · r), (y, snd · r))
and, as before, it is easy to see that this is an inverse to mA,B , as r is necessarily of
the form pair a b. Hence,
Theorem 42. The exposure  : Asm(A) # Asm(A) is product-preserving.
Comonadicity and Idempotence
Proposition 9. There exists a natural transformation of exposures,
•

 :  # IdAsm(A)
Proof. Define X = (uX , I), where
uX : |X| → |X|
(x, a) 7−→ x
If b ∈ k(x, a)kX = {a}, then b = a and I · b ' b = a ∈ kxkX , so uX is indeed tracked
by I. To show naturality for (f, r) : X → Y , we chase around the diagram:
(x, a)

fr

(f (x), r · a)
uY

uX

x

f (x)

f

Hence uY ◦ fr = f ◦ uX , so the square commutes up to ∼. Bear in mind that the
tracking element along one composite is B · r · I, whereas along the other composite
it is B · I · r.
Let us now investigate the structure of 2 X, for any assembly X. For each
(x, a) ∈ |X|, we have that k(x, a)kX = {a}. Thus, we can infer that
2 X = { ((x, a), a) | a ∈ kxkX }
111

and that, for any (f, r) : X → Y ,
2 f : 2 X −→ 2 Y
((x, a), a) 7−→ ((f (x), r · a), r · a)
Proposition 10. There exists a natural transformation of exposures,
•

δ :  # 2
Proof. Define δX = (vX , I), where
vX : |X| −→ 2 X
(x, a) 7−→ ((x, a), a)
If a ∈ kxkX , then I · a ' a ∈ {a} = k((x, a), a)k2 X , so I indeed tracks vX . To show
naturality for a given arrow (f, r) : X → Y , we chase around the diagram:
fr

(x, a)

(f (x), r · a)

vX

vY

((x, a), a)

((f (x), r · a), r · a)

(fr )r

and so the diagram commutes up to ∼. Note that the tracking elements along the
composites are respectively B · I · r and B · r · I.
•

It is not difficult to see that the components of δ :  # 2 are actually isomorphisms.
Hence, putting everything together:
Theorem 43. (, , δ) is a product-preserving idempotent comonadic exposure.
Proof. It suffices to verify the coherence conditions. Regarding the first one:
vX

(x, a)

((x, a), a)
vX

vX

((x, a), a)

(vX )I

(((x, a), a), I · a) = (((x, a), a), a)

which commutes, since I · a ' a. Both the tracking elements along each composite
are B · I · I, so the diagram actually commutes on the nose. Regarding the second
one:
(x, a)

vX

((x, a), a)
uX

vX

((x, a), a)

(uX )I

(x, I · a) = (x, a)

which commutes, since I · a ' a. Once more, both tracking elements are B · I · I, so
commutation is again on the nose.
112

5.2.5

Weak Extensionality and Naturality

We have shown that nearly everything in sight behaves well, even with respect to
intensional equality ≈ : Proposition 5 necessitates that, when we have a productpreserving (and hence cartesian) exposure, the function
h·, ·i : Asm(A)(C, X) × Asm(C, Y ) → Asm(A)(C, X × Y )
that is implicated in the definition of products respects intensional equality ≈ . The
glaring exception, of course, is the cartesian closed structure: it is not necessarily
that
λC : Asm(A)(C × X, Y ) → Asm(A)(C, Y X )
preserves intensional equality.
However, it is interesting to investigate when this might happen. Let (f, r) ≈
(f, s) : C × X → Y be two intensionally equal morphisms; we have
∀d ∈ k(c, x)kC×X . r · d ' s · d

(5.1)

We can calculate that
λ(f, r) = (λ(f ), λ∗ c a. r(pair c a))
def

λ(f, s) = (λ(f ), λ∗ c a. s(pair c a))
def

Thus, to prove that λ(f, r) ≈Q λ(f, s), all we need to check is that
∀d ∈ kckC . λ∗ a. r(pair c a) ' λ∗ a. s(pair c a)
By (5.1), it is indeed the case that r(pair c a) ' s(pair c a), because the realizers
d ∈ k(c, x)kC×X are exactly of the right form. Nevertheless, we are not allowed to
use that equation under an occurrence of λ∗ ! The situation that allows this is the one
where the PCA A is weakly extensional.
Definition 41. A PCA (A, ·) is weakly extensional if it satisfies the rule
M 'N
λ∗ x. M ' λ∗ x. N
for any two expressions M, N and any variable x.

113

Weak extensionality, also known as rule (ξ), is a notorious thorn in the study of
the correspondence between combinatory logic and untyped λ-calculus. [Barendregt,
1984, §7.3.5(iii)] sets out a finite set of equational axioms (due to Curry) that suffice
to ensure it.
The original plan for this thesis was that Asm(K1 ) would be a model of Intensional PCF, and Löb’s rule would directly correspond to Kleene’s Second Recursion
Theorem. Unfortunately, K1 is very likely not weakly extensional. In §8 we will
develop a slight restriction on Intensional PCF, which will remove the requirement
that λ(−) preserve intensional equality, which is otherwise necessary.
Since we have come this far, let us also investigate the naturality of λ(−), i.e. the
equation
λ (f ◦ (g × id)) ≈ λ(f ) ◦ g
under intensional equality. Given (f, r) : C ×X → Y and (g, s) : C 0 → C, we compute
that
λ ((f, r) ◦ ((g, s) × id)) = (λ (f ◦ (g × id)) , λ∗ c0 a. (B · r · h) · (pair c0 a))
def

λ(f, r) ◦ (g, s) = (λ(f ) ◦ g, B · (λ∗ c0 a. r · (pair c0 a)) · s)
def

def

where h = λ∗ d. pair (B · s · fst · d) (B · I · snd · d). It would suffice to prove that these
two realizers, when applied to anything, would return the same c0 , namely
λ∗ . r · (pair (s · c0 ) a)
This is easy to check with weak extensionality, but it seems impossible to ensure
without it. Therefore, λ(−) is natural up to ≈ if A is weakly extensional.
Finally, let us seize the opportunity to mention that if A is extensional, in the
sense that the η-rule
λ∗ x. e x ' e
holds for any expression e ∈ E(A), then
ev ◦ ((f, r) ◦ id) ≈Q (f, r) : C → Y X
In that case we would say that  : Asm(A) # Asm(A) is cartesian closed.

114

5.3

Exposures in Homological Algebra

This section aims to support the claim that, even though inspired by logic and computability, exposures are to be found in other contexts as well. This lends credibility
to the idea that, even if within logic exposures are a sort of abstract yet well-behaved
Gödel numbering, the phenomenon of intensionality, as discussed in §1.1 is more
general, and can be found in other areas of mathematics.
We will draw our example from homological algebra. Homological algebra begins once we have chain complexes C(X), i.e. sequences of abelian groups Ci with
homomorphisms
∂n+1

∂n−1

∂

∂

∂

n
1
0
Cn−1 −−−→ . . . −
→
C1 −
→
C0
. . . −−−→ Cn −→

such that ∂d ◦ ∂n+1 = 0. One then forms the groups of boundaries and cycles, namely
def

Bn (X) = im(∂n+1 )

def

Zn (X) = ker(∂n )

The objects of study are then the homology groups Hn , defined by
def

Hn (X) = Zn (X)/Bn (X)
A natural question arises: what if we make it so we never actually have to take
quotients?

5.3.1

The P-category Grp

Instead of taking the quotient G/N of a group G by one of its normal subgroups N ,
we will instead merely keep the tuple
(G, N )
and work with it: we will consider this as G/N , even though the two components are
kept separately.
Often in homology one considers maps between homology groups, which are group
homomorphisms of type
f∗ : G1 /H1 → G2 /H2
Nevertheless, rarely does one work out G1 /H1 exactly before defining such a f∗ . More
commonly, one picks out a representative of the equivalence class, defines f on that,

115

and then proves that the outcome is invariant under the choice of representative. This
amounts to defining some f : G1 → G2 such that
f (H1 ) ⊆ H2
Thus, we pick the morphisms f : (G1 , H1 ) → (G2 , H2 ) to be exactly those homomorphisms. Each one of them induces a homomorphism f∗ : G1 /H1 → G2 /H2 as is
customary.
To prove that two such maps f∗ , g∗ : G1 /H1 → G2 /H2 are equal, it suffices to
prove that they are pointwise homologous, i.e. that that f − g takes values only in
H2 . This will be exactly our definition of extensional equality:
f ∼ g : (G1 , H1 ) → (G2 , H2 )

just if

im(f − g) ⊆ H2

A classic result of basic group theory, viz.
G1 /N1 × G2 /N2 ∼
= (G1 × G2 )/(N1 × N2 )
also implies that we can define
def

(G1 , N1 ) × (G2 , N2 ) = (G1 × G2 , N1 × N2 )
and use it to prove that
Theorem 44. The P-category Grp is cartesian.
We can now think of the n-th homology functor as taking values in this P-category,
or—even better—its subcategory Ab of abelian groups,
Hn : Top −→ Ab
X 7−→ (Zn (X), Bn (X))
f : X → Y 7−→ f# : (Zn (X), Bn (X)) → (Zn (Y ), Bn (Y ))

5.3.2

Intensionality and Homomorphisms

The point of not forcing f to be f∗ is that the action of f : (G1 , H1 ) → (G2 , H2 )
on each cycle of G1 is ‘visible,’ even if that cycle is a boundary. This is because
f : G1 → G2 is still an actual homomorphism, which only happens to ‘respect’ a
normal subgroup. The way we will define an exposure on this category is precisely
by ‘exposing’ the action of f on individual cycles, even if they are boundaries.

116

We shall then define an endoexposure,
C : Grp # Grp
by
def

C(G, H) = (G, {eG })
def

Cf = f : (G1 , {eG1 }) → (G2 , {eG2 })
It is not at all difficult to prove that this is indeed an exposure: it preserves
composition and identities, and indeed if Cf ∼ Cg then f and g are equal, so im(f −g)
is just the identity element.
In fact, this exposure has comonadic structure, which comes for free. For evaluators, we notice that (G,H) : C(G, H) → (G, H) is actually of type (G, {eG }) → (G, H),
so it suffices to take the identity, which—in this context—is a kind of quotient map.
Similarly, δ(G,H) : (G, {eG }) → (G, {eG }), so again it suffices to take the identity. It
is trivial that every single diagram in the definition of evaluator and quoter, as well
as that of comonadic exposure, commutes: all the arrows are identities.
Furthermore, it is not hard to see that C preserves products: the candidate isomorphisms
m : Q(G1 , H1 ) × Q(G2 , H2 ) → Q(G1 × G2 , H1 × H2 )
have the same source and target, namely (G1 × G2 , {(eG1 , eG2 )}), so it suffices to take
the identity.

117

Chapter 6
Intensional Recursion in
P-Categories1
Armed with the framework of exposures, we can now speak of both extensional and
intensional recursion in categorical terms.
The case of extensional fixed points (EFPs) was first treated by Lawvere [1969,
2006] in the late 1960s. However, we will argue that his notion of fixed point is far
too coarse for most applications in logic and computer science.
Instead, we will use exposures to replace that definition with one that captures
intensional recursion, namely that of intensional fixed points (IFPs) (§6.1). We begin
our investigation by showing that our framework allows for clear and concise formulations of the classic theorems of Gödel, Tarski, and Rice. The relevant arguments
are entirely algebraic, and it is very clear what logical devices or assumptions each
one requires. The conclusion to be drawn is that, despite their common use of IFPs,
these three arguments have a fundamentally different flavour. In (§6.2) we discuss
the relationship between IFPs and Löb’s rule in provability logic.
Then, in §6.3, we then ask the natural question: where do IFPs come from? We
recall in detail a theorem of Lawvere which guarantees the existence of EFPs under
certain assumptions. We use exposures to prove the Intensional Recursion Theorem,
a similar theorem that pertains to IFPs instead.
Finally, we examine the nature of both EFPs and IFPs in the three examples
that we presented at length in §5. In particular, when viewed through the lens of
the exposure on assemblies (§5.2), Lawvere’s theorem and our Intensional Recursion
Theorem are revealed to be categorical versions of the First and Second Recursion
Theorems of Kleene respectively, as discussed in §2.
1
A preliminary form of the results in this chapter was first published as [Kavvos, 2017a], which
is available at Springer: https://dx.doi.org/10.1007/978-3-662-54458-7_32

118

6.1

Extensional and Intensional Fixed Points

Lawvere [1969, 2006] famously proved a theorem which guarantees that, under certain
assumptions, which we discuss in §6.3, there exist fixed points of the following sort.
Definition 42. An extensional fixed point (EFP) of an arrow t : Y → Y is a point
y : 1 → Y such that
t◦y =y
If every arrow t : Y → Y has a EFP, then we say that Y has EFPs.
In Lawvere’s paper EFPs are a kind of fixed point that, for logical purposes,
oughtn’t exist. After constructing a category based on a logical theory (e.g. PA), in
a manner that we have quite closely followed in §5.1, he argues that there can be no
sat : A × A → 2
such that for every formula φ : A → 2 there is a point cφ : 1 → A such that
a

1
ha,cφ i

A
φ

A×A

sat

2

for every point a : 1 → A. In logical terms, this would amount to the existence of a
two-variable predicate sat(−, −), and a Gödel number pφq for each unary predicate
φ(x), such that
T ` sat(pφ(x)q, n) ↔ φ(n)
for each n. If such a predicate existed, then ‘satisfaction would be definable,’ and we
would obtain a EFP of the arrow 2 → 2 encoding the logical ‘not’ function. In logical
terms, we could obtain a closed formula ψ such that T ` ψ ↔ ¬ψ. This leads to a
categorical version of Tarski’s Undefinability Theorem: if ‘truth were definable,’ then
substitution would be too, and ¬ would have a fixed point.
Finally, Lawvere obtains a version of Gödel’s First Incompleteness Theorem as
follows: given an (external) relation between closed formulas and points, relating
closed formulas to their ‘Gödel number,’ if we assume that provability is ‘internally
decidable’ on these Gödel numbers, and if we assume that all ‘truth values’ are either
true or false, then truth would be definable, which—by the categorical version of
Tarski’s undefinability theorem—it is not.

119

We can already see that Lawvere’s notion of EFPs do not encompass fixed points
that ought to exist. For example, the diagonal lemma for Peano Arithmetic (henceforth PA) manufactures a closed formula fix(φ) for every formula φ(x), such that
PA ` fix(φ) ↔ φ(pfix(φ)q)
The formula fix(φ) occurs asymmetrically: on the left hand side of the bi-implication
it appears as a truth value, but on the right hand side it appears under a Gödel
numbering, i.e. an assignment p·q of a numeral to each term and formula of PA.
Taking our cue from the exposure on Peano arithmetic (§5.1), we can generalise this
idea to the following, which encompasses this kind of ‘asymmetric’ fixed point.
Definition 43. Let Q : B # B be a product-preserving endoexposure. An intensional fixed point (IFP) (w.r.t. to Q) of an arrow t : QA → A is a point a : 1 → A
such that the following diagram commutes up to ∼:
1

a

A

m0

t

Q1

Qa

QA

An object A has IFPs (w.r.t. Q) if every arrow t : QA → A has a IFP.
This makes intuitive sense: a : 1 → A is extensionally equal to t ‘evaluated’ at the
point Qa ◦ m0 : 1 → Qa, which is the ‘quoted’ version of a.

6.1.1

Consistency, Truth and Provability: Gödel and Tarski

We are now in a position to argue that the two well-known theorems that were
discussed by Lawvere can be reduced to very simple algebraic arguments involving
exposures. In fact, the gist of both arguments relies on the existence of IFPs for an
‘object of truth values’ in a P-category. For background in Gödel’s First Incompleteness Theorem and Tarski’s Undefinability Theorem, see Smullyan [1992] and Boolos
[1994].
Suppose that we have some sort of object 2 of ‘truth values.’ This need not be
fancy: we require that it has two points,
>:1→2
⊥:1→2

120

standing for truth and falsehood respectively. We also require an arrow ¬ : 2 → 2
that encodes the logical negation, satisfying
¬◦>∼⊥
¬◦⊥∼>
and
¬◦f ∼⊥

=⇒

f ∼>

A simplified version of Gödel’s First Incompleteness theorem for PA is this:
Theorem 45 (Gödel). If PA is consistent, then there are sentences φ of PA such that
neither PA ` φ nor PA ` ¬φ.
The proof relies on two constructions: the diagonal lemma, and the fact that provability is definable within the system. The definability of provability amounts to the
fact that there is a formula Prov(x) with one free variable x such that
PA ` φ if and only if PA ` Prov(pφq)
That is: modulo Gödel numbering, the system can internally ‘talk’ about its own
provability. It is not then hard to sketch the proof to Gödel’s theorem.
Proof of Theorem 45. Use the diagonal lemma to construct ψ such that
PA ` ψ ↔ ¬Prov(pψq)
Then ψ is provable if and only if it is not, so if either PA ` ψ or PA ` ¬ψ we would
observe inconsistency. Thus, if PA is consistent, neither ψ nor ¬ψ are provable.
It follows that ψ is not equivalent to either truth value. In a way, ψ has some other
eerie truth value, which is neither > nor ⊥. Classical logicians would say that it is
undecidable.
Let us represent the provability predicate as an arrow p : Q2 → 2 such that y ∼ >
if and only if p ◦ Qy ◦ m0 ∼ >. Consistency is captured by the following definition:
Definition 44. An object of truth values 2 as above is simply consistent just if
> 6∼ ⊥
Armed with this machinery, we can now transport the argument underlying Gödel’s
proof to our more abstract setting.
121

Theorem 46. If a p : Q2 → 2 is as above, and 2 has IFPs, then one of the following
things is true:
• either there are points of 2 other than > : 1 → 2 and ⊥ : 1 → 2, or
• 2 is not simply consistent, i.e. > ∼ ⊥.
Proof. As 2 has IFPs, take y : 1 → 2 such that
y ∼ ¬ ◦ p ◦ Qy ◦ m0
Now, if y ∼ >, then by the property of p above, p◦Qy◦m0 ∼ >, hence ¬◦p◦Qy◦m0 ∼
⊥, hence y ∼ ⊥. So either y 6∼ > or 2 is not simply consistent. Similarly, either
y 6∼ ⊥ or 2 is not simply consistent.
Tarski’s Undefinability Theorem, on the other hand is the result that truth cannot
be defined in arithmetic [Smullyan, 1992].
Theorem 47 (Tarski). If PA is consistent, then there is no predicate True(x) such
that
PA ` φ ↔ True(pφq)
for all sentences φ.
Proof. Use the diagonal lemma to obtain a closed ψ such that
PA ` ψ ↔ ¬True(pψq)
Then PA ` ψ ↔ ¬ψ, which leads to inconsistency.
•

A truth predicate would constitute an evaluator  : Q # IdB . If we had one, we
would have that
2 ◦ Q(y) ◦ m0 ∼ y ◦ 1 ◦ m0 ∼ y
where the last equality is because 1 is terminal. This is actually a more general
•

Lemma 24. Let Q : B # B be an endoexposure, and let  : Q # IdB be an evaluator.
Then, if A has IFPs then it also has EFPs.
Proof. Given t : A → A, consider t ◦ A : QA → A. A IFP for this arrow is a point
y : 1 → A such that y ∼ t ◦ A ◦ Qy ◦ m0 ∼ t ◦ y.
In proving Tarski’s theorem, we constructed a sentence ψ such that PA ` ψ ↔ ¬ψ.
This can be captured abstractly by the following definition.
122

Definition 45. An object 2 as above is fix-consistent just if the arrow ¬ : 2 → 2 has
no EFP: that is, there is no y : 1 → 2 such that ¬ ◦ y ∼ y.
Putting these together, we get
Theorem 48. If 2 has IFPs in the presence of an evaluator, then it is not fixconsistent.

6.1.2

Rice’s theorem

To further illustrate the applicability of the language of exposures, we state and prove
an abstract version of Rice’s theorem. Rice’s theorem is a result in computability
which states that no computer can decide any non-trivial property of a program by
looking at its code. A short proof relies on the SRT.
Theorem 49 (Rice). Let F be a non-trivial set of partial recursive functions, and
def

let AF = { e ∈ N | φe ∈ F } be the set of indices of functions in that set. Then AF is
undecidable.
Proof. Suppose AF is decidable. The fact F is non-trivial means that there is some
a ∈ N such that φa ∈ F and some b ∈ N such that φb 6∈ F. Consequently, a ∈ AF
and b 6∈ AF .
Define f (e, x) ' if e ∈ AF then φb (x) else φa (x). By Church’s thesis, f : N ×
N * N is partial recursive. Use the SRT to obtain e ∈ N such that φe (x) ' f (e, x).
Now, either e ∈ AF or not. If it is, φe (x) ' f (e, x) ' φb (x), so that φe 6∈ F, a
contradiction. Similarly if e 6∈ AF .
Constructing the function f in the proof required three basic elements: (a) the
ability to evaluate either φa or φb given a and b; (b) the ability to decide which one
to use depending on the input; and (c) intensional recursion. For (a), we shall need
evaluators, for (b) we shall need that the truth object 2 is a weak coproduct of two
copies of 1, and for (c) we shall require IFPs.
Theorem 50. Let 2 be a simply consistent truth object which also happens to be a a
weak coproduct of two copies of 1, with injections
>:1→2
⊥:1→2
Suppose that A has EFPs. If f : A → 2 is such that for all x : 1 → A, either
f ◦ x ∼ > or f ◦ x ∼ ⊥. Then f is trivial, in the sense that either
∀x : 1 → A. f ◦ x ∼ >

or
123

∀x : 1 → A. f ◦ x ∼ ⊥

Proof. Suppose that there are two such distinct a, b : 1 → A such that f ◦ a ∼ > and
f ◦ b ∼ ⊥. Let
def

g = [b, a] ◦ f : A → A
and let y : 1 → A be its EFP. Now, either f ◦ y ∼ > or f ◦ y ∼ ⊥. In the first case,
we can calculate that
> ∼ f ◦ y ∼ f ◦ g ◦ y ∼ f ◦ [b, a] ◦ f ◦ y ∼ f ◦ [b, a] ◦ > ∼ f ◦ b ∼ ⊥
so that 2 is not simply consistent. A similar situation occurs if f ◦ y ∼ ⊥.
Needless to say that the premises of this theorem are easily satisfied in our exposure
on assemblies from §5.2 if we take A = N⊥ N and 2 to be the lifted coproduct (1 + 1)⊥ .

6.2

The relationship to Löb’s rule

In this chapter we have considered two sorts of fixed points, extensional and intensional. Figure 6.1 summarises the definition of these two types of fixed points, in
1-category theory and P-category theory respectively.
Figure 6.1: Types of Fixed Points (without parameters)
Type

Morphism

Extensional

t:A→A

Intensional

t : QA → A

Fixed Point
a:1→A
t◦a=a
a:1→A
t ◦ Qa ◦ m0 ∼ a

Viewed through the lens of the Curry-Howard isomorphism, the existence of extensional fixed points at A can be written as the logical inference rule
A→A
A
which is exactly the type of the Y combinator of PCF. In fact, this exact inference rule
corresponds to an equivalent formulation of PCF that proceeds through the binding
construct µx:A.M with equation
µx:A.M = M [µx:A.M ]
For more details, see Gunter [1992].
124

This rule is obviously logically catastrophic, as it produces a closed term µx:A. x
at each type A. Consequently, there is no honest Curry-Howard isomorphism for PCF:
every type is inhabited, and thus every ‘formula’ is provable, leading to the trivial
logic. However, the terms do matter, because they have computational behaviour : it
might be that the types do not correspond to logical formulae, but they are there to
stop basic programming errors. And, in the end, the purpose of PCF is simply typed
general recursive programming.
Viewing the notion of intensional fixed points through the lens of Curry-Howard,
the result is much more impressive: IFPs correspond to Löb’s rule, namely
A → A
A
def

To see this, it suffices to read  = Q and to look at the definition of intensional fixed
points as an inference rule, i.e.
f : QA → A
f◦ : 1 → A
such that
1

Qf ◦ ◦m0

QA

f◦
f

A
commutes up to ∼.
Unfortunately, we have seen in this chapter that a key ingredient in the theory of
•

exposures are the so-called evaluators, which are natural transformations  : Q # Id.
These encapsulate the modal axiom T, namely
A → A
Coupled with the above inference rule, this will also have the catastrophic consequence
that every type is inhabited. We shall not be alarmed by this fact, for we will
want general recursion, and there seems no way around partiality in that case, as
we discussed in §1.2.4. We shall still use the Curry-Howard isomorphism, but only
heuristically.
However, let us for the moment revert to the mindset of a purely categorical
logician. In our parallel work [Kavvos, 2017b,c] we have investigated an extension
of the Curry-Howard isomorphism to box modalities. Our methodology consisted of
mimicking the rules of sequent calculus in natural deduction. A quick perusal suffices

125

to bring to light the fact that in that work we used a stronger form of Löb’s rule,
namely
A → A
A
Historically speaking, this variant of Löb’s rule is proof-theoretically well-behaved,
and yields cut-free sequent calculi. It was introduced in the context of intuitionistic
modal logic by Ursini [1979a]. If we were to use it to formulate iPCF,2 we would
obtain something akin to
∆ ; z : A ` M : A
∆ ; Γ ` fix z in box M : A
with
fix z in box M −→ box M [fix z in box M/z]
However, this does not have a clear intensional interpretation. If, as in §1.4.2, we try
to devise a ‘reading’ of this in the untyped λ-calculus, this rule would require that
for each term f there exists a u such that
u =β pf puqq
which is obviously nonsense. This is why in this thesis we have weakened our formulation to Löb’s original rule.
Nevertheless, we can still ‘transport’ this version of Löb’s rule over to P-categories:
it amounts to the inference rule
f : QA → A
f † : 1 → QA
such that
1

Qf † ◦m0

Q2 A

f◦
Qf

QA
commutes up to ∼.
Now: can we use the framework of comonadic exposures to prove that this version
of Löb’s rule is stronger? What is the exact relationship between this and the original
form?
Surprisingly, the answer is positive. But before we show that, let us give a name
to these two kinds of IFPs so we can talk about them efficiently.
2

In fact, the first versions of this thesis and [Kavvos, 2017d] both used this version of iPCF.

126

Definition 46. Let Q : B # B be a product-preserving endoexposure.
1. A meek intensional fixed point (meek IFP) of an arrow f : QA → A is a point
a : 1 → a such that the following diagram commutes up to ∼:
a

1

A

m0

f

Q1

Qa

QA

i.e. a ∼ f ◦ Qa ◦ m0 .
2. A vehement intensional fixed point (vehement IFP) of an arrow f : QA → A is
a point a : 1 → QA such that the following diagram commutes up to ∼:
a

1

QA

m0

Qf

Q1

Qa

Q2 A

i.e. a ∼ Qf ◦ Qa ◦ m0 .
Thus the intensional fixed points we have been working with up to this point are
meek, whereas the proof theory in [Kavvos, 2017b,c] use a pattern closer to vehement
ones.
If we have a meek IFP whose defining equation holds up to intensional equality
(≈Q ), then that is also a vehement IFP. Conversely, if we have a vehement IFP, and
our comonadic exposure is idempotent, then we obtain a meek IFP.
Theorem 51. Let f : QA → A.
1. If we have a meek IFP of f : QA → A, which moreover is so intensionally, i.e.
f ◦ ≈Q f ◦ Qf ◦ ◦ m0
then we can obtain a vehement IFP of f , defined by
def

f † = Qf ◦ ◦ m0
2. If we have a vehement IFP f : QA → A, and moreover the comonadic exposure
(Q, , δ) is idempotent, then we can obtain a meek IFP of of f , defined by
def

f ◦ = A ◦ f †
127

Proof.
1. We calculate:
f†
∼ { definition }
Qf ◦ ◦ m0
∼ { assumption }
Q(f ◦ Qf ◦ ◦ m0 ) ◦ m0
∼ { exposure }
Qf ◦ Q(Qf ◦ ◦ m0 ) ◦ m0
∼ { definition }
Qf ◦ Qf † ◦ m0
so that f † is a vehement IFP.
2. We calculate
f◦
∼ { definition }
A ◦ f †
∼ { definition }
A ◦ Qf ◦ Qf † ◦ m0
∼ {  natural }
f ◦ QA ◦ Qf † ◦ m0
∼ {  natural }
f ◦ f † ◦ 1 ◦ m0
∼ {  monoidal }
f ◦ f†
But, by the corollary of the Quotation-Evaluation lemma (Lemma 4),
f † ∼ Q(A ◦ f † ) ◦ m0 ∼ Qf ◦ ◦ m0
so f ◦ ∼ f ◦ Qf ◦ ◦ m0 is a meek IFP.

128

6.3

Whence fixed points?

6.3.1

Lawvere’s Theorem

Lawvere [1969, 2006] proved a fixed point theorem that generalises a number of ‘diagonal’ constructions, including Cantor’s theorem, Gödel’s First Incompleteness Theorem, and the Tarski undefinability theorem. In order to state it, we will first need
some notation for cartesian closed categories (CCCs). A cartesian closed category
[Eilenberg and Kelly, 1966] is a great place: it is a mathematical universe where
morphisms of the category correspond exactly to points of certain objects, the exponentials. Indeed, to every morphism f : A → Y there corresponds a point of the
exponential object Y A , namely
pf q : 1 → Y A
which is defined by


∼
f
def
=
pf q = λ 1 × A −
→A→
− Y
and to each point y : 1 → Y A there corresponds a morphism y o : A → Y , defined by
hy◦!A ,idA i

ev

y o = A −−−−−−→ Y A × A −
→Y
def

The above operations are mutually inverse:
pf qo = f,

o
py q = y

For a classic exposition, see Lambek and Scott [1988].
The main idea in Lawvere’s paper is this: a morphism
r

X→
− YA
from an object to an exponential may be thought as ‘indexing’ morphisms of type
A → Y ; for, given x : 1 → X, we have (r ◦ x)o : A → Y . Such an indexing may be
considered an enumeration if it is, in some sense, surjective. There are many ways in
which an arrow r : X → A can be surjective. Here are four:
• It could a retraction; that is, there could exist s : A → X such that
A
idA

s

X

r

A

The arrow s may be thought of as ‘choosing a preimage’ of elements of A with
respect to r. In the category of sets, surjective functions are always retractions
(if one assumes the axiom of choice).
129

• It could be point-surjective: for each point a : 1 → A there could be a point
x : 1 → X such that
1
a

x

X

A

r

• It could be N -path-surjective: it could be that, for each ‘N -path’ q : N → A,
there is a N -path p : N → X such that
N
p

q

X

r

A

The name of the object N has been chosen to suggest the natural numbers, so
that p : N → A can be thought of as tracing out a discrete path of points in A.
A point-surjective arrow is, of course, a 1-path-surjective arrow.
• It could be weakly point-surjective (only if the codomain is an exponential): if
r : X → Y A , then, for each x : 1 → X, we obtain r ◦ x : 1 → Y A , which
corresponds to a morphism
(r ◦ x)o : A → Y
It could then be that every morphism A → Y is ‘pointwise emulated’ by (r ◦ x)o
for some x. That is, for each f : A → Y , there exists xf : 1 → X such that
∀a : 1 → A. (r ◦ xf )o ◦ a = f ◦ a
So a weak point-surjection is a bit like ‘pointwise cartesian closure.’
Evidently,
r is a retraction =⇒ r is N -path-surjective
if N non-empty

========⇒ r is point-surjective
=⇒ r is weakly point-surjective
where the third implication only makes sense if codomain of r is an exponential, but
!

x

may be skipped otherwise. For the second implication, notice that N →
− 1→
− A is a
N -path, factorise it through X, and pre-compose with any point n : 1 → N .
Lawvere then observed that, if the codomain of the weak point-surjection is an
exponential Y A , and the ‘indexing object’ X coincides with A, a curious phenomenon
occurs.
130

Theorem 52 (Lawvere). If r : A → Y A is a weak point-surjection, then then every
arrow t : Y → Y has a fixed point.
Proof. Let
def

hr,idA i

ev

t

f = A −−−−→ Y A × A −
→Y →
− Y
As r is a weak point-surjection, there exists a xf : 1 → A such that, for all a : 1 → A,
we have
(r ◦ xf )o ◦ a
= { r is a weak point-surjection }
f ◦a
= { definition of f }
t ◦ ev ◦ hr, idA i ◦ a
= { naturality of product }
t ◦ ev ◦ hr ◦ a, ai
= { terminal object: a ◦ !A = id1 }
t ◦ ev ◦ hr ◦ a ◦ !A ◦ a, ai
= { naturality of product }
t ◦ ev ◦ hr ◦ a ◦ !A , idA i ◦ a
= { definition of (−)o }
t ◦ (r ◦ a)o ◦ a
def

Taking a = xf produces a fixed point.
Lawvere also hinted at a ‘cartesian’ version of the above result that does not require
exponentials. In this version, the diagonal nature of the argument is even more
evident. To prove it, we need to introduce the following definition:
Definition 47. An arrow r : X × A → Y is a (cartesian) weak point-surjection if for
every f : A → Y there exists a xf : 1 → X such that
∀a : 1 → A. r ◦ hxf , ai = f ◦ a
We will not bother to qualify weak point-surjections as ordinary or cartesian, as it
will be clear by the context. We can now prove the
Theorem 53 (Lawvere). If r : A × A → Y is a weak point-surjection, then every
arrow t : Y → Y has a fixed point.
131

Proof. Let
def

f = t ◦ r ◦ hidA , idA i
Then there exists a xf : 1 → A such that
r ◦ hxf , ai = f ◦ a
for all a : 1 → A. We compute that
r ◦ hxf , xf i = t ◦ r ◦ hidA , idA i ◦ xf = t ◦ r ◦ hxf , xf i
so that r ◦ hxf , xf i is a fixed point of of t.
We have seen in §6.1 that the extensional kind of fixed points produced by this
theorem are of a sort that oughtn’t exist. We believe that this is one of the reasons
that Lawvere’s result has not found wider applications. Nevertheless, we will also see
in §6.4.2 that—in a certain setting—this theorem corresponds to a very weak form of
Kleene’s First Recursion Theorem, which has been a central theorem in the semantics
of programming languages (see §2).

6.3.2

An intensional Lawvere theorem

Can we adapt Lawvere’s result to IFPs? The answer is positive: all we need is a
cartesian P-category B, a product-preserving exposure Q : B # B, and a reasonable
quoting device. What remains is to ‘embellish’ Lawvere’s argument with appropriate
instances of Q.
Theorem 54 (Intensional Recursion). Let Q : B # B be a product-preserving exposure, and let δA : QA → Q2 A be a reasonable quoting device. If r : QA × QA → Y is
a weak point-surjection, then every arrow
t : QY → Y
has an intensional fixed point.
Proof. Let
def

hδ,δi

m

Qr

t

f = QA −−→ Q2 A × Q2 A −
→ Q(QA × QA) −→ QY →
− Y
Then, there exists a xf : 1 → QA such that
r ◦ hxf , ai ∼ f ◦ a
132

for all a : 1 → QA. We compute that
r ◦ hxf , xf i
∼ { definition }
t ◦ Qr ◦ m ◦ hδA , δA i ◦ xf
∼ { naturality }
t ◦ Qr ◦ m ◦ hδA ◦ xf , δA ◦ xf i
∼ { δA is a reasonable quoting device }
t ◦ Qr ◦ m ◦ hQxf ◦ m0 , Qxf ◦ m0 i
∼ { naturality }
t ◦ Qr ◦ m ◦ hQxf , Qxf i ◦ m0
∼ { Proposition 2 }
t ◦ Qr ◦ Qhxf , xf i ◦ m0
∼ { exposures preserve composition }
t ◦ Q(r ◦ hxf , xf i) ◦ m0
so that r ◦ hxf , xf i is a IFP of t.

6.4

Examples of Fixed Points

In this final section we shall briefly examine what extensional and intensional fixed
points mean in the first two examples of exposures presented in §5, namely the Lindenbaum P-category and the P-category of assemblies.
Unfortunately, since the trivial group is a zero object in the P-category of groups,
points do not carry any interesting structure, and thus neither notion of fixed point
is interesting in the third example.

6.4.1

Fixed Points in Gödel numbering: the Diagonal Lemma

We will now carefully consider what we have hinted at throughout the development of
the abstract analogues of Gödel and Tarski’s results in §6.1.1, viz. the diagonal lemma
of Peano arithmetic is precisely the existence of IFPs in the case of the exposure on
arithmetic presented in §5.1.
Recall once more the diagonal lemma: for every formula φ(x) there exists a closed
formula fix(φ) such that
PA ` fix(φ) ↔ φ(pfix(φ)q)
133

Take the formula φ(x). In Lind(PA), it is an arrow
φ(x) : A → 2
Let there be a sentence ψ : 1 → 2. When the exposure acts on it, it produces (the
numeral of) the Gödel number of ψ, which is a closed term. Suppose ψ is an IFP of
φ, i.e
ψ ∼ φ ◦ Qψ ◦ m0
We can then see that the RHS simplifies by substitution to φ(pψq), so this is precisely
the conclusion of the diagonal lemma.

6.4.2

Fixed Points in Assemblies: Kleene’s Recursion Theorems

We now turn to the consideration of fixed points in the P-category of assemblies
Asm(A) that we considered in §5.2, along with the paradigmatic exposure
 : Asm(A) # Asm(A)
EFPs are exactly what one would expect: given an arrow (f, r) : X → X, a EFP
of this arrow is a x ∈ |X| such that
f (x) = x
We will shortly argue that EFPs in this setting are strongly reminiscent of Kleene’s
First Recursion Theorem, which we discussed at length in §2.
On the contrary, a IFP of an arrow
(f, r) : X → X
is more than what we had before: it is an element x ∈ |X| along with a realizer
a ∈ kxkX of it, such that
f (x, a) = x
That is, it is a kind of fixed point of f , but the computation of f also depends on the
chosen realizer a rather than simply x.
It is worth pausing for a moment to ask what a vehement IFP (as discussed in
§6.2) is in this case. It is not hard to compute that it consists once again of both an
element x ∈ |X| and a realizer a ∈ kxkX for it, but the pair now needs to satisfy not
only f (x, a) = x, but also
r·a'a
134

That is, the two sides need to have the same realizer. The above theorem is not too
surprising in light of Theorem 28 and Corollary 3: in the idempotent case, the fact
that two arrows 1 → QA are equal immediately yields that they are intensionally
equal. It therefore follows that vehement IFPs are too strong a notion for what we
consider to be intensional recursion.
Kleene’s Recursion Theorems
We will now argue that, in the case of Asm(K1 ), the notions of EFPs and IFPs indeed
match the conclusions of the two main theorems that are used to make recursive
definitions in computability theory, namely the First and Second Recursion Theorems
of Kleene. In fact, we will argue that Lawvere’s fixed point theorem (Theorem 53)
and our own Intensional Recursion theorem (Theorem 54) each correspond to abstract
versions of them. We have discussed the relationship between the two theorems at
length in §2, but—for the benefit of the reader—we recapitulate some basic points of
this discussion here, in a form tailored to our needs in this chapter.
Let us fix some notation. We write ' for Kleene equality: we write e ' e0 to mean
either that both expressions e and e0 are undefined, if either both are undefined, or
both are defined and of equal value. Let φ0 , φ1 , . . . be an enumeration of the partial
recursive functions. We will also require the s-m-n theorem from computability theory.
Full definitions and statements may be found in the book by Cutland [1980].
Theorem 55 (First Recursion Theorem). Let PR be the set of unary partial recursive
functions, and let F : PR → PR be an effective operation. Then F : PR → PR
has a fixed point.
Proof. That F : PR → PR is an effective operation means that there is a partial
recursive f : N × N * N such that f (e, x) ' F (φe )(x). Let d ∈ N a code for the
def

partial recursive function φd (y, x) = f (S(y, y), x), where S : N × N * N is the s-1-1
function of the s-m-n theorem. Then, by the s-m-n theorem, and the definitions of
d ∈ N and f ,
φS(d,d) (x) ' φd (d, x) ' f (S(d, d), x) ' F (φS(d,d) )(x)
so that φS(d,d) is a fixed point of F : PR → PR.
Lawvere’s theorem is virtually identical to a point-free version of this proof. Indeed,
if we let
S : N × N −→ PR
(a, b) 7−→ φS(a,b)
135

We can then show that this is a weak point-surjection: any ‘computable’ f : N → PR
is actually just an index d ∈ N such that
φd (x, y) ' f (x)(y)
for all x, y ∈ N. We can then show that
S(d, x)(y) ' φS(d,x) (y) ' φd (x, y) ' f (x)(y)
so that S(d, x) = f (x) ∈ PR. Thus the resemblance becomes formal, and the argument applies to yield the FRT.

Yet, one cannot avoid noticing that we have proved more than that for which we
bargained. The f : N × N * N in the proof implemented a certain effective operation
F : PR → PR. It follows that f has a special property: it is extensional, in the
sense that
φe = φe0

=⇒

∀x ∈ N. f (e, x) ' f (e0 , x)

Notice, however, that the main step that yields the fixed point in this proof also holds
for any such f , not just the extensional ones. This fact predates the FRT, and was
shown by Kleene [1938].
Theorem 56 (Second Recursion Theorem). For any partial recursive f : N×N * N,
there exists e ∈ N such that φe (y) ' f (e, y) for all y ∈ N.
This is significantly more powerful than the FRT, as f (e, y) can make arbitrary
decisions depending on the source code e, irrespective of the function φe of which it is
the source code. Moreover, it is evident that the function φe has access to its own code,
allowing for a certain degree of reflection. Even if f is extensional, hence defining an
effective operation, the SRT grants us more power than the FRT: for example, before
recursively calling e on some points, f (e, y) could ‘optimise’ e depending on what y
is, hence ensuring that the recursive call will run faster than e itself would.
Lawvere’s argument, as presented above, cannot account for the Second Recursion
Theorem: S : N × N → PR had PR in the codomain, and thus this argument only
works to yield fixed points of effective operations PR → PR. We do not see a
meaningful way of replacing this with, say, N . We could certainly replace it with an
object N⊥ that accounts for non-termination, but that is not what we want. we wish
to take here.
136

What we really want is to define a computable operation PR 99K PR. In order
to explain the meaning of this, a shift in perspective is required. To say that F :
PR → PR is an effective operation, we need an extensional, total recursive function
f , implemented by some index d ∈ N that tracks it on codes, along with a proof that
f is extensional. But what about indices d ∈ N that describe a total φd , yet are not
extensional? These still map every e ∈ N, which is an index for φe , to φd (e), which is
an index for φφd (e) . Hence, while f may map codes of partial recursive functions to
codes of partial recursive functions, it may do so without being extensional. In that
case, it defines a non-functional operation G : PR 99K PR, which is exactly the case
where IFPs will apply.
We can see this far more clearly in the setting of Asm(K1 ). Arrows
N → N⊥
are easily seen to correspond to partial recursive functions. The weak point-surjection
S : N × N → PR we produced above can now be seen as an arrow r : N × N → NN⊥
in Asm(K1 ), and invoking Lawvere’s theorem indeed shows that every arrow
NN⊥ → NN⊥
has an extensional fixed point. Now, by Longley’s generalised Myhill-Shepherdson
theorem [Longley, 1995, Longley and Normann, 2015], these arrows exactly correspond to effective operations. Hence, in this context Lawvere’s theorem states that
each effective operation has a fixed point, and indeed corresponds to the simple diagonal argument above.3
However, let us look now look at arrows of type
NN⊥ → NN⊥
These correspond to ‘non-functional’ transformations, mapping functions to functions, but without respecting extensionality. As every natural number indexes a
partial recursive function, these arrows really correspond to all partial recursive functions. It is not hard to see that N is P-isomorphic to N: this fact can be used with
r to immediately produce a weak point-surjection q : N × N → NN⊥ , so that, by
our Intensional Recursion theorem (Theorem 54), every arrow of type
NN⊥ → NN⊥
has a IFP. It is thus evident that there is considerable formal similarity between this
application of Theorem 54 and Kleene’s Second Recursion Theorem!
3

But note that this is not the complete story, as there is no guarantee that the fixed point obtained
in least, which is what Kleene’s original proof in Kleene [1952] gives. See also §2.

137

Chapter 7
Intensional Semantics of iPCF I
This is the first of the two chapters that address the issue of finding a truly intensional
semantics for the language iPCF which we introduced in §3. Both of these chapters
can be seen as evidence towards the claim that iPCF is a truly intensional language.
To make progress towards our goal, we will use the theory of exposures, as developed in §4 and 6. The desired outcome is that the category of assemblies Asm(K1 )
over the PCA K1 , which—as we showed in §5.2—is a cartesian closed P-category
equipped with an idempotent comonadic exposure, is a model of iPCF.
However, before we delve into the details, we need to develop some algebraic
machinery for interpreting the rules of iPCF. Because of the delicate behaviour of
our two notions of equality—extensional (∼) and intensional (≈Q )—this will be more
involved than it sounds. Nevertheless, a lot of the ground work has been done before,
and is still applicable to this setting.
We have discussed the categorical semantics of modal λ-calculi at length in previous work—see [Kavvos, 2017b,c]: therein we found that categorical semantics of a
S4 modality comprise a Bierman-de Paiva category [Bierman, 2000], viz. a cartesian
closed category (C, ×, 1) along with a product-preserving comonad (Q, , δ). Adapting this to the intensional setting involves exchanging Q : C −→ C for an exposure
Q : (C, ∼) # (C, ∼) that is comonadic. The crucial factor that one should be aware
of is that no calculation in our previous work depended on the ‘forbidden principle’
f = g =⇒ Qf = Qg. Hence, a lot of the groundwork may be immediately transferred
to the intensional setting.
Nevertheless, there are some differences, and we shall deal with them in this
chapter. One of the main ones is our emphasis on idempotence. In the ensuing
development it will become clear that the idempotent case is particularly elegant and
useful. What is more, the argument made in §4.2.4, viz. that idempotence is the
right notion for intensionality, will be corroborated in this chapter.
138

7.1

Setting the scene

First, we shall define certain basic ingredients that we will use for our semantics.
These amount to algebraic short-hands that will prove incredibly useful for calculations.
We shall define the following arrows by induction (and be lax about the subscripts):
m

def

0
m(0) = 1 −→
Q1

def

m(n+1) =

n+1
Y

m(n) ×id

QAi −−−−−→ Q

i=1

n
Y

!
Ai

m

× QAn+1 −
→Q

i=1

n+1
Y

!
Ai

i=1

Then, the m(n) ’s are natural, in the sense that
(n)

m

◦

n
Y

Qfi ∼ Q

i=1

n
Y

!
◦ m(n)

fi

i=1

The main contraption in the semantics of S4 was a hom-set map that generalised the
notion of co-Kleisli lifting. In our setting, this will be an operation:
!
!
n
n
Y
Y
(−)∗ : C
QAi , B 99K C
QAi , QB
i=1

i=1

which we define as follows:
f:

n
Y

QAi → B

i=1
n
n
n
Qn
Y
Y
Y
m(n)
def
i=1 δAi
f∗ =
QAi −−−−−→
Q2 Ai −−→ Q
QAi
i=1

i=1

!
Qf

−→ QB

i=1

This operation is the categorical counterpart of an admissible rule of S4, which from
Γ ` A allows one to infer Γ ` A. In the weaker setting of K, we only have Scott’s
rule: from Γ ` A infer Γ ` A. This is also categorically also an operation:
!
!
n
n
Y
Y
(−)• : C
Ai , B 99K C
QAi , QB
i=1

i=1

which is defined as follows:
f:

n
Y

Ai → B

i=1

f• =

def

n
Y

m(n)

QAi −−→ Q

i=1

n
Y
i=1

139

!
Ai

Qf

−→ QB

It might, of course, seem that both (−)• and (−)∗ are operations, but what they
have in common is that they both act by applying the exposure Q to their argument.
It follows then that they are functions with respect to intensional equality, and hence
well-defined on the x-ray category of C. We write
!
!
n
n
Y
Y
(−)∗ : (C, ≈Q )
QAi , B → C
QAi , QB
(−)• : (C, ≈Q )

i=1
n
Y

!
Ai , B

→C

i=1

i=1
n
Y

!

QAi , QB

i=1

However, if (Q, , δ) is idempotent, we can show that (−)∗ actually preserves intensional equality. For this, we will need the following proposition.
Q
Proposition 11. If (Q, , δ) is idempotent, then for f : ni=1 QAi → B,
Qf ∗ ∼ δB ◦ Qf
Proof.
Qf ∗
∼ { definition, Q exposure }
!
n
Y
Q2 f ◦ Qm(n) ◦ Q
δA i
i=1

∼ { Proposition 2 }
−−−−−−−−→
Q2 f ◦ Qm(n) ◦ m(n) ◦ hQδAi ◦ QπAi i
∼ { Q idempotent, so QδAi ∼ δQAi }
−−−−−−−→
Q2 f ◦ Qm(n) ◦ m(n) ◦ hδQAi ◦ Qπi i
∼ { product equation, δ monoidal }
−−→
Q2 f ◦ δ ◦ m(n) ◦ hQπi i
−−→
∼ { δ natural, inverse of m(n) is hQπi i }
δ ◦ Qf

This allows us to infer that
Corollary 5. If Q is idempotent then (−)∗ preserves ≈Q : it is a map
!
!
n
n
Y
Y
(−)∗ : (C, ≈Q )
QAi , B → (C, ≈Q )
QAi , QB
i=1

i=1

Proof. If f ≈Q g, then Qf ∗ ∼ δ ◦ Qf ∼ δ ◦ Qg ∼ Qg ∗ .
140

7.2

Distribution and naturality laws

We now look at the relationship between the two operations (−)• and (−)∗ , and we
state and prove certain ‘distribution’ laws that apply to them, and describe their
interaction. First, we note that it is definitionally the case that
∗

def

•

f =f ◦

n
Y

δA i

i=1

for f :

Qn

i=1

QAi → B.

Proposition 12. Given a comonadic exposure (Q, , δ), the following equations hold
up to ∼. Furthermore, if Q is idempotent, they hold up to ≈Q .
(i) id∗QA ∼ δQA
(ii) ∗A ∼ idQA
(iii) For k :

Qn

i=1

QAi → B and l : QB → C,
(l ◦ k ∗ )∗ ∼ l∗ ◦ k ∗

(iv) For k :

Qn

i=1

Ai → B and l : QB → C,
(l ◦ k • )∗ ∼ l∗ ◦ k •

(v) Let f :

Qn

i=1

Bi → C and gi :

Qk

j=1

QAj → Bi for i = 1, . . . , n. Then

D→
−E
∗
−
(f ◦ h→
gi i) ∼ f • ◦ gi∗
Q
Q
Q
−
(vi) For f : ni=1 QAi → B and h→
πj i : ni=1 QAi → j∈J QAj for J a list with
elements from {1, . . . , n},
∗
−
−
(f ◦ h→
πj i) ∼ f ∗ ◦ h→
πj i

(vii) If (Q, , δ) is idempotent then for f :
Qn
i=1 QAi we have

Qn

i=1

QAi → B and k :

(f ◦ k)∗ ≈Q f ∗ ◦ k
and hence (f ◦ k)∗ ∼ f ∗ ◦ k.

141

Qm

j=1

QDj →

Proof. Straightforward calculations involving the comonadic equations. (i) and (ii)
are standard from the theory of comonads and functional programming. In the case
of idempotence we can use them alongside Proposition 11 to prove the intensional
equation, e.g.
Q(id∗A ) ∼ δQA ◦ QidA ∼ δQA ∼ QδA
and hence id∗QA ≈Q δQA . For (ii) use δA ◦ QA ∼ idQ2 A . (iii) and (iv) are easy
calculations; e.g. for (iv):
(l ◦ k • )∗
∼ { definitions }
2

Ql ◦ Q k ◦ Qm

(n)

◦m

(n)

◦

n
Y

δA i

i=1

∼ { δ monoidal }
Ql ◦ Q2 k ◦ δ ◦ m(n)
∼ { δ natural }
Ql ◦ δ ◦ Qk ◦ m(n)
which by definition is l∗ ◦ k • . Given idempotence it is simple to use Proposition 11 to
prove (iii) and (iv) up to ≈Q , without even using the non-idempotent result; e.g. for
(iv):
Q (l ◦ k • )∗ ∼ δC ◦ Ql ◦ Qk • ∼ Ql∗ ◦ Qk •
(v) is a simple but lengthy calculation. With idempotence we have
∗
−
Q (f ◦ h→
πj i)

∼ { Proposition 11 }
−
δ ◦ Qf ◦ Qh→
g i
i

∼ { δ natural, Proposition 2 }
−→
Q2 f ◦ δ ◦ m(n) ◦ hQgi i
∼ { δ monoidal }
2

(n)

Q f ◦ Qm

(n)

◦m

◦

n
Y

−→
δ ◦ hQgi i

i=1

∼ { product equation, Proposition 11 }
−−−→
Q2 f ◦ Qm(n) ◦ m(n) ◦ hQ(gi∗ )i
∼ { Proposition 2 }
−−→
Q2 f ◦ Qm(n) ◦ Qh(gi∗ )i
142

→
−
−
and hence (f ◦ h→
gi )∗ ≈Q f • ◦ h gi∗ i. (vi) is a corollary of (v), once we notice that
Q
def
πi∗ ∼ δAi ◦ πi , and use the definition of f ∗ = f • ◦ δ. For the idempotent case, notice
that πi∗ ≈Q δAi ◦ πi , or derive it as a corollary of (vii).
(v) is an easy calculation:
Q(f ◦ k)∗ ∼ δ ◦ Qf ◦ Qk ∼ Qf ∗ ◦ Qk
which yields (f ◦ k)∗ ≈Q f ∗ ◦ k, and hence (f ◦ k)∗ ∼ f ∗ ◦ k. It is worth noting that we
know of no direct calculation that proves (7) up to ∼ without going through ≈Q .
In other news, (−)∗ interacts predictably with δ and .
Proposition 13.
Q
(i) Let f : ni=1 QAi → B. Then δB ◦ f ∗ ∼ (f ∗ )∗ . Furthermore, if Q is idempotent
then this equation holds intensionally.
Q
(ii) Let f : ni=1 QAi → B. Then B ◦ f ∗ ∼ f . Furthermore, if Q is idempotent
then this equation holds intensionally.
Proof.
def

1. Let E =

Qn

i=1

QAi . Then
δB ◦ f ∗
∼ { definition }
(n)

δB ◦ Qf ◦ m

◦

n
Y

δA i

i=1

∼ { δ natural }
Q2 f ◦ δE ◦ m(n) ◦

n
Y

δA i

i=1

∼ { δ monoidal }
2

Q f ◦ Qm

(n)

(n)

◦m

◦

n
Y
i=1

δQAi ◦

n
Y

δAi

i=1

∼ { product is functorial, comonadic equation }
n
n
Y
Y
2
(n)
(n)
Q f ◦ Qm ◦ m ◦
QδAi ◦
δA i
i=1

i=1

∼ { Q product-preserving }
!
n
n
Y
Y
Q2 f ◦ Qm(n) ◦ Q
δAi ◦ m(n) ◦
δA i
i=1

∼ { definitions }
(f ∗ )∗
143

i=1

If Q is idempotent, we can also compute that
Qδ ◦ Qf ∗
∼ { Proposition 11 }
Qδ ◦ δ ◦ Qf
∼ { comonadic equation }
δ ◦ δ ◦ Qf
∼ { Proposition 11 }
δ ◦ Qf ∗
∼ { Proposition 11 }
Q ((f ∗ )∗ )
and hence δ ◦ f ∗ ≈Q (f ∗ )∗ .
2. Straightforward calculation involving—amongst other things—the naturality
and monoidality of . If Q is idempotent, then we calculate that
QB ◦ Qf ∗
∼ { Proposition 11 }
QB ◦ δB ◦ Qf
∼ { comonadic equation }
Qf
and hence B ◦ f ∗ ≈Q f .

To conclude this section, we note that a special case of Proposition 12(7) generalises
the Quotation-Evaluation lemma (Lemma 17).
Corollary 6. If (Q, , δ) is idempotent then for k :

Qm

i=1

QBi → QA we have

(A ◦ k)∗ ≈Q k
and hence (f ◦ k)∗ ∼ f ∗ ◦ k.
Proof. By Proposition 12 (vii) & (ii), (A ◦ k)∗ ≈Q ∗A ◦ k ≈Q k

144

7.3

Fixed Points with Parameters

In §6 we discussed two types of fixed points, EFPs and IFPs. The first type concerned
arrows f : A → A, whereas the second pertained to arrows f : QA → A. However, if
we are to formulate a categorical semantics of PCF and iPCF, we are going to need a
slightly more general notion of each fixed point, namely a fixed point with parameters.
The parameters correspond to the context of free variables in the presence of which
we are taking the relevant fixed point.
In the case of extensional fixed points, the context appears as a cartesian product
in the domain of the morphism, which is of type t : B × Y → Y . B is usually of the
Q
form ni=1 Bi . Indeed, this is what happens in the categorical semantics of PCF, for
which see Hyland and Ong [2000], Poigné [1992], or Longley [1995]. It is not at all
difficult to generalise Lawvere’s theorem to produce this kind of fixed point.
We then move on to intensional fixed points. The situation in this case is slightly
more nuanced, for—as we saw in §6.2—we essentially need to model our fixed points
after Löb’s rule, viz.
A → A
A
Adapting this rule to a parametric version is not a trivial task, as it is almost equivalent to developing proof theory for it. However, we can look to our previous work on
the proof theory of GL [Kavvos, 2017b,c] to find a good pattern. We briefly discussed
that work in §6.2. The right form of the generalised rule is
Γ, Γ ` A → A
Γ ` A
However, since iPCF is based on an S4-like setting, the 4 axiom is available. Thus, it
suffices to consider a rule of the following shape:
Γ ` A → A
Γ ` A
Indeed, this is very close to the rule we used for iPCF in §3: the only remaining step is
the weaken the fixed point by dropping the box in the conclusion, thereby mimicking
the form of Löb’s rule more commonly found in the literature. Therefore, IFPs with
parameters will pertain to arrows of type
f:

n
Y

QBi × QA → A

i=1

145

and yield
f† :

n
Y

QBi → A

i=1

We thus arrive at a kind of context for IFPs that consists of a handful of intensional
assumptions QBi . We elaborate on that in §7.3.2.
But, before that, let us recall the extensional case.

7.3.1

Extensional Fixed Points with Parameters

Suppose we have a cartesian 1-category C. An arrow
f :B×A→A
can be considered as a sort of endomorphism of A that is ‘parameterised’ by B.
Type-theoretically, we will consider B to be the context, and we can take the EFP
‘at A.’
Definition 48. Let C be a cartesian 1-category. A parametric extensional fixed point
(parametric EFP) of f : B × A → A is an arrow f † : B → A such that the following
diagram commutes:
B

hidB ,f † i

B×A

f†
f

A
Definition 49 (Extensional Fixed Points with Parameters). A cartesian category C
has parametric extensional fixed points (parametric EFPs) at A ∈ C just if for all
B ∈ C there exists a map
(−)†B : C(B × A, A) −→ C(B, A)
such that for each f : B × A → A, the morphism f † : B → A is a EFP of f .
This, of course, is an ‘external view’ of what it means to have parametric EFPs in
a category. However, in typed λ-calculi we often include a fixed point combinator
YA : (A → A) → A in our calculus, which is rather more ‘internal.’ This fixed point
combinator can be either weak or strong, and always occurs in the context of a CCC.
Definition 50 (Fixed Point Combinators). Let C be a cartesian closed category.

146

1. A strong fixed point combinator at A is an arrow Y : AA → A such that
AA

hid,Y i

Y

AA × A

ev

A
2. A weak fixed point combinator at A is an arrow Y : AA → A such that, for each
f : B × A → A, the arrow
Y ◦ λ(f ) : B → A
is a EFP of f .
Surprisingly, we have the following theorem.
Theorem 57. In a cartesian closed category C, the following are equivalent:
1. A strong fixed point combinator at A.
2. A weak fixed point combinator at A.
3. Extensional fixed points at A.
Proof. We will prove a circular chain of implications.
Case(1 ⇒ 2). If Y : AA → A is a strong FPC, then
Y ◦ λ(f ) = ev ◦ hid, Y i ◦ λ(f ) = ev ◦ hλ(f ), Y ◦ λ(f )i = f ◦ hid, Y ◦ λ(f )i
so Y ◦ λ(f ) is a fixed point of f .
Case(2 ⇒ 3). Trivial: define (−)† by λ-abstraction and composition with Y .
Case(3 ⇒ 1). A strong FPC Y at A is a fixed point of ev : AA × A → A.
Hence, if we let
def

ev†

Y = AA −→ A
then Y = ev ◦ hid, Y i.

Finally, we note the following naturality property, which we learned from Simpson
and Plotkin [2000].
147

Lemma 25. EFPs induced by a (strong or weak) fixed point combinator satisfy the
following equation: for any f : B × A → A and g : C → B,
(f ◦ (g × idA ))† = f † ◦ g
Proof. We have
(f ◦ (g × idA ))† = Y ◦ λ (f ◦ (g × idA )) = Y ◦ λ(f ) ◦ g = f † ◦ g
by naturality of the λ(−) operation.
It is easy to extend the cartesian version of Lawvere’s theorem to one that also
yields fixed points with parameters: we redefines weak point-surjections to include a
parameter.
Definition 51 (Parametric weak point-surjection). An arrow r : X × A → Y is a
parametric weak point-surjection if for every f : B ×A → Y there exists a xf : B → X
such that
∀a : B → A. r ◦ hxf , ai = f ◦ hidB , ai
The only change in the main theorem is that the fixed points of an arrow of type
B × Y → Y now have type B → Y instead of being points of Y .
Theorem 58 (Parametric Recursion). If r : A × A → Y is a parametric weak-point
surjection, then every arrow
t:B×Y →Y
has a EFP.
Proof. Let
idB ×hidA ,idA i

def

id ×r

t

f = B × A −−−−−−−−→ B × (A × A) −−B−→ B × A →
− A
Then there exists a xf : B → A such that
r ◦ hxf , ai = f ◦ a
for all a : B → A. Then
r ◦ hxf , xf i
= { definition of parametric weak point-surjection }
t ◦ (idB × r) ◦ (idB × hidA , idA i) ◦ hidB , xf i
= { various product equations }
t ◦ hidB , r ◦ hxf , xf ii
so that r ◦ hxf , xf i is a EFP of t.
148

7.3.2

Intensional Fixed Points with Parameters

Without further ado, we generalise IFPs to include parameters.
Definition 52. Let (Q, , δ) be a product-preserving comonadic exposure. A paraQ
metric intensional fixed point (parametric IFP) of f : ni=1 QBi × QA → A (w.r.t.
Q) is an arrow
†

f :

n
Y

QBi → A

i=1

such that the following diagram commutes up to ∼:
∗

Qn

i=1

QBi

hid,(f † ) i

Qn

i=1

QBi × QA

f†
f

A
∗ Q
Q
Q
If f : ni=1 QBi × QA → A, then f † : ni=1 QBi → A, so f † : ni=1 QBi → QA, so
this diagram has the right types.
This definition is a generalisation analogous to the one for EFPs. The context is
Q
Q
intensional ( ni=1 QBi ) instead of extensional (B = ni=1 Bi ), and f † appears under
the co-Kleisli lifting, so essentially under an occurrence of Q. Notice that we have used
•
both product-preservation and the quoter δ : Q # Q2 for this definition; this probably
corresponds to the fact that that the 4 axiom (A → A) is a theorem of provability
logic: see [Boolos, 1994, Kavvos, 2017b,c]. Since we are in a categorical logic setting,
an appropriate gadget standing for the 4 axiom must be given as a primitive, alongside
appropriate coherence conditions (e.g. the first comonadic equation).
Definition 53 (Intensional Fixed Points with Parameters). Let (Q, , δ) be a productpreserving comonadic exposure on B. We say that B has parametric intensional fixed
points at A (parametric IFPs) just if for any objects Bi ∈ C there exists an operation
!
!
n
n
Y
Y
(−)†−→ : B
QBi × QA, A 99K B
QBi , A
Bi

such that for each arrow f :

i=1

i=1

Qn

i=1

QBi × QA → A, the arrow f † :

Qn

i=1

QBi → A is

an intensional fixed point of f .
−
→
We often write f † for succinctness, without specifying the context Bi .
In analogy to EFPs, there is a similar ‘internal’ view of this definition, related
to the Gödel-Löb axiom. However, in contrast to what we had before, it comes with
certain caveats. But first, some more definitions:
149

Definition 54 (Intensional Fixed Point Combinators). Let there be a cartesian closed
P-category B, along with a product-preserving comonadic exposure (Q, , δ) on it.
1. A strong intensional fixed point combinator at A (w.r.t. Q) is an arrow
Y : Q(AQA ) → QA
such that the following diagram commutes up to ∼:
Q(AQA )

h,Y i

AQA × QA
ev

Y

QA



A

2. A weak intensional fixed point combinator (w.r.t. Q) is an arrow
Y : Q(AQA ) → QA
such that, for each f :

Qn

n
Y

i=1

QBi × QA → A, the arrow

 Y
(λ(f ))∗
A
QBi −−−−→ Q AQA −
→ QA −→
A

i=1

is a IFP of f .
Theorem 59. Let B be a cartesian closed P-category, along with a product-preserving
comonadic exposure (Q, , δ) on it.
1. If (Q, , δ) is idempotent then a strong fixed point combinator is also a weak fixed
point combinator.
2. A weak fixed point combinator Y : Q(AQA ) → QA implies the existence of
intensional fixed points at A.
3. The existence of intensional fixed points at A implies the existence of a strong
intensional fixed point combinator at A.
Proof.

150

1. Let Y : Q(AQA ) → QA be a strong FPC. Then, given f :

Qn

i=1

QBi × QA → A,

we may calculate that
 ◦ Y ◦ (λf )∗
∼ { definition of strong FPC }
ev ◦ h, Y i ◦ (λf )∗
∼ { naturality of product, Proposition 13 (ii) }
ev ◦ hλf, Y ◦ (λf )∗ i
∼ { cartesian closure }
f ◦ hid, Y ◦ (λf )∗ i
But as Q is idempotent and Y ◦ (λf )∗ :

Qn

i=1

QBi → QA, we can use quotation-

evaluation (Corollary 6) to conclude that ( ◦ Y ◦ (λf )∗ )∗ ≈Q Y ◦ (λf )∗ , and
hence that we have a IFP.
2. Trivial.
3. Let
×id

def

ev

g = Q(AQA ) × QA −−→ AQA × QA −
→A
Then we can show that (g † )∗ : Q(AQA ) → QA is a strong FPC. It is easy to
∗
calculate that g † ∼ ev ◦ h, g † i and hence that
 ◦ g†

∗

∗
∼ g † ∼ ev ◦ h, g † i

by using Proposition 13 (ii).

It is interesting to examine if and when the map (−)† might turn ≈Q to ∼, or
even preserve it. In fact, it is easy to see that if λ(−) preserves ≈Q , then we can build
a (−)† that turns it into ∼: a weak FPC suffices. If Q is idempotent then (−)† also
preserves ≈Q .
Lemma 26. If Y : Q(AQA ) → QA is a weak FPC, and the map
λC (−) : C(C × A, B) → C(C, B A )
preserves the intensional equality ≈Q , i.e. is a map
λC (−) : (C, ≈Q )(C × A, B) → (C, ≈Q )(C, B A )
151

then the IFPs induced by f † = A ◦ Y ◦ (λ(f ))∗ turn ≈Q into ∼, i.e. (−)† is a map
!
!
n
n
Y
Y
(−)† : (B, ≈Q )
QBi × QA, A → B
QBi , A
def

i=1

i=1

Moreover, if Q is idempotent, then (−)† preserves ≈Q , and hence is a map
!
!
n
n
Y
Y
(−)† : (B, ≈Q )
QBi × QA, A → (B, ≈Q )
QBi , A
i=1

i=1
∗

Proof. Since λ(−) preserves ≈Q (by assumption), and (−) turns that into ∼ (§7.1)
the result follows. In the case of idempotence observe that (−)∗ also preserves ≈Q
(Corollary 5), and so does post-composition with  ◦ Y .
A similar argument will yield that, if λ(−) is natural up to ≈Q , then so are the fixed
points in a certain sense.
Lemma 27. If (Q, , δ) is idempotent, Y : Q(AQA ) → QA is a weak FPC, and
λC (−) : C(C × A, B) → C(C, B A )
is natural up to ≈Q , i.e.
λ (f ◦ (g × id)) ≈Q λ(f ) ◦ g
then the IFPs induced by f † = A ◦Y ◦(λ(f ))∗ are also natural, i.e. for f :
Q
Q
QA → A and k : kj=1 QCj → ni=1 QBi , we have
def

Qn

i=1

QBi ×

(f ◦ (k × id))† ≈Q f † ◦ k
Proof. Use naturality for λ(−) up to ≈Q , Corollary 5 for the preservation of ≈Q by
(−)∗ , and finally Proposition 12 (vii) to show that (λ(f ) ◦ k)∗ ≈Q (λ(f ))∗ ◦ k.
There is also a weaker version of this lemma that does not require idempotence: it
Q
Q
†
states that if f : ni=1 QBi ×QA → A and gi : Ci → Bi , then (f ◦ ( ni=1 Qgi × id)) ∼
Q
f † ◦ ni=1 gi . However, we do not find any use for it in the sequel.
We can summarise the above results by saying that if we have
• an idempotent comonadic exposure (Q, , δ);
• any of our three flavours of IFPs (strong, weak, (−)† );
• a λ(−) that preserves ≈Q and is natural up to it
then we obtain IFPs at A, which preserve ≈Q and are natural up to ≈Q . While this
is nice and useful, we will see in §8.6 that in the most intensional of P-categories it
will emphatically not be the case that λ(−) preserves ≈Q .
152

7.4

A Parametric Intensional Lawvere Theorem

In the final section of this chapter we shall generalise the Intensional Recursion Theorem (Theorem 54) to a version that admits parameters. The theorem will now
guarantee the existence of parametric IFPs.
Accordingly, we will have to also change the antecedent: neither weak pointsurjections (Def. 47) nor parametric weak point-surjections (Def. 51) are adequate
anymore. We shall therefore introduce a variant, which—due to lack of imagination on
the part of the author—we shall call an intensional parametric weak point-surjection.
The only essential difference is the restriction of the arbitrary context B to an intenQ
sional one, viz. of the form ni=1 QBi .
Definition 55 (IPWPS). An arrow r : X × A → Y is a intensional parametric
Q
weak point-surjection (IPWPS) if, for every f : ni=1 QBi × A → Y , there exists a
Q
xf : ni=1 QBi → X such that
∀a :

n
Y

QBi → A. r ◦ hxf , ai = f ◦ hid, ai

i=1

Armed with this, we can now prove a theorem analogous to the Parametric Recursion
Theorem (Theorem 58), but yielding IFPs instead. Recall that in the Intensional
Recursion Theorem (Theorem 54) we only needed a particular component of δ to be
‘reasonable,’ but in this case we will require full idempotence.
Theorem 60 (Parametric Intensional Recursion). Let (Q, , δ) be a product-preserving
idempotent comonadic exposure. If r : QA × QA → Y is a IPWPS, then every arrow
t:

n
Y

QBi × QY → Y

i=1

has an intensional fixed point.
Proof. Let
def

f=

n
Y

id×hid,idi

QBi × QA −−−−−→

n
Y

i=1

QBi × (Q2 A × Q2 A)

i=1
id×r∗

−−−→

n
Y
i=1

t

→
− Y

153

QBi × QY

Then, there exists a xf :

Qn

i=1

QBi → QA such that
r ◦ hxf , ai ∼ f ◦ hid, ai

for all a :

Qn

i=1

QBi → QA. We compute that
r ◦ hxf , xf i
∼

{ definition of IPWPS }
t ◦ (id × r∗ ) ◦ (id × hid, idi) ◦ hid, xf i

≈Q { product equation, naturality of brackets }
t ◦ hid, r∗ ◦ hxf , xf ii
≈Q { idempotence: Prop. 12(vii) }
t ◦ hid, (r ◦ hxf , xf i)∗ i
so that r ◦ hxf , xf i is a IFP of t.
Notice that we are allowed to use Proposition 12(vii) only because hxf , xf i :

Qn

i=1

QBi →

QA × QA is of the right type, i.e. there are occurrences of Q ‘guarding’ all the types.

Naturality
As we saw in §7.3.2, the main reason for introducing parametric IFPs is to have a conQ
text ni=1 QBi . In turn, a context is useful because one can substitute for any objects
in it, as they represent free variables. In this light, naturality is a key property: it
states that substitution (composition) commutes with the (type-theoretic/categorical)
construct in question; we will discuss that more in §8.
We showed in Lemmata 26 and 27 that, in the idempotent setting, if IFPs are
induced by a weak FPC, and λ(−) preserves ≈Q , then so does (−)† , and moreover it is
natural. But what about the IFPs produced by the Parametric Intensional Recursion
Theorem?
A IPWPS r : QA × QA → Y induces a map
f:

n
Y

QBi × QA → Y 7−→ xf :

i=1

n
Y

QBi → QA

i=1

Q
Q
and then we can define (−)† : B ( ni=1 QBi × QY, Y ) 99K B ( ni=1 QBi , Y ) to be
t 7−→ ft 7−→ xft 7−→ r ◦ hxft , xft i :
def

where ft = t ◦ (id × r∗ ) ◦ (id × hid, idi) :

Qn

i=1

154

QBi × QA → Y .

The final map xft 7→ r ◦ hxft , xft i is clearly natural and preserves both ∼ and ≈Q ,
as h·, ·i does. But what about the rest? Suppose that we pre-compose t with g × id,
Q
Qn
where g : m
QD
→
j
j=1
i=1 QBi . The map t 7→ ft clearly preserves both ∼ and ≈Q ,
and moreover it is natural, in the sense that
ft◦(g×id) ≈Q ft ◦ (g × id)
because of the interchange law for cartesian products, which holds up to ≈Q .
This leaves only the difficult case of f 7→ xf . For naturality, we would need1
xft◦(g×id) ≈Q xft ◦ g
which easily follows if f 7→ xf preserves ≈Q , and2
xh◦(g×id) ≈Q xh ◦ g
In that case xft◦(g×id) ≈Q xft ◦(g×id) ≈Q xft ◦ g, and hence
(t ◦ (g × id))† ≈Q r◦hxft◦(g×id) , xft◦(g×id) i ≈Q r◦hxft ◦g, xft ◦gi ≈Q r◦hxft , xft i◦g ≈Q t† ◦g
Hence, to obtain naturality we would need that the IPWPS be ‘natural,’ and that
f 7→ xf turn ≈Q to ∼.
Corollary 7. If the IPWPS r : QA × QA → Y of Theorem 60 is such that f 7→ xf
preserves ≈Q (or, equivalently, turns ≈Q into ∼), and is ‘natural’ insofar as
xf ◦(g×id) ≈Q xf ◦ g
(equivalently, with ∼) then the induced (−)† is a map
!
!
n
n
Y
Y
(−)† : (B, ≈Q )
QBi × QY, Y → (B, ≈Q )
QBi , Y
i=1

i=1

which is natural up to ≈Q , i.e.
(f ◦ (g × id))† ≈Q f † ◦ g

1
2

Note that because of idempotence and the type of xf , ∼ suffices.
Ditto.

155

Chapter 8
Intensional Semantics of iPCF II
In this final chapter, we shall use all our results up to this point to attempt to
produce an intensional semantics for iPCF. The intended—but, as it transpires,
unachievable—result is that the category of assemblies Asm(K1 ) is a model of iPCF.
We have shown in previous chapters that a product-preserving comonadic exposure
satisfies most of the standard equations of a product-preserving comonad. It should
therefore be the case that, given such an exposure, one can use it to almost directly
interpret the Davies-Pfenning fragment of iPCF. However, this is not so straightforward. The main ingredient of our soundness result is a substituion lemma, which
relates the interpretation with substition. Since we are allowed to substitute terms
under box (−) constructs—which we model by (−)∗ —we need the substitution lemma
to hold up to ≈Q at that location. Furthermore, since we may have multiple nested
occurrences of boxes, we will need that (−)∗ preserve ≈Q , which is the case if the
comonadic exposure is idempotent (Cor. 5). Thus idempotence is essential.
Once this is decided, we run into a second issue. Suppose that there is a λ in a
term, which we model by the function λ(−) of a cartesian closed category. Since this
λ might occur in the scope of a box (−), and a (modal) variable for which we want to
substitute might occur under that λ, the above soundness result requires that λ(−) be
natural up to ≈Q . Whereas in the case of Asm(K1 ), the exposure is idempotent, we
have no guarantees at all about the naturality of λ(−)—see §5.2.5. We will therefore
need to forbid λ-abstractions with free variables under boxes.
The above suffices to interpret the Davies-Pfenning fragment, in an intensional
sense. The remaining piece of the puzzle pertains to the construction of IFPs. This is
easy for booleans and naturals, but at higher types we are only able to use an inductive
construction that only builds IFPs for a certain kind of intensional exponential ideal :
if X is any object and Y is in the ideal, then Y QX is in the ideal as well. We also
face certain difficulties in showing that the IFPs are natural, as per §7.4, and lack of
156

naturality entails lack of substitution. It follows that we must constrain the taking of
IFPs to closed terms, at only at certain types.
We are thus led to reformulate iPCF, or—more specifically—to admit only a
subset of it. To reach this subset, we first layer it, so as to separate the intensional
layer —where everything will hold up to ≈Q —and the extensional layer, where things
will hold up to ∼. Since the modality already implicitly enables this kind of layering,
this will be a minor change. Nevertheless, it decisively quells the problem, as we will
never need to substitute in a λ-abstraction under the box, so the desired lemma holds
up to ≈Q at that location. In the case of IFPs, our only option is to alter the fixed
point rule.
The resulting language is called iPCF v2.0. On the one hand, the new language
has Asm(K1 ) as a model; on the other, a lot of expressiveness has been lost. We
discuss what has been lost, and when one can regain it. In particular, we can model
iPCF itself when given a natural iPCF v2.0 model. Furthermore, a weakly extensional
model of iPCF v2.0 is already natural; the terminology comes from PCAs: if A is a
weakly extensional PCA, then Asm(A) is a weakly extensional model, and hence a
model of iPCF; see also §5.2.5.

8.1

iPCF v2.0

We promptly introduce iPCF v2.0. We shall not prove any theorems in this section,
because we have formally proven all of them in Agda: see Appendix A for the proofs.
Each typing judgement of iPCF v2.0 will be annotated by a J , like so:
∆ ; Γ `J M : A
The possible options for J will be “int.” for intensional, and “ext.” for extensional.
The revised system appears in Figure 8.1. The occurrence of a generic J in these
rules is universally quantified. There is little else to say apart from the fact that these
rules enforce the prohibition of free variables under a λ in the intensional judgements.
In programming language terms this could be transliterated as the prohibition of the
creation of closures (= λ-abstraction + environment for free variables). Of course,
a term can then only be placed under a box if it is intensional, but the boxed term
itself can be either intensional or extensional:
∆ ; · `int. M : A
∆ ; Γ `J box M : A

157

Figure 8.1: Syntax and Typing Rules for Intensional PCF v2.0
::= Nat | Bool

Ground Types G

::= G | A → B | A

Types A, B

::= G | A → Afix

Fixable Types Afix

Terms M, N ::= x | λx:A. M | M N | box M | let box u ⇐ M in N |
n
b | true | false | succ | pred | zero? | ⊃G | fix z in M
Contexts Γ, ∆

· | Γ, x : A

::=

(b ∈ {true, false})

∆ ; Γ `J n
b : Nat

∆ ; Γ `J b : Bool

∆ ; Γ `J zero? : Nat → Bool

∆ ; Γ `J f : Nat → Nat

(f ∈ {succ, pred})

∆ ; Γ `J ⊃G : Bool → G → G → G
∆ ; Γ, x:A, Γ0 `J x : A

(var)

∆ ; Γ, x:A `ext. M : B
∆ ; Γ `ext. λx:A. M : A → B
∆ ; · `int. M : A
∆ ; Γ `J box M : A

(→ I)

(I)

∆, u:A, ∆0 ; Γ `J u : A
∆ ; Γ `J M : A → B

(var)

∆ ; Γ `J N : A

∆ ; Γ `J M N : B
∆ ; Γ `J M : A

∆, u:A ; Γ `J N : C

∆ ; Γ `J let box u ⇐ M in N : C

· ; z : Afix `int. M : Afix
∆ ; Γ `J fix z in M : Afix
· ; x:A `J M : B
∆ ; Γ `int. λx:A. M : A → B

158

(→ E)

(fix)

(→ Iint. )

(E)

We can only λ-abstract in an extensional term, yielding another extensional term:
∆ ; Γ, x:A `ext. M : B
∆ ; Γ `ext. λx:A. M : A → B
But if this term has no other free variables, then the result can be an intensional term.
Of course, we must not forget to include the ‘opportunity’ to weaken the context:
· ; x:A `J M : B
∆ ; Γ `int. λx:A. M : A → B
We shall also change the rule for intensional fixed points, which now reads
· ; z : Afix `int. M : Afix
∆ ; Γ `J fix z in M = M [box (fix z in M )/z] : Afix

(fix)

So fix z in M recurses, but it can only do so when M is closed to everything else save
the ‘diagonal’ variable z. What is more, we can only invoke this rule for types Afix
generated by the following grammar, where A is any type at all:
Afix

::=

Nat | Bool | A → Afix

Theorem 61. The following rules are admissible in iPCF v2.0:
∆ ; Γ `J M : A

∆ ; Γ `int. M : A

∆ ; Γ `ext. M : A

∆ ; Γ `J M : A

The standard admissibility results for iPCF are also valid in iPCF v2.0, but they are
now parametric in J .
Theorem 62 (Structural). The standard structural rules of iPCF (as stated in Theorem 21) are admissible in iPCF v2.0, parametrically up to J .
The situation with the cut rule, however, is slightly more complicated, and this has
to do with the nature of the term being substituted. If we substitute an intensional
term for a variable, the resulting term will still retain its original disposition (int. or
ext.). However, if we substitute an extensional term, we force the resulting term to
be extensional. Similarly, and because of (I), we may only substitute an intensional
term for a modal variable, and that leaves the disposition of the term invariant.
Theorem 63 (Cut for iPCF v2.0). The following rules are admissible in iPCF v2.0.
1. (Cut-Ext)
∆ ; Γ, x:A, Γ0 `J M : A

∆ ; Γ `ext. N : A

∆ ; Γ, Γ0 `ext. M [N/x] : A
159

2. (Cut-Int)
∆ ; Γ, x:A, Γ0 `J M : A

∆ ; Γ `int. N : A

∆ ; Γ, Γ0 `J M [N/x] : A
3. (Modal Cut)
∆ ; · `int. N : A ∆, u:A, ∆0 ; Γ `J M : C
∆, ∆0 ; Γ `J M [N/u] : C
In light of those theorems we reformulate the equational theory of iPCF (Figure
3.3) for iPCF v2.0. The resulting theory can be found in Figure 8.2. Curiously, we see
that a form of the congruence rule for  reappears, even though the considerations of
Davies and Pfenning led us to banish such rules in §3. When proving soundness, we
will see that this rule reflects the fact shown in Corollary 5, viz. that (−)∗ preserves
intensional equality ≈Q .

Expressitivity of iPCF v2.0
It is easy to see that every typing judgment of iPCF v2.0 is also a typing judgment
of iPCF: each rule of v2.0 is a special case of the rule for iPCF. Hence, iPCF v2.0 is
in some sense a proper subset of iPCF.
We can thus conclude that, by moving to v2.0, we have lost some expressivity.
This is centred around three limitations:
1. no free variables under λ-abstractions in the modal/intensional fragment, i.e.
under a box (−);
2. IFPs can only be taken when there is exactly one free variable, the diagonal
variable, and that must be of modal type; and
3. IFPs can only be taken at certain types
The first limitation is, in a way, double-edged. On the one hand, it is reasonable
and familiar from someone coming from the computability theory, especially from the
perspective of Jones [1997]. Indices do not have “free variables”; sometimes they are
meant to have more than one argument, and in those cases we use the s-m-n theorem
to substitute for one of those; this can be simulated here using λ-abstraction. On
the other hand, this limitation invalidates every single one of the original examples of
S4-typed staged metaprogramming of Davies and Pfenning [2001] (power, acker, ip,
etc.—see §7 of that paper): in almost all cases, a box (−) containing a λ-abstraction
with free variables is implicated in the result.
160

Figure 8.2: Equational Theory for Intensional PCF v2.0

Function Spaces

∆ ; Γ `ext. N : A

∆ ; Γ, x:A, Γ0 `J M : B

∆ ; Γ, Γ0 `ext. (λx:A.M ) N = M [N/x] : B
∆ ; Γ `J M : A → B

x 6∈ fv(M )

∆ ; Γ `ext. M = λx:A.M x : A → B

(→ β)

(→ η)

Modality

∆ ; · `int. M : A

∆, u : A ; Γ `J N : C

(β)

∆ ; Γ `J let box u ⇐ box M in N = N [M/x] : C
∆ ; Γ `int. M : A
∆ ; Γ `J let box u ⇐ M in box u = M : A
∆ ; · `int. M = N : A
∆ ; Γ `J box M = box N : A

(η)

(cong)

· ; z : A `int. M : A
∆ ; Γ `J fix z in M = M [box (fix z in M )/z] : A
∆ ; Γ `J M = N : A

(fix)

∆ ; Γ `J P = Q : C

∆ ; Γ `J let box u ⇐ M in P = let box u ⇐ N in Q : B

(let-cong)

Remark. In addition to the above, one should also include (a) rules that ensure
that equality is an equivalence relation, (b) congruence rules for λ-abstraction and
application, and (c) rules corresponding to the behaviour of constants, as e.g. in
Figure 3.2.

161

The second limitation seems reasonably innocuous, but it is actually more severe
than it looks. As an example, it renders the intensional fixed-point combinator —
whose type is the Gödel-Löb axiom, see §3.4—untypable:
def

YA = λx : (A → A). let box f ⇐ x in box (fix z in f z)
6` YA : (A → A) → A
Notice the characteristic occurrence of f within the fix z in (−) construct. This particular limitation is severe, and increases the distance between iPCF and provability
logic: Löb’s rule does not even imply the Gödel-Löb axiom. This has to do with the
‘loss of naturality’ that occurs when we constrain the fixed point rule: the  in the
antecedent (A → A) means that ‘only code variables can be found in the input
data,’ and this is too weak an assumption to use Löb’s rule, which requires exactly
one free variable, the diagonal one. This could be fixed by redefining box (−) to
only enclose completely closed terms, but then we completely obliterate the expressive content of iPCF. If we did that, modal types would not be useful for anything
at all, leading us to add more and more combinators that do specific things, e.g.
something like app : (A → B) → A → B with a δ-reduction of the form
app (box F )(box M ) → box F M . We are not sure that this approach is sustainable.
The relationship of this second limitation with computability theory is more subtle. Using the SRT on a program with a ‘free variable’ made no sense at all, as using
it on a program with ‘two arguments’ was the norm; thus, not much seems to be lost.
However, we remind the reader that ‘constructive’ versions of the SRT are available
in computability theory, e.g. there is a a partial recursive function n(−) that, given
an index e, returns n(e) which would be a sort of IFP of e: see §2.1.2. These, one
would expect, are intensional fixed point combinators. The fact that we cannot define an intensional fixed-point combinator with the Gödel-Löb axiom as type means
that this is not possible to do within iPCF v2.0, not unless we redefine  to mean
completely closed. This is a serious limitation towards the goal of making iPCF v2.0
a typed ‘language of indices’ that works more or less in the style of Jones [1997]. The
only way out of this impasse would be to show that our intended model is natural, so
that we could model iPCF itself. We discuss this further in §8.4.

8.2

Interpreting iPCF v2.0

We have finally made it to the categorical interpretation of iPCF v2.0, which we will
use the algebraic machinery developed in §7 to define. We assume that the reader
162

has some background on the categorical semantics of simply-typed λ-calculus. Useful
expositions include the classics by Lambek and Scott [1988] and Crole [1993], as well
as the detailed presentation of Abramsky and Tzevelekos [2011]. For the details of
the categorical semantics of modal λ-calculi see [Kavvos, 2017b,c].
First, we define the notion of a iPCF v2.0 model.
Definition 56 (iPCF v2.0 model). An iPCF v2.0 model consists of
(i) a cartesian closed P-category (C, ∼, ×, 1);
(ii) a product-preserving idempotent comonadic exposure (Q, , δ);
(iii) a choice of objects N and B, suitable for interpreting the constants (see Hyland
and Ong [2000]); and
(iv) maps (−)† yielding IFPs at all the objects generated by
I

::=

B | N | I QZ

for all Z ∈ C, as per Definition 53.
Given an iPCF v2.0 model we define an object JAK ∈ C for every type A of iPCF, by
induction:
def

JNatK = N
def

JBoolK = B
def

JA → BK = JBKJAK
def

JAK = Q JAK

Then, given a well-defined context ∆ ; Γ where ∆ = u1 :B1 , . . . un :Bn and Γ =
x1 :A1 , . . . , xm :Am , we let
def

J∆ ; ΓK = QB1 × · · · × QBn × A1 × · · · × Am
where the product is, as ever, left-associating.
We then extend the semantic map J−K to one that associates an arrow
J∆ ; Γ ` M : AK : J∆ ; ΓK → JAK
of the P-category C to each derivation ∆ ; Γ ` M : A. The full definition is given in
Figure 8.3. The map
∆;Γ
π∆
: J∆ ; ΓK → J∆ ; ·K

163

Figure 8.3: Categorical Semantics for Intensional PCF v2.0

J∆ ; Γ, x:A, Γ0 `J x : AK = π : J∆ ; Γ, x:A, Γ0 K −→ JAK
def

J∆, u:A, ∆0 ; Γ `J u : AK = A ◦ π : J∆, u:A, ∆0 ; ΓK → JAK → JAK
def

def

J∆ ; Γ `ext. λx:A.M : A → BK = λ (J∆ ; Γ, x : A `ext. M : BK) : J∆ ; ΓK −→ JBKJAK


def
1,JAK
◦ ! : J∆ ; ΓK −→ JBKJAK
J∆ ; Γ `int. λx:A.M : A → BK = λ J· ; x : A `int. M : BK ◦ π2
def

J∆ ; Γ `J M N : BK = ev ◦ hJ∆ ; Γ `J M : A → BK , J∆ ; Γ `J N : AKi
def
−
→
J∆ ; Γ `J let box u ⇐ M in N : CK = J∆, u:A ; Γ `J N : CK ◦ h−
π→
∆ , J∆ ; Γ `J M : AK , πΓ i

Definitions for modal rules

∆;Γ
J∆ ; Γ `J box M : AK = J∆ ; · `int. M : AK∗ ◦ π∆
def

J∆ ; Γ `J fix z in M : AK = J· ; z : A `int. M : AK† ◦ !
def

164

−
→
is the obvious projection. Moreover, the notation h−
π→
∆ , f, πΓ i stands for
−
→ def
h−
π→
∆ , f, πΓ i = hπ1 , . . . , πn , f, πn+1 , . . . , πn+m i
The first thing we need to observe is that there is no difference in the interpretation
if the term is intensional or extensional: if a term can be both, it has the same
interpretation.
Lemma 28. If ∆ ; Γ `int. M : A, then
J∆ ; Γ `int. M : AK = J∆ ; Γ `ext. M : AK
where = stands for strict equality.

8.3

Soundness

The main tools in proving soundness of our interpretation are (a) lemmas giving the
categorical interpretation of various admissible rules, and (b) a fundamental lemma
relating substitution of terms to composition in the category. In the sequel we often
~ for the context
use informal vector notation for contexts: for example, we write ~u : B
~ /~u] for the simultaneous, capture-avoiding
u1 : B1 , . . . , un : Bm . We also write [N
substitution [N1 /u1 , . . . , Nm /un ].
First, we interpret weakening and exchange.
Lemma 29 (Semantics of Weakening).
1. Let ∆ ; Γ, x:C, Γ0 `int. M : A with x 6∈ fv (M ). Then
J∆ ; Γ, x:C, Γ0 `int. M : AK ≈Q J∆ ; Γ, Γ0 `int. M : AK ◦ π
where π : J∆ ; Γ, x:C, Γ0 K → J∆ ; Γ, Γ0 K is the obvious projection.
2. Let ∆ ; Γ, x:C, Γ0 `ext. M : A with x 6∈ fv (M ). Then
J∆ ; Γ, x:C, Γ0 `ext. M : AK ∼ J∆ ; Γ, Γ0 `ext. M : AK ◦ π
where π : J∆ ; Γ, x:C, Γ0 K → J∆ ; Γ, Γ0 K is the obvious projection. If the iPCF

model is weakly extensional (see §8.4) then the result holds up to ≈Q .
3. Let ∆, u:B, ∆0 ; Γ `int. M : A with u 6∈ fv (M ). Then
J∆, u:B, ∆0 ; Γ `int. M : AK ≈Q J∆, ∆0 ; Γ `int. M : AK ◦ π
where π : J∆, u:B, ∆0 ; ΓK → J∆, ∆0 ; ΓK is the obvious projection.
165

4. Let ∆, u:B, ∆0 ; Γ `ext. M : A with u 6∈ fv (M ). Then
J∆, u:B, ∆0 ; Γ `ext. M : AK ∼ J∆, ∆0 ; Γ `ext. M : AK ◦ π
where π : J∆, u:B, ∆0 ; ΓK → J∆, ∆0 ; ΓK is the obvious projection. If the iPCF

model is weakly extensional (see §8.4) then the result holds up to ≈Q .
Proof. By induction on the derivations. Most cases are straightforward.

The first one holds up to ≈Q because it essentially consists of projecting away
components, which holds intensionally: the fact the judgement is intensional means
no λ’s are involved.
The second one holds only up to ∼, because of the occurrence of λ(−)’s in the
semantics. If moreover the model is weakly extensional, λ(−) preserves ≈Q (Cor.
5) so we can strengthen the inductive hypothesis to ≈Q and obtain the result up to
intensional equality.
The third one also follows easily. In the case of a box (−), the term within it
is intensional, so we use the induction hypothesis and the fact1 (−)∗ preserves ≈Q .
We then know that (−)∗ is natural for projections (Prop. 12(vi)) up to ≈Q (due to
idempotence). There is not much to show in the case of fix z in (−), as no modal
variables occur freely under it.
The fourth one is perhaps the most complicated, and only holds up to ∼, again
because of the occurrence of λ(−)’s. In the case of box (−), the term within it is
intensional, so we use the third result and the fact (−)∗ preserves ≈Q , followed again
by naturality for projections. The case of fix z in (−) is again trivial.
We can also show that the components of the interpretation interact in the expected
way with the corresponding term formation rules in the language. These follows
from the analogous lemmata in §7.1, which show that the necessary equations hold
intensionally in a iPCF model, i.e. when the exposure Q is idempotent.
Lemma 30 (Double box). If ∆ ; · `J M : A, then

1

J∆ ; Γ `J box (box M ) : AK ≈Q δA ◦ J∆ ; Γ `J box M : AK

This is where idempotence is essential, otherwise this would hold only up to ∼ and the inductive
hypothesis for box (−) would fail.

166

def

Proof. Let f = J∆ ; · `J M : AK. Then
J∆ ; Γ `J box (box M ) : AK

≈Q { definitions }
∆;Γ
(f ∗ )∗ ◦ π∆

≈Q { Proposition 13 }
∆;Γ
δA ◦ f ∗ ◦ π∆

≈Q { definitions }
δA ◦ J∆ ; Γ `J box M : AK

Lemma 31 (Identity Lemma). For (ui : Bi ) ∈ ∆,
∆;Γ
J∆ ; Γ `J box ui : Bi K ≈Q πB
i

Proof.
J∆ ; Γ `J box ui : Bi K

≈Q { definition }

∗
∆;·
∆;Γ
Bi ◦ πBi ◦ π∆
≈Q { Proposition 12 }
∆;·
∆;Γ
∗Bi ◦ πB
◦ π∆
i

≈Q { Proposition 12 (ii), projections }
∆;Γ
πB
i

Lemma 32 (Semantics of Substitution). Suppose that ∆ ; Γ `J Mi : Ai for i =
1, . . . , n, and that ∆ ; · `int. Nj : Bj for j = 1, . . . , m, and let
def

βj = J∆ ; Γ `int. box Nj : Bj K
def

αi = J∆ ; Γ `J Mi : Ai K

Then,
~ ; ~x : A
~ `int. P : C, we have
1. if ~u : B
r
z
r
z D−
E
−
~ /~u, M
~ /~x] : C ≈Q ~u : B
~ ; ~x : A
~ `int. P : C ◦ →
∆ ; Γ `J P [N
β ,→
α
167

~ ; ~x : A
~ `ext. P : C, we have
2. if ~u : B
r
z r
z D−
E
−
~ /~u, M
~ /~x] : C ∼ ~u : B
~ ; ~x : A
~ `ext. P : C ◦ →
∆ ; Γ `ext. P [N
β ,→
α
~ ; ~x : A
~ `J P : C. Most cases are
Proof. By induction on the derivation of ~u : B
straightforward, and use a combination of standard equations that hold in cartesian
closed categories—see [Crole, 1993, §2]—in order to perform calculations very close
the ones detailed in [Abramsky and Tzevelekos, 2011, §1.6.5]. Because of the precise
definitions we have used, we also need to make use of Lemma 29 to interpret weakening
whenever variables in the context do not occur freely in the term. We only cover the
modal cases.
Case(var). Then P ≡ ui for some ui amongst the ~u. Hence, the LHS is
∆ ; Γ `int. Ni : Bi , whereas we calculate that the RHS, in either case, is
r
z
~ α
~ ; ~x : A
~ `J P : C ◦ hβ,
~u : B
~i
≈Q { definition, projection }
Bi ◦ J∆ ; Γ `int. box Ni : Bi K

≈Q { definition }

∆;Γ
Bi ◦ J∆ ; · `int. Ni : Bi K∗ ◦ π∆

≈Q { Proposition 13 }

∆;Γ
J∆ ; · `int. Ni : Bi K ◦ π∆

≈Q { Semantics of Weakening (Lemma 29) }
J∆ ; Γ `int. Ni : Bi K
→
− −
→
−
−
−
Case(I). We have that →
u : B ;→
x : A `J box P : C, so that →
u :
→
−
→
−
B ; · `int. P : C, with the result that none of the variables x occur in P . Hence

168

~ /~u, M
~ /~x] ≡ P [N
~ /~u], and we calculate, in either case:
P [N
r
z
~ /~u, M
~ /~x]) : C
∆ ; Γ `J box (P [N
≈Q { definition, and non-occurrence of the ~x in P }
r
z∗
∆;Γ
~
∆ ; · `int. P [N /~u] : C ◦ π∆
≈Q { IH, (−)∗ preserves ≈Q (Corollary 5) }
r
z D −−−−−−−−−−−−−−−−→E∗
∆;Γ
~ ; · `int. P : C ◦ −
~u : B
J∆ ; · `int. box Ni : Bi K
◦ π∆
≈Q { Proposition 12 }
r
z• D−−−−−−−−−−−−−−−−−−→E
~ ; · `int. P : C ◦ J∆ ; · `int. box Ni : Bi K∗ ◦ π ∆;Γ
~u : B
∆

≈Q { naturality of product morphism, definition }
r
z• D−−−−−−−−−−−−−−−−−−−−−−−−→E
~
~u : B ; · `int. P : C ◦ J∆ ; Γ `int. box (box Ni ) : Bi K

≈Q { Double box (Theorem 30), h·, ·i preserves ≈Q }
r
z• D −−−−−−−−−−−−−−−−−−−−−−→E
~ ; · `int. P : C ◦ −
δJBi K ◦ J∆ ; Γ `int. box Ni : Bi K
~u : B

≈Q { product after angled brackets }
n
r
z• Y
D−−−−−−−−−−−−−−−−−−→E
~
~u : B ; · `int. P : C ◦
δJBi K ◦ J∆ ; Γ `int. box Ni : Bi K
i=1

≈Q { some projections and definition of (−)∗ and J−K }
r
z D−
E
−
~ ; ~x : A
~ `J box P : C ◦ →
~u : B
β ,→
α
→
− − →
−
→
−
−
−
x : A `J fix z in P : C, so that →
u : B ;z :
Case(fix). We have that →
u : B ;→
−
C `int. P : C, with the result that none of the variables →
x occur in P . Hence
~ /~u, M
~ /~x] ≡ P [N
~ /~u], and we calculate:
P [N
r
z
~ /~u, M
~ /~x]) : C
∆ ; Γ `J fix z in (P [N
≈Q { definitions; only z is free in P }
J· ; z : C `int. P : CK† ◦ !

≈Q { definition }

J· ; · `int. fix z in P : CK ◦ !

≈Q { projections, definitions }
E
r
z D−
−
~ ; ~x : A
~ `J fix z in P : C ◦ →
~u : B
β ,→
α

Theorem 64 (Soundness).

169

1. If ∆ ; Γ `int. M = N : A, then we have that
J∆ ; Γ `int. M : AK ≈Q J∆ ; Γ `int. N : AK
2. If ∆ ; Γ `ext. M = N : A, then we have that
J∆ ; Γ `ext. M : AK ∼ J∆ ; Γ `ext. N : AK
Proof. By induction on the derivation of ∆ ; Γ ` M = N : A. The congruence cases
are clear, as is the majority of the ordinary clauses. All of these even hold up to ≈Q ,
with the exception of (→ β) and (→ η), which only hold up to ∼. Only the modal
rules remain, which we prove with direct calculation.
For (β) in the case of J = int. we calculate:
J∆ ; Γ `int. let box u ⇐ box M in N : CK

≈Q { definition }

−
→
J∆, u:A ; Γ `int. N : CK ◦ h−
π→
∆ , J∆ ; Γ `int. box M : AK , πΓ i

≈Q { Lemma 31 }

−−−−−−−−−−−−−−−−−→
→i
J∆, u:A ; Γ `int. N : CK ◦ hJ∆ ; Γ `int. box ui : Bi K, J∆ ; Γ `int. box M : AK , −
π
Γ

}
≈Q { Lemma 32; J∆ ; Γ `int. xi : Ai K = πA∆;Γ
i
def

J∆ ; Γ `int. N [~
ui /~
ui , M/u, x~i /~
xi ] : CK

In the case of J = ext., we use Lemma 28 to write J∆ ; Γ `ext. box M : AK =
J∆ ; Γ `int. box M : AK, and then the same calculation works up to ∼.
There remains the case of the fixpoint; let
def

g = J∆ ; Γ `J fix z in M : AK

def

Then g = f † ◦ !, where

def

f = J· ; z : A `int. M : AK

But we can easily calculate that
f†
∼

{ definition of fixpoint (Def. 52) }
∗
f ◦ f†

≈Q { definitions }
f ◦ J· ; · `int. box (fix z in M ) : AK

≈Q { Lemma 32 }

J· ; · `int. M [box (fix z in M )/z] : AK
and hence g ∼ J∆ ; Γ `J M [box (fix z in M )/z] : AK by weakening (Lemma 29).
170

8.4

Natural and Weakly Extensional Models

In iPCF v2.0 we effected three restrictions:
• No free variables when taking intensional fixed points (except the diagonal).
• No λ-abstractions with free variables under boxes.
• IFPs only at certain types generated by Afix .
We discussed at the end of §8.1 the effect that these have on the expressivity of
the language, and found that it was far too strong, so we would like to examine when
these can be lifted.
A iPCF v2.0 model must satisfy certain requirements in order for these restrictions
to be lifted. The first one can be lifted whenever a iPCF model is natural. The second
one can be lifted whenever a iPCF model is weakly extensional. Unfortunately, we
are still at a loss regarding the existence of IFPs at all objects.

8.4.1

Natural iPCF v2.0 models

The first restriction we want to lift is the occurrence of free variables when taking an
intensional fixed point; that is, we want to generalise the (fix) rule to
∆ ; z : Afix `int. M : Afix
∆ ; Γ `J fix z in M : Afix
We will be able to do this in natural models of iPCF v2.0.
Definition 57. An iPCF v2.0 model is natural just if
1. (−)† preserves ≈Q ; and
2. (−)† is natural up to ≈Q , in the sense that for any f :
Q
Q
and k : kj=1 QCj → ni=1 QBi , it is the case that

Qn

i=1

QBi × QA → A

(f ◦ (k × id))† ≈Q f † ◦ k
In this kind of iPCF model, we are free to have parameters in our IFPs, and we can
interpret the Löb rule by
∆;Γ
J∆ ; Γ `J fix z in M : AK = J∆ ; z : A `int. M : AK† ◦ π∆
def

171

The lemmas for weakening (Lem. 29) and substitution (Lem. 32) directly carry
over. Naturality is only used in the appropriate cases for (fix); e.g. here is the case
for substitution:
r
z
~ /~u, M
~ /~x]) : C
∆ ; Γ `J fix z in (P [N
≈Q { definition, and non-occurrence of the ~x in P }
r
z†
~ /~u] : C ◦ π ∆;Γ
∆ ; z : C `int. P [N
∆
≈Q { IH, (−)† preserves ≈Q , definitions }
r
z D −−−−−−−−−−−−−−−−−−−−−→
E†
∆;z:C
∆;Γ
~ ; z : C `int. P : C ◦ −
~u : B
J∆ ; z : C `int. box Ni : Bi K, πz:C
◦ π∆

≈Q { weakening, h·, ·i and (−)† preserve ≈Q }
r
†
z −−−−−−−−−−−−−−−−−−−−−−−−→
∆;z:C
∆;z:C
∆;Γ
~
~u : B ; z : C `int. P : C ◦ J∆ ; · `int. box Ni : Bi K ◦ π∆;·
, πz:C
◦ π∆
≈Q { naturality of products, definition }
r
z D −−−−−−−−−−−−−−−−→E
†
∆;Γ
~ ; z : C `int. P : C ◦ −
~u : B
J∆ ; · `int. box Ni : Bi K × id
◦ π∆
≈Q { naturality of (−)† }
r
z† D −−−−−−−−−−−−−−−−→E
∆;Γ
~ ; z : C `int. P : C ◦ −
~u : B
J∆ ; · `int. box Ni : Bi K ◦ π∆

≈Q { naturality of products, Lemma 29, projections, definitions }
r
z D−
E
−
~ ; ~x : A
~ `J fix z in P : C ◦ →
~u : B
β ,→
α
def

We can also calculate as usual for the fixed point. Let g = J∆ ; Γ `J fix z in M : AK.

∆;Γ
Then g = f † ◦ π∆
, where
def

def

f = J∆ ; z : A `int. M : AK
But we can easily calculate that
f†
∼

{ definition of fixpoint (Def. 52) }
∗
f ◦ hid, f † i

≈Q { definitions }
f ◦ hid, J∆ ; · `int. box (fix z in M ) : AKi

≈Q { Lemma 32 }

J∆ ; · `int. M [box (fix z in M )/z] : AK
and hence g ∼ J∆ ; Γ `J M [box (fix z in M )/z] : AK, by weakening.
172

8.4.2

Weakly Extensional iPCF v2.0 models, or iPCF models

In some cases, we can even rid ourselves of the distinction between intensional and
extensional judgements, eventually reaching a language very close to the one with
which we begun our investigation in §3. The models in which this can occur are
known as weakly extensional.
Definition 58 (iPCF model). An iPCF v2.0 model is weakly extensional —or, more
simply, a iPCF model—just if
1. λ(−) preserves ≈Q , and
2. λ(−) is natural with respect to ≈Q , i.e.
λ(f ◦ (g × id)) ≈Q λ(f ) ◦ g
Before anything else, let us immediately remark that
Lemma 33. A weakly extensional iPCF v2.0 model can be made natural.
Proof. We can use Theorem 59(3) to define a strong intensional fixed point combinator
at every object with IFPs given by (−)∗ . Because Q is idempotent, we can then use
Theorem 59(1) to yield weak fixed point combinators, and then Theorem 59(2) to
induce IFPs anew, by setting
0 def

f † = A ◦ Y ◦ (λ(f ))∗
As Q is idempotent and λ(−) preserves ≈Q , we have—by Lemmata 26 and 27—that
0
0
(−)† preserves ≈Q , and is natural. Thus, we can replace (−)† by (−)† , which results
in a weakly extensional and natural iPCF v2.0 model.
We can use a weakly extensional model to interpret iPCF almost as presented in
its original form in §3: we only need to hold back on the IFPs, and limit them to the
intensional exponential ideal Afix . Of course, we call these models weakly extensional
as the category of assemblies Asm(A) constitutes such a model whenever A is a weakly
extensional PCA: see §5.2.5.
It is not a difficult calculational exercise to show that the main lemmata in this
chapter, i.e. weakening (Lemma 29) and substitution (Lemma 32), hold up to ≈Q ,
with no distinction between extensional and intensional judgements. This happens
because the interpretation of all the main language constructs, i.e. λ(−) and (−)∗ ,
preserve ≈Q .
173

The only exception is the soundness theorem, which only holds up to ∼, and it
does so with good reason. Firstly, we do not expect the equational behaviour of the
constants (naturals, booleans) to be intensional : on account of the language being
partial, we expect both of these objects to have highly intensional structure. But
even if they did not, the cartesian closed equations can realistically be expected to
only hold extensionally (especially η).
However, if asked to name a weakly extensional model of iPCF, we might find ourselves at a loss. The paradigmatic example of a weakly extensional PCA is certainly
Λ/ =β , the closed terms of the untyped λ-calculus quotiented by β-equivalence. The
construction of Asm(Λ/ =β ) and the exposure  on it (§5.2) are parametric in A,
so all that remains is to construct IFPs. But even if we were to construct them, we
might think that we have just engaged in an exercise in futility. The elements of A
would be pairs (a, x) where x ∈ kakA is a realizer of a point x ∈ |A|. But x would be
an equivalence class [P ]=β of an untyped λ-term, which would be an object that is
‘too extensional’ for the level at which we have been aiming: IFPs would merely be
ordinary fixed points of λ-terms!
That leaves us with three choices:
(i) Seek the Holy Grail PCA HG that is weakly extensional, yet sufficiently intensional for IFPs w.r.t. to  in Asm(HG) to be of interest: this seems rather
difficult, perhaps to the point of being a contradiction in terms.
(ii) Try to redefine  : Asm(A) # Asm(A) in the case of a weakly extensional PCA
A. In the previous case we were content to use realizers as the ‘true intensions.’
But how can we proceed this time? One attempt in the case of A consisting of
equivalence classes would be to try to ‘pick’ a representative of each class. But
then for  to respect composition these would have to be ‘compatible’ up to
composition, which seems impossible.
(iii) A third option would be to be in a position to accept that weakly extensional
realizers, such as the terms of Λ/ =β , are sufficiently intensional. This could
be the case of we require a lot of extensionality at the assembly level, perhaps
to the point where a fixed point of an untyped λ-term seems a rather intensional affair. This is again in the spirit described in the introduction (§1.1),
where intensionality is argued to only be defined only relative to the extensional
equality.

174

It is slowly beginning to seem that, in the most intensional of settings, the restrictions we have demanded of iPCF v2.0 are somehow indispensable. We will produce
some further evidence for that in the process of proposing a general method for constructing IFPs at the end of the next section (§8.5): the simplest naturality argument
we can concoct already requires weak extensionality. This may not be proof, but
nonetheless it is solid evidence, as the method described therein is particularly useful
in constructing IFPs for very intensional PCA of classical computability K1 (§8.6).

8.5

Building IPWPSs categorically

In this section we shall show how to build IPWPSs from more basic constructs. If
given sufficiently many IPWPSs in a P-CCC which is equipped with an idempotent
comonadic exposure, then we can use our Parametric Intensional Recursion Theorem
(Theorem 60) to build a iPCF model.
The two main ingredients at our disposal will be a certain kind of retraction, and
a certain kind of enumeration. Both of these are unlike the ones that have been
considered before, and they make deep use of the theory of exposures as developed
in this thesis. Consequently, they have a very intensional flavour.
Our enumerations will be arrows of the form X → A, where A will be the object
enumerated, and X the object of ‘indices.’ To this we will add a factorisation property,
which will be evocative of, or even directly related to, the idea of path surjections as
briefly discussed in §6.3.
To this, we will add a special notion of intensional retraction, which allows one
to represent ‘code’ for objects of the form X QZ (for any Z) as a sort of retract
of X, but only up to extension. We will use these contraptions to formulate an
inductive argument that constructs IPWPSs at all objects contained in the intensional
exponential ideal I generated by the ‘grammar’
I

::=

B | N | I QZ

Throughout this section, let us fix a cartesian closed P-category C, and a comonadic
exposure (Q, , δ) on it.
QX is an object which holds information about ‘codes’ of objects of type X.
These ‘codes’ can often be encoded as very simple first-order data in an object Y ;
for example, Y could be the natural numbers object. Sometimes we might be able
to retrieve the original ‘code’ in QX from Y , making QX a retract of Y . But, in
some cases, we might not: we will only manage to ‘interpret’ the data in Y as data
175

in X, yielding the same extension—but not the same code—as the original one. This
situation is precisely captured by intensional retractions.
Definition 59. X is an intensional retract of Y (w.r.t. Q) whenever there is a pair
of arrows s : QX → Y and r : Y → X such that
s

QX
X

Y

r

X
commutes up to ∼. We call X an intensional retract of Y .
The second concept that is central is that of enumeration. As hinted in §6.3
in the context of various forms of surjections, we can think of arrows X → A as
‘enumerating’ the elements of A by ‘indices’ in X. We will require the existence of a
particular type of path surjection (see §6.3), namely one whose ‘path’ object (denoted
Q
N in §6.3) is an intensional context of the form ni=1 QBi .
Definition 60. An object A ∈ C is (Q, X)-enumerated by e : X → A just if it is a
Q
−
→
( ni=1 QBi )-path surjection for every finite list of objects Bi .
Qn
That is: for every arrow f :
i=1 QBi → A there is at least one arrow φf :
Qn
i=1 QBi → X, not necessarily unique, that makes the diagram
Qn

i=1

QBi
f

φf

X

e

A

commute. We often call the arrow e : X → A a (Q, X)-enumeration, and say that A
is (Q, X)-enumerable.
We are very fond of (Q, X)-enumerations for two reasons. The first reason is
that they are quite easy to construct: the domain of φf provides enough intensional
information in the QBi ’s. It would be essentially impossible to construct something
Q
of the sort given merely a ni=1 Bi . Intuitively, the reason is that the Bi ’s are available extensionally, i.e. as a kind of oracle to which we can pose a (probably finite)
number of questions. It would be unthinkable to internally extract an ‘index’ for the
enumeration e : X → A in such a situation.
The second reason is simply because—under one mild assumption—they directly
give rise to IPWPSs.
176

Lemma 34. If
• A is (Q, X)-enumerated by e : X → A; and
• X QX is an intensional retract of X.
then there is an intensional parametric weak-point surjection p : QX × QX → A.
Proof. Let (s, r) witness X QX as an intensional retract of X. Define
×id

def

r×id

ev

p = QX × QX −−→ X × QX −−→ X QX × QX −
→X
Q
We want to show that this is a IPWPS. Let f : ni=1 QBi × QX → A. Then f can
be written as
n
Y
φf
e
QBi × QX −→ X →
− A
i=1

as e : X → A is a (Q, X)-enumeration. We can λ-abstract the index, and take its
Q
co-Kleisli lifting to obtain (λ(φf ))∗ : ni=1 QBi → Q(X QX ). Post-composing with the
lifted section s∗ : Q(X QX ) → QX yields an ‘index’
def

∗

∗

xf = s ◦ (λ(φf )) :

n
Y

QBi → QX

i=1

w.r.t to p:
p ◦ hs∗ ◦ (λ(φf ))∗ , ai
∼ { definition of p, products after brackets }
e ◦ ev ◦ hr ◦  ◦ s∗ ◦ (λ(φf ))∗ , ai
∼ { Prop. 13, int. retract. }
e ◦ ev ◦ h ◦ (λ(φf ))∗ , ai
∼ { Prop. 13 again }
e ◦ ev ◦ hλ(φf ), ai
∼ { cartesian closure }
e ◦ φf ◦ hid, ai
∼ { e is a (Q, X)-enumeration }
f ◦ hid, ai

177

So much for the construction of IPWPSs given enumerations. What about higher
types? In fact, the following lemma shows that, if X is sufficient to intensionally
encode X QZ , then we can ‘lift’ a (Q, X)-enumeration e : X → A to (Q, X)-enumerate
AQZ . This is where our previous notion of intensional exponential ideal comes from.
Lemma 35. Suppose that
• A ∈ C is (Q, X)-enumerated by e : X → A, and
• X QZ is an intensional retract of X.
Then AQZ is (Q, X)-enumerable.
Qn

QBi → AQZ . Then f ∼ λ(g) for some g :
Q
By IH, we have some φg : ni=1 QBi × QZ → X such that
Proof. Take f :

i=1

Qn

i=1

Qn

i=1

QBi × QZ
g

φg

X

A

e

If we apply λ(−) to this triangle, we obtain
Qn

i=1

QBi
f

λ(φg )

X QZ

eQZ

AQZ

We can now rewrite λ(φf ) ∼  ◦ (λ(φf ))∗ using Proposition 13:
Qn

i=1

QBi

f

(λ(φg ))∗

AQZ
eQZ

Q X QZ




X QZ

But X QZ is an intensional retract of X, so we can rewrite  like so:
Qn

i=1

f

QBi

AQZ

(λ(φg ))∗

Q X QZ

eQZ



X QZ
r

s

X
178

QBi × QZ → A.

Hence, by defining
e0 = eQZ ◦ r : X → E QZ
def

we have that E QZ is (Q, X)-enumerated by e0 , and the index of f is
φf = s ◦ (λ(φg ))∗
def

Theorem 65. Suppose that
• B, N ∈ C are (Q, X)-enumerable, and that
• X QZ is an intensional retract of X for any Z ∈ C.
Then any object in the intensional exponential ideal generated by
I

::=

B⊥

| N⊥

| I QZ

for any Z ∈ C has parametric IFPs.
Proof. We can show by induction that every object generated by I is (Q, X)-enumerable:
the base cases are assumptions, and the inductive step is provided by Lemma 35. Then
by Lemma 34 there is an intensional weak-point surjection pI : QX × QX → I for
every I. Finally, by the Parametric Intensional Recursion Theorem (Theorem 60)
each I has IFPs.
Naturality
It is again worth asking about the necessary premises that are sufficient for us to
conclude that the IPWPSs build in this section are natural in the sense of §7.4.
According to our previous results, we need xh ◦ g ≈Q xh◦(g×id) . We can show that,
under certain assumptions, the construction of a IPWPS from an enumeration in
Lemma 34 maintains it. Calculating suffices to elicit the necessary assumptions:
xh ◦ g
≈Q { definition }
s∗ ◦ (λ(φh ))∗ ◦ g
≈Q { idempotence }
s∗ ◦ (λ(φh ) ◦ g)∗
≈Q { λ(−) natural up to ≈Q }
s∗ ◦ (λ(φh ◦ (g × id)))∗
≈Q { λ(−) preserves ≈Q , φh ◦ (g × id) ≈Q φh◦(g×id) }
s∗ ◦ (λ(φh◦(g×id) ))∗
179

which by definition is xh◦(g×id) . Hence,
Corollary 8. If λ(−) preserves ≈Q and is natural up to it, and moreover the (Q, X)enumeration e : X → A satisfies φh ◦ (g × id) ≈Q φh◦(g×id) then the IPWPS p :
QX × QX → A constructed in Lemma 34 is natural in the sense described at the end
of §7.4.
In turn, an easy calculation shows that if a (Q, X)-enumeration is ‘natural’ in the
above sense then the inductive step of Lemma 35 maintains this property—if λ(−)
preserves ≈Q ! By induction, all the IPWPSs constructed in Theorem 65 are natural.
But we are—so to speak—already preaching to the choir: we have made use of
the naturality and preservation of λ(−) up to ≈Q . Thus, the model is already weakly
extensional, and Lemma 33 already provides a way to make it natural.
At this point, it is beginning to seem like there is no way around weak extensionality. On the one hand, generalising our results to yield natural IFPs seems to already
already weak extensionality. On the other hand, we cannot conceive of a weakly extensional model in which IFPs really are more informative than EFPs. Intensionality
and weak extensionality seem to be at odds with each other. If we take all of this
into account, limiting the fixed point rule to admit no free variables other than the
‘diagonal’ one seems almost forced in the most intensional of settings.

8.6

Asm(K1) as a model of iPCF v2.0

Let us revisit the construction of the P-category of assemblies Asm(K1 ) on the PCA
K1 of classical computability, as described in §5.2. We shall prove that it is a iPCF
model, as per Definition 56. It certainly comes with all the prerequisite structure,
so all we need to check is whether it has (natural) intensional fixed points at all the
relevant objects. We shall construct them using Theorem 65.
Before we proceed with the construction, we need to define some objects of interest.
First, we define the assembly N ∈ Asm(K1 ) of natural numbers by
def

def

knkN = {n}

|N| = N,

We also need to define the assembly N ∈ Asm(K1 ) of booleans by
(
{0}
for b = ff
def
def
|B| = {ff, tt},
kbk =
{1, 2, . . . } for b = tt
At this point we urge the reader to recall the definition of the lifted assemblies N⊥
and B⊥ that we defined for K1 in §5.2.3.
180

Proposition 14. For any assembly Z ∈ Asm(K1 ) there is an intensional retraction
Q N⊥ QZ

s



X

N⊥

r

N⊥ QZ
Proof. For the section part, we define


s : Q NQZ
−→ |N⊥ |
⊥
(f, n) 7−→ n
which is realized by λ∗ nx.n. For the retraction we define
r : |N⊥ | −→ NQZ
⊥
n 7−→ fn
⊥ 7−→ ((z, a) 7→ ⊥)
where
fn : |QZ| −→ |N⊥ |
(
m if n · a · 0 ' m
(z, a) 7−→
⊥ if n · a · 0 ↑
fn is realized by λ∗ ax. n · a · 0, and hence r itself is realized by λ∗ wax. w · 0 · a · 0.
It remains to show that if n ∈ kf kNQZ , then fn = f . In order to show this, the
⊥

first thing we have to note is that N⊥ is a modest set: a realizer can only realize one
def

element of |N⊥ | = N + {⊥}. Thus, if n · a ∈ kxkN⊥ , then necessarily f (z, a) = x: if
f (z, a) = x0 , then we must have n · a ∈ kx0 kN⊥ , so x = x0 . We can thus set up a chain
of equivalences,
f (z, a) = m ⇐⇒ n · a ∈ kmkN⊥ ⇐⇒ n · a · 0 ' m ⇐⇒ fn (z, a) = m
and, similarly,
f (z, a) = ⊥ ⇐⇒ n · a ∈ k⊥kN⊥ ⇐⇒ n · a · 0 ↑ ⇐⇒ fn (z, a) = ⊥

Proposition 15. N⊥ is (, N⊥ )-enumerable.

181

Proof. Suppose (f, r) :

Qn

i=1

QBi → N⊥ . This means that, if ai ∈ kbi kBi for all i then

r · ha1 , . . . , an i ∈ kf ((b1 , a1 ), . . . , (bn , an ))kN⊥
where
def

hai = a
def

ha1 , . . . , am+1 i = pair ha1 , . . . , am i am+1
def

We can then define φ(f,r) = (gr , s) where
gr :

n
Y

QBi −→ |N⊥ |

i=1

((b1 , a1 ), . . . , (bn , an )) 7−→ hr, a1 , . . . , an i
def

which is obviously realizable. Then, define eN⊥ : N⊥ → N⊥ = (h, v) by
h : |N⊥ | −→ N⊥
(
⊥, if (c)1 · h(c)2 . . . (c)n+1 i · 0 ↑
c 7−→
m, if (c)1 · h(c)2 . . . (c)n+1 i · 0 ' m
⊥ 7−→ ⊥
def

where (ha1 , . . . , am i)i = ai . This is realizable, and it is easy to show that the required
diagram
Qn
i=1 QBi
f

φf

N⊥

eN⊥

N⊥

commutes.
Proposition 16. B⊥ is (, N⊥ )-enumerable.
Proof. The same proof as for N⊥ almost works: we only need to slightly alter the
def

definition of eN⊥ = (h, v) : N⊥ → N⊥ to make it into an arrow eB⊥ = (h0 , v) : N⊥ → B⊥
where
h0 : |N⊥ | −→ B⊥


⊥, if (c)1 · h(c)2 . . . (c)n+1 i · 0 ↑
c 7−→ ff, if (c)1 · h(c)2 . . . (c)n+1 i · 0 ' 0


tt, if (c)1 · h(c)2 . . . (c)n+1 i · 0 ' m 6= 0
⊥ 7−→ ⊥
The same realizer works.
182

We thus conclude that
Theorem 66. Asm(K1 ) has intensional fixed points at the intensional exponential
ideal generated by the ‘grammar’
I

::=

B | N | I QZ

for any Z ∈ Asm(K1 ).
Proof. Use Propositions 14, 16, 15 to fulfil the premises of Theorem 65.

183

Chapter 9
Conclusions & Future Work
We briefly peruse what has been achieved in this thesis:
(i) We first attempted to pin down the informal meaning of intensionality as the
possibility of non-functional operations (§1), where non-functionality is understood in the presence of some ambient extensional equality.
(ii) Then, we carefully reviewed the distinction between extensional and intensional
recursion in computability theory (§2).
(iii) This led us to the formulation of a higher-order intensional and reflective programming language, in the form of a modal λ-calculus called Intensional PCF.
This language included genuinely ‘non-functional’ operations, and typed intensional recursion through Löb’s rule. We showed that, if intensionality/‘nonfunctionality’ is limited to modal types, then iPCF is consistent (§3).
(iv) In §4 we began the search for a categorical semantics for that calculus. We
first argued that 1-category theory is not the correct mathematical setting to
speak of intensionality. As an alternative, we proposed P-category theory. We
then proceeded to introduce exposures—a new P-categorical construct which
abstracts the idea of intensional devices, e.g. Gödel numberings. Then, drawing
inspiration from comonads, we developed the theory of exposures.
(v) The claim that exposures are abstractions of intensional devices was substantiated by carefully constructing three rather different examples in §5.
The first one comprises an actual Gödel numbering on Peano Arithmetic.
The second one was drawn from higher-order computability/realizability. If we
think of realizers as machine code, this main example made clear the idea that
exposures expose the implementation.
184

The third one is based on ideas from homological algebra, and constitutes a
first attempt at recognising the occurrence of intensionality in fields beyond
logic and computability.
(vi) Then, in §6, we reformulated to intensional recursion, and showed that it can
be captured through exposures. We proved abstract analogues of classic intensional results, like Gödel’s First Incompleteness Theorem, Tarski’s Undefinability Theorem, and Rice’s Theorem. These results lend credibility to the idea that
exposures are a toolkit where the fine structure of results with an intensional
flavour can be described.
The culmination of this chapter was the Intensional Recursion Theorem (Theorem 54), which set out conditions that guarantee the existence of intensional
fixed points. The Intensional Recursion Theorem can be thought of as an abstract version of Kleene’s Second Recursion Theorem.
(vii) In the final two chapters (§7, §8) we brought iPCF and exposures together.
After some technical development, we showed that a restriction of iPCF, called
iPCF v2.0, can be interpreted in a cartesian closed P-category equipped with a
product-preserving comonadic exposure, and IFPs at appropriate objects.
We then discussed the cases in which the restrictions that plague iPCF v2.0
can be waived. However, we argued that there are good reasons indicating that
lifting those restrictions is at odds with intensionality, at least in the way in
which we understand it.
We closed the thesis by proving that Asm(K1 ), the P-category of assemblies on
K1 , is a model of iPCF v2.0. As K1 is a PCA based on classical computability, this means that iPCF v2.0 is adequate for constructing indices in classical
computability theory: it is a typed ‘intensional metaprogramming’ language for
writing programs in the style of Jones [1997], albeit with limited expressivity.
In the rest of this concluding chapter, we will try to evaluate these achievements. We
would like to focus on four aspects in particular:
• Is intensionality really just the ability to have non-functional operations?
• Are iPCF and iPCF v2.0 adequate intensional and reflective languages?
• How do exposures compare with alternative ‘theories of intensionality’ ?
• Have we managed to elucidate the mysterious Second Recursion Theorem of
Kleene?
185

9.1

Is intensionality really just non-functionality?

The formalisation of Frege’s ideas of sense and reference, which we discussed in §1.1, is
an old problem. Even though many have tried, there does not seem to be a definitive
account. Some even question whether such a definitive account should exist.
Moschovakis [1993] defines the sense of logical formula as the (possibly infinitary)
algorithm that the syntax of a (first-order) formula suggests. This is formalised using
Moschovakis’ own theory of recursive algorithms.
Occupying some middle ground, Abramsky [2014] draws on a long tradition of
programming language semantics. In a sense, he introduced what one could call the
spectrum of intensionality: some kinds of semantics is more intensional than others,
in that the mathematical objects that comprise it contain strictly more information
about the computation that is being modelled, e.g. an account of the interactions
that take place when a program is run. The gist is that, by moving to more refined
semantics, more can be captured, even though a price might have to be paid, perhaps
in the form of quotienting the model. However, we believe that op. cit. is permeated
by a preliminary form of the ideas explicitly developed in this thesis.
A third opinion is given by Girard et al. [1989]: “the sense contains the denotation,
at least implicitly.” Girard proposes a study of the invariants of syntax, in a vein
inspired by proof theory. Some interpret this statement as taking the extreme viewpoint that ‘syntax = sense,’ but it becomes clear in [Girard, 2011] that the author is
simply proposing the study of new, unorthodox proof-theoretic structures.
In this thesis we avoided this lengthy debate by defining intensionality to mean
‘anything finer than what we call extensional equality.’ We like to view this as purely
mathematical, and philosophically agnostic. We have merely demonstrated in §3 that
modal types allow one to treat their elements as pure syntax.
In the development of exposures in §4, and then in the intensional semantics of
§8, it became clear that this view of equality is modular. The modal types allow one
to introduce equalities in a controlled fashion: we began with no equations in iPCF
(§3), and gradually reached a set of equations in iPCF v2.0 (§8) which seem to mirror
intensional equality, as defined by the exposure. Whether that is a precise reflection
can be shown through a completeness theorem, which we conjecture to hold. In turn,
our flavour of exposure (cartesian, product-preserving, weakly cartesian closed, etc.)
determines which equations intensional equality will satisfy. We believe that the
modularity of this framework is a serious advantage that makes it adaptable to all
sorts of settings, and all levels of fine-grain intensional information.

186

9.2

How expressive is iPCF?

The first two objectives of this thesis that we discussed in §1.2 were the clarification
of the intensional and reflective programming paradigms.
The development of iPCF elucidated the fact that we can indeed treat terms at
modal types as if they were ‘pure syntax’ (up to α-equivalence), and make arbitrary
decisions on them in a typed manner. This shows that, if we comprehend intensional
programming as entailing non-functional behaviour, then there is a type theory in
which this ability is provably consistent. As we remarked in the introduction, there
have been many similar attempts in the past, but all were in one way or another
problematic: some led to particularly complicated languages with unclear semantics,
like those of Smith [1982, 1984]; others, like Gabbay and Nanevski [2013], were close
to ours, but proposed semantics which are—unfortunately—inconsistent. A third
class led to impossibility theorems, e.g. Wand [1998].
Our work decisively resolved many of these issues: once a modal typing discipline
is established, then we are perfectly capable of accommodating both non-functional
behaviour as well as reflexivity. If we limit these behaviours to the modal types, and
use the typing system to stop the flow from the extensional region of the language to
the modal types, then we get a consistent language. We also believe that we are the
first to directly tie intensionality and reflexivity together, as we think they should be,
if we are to use reflexivity in any interesting manner.
Nonetheless, as we hinted in §3.6, iPCF can only be considered a proof-of-concept.
We have deliberately decided not to concern ourselves with the task of finding good
sets of intensional primitives, but merely with the possibility of crafting a setting in
which this is possible. We believe that finding good intensional primitives is a particularly hard problem, with close connections to both metaprogramming and higher-order
computability. Furthermore, finding other models is likely to prove challenging.

9.2.1

Metaprogramming

As we discussed in the introduction, metaprogramming is a difficult task that dates
back to the work of the Lisp community. The area has recently witnessed a resurgence
of interest, leading to the International Summer School on Metaprogramming that
took place at Robinson College, Cambridge (8-12 August 2016) around the time
that the author began drafting this thesis. It is quite clear that a good foundation for
metaprogramming is still lacking: see the work of Berger [2016] for a recent discussion.

187

At this point we should remark that intensional operations are not the main
subject of that area: metaprogramming is about constructing code dynamically from
its fragments, and not destructing it, as we are wont to do with intensionality.
A common issue in metaprogramming is that of manipulating code with open variables (= free variables). This is known to be a rather painful limitation of the S4-based
language of Davies and Pfenning [1996] on which iPCF is based. In order to overcome
this, Davies [1995, 1996, 2017] developed a λ-calculus based on another modality that
is reminiscent of the ‘next’ operator of Linear Temporal Logic (LTL). This language
has explicit annotations of the stage at which each computation is taking place, and is
also able to handle open code. This led to a flurry of developments, and in particular
the very influential work of Taha and Sheard [1997, 2000] on MetaML, and then the
environment classifiers of Taha and Nielsen [2003], which have recently been improved
by Tsukada and Igarashi [2010]. See [Kavvos, 2016, §6] for further references, and for
a discussion of the modal aspects used.
In iPCF, the restriction of no open code does not only occur as it did before
(only modal variables under boxes), but it also vengefully reappears in the case of
intensional operations: we saw in §3.3 that, unless the terms on which we operate
intensionally are closed, we risk inconsistency. The author’s colleague, Mario AlvarezPicallo, has begun some preliminary work in intensionality in calculi like Davies’,
which we discuss further in §9.3.
However, to achieve any meaningful notion of intensional primitives, much more
than simple modal types is required. Consider, for example, a constant deapp that
attempts to take apart an application, in the sense that
deapp (box (M N )) = hbox M, box N i
(where we have also assumed products in the language). This cannot meaningfully
be typed in the simple modal setting. In fact, it seems that we need existential types
in order to assign a type to this, as the domain of M is unknown. For example, the
type would be something like
deapp : B → ∃A. (A → B) × A
However, this would take us deep into the waters of second-order modal logic, and we
are not aware of any previous work on that front.
Similar second-order type systems like this have been suggested in the context of
Barry Jay’s factorisation calculi. These are combinatory calculi that admit intensional
operations at ‘face value.’ The trick by which disaster is avoided is that of having
188

intensional operations act only on normal forms, e.g. a partially applied S combinator
(SP Q), which they are able to take apart (factorise) in order to reuse its immediate
subterms P and Q: see Jay and Given-Wilson [2011]. In subsequent work by Jay and
Palsberg [2011] it was shown that such a system admits a second-order Curry-style
typing similar the one shown above, but without the modalities.

9.2.2

Higher-Order Computability

This is perhaps the point of view from which the present work originates, but also the
least developed in this thesis. We discussed some possible applications of our ideas
on intensional higher-order computation in §1.2.3. Unfortunately, the scope of this
thesis could not be stretched to contain more material in this direction. Nevertheless, the author has a presentiment that any truly novel understanding of intensional
higher-order computation will come simultaneously with the development of intensional primitives for a language like iPCF.

9.2.3

iPCF, iPCF v2.0, and their models

Even though we begun with the model of assemblies on K1 in mind, it gradually
became apparent that things were not quite that simple. In §8 we ran into severe
difficulties when trying to force Asm(K1 ) to be a model of iPCF, which we related to
three fundamental problems:
1. free variables in intensional fixed points;
2. free variables in abstractions of quoted terms, a.k.a no higher-order intensional
programming; and
3. the construction of intensional fixed points at all types.
Whereas the third problem is largely technical, the other two are quite serious
points against our argument that iPCF v2.0 is a good ‘language of indices.’ We argued
extensively in §8.1 that, indeed, both of these problems seem more-or-less natural
from a computability theory point-of-view. However, naturality and substitution are
fundamental aspects of any λ-calculus, and the fact that we have to disallow them
fundamentally reduces the expressiveness of what we have achieved.
It thus follows that we need to consider more candidate models of iPCF. We can
go about this task in three ways:
(i) We can study Asm(K1 ) more closely; or
189

(ii) we can look for other PCAs A such that Asm(A) is an interesting natural /weakly
extensional model; or
(iii) we can look elsewhere.
Regarding the first option, we should remark that we did not show that Asm(K1 )
is not natural. We very strongly believe that it is not weakly extensional, although we
have no evidence for that either. Disproving either of these assertions is likely to be
a very cumbersome exercise, and it is perhaps best that it be automated/computerassisted. If naturality is shown to not be the case, then we should perhaps redefine
box (−) to enclose only completely closed terms, with no free variables at all, whether
modal or intuitionstic. This would directly lead us to some kind of intensional combinator language, as also described at the end of §8.1, which would not be very far
from what is already the case with indices in computability theory. It may be that
the ‘nature’ of K1 simply has this shape.
However, even if Asm(K1 ) were to unexpectedly prove to be natural, the key to
Davies-Pfenning style staged metaprogramming—which is an expressive improvement
over indices in computability theory—is precisely the free variables under quoted λabstractions. This very urgently requires weak extensionality, as remarked in §8.4.
In that section, we also discussed the possibility of finding some weakly extensional
PCA A that can be informative in terms of intensional programming. We concluded
that the said task is likely very difficult.
It is not inconceivable that there could be another source of models for iPCF:
perhaps a change in perspective is required, and this change may be one that involves
moving away from ideas sourced from realizability, and more towards the emergent
theory of metaprogramming. This is also related to some ideas that we will discuss
in the next section, regarding alternative proposals for modelling the phenomenon of
intensionality at large.
Finally, as soon as more models of iPCF are identified, there are many interesting
questions that need to be answered. First, showing a completeness theorem for iPCF
interpreted with exposures should be a primary goal. In a sense, a completeness
theorem will demonstrate that our categorical structure indeed corresponds to what
we type-theoretically understand as intensional types. This should be investigated as
a priority. Secondly, a more careful approach to the available intensional operations
should be taken, and some form of adequacy theorem for iPCF should be shown.
We are not exactly sure what form this should take, but it should certainly be much
more involved than the adequacy statements concerning PCF. This issue is likely
190

to be deeply intertwined with the intensional primitives we discussed this section.
Thirdly, there must be many interesting results concerning the mismatch between
iPCF and its various models. This is very much the case with PCF, beginning with
the work of Plotkin [1977] on domain-theoretic models, and all the way to the work of
Escardó [1999] on metric models. However, the intensional case is likely to be much
richer, detailed, and tricky.

9.3

Exposures vs. other theories of intensionality

Exposures attempt to abstract the general notion of intensional devices, of which
Gödel numberings or numberings of partial recursive functions are only particular
cases, as seen in §5. As such, the ambition of the work in this thesis is slightly different
when compared to previous attempts, which are mainly concerned with presenting a
categorical account of computability theory.
We showed in §6 that exposures are particularly elegant settings for reproducing
well-known diagonal arguments. It has been known for some time that there are
common elements between these theorems, but the language of P-categories and exposures allows us to capture what is needed for each argument in very fine detail.
•

For example, Rice’s theorem necessitates an evaluator  : Q # Id, whereas Tarski’s
Undefinability Theorem precisely states that merely having evaluators is catastrophic
for one aspect of consistency (fix-consistency), as this causes ¬ to have a fixed point.
On the other hand, Gödel’s First Incompleteness Theorem states that we must have
more truth values than simply true and false.
Contrary to the presentation of Lawvere [1969, 2006], all our theorems are in the
same language of comonadic exposures. Our development is positive, in that it is
predicated on the existence of IFPs, and not the absence of EFPs, as in Lawvere’s
paper. We have concentrated on the oughts, and not the ought nots. It is for this
reason that we view our results as a refinement of those of Lawvere.
We believe that all these observations and results lend support to the idea that
exposures can become a useful toolkit situated at the heart of a new theory of intensionality, which would be applicable in all sorts of settings, not necessarily related to
logic and computation. Furthermore, unlike previous work in the same style, exposures draw inspiration from modal logic and the Curry-Howard correspondence. It is
for that reason that the resulting framework is—unlike all its predecessors—inherently
typed. Essentially all previous work on the subject relied on some ‘universal’—in one
way or another object—which contained codes for a whole class of arrows.
191

First, we want to mention the only two generalisations of the SRT of which we
are aware. They both seem very similar, and they concern effective Scott domains:
one is due to Kanda [1988], and the other one due to Case and Moelius [2012].
As for category-theoretic frameworks, the only previous work with a similar flavour
consists of (a) a paper of Mulry, which uses the recursive topos; and (b) the line of
work that culminates with Cockett and Hofstra’s Turing categories, as well as their
intellectual predecessors.

Mulry’s Recursive Topos
Mulry [1982] constructed the recursive topos Rec, which is the Grothendieck topos of
canonical sheaves on the monoid of recursive functions under composition. Broadly
speaking, the notion of (higher-order) computation in the recursive topos is that of
Banach-Mazur computability: a map is computable if it maps recursive sequences to
recursive sequences.1
In [Mulry, 1989], the author aims to “contemplate a synthetic theory of computation, i.e. an intrinsic set of categorical axioms for recursion which captures both
essential features of classical recursion theory but is also applicable over a wide range
of applications in areas of effective mathematics and computer science.”
Indeed, Mulry’s work has some overlap with some of the material we presented in
§6.3 on Lawvere’s theorem. He identifies an enumeration of the partial recursive functions as a point surjective map, and then proceeds to interpret all the classic results
of type 2 computability (Myhill-Shepherdson, Kreisel-Lacombe-Shoenfield, etc.) in
the context of the recursive topos. This is followed by a discussion of the connections
between the recursive topos, the effective topos of Hyland [1982], and effective Scott
domains. He there points out that one can construct a N-path surjection N → D and
a point surjection N → DN in Rec, for any effective Scott domain D.
Fixed points are discussed in the final section of the paper. It is noted there that
Lawvere’s theorem corresponds to (a limited version of) Kleene’s FRT, simply by
considering an enumeration of (two-argument) partial recursive functions, alongside
N∼
= N × N. This last isomorphism is also used to prove versions of the FRT and SRT
for effective Scott domains, based on the observations of the previous paragraph. It is
remarked that the same can be shown in the effective topos, but not in the category
of effective domains itself, as neither of their natural numbers objects are effective
domains.
1

This short explanation of Banach-Mazur is due to Andrej Bauer, and was sourced from mathoverflow question #21745.

192

Thus, Mulry’s versions of the FRT and SRT seem to depend on the natural numbers object N. The SRT seems to give a fixed point for h : N → N, in the sense that
both the fixed point n and h ◦ n are indices for the same element of the effective Scott
domain. This is indeed a version of the SRT for all effective Scott domains, but it
lacks the well-typed flavour of our approach.

The road to Turing categories
Inspired by previous work by Paola and Heller [1987], and some of the material in
the thesis of Birkedal [2000], Cockett and Hofstra [2008] developed the notion of a
Turing category.
Turing categories are cartesian restriction categories: that is, they are equipped
with some structure to handle the partiality of their arrows, and there are cartesian
products—up to partiality. Their defining feature is that they have a Turing object
A, which is a domain that contains codes for all the arrows of the category: it has a
universal application,
τX,Y : A × X → Y
for each pair of objects X and Y , such that given any f : Z × X → Y , an index h :
Z → A exists, not by any means unique, such that the following diagram commutes:
A×X

τX,Y

h×idX

Y

f

Z ×X
So A is a very weak exponential for all X, Y at the same time. In fact, every object
X of a Turing category is a retract of A.
Whereas the work of Cockett and Hofstra is a beautiful and general account of
settings where basic recursion theory can be done, and also give rise to an interesting
theory of categorical simulations [Cockett and Hofstra, 2010], they are very far from
the goals of our own work: we are interested in exploring intensionality, which is only
one of the phenomena that occur in recursion theory. We are also interested in doing
so in a stringent type-theoretic manner, and thus we perceive the reliance on Turing
objects as a problem. Cockett and Hofstra themselves point out the untyped nature
of their work:
“A similar inherent limitation to Turing categories lies in its essential untypedness. Recently, Longley [...] has advocated the use of typed PCAs in

193

order to clarify notions of computation at higher types; it is not unimaginable that the corresponding generalization of Turing categories can be
of interest if we wish to handle such notions of computation in our setting.
Such a generalization would essentially bring us back to Birkedal’s weakly
closed partial cartesian categories.”
This is followed by the observation that in the Turing category corresponding to
classical computability theory no real discussion of higher-order phenomena can occur,
as one has no way of speaking about type-2 functionals.
In conclusion, the work of Cockett and Hofstra is untyped, fundamentally based
on partiality, and mostly centred around recursion theory. We prefer typed, total, and
intensional settings, without wanting to declare any particular allegiance to recursiontheoretic arguments.

9.3.1

An Idea for an Alternative Approach

At this point we ought to record another candidate approach for modelling intensionality as we see it in this thesis. This idea is due to Martin Hyland, who examined
this thesis. However, a similar framework has also been put forward by my fellow
student, Mario Alvarez-Picallo, in his work on the semantics of metaprogramming.
In many ways, the framework of exposures can be seen as evil or pathological,
in that it requires a highly non-standard property, namely that PERs are reflected
instead of preserved—as they would be for a P-functor. In that sense, it may indeed
be non-categorical (this is another interesting idea that needs to be investigated).
Perhaps the following proposal would be more workable. Instead of insisting on a
single mathematical universe, i.e. a single category, we could consider two: one that
is intensional, and one that is extensional. The theory of exposures already gives us
two rather good candidates for these: given an endoexposure Q : (C, ∼) # (C, ∼), the
intensional universe is the x-ray P-category (C, ≈Q ), wheras the extensional one is the
P-category (C, ∼) itself—see §4.2 for definitions of these notions. Now, as intensional
equality implies extensional equality, it is evident that there is a trivial P-functor,
(C, ≈Q ) −→ (C, ∼)
which is the identity on objects, the identity on morphisms, and full—but definitely
not faithful!2 One could perhaps argue that we could even move away from Pcategories, and back into ordinary categories: there could be a functor C → D, which
2

The first of these criteria is a recurrent theme of questionable categorical status, which nonetheless occurs reasonably often, e.g. in Freyd categories; see e.g. Staton [2014].

194

is the identity on objects and full. Perhaps D could be of the form C/ ∼, i.e. a quotient category of some sort. Thus, intensionality is obtained by having (P-)categories
on two levels, so that one is included in the other.
Mario Alvarez has proposed some directions regarding the categorical modelling
of non-homogeneous staged metaprogramming calculi, like the ones of Davies [1995,
1996, 2017], which bear a certain resemblance to the preceding idea. Put simply,
he proposes a simple metaprogramming calculus which consists of essentially two
‘stages,’ one ‘under the circle’ (cf. under the box), and the ordinary one. Under the
circle, affairs intensional, in much the same way that they are under our boxes, but
otherwise things work up to ordinary equality. Using the syntax of this calculus, one
can construct a cartesian category SM, the syntactic model : this is a term model,
but not quotiented up to equality. A model of this is then a cartesian closed category
C along with a functor,
F : SM −→ C
which is strictly product-preserving. Furthermore, if intensional operations are to
be soundly interpreted, this functor should be faithful. This is to be understood in
the following way: the functor F encodes syntactic information within the semantic
model, in a manner that does not collapse the syntax.
There is an odd tension between fullness and faithfulness in this. Which one
should we choose for intensionality? Faithfulness guarantees that the syntax is accurately represented in the model, whereas fullness describes the idea that for every
‘extensional’ view, there is at least one intensional. Nevertheless, investigation of
this idea of two level-two category paradigm of intensionality is likely to be a very
interesting avenue for further research.

9.4

Kleene’s mysterious Second Recursion Theorem

The basic impetus behind this thesis was not intensionality itself, but rather its rôle
in Kleene’s Second Recursion Theorem, which we exhaustively studied in §2. These
questions were brought to the author’s attention by Abramsky [2012, 2014], who—
along with Jones [2013]—had identified the mysterious nature of this theorem in the
1980s. Abramsky [2012] also remarks that the theorem is very powerful, and—even
though very simple—its proof is opaque, and provides no intuition. Our analysis of
intensional recursion in §6, and the connection we have drawn with Lawvere’s work
on diagonal arguments, has shed some light on these issues.

195

First, we believe that the opacity in proof is not a real problem: all diagonalisation proofs have a quintessentially ‘magical’ element that often stimulates people’s
imagination, bringing them to the forefront of popular science books and scientific
novels, see e.g. Hofstadter [1979], Doxiadis [2001]. What is more, Kleene [1981] explicitly states that the SRT was obtained quite straightforwardly by translating the
FRT from the λ-calculus. He even dates this derivation before the 1st of July 1935.
Instead, we believe that the our analysis provides a new perspective on the structure of the situations in which Kleene’s argument is fundamentally applicable. This
amounts to a generalisation of intensional recursion beyond first-order computability: the Curry-Howard interpretation through Löb’s rule, as well as the Intensional
Recursion theorem stated in the language of comonadic exposures, reveal patterns in
the statement and the proof of the theorem that were not known before.

9.5

Concluding remarks

It is evident from the previous sections that there are many very interesting questions that follow from our work in this thesis. Perhaps the most interesting theoretical
direction is that of studying the expressiveness of iPCF, especially through the related themes of metaprogramming and non-functional higher-order computation. The
present author believes that it is very likely that we could use modalities and intensionality to obtain access to computational power that we have both sclerotically
rejected from theoretical analysis, or left to programmers of the untyped persuasion.
These developments—we hope—will proceed hand-in-hand with an improved understanding of metaprogramming, intensional or not. Progress is difficult to achieve
in metaprogramming not only because we have been lacking a theoretical foundation, but also because industrial metaprogramming has progressed unabashedly in
the meantime. The result is that multiple hard-to-shake ad-hoc habits have been
established.
On the other hand, our intensional framework is as close to 1-category theory
as one can get, and it is for this reason that we hope that it may be more widely
applicable than just in the context of computability and logic. We have demonstrated
at least one example of this in the case of homological algebra (§5.3). However, as the
applications of category theory expand to include linguistics and philosophy—see e.g.
the forthcoming volume [Landry, 2017]—we would like to believe that the concept
of intensionality will reappear in many different settings, and our framework will be
there to explain its structure.
196

Appendix A
iPCF v2.0 in Agda
A.1

Basics.agda
module Basics where
open import Relation.Binary.PropositionalEquality
open import Data.Nat using (N ; zero ; suc)
open import Data.Sum renaming (_]_ to _+_)
infixr 1 _=>_
infixr 5 _∈_
infixl 1 _⊆_
infixl 4 _,_
infixl 3 _++_
infixl 2 _∧_
––––––––––––
– Types and Contexts –
––––––––––––
data Types : Set where
simple : Types
modal : Types
data Ty : Types → Set where
P : ∀ {T} → N → Ty T
_=>_ : ∀ {T} → Ty T → Ty T → Ty T
197

_∧_ : ∀ {T} → Ty T → Ty T → Ty T
_ : Ty modal → Ty modal
data Cx : Types → Set where
· : ∀ {T} → Cx T
_,_ : ∀ {T : Types} (Γ : Cx T) (A : Ty T) → Cx T
data _∈_ : ∀ {T : Types} (A : Ty T) (Γ : Cx T) → Set where
top : ∀ {T} {Γ : Cx T} {A : Ty T} → A ∈ (Γ , A)
pop : ∀ {T} {Γ : Cx T} {A B : Ty T} (i : A ∈ Γ) → A ∈ (Γ , B)
_⊆_ : ∀ {T} (Γ ∆ : Cx T) → Set
Γ ⊆ ∆ = ∀ {A} → A ∈ Γ → A ∈ ∆
– Functions on contexts.
boxcx : Cx modal → Cx modal
boxcx · = ·
boxcx (Γ , A) = boxcx Γ ,  A
_++_ : ∀ {T} → Cx T → Cx T → Cx T
∆ ++ · = ∆
∆ ++ (Γ , A) = (∆ ++ Γ) , A
box∈cx : ∀ {Γ : Cx modal} {A : Ty modal} → A ∈ Γ →  A ∈ boxcx Γ
box∈cx top = top
box∈cx (pop d) = pop (box∈cx d)
subsetdef : ∀ {T} {Γ ∆ : Cx T} {A} → A ∈ Γ → Γ ⊆ ∆ → A ∈ ∆
subsetdef d f = f d
subsetempty : ∀ {T} {Γ : Cx T} → · ⊆ Γ
subsetempty ()
subsetid : ∀ {T} {Γ : Cx T} → Γ ⊆ Γ
subsetid = ń {Γ} {A} z → z
198

weakone : ∀ {T} {Γ ∆ : Cx T} {A} → Γ ⊆ ∆ → Γ ⊆ (∆ , A)
weakone p = ń {A} z → pop (p z)
weakboth : ∀ {T} {Γ ∆ : Cx T} {A} → Γ ⊆ ∆ → Γ , A ⊆ ∆ , A
weakboth p top = top
weakboth p (pop x) = subsetdef x (weakone p)
weakmany : ∀ {T} (Γ ∆ : Cx T) → Γ ⊆ Γ ++ ∆
weakmany Γ · x = x
weakmany Γ (∆ , A) x = pop (weakmany Γ ∆ x)
concat-subset-1 : ∀ {T} (Γ ∆ : Cx T) → Γ ⊆ Γ ++ ∆
concat-subset-1 Γ · x = x
concat-subset-1 Γ (∆ , A) x = subsetdef x (weakone (concat-subset-1 Γ ∆))
concat-subset-2 : ∀ {T} (Γ ∆ : Cx T) → ∆ ⊆ Γ ++ ∆
concat-subset-2 Γ · ()
concat-subset-2 Γ (∆ , A) x = subsetdef x (weakboth (concat-subset-2 Γ ∆))
incl-trans : ∀ {T} {Γ Γ’ Γ” : Cx T} → Γ ⊆ Γ’ → Γ’ ⊆ Γ” → Γ ⊆ Γ”
incl-trans p q x = q (p x)
swap-last : ∀ {T} {Γ : Cx T} {A B} → Γ , A , B ⊆ Γ , B , A
swap-last {_} {·} top = pop top
swap-last {_} {·} (pop top) = top
swap-last {_} {·} (pop (pop x)) = pop (pop x)
swap-last {_} {Γ , A} top = pop top
swap-last {_} {Γ , A} (pop top) = top
swap-last {_} {Γ , A} (pop (pop x)) = pop (pop x)
cx-exch : ∀ {T} {Γ ∆ : Cx T} {A B} → (Γ , A , B) ++ ∆ ⊆ (Γ , B , A) ++ ∆
cx-exch {∆ = ·} d = swap-last d
cx-exch {∆ = ∆ , A1} top = top
cx-exch {∆ = ∆ , A1} (pop d) = subsetdef d (weakone (cx-exch {∆ = ∆}))

199

cx-contr : ∀ {T} {Γ ∆ : Cx T} {A} → (Γ , A , A) ++ ∆ ⊆ (Γ , A) ++ ∆
cx-contr {∆ = ·} top = top
cx-contr {∆ = ·} (pop d) = d
cx-contr {∆ = ∆ , A1} top = top
cx-contr {∆ = ∆ , A1} (pop d) = subsetdef d (weakone (cx-contr {∆ = ∆}))
is-in : ∀ {T} (Γ Γ’ : Cx T) (A : Ty T) → A ∈ (Γ , A ++ Γ’)
is-in Γ · A = top
is-in Γ (Γ’ , A’) A = pop (is-in Γ Γ’ A)
ctxt-disj : ∀ {T} (Γ Γ’ : Cx T) (A : Ty T) → A ∈ (Γ ++ Γ’) → A ∈ Γ + A ∈ Γ’
ctxt-disj Γ · A x = inj1 x
ctxt-disj Γ (Γ’ , A’) .A’ top = inj2 top
ctxt-disj Γ (Γ’ , A’) A (pop x)
with ctxt-disj Γ Γ’ A x
ctxt-disj Γ (Γ’ , A’) A (pop x) | inj1 z = inj1 z
ctxt-disj Γ (Γ’ , A’) A (pop x) | inj2 z = inj2 (pop z)
swap-out : ∀ {T} (∆ Γ : Cx T) (A : Ty T) → (∆ , A) ++ Γ ⊆ (∆ ++ Γ) , A
swap-out ∆ · A x = x
swap-out ∆ (Γ , B) A x = swap-last (subsetdef x (weakboth (swap-out ∆ Γ A)))
swap-in : ∀ {T} (∆ Γ : Cx T) (A : Ty T) → (∆ ++ Γ) , A ⊆ (∆ , A) ++ Γ
swap-in ∆ Γ A top = is-in ∆ Γ A
swap-in ∆ Γ A (pop x)
with ctxt-disj ∆ Γ _ x
swap-in ∆ Γ A (pop x) | inj1 y = concat-subset-1 (∆ , A) Γ (pop y)
swap-in ∆ Γ A (pop x) | inj2 y = concat-subset-2 (∆ , A) Γ y

200

A.2

iPCF.agda
module iPCF where
infixl 0 _/_`_
open import Basics
– Definition
data _/_`_ (∆ Γ : Cx modal) : Ty modal → Set where
iPCF-var : ∀ {A}
→A∈Γ
––––––→∆/Γ`A
iPCF-modal-var : ∀ {A}
→A∈∆
––––––
→∆/Γ`A
iPCF-app : ∀ {A B}
→ ∆ / Γ ` A => B → ∆ / Γ ` A
––––––––––––––––→∆/Γ`B
iPCF-lam : ∀ {A B}
→ ∆ / (Γ , A) ` B
–––––––––
→ ∆ / Γ ` A => B

201

iPCF-prod : ∀ {A B}
→∆/Γ`A →∆/Γ`B
––––––––––––––
→∆/Γ`A∧B
iPCF-fst : ∀ {A B}
→∆/Γ`A∧B
––––––––→∆/Γ`A
iPCF-snd : ∀ {A B}
→∆/Γ`A∧B
––––––––
→∆/Γ`B
iPCF-boxI : ∀ {A}
→∆/·`A
–––––––→∆/Γ`A
iPCF-boxE : ∀ {A C}
→ ∆ / Γ `  A → (∆ , A) / Γ ` C
––––––––––––––––––
→∆/Γ`C
iPCF-fix : ∀ {A}
→ ∆ / (· ,  A) ` A
–––––––→∆/Γ`A

202

– Weakening and exchange.

exch : ∀ {∆ Γ A B C} (Γ’ : Cx modal)
→ ∆ / (Γ , A , B) ++ Γ’ ` C
––––––––––––––→ ∆ / (Γ , B , A) ++ Γ’ ` C
exch Γ’ (iPCF-var x) = iPCF-var (cx-exch {∆ = Γ’} x)
exch Γ’ (iPCF-modal-var x) = iPCF-modal-var x
exch Γ’ (iPCF-app d d1) = iPCF-app (exch Γ’ d) (exch Γ’ d1)
exch {C = A => B} Γ’ (iPCF-lam d) = iPCF-lam (exch (Γ’ , A) d)
exch Γ’ (iPCF-prod d e) = iPCF-prod (exch Γ’ d) (exch Γ’ e)
exch Γ’ (iPCF-fst d) = iPCF-fst (exch Γ’ d)
exch Γ’ (iPCF-snd d) = iPCF-snd (exch Γ’ d)
exch Γ’ (iPCF-boxI d) = iPCF-boxI d
exch Γ’ (iPCF-boxE d e) = iPCF-boxE (exch Γ’ d) (exch Γ’ e)
exch Γ’ (iPCF-fix d) = iPCF-fix d

exch-modal : ∀ {∆ Γ A B C} (∆’ : Cx modal)
→ (∆ , A , B) ++ ∆’ / Γ ` C
–––––––––––––––
→ (∆ , B , A) ++ ∆’ / Γ ` C
exch-modal ∆’ (iPCF-var x) = iPCF-var x
exch-modal ∆’ (iPCF-modal-var x) =
iPCF-modal-var (subsetdef x (cx-exch {∆ = ∆’}))
exch-modal ∆’ (iPCF-app d e) =
iPCF-app (exch-modal ∆’ d) (exch-modal ∆’ e)
exch-modal ∆’ (iPCF-lam d) = iPCF-lam (exch-modal ∆’ d)
exch-modal ∆’ (iPCF-prod d e) =
iPCF-prod (exch-modal ∆’ d) (exch-modal ∆’ e)
203

exch-modal ∆’ (iPCF-fst d) = iPCF-fst (exch-modal ∆’ d)
exch-modal ∆’ (iPCF-snd d) = iPCF-snd (exch-modal ∆’ d)
exch-modal ∆’ (iPCF-boxI d) = iPCF-boxI (exch-modal ∆’ d)
exch-modal ∆’ (iPCF-boxE d e) =
iPCF-boxE (exch-modal ∆’ d) (exch-modal (∆’ , _) e)
exch-modal ∆’ (iPCF-fix d) = iPCF-fix (exch-modal ∆’ d)

weak : ∀ {∆ Γ Γ’ A}
→ ∆ / Γ ` A → Γ ⊆ Γ’
––––––––––––→ (∆ / Γ’ ` A)
weak (iPCF-var x) f = iPCF-var (f x)
weak (iPCF-modal-var x) f = iPCF-modal-var x
weak (iPCF-app d e) f = iPCF-app (weak d f) (weak e f)
weak (iPCF-lam d) f = iPCF-lam (weak d (weakboth f))
weak (iPCF-prod d e) f = iPCF-prod (weak d f) (weak e f)
weak (iPCF-fst d) f = iPCF-fst (weak d f)
weak (iPCF-snd d) f = iPCF-snd (weak d f)
weak (iPCF-boxI d) f = iPCF-boxI d
weak (iPCF-boxE d e) f =
iPCF-boxE (weak d f) (weak e f)
weak (iPCF-fix d) f = iPCF-fix d

weak-modal : ∀ {∆ ∆’ Γ A}
→ ∆ / Γ ` A → ∆ ⊆ ∆’
––––––––––––→ ∆’ / Γ ` A
weak-modal (iPCF-var p) x = iPCF-var p
weak-modal (iPCF-modal-var p) x = iPCF-modal-var (x p)
weak-modal (iPCF-app t u) x = iPCF-app (weak-modal t x)
204

(weak-modal u x)
weak-modal (iPCF-lam t) x = iPCF-lam (weak-modal t x)
weak-modal (iPCF-prod t u) x = iPCF-prod (weak-modal t x)
(weak-modal u x)
weak-modal (iPCF-fst t) x = iPCF-fst (weak-modal t x)
weak-modal (iPCF-snd t) x = iPCF-snd (weak-modal t x)
weak-modal (iPCF-boxI t) x = iPCF-boxI (weak-modal t x)
weak-modal (iPCF-boxE t u) x =
iPCF-boxE (weak-modal t x)
(weak-modal u (weakboth x))
weak-modal (iPCF-fix t) x = iPCF-fix (weak-modal t x)

– Cut.
cut : ∀ {∆ Γ A B} → (Γ’ : Cx modal)
→ ∆ / Γ ` A → ∆ / Γ , A ++ Γ’ ` B
–––––––––––––––––––→ ∆ / Γ ++ Γ’ ` B
cut · d (iPCF-var top) = d
cut · d (iPCF-var (pop x)) = iPCF-var x
cut (Γ’ , B) d (iPCF-var top) = iPCF-var top
cut (Γ’ , A’) d (iPCF-var (pop x)) =
weak (cut Γ’ d (iPCF-var x)) (weakone subsetid)
cut Γ’ d (iPCF-modal-var p) = iPCF-modal-var p
cut Γ’ d (iPCF-app t u) = iPCF-app (cut Γ’ d t) (cut Γ’ d u)
cut Γ’ d (iPCF-lam e) = iPCF-lam (cut (Γ’ , _) d e)
cut Γ’ d (iPCF-prod t u) = iPCF-prod (cut Γ’ d t) (cut Γ’ d u)
cut Γ’ d (iPCF-fst e) = iPCF-fst (cut Γ’ d e)
cut Γ’ d (iPCF-snd e) = iPCF-snd (cut Γ’ d e)
cut Γ’ d (iPCF-boxI e) = iPCF-boxI e
cut Γ’ d (iPCF-boxE t u) =
iPCF-boxE (cut Γ’ d t)
(cut Γ’ (weak-modal d (weakone (subsetid))) u)
205

cut Γ’ d (iPCF-fix t) = iPCF-fix t

cut-modal : ∀ {∆ Γ A B} → (∆’ : Cx modal)
→ ∆ / · ` A → ∆ , A ++ ∆’ / Γ ` B
–––––––––––––––––––→ ∆ ++ ∆’ / Γ ` B
cut-modal ∆’ d (iPCF-var x) = iPCF-var x
cut-modal · d (iPCF-modal-var top) = weak d subsetempty
cut-modal · d (iPCF-modal-var (pop x)) = iPCF-modal-var x
cut-modal (∆’ , B) d (iPCF-modal-var top) = iPCF-modal-var top
cut-modal (∆’ , A’) d (iPCF-modal-var (pop x)) =
weak-modal (cut-modal ∆’ d (iPCF-modal-var x)) (weakone subsetid)
cut-modal ∆’ d (iPCF-app p q) =
iPCF-app (cut-modal ∆’ d p) (cut-modal ∆’ d q)
cut-modal ∆’ d (iPCF-lam e) = iPCF-lam (cut-modal ∆’ d e)
cut-modal ∆’ d (iPCF-prod p q) =
iPCF-prod (cut-modal ∆’ d p) (cut-modal ∆’ d q)
cut-modal ∆’ d (iPCF-fst e) = iPCF-fst (cut-modal ∆’ d e)
cut-modal ∆’ d (iPCF-snd e) = iPCF-snd (cut-modal ∆’ d e)
cut-modal ∆’ d (iPCF-boxI e) = iPCF-boxI (cut-modal ∆’ d e)
cut-modal ∆’ d (iPCF-boxE p q) =
iPCF-boxE (cut-modal ∆’ d p) (cut-modal (∆’ , _) d q)
cut-modal ∆’ d (iPCF-fix e) = iPCF-fix (cut-modal ∆’ d e)

206

A.3

iPCF2.agda
module iPCF2 where
infixl 0 _/_`_::_
open import Basics
– Definition
data Judgement : Set where
int : Judgement
ext : Judgement
data _/_`_::_ (∆ Γ : Cx modal) : Judgement → Ty modal → Set where
iPCF-var : ∀ {J A}
→A∈Γ
–––––––––––––→ ∆ / Γ ` J :: A
iPCF-modal-var : ∀ {J A}
→A∈∆
–––––––––––––→ ∆ / Γ ` J :: A
iPCF-app : ∀ {J A B}
→ ∆ / Γ ` J :: A => B

→ ∆ / Γ ` J :: A

–––––––––––––––––––––––––––––
→ ∆ / Γ ` J :: B
iPCF-lam-ext : ∀ {A B}

207

→ ∆ / (Γ , A) ` ext :: B
–––––––––––––––––––
→ ∆ / Γ ` ext :: A => B
iPCF-lam-int : ∀ {J A B}
→ · / (· , A) ` J :: B
–––––––––––––––––
→ ∆ / Γ ` int :: A => B
iPCF-boxI : ∀ {J A}
→ ∆ / · ` int :: A
–––––––––––––––→ ∆ / Γ ` J ::  A
iPCF-boxE : ∀ {J A C}
→ ∆ / Γ ` J ::  A → (∆ , A) / Γ ` J :: C
–––––––––––––––––––––––––––––––––
→ ∆ / Γ ` J :: C
iPCF-fix : ∀ {J A}
→ · / (· ,  A) ` int :: A
–––––––––––––––––––
→ ∆ / Γ ` J :: A

– Weakening and exchange.

exch : ∀ {∆ Γ J A B C} (Γ’ : Cx modal)
→ ∆ / (Γ , A , B) ++ Γ’ ` J :: C
––––––––––––––208

→ ∆ / (Γ , B , A) ++ Γ’ ` J :: C
exch Γ’ (iPCF-var x) = iPCF-var (cx-exch {∆ = Γ’} x)
exch Γ’ (iPCF-modal-var x) = iPCF-modal-var x
exch Γ’ (iPCF-app d d1) = iPCF-app (exch Γ’ d) (exch Γ’ d1)
exch {C = A => B} Γ’ (iPCF-lam-ext d) = iPCF-lam-ext (exch (Γ’ , A) d)
exch Γ’ (iPCF-lam-int d) = iPCF-lam-int d
exch Γ’ (iPCF-boxI d) = iPCF-boxI d
exch Γ’ (iPCF-boxE d e) = iPCF-boxE (exch Γ’ d) (exch Γ’ e)
exch Γ’ (iPCF-fix f) = iPCF-fix f

exch-modal : ∀ {∆ Γ J A B C} (∆’ : Cx modal)
→ (∆ , A , B) ++ ∆’ / Γ ` J :: C
–––––––––––––––
→ (∆ , B , A) ++ ∆’ / Γ ` J :: C
exch-modal ∆’ (iPCF-var x) = iPCF-var x
exch-modal ∆’ (iPCF-modal-var x) =
iPCF-modal-var (subsetdef x (cx-exch {∆ = ∆’}))
exch-modal ∆’ (iPCF-app d e) =
iPCF-app (exch-modal ∆’ d) (exch-modal ∆’ e)
exch-modal ∆’ (iPCF-lam-ext d) = iPCF-lam-ext (exch-modal ∆’ d)
exch-modal ∆’ (iPCF-lam-int d) = iPCF-lam-int d
exch-modal ∆’ (iPCF-boxI d) = iPCF-boxI (exch-modal ∆’ d)
exch-modal ∆’ (iPCF-boxE d e) =
iPCF-boxE (exch-modal ∆’ d) (exch-modal (∆’ , _) e)
exch-modal ∆’ (iPCF-fix f) = iPCF-fix f

weak : ∀ {∆ Γ Γ’ J A}
→ ∆ / Γ ` J :: A → Γ ⊆ Γ’
–––––––––––––––→ ∆ / Γ’ ` J :: A
209

weak (iPCF-var x) f = iPCF-var (f x)
weak (iPCF-modal-var x) f = iPCF-modal-var x
weak (iPCF-app d e) f = iPCF-app (weak d f) (weak e f)
weak (iPCF-lam-int d) f = iPCF-lam-int d
weak (iPCF-lam-ext d) f = iPCF-lam-ext (weak d (weakboth f))
weak (iPCF-boxI d) f = iPCF-boxI d
weak (iPCF-boxE d e) f =
iPCF-boxE (weak d f) (weak e f)
weak (iPCF-fix d) f = iPCF-fix d

weak-modal : ∀ {∆ ∆’ Γ J A}
→ ∆ / Γ ` J :: A → ∆ ⊆ ∆’
––––––––––––→ ∆’ / Γ ` J :: A
weak-modal (iPCF-var p) x = iPCF-var p
weak-modal (iPCF-modal-var p) x = iPCF-modal-var (x p)
weak-modal (iPCF-app t u) x = iPCF-app (weak-modal t x)
(weak-modal u x)
weak-modal (iPCF-lam-int t) x = iPCF-lam-int t
weak-modal (iPCF-lam-ext t) x = iPCF-lam-ext (weak-modal t x)
weak-modal (iPCF-boxI t) x = iPCF-boxI (weak-modal t x)
weak-modal (iPCF-boxE t u) x =
iPCF-boxE (weak-modal t x)
(weak-modal u (weakboth x))
weak-modal (iPCF-fix f) x = iPCF-fix f

– Including intensional into extensional.
incl : ∀ {∆ Γ A}
→ ∆ / Γ ` int :: A
210

–––––––––→ ∆ / Γ ` ext :: A
incl (iPCF-var x) = iPCF-var x
incl (iPCF-modal-var x) = iPCF-modal-var x
incl (iPCF-app d e) = iPCF-app (incl d) (incl e)
incl (iPCF-lam-int {int} d) =
iPCF-lam-ext (weak (weak-modal (incl d) subsetempty) (weakboth subsetempty))
incl (iPCF-lam-int {ext} d) =
iPCF-lam-ext (weak (weak-modal d subsetempty) (weakboth subsetempty))
incl (iPCF-boxI d) = iPCF-boxI d
incl (iPCF-boxE d e) = iPCF-boxE (incl d) (incl e)
incl (iPCF-fix f) = iPCF-fix f

incl-either-ext : ∀ {∆ J Γ A}
→ ∆ / Γ ` J :: A
–––––––––→ ∆ / Γ ` ext :: A
incl-either-ext {J = int} d = incl d
incl-either-ext {J = ext} d = d

incl-either-int : ∀ {∆ J Γ A}
→ ∆ / Γ ` int :: A
–––––––––→ ∆ / Γ ` J :: A
incl-either-int {J = int} d = d
incl-either-int {J = ext} d = incl d
– Cut.

211

cut-ext : ∀ {∆ Γ J A B} → (Γ’ : Cx modal)
→ ∆ / Γ ` ext :: A

→ ∆ / Γ , A ++ Γ’ ` J :: B

––––––––––––––––––––––––
→ ∆ / Γ ++ Γ’ ` ext :: B
cut-ext · d (iPCF-var top) = d
cut-ext · d (iPCF-var (pop x)) = iPCF-var x
cut-ext (Γ’ , B) d (iPCF-var top) = iPCF-var top
cut-ext (Γ’ , A’) d (iPCF-var (pop x)) =
weak (cut-ext {J = ext} Γ’ d (iPCF-var x)) (weakone subsetid)
cut-ext Γ’ d (iPCF-modal-var p) = iPCF-modal-var p
cut-ext Γ’ d (iPCF-app t u) = iPCF-app (cut-ext Γ’ d t) (cut-ext Γ’ d u)
cut-ext Γ’ d (iPCF-lam-int e) = incl (iPCF-lam-int e)
cut-ext Γ’ d (iPCF-lam-ext e) = iPCF-lam-ext (cut-ext (Γ’ , _) d e)
cut-ext Γ’ d (iPCF-boxI e) = iPCF-boxI e
cut-ext Γ’ d (iPCF-boxE t u) =
iPCF-boxE (cut-ext Γ’ d t)
(cut-ext Γ’ (weak-modal d (weakone (subsetid))) u)
cut-ext Γ’ d (iPCF-fix f) = iPCF-fix f

cut-int : ∀ {∆ Γ J A B} → (Γ’ : Cx modal)
→ ∆ / Γ ` int :: A

→ ∆ / Γ , A ++ Γ’ ` J :: B

––––––––––––––––––––––––
→ ∆ / Γ ++ Γ’ ` J :: B
cut-int · d (iPCF-var top) = incl-either-int d
cut-int · d (iPCF-var (pop x)) = iPCF-var x
cut-int (Γ’ , B) d (iPCF-var top) = iPCF-var top
cut-int (Γ’ , A’) d (iPCF-var (pop x)) =
weak (cut-int Γ’ d (iPCF-var x)) (weakone subsetid)
cut-int Γ’ d (iPCF-modal-var p) = iPCF-modal-var p
cut-int Γ’ d (iPCF-app t u) = iPCF-app (cut-int Γ’ d t) (cut-int Γ’ d u)
212

cut-int Γ’ d (iPCF-lam-int e) = iPCF-lam-int e
cut-int Γ’ d (iPCF-lam-ext e) = iPCF-lam-ext (cut-ext (Γ’ , _) (incl d) e)
cut-int Γ’ d (iPCF-boxI e) = iPCF-boxI e
cut-int Γ’ d (iPCF-boxE t u) =
iPCF-boxE (cut-int Γ’ d t)
(cut-int Γ’ (weak-modal d (weakone (subsetid))) u)
cut-int Γ’ d (iPCF-fix e) = iPCF-fix e

cut-modal : ∀ {∆ Γ J A B} → (∆’ : Cx modal)
→ ∆ / · ` int :: A

→ ∆ , A ++ ∆’ / Γ ` J :: B

–––––––––––––––––––––––––
→ ∆ ++ ∆’ / Γ ` J :: B
cut-modal ∆’ d (iPCF-var x) = iPCF-var x
cut-modal · d (iPCF-modal-var top) = incl-either-int (weak d subsetempty)
cut-modal · d (iPCF-modal-var (pop x)) = iPCF-modal-var x
cut-modal (∆’ , B) d (iPCF-modal-var top) = iPCF-modal-var top
cut-modal (∆’ , A’) d (iPCF-modal-var (pop x)) =
weak-modal (cut-modal ∆’ d (iPCF-modal-var x)) (weakone subsetid)
cut-modal ∆’ d (iPCF-app p q) =
iPCF-app (cut-modal ∆’ d p) (cut-modal ∆’ d q)
cut-modal ∆’ d (iPCF-lam-ext e) = iPCF-lam-ext (cut-modal ∆’ d e)
cut-modal ∆’ d (iPCF-lam-int e) = iPCF-lam-int e
cut-modal ∆’ d (iPCF-boxI e) = iPCF-boxI (cut-modal ∆’ d e)
cut-modal ∆’ d (iPCF-boxE p q) =
iPCF-boxE (cut-modal ∆’ d p) (cut-modal (∆’ , _) d q)
cut-modal ∆’ d (iPCF-fix f) = iPCF-fix f

213

Bibliography
Samson Abramsky. The Lazy Lambda Calculus. In Research Topics in Functional
Programming, pages 65–117. Addison Wesley, 1990. URL https://www.cs.ox.ac.
uk/files/293/lazy.pdf.
Samson Abramsky. What are the Fundamental Structures of Concurrency? Electronic
Notes in Theoretical Computer Science, 162:37–41, 2006. ISSN 15710661. doi:
10.1016/j.entcs.2005.12.075. URL http://linkinghub.elsevier.com/retrieve/
pii/S1571066106004105.
Samson Abramsky. Notes on Intensional Recursion, 2012.
Samson Abramsky. Intensionality, Definability and Computation. In Alexandru Baltag and Sonja Smets, editors, Johan van Benthem on Logic and Information Dynamics, pages 121–142. Springer-Verlag, 2014. doi: 10.1007/978-3-319-06025-5_5.
URL https://dx.doi.org/10.1007/978-3-319-06025-5_5.
Samson Abramsky and Achim Jung. Domain Theory. Handbook of Logic in Computer Science, 3:1–168, 1994.

URL https://www.cs.bham.ac.uk/$\sim$axj/

pub/papers/handy1.pdf.
Samson Abramsky and Guy McCusker.

Linearity, Sharing and State: a fully

abstract game semantics for Idealized Algol with active expressions.

Elec-

tronic Notes in Theoretical Computer Science, 3:2–14, 1996. ISSN 15710661.
doi: 10.1016/S1571-0661(05)80398-6. URL http://linkinghub.elsevier.com/
retrieve/pii/S1571066105803986.
Samson Abramsky and Nikos Tzevelekos. Introduction to Categories and Categorical
Logic. In Bob Coecke, editor, New Structures for Physics, pages 3–94. SpringerVerlag, 2011. doi: 10.1007/978-3-642-12821-9_1. URL http://arxiv.org/abs/
1102.1313.

214

Samson Abramsky, Radha Jagadeesan, and Pasquale Malacaria. Full Abstraction for
PCF. Information and Computation, 163:409–470, 1996.
Samson Abramsky, Kohei Honda, and G McCusker. A fully abstract game semantics for general references. In Proceedings of theThirteenth Annual IEEE Symposium on Logic in Computer Science. IEEE Comput. Soc, 1998. ISBN 0-8186-85069. doi: 10.1109/LICS.1998.705669. URL http://ieeexplore.ieee.org/lpdocs/
epic03/wrapper.htm?arnumber=705669.
Leonard M. Adleman. An Abstract Theory of Computer Viruses. In Advances
in Cryptology - CRYPTO’ 88, volume 403 of Lecture Notes in Computer Science, pages 354–374. Springer New York, New York, NY, 1990. ISBN 3-54097196-3. doi: 10.1007/0-387-34799-2_28. URL https://dx.doi.org/10.1007/
0-387-34799-2_28.
Thorsten Altenkirch, Nils Anders Danielsson, and Nicolai Kraus. Partiality, Revisited:
The Partiality Monad as a Quotient Inductive-Inductive Type. In Proceedings of the
20th International Conference on Foundations of Software Science and Computation Structures (FoSSaCS), oct 2017. URL http://arxiv.org/abs/1610.09254.
Steve Awodey. Category Theory. Oxford Logic Guides. Oxford University Press,
2010. ISBN 9780191612558.
zLs8BAAAQBAJ.

URL https://books.google.co.uk/books?id=

Andrew Graham Barber. Dual Intuitionistic Linear Logic. Technical report,
ECS-LFCS-96-347, Laboratory for Foundations of Computer Science, University of Edinburgh, 1996.

URL http://www.lfcs.inf.ed.ac.uk/reports/96/

ECS-LFCS-96-347/.
Henk Barendregt. Lambda Calculus: Its Syntax and Semantics. North-Holland, Amsterdam, 1984. ISBN 978-0444875082.
Henk Barendregt.

Self-Interpretation in Lambda Calculus.

Journal of Func-

tional Programming, 1(2):229–233, 1991. URL https://dx.doi.org/10.1017/
S0956796800020062.
Andrej

Bauer.

ulus

of

tion

(blog),

Definability

and

continuity

functional.

2011.

URL

extensionality
Mathematics

of
and

the

mod-

Computa-

http://math.andrej.com/2011/07/27/

definability-and-extensionality-of-the-modulus-of-continuity-functional/.
215

Alan Bawden.

Quasiquotation in LISP.

In Proceedings of the 6th ACM SIG-

PLAN Workshop on Partial Evaluation and Semantics-Based Program Manipulation (PEPM ’99), 1999. URL http://repository.readscheme.org/ftp/papers/
pepm99/bawden.pdf.
Michael J. Beeson. Foundations of Constructive Mathematics. Springer Berlin Heidelberg, 1985. ISBN 978-3-642-68954-3. doi: 10.1007/978-3-642-68952-9. URL
https://dx.doi.org/10.1007/978-3-642-68952-9.
Martin Berger.

Foundations of meta-programming, 2016.

URL http://users.

sussex.ac.uk/$\sim$mfb21/publications/mp-slides/slides.pdf.
Gavin M. Bierman. Program equivalence in a linear functional language. Journal
of Functional Programming, 10(2):167–190, 2000. ISSN 09567968. doi: 10.1017/
S0956796899003639.
Gavin M. Bierman and Valeria de Paiva. On an Intuitionistic Modal Logic. Studia
Logica, 65(3):383–416, 2000. doi: 10.1023/A:1005291931660. URL https://dx.
doi.org/10.1023/A:1005291931660.
Lars Birkedal. Developing theories of types and computability via realizability. Electronic Notes in Theoretical Computer Science, 34:2, 2000. ISSN 15710661. doi:
10.1016/S1571-0661(05)80642-5. URL http://cs.au.dk/$\sim$birke/papers/
devttc.pdf.
Errett Bishop. Foundations of Constructive Analysis. McGraw-Hill, 1967.
B Bloom and J G Riecke. LCF Should Be Lifted. 1989.
Manuel Blum. On the size of machines. Information and Control, 11(3):257–265,
sep 1967. ISSN 00199958. doi: 10.1016/S0019-9958(67)90546-3. URL http://
linkinghub.elsevier.com/retrieve/pii/S0019995867905463.
Achim Blumensath and Viktor Winschel. A Coalgebraic Framework for Games in
Economics. 2013.
Guillaume Bonfante, Matthieu Kaczmarek, and Jean-Yves Marion. Toward an Abstract Computer Virology. In Dan Van Hung and Martin Wirsing, editors, Theoretical Aspects of Computing – ICTAC 2005: Second International Colloquium,
Hanoi, Vietnam, October 17-21, 2005. Proceedings, volume 3722 of Lecture Notes
in Computer Science, pages 579–593. Springer Berlin Heidelberg, 2005. ISBN
216

3540291075. doi: 10.1007/11560647_38. URL http://link.springer.com/10.
1007/11560647_38.
Guillaume Bonfante, Matthieu Kaczmarek, and J.-Y. Marion. On Abstract Computer
Virology from a Recursion Theoretic Perspective. Journal in Computer Virology,
1(3):45–54, 2006. ISSN 1772-9890. doi: 10.1007/s11416-005-0007-4. URL http:
//link.springer.com/10.1007/s11416-005-0007-4.
Guillaume Bonfante, Matthieu Kaczmarek, and Jean-Yves Marion. A Classification
of Viruses Through Recursion Theorems. In S Barry Cooper, Benedikt Löwe, and
Andrea Sorbi, editors, Computation and Logic in the Real World: Third Conference
on Computability in Europe, CiE 2007, Siena, Italy, June 18-23, 2007. Proceedings,
volume 4497 of Lecture Notes in Computer Science, pages 73–82. Springer Berlin
Heidelberg, Berlin, Heidelberg, 2007. doi: 10.1007/978-3-540-73001-9_8. URL
http://link.springer.com/10.1007/978-3-540-73001-9_8.
George S. Boolos. The Logic of Provability. Cambridge University Press, Cambridge,
1994. ISBN 9780511625183. doi: 10.1017/CBO9780511625183. URL https://dx.
doi.org/10.1017/CBO9780511625183.
Ana Bove and Venanzio Capretta. Modelling general recursion in type theory. Mathematical Structures in Computer Science, 15(4):671–708, aug 2005.
Torben Braüner. The Girard Translation Extended with Recursion. In Leszek Pacholski and Jerzy Tiuryn, editors, Computer Science Logic, 8th International Workshop,
CSL ’94, Kazimierz, Poland, September 25-30, 1994, Selected Papers, number Lecture Notes in Computer Science 933, pages 31–45, 1995. ISBN 3-540-60017-5. doi:
10.1007/BFb0022245.
Torben Braüner. A general adequacy result for a linear functional language. Theoretical Computer Science, 177(1):27–58, 1997. ISSN 03043975. doi: 10.1016/
S0304-3975(96)00233-2.
Venanzio Capretta. General recursion via coinductive types. Logical Methods in
Computer Science, 1(2):1–28, jul 2005. ISSN 18605974. doi: 10.2168/LMCS-1(2:
1)2005. URL http://www.lmcs-online.org/ojs/viewarticle.php?id=55.
John Case and Samuel E. Moelius.
Self-reference.

Properties Complementary to Program

In Luděk Kučera and Antonín Kučera, editors, Proceedings

217

of the 32nd International Symposium on Mathematical Foundations of Computer Science 2007 (MFCS’07), volume 4708 of Lecture Notes in Computer
Science, pages 253–263, Berlin, Heidelberg, 2007. Springer Berlin Heidelberg. doi: 10.1007/978-3-540-74456-6_24. URL https://dx.doi.org/10.1007/
978-3-540-74456-6_24.
John Case and Samuel E. Moelius. Characterizing programming systems allowing
program self-reference. Theory of Computing Systems, 45(4):756–772, 2009a. ISSN
14324350. doi: 10.1007/s00224-009-9168-8. URL https://dx.doi.org/10.1007/
s00224-009-9168-8.
John Case and Samuel E. Moelius. Independence Results for n-Ary Recursion Theorems. In Miroslaw Kutylowski, Witold Charatonik, and Maciej Gebala, editors, Fundamentals of Computation Theory: Proceedings of the 17th International
Symposium, FCT 2009, Wrocław, Poland, September 2-4, 2009, volume 5699 of
Lecture Notes in Computer Science, pages 38–49. Springer, 2009b. ISBN 978-3642-03408-4. doi: 10.1007/978-3-642-03409-1_5. URL https://dx.doi.org/10.
1007/978-3-642-03409-1_5.
John Case and Samuel E. Moelius.
Scott Subdomains.

Program Self-Reference in Constructive

Theory of Computing Systems, 51(1):22–49, 2012.

ISSN

14324350. doi: 10.1007/s00224-011-9372-1. URL https://dx.doi.org/10.1007/
s00224-011-9372-1.
J. R. B. Cockett and Pieter J. W. Hofstra. Introduction to Turing categories. Annals
of Pure and Applied Logic, 156(2-3):183–209, 2008. doi: 10.1016/j.apal.2008.04.005.
URL http://dx.doi.org/10.1016/j.apal.2008.04.005.
J. R. B. Cockett and Pieter J. W. Hofstra. Categorical simulations. Journal of Pure
and Applied Algebra, 214(10):1835–1853, 2010. ISSN 00224049. doi: 10.1016/j.
jpaa.2009.12.028. URL http://dx.doi.org/10.1016/j.jpaa.2009.12.028.
Fred Cohen. Computational aspects of computer viruses. Computers and Security, 8
(4):325–344, 1989. ISSN 01674048. doi: 10.1016/0167-4048(89)90094-1.
Robert L. Constable and Scott F. Smith. Computational foundations of basic recursive function theory. Theoretical Computer Science, 121(1-2):89–112, dec 1993.
ISSN 03043975. doi: 10.1016/0304-3975(93)90085-8. URL https://dx.doi.org/
10.1016/0304-3975(93)90085-8.
218

Roy L. Crole. Categories for Types. Cambridge University Press, 1993. ISBN 0 521
45701 7.
Djordje Čubrić, Peter Dybjer, and Philip J. Scott.

Normalization and the

Yoneda embedding. Mathematical Structures in Computer Science, 8(2):153–192,
1998. doi: 10.1017/s0960129597002508. URL https://dx.doi.org/10.1017/
s0960129597002508.
Nigel Cutland. Computability: An Introduction to Recursive Function Theory. Cambridge University Press, 1980. ISBN 9780521294652.
Olivier Danvy and Karoline Malmkjaer. Intensions and extensions in a reflective
tower. In Proceedings of the 1988 ACM conference on LISP and functional programming (LFP ’88), pages 327–341, New York, New York, USA, 1988. ACM
Press. ISBN 089791273X. doi: 10.1145/62678.62725. URL https://dx.doi.org/
10.1145/62678.62725.
Rowan Davies. A Temporal-Logic Approach to Binding-Time Analysis. Technical
report, BRICS Report Series RS-95-51, 1995.
Rowan Davies. A temporal-logic approach to binding-time analysis. Proceedings 11th
Annual IEEE Symposium on Logic in Computer Science, pages 184–195, 1996.
ISSN 1043-6871. doi: 10.1109/LICS.1996.561317.
Rowan Davies. A Temporal Logic Approach to Binding-Time Analysis. Journal of
the ACM, 64(1):1–45, mar 2017. ISSN 00045411. doi: 10.1145/3011069. URL
http://dx.doi.org/10.1145/3011069.
Rowan Davies and Frank Pfenning. A modal analysis of staged computation. In Proceedings of the 23rd ACM SIGPLAN-SIGACT Symposium on Principles of Programming Languages (POPL’96), pages 258–270, 1996. ISBN 0897917693. doi:
10.1145/382780.382785. URL https://dx.doi.org/10.1145/382780.382785.
Rowan Davies and Frank Pfenning. A modal analysis of staged computation. Journal
of the ACM, 48(3):555–604, 2001. ISSN 00045411. doi: 10.1145/382780.382785.
URL https://dx.doi.org/10.1145/382780.382785.
François-Nicola Demers and Jacques Malenfant. Reflection in logic, functional and
object-oriented programming: a Short Comparative Study. In Proceedings of the
IJCAI ’95 Workshop on Reflection and Metalevel Architectures and their Applications in AI, pages 29–38, 1995.
219

Apostolos Doxiadis. Uncle Petros and Goldbach’s Conjecture. Faber and Faber, 2001.
Samuel Eilenberg and G. Max Kelly. Closed Categories. In Proceedings of the
Conference on Categorical Algebra, pages 421–562. Springer Berlin Heidelberg,
Berlin, Heidelberg, 1966. doi: 10.1007/978-3-642-99902-4_22. URL http://www.
springerlink.com/index/10.1007/978-3-642-99902-4_22.
A. P. Ershov. On the partial computation principle. Information Processing Letters,
6(2):38–41, apr 1977. ISSN 00200190. doi: 10.1016/0020-0190(77)90078-3. URL
https://dx.doi.org/10.1016/0020-0190(77)90078-3.
A. P. Ershov. Mixed computation: potential applications and problems for study.
Theoretical Computer Science, 18(1):41–67, apr 1982. ISSN 03043975. doi: 10.1016/
0304-3975(82)90111-6. URL http://linkinghub.elsevier.com/retrieve/pii/
0304397582901116.
Martín Hötzel Escardó. A metric model of PCF, 1999. URL http://cs.bham.ac.
uk/$\sim$mhe/papers/metricpcf.pdf.
Melvin Fitting. Intensional Logic. In Edward N Zalta, editor, The Stanford Encyclopedia of Philosophy. Metaphysics Research Lab, Stanford University, summer ’15
edition, 2015. URL https://plato.stanford.edu/archives/sum2015/entries/
logic-intensional/.
Daniel P. Friedman and Mitchell Wand. Reification: Reflection without metaphysics.
In Proceedings of the 1984 ACM Symposium on LISP and functional programming
(LFP ’84), pages 348–355, New York, New York, USA, 1984. ACM Press. ISBN
0897911423. doi: 10.1145/800055.802051. URL https://dx.doi.org/10.1145/
800055.802051.
Harvey Friedman. FOM: renaming recursion theory, 1998. URL http://www.cs.
nyu.edu/pipermail/fom/1998-August/002017.html.
Yoshihiko Futamura. Partial evaluation of computation process–an approach to a
compiler-compiler. Higher-Order and Symbolic Computation, 12(4):381–391, 1999.
ISSN 13883690. doi: 10.1023/A:1010095604496. URL http://link.springer.
com/article/10.1023/A:1010095604496.
Murdoch J. Gabbay and Aleksandar Nanevski. Denotation of contextual modal type
theory (CMTT): Syntax and meta-programming. Journal of Applied Logic, 11
220

(1):1–29, mar 2013. ISSN 15708683. doi: 10.1016/j.jal.2012.07.002. URL http:
//dx.doi.org/10.1016/j.jal.2012.07.002.
R Gandy. The Confluence of Ideas in 1936. In A Half-century Survey on The Universal
Turing Machine, pages 55–111, New York, NY, USA, 1988. Oxford University Press,
Inc. ISBN 0-19-853741-7. URL http://dl.acm.org/citation.cfm?id=57249.
57252.
R. O. Gandy.

On the axiom of extensionality – Part I.

The Journal

of Symbolic Logic, 21(01):36–48, mar 1956.
ISSN 0022-4812.
doi: 10.
2307/2268484. URL https://www.cambridge.org/core/product/identifier/
S0022481200085352/type/journal_article.
R. O. Gandy.
On the axiom of extensionality, Part II.
The Journal of
Symbolic Logic, 24(04):287–300, dec 1959.
ISSN 0022-4812.
doi: 10.
2307/2963897. URL https://www.cambridge.org/core/product/identifier/
S0022481200123266/type/journal_article.
Jean-Yves Girard.

Interprétation fonctionelle et élimination des coupures de

l’arithmétique d’ordre supérieur. PhD thesis, Université Paris VII, 1972.
Jean-Yves Girard. The Blind Spot: Lectures on Logic. European Mathematical Society, 2011. ISBN 978-3037190883.
Jean-Yves Girard, Yves Lafont, and Paul Taylor. Proofs and Types. Cambridge
University Press, 1989.
Paul Graham. On LISP: Advanced Techniques for Common LISP. Prentice Hall,
1993. ISBN 0130305529.
Carl A. Gunter. Semantics of programming languages: structures and techniques.
Foundations of Computing. The MIT Press, 1992.
Torben Amtoft Hansen, Thomas Nikolajsen, Jesper Larsson Träff, and Neil D. Jones.
Experiments with Implementations of Two Theoretical Constructions. In Proceedings of the Symposium on Logical Foundations of Computer Science: Logic at Botik
’89, pages 119–133, London, UK, 1989. Springer-Verlag. ISBN 3-540-51237-3. URL
http://dl.acm.org/citation.cfm?id=646798.759646.

221

Robert
2014.

Harper.

Old

URL

Neglected

Theorems

Are

Still

Theorems,

https://existentialtype.wordpress.com/2014/03/20/

old-neglected-theorems-are-still-theorems/.
Douglas R Hofstadter. Godel, Escher, Bach: An Eternal Golden Braid. Basic Books,
Inc., New York, NY, USA, 1979. ISBN 0465026850.
Hagen Huwig and Axel Poigné. A note on inconsistencies caused by fixpoints in a
cartesian closed category. Theoretical Computer Science, 73(1):101–112, jun 1990.
ISSN 03043975. doi: 10.1016/0304-3975(90)90165-E. URL http://linkinghub.
elsevier.com/retrieve/pii/030439759090165E.
J. M. E. Hyland.

The Effective Topos.

In Anne S. Troelstra and Dick van

Dalen, editors, The L. E. J. Brouwer Centenary Symposium, pages 165–216.
North-Holland, 1982. URL https://webdpmms.maths.cam.ac.uk/$\sim$martin/
Research/Oldpapers/hyland-effectivetopos.pdf.
J.M.E. Hyland. The Forgotten Turing. In S. Barry Cooper and Andrew Hodges,
editors, The Once and Future Turing, pages 20–33. Cambridge University Press,
Cambridge, 2016. doi: 10.1017/CBO9780511863196.005. URL http://ebooks.
cambridge.org/ref/id/CBO9780511863196A012.
J.M.E. Hyland and C.-H.L. Ong. On Full Abstraction for PCF: I, II, and III. Information and Computation, 163(2):285–408, 2000. doi: 10.1006/inco.2000.2917.
URL http://linkinghub.elsevier.com/retrieve/pii/S0890540100929171.
Martin Hyland and John Power. The Category Theoretic Understanding of Universal
Algebra: Lawvere Theories and Monads. Electronic Notes in Theoretical Computer
Science, 172:437–458, 2007. ISSN 15710661. doi: 10.1016/j.entcs.2007.02.019.
Bart Jacobs. Categorical Logic and Type Theory. Number 141 in Studies in Logic
and the Foundations of Mathematics. North Holland, Amsterdam, 1999.
Barry Jay. Programs as Data Structures in λSF-Calculus. Electronic Notes in Theoretical Computer Science, 325:221–236, 2016. ISSN 15710661. doi: 10.1016/j.entcs.
2016.09.040. URL http://dx.doi.org/10.1016/j.entcs.2016.09.040.
Barry Jay and Thomas Given-Wilson. A Combinatory Account of Internal Structure.
The Journal of Symbolic Logic, 76(3):807–826, 2011. URL http://www.jstor.
org/stable/23041848.
222

Barry Jay and Jens Palsberg. Typed self-interpretation by pattern matching. ACM
SIGPLAN Notices, 46(9):247, sep 2011. ISSN 03621340. doi: 10.1145/2034574.
2034808. URL http://dl.acm.org/citation.cfm?doid=2034574.2034808.
Neil D. Jones. Computer Implementation and Applications of Kleene’s S-M-N and
Recursion Theorems. In Yiannis N Moschovakis, editor, Logic from Computer
Science: Proceedings of a Workshop Held November 13-17, 1989 [at MSRI], volume 21 of Mathematical Sciences Research Institute Publications, pages 243–263.
Springer New York, 1992. doi: 10.1007/978-1-4612-2822-6_9.
//dx.doi.org/10.1007/978-1-4612-2822-6_9.

URL https:

Neil D. Jones. An introduction to partial evaluation. ACM Computing Surveys,
28(3):480–503, 1996. ISSN 03600300. doi: 10.1145/243439.243447. URL http:
//doi.acm.org/10.1145/243439.243447.
Neil D. Jones. Computability and Complexity: From a Programming Perspective.
Foundations of Computing. MIT Press, 1997.
Neil D. Jones. A Swiss Pocket Knife for Computability. Electronic Proceedings in
Theoretical Computer Science, 129:1–17, sep 2013. ISSN 2075-2180. doi: 10.4204/
EPTCS.129.1. URL http://arxiv.org/abs/1309.5128v1.
Neil D. Jones, Carsten K. Gomard, and Peter Sestoft. Partial Evaluation and Automatic Program Generation. Prentice Hall International, 1993. ISBN 0-13-020249-5.
Akira Kanda. Recursion theorems and effective domains. Annals of Pure and Applied
Logic, 38(3):289–300, 1988. ISSN 01680072. doi: 10.1016/0168-0072(88)90029-2.
G. A. Kavvos. The Many Worlds of Modal λ-calculi: I. Curry-Howard for Necessity,
Possibility and Time. CoRR, 2016.
G. A. Kavvos. On the Semantics of Intensionality. In Javier Esparza and Andrzej S. Murawski, editors, Proceedings of the 20th International Conference on
Foundations of Software Science and Computation Structures (FoSSaCS), volume 10203 of Lecture Notes in Computer Science, pages 550–566. Springer-Verlag
Berlin Heidelberg, 2017a. doi: 10.1007/978-3-662-54458-7_32.
//dx.doi.org/10.1007/978-3-662-54458-7_32.

URL https:

G. A. Kavvos. Dual-context calculi for modal logic. In 2017 32nd Annual ACM/IEEE
Symposium on Logic in Computer Science (LICS). IEEE, 2017b. ISBN 978-1-50903018-7. doi: 10.1109/LICS.2017.8005089.
223

G. A. Kavvos. Dual-context calculi for modal logic (technical report). Technical report, University of Oxford, 2017c. URL http://www.lambdabetaeta.eu/papers/
dualcalc.pdf.
G. A. Kavvos. Intensionality, Intensional Recursion, and the Gödel-Löb axiom. In
Proceedings of 7th Workshop on Intuitionistic Modal Logic and Applications (IMLA
2017), 2017d.
Oleg Kiselyov. In’yō to ichiokubai kōsokuka no monogatari: Kansū puroguramingu ni
yoru Kleene daini saiki teiri no shōmei [A story of quotation and 108 -fold speed-up:
A proof of Kleene’s second recursion theorem by functional programming]. In The
17th Programming and Programming Language Workshop (PPL 2015), 2015. URL
http://okmij.org/ftp/Computation/Kleene.pdf.
S. C. Kleene. λ-definability and recursiveness. Duke Mathematical Journal, 2(2):340–
353, 1936. ISSN 0012-7094. doi: 10.1215/S0012-7094-36-00227-2. URL https:
//dx.doi.org/10.1215/S0012-7094-36-00227-2.
Stephen C. Kleene. On notation for ordinal numbers. The Journal of Symbolic
Logic, 3(04):150–155, 1938. ISSN 0022-4812. doi: 10.2307/2267778. URL https:
//dx.doi.org/10.2307/2267778.
Stephen C. Kleene. Introduction to Metamathematics. North-Holland, Amsterdam,
1952.
Stephen C. Kleene. Origins of Recursive Function Theory. IEEE Annals of the History
of Computing, 3(1):52–67, 1981. ISSN 1058-6180. doi: 10.1109/MAHC.1981.10004.
URL https://dx.doi.org/10.1109/MAHC.1981.10004.
Satoshi Kobayashi. Monad as modality. Theoretical Computer Science, 175(1):29–74,
1997. doi: 10.1016/S0304-3975(96)00169-7.
Joachim Lambek and Philip J. Scott. Introduction to Higher-Order Categorical Logic.
Cambridge University Press, 1988. ISBN 9780521356534.
Elaine Landry, editor. Categories for the Working Philosopher. Oxford University
Press, 2017. ISBN 9780198748991.
J.-L. Lassez, V.L. Nguyen, and E.a. Sonenberg. Fixed point theorems and semantics:
a folk tale. Information Processing Letters, 14(3):112–116, 1982. ISSN 00200190.
doi: 10.1016/0020-0190(82)90065-5.
224

F. William Lawvere. Diagonal arguments and cartesian closed categories. In Category Theory, Homology Theory and their Applications II, number 15, pages
134–145. Springer Berlin Heidelberg, 1969. ISBN 978-3-540-04611-0. doi: 10.
1007/BFb0080769. URL http://link.springer.com/content/pdf/10.1007/
BFb0080769.pdf.
F. William Lawvere. Diagonal arguments and cartesian closed categories. Reprints
in Theory and Applications of Categories, 15:1–13, 2006. URL http://www.tac.
mta.ca/tac/reprints/articles/15/tr15abs.html.
Paul Blain Levy. Call-by-Push-Value: A Functional-Imperative Synthesis. Semantic
Structures in Computation. Springer, 2003. ISBN 978-94-010-3752-5. doi: 10.1007/
978-94-007-0954-6.
Harry R Lewis and Christos H Papadimitriou. Elements of the Theory of Computation. Prentice Hall PTR, Upper Saddle River, NJ, USA, 2nd edition, 1997. ISBN
0132624788.
Tadeusz Litak. Constructive Modalities with Provability Smack. In Guram Bezhanishvili, editor, Leo Esakia on duality in modal and intuitionistic logics, pages 179–
208. Springer, 2014. doi: 10.1007/978-94-017-8860-1_8. URL https://www8.cs.
fau.de/ext/litak/esakiaarxivfull.pdf.
John R. Longley. Realizability Toposes and Language Semantics. PhD thesis, University of Edinburgh. College of Science and Engineering. School of Informatics.,
1995. URL http://www.lfcs.inf.ed.ac.uk/reports/95/ECS-LFCS-95-332/.
John R. Longley. Matching typed and untyped realizability. Electronic Notes in Theoretical Computer Science, 23(1):74–100, 1999a. ISSN 15710661. doi: 10.1016/
S1571-0661(04)00105-7.
URL http://linkinghub.elsevier.com/retrieve/
pii/S1571066104001057.
John R. Longley. Unifying Typed and Untyped Realizability, 1999b. URL http:
//homepages.inf.ed.ac.uk/jrl/Research/unifying.txt.
John R. Longley. Notions of computability at higher types I. In Logic Colloquium
2000: Proceedings of the Annual European Summer Meeting of the Association for
Symbolic Logic, held in Paris, France, July 23-31, 2000, volume 19 of Lecture Notes
in Logic, pages 32–142. A. K. Peters, 2005.

225

John R. Longley and Dag Normann. Higher-Order Computability. Theory and
Applications of Computability. Springer Berlin Heidelberg, Berlin, Heidelberg,
2015. ISBN 978-3-662-47991-9. doi: 10.1007/978-3-662-47992-6. URL https:
//dx.doi.org/10.1007/978-3-662-47992-6.
John R. Longley and Alex K. Simpson. A uniform approach to domain theory in
realizability models. Mathematical Structures in Computer Science, 7:469–505,
1997. doi: 10.1017/S0960129597002387. URL https://dx.doi.org/10.1017/
S0960129597002387.
Giuseppe Longo and Eugenio Moggi. Constructive natural deduction and its ‘omegaset’ interpretation. Mathematical Structures in Computer Science, 1(02):215, 1991.
ISSN 0960-1295. doi: 10.1017/S0960129500001298. URL http://www.journals.
cambridge.org/abstract_S0960129500001298.
Saunders Mac Lane. Categories for the Working Mathematician, volume 5 of Graduate
Texts in Mathematics. Springer New York, New York, NY, 1978. ISBN 978-1-44193123-8. doi: 10.1007/978-1-4757-4721-8. URL http://link.springer.com/10.
1007/978-1-4757-4721-8.
Michael Machtey and Paul Young. An introduction to the general theory of algorithms.
Theory of Computation Series. Elsevier North-Holland, New York, 1978. ISBN
9780444002266. URL http://books.google.co.uk/books?id=qncEAQAAIAAJ.
Michael Machtey, Karl Winklmann, and Paul Young. Simple Gödel Numberings,
Isomorphisms, and Programming Properties. SIAM Journal on Computing, 7(1):
39–60, feb 1978. ISSN 0097-5397. doi: 10.1137/0207003. URL https://dx.doi.
org/10.1137/0207003.
John Maraist, Martin Odersky, David N Turner, and Philip Wadler. Call-by-name,
call-by-value, call-by-need, and the linear lambda calculus. Electronic Notes in
Theoretical Computer Science, 1:370–392, 1995.
Jean-Yves Marion. From Turing machines to computer viruses. Philosophical Transactions of the Royal Society A: Mathematical, Physical and Engineering Sciences, 370
(1971):3319–3339, 2012. ISSN 1364-503X. doi: 10.1098/rsta.2011.0332. URL http:
//rsta.royalsocietypublishing.org/cgi/doi/10.1098/rsta.2011.0332.
Per Martin-Löf. Intuitionistic type theory, volume 1 of Studies in Proof Theory.
Bibliopolis, 1984. ISBN 88-7088-105-9.
226

Per Martin-Löf. An intuitionistic theory of types. In Giovanni Sambin and Jan M
Smith, editors, Twenty-five years of constructive type theory (Venice, 1995), volume 36 of Oxford Logic Guides, pages 127–172. Oxford University Press, 1998.
Paul-André Melliès. Categorical Semantics of Linear Logic. In Pierre-Louis Curien,
Hugo Herbelin, Jean-Louis Krivine, and Paul-André Melliès, editors, Panoramas
et synthèses 27: Interactive models of computation and program behaviour. Société
Mathématique de France, 2009. ISBN 978-2-85629-273-0. URL http://www.pps.
univ-paris-diderot.fr/$\sim$mellies/papers/panorama.pdf.
John C. Mitchell. Foundations for programming languages. Foundations of Computing. The MIT Press, 1996. ISBN 9780262133210.
Samuel E. Moelius. Program Self-Reference. PhD thesis, University of Delaware,
2009.
Torben Æ. Mogensen. Efficient self-interpretation in lambda calculus. Journal of Functional Programming, 2(03):345–364, jul 1992. ISSN 0956-7968.
doi: 10.1017/S0956796800000423. URL http://www.journals.cambridge.org/
abstract_S0956796800000423.
Eugenio Moggi. Computational lambda-calculus and monads. In [1989] Proceedings. Fourth Annual Symposium on Logic in Computer Science, pages 14–23. IEEE
Comput. Soc. Press, 1989. ISBN 0-8186-1954-6. doi: 10.1109/LICS.1989.39155.
Eugenio Moggi. Notions of computation and monads. Information and Computation,
93(1):55–92, 1991. ISSN 08905401. doi: 10.1016/0890-5401(91)90052-4. URL
https://dx.doi.org/10.1016/0890-5401(91)90052-4.
Yiannis N. Moschovakis. Sense and Denotation as Algorithm and Value. Logic Colloquium ’90: ASL Summer Meeting in Helsinki, 2:210–249, 1993. URL http:
//www.math.ucla.edu/$\sim$ynm/papers/frege.pdf.
Yiannis N Moschovakis. Kleene’s Amazing Second Recursion Theorem. Bulletin of
Symbolic Logic, 16(2):189–239, 2010.
Philip S. Mulry. Generalized Banach-Mazur functionals in the topos of recursive
sets. Journal of Pure and Applied Algebra, 26(1):71–83, oct 1982. ISSN 00224049.
doi: 10.1016/0022-4049(82)90030-5. URL http://linkinghub.elsevier.com/
retrieve/pii/0022404982900305.
227

Philip S. Mulry. A categorical approach to the theory of computation. Annals of
Pure and Applied Logic, 43(3):293–305, aug 1989. ISSN 01680072. doi: 10.1016/
0168-0072(89)90072-9. URL http://linkinghub.elsevier.com/retrieve/pii/
0168007289900729.
J. Myhill and J. C. Shepherdson. Effective operations on partial recursive functions.
Zeitschrift für Mathematische Logik und Grundlagen der Mathematik, 1(4):310–
317, 1955. ISSN 00443050. doi: 10.1002/malq.19550010407. URL http://doi.
wiley.com/10.1002/malq.19550010407.
Aleksandar Nanevski. Meta-programming with names and necessity. ACM SIGPLAN
Notices, 37:206–217, 2002. ISSN 03621340. doi: 10.1145/583852.581498.
Aleksandar Nanevski and Frank Pfenning. Staged computation with names and necessity. Journal of Functional Programming, 15(06):893, 2005. ISSN 0956-7968.
doi: 10.1017/S095679680500568X.
Flemming Nielson and Hanne Riis Nielson. Two-Level Functional Languages. Cambridge Tracts in Theoretical Computer Science. Cambridge University Press, 1992.
ISBN 9780521018470.
Bengt Nordström, Kent Petersson, and Jan M. Smith. Programming in Martin-Löf ’s
Type Theory: an Introduction. Oxford University Press, 1990. ISBN 0-19-853814-6.
doi: 10.1016/0377-0427(91)90052-L.
Piergiorgio Odifreddi. Classical recursion theory: The theory of functions and sets of
natural numbers. Elsevier, 1992. ISBN 9780444894830.
Robert A. Di Paola and Alex Heller. Dominical Categories: Recursion Theory without
Elements. The Journal of Symbolic Logic, 52(3):594, sep 1987. ISSN 00224812.
doi: 10.2307/2274352. URL http://www.jstor.org/stable/2274352?origin=
crossref.
Frank Pfenning and Rowan Davies. A judgmental reconstruction of modal logic.
Mathematical Structures in Computer Science, 11(4):511–540, 2001. ISSN 09601295. doi: 10.1017/S0960129501003322. URL https://dx.doi.org/10.1017/
S0960129501003322.
Richard Alan Platek. Foundations of Recursion Theory. PhD thesis, Stanford University, 1966.
228

Gordon Plotkin and John Power.

Computational Effects and Operations: An

Overview. Electronic Notes in Theoretical Computer Science, 73(March 2002):
149–163, oct 2004. ISSN 15710661. doi: 10.1016/j.entcs.2004.08.008.
http://linkinghub.elsevier.com/retrieve/pii/S1571066104050893.

URL

Gordon D. Plotkin. LCF considered as a programming language. Theoretical Computer Science, 5(3):223–255, 1977. ISSN 03043975. doi: 10.1016/0304-3975(77)
90044-5.
Gordon D. Plotkin. Type theory and recursion. In Proceedings Eighth Annual IEEE
Symposium on Logic in Computer Science, page 374. IEEE Comput. Soc. Press,
1993. ISBN 0-8186-3140-6. doi: 10.1109/LICS.1993.287571. URL https://dx.
doi.org/10.1109/LICS.1993.287571.
Axel Poigné. Basic category theory. In Handbook of Logic in Computer Science.
Clarendon Press, 1992. ISBN 9780198537359.
Andrew Polonsky. Axiomatizing the Quote. In Marc Bezem, editor, Computer Science Logic (CSL’11) - 25th International Workshop/20th Annual Conference of the
EACSL, volume 12 of Leibniz International Proceedings in Informatics (LIPIcs),
pages 458–469. Schloss Dagstuhl - Leibniz-Zentrum fuer Informatik, 2011. doi:
10.4230/LIPIcs.CSL.2011.458. URL https://dx.doi.org/10.4230/LIPIcs.CSL.
2011.458.
Gregory A. Riccardi. The Independence of Control Structures in Abstract Programming Systems. PhD thesis, State University of New York at Buffalo, 1980.
Gregory A. Riccardi. The independence of control structures in abstract programming
systems. Journal of Computer and System Sciences, 22(2):107–143, apr 1981. ISSN
00220000. doi: 10.1016/0022-0000(81)90024-6. URL https://dx.doi.org/10.
1016/0022-0000(81)90024-6.
Hartley Rogers. Gödel numberings of partial recursive functions. The Journal of
Symbolic Logic, 23(03):331–341, sep 1958. ISSN 0022-4812. doi: 10.2307/2964292.
URL http://www.journals.cambridge.org/abstract_S0022481200058011.
Hartley Rogers. Theory of recursive functions and effective computability. MIT Press,
Cambridge, MA, USA, 1987. ISBN 0-262-68052-1.

229

James S. Royer.

A Connotational Theory of Program Structure,

ume 273 of Lecture Notes in Computer Science.

vol-

Springer Berlin Heidel-

berg, Berlin, Heidelberg, 1987.
ISBN 978-3-540-18253-5.
doi: 10.1007/
3-540-18253-5. URL http://link.springer.com/10.1007/3-540-18253-5www.
cis.syr.edu/$\sim$royer/archive/ctps.ps.
James S. Royer and John Case.
Subrecursive Programming Systems.
Birkhäuser Boston, Boston, MA, 1994.
ISBN 978-1-4612-6680-8.
doi:
10.1007/978-1-4612-0249-3.

URL

http://link.springer.com/10.1007/

978-1-4612-0249-3.
Dana Scott. Lambda Calculus and Recursion Theory (Preliminary Version). In Stig
Kanger, editor, Proceedings of the Third Scandinavian Logic Symposium, volume 82
of Studies in Logic and the Foundations of Mathematics, pages 154–193. NorthHolland, 1975. doi: 10.1016/S0049-237X(08)70730-4. URL http://linkinghub.
elsevier.com/retrieve/pii/S0049237X08707304.
Dana S. Scott. Data Types as Lattices. SIAM Journal on Computing, 5(3):522–587,
1976. doi: 10.1137/0205037.
Dana S. Scott. A type-theoretical alternative to ISWIM, CUCH, OWHY. Theoretical Computer Science, 121(1-2):411–440, 1993. ISSN 03043975. doi: 10.1016/
0304-3975(93)90095-B.
Alex K. Simpson and Gordon D. Plotkin. Complete axioms for categorical fixedpoint operators. In Proceedings of the 15th Annual IEEE Symposium on Logic in
Computer Science (LICS 2000), pages 30–41. IEEE Comput. Soc, 2000. ISBN
0-7695-0725-5. doi: 10.1109/LICS.2000.855753. URL http://ieeexplore.ieee.
org/document/855753/.
Brian Cantwell Smith. Procedural reflection in programming languages. PhD thesis,
Massachusetts Institute of Technology, 1982. URL http://hdl.handle.net/1721.
1/15961.
Brian Cantwell Smith. Reflection and Semantics in LISP. In Proceedings of the 11th
ACM SIGACT-SIGPLAN Symposium on Principles of Programming Languages
(POPL ’84), pages 23–35, New York, New York, USA, 1984. ACM Press. ISBN
0897911253. doi: 10.1145/800017.800513. URL https://dx.doi.org/10.1145/
800017.800513.
230

Raymond M. Smullyan. Gödel’s Incompleteness Theorems. Oxford University Press,
1992.
Sam Staton. Freyd categories are Enriched Lawvere Theories. Electronic Notes in
Theoretical Computer Science, 303:197–206, 2014. ISSN 15710661. doi: 10.1016/j.
entcs.2014.02.010. URL http://dx.doi.org/10.1016/j.entcs.2014.02.010.
Christopher Strachey. Fundamental Concepts in Programming Languages. HigherOrder and Symbolic Computation, 13:11–49, 2000. ISSN 13883690. doi: 10.1023/A:
1010000313106. URL http://dx.doi.org/10.1023/A:1010000313106.
Thomas Streicher. Domain-theoretic Foundations of Functional Programming. World
Scientific, 2006.
Thomas Streicher.

How Intensional Is Homotopy Type Theory?

In Maria

del Mar González, Paul C. Yang, Nicola Gambino, and Joachim Kock, editors,
Extended Abstracts Fall 2013: Geometrical Analysis; Type Theory, Homotopy Theory and Univalent Foundations, number September in Research Perspectives CRM
Barcelona, pages 105–110. Birkhäuser Basel, Cham, 2015. ISBN 978-3-319-212838. doi: 10.1007/978-3-319-21284-5_20. URL https://dx.doi.org/10.1007/
978-3-319-21284-5_20.
Walid Taha and Michael Florentin Nielsen. Environment classifiers. ACM SIGPLAN
Notices, 38:26–37, 2003. ISSN 03621340. doi: 10.1145/640128.604134.
Walid Taha and Tim Sheard. Multi-stage programming with explicit annotations.
In Proceedings of the 1997 ACM SIGPLAN symposium on Partial evaluation and
semantics-based program manipulation (PEPM ’97), pages 203–217, New York,
New York, USA, 1997. ACM Press. ISBN 0897919173. doi: 10.1145/258993.259019.
URL https://dx.doi.org/10.1145/258993.259019.
Walid Taha and Tim Sheard. MetaML and multi-stage programming with explicit annotations. Theoretical Computer Science, 248(1-2):211–242, 2000. ISSN
03043975. doi: 10.1016/S0304-3975(00)00053-0. URL https://dx.doi.org/10.
1016/S0304-3975(00)00053-0.
M. Takahashi. Parallel Reductions in λ-Calculus. Information and Computation,
118(1):120–127, apr 1995. ISSN 08905401. doi: 10.1006/inco.1995.1057. URL
https://dx.doi.org/10.1006/inco.1995.1057.

231

Takeshi Tsukada and Atsushi Igarashi. A logical foundation for environment classifiers. Logical Methods in Computer Science, 6(4):1–43, 2010. ISSN 18605974.
doi: 10.2168/LMCS-6(4:8)2010. URL https://dx.doi.org/10.2168/LMCS-6(4:
8)2010.
Alan M Turing. On Computable Numbers, with an Application to the Entscheidungsproblem. Proceedings of the London Mathematical Society, s2-42(1):230–
265, jan 1937. ISSN 0024-6115. doi: 10.1112/plms/s2-42.1.230. URL http:
//plms.oxfordjournals.org/cgi/doi/10.1112/plms/s2-42.1.230.
Alan M Turing. Systems of logic based on ordinals. Proceedings of the London
Mathematical Society, 2(1):161–228, 1939.
Aldo Ursini. Intuitionistic diagonalizable algebras. Algebra Universalis, 9(1):229–237,
1979a. ISSN 00025240. doi: 10.1007/BF02488034.
Aldo Ursini. A modal calculus analogous to K4W, based on intuitionistic propositional logic.

Studia Logica, 38(3):297–311, 1979b.

ISSN 0039-3215.

doi:

10.1007/BF00405387. URL https://dx.doi.org/10.1007/BF00405387.
Jaap van Oosten. Realizability: An Introduction to its Categorical Side, volume 152.
Elsevier, 2008. ISBN 978-0-444-51584-1. URL http://www.sciencedirect.com/
science/bookseries/0049237X/152.
Spyros Vassilakis. Economic Data Types. 1989.
Spyros Vassilakis.

Some economic applications of Scott domains.

Mathemati-

cal Social Sciences, 24(2-3):173–208, nov 1992. ISSN 01654896. doi: 10.1016/
0165-4896(92)90061-9. URL http://linkinghub.elsevier.com/retrieve/pii/
0165489692900619.
Kumaraswamy Velupillai. Computable economics. The Arne Ryde Memorial Lectures.
Oxford University Press, 2000. ISBN 978 1 84376 239 3.
P Wadler. A critique of Abelson and Sussman or why calculating is better than
scheming. ACM SIGPLAN Notices, 22(3):83–94, mar 1987. ISSN 03621340. doi:
10.1145/24697.24706. URL https://dx.doi.org/10.1145/24697.24706.
Mitchell Wand. The Theory of Fexprs is Trivial. LISP and Symbolic Computation,
10(3):189–199, 1998. ISSN 08924635. doi: 10.1023/A:1007720632734. URL https:
//dx.doi.org/10.1023/A:1007720632734.
232

Mitchell Wand and Daniel P. Friedman. The mystery of the tower revealed: A
nonreflective description of the reflective tower.

Lisp and Symbolic Computa-

tion, 1(1):11–38, jun 1988. ISSN 0892-4635. doi: 10.1007/BF01806174. URL
https://dx.doi.org/10.1007/BF01806174.
Steven J Winrich. Self-Reference and the Incomplete Structure of Neoclassical Economics. Journal of Economic Issues, 18(4):987–1005, 1984.

233

