Technical Report Second-order algebraic theories Ola Mahmoud Number 807

Technical Report Second-order algebraic theories Ola Mahmoud Number 807
Technical Report
UCAM-CL-TR-807
ISSN 1476-2986
Number 807
Computer Laboratory
Second-order algebraic theories
Ola Mahmoud
October 2011
15 JJ Thomson Avenue
Cambridge CB3 0FD
United Kingdom
phone +44 1223 763500
http://www.cl.cam.ac.uk/
c 2011 Ola Mahmoud
This technical report is based on a dissertation submitted
March 2011 by the author for the degree of Doctor of
Philosophy to the University of Cambridge, Clare Hall.
Technical reports published by the University of Cambridge
Computer Laboratory are freely available via the Internet:
http://www.cl.cam.ac.uk/techreports/
ISSN 1476-2986
Õæ
k QË@
é<Ë@ Õæ„.
á Ô gQË@
Z@Yë@
(AîD
Ê« é<Ë@ éÔ gP) ú
×@ úÍ@
ú
G. @ úÍ@ ð
Ê« áK Y ÊË@
. ú
GñÒ
4
Summary
Second-order universal algebra and second-order equational logic respectively provide a model theory and a formal deductive system for languages with variable binding and parameterised metavariables. This dissertation completes the algebraic foundations of second-order languages from the
viewpoint of categorical algebra.
In particular, the dissertation introduces the notion of second-order algebraic theory. A main role in
the definition is played by the second-order theory of equality M, representing the most elementary
operators and equations present in every second-order language. We show that M can be described
abstractly via the universal property of being the free cartesian category on an exponentiable object.
Thereby, in the tradition of categorical algebra, a second-order algebraic theory consists of a cartesian category M and a strict cartesian identity-on-objects functor M : M → M that preserves the
universal exponentiable object of M.
At the syntactic level, we establish the correctness of our definition by showing a categorical equivalence between second-order equational presentations and second-order algebraic theories. This
equivalence, referred to as the Second-Order Syntactic Categorical Type Theory Correspondence,
involves distilling a notion of syntactic translation between second-order equational presentations
that corresponds to the canonical notion of morphism between second-order algebraic theories. Syntactic translations provide a mathematical formalisation of notions such as encodings and transforms
for second-order languages.
On top of the aforementioned syntactic correspondence, we furthermore establish the Second-Order
Semantic Categorical Type Theory Correspondence. This involves generalising Lawvere’s notion of
functorial model of algebraic theories to the second-order setting. By this semantic correspondence,
second-order functorial semantics is shown to correspond to the model theory of second-order universal algebra.
We finally show that the core of the theory surrounding Lawvere theories generalises to the second
order as well. Instances of this development are the existence of algebraic functors and monad morphisms in the second-order universe. Moreover, we define a notion of translation homomorphism
that allows us to establish a 2-categorical type theory correspondence.
5
6
Acknowledgments
This work would not have been possible without the guidance of Marcelo Fiore, my Ph.D. supervisor. I am extremely grateful to him for his insightful discussions, for sharing his intuition, and for
his support and flexibility during my four years at Cambridge. Special thanks to Glynn Winskel and
Giuseppe Rosolini for examining this thesis and providing thoughtful comments and suggestions.
I would like to thank the Cambridge Overseas Trust for funding my Ph.D., and the Computer Laboratory for providing generous additional financial support. At the Computer Laboratory, I am grateful
to Glynn Winskel and Thomas Forster, for being involved in my work over the years; to my colleagues Sam Staton and Chung-Kil Hur, for never tiring from answering my questions; and to Aisha
Elsafty, for giving me a dose of Egyptian spirit on a daily basis. I must also express my gratitude to
my college, Clare Hall, which has been a warm and supportive second home to me.
I will always remain indebted to Michel Hebert for his inspiring and intellectually stimulating guidance during my undergraduate years in Cairo. He gave me the first introduction to number theory,
logic, and categories back when the only mathematics I knew ended with the Fundamental Theorem
of Calculus. I would like to thank him for involuntarily influencing my mathematical taste, and for
helping pave the way to Cambridge and this dissertation.
Although their direct contribution to this work may not be apparent, my appreciation goes out to
Lisa Goldberg and Michael Hayes for their kindness and support, for opening my eyes to a different,
just as exciting, mathematics, and for making my days over the past months more interesting.
Finally, I dedicate this dissertation to my family. To my husband, Mikkel − for his infinite patience
and continued love during a highly volatile period; for being my primary source of strength; and
for generally being my kinder half. To my brother, Mohamed − for being the sound of reason in my
life and my best friend ever since I can remember; and for always helping me maintain the last bit
of sanity I have left. To my father, Ibrahim, and my mother, Mona − the most wonderful people
I have met in my short life − for educating me; for teaching me integrity, modesty, and above all
humour with their example; and for their open-mindedness, encouragement, and trust in whatever
endeavours I choose.
7
8
Es nimmt der Augenblick, was Jahre geben.
- Johann Wolfgang von Goethe
10
Contents
1 INTRODUCTION
13
1.1 Background . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
15
1.2 Contributions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
19
1.3 Synopsis . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
22
2 FIRST-ORDER ALGEBRAIC THEORIES
25
2.1 First-Order Syntactic Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
25
2.2 First-Order Model Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
28
2.3 First-Order Algebraic Theories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
31
2.4 First-Order Categorical Type Theory Correspondence . . . . . . . . . . . . . . . . . . . .
34
3 FIRST-ORDER SYNTACTIC TRANSLATIONS
4
5
6
39
3.1 Syntactic Maps . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
40
3.2 Syntactic Translations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
40
3.3 The Signature/Theory Adjunction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
44
3.4 First-Order Syntactic Categorical Type Theory Correspondence . . . . . . . . . . . . . .
45
SECOND -ORDER SYNTAX
53
AND
SEMANTICS
4.1 Second-Order Syntactic Theory . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
53
4.2 Second-Order Equational Logic . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
57
4.3 Second-Order Universal Algebra . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
59
4.A Appendix to Chapter 4: Multi-Sorted Second-Order Syntax . . . . . . . . . . . . . . . .
64
4.B Appendix to Chapter 4: Proofs of Substitution and Metasubstitution Lemmas . . . . .
66
SECOND -ORDER ALGEBRAIC THEORIES
71
5.1 Exponentiable objects . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
71
5.2 The Second-Order Theory of Equality . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
72
5.3 Second-Order Algebraic Theories . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
79
5.4 Second-Order Theory/Presentation Correspondence . . . . . . . . . . . . . . . . . . . . .
80
SECOND -ORDER SYNTACTIC TRANSLATIONS
87
6.1 Second-Order Signature Translations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
87
6.2 Second-Order Equational Translations . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
89
11
7
6.3 Syntactic and Algebraic Translations . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
91
6.4 Second-Order Syntactic categorical Type Theory Correspondence . . . . . . . . . . . .
93
6.A Appendix to Chapter 6 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .
98
SECOND -ORDER FUNCTORIAL SEMANTICS
101
7.1 Clone Structures . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 102
7.2 Classifying Clones . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106
7.3 Second-Order Functorial Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108
7.4 Second-Order Semantic Categorical Type Theory Correspondence . . . . . . . . . . . . 109
7.5 Translational Semantics . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 112
8
CONCLUDING REMARKS
113
8.1 Second-Order Algebraic Functors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 114
8.2 Second-Order Monad Morphisms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 120
8.3 2-Categorical Type Theory Correspondence . . . . . . . . . . . . . . . . . . . . . . . . . . 122
8.4 Future Directions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 124
12
Chapter 1
INTRODUCTION
[...] The most effective illumination of algebraic practice by general algebra, both classical and categorical, has come from the explicit nature of the framework itself. The closure
properties of certain algebraic sub-categories, the functoriality of semantics itself, the ubiquitous existence of functors adjoint to algebraic functors, the canonical method for extracting algebraic information from non-algebraic categories, have served (together with their
many particular ramifications) as a partial guidance to mathematicians in dealing with
the inevitably algebraic content of their subjects.
William Lawvere [Adamek et al., 2009]
Algebra is the study of operations on mathematical structures, and the constructions and relationships arising from them. These structures span the most basic algebraic entities, such as arithmetic,
to the more abstract, such as groups, rings, lattices, etc. Based on these, Birkhoff [Birkhoff, 1935]
laid out the foundations of a general unifying theory, now known as universal algebra. His formalisation of the notion of algebra starts with the introduction of equational presentations. These
constitute the syntactic foundations of the subject. Algebras are then the semantics, or model theory, and play a crucial role in establishing the logical foundations. Indeed, Birkhoff introduced
equational logic as a sound and complete formal deductive system for reasoning about algebraic
structure.
The investigation of algebraic structure was further enriched by Lawvere’s fundamental work on
algebraic theories [Lawvere, 2004]. His approach gives an elegant categorical framework for providing a presentation-independent treatment of universal algebra, and it embodies the motivation
for the present work.
As per Lawvere’s own philosophy, we believe in the inevitability of algebraic content in mathematical subjects. We contend that it is only by looking at algebraic structure from all perspectives − syntactic, semantic, categorical − and the ways in which they interact, that the subject is
properly understood. In the context of computer science, for instance, consider that: (i) initialalgebra semantics provides canonical compositional interpretations [Goguen et al., 1978]; (ii) free
13
CHAPTER 1. INTRODUCTION
constructions amount to abstract syntax [McCarthy, 1963] that is amenable to proofs by structural
induction and definitions by structural recursion [Burstall, 1969]; (iii) equational presentations can
be regarded as bidirectional rewriting theories and studied from a computational point of view
[Knuth and Bendix, 1970]; (iv) algebraic theories come with an associated notion of algebraic translation [Lawvere, 2004], whose syntactic counterpart provides the right notion of syntactic translation between equational presentations [Fujiwara, 1959, Fujiwara, 1960]; (v) strong monads have
an associated metalogic from which equational logics can be synthesised [Fiore and Hur, 2008b,
Fiore and Hur, 2010].
The realm of categorical universal algebra has so far been restricted to first-order languages. This
dissertation further extends it to include languages with variable-binding, such as the λ-calculus
[Aczel, 1978] and predicate logic [Aczel, 1980]. We take the explicit nature of the framework introduced in Lawvere’s seminal thesis as heuristic guidelines for applying the categorical algebra
framework to second-order languages. In particular, emulating Lawvere’s framework will enable us
to:
- define second-order algebraic theories to be structure preserving functors from a suitable base
category, the second-order theory of equality, to a category which abstractly classifies a given
second-order presentation,
- extract syntactic information via internal languages from the categorical framework of secondorder algebraic theories,
- synthesise a notion of syntactic translation from the canonical notion of morphism of algebraic
theories, and vice versa,
- establish the functoriality of second-order semantics;
all in such a way that the expected categorical equivalences are respected. More precisely, we obtain:
1. the Second-Order Syntactic Categorical Type Theory Correspondence, by which second-order
algebraic theories and their morphisms correspond to second-order equational presentations
and syntactic translations; and
2. the Second-Order Semantic Categorical Type Theory Correspondence, by which algebras for
second-order equational presentations correspond to second-order functorial models.
14
1.1. Background
1.1 Background
We review the key developments of categorical algebra (Lawvere theories) and computer science
(languages with variable binding) that are most relevant to us. Their combination forms the basis of
this dissertation. Our approach towards syntactic notions of morphisms of equational presentations
via syntactic translations is also briefly introduced and compared to existing such notions.
1.1.1 Algebraic theories
With the advent of category theory, the development of universal algebra was further advanced by
Lawvere and his fundamental thesis on algebraic theories [Lawvere, 2004]. In it, Lawvere exhibited
a presentation-independent category-theoretic formulation of finitary first-order theories; finitary in
the sense that only operations of arity given by a finite cardinal are considered, and first-order in
that the arguments of the operations do not allow variable-binding. We proceed to review Lawvere’s
categorical approach and its syntactic counterpart given by mono-sorted equational presentations.
The basic rough idea underlying Lawvere’s abstraction is that an algebraic theory is a functor from
a base category to a small category with strict finite products, whose morphishms can be thought of
as tuples of abstract terms or derived operations. The base category intuitively represents the most
fundamental equational theory, the theory of equality. It arises from the universal property of the
categorical cartesian product.
Lawvere’s axiomatisation of what is essentially the clone of an equational theory [Cohn, 1965] is
along the following lines.
The first-order theory of equality. Let F be the category of finite cardinals and all functions between them. The objects of F are simply denoted by n ∈ N; it comes equipped with a cocartesian
structure given via cardinal sum m + n. Moreover, F can be universally characterised as the free
cocartesian category generated by the object 1. By duality, the opposite of F, which we shall denote
by L for Lawvere, is equipped with finite products. This category, together with a suitable cartesian
functor, form the main constituents of a Lawvere theory.
Definition 1.1 (Lawvere theory). A Lawvere theory consists of a small category L with strictly
associative finite products, together with a strict cartesian identity-on-objects functor L : L → L . A
morphism of Lawvere theories L : L → L and L ′ : L → L ′ is a cartesian functor F : L → L ′ which
commutes with the theory functors L and L ′ . We write LAW for the category of Lawvere theories
and their morphisms.
For a Lawvere theory L : L → L , the objects of L are then precisely those of L. For any n ∈ N,
morphisms in L (n, 1) are referred to as the operators of the theory, and those arising from L(n, 1) as
the elementary such operators. For any n, m ∈ N, morphisms in L (n, m) are m-tuples of operators,
because L (n, m) ∼
= L (n, 1)m . Intuitively, a morphism of Lawvere theories encapsulates the idea of
interpreting one theory in another.
15
CHAPTER 1. INTRODUCTION
Definition 1.2 (Functorial models of Lawvere theories). A functorial model of a given Lawvere theory
L : L → L in a cartesian category C is a cartesian functor L → C .
Remark 1.3. Our reference to algebraic theory in this dissertation is solely in the categorical-algebra,
functorial sense of Lawvere, with its syntactic counterpart given by equational presentations. Lawvere theories can be thought of as an abstract invariant notion different from the more concrete one
of equational presentations. In fact, every equational presentation determines a Lawvere theory and
every Lawvere theory is determined by an infinite class of equational presentations. As Hyland and
Power point out [Hyland and Power, 2007], choosing good presentations for algebraic theories and,
in the other direction, deriving an invariant, abstract, and universal description from a concrete
presentation are important aspects of computer science. The transformation from one to the other
is a main theme throughout this dissertation.
First-order equational presentations. An equational presentation consists of a signature defining
its operations and a set of axioms describing the equations it should obey. Formally, a mono-sorted
first-order equational presentation is specified as E = (Σ, E), where Σ = {Σn }n∈N is an indexed family
of first-order operators. For a given n ∈ N, we say that an operator ω ∈ Σn has arity n. The set of
terms TΣ (V ) on a set of variables V generated by the signature Σ is built up by the grammar
t ∈ TΣ (V ) := v
|
ω(t 1 , . . . , t k )
,
where v ∈ V , ω ∈ Σk , and for i = 1, . . . , k, t i ∈ TΣ (V ). An equation is simply given by a pair of
terms, and the set E of the equational presentation E = (Σ, E) contains equations, which we refer
to as the axioms of E .
The model-theoretic universe of first-order languages is classically taken to be the category Set. A
(set-theoretic) algebra in this universe for a first-order signature Σ is a pair (X , ¹−ºX ) consisting of
a set X and interpretation functions ¹ωºX : X |ω| → X , where |ω| denotes the arity of ω. Algebras
induce interpretations on terms (see for example [Fiore and Hur, 2008a] for details). An algebra for
an equational presentation E = (Σ, E) is an algebra for Σ which satisfies all equations in E, in the
sense that an equal pair of terms induces equal interpretation functions in Set.
We remind the reader that the passage from Lawvere theories and their functorial models to monosorted first-order equational presentations and their algebras is invertible (see Section 2.4.2 for a
multi-sorted generalisation of this invertibility). This makes Lawvere theories an abstract, presentationindependent formalisation of equational presentations.
1.1.2 Rudiments of second-order languages
Variable-binding constructs are at the core of fundamental calculi and theories in computer science
and logic [Church, 1936, Church, 1940]. Over the past two decades, many formal frameworks for
16
1.1. Background
languages
with
binding
have
been
developed,
including
higher-order
abstract
syntax [Pfenning and Elliott, 1988] and Gabbay and Pitts’ set-theoretic abstract syntax
[Gabbay and Pitts, 2001]. The second-order framework we base this dissertation on is that of Fiore
et al. [Fiore et al., 1999], as developed further by Hamana [Hamana, 2005], Fiore [Fiore, 2008],
and Fiore and Hur [Fiore and Hur, 2010]. It provides a formal account of the principles of variablebinding and substitution.
Second-order languages. The passage from first to second order involves extending the language
with both variable-binding operators and parameterised metavariables. Variable-binding operators
bind a list of variables in each of their arguments, leading to syntax up to alpha equivalence
[Aczel, 1978]. On top of variables, second-order languages come equipped with parameterised
metavariables. These are essentially second-order variables for which substitution also involves instantiation.
We briefly review the mono-sorted version of the syntactic theory of second-order languages as developed by Fiore and Hur [Fiore and Hur, 2010]. Any simply-typed language with variable-binding
fits their formalism. Examples of second-order languages spelled out in the literature include the
λ-calculus [Aczel, 1978], the fixpoint operator [Klop et al., 1993], the primitive recursion operator
[Aczel, 1978], the universal and existential quantifiers of predicate logic [Aczel, 1980], and the list
iterator [van Raamsdonk, 2003].
Second-order signatures and their term calculus.
A (mono-sorted) second-order signature
Σ = (Ω, | − |) is specified by a set of operators Ω and an arity function | − |: Ω → N∗ . An operator ω ∈ Ω of arity |ω| = (n1 , . . . , nk ) takes k arguments binding ni variables in the i th argument.
Unlike the first-order universe, where terms are built up only from variables and (first-order) operators, second-order terms have metavariables as additional building blocks. A metavariable
of meta-arity m, denoted by
M:
M
[m], is to be parameterised by m terms. Therefore, second-order
terms are considered in contexts
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n with two zones, each respec-
tively declaring metavariables and variables. Second-order terms in context Θ Â Γ ⊢ t are defined
inductively as follows.
- For x ∈ Γ,
- For (M : [m]) ∈ Θ,
- For ω: (n1 , . . . , nk ),
ΘÂΓ⊢ x
Θ Â Γ ⊢ ti
(1 ≤ i ≤ m)
Θ Â Γ ⊢ M[t 1 , . . . , t m ]
→
Θ Â Γ, −
x i ⊢ t i (1 ≤ i ≤ k)
→
→
Θ Â Γ ⊢ ω (−
x 1 )t 1 , . . . , (−
x k )t k
→
(−
x i = x 1 , . . . , x n(i)i )
(i)
The second-order nature of the syntax requires a two-level substitution calculus, as formalised in
[Aczel, 1978] and [Fiore, 2008]. Each level respectively accounts for the substitution of variables
and metavariables, with the latter operation depending on the former. See Section 4.1.3 for a de17
CHAPTER 1. INTRODUCTION
tailed account of both substitution and metasubstitution.
Second-order equational logic. A Second-order equational presentation E = (Σ, E) is obtained by
adding equations on top of the above constructions. It is specified by a second-order signature Σ
together with a set of equations E, where a second-order equation Θ Â Γ ⊢ s ≡ t is given by a pair
of second-order terms Θ Â Γ ⊢ s and Θ Â Γ ⊢ t. The rules of Second-Order Equational Logic are
given in Figure 4.1 in Section 4.2.1. They provide a sound and complete formal deductive system
for reasoning about second-order equational presentations [Fiore and Hur, 2010].
Second-order semantic universe. In the framework developed by Fiore et al. in [Fiore et al., 1999],
instead of working within the objects of the category Set, one takes the category SetF of covariant
presheaves (or variable sets). In the model theory, algebras over sets are replaced by so-called binding algebras over variable sets. Binding algebras are essentially presheaves endowed with both an
algebra structure and a compatible substitution structure. The suitability of taking SetF as the mathematical universe in which to deal with variable binding can be seen as follows. The index category
F provides a notion of cartesian context and allows for the familiar operations on contexts, such as
exchange, weakening, and contraction. The presheaf of variables V : F → Set is simply the inclusion
of F in Set, and for any n ∈ F and presheaf X : F → Set, the set X (n) can be seen as giving the
terms with at most n free variables. It is well known that the category SetF is cartesian closed. In
particular, exponentiating any X with respect to the presheaf of variables V yields an abstract view
of variable binding via the resulting exponential X V . Indeed, one has the equality X V (n) = X (n + 1)
for any n ∈ F.
1.1.3 Theories of translations
One of the principle dogmas of category theory is that for every mathematical structure, no matter
how general or specific, there exists a category whose objects have that structure and, more importantly, whose morphisms preserve it [Goguen, 1991]. The significance of the latter lies in the
categorical convention that morphisms are in fact more fundamental than objects, as they reveal
what the structure really is.
It is for this reason rather surprising that there is no generic agreed-upon syntactic notion of morphism between equational presentations. In the context of Lawvere theories, the canonical notion of
morphism is given by a cartesian functor (Definition 1.1). In the categorical algebra framework, we
expect this to be the presentation-independent formalisation of some syntactically defined notion of
morphism of equational presentations. We will show that this notion is precisely given by syntactic
translations.
Notions of mappings of signatures and presentations have been developed in the first-order setting
by Fujiwara [Fujiwara, 1959, Fujiwara, 1960], Goguen et al. [Goguen et al., 1978], and Vidal and
Tur [Vidal and Tur, 2008], all of which use the common definition that a syntactic notion of morphism maps operators to terms. We briefly review these approaches.
18
1.2. Contributions
Fujiwara mappings. A formalisation for mappings of mono-sorted first-order finite product theories was constructed by Fujiwara in [Fujiwara, 1959, Fujiwara, 1960]. His general theory of such
mappings between algebraic systems is defined via a so-called system of P-mappings. For first-order
mono-sorted signatures Σ = {(Σ)n}n∈N and Σ′ = {(Σ′ )n }n∈N , a morphism Σ → Σ′ is given by a pair
(Φ, P), where Φ is a set of mapping variables and P = {Pn }n∈N is a family of mappings, where for
n ∈ N, Pn sends a pair (ϕ, ω) ∈ Φ × Σn of a mapping variable ϕ and an operator ω of arity n to a
term t n,ω of Σ′ formed on top of the set of variables Φ × (v1 , . . . , vn ). The mapping variables here
are to be replaced by mappings from a Σ-algebra to another Σ-algebra derived from a Σ′ -algebra.
What is important here is to note that the set of variables Φ × (v1, . . . , vn ) used to form the term t n,ω
is determined by the arity of the operator ω. We will see in Chapter 3 and Chapter 6 that syntactic
translations impose a similar condition on the context of the terms which operators are mapped to.
Polyderivors. Polyderivors were introduced by Goguen et al. in [Goguen et al., 1978]. They provide a formal notion of syntactic morphism similar to that of Fujiwara, but in a multi-sorted framework. A polyderivor thereby consists of two mappings. One mapping relates the sets of sorts of the
signatures. It assigns to each sort in the first signature a derived sort in the second signature, which
is a word on the set of sorts in the second signature. The other mapping assigns to each operator
in the first signature a family of terms in the second. The context of each of these terms is again
specified by the arity of the operator being mapped.
Syntactic translations. There are three constituents defining the notion of morphism of (generic)
mono-sorted equational presentations E = (Σ, E) → E ′ = (Σ′ , E ′ ):
1. An operator ω of Σ is mapped to a term Γ ⊢ t of Σ′ , with its context Γ given by the arity of ω.
2. The above mapping induces a mapping between the terms of Σ and Σ′ in such a way that the
axioms of E are respected.
3. The generalisation to include sorts yields a mapping of sorts of Σ to tuples of sorts of Σ′ , and
operators to tuples of terms.
We will show in Section 3.2 and Section 6.2 that a syntactic morphism with these properties mirrors
the behaviour of morphisms of first- and second-order algebraic theories, respectively. Indeed, we
define syntactic translations to be exactly those maps specified by the above three components.
Both polyderivors and Fujiwara mappings satisfy the above and therefore coincide with our notion
of (first-order) syntactic translation.
1.2 Contributions
Motivated by Lawvere’s observation that algebraic structure is inevitable in mathematics, this work
illustrates the imminence of his abstract categorical treatment of syntactic equational presentations
in the setting of second-order languages. We develop the main ingredients in such a development
19
CHAPTER 1. INTRODUCTION
à-la-Lawvere, which encompasses: (i) the definition of second-order algebraic theories and their
morphisms; (ii) the formalisation of a syntactic notion of morphism of second-order presentations;
and (iii) the functorial semantics for second-order algebraic theories.
With the second-order syntactic theory reviewed in Section 1.1.2 in mind, we now give an overview
of the above three main contributions of this dissertation. A more detailed chapter-by-chapter synopsis is provided in Section 1.3.
1.2.1 Second-order algebraic theories
The second-order theory of equality. In the notion of categorical algebraic theory, the elementary
theory of equality represents the most fundamental theory and plays a pivotal role. The second-order
algebraic theory of equality M has objects given by N∗ and morphisms (m1 , . . . , mk ) → (n1 , . . . , nl )
given by tuples
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x ni ⊢ t i
1≤i≤l
of so-called elementary second-order terms. These are built from variables and metavariables only.
Just as composition in the first-order theory of equality L is given by substitution, composition in M
is defined via metasubstitution. Another similarity lies in the cartesian structure of M, which is given
by the concatenation of tuples. Its universal structure goes beyond that of the categorical product
though. In fact, every object (n) ∈ M is the exponential (0)n ⇒ (0). This exponential structure provides a universal semantic characterisation of M. Loosely speaking, M is the free cartesian category
on the exponentiable object (0).
Second-order algebraic theories. The core contribution of this dissertation is the introduction of
second-order algebraic theories and their morphisms.
A second-order algebraic theory consists of a cartesian category M and a strict cartesian
identity-on-objects functor M : M → M that preserves the exponentiable object (0). A secondorder algebraic translation between second-order algebraic theories M : M → M and M ′ : M →
M ′ is a cartesian functor F : M → M ′ satisfying M ′ ◦ F = M .
We obtain the category SOAT of second-order algebraic theories and their algebraic translations,
with the evident functorial identity and functorial composition.
Classifying algebraic theories and internal languages. Second-order equational presentations
induce second-order algebraic theories, and vice versa. For a second-order equational presentation
E = (Σ, E), one can start by constructing the classifying category M(E ), which has the same set of
objects as the elementary theory M and morphisms (m1 , . . . , mk ) → (n1 , . . . , nl ) given by tuples of
equivalence classes of terms generated from Σ under the equivalence relation identifying two terms
if and only if they are provably equal from E in Second-Order Equational Logic (Figure 4.1). This
canonical methodology for constructing classifying categories is borrowed from traditional categorical type theory. For a second-order equational presentation E , the category M(E ) together with the
20
1.2. Contributions
canonical functor ME : M → M(E ) is a second-order algebraic theory, referred to as the classifying
theory. Going in the other direction, the internal language E(M ) of a second-order algebraic theory
M : M → M has operators specified by the morphisms of M , and equations specified by the morphism equalities of M and M . Again, this mirrors the classical way of extracting syntactic theories
from categorical ones.
Second-order theory/presentation correspondence. The correctness of our definition of secondorder algebraic theory is verified by establishing its correspondence to the notion of second-order
equational presentation. Indeed, every second-order algebraic theory M : M → M is isomorphic
to the second-order algebraic theory of its associated second-order equational presentation M →
M(E(M )).
1.2.2 Second-order syntactic translations
Morphisms of second-order equational presentations. Algebraic theories come with an associated notion of algebraic translation, their morphisms. While the syntactic counterpart of these
morphisms has been developed in one form or another in the first-order setting, in the second-order
universe, a notion of syntactic morphism has yet to be formalised. Our main contribution in this regard is the generalisation of the notion of syntactic translation as introduced in Section 1.1.3 above
to second-order languages.
A second-order syntactic translation τ: Σ → Σ′ between second-order signatures is given by a
mapping from the operators of Σ to the terms of Σ′ as follows:
ω: (m1 , . . . , mk )
7→
M1 :
[m1 ], . . . , M k : [mk ] Â − ⊢ τω
We will show that a translation τ: Σ → Σ′ extends to a mapping from the terms of Σ to the
terms of Σ′ . When translating between equational presentations, we take syntactic translations E = (Σ, E) → E ′ = (Σ′ , E ′ ) to be those signature translations τ: Σ → Σ′ which preserve
the equational theory of E in the sense that axioms are mapped to theorems.
Note that this definition satisfies properties 1 and 2 in our proposed development of syntactic translations of Section 1.1.3. This shows that our framework for a general theory of morphisms between
algebraic systems is easily generalisable to second-order algebraic systems. We will also define a
canonical identity translation and translation composition, which leads us to construct the category
SOEP of second-order equational presentations and their syntactic translations.
Second-order presentation/theory correspondence. By considering syntactic translation isomorphisms, we are able to establish at the syntactic level whether two equational presentations are
essentially the same without having to revert to their categorical counterparts. This explicit machinery of syntactic comparison is used to prove that every second-order equational presentation E
is isomorphic to the second-order equational presentation E(ME ) of its associated algebraic theory
ME : M → M(E ).
21
CHAPTER 1. INTRODUCTION
Second-order syntactic categorical type theory correspondence. This correspondence constitutes
another core contribution of the dissertation, as it precisely and completely establishes the correctness of (i) the definition of second-order algebraic theories, and (ii) the definition of second-order
syntactic translations. This is done by establishing the categorical equivalence of SOAT and SOEP.
Note that not only does this categorical equivalence demonstrate the strong similarities of secondorder algebraic theories and presentations, but it makes the notion of algebraic theory even more
powerful: it creates the opportunity to translate theorems between abstract and concrete secondorder algebraic systems, knowing that the essential meaning of those theorems is preserved under
this equivalence.
1.2.3 Second-order functorial semantics
Second-order functorial models. We show that Lawvere’s functorial semantics for algebraic theories admits generalisation to the second-order universe, in which a second-order functorial model of
a second-order algebraic theory is given in terms of a suitable functor from the algebraic theory to
Set, as follows:
A second-order functorial model of a second-order algebraic theory M : M → M is given by a
cartesian functor M → C , for C a cartesian category. We obtain the category
Mod(M , C ) of
functorial models of M in C , with morphisms (necessarily monoidal) natural transformations
between them. A second-order set-theoretic functorial model of a second-order algebraic theory
M : M → M is simply a cartesian functor from M to Set. We obtain the category
Mod(M )
of set-theoretic functorial models of M in Set.
Second-order semantic categorical type theory correspondence. Second-order functorial models
are proven to correspond to second-order algebras, as developed by Fiore in [Fiore, 2008]. More
precisely, for every second-order equational presentation E , the category of E -models Mod(E ) and
the category of second-order functorial models
Mod(M ) are equivalent.
E
Second-order translational semantics. Second-order functorial semantics enables us to take a
model of an algebraic theory in any cartesian category C . Moreover, the notion of algebraic translation between second-order algebraic theories encapsulates the idea of a simple interpretation of
one theory in another. We observe that a second-order syntactic translation is the equivalent syntactic such idea. We have thus introduced a less abstract, more concrete way of giving semantics to
equational presentations. We refer to it as (second-order) Translational Semantics.
1.3 Synopsis
This dissertation begins with three chapters (Chapters 2-4) dedicated to setting the background of
first-order algebraic theories and translations, and of second-order syntax. The following three chapters (Chapters 5-7) develop the three main contributions discussed above. We conclude in Chapter
22
1.3. Synopsis
8 by showing that many of the developments surrounding Lawvere theories still hold in the secondorder universe. We also propose two concrete research directions based on the work introduced
here.
Chapter 2: First-Order Algebraic Theories. In this chapter, we review the syntactic framework
of first-order equational presentations, and the categorical counterpart given by first-order
algebraic theories. Our exposition lies in the multi-sorted universe and can be viewed as a
generalisation of Lawvere theories. We review the classical set-theoretic semantics, and the
multi-sorted version of functorial semantics. We conclude this chapter by recalling the firstorder categorical type theory correspondence - the syntactic correspondence being the equivalence of algebraic theories and equational presentations, and the semantic correspondence
being that of set-theoretic and functorial semantics.
Chapter 3: First-Order Syntactic Translations. This chapter introduces the notion of syntactic
translation in the multi-sorted first-order universe. We show that syntactic translations can be
defined as Kleisli maps. The correctness of our syntactic definition is established by proving
its correspondence to that of a canonical morphism of algebraic theories.
Chapter 4: Second-Order Syntax and Semantics. This chapter gives an introduction to the work of
Fiore and Hur [Fiore and Hur, 2010] on second-order universal algebra. It lays the syntactic
foundations of the second-order universe, whose categorical counterpart is developed in the
following chapters. Our summary recalls: (i) the notion of second-order equational presentation, that allows the specification of equational theories by means of schematic identities over
signatures of variable-binding operators; (ii) the model theory of second-order equational
presentations by means of second-order algebras; and (iii) the deductive system underlying
formal reasoning about second-order algebraic structure.
Chapter 5: Second-Order Algebraic Theories. In this chapter, we present the main contribution
of this dissertation. We define second-order algebraic theories, their algebraic translations,
and establish the correctness of our definition by showing a categorical equivalence between
second-order equational presentations and second-order algebraic theories.
Chapter 6: Second-Order Syntactic Translations. The notion of syntactic translation is generalised
to the second-order setting, and we show that it corresponds to the notion of second-order
algebraic translation. This completes the Second-Order Syntactic Categorical Type Theory Correspondence by which second-order algebraic theories and their translations are categorically
equivalent to second-order equational presentations and their syntactic translations.
Chapter 7: Second-Order Functorial Semantics. In this chapter, we show that Lawvere’s functorial
semantics for algebraic theories is generalisable to the second-order universe. Second-order
functorial models are shown to correspond to second-order algebras as defined in Chapter 4.
23
CHAPTER 1. INTRODUCTION
This completes the Second-Order Semantic Categorical Type Theory Correspondence.
Chapter 8: Concluding Remarks. We conclude the dissertation by generalising the notions of algebraic functors and monad morphisms to the second-order setting. We also define a notion of
translation homomorphism, which allows us to establish a 2-categorical equivalence between
syntactic and categorical presentations of equational theories. Finally, we propose two concrete directions for future research.
1.3.1 Published work
The work presented here is largely based on [Fiore and Mahmoud, 2010] written by the author
together with Marcelo Fiore, but has been significantly expanded in this dissertation.
24
Chapter 2
FIRST-ORDER ALGEBRAIC THEORIES
Equational presentations provide a syntactic formalisation of the notion of algebraic equational
theory by specifying a set of operations, the signature, and the laws that these operations must satisfy, the axioms. Lawvere theories abstract away from particular syntactic descriptions by giving a
syntax-independent formulation of presentations. With these fundamental counterparts in mind,
the purpose of the following two chapters is twofold. First, we recall these two approaches in the
first-order setting and prove their mutual correspondence. While this is a classic result, we nevertheless review the details to motivate our analogous development for second-order algebraic theories.
Second, recalling that a cartesian functor defines a morphism between Lawvere theories, we introduce in Chapter 3 the notion of syntactic translation between first-order equational presentations
and validate our definition by establishing its equivalence with cartesian functors.
Our exposition lies in the multi-sorted universe and is presented as follows. We start by reviewing the syntactic definition of first-order equational presentations (Section 2.1) and its set-theoretic
and categorical semantics (Section 2.2). We then move on to the categorical counterparts given
by first-order algebraic theories and functorial semantics (Section 2.3). We conclude by recalling
the categorical type theory correspondence in Section 2.4 - the syntactic correspondence being the
equivalence of algebraic theories and their corresponding equational presentations, and the semantic equivalence being that of set-theoretic and functorial models. This chapter together with the
following one serve as a motivational review and are not a prerequisite to understanding the core
contributions of this dissertation. We therefore skip or sketch proofs of classical results and refer the
reader to literature for existing proofs.
2.1 First-Order Syntactic Theory
The purely abstract approach to algebraic theories, as developed by Lawvere, is often not sufficient
for the needs of the computer scientist. We review the concrete structures of first-order multi-sorted
algebraic signatures and equational presentations and the syntactic machinery surrounding them.
25
CHAPTER 2. FIRST-ORDER ALGEBRAIC THEORIES
2.1.1 Signatures and their term calculus
A multi-sorted (first-order) algebraic signature, or just signature, Σ = (S, Ω, | − |) is given by a set
of sorts S, a set of operators Ω, and a function | − |: Ω → S ∗ × S specifying the operator arity. We
typically write ω: σ1 , . . . , σn → τ to indicate an operator ω ∈ Ω with arity |ω| = (σ1 , . . . , σn ), τ.
Note that a signature is an object of the indexed category SetS
∗
×S
.
Example 2.1. A typical example of a (mono-sorted) first-order algebraic signature is the signature
ΣG of the theory of groups specifying the algebraic structure of groups. Recalling that for mono-sorted
signatures operator arities are equivalently given by natural numbers, ΣG consists of the following three
operators:
- e: 0
(identity)
- i: 1
(inverse)
- m: 2
(multiplication)
Remark 2.2 (Notational convention). Throughout this dissertation, we will, for any n ∈ N, denote
by knk the set {1, . . . , n}.
Contexts. Given a countable set V of variables, a context is a finite sequence of variable declarations
of the form Γ = (x 1 : σ1 , . . . , x n : σn ), where σi ∈ S for all i ∈ knk, and all variables are assumed
to be distinct. Concatenation of contexts Γ = (x 1 : σ1 , . . . , x n : σn ) and Γ′ = ( y1 : τ1 , . . . , yk : τ k ) is
defined as Γ, Γ′ := (x 1 : σ1 , . . . , x n : σn , x n+1 : τ1 , . . . , x n+k : τ k ), noting that the variables, which are
merely placeholders, remain distinct.
Terms. We associate to a signature Σ its term calculus, which specifies the rules for term generation.
The set of raw terms TΣ (V ) generated by the signature Σ over the set of variables V is given by the
grammar
t ∈ TΣ (V )
:=
v
|
ω(t 1 , . . . , t k )
,
where v ∈ V , ω ∈ Ω, and t 1 , . . . , t k ∈ TΣ (V ). Terms-in-context, or simply terms, denoted by Γ ⊢ t : σ,
are described with respect to a finite set of variables receiving their type assignments in the contexts.
They are generated via the following rules.
Γ ⊢ t i : σi
Γ, x : σ ⊢ x : σ
(1 ≤ i ≤ k)
Γ ⊢ ω(t 1 , . . . , t k ): σ
(ω: σ1 , . . . , σk → σ)
The terms of every first-order signature come equipped with structural rules, which are often not
listed explicitly, as they are derivable. They respectively allow adding an extra variable declaration
in the context, replacing two variables of the same sort by a single variable, and permuting contexts.
26
2.1. First-Order Syntactic Theory
Substitution. The operation of simultaneous substitution maps terms Γ, x 1 : σ1 , . . . , x n : σn ⊢ t : σ
and Γ ⊢ si : σi , for i ∈ knk, to the term
Γ ⊢ t{x i := si }i∈knk : σ
,
which is defined by induction on the structure of t as follows:
- x j {x i := si }i∈knk = s j
- ω(t 1 , . . . , t k ){x i := si }i∈knk = ω t 1 {x i := si }i∈knk , . . . , t 1 {x i := si }i∈knk
It is easy to verify that the operation of substitution is well-defined and well-typed (see e.g. [Jacobs, 1999])
and moreover associative, as expressed formally by the following fundamental lemma.
Lemma 2.3 (First-Order Substitution Lemma). Given terms
Γ, x 1 : σ1 , x n : σn , y1 : τ1 , . . . , yk : τ k ⊢ t : σ
Γ ⊢ si : σ i
(1 ≤ i ≤ n)
Γ ⊢ rj : τj
and
,
(1 ≤ j ≤ k)
,
we have the following syntactic equality:
Γ ⊢ t{x i := si }i∈knk { y j := r j } j∈kkk = t x i := si { y j := r j } j∈kkk i∈knk
.
The definition of substitution together with the First-Order Substitution Lemma play a principal role
in the categorical formulation of first-order signatures and presentations, as composition in their
classifying categories is defined via term substitution (see Section 2.4).
2.1.2 Equational presentations
Adding equations to signatures yields equational presentations. An equation-in-context, or simply
equation, written Γ ⊢ t 1 ≡ t 2 : σ, is given by a pair of terms Γ ⊢ t 1 : σ and Γ ⊢ t 2 : σ. A (multi-sorted
first-order) equational presentation E = (Σ, E) is specified by a first-order algebraic signature Σ and
a set of equations E. Elements of E are the axioms of the equational presentation E and are denoted
Γ ⊢ E t 1 ≡ t 2 : σ.
Example 2.4. The equational presentation EG = (ΣG , EG ) associated to the theory of groups has a set
of equations EG expressing the usual group axioms:
- (Associativity)
- (Identity)
- (Inverse)
Γ, x, y, z ⊢ m m(x, y), z ≡ x, m(y, z)
Γ, x ⊢ m x, e() ≡ x
and
Γ, x ⊢ m i(x), x ≡ e()
Γ, x ⊢ m e(), x ≡ x
and
Γ, x ⊢ m x, i(x) ≡ e()
27
CHAPTER 2. FIRST-ORDER ALGEBRAIC THEORIES
2.1.3 First-order equational logic
First-order equational presentations E have the following derivability rules:
Axioms
(AX)
Γ ⊢E t1 ≡ t2 : σ
Γ ⊢E t 1 ≡ t 2 : σ
Equality rules
(REFL)
Γ ⊢ t: σ
(SYM)
Γ ⊢E t ≡ t : σ
Γ ⊢E t 1 ≡ t 2 : σ
Γ ⊢E t 2 ≡ t 1 : σ
(TRANS)
Γ ⊢E t 1 ≡ t 2 : σ
Γ ⊢E t 2 ≡ t 3 : σ
Γ ⊢E t 1 ≡ t 3 : σ
Substitution
(SUB)
Γ ⊢E t 1 ≡ t 2 : σ
Γ, x : σ ⊢E s : τ
Γ ⊢E s{x := t 1 } ≡ s{x := t 2 }: τ
An equation Γ ⊢E t 1 ≡ t 2 : σ derivable from first-order equational logic is called a theorem of the
equational presentation E .
It is well-known that First-Order Equational Logic is sound and complete for first-order equational
presentations (Birkhoff 1935, Goguen and Mesenguer 1985), in the sense that an equation is derivable if and only if it is satisfied by all algebras for the presentation (see Section 2.2).
2.2 First-Order Model Theory
We recall the fundamental development of set-theoretic and categorical semantics for multi-sorted
first-order languages.
2.2.1 Categorical semantics
The power of the categorical language as an organisational tool allows us to consider interpretations of syntactically defined theories in the abstract setting of a category. Intuitively, terms are
morphisms, term substitution is interpreted by composition of morphisms, and model soundness is
established by looking at morphism equality. To illustrate this approach, we recall the notion of
algebra for a first-order signature and equational presentation in a cartesian category. As a special
case, we obtain the traditional set-theoretic model theory, which we generalise to include multiple
sorts.
Definition 2.5. An algebra (X S , ¹−ºX S ) for the signature Σ = (S, Ω, | − |) in a cartesian category C
is given by an S-indexed collection X S = {X σ }σ∈S of objects of C together with, for every operator
ω: σ1 , . . . , σn → σ, a morphism ¹ωºX S : X σ1 × . . . X σn → X σ of C . A homomorphism of Σ-algebras
28
2.2. First-Order Model Theory
(X S , ¹−ºX S ) → (YS , ¹−ºYS ) is specified by giving a collection of morphisms f : X σ → Yσ of C for
each sort σ ∈ S such that for every operator ω: σ1 , . . . , σn → σ, we have
¹ωºYS ◦ ( fσ1 × · · · × fσn ) = fσ ◦ ¹ωºX S
.
Σ-algebras in C and their homomorphisms form the category Σ-Alg(C ).
Such an algebra (X S , ¹−ºX S ) induces the interpretation
¹tºX S : X σ1 × · · · × X σn → X σ
for a term x 1 : σ1 , . . . , x n : σn ⊢ t : σ as follows:
• ¹x i ºX S := πi , where πi : X σ1 × · · · × X σn → X σi is the i-th projection in C .
• ¹ω(t 1 , . . . , t k )ºX S := ¹ωºX S ◦ 〈¹t 1 ºX S , . . . , ¹t k ºX S 〉.
A Σ-algebra (X S , ¹−ºX S ) in a cartesian category C is said to satisfy an equation Γ ⊢ t 1 ≡ t 2 : σ if
¹t 1 ºX S and ¹t 2 ºX S are equal morphisms in C .
Satisfiability of the axioms of equational presentations determines their algebras, which we define
as follows.
Definition 2.6. An algebra for an equational presentation E = (Σ, E) in a cartesian category C is
a Σ-algebra in C that satisfies all equations in E. E -algebra homomorphisms are simply Σ-algebra
homomorphisms. We write E -Alg(C ) for the category of E -algebras and their homomorphisms.
Theorem 2.7 (Soundness). An algebra for an equational presentation E = (Σ, E) in a cartesian
category C satisfies all theorems derivable from E.
2.2.2 Set-theoretic semantics
We review folklore results from first-order set-theoretic model theory. To generalise the universe
of discourse to include sorts, one takes a sort-indexed collection of sets as the base category rather
than just Set. Thus, for a set of sorts S, we consider the category SetS whose objects are S-indexed
sets X S := {X σ }σ∈S and whose morphisms fS : X S → X S′ are S-indexed functions { fσ }σ∈S . More
precisely, SetS is a fibre within the category MSSet of multi-sorted sets and functions, whose objects
are sets indexed over arbitrary sets of sorts. Furthermore, SetS is bicomplete; we refer the reader to
[Tarlecki et al., 1991] for a straightforward proof involving machinery from indexed category theory.
First-order signature algebras. An algebra (X S , ¹−ºX S ) for a multi-sorted first-order signature
Σ = (S, Ω, | − |) in Set is given by an object X S ∈ SetS together with interpretation functions
¹ωºX S : X σ1 × · · · × X σn → X σ
29
CHAPTER 2. FIRST-ORDER ALGEBRAIC THEORIES
for every operator ω: σ1 , . . . , σn → σ in Ω. We write Σ-Alg for the category of set-theoretic Σalgebras and their homomorphisms, with the evident composition and identity.
Note that by simply referring to Σ-algebras without specifying the cartesian category they are considered in, we mean by default Σ-algebras in SetS and use the widely used notation Σ-Alg rather
than the more precise Σ-Alg(SetS ).
It is generally known that a signature induces an algebra-preserving endofunctor on its modeltheoretic base category. The signature endofunctor Σ: SetS → SetS corresponding to the signature
Σ is defined by
{X σ }σ∈S 7→
n
a
Ω(σ1 ,...,σn ),τ ×
(σ1 ,...,σn )∈S ∗
Y
1≤i≤n
X σi
o
τ∈S
.
A Σ-algebra is then an algebra for the endofunctor Σ.
Definition 2.8. Given the endofunctor F : C → C , an F-algebra (X , ϕ) is given by a carrier object
X and a structure map ϕ : F C → C. A homomorphism of F-algebras (X , ϕ) → (Y, ψ) is a morphism
f : X → Y in C such that f ◦ ϕ = ψ ◦ F f . F-algebras and their homomorphisms form the category
F-Alg.
Algebras for signature endofunctors are an abstract formulation of signature models. Indeed, there is
an isomorphism between the category Σ-Alg and Σ-Alg. We also obtain the well-known left adjoint
to the canonical forgetful functor U : Σ-Alg → SetS , which maps X S to the free Σ-algebra generated
by X S . The underlying endofunctor TΣ : SetS → SetS of this adjunction maps an S-indexed set X S
to the initial (X S + Σ)-algebra. Moreover, this adjunction is monadic, making the categories TΣ -Alg
and Σ-Alg equivalent.
First-order presentation algebras. An algebra for an equational presentation E = (Σ, E) is simply
a Σ-algebra satisfying the equations of E in Set. We again simplify notation and write E -Alg for the
category of E -algebras and their homomorphisms, noting that it is a full subcategory of Σ-Alg.
The existence of free algebras for an equational presentation E = (Σ, E) is one of the most fundamental developments in universal algebra. Define the equivalence relation ∼ E on the set of
terms TΣ (X S ) generated over the S-indexed set X S by identifying two terms if and only if they
are derivably equal using equations of E and first-order equational logic. Then the free E -algebra
generated by X S is given by (TΣ (X S )/ ∼ E , ¹−º TΣ (X S )/∼E ), where TΣ (X S )/ ∼ E is the set of equiva-
lence classes [−]E of terms of TΣ (X S ) under ∼ E , and the interpretation function is given by defining
¹ωº TΣ (X S )/∼E ([t 1 ]E , . . . , [t n ]E ) for each operator ω as [ω(t 1 , . . . , t n )]E . This development yields the
monadic
forgetful
functor
S
E -Alg → Set , hence the category of E -algebras is isomorphic to the category of Eilenberg-Moore
algebras for the monad induced by the free E -algebras. Finally, as another well-known property we
have that the category E -Alg is complete and cocomplete.
30
2.3. First-Order Algebraic Theories
2.3 First-Order Algebraic Theories
First-order equational presentations are abstractly formalised as algebraic theories. The details surrounding the strong connection to finitary monads, that is monads preserving filtered colimits, will
be omitted here.
2.3.1 Algebraic theories and their translations
We generalise first-order algebraic theories of Lawvere (Definition 1.1) to the multi-sorted universe.
This involves a generalisation of the first-order theory of equality to include sorts.
The multi-sorted first-order theory of equality. For S a set of sorts, let LS be the opposite of the
category whose objects are pairs (n, σ(−) ), with σ(−) : knk → S a function mapping i ∈ knk to σi , and
′
with morphisms f : (n, σ(−) ) → (n′ , σ(−)
) given by functions f : knk → kn′ k such that σ(−) = σ′f (−) .
Composition is simply function composition, and the identity on (n, σ(−) ) is just the identity on knk.
Informally, we think of objects of LS as given by tuples (σ1 , . . . , σn ) of (S ′ )∗ .
The opposite of LS comes equipped with a cocartesian structure given by the concatenation
σ1 , . . . , σn , σ′n+1 , . . . , σ′n+k
(i)
′
of tuples (n, σ(−) ) and (k, σ(−)
), with injections (n(i) , σ(−) ) →
(i)
kn k → k
X
j
( j)
n k,
k 7→ k +
` i−1
X
j
( j)
n( j) , σ(−)
n( j)
given by
.
j=1
The initial object is the empty tuple (), equivalently represented as φ → S. This of course means
that LS is cartesian.
We refer to LS as the multi-sorted first-order theory of equality. Like its mono-sorted version, L, we
can characterise LS abstractly via its universal cartesian structure.
Lemma 2.9 (Universal property). For a set of sorts S, the first-order theory of equality LS is the free
cartesian category generated by S.
Definition 2.10 (Multi-sorted first-order algebraic theories). A multi-sorted first-order algebraic theory consists of a set of sorts S, a small cartesian category L , and a strict identity-on-objects cartesian
functor L : LS → L .
Remark 2.11. Although, strictly, the combination of a strict cartesian functor L and a cartesian
category L defines an algebraic theory, we informally refer to both L and L separately as algebraic
theories.
Since for the one-element set {∗} we evidently have L = L{∗} , our first example of an algebraic
theory is a Lawvere theory, that is a mono-sorted first-order algebraic theory L : L{∗} → L .
31
CHAPTER 2. FIRST-ORDER ALGEBRAIC THEORIES
First-order algebraic translations. For multi-sorted first-order algebraic theories L : LS → L
and L ′ : LS ′ → L ′ , a (multi-sorted) first-order algebraic translation is given by a cartesian functor
F : L → L ′ , together with a function ϕ : S → (S ′ )∗ , making the following commute
LS
Lϕ
- L ′
S
L′
L
?
L
F
?
- L′
noting that Lϕ : LS → LS ′ is the functor induced by ϕ mapping the tuple (σ1 , . . . , σn ) to the concatenation of the tuples ϕ(σi ), for 1 ≤ i ≤ n.
The category of first-order algebraic theories. We denote by FOAT the category of multi-sorted
first-order algebraic theories and algebraic translations, with the evident identity and composition.
We furthermore obtain, for a fixed set of sorts S, the category FOATS of S-sorted first-order theories, whose algebraic translations all have component maps ϕ : S → S ∗ ; σ 7→ (σ), together
with the resulting identity functor LS → LS . Note that this results in the categorical equivalence
FOAT ∼
= LAW.
{∗}
The category LAW of Lawvere theories is known to be bicomplete [Lawvere, 2004], and this result
has been extended to include many-sorted algebraic theories, see for example [Goguen and Burstall, 1984a,
Goguen and Burstall, 1984b].
Theorem 2.12. The category FOAT of multi-sorted first-order algebraic theories and algebraic translations is bicomplete.
We use completeness and cocompleteness to provide examples of some basic algebraic theories via
universal properties arising from (co)limiting constructions.
- The most elementary algebraic theory is the identity L → L, which is initial in FOAT. It is
mono-sorted and has no operators or axioms. A model of it is just a set, and it is therefore
often referred to as ‘the theory of sets’.
- The most elementary S-sorted algebraic theory is given by the identity functor LS → LS . It is
again free of operators and axioms, and is the initial object in the category FOATS of S-sorted
algebraic theories.
- The terminal object of FOAT is a mono-sorted so-called trivial algebraic theory and defined as
follows. Let L T be the category with objects those of L and exactly one morphism from any
object to another, making it equivalent to the unit category 1. The trivial theory L T : L → L T
is the identity on objects but trivial on morphisms, and in that sense it identifies all morphisms
in a given hom-set L(m, n).
- One of the most interesting constructions in universal algebra is the tensor product of algebraic
theories, which we illustrate here in the mono-sorted setting for simplicity. Given Lawvere
32
2.3. First-Order Algebraic Theories
theories L : L → L and L ′ : L → L ′ , the tensor product theory (L ⊗ L ′ ): L → (L ⊗ L ′ ) is
constructed by taking the coproduct of L and L ′ and imposing the following equality in the
category L ⊗ L ′ : for every morphism f : m → 1 in L and g : n → 1 in L ′ , f ◦ g m = g ◦ f n .
Intuitively, this requirement enforces the operators of both Lawvere theories to commute in
their tensor product theory. The tensor product operation is associative, commutative, and
admits the ‘theory of sets’ as a unit. Moreover, it can be combined with a coequaliser to
construct the tensor product of two algebraic theories over a third one. The importance of this
universal construction lies in the fact that the following categories of mono-sorted functorial
models (Definition 1.2) are equivalent:
FMod(L, L ′ ) ∼
= FMod(L ′ , L ) ∼
= FMod(L ⊗ L ′ , Set)
2.3.2 Functorial Semantics
The mono-sorted functorial model theory of Lawvere presented in Section 1.1.1 generalises easily
to the multi-sorted universe. Functorial models are again defined to be cartesian functors.
Definition 2.13. A functorial model of an algebraic theory L : LS → L in a cartesian category C
is given by a cartesian functor F : L → C . For any cartesian category C , FMod(L, C ) denotes the
category of functorial models of L : LS → L in C and natural transformations between them. We
denote by FMod(L) the category of set-theoretic functorial models L → SetS of the theory L : LS →
L in the category SetS .
Note that functorial models are defined to be cartesian rather than strict cartesian, which is a fundamental difference pointed out by Lawvere in [Lawvere, 2004]. With Set and SetS being the primary
semantic universes of interest, note that their finite products are not strictly associative, whereas
they are associative in any algebraic theory. The importance of this can be seen in Lawvere’s example of the category of functorial models of the algebraic theory of monoids, which would be empty
under strict cartesian models rather than the category of monoids as one would expect.
Remark 2.14. In defining the category of functorial models, the correctness of taking all natural
transformations as morphisms rather than monoidal ones can be easily verified. A natural transformation α: F → G between cartesian functors F, G : LS ⇉ C is monoidal if it respects the cartesian
structure, in the sense that
F(σ1 , . . . , σn )
α(σ1 ,...,σn )
- G(σ , . . . , σ )
1
n
∼
=
∼
=
?
F(σ1 ) × · · · × F(σn )
〈ασ1 ,...,ασn 〉
?
- G(σ ) × · · · × G(σ )
1
n
commutes for all (σ1 , . . . , σn ) of LS . The subtlety here is in that natural transformations between
cartesian functors are necessarily monoidal, as for (σ1 , . . . , σn ) ∈ LS , the morphism
α(σ1 ,...,σn ) : F(σ1 , . . . , σn ) → G(σ1 , . . . , σn )
33
CHAPTER 2. FIRST-ORDER ALGEBRAIC THEORIES
is simply the n-ary product of ασi , for i ∈ knk.
2.4 First-Order Categorical Type Theory Correspondence
A main theme throughout this dissertation is the formulation of an abstract view of syntactic universal algebra, and, vice versa, the extraction of syntactic presentations, their morphisms and models
from categorical constructions inspired by Lawvere. Having presented the two developments in the
multi-sorted first-order setting independently, we now proceed to review what we refer to as the
syntactic and semantic categorical type theory correspondences, which respectively establish
- the equivalence between first-order algebraic theories and first-order equational presentations,
making algebraic theories a syntax-independent presentation of equational theories; and
- the equivalence between the corresponding first-order algebras and functorial models.
2.4.1 Classifying algebraic theories and internal languages
We start by illustrating that a first-order equational presentation induces an algebraic theory, and,
vice versa, that any algebraic theory has an underlying equational presentation.
Classifying categories. A classifying category for a syntactic specification is the ‘smallest’, up-toequivalence unique category in which it can be soundly modelled. Given an S-sorted equational
presentation E = (Σ, E), its classifying category is a cartesian category L(E ) equipped with a
generic E -algebra (GS , ¹−ºGS ), which is generic in the sense that for any E -algebra (DS , ¹−º DS )
in a cartesian category D, there is a unique functor F : L(E ) → D such that for all operators ω of E ,
F(¹ωºGS ) = ¹ωº DS .
The universal category L(E ) arises through a formal construction from the syntactic definition of
E as follows. Objects are tuples of sorts, and morphisms (σ1 , . . . , σk ) → (σ1′ , . . . , σ′n ) are tuples
〈[t 1 ]E , . . . , [t n ]E 〉 of equivalence classes of terms x 1 : σ1 , . . . , x k : σk ⊢ t i : σ′i under the equivalence
∼E identifying two terms if and only if their equational congruence ≡ is derivable from E.
This construction does indeed yield a category. The identity on the tuple (σ1 , . . . , σk ) is the tuple
〈[x 1 : σ1 , . . . , x k : σk ⊢ x i : σi ]E 〉i∈knk , and the composition of 〈[Γ ⊢ t i : σ′i ]E 〉i∈knk with
〈[Γ′ ⊢ s j : σ′′j ]E 〉 j∈kkk is given via substitution by 〈[s j {x i := t i }i∈knk ]E 〉 j∈kkk , where x i are the variables appearing in Γ′ . Associativity of composition is a consequence of the First-Order Substitution
Lemma (Lemma 2.3), and its well-definedness is an immediate consequence of the (Substitution)
derivability rule of First-Order Equational Logic (Section 2.1.3). Finally, we note that the classifying
category L(E ) is cartesian, with products given by tuple concatenation, the terminal object being
the empty tuple and the terminal map the empty tuple. The projection πi : σ1 × · · · × σn → σi is
given by 〈[x 1 : σ1 , . . . , x n : σn ⊢ x i : σi ]E 〉.
34
2.4. First-Order Categorical Type Theory Correspondence
Note that we can construct the classifying category L(Σ) of a signature by taking the set of axioms
to be empty. Morphisms are then simply tuples of equivalence classes of terms under the empty set,
or equivalently, tuples of terms rather than equivalence classes of terms.
Lemma 2.15. Let E0 = (Σ0 , {}) be the ’elementary’ S-sorted equational presentation with underlying
empty signature Σ0 = (S, {}) and no axioms. Its classifying category L(E0 ) is (isomorphic to) the
first-order theory of equality LS .
Classifying algebraic theories. An S-sorted equational presentation E = (Σ, E) induces the algebraic theory LE : LS → L(E ), where LE is the canonical cartesian functor mapping 〈t〉 to 〈[t]E 〉. In
consistency with the terminology above, we refer to LE as the classifying algebraic theory of E .
Remark 2.16. Generally, the notion of classifying algebraic theory for an equational presentation E
is formalised as the theory L ∗ : L → L∗ resulting in the categorical equivalence
E -Alg(C ) ∼
= FMod(L ∗ , C )
for any cartesian category C . We show in Section 2.4.3 that our reference to the algebraic theory
LE : LS → L(E ) as being classifying is justified, as we do indeed obtain the equivalence
E -Alg(C ) ∼
= FMod(LE , C ).
Internal languages. In the other direction, the internal language E(L) = (Σ(L), E(L)) of an algebraic theory L : LS → L is the equational presentation defined by taking the objects of L , or
equivalently of LS , as its set of sorts and a morphism f : σ1 × · · · × σn → σ of L to be an operator
ω f : σ1 , . . . , σn → σ. One canonically obtains the algebra (ob(L ), ¹−º∗ ) of Σ L in L by defining
¹ω f º∗ := f . The equations E(L) of E(L) are obtained by setting Γ ⊢ E(L) t 1 ≡ t 2 : σ if and only if
¹t 1 º∗ and ¹t 2 º∗ are equal morphisms in L . The algebra ¹−º∗ is referred to as the generic algebra
of L induced by its own internal language.
The semantic definition of the equations E(L) associated with an internal language can be given
more explicitly, but equivalently, by the following axioms:
(E 1) For any projection πi : σ1 × · · · × σn → σi in L , we set
x 1 : σ1 . . . , x n : σn ⊢ E(L) x i ≡ ωπi (x 1 , . . . , x n ): σi
.
(E 2) For morphisms h: σ1 ×· · ·×σn → σ, g : τ1 ×· · ·×τ l → σ, and f i : σ1 ×· · ·×σn → τ i (1 ≤ i ≤ l)
of L with h = g ◦ 〈 f1 , . . . , f l 〉, we set
x 1 : σ1 , . . . , x n : σn ⊢ E(L) ωh (x 1 , . . . , x n ) ≡ ω g ( y1 , . . . , yl ){ yi := ω f i (x 1 , . . . , x n )}i∈klk : σ
.
35
CHAPTER 2. FIRST-ORDER ALGEBRAIC THEORIES
2.4.2 Towards first-order syntactic categorical type theory correspondence
We prove the first part of the syntactic categorical type theory correspondence, namely that an
algebraic theory is essentially the same as the classifying theory of its internal language.
Theorem 2.17 (First-order theory/presentation correspondence). A multi-sorted first-order algebraic
theory L : LS → L is isomorphic to the classifying algebraic theory LE(L) : LS → L(E(L)) of its own
internal language E(L).
Proof sketch. The isomorphism is trivial on objects, as a tuple (σ1 , . . . , σn ) of L(E(L)) is just the
cartesian product σ1 × · · · × σn as in L . A morphism f : σ1 × · · · × σn → σ of L is mapped under
the isomorphism to 〈[ω f (x 1 , . . . , x n )]E(L) 〉: (σ1 , . . . , σn ) → σ of L(E(L)). In the other direction,
a morphism 〈[t]E(L) 〉: (σ1 , . . . , σn ) → σ of L(E(L)) is mapped to the term interpretation ¹tº∗
induced by the generic algebra of E(L) in L . Note that this mapping respects the equivalence
relation ∼E(L) as by definition the generic algebra satisfies all equations of E(L). These mappings
are indeed mutual inverses: a morphism f : σ1 ×· · ·×σn → σ of L is trivially equal to the composite
f ◦ 〈π1 , . . . , πn 〉. The other direction is given by the equational theory of E(L) and established by
induction on term structure:
- 〈[x 1 : σ1 , . . . , x n : σn ⊢ x i : σi ]E(L) 〉 corresponds to the morphism 〈[ωπi (x 1 , . . . , x n )]E(L) 〉,
which are indeed equal by (E 1).
- For f : τ1 × · · · × τ k → σ, the morphism 〈[ω f (t 1 , . . . , t k )]E(L) 〉 corresponds to the
→
ω f ( y1 , . . . , yk ){ yi := ω¹t i º∗ (−
zi )}i∈kkk E(L)
,
which are similarly equal by (E 2).
2.4.3 Semantic categorical type theory correspondence
We conclude by recalling the semantic component of the Categorical Type Theory Correspondence
given by the correspondence between functorial models for first-order algebraic theories, algebras
for first-order equational presentations, and Eilenberg-Moore algebras for finitary monads. We refer
the reader to [Borceux, 1994] for detailed proofs.
Theorem 2.18 (First-Order Semantic Categorical Type Theory Correspondence). For every S-sorted
first-order equational presentation E with classifying algebraic theory LE : LS → L(E ), the category
E -Alg of E -algebras and the category of functorial models FMod(LE , SetS ) are equivalent. Similarly,
for every first-order algebraic theory L : LS → L , the category of functorial models FMod(L, Setob(L ) )
is equivalent to the category E(L)-Alg of algebras for the internal language E(L).
Proposition 2.19. For every S-sorted first-order equational presentation E , there exists a finitary
monad T on SetS such that the category of E -algebras is isomorphic to that of Eilenberg-Moore algebras
for T. Also, for a set S and every finitary monad T on SetS , there exists a first-order algebraic theory
36
2.4. First-Order Categorical Type Theory Correspondence
L : LS → L such that the category of Eilenberg-Moore algebras for T is isomorphic to the category of
functorial models FMod(L, SetS ).
37
CHAPTER 2. FIRST-ORDER ALGEBRAIC THEORIES
38
Chapter 3
FIRST-ORDER SYNTACTIC TRANSLATIONS
Formal comparison of equational presentations is traditionally obtained by comparing their categories of models. If those are categorically equivalent, we say that the presentations are Morita
equivalent. Alternatively, if known, one may look at the respective classifying categories, in which
case an equivalence of presentations would be established if the classifying categories are isomorphic. We seek to develop a syntactic mathematical formalism for notions such as equivalence and
conservative extension, amongst others, enabling us to compare equational presentations at the
syntactic level. To this end, we introduce our notion of (first-order) syntactic translation between
equational presentations. We justify the correctness of our definition by establishing its correspondence with that of algebraic translations, the canonical notion of morphism between first-order
algebraic theories.
Despite that our definition coincides in principle with that of Fujiwara [Fujiwara, 1959, Fujiwara, 1960]
and with the concept of polyderivor [Vidal and Tur, 2008], the notion of syntactic translation carries
its advantages. Its syntactic formulation enables an explicit description of the mapping of the components (sorts, operators, equations) defining equational presentations, and is, as a result, easily
generalisable to the second-order setting. Moreover, as it is the syntactic counterpart of algebraic
translation, it encapsulates the idea of a syntactic interpretation of one presentation in another.
Our development begins with the notion of a syntactic map of equational presentations (Section
3.1), which are simply functions between the corresponding sets of sorts and operators. Maps are
what one may initially believe to be the correct definition of morphism of equational presentations;
however, we show that syntactic translations, defined in Section 3.2, arise as Kleisli syntactic maps
(Section 3.3). We establish the correctness of our definition of syntactic translations in Section 3.4
by proving that they correspond to algebraic translations. Syntactic translations moreover enable an
explicit description of the notion of isomorphism of equational presentation. We use this to establish
the syntactic counterpart of the Theory/Presentation Correspondence, by syntactically verifying that
an equational presentation is isomorphic to the internal language of its classifying algebraic theory
(Theorem 3.8).
39
CHAPTER 3. FIRST-ORDER SYNTACTIC TRANSLATIONS
3.1 Syntactic Maps
Signature maps. A (first-order) syntactic map µ: Σ → Σ′ between multi-sorted first-order signatures
Σ = (S, Ω, | − |) and Σ′ = (S ′ , Ω, | − |) is given by functions between the corresponding sets of sorts
and operators as follows:
S
→ S′
σ 7→ µ(σ)
Ω → Ω′
ω: σ1 , . . . , σk → σ 7→ µ(ω): µ(σ1 ), . . . , µ(σk ) → µ(σ)
A signature map µ: Σ → Σ′ induces an evident mapping on contexts and terms, by mapping a
context Γ = (x 1 : σ1 , . . . , x n : σn ) of Σ to µ(Γ) = (x 1 : µ(σ1 ), . . . , x n : µ(σn )) of Σ′ , and a term
Γ ⊢ t : σ to µ(Γ) ⊢ µ(t): µ(σ), which is defined by induction on term structure as follows:
- x 1 : σ1 , . . . , x n : σn ⊢ x i : σi is mapped to x 1 : µ(σ1 ), . . . , x n : µ(σn ) ⊢ x i : µ(σi ).
- Γ ⊢ ω(t 1 , . . . , t k ): σ is mapped to µ(Γ) ⊢ µ(ω) µ(t 1 ), . . . , µ(t k ) : µ(σ).
Syntactic maps. A first-order syntactic map µ: E → E ′ between equational presentations E = (Σ, E)
and E ′ = (Σ′ , E ′ ) is a signature map µ: Σ → Σ′ such that for every axiom Γ ⊢ E t ≡ t ′ : σ of E , the
judgement µ(Γ) ⊢E ′ µ(t) ≡ µ(t ′ ): µ(σ) is a theorem of E ′ .
The identity syntactic map µE : E → E is simply the identity function on the sets of sorts, operators
and equations, and composition of syntactic maps is given by composition of the underlying functions. We write Sigµ for the category of multi-sorted first-order signatures and syntactic maps, and
FOEPµ for the category of first-order equational presentations and syntactic maps.
3.2 Syntactic Translations
A syntactic map is not the appropriate notion of a morphism for equational presentations. However,
it plays a subtle role in the definition of syntactic translation, which we explicitly define next.
Signature translations. A first-order syntactic translation τ: Σ → Σ′ between multi-sorted signatures Σ = (S, Ω, | − |) and Σ′ = (S ′ , Ω′ , | − |) maps sorts to tuples of sorts and operators to tuples of
40
3.2. Syntactic Translations
terms in a context determined by the operator arity. Formally, τ is given by mappings
τ: S → (S ′ )∗
σ 7→
τ(σ)1 , . . . , τ(σ)|τ(σ)|
τ: Ω → TΣ′
D
E
ω: σ1 , . . . , σk → σ 7→
Γ′τ(σ ) , . . . , Γ′τ(σ ) ⊢ τ(ω)i : τ(σ)i
1
n
1≤i≤|τ(σ)|
,
where Γ′τ(σ ) denotes the context declaring the sorts τ(σ j )i for 1 ≤ i ≤ |τ(σ j )|.
j
Remark 3.1 (Notational Convention). In the above definition, we write | − | for the length of any
tuple, and we moreover denote the i-th element of a tuple (−) by (−)i .
Translation of contexts. A signature translation τ: Σ → Σ′ induces an evident mapping from
the contexts of Σ to the contexts of Σ′ , defined for a context Γ = (x 1 : σ1 , . . . , x n : σn ) of Σ by
τ(Γ) := Γ′τ(σ ) , . . . , Γ′τ(σ ) .
1
n
Translation of terms. A signature translation τ: Σ → Σ′ further extends to a mapping τ: TΣ →
(TΣ′ )∗ from the terms of Σ to tuples of terms of Σ′ according to the following definition by structural
induction.
• The variable term x 1 : σ1 , . . . , x n : σn ⊢ x i : σi is mapped to the tuple
D
Γ′τ(σ ) , . . . , Γ′τ(σ ) ⊢ x i, j : τ(σi ) j
1
n
E
1≤ j≤|τ(σi )|
.
• For an operator ω: σ1 , . . . , σk → σ of Σ with image under τ given by
D
E
Γ′τ(σ ) , . . . , Γ′τ(σ ) ⊢ τ(ω)i : τ(σ)i
1
k
1≤i≤|τ(σ)|
and for terms Γ ⊢ t i : σi (1 ≤ i ≤ k) with images under τ given by
¬
τ(Γ) ⊢ τ(t i ) j : τ(σi ) j
¶
1≤ j≤|τ(σi )|
,
the term Γ ⊢ ω(t 1 , . . . , t k ): σ is mapped under the translation τ to the tuple
D
E
¦
©
τ(Γ) ⊢ τ(ω)h { yi, j := τ(t i ) j }1≤ j≤|τ(σi )| i∈kkk
1≤h≤|τ(σ)|
.
Lemma 3.2 (Compositionality). The extension of a first-order syntactic translation on terms commutes
with substitution. Formally, for a translation τ: Σ → Σ′ and term Γ ⊢ t{x k := sk }k∈knk : σ, where
k ∈ knk and Γ ⊢ sk : σk , we have for all 1 ≤ i ≤ |τ(σ)|,
τ(Γ) ⊢ τ t{x k := sk }k∈knk
i
= τ(t)i {x k, j := τ(sk ) j }k∈knk,1≤ j≤|τ(σk )| : τ(σ)i
.
41
CHAPTER 3. FIRST-ORDER SYNTACTIC TRANSLATIONS
Proof. We proceed by induction on the structure of the term Γ, x 1 : σ1 , . . . , x n : σn ⊢ t : σ.
τ x l {x k := sk }k∈knk
-
= τ(sl )i
i
= x l,i {x k, j := τ(sk ) j }k∈knk,1≤ j≤|τ(sk )|
= τ(x l ){x k, j := τ(sk ) j }k∈knk,1≤ j≤|τ(sk )|
τ ω(. . . , t, . . . ){x k := sk }k∈knk
-
i
= τ ω(. . . , t{x k := sk }k∈knk , . . . ) i
= τ(ω)i yl := τ t{x k := sk }k∈knk l 1≤l≤|τ(t)|
= τ(ω)i yl := τ(t)l {x k, j := τ(sk ) j }k∈knk,1≤ j≤|τ(sk )| 1≤l≤|τ(t)|
= τ(ω)i { yl := τ(t)l }1≤l≤|τ(t)| {x k, j := τ(sk ) j }k∈knk,1≤ j≤|τ(sk )|
= τ ω(. . . , t, . . . ) i {x k, j := τ(sk ) j }k∈knk,1≤ j≤|τ(sk )|
Syntactic translations. A syntactic translation τ: E → E ′ between first-order equational presentations E = (Σ, E) and E ′ = (Σ′ , E ′ ) is a signature translation τ: Σ → Σ′ , such that for every axiom
Γ ⊢ E t 1 ≡ t 2 : σ of E , the judgements τ(Γ) ⊢ τ(t 1 )i ≡ τ(t 2 )i : τ(σ)i (for all 1 ≤ i ≤ |τ(σ)|) are
derivable from E ′ .
Lemma 3.3. The extension of a first-order syntactic translation on terms preserves equational derivability.
Proof. We verify for each rule of First-Order Equational Logic (Section 2.1.3) that the hypothesis
is mapped under a syntactic translation to a finite collection of derivable equations. One needs to
only check the Substitution derivability rule. For τ: E → E ′ a syntactic translation of equational
presentations, let
τ(Γ), τ(x : σ) ⊢ τ(s) j : τ(σ′ ) j
be a term and
τ(Γ) ⊢ τ(t 1 )i ≡ τ(t 2 )i : τ(σ)i
be an equation of E ′ . Then we indeed have from the substitution rule of the First-Order Equational
Logic of E ′
τ(Γ) ⊢ τ(s) j { y j := τ(t 1 )i }1≤i≤|σ| ≡ τ(s) j { y j := τ(t 2 )i }1≤i≤|σ| : τ(σ′ ) j
for all 1 ≤ j ≤ |τ(s)|, which further implies
τ(Γ) ⊢ τ s{x := t 1 } ≡ τ s{x := t 2 } : τ(σ′ ) j
by the Compositionality Lemma (Lemma 3.2).
42
,
3.2. Syntactic Translations
For the detailed syntactic definitions to yield some intuition, we provide examples of (mono-sorted)
syntactic translations from classical universal algebra.
Example 3.4.
(1) One may define a syntactic translation from the presentation EG of the theory of groups to itself,
according to the following mappings of operators to terms:
e 7→ − ⊢ e()
i 7→ x ⊢ i(x)
m 7→ x 1 , x 2 ⊢ m(x1 , x2 )
The axioms of group theory are just mapped to themselves. In fact, we will see below that this is
an example of an identity syntactic translation.
(2) We can also translate the presentation EG of the theory of groups into that of the theory of rings,
ER , which has operators +: 2, 0: 0, −: 1, •: 2, and 1: 1. Recall that the axioms of ER are
given by associativity of + and •, identity with respect to both + and •, existence of an inverse
−, commutativity of +, and finally distributivity of • over +. We define the syntactic translation
τG →R : EG → ER by the following mapping (where infix notation is used for the operators of
ER ):
e 7→ − ⊢ 0()
i 7→ x ⊢ −(x)
m 7→ x 1 , x 2 ⊢ x 1 + x 2
Axioms of EG translate to axioms of ER representing associativity, identity, and the existence of
an inverse for the operator +.
Translation composition and identity. We define the composition τ′ ◦ τ: E1 → E3 of translations
τ: E1 → E2 and τ′ : E2 → E3 to be the composition of the underlying mappings, more formally given
by
σ 7→ τ′ (τ(σ)1 ), . . . , τ′ (τ(σ)|τ(σ)| )
ω: σ1 , . . . , σk → σ 7→ Γτ′ (τ(σ1 )) , . . . , Γτ′ (τ(σk )) ⊢ τ′ (τ(ω)i ) ji : τ′ (τ(σ)i ) ji 1≤i≤|τ(σ)|,
1≤ ji ≤|τ′ (τ(σ)i )|
Note that this definition immediately implies that the extension of the composite τ′ ◦τ on a term t is
simply given by τ′ (τ(t)), and that composition of translations is an associative operation. Translation composition moreover preserves equational derivability. More precisely, an axiom Γ ⊢ s ≡ t : σ
of E1 has its image under the composite τ′ ◦ τ given by the tuple
τ′ (τ(Γ)) ⊢ τ′ (τ(s))i ≡ τ′ (τ(t))i : τ′ (τ(σ))i
1≤i≤|(τ′ ◦τ)(σ)|
,
43
CHAPTER 3. FIRST-ORDER SYNTACTIC TRANSLATIONS
whose component equations are indeed derivable in E3 because each of τ and τ′ preserves equational derivability.
Furthermore, we define the identity syntactic translation τE : E → E on an equational presentation
E = (Σ, E) by the following mappings
σ 7→ (σ)
ω: σ1 , . . . , σn → σ 7→
x 1 : σ1 , . . . , x n : σn ⊢ ω(x 1 , . . . , x n ): σ
The extension of the identity translation evidently acts as the identity on contexts and terms; hence
axioms are just mapped to themselves. Note that τE behaves indeed as the identity with respect to
′
syntactic translation composition. Given a translation τ: E → E ′ , the fact that τ ◦ τE = τ = τE ◦ τ
is clear for sorts. For an operator ω: σ1 , . . . , σn → σ of E , (τ ◦ τE )(ω) is the image of the term
x 1 : σ1 , . . . , x n : σn ⊢ ω(x 1 , . . . , x n ): σ
′
under τ, which is just τ(ω). On the other hand, the image of τ(ω) under τE is also simply τ(ω),
as the extension of the identity syntactic translation on terms is the identity mapping.
The category of first-order equational presentations. Using the previous development, we define
the category FOEP to have objects first-order equational presentations and morphisms given by
syntactic translations.
3.3 The Signature/Theory Adjunction
A signature generates a free algebraic theory, and every algebraic theory is given by a quotient of
a free algebraic theory. We take a little diversion from the categorical type theory correspondence
to recall this fundamental adjunction presented by Lawvere [Lawvere, 2004]. Although it is an integral element of the development of algebraic theories, its aim here is to illustrate that syntactic
translations are syntactically constructed Kleisli maps under the signature/theory adjunction.
Recall that Sigµ is the category of multi-sorted first-order signatures and maps. Define the functor
U : FOAT → Sigµ by mapping an algebraic theory L : LS → L to the signature Σ(L) of its internal
language E(L). An algebraic translation F : L → L ′ (ϕ : S → (S ′ )∗ ) between algebraic theories
L : LS → L and L ′ : LS ′ → L ′ is mapped to the signature map
µ̂ F : Σ(L) → Σ(L ′ )
σ 7→ Fσ
ω f : σ1 , . . . , σn → σ 7→ Fω◦ ∼
=σ1 ,...,σn
where ∼
=σ1 ,...,σn : Fσ1 × · · · × Fσn → F(σ1 × · · · × σn ) is the canonical isomorphism.
44
3.4. First-Order Syntactic Categorical Type Theory Correspondence
Theorem 3.5 (Signature/theory adjunction). In the above setting, the functor U : FOAT → Sigµ has
a left adjoint F : Sigµ → FOAT.
Proof sketch. The left adjoint maps an S-sorted signature Σ to its classifying algebraic theory
LΣ : LS → L(Σ), and a signature map µ: Σ → Σ′ , for Σ′ = (S ′ , Ω′ , | − |), to (ϕµ∗ , Fµ∗ ), where
ϕµ∗ : S → (S ′ )∗ ,
Fµ∗ : L(Σ) → L(Σ′ ),
σ 7→ µ(σ)
σ1 , . . . , σn 7→ µ(σ1 ), . . . , µ(σn ),
〈t 1 , . . . , t k 〉 7→ 〈µ(t 1 ), . . . , µ(t n )〉
It is clear that this satisfies the definition of algebraic translation. The counit ε of this adjunction has
component at an algebraic theory L : LS → L given by the algebraic translation (idS , ε L ), where idS
is just the identity on the set of sorts S, and ε L : L(Σ(L)) → L is the functor mapping (σ1 , . . . , σn ) to
σ1 × · · · × σn . On morphisms, ε L is defined by induction on term structure as follows. The variable
term x 1 : σ1 , . . . , x n : σn ⊢ x i : σi is mapped to the projection πi : σ1 ×· · ·×σn → σi , and for an operator ω f : τ1 , . . . , τ k → τ, the term x 1 : σ1 , . . . , x n : σn ⊢ ω f (t 1 , . . . , t k ): τ is mapped to the composite
f ◦ 〈ε L (t 1 ), . . . , ε L (t k )〉.
We use the free theory construction of Theorem 3.5 to provide an equivalent definition of the notion
of syntactic signature translation.
Proposition 3.6. Let F ⊣ U be the signature/theory adjunction. The Kleisli category Sigµ (T) for
the monad T = U F is isomorphic to the category Sigτ of multi-sorted first-order signatures and their
syntactic translations.
Indeed, a Kleisli map Σ → Σ′ maps sorts to tuples of sorts and operators to tuples of terms, which
defines a signature translation. The identity translation on Σ is given by the component ηΣ : Σ → TΣ
at Σ of the unit η of this adjunction.
3.4 First-Order Syntactic Categorical Type Theory Correspondence
We have only shown one direction of the First-Order Syntactic Categorical Type Theory Correspondence, namely the equivalence of an algebraic theory and the classifying algebraic theory of its own
internal language (Theorem 2.17). We now complete this correspondence by proving the other
direction, which states that an equational presentation is isomorphic to the internal language of
its own classifying theory (Theorem 3.8) and finally establishing that syntactic translations are the
correct syntactic counterpart of algebraic translations (Theorem 3.10).
3.4.1 Presentation/theory correspondence
Although Theorem 2.17 is now an integral result of the development surrounding categorical universal algebra, its syntactic counterpart has not been spelled out elsewhere. This, we believe, is
due to the non-existence of an explicit, syntactically specified notion of isomorphism of equational
presentations, which, given our definition of syntactic translation, is now trivial to formalise.
45
CHAPTER 3. FIRST-ORDER SYNTACTIC TRANSLATIONS
Definition 3.7. A syntactic translation τ: E → E ′ of equational presentations is an isomorphism if
′
there exists a syntactic translation τ−1 : E ′ → E such that τ ◦ τ−1 is naturally isomorphic to τE and
′
τ−1 ◦ τ is naturally isomorphic τE , where τE and τE are the identity syntactic translations on E and
E ′ , respectively.
Theorem 3.8 (First-order presentation/theory correspondence). Every multi-sorted first-order equational presentation E = (S, Σ, E) is isomorphic to the internal language E(LE ) of its own classifying
first-order algebraic theory LE : LS → L(E ).
Proof. Let E = (S, Σ, E) be an equational presentation, and define the syntactic translation
ξE : E → E(LE )
by mapping a sort σ to itself (more correctly to the single tuple (σ) of itself, but for ease of readability, and without compromising our proof, we will not make this slight distinction in what follows)
and an operator ω̂: σ1 , . . . , σk → σ to the term
x 1 : σ1 , . . . , x k : σk ⊢ ω f (ω̂) (x 1, . . . , x k ): σ
,
where we write f (ω̂) for the morphism
x 1 : σ1 , . . . , x k : σk ⊢ ω̂(x 1 , . . . , x k ): σ
E
: σ1 × · · · × σ k → σ
of L(E ), which induces the operator ω f (ω̂) of E(LE ). Note that ξE acts as the identity on contexts,
and its extension on a term x 1 : σ1 , . . . , x n : σn ⊢ t : σ of E is given by
x 1 : σ1 , . . . , x n : σn ⊢ ω〈[t]E 〉 (x 1 , . . . , x n ): σ
of E(LE ). The correctness of this extension mapping can be seen by structural induction on t:
- The image of x 1 : σ1 , . . . , x n : σn ⊢ x i : σi under ξE is given by
x 1 : σ1 , . . . , x n : σ n
⊢
(E 1)
xi
≡
ωπi (x 1 , . . . , x n )
=
ω〈[x i ]E 〉 (x 1 , . . . , x n ) : σi
,
where 〈[x i ]E 〉: σ1 × · · · × σn → σi is the i-th projection πi in L(E ).
- For an operator ω̂: τ1 , . . . , τ k → σ, the image of x 1 : σ1 , . . . , x n : σn ⊢ ω̂(t 1 , . . . , t k ): σ under
ξE is
x 1 : σ1 , . . . , x n : σ n
⊢
=
(E 2)
≡
46
ξE (ω̂) yi := ξE (t i ) i∈kkk
ω f (ω̂) ( y1 , . . . , yk ) yi := ω〈[t i ]E (x1 ,...,x n )〉 i∈kkk
ω〈[ω̂(t 1 ,...,t k )]E 〉 (x 1 , . . . , x n ) : σ
,
3.4. First-Order Syntactic Categorical Type Theory Correspondence
where, recall, f (ω̂) is the morphism 〈[ω̂( y1 , . . . , yk )]E 〉: τ1 × · · · × τ k → σ of L(E ), and the
validity of applying (E 2) above follows from the morphism equality
〈[ω̂(t 1 , . . . , t k )]E 〉 = f (ω̂) ◦ 〈[t 1 ]E , . . . , [t k ]E 〉
in L(E ).
Moreover, the translation ξE maps axioms of E to derivable equations of E(LE ) and is therefore
justifiably a translation of equational presentations. Indeed, given an axiom
x 1 : σ1 , . . . , x n : σ n ⊢ E t ≡ s : σ
of E , we know that 〈[t]E 〉 and 〈[s]E 〉 are the same morphism in L(E ) and therefore induce the same
operator ω〈[t]E 〉 = ω〈[s]E 〉 of E(LE ). This means that we have the equality
x 1 : σ1 , . . . , x n : σn ⊢ ω〈[t]E 〉 (x 1 , . . . , x n ) ≡ ω〈[s]E 〉 (x 1 , . . . , x n ): σ
in E(LE ), which further gives
x 1 : σ1 , . . . , x n : σn ⊢ ξE (t) ≡ ξE (s): σ
from the definition of the extension of ξE on terms.
In the other direction, define the syntactic translation
ξ̄E : E(LE ) → E
by mapping a sort σ1 × · · · × σn of E(LE ) to the tuple (σ1 , . . . , σn ) of sorts σi of E . For a morphism
〈[t]E 〉: σ1 × · · · × σn → σ of L(E ), the operator ω〈[t]E 〉 : σ1 , . . . , σn → σ is mapped under ξ̄E to the
term x 1 : σ1 , . . . , x n : σn ⊢ t : σ of E . A few requirements need to be satisfied for ξ̄E to be a welldefined syntactic translation. First, note that it has been defined on representatives of equivalence
classes [−]E . However, these are well-respected, as given congruent terms t and s, the morphisms
〈[t]E 〉 and 〈[s]E 〉 are equal in L(E ), and therefore they induce the same operator ω〈[t]E 〉 = ω〈[s]E 〉
of E(LE ), whose images under ξ̄E must therefore be equal. Moreover, the definition of ξ̄E ensures
that axioms of E(LE ) are mapped to theorems of E .
We finally show that the syntactic translations ξE and ξ̄E are mutual inverses in the sense of
Definition 3.7, thereby proving the syntactic isomorphism E ∼
= E(L ). The isomorphism is evident
E
on sorts − we have (ξ̄E ◦ ξE )(σ) = ξ̄(σ) = σ, and
(ξE ◦ ξ̄E )(σ1 × · · · × σn ) = ξE (σ1 , . . . , σn ) = (σ1 , . . . , σn ) = σ1 × · · · × σn
.
47
CHAPTER 3. FIRST-ORDER SYNTACTIC TRANSLATIONS
For an operator ω̂: σ1 , . . . , σn → σ of E , we have
(ξ̄E ◦ ξE )(ω̂) = ξ̄E ω〈[ω̂(x1 ,...,x n )]E 〉
= ω̂(x 1 , . . . , x n ) = τE (ω̂)
.
On the other hand, given a term x 1 : σ1 , . . . , x n : σn ⊢ t : σ of E , we have
(ξE ◦ ξ̄E )(ω〈[t]E 〉 ) = ξE (t) = ω〈[t]E 〉 (x 1 , . . . , x n ) = τE(LE ) (ω〈[t]E 〉 )
.
3.4.2 Induced syntactic and algebraic translations
To ensure the correctness of our development of syntactic translations, we verify that the notion
of algebraic translation is equivalent to that of syntactic translation in the context of the Syntactic Categorical Type Theory Correspondence. We start by illustrating how to construct an algebraic
translation from a syntactic one, and, vice versa, a syntactic translation from an algebraic translation.
Induced algebraic translations. Let τ: E → E ′ be a first-order syntactic translation between equational presentations E = (S, Σ, E) and E ′ = (S ′ , Σ′ , E ′ ) equational presentations with respective
classifying algebraic theories LE : LS → L(E ) and LE ′ : LS ′ → L(E ′ ). Define the functor
L(τ)
L(E ) → L(E ′ )
:
(σ1 , . . . , σn ) 7→ τ(σ1 ), . . . , τ(σn )
7→ [τ(t)1 ]E ′ , . . . , [τ(t)|τ(t)| ]E ′
.
[t]E
L(τ) respects the equivalence classes [−]E because the translation τ preserves equational derivability. Note also that L(τ) is functorial: evidently, L(τ)(id(σ1 ,...,σn ) ) = idτ(σ1 ),...,τ(σn ) , and compositionality is implied by the fact that the extension of τ on terms of E commutes with substitution (Lemma
3.2). Moreover, the functor L(τ), together with the mapping ϕ(τ): S → (S ′ )∗ (σ 7→ τ(σ)), is indeed
an algebraic translation. By definition, it is cartesian, and the following diagram commutes.
Lϕ(τ)
LS
- L ′
S
LE ′
LE
?
L(E )
L(τ)
?
- L(E ′ )
We have this way defined a functor
L(−)
:
FOEP → FOAT
E
7→
LE : LS → L(E )
τ 7→ L(τ)
mapping a first-order equational presentation to its classifying first-order algebraic theory, and a
48
3.4. First-Order Syntactic Categorical Type Theory Correspondence
first-order syntactic translation to its induced algebraic translation.
Induced syntactic translations. Let L : LS → L and L ′ : LS ′ → L ′ be first-order algebraic theories,
and F : L → L ′ , together with ϕ : S → (S ′ )∗ , be a first-order algebraic translation. Define the
syntactic translation
E(F): E(L) → E(L ′ )
by mapping σ to F(σ), and an operator ω f : σ1 , . . . , σn → σ of E(L) to the tuple
→
Γ F σ 1 , . . . , Γ F σ n ⊢ ω F f i (−
y)
1≤i≤|F (σ)|
of terms of E(L ′ ), where ω f is the operator induced by the morphism f : σ1 × · · · × σn → σ of L ,
→
the notation −
y denotes the list of variables y j with length given by the arity of ω F f i , and F f of L ′
is the morphism
(F f )1 , . . . , (F f )|F σ| : F(σ1 ) × F(σn ) → F(σ)1 × · · · × F(σ)|F σ|
.
Lemma 3.9. The induced syntactic translation E(F)(t) on a term t of sort σ of E(L) is given by the
tuple
→
ω F ¹tº∗ j (−
y)
1≤ j≤|F σ|
,
where ¹−º∗ is the canonical algebra of E(L) in L , and F¹tº∗ j is the j-th component morphism of the
tuple F¹tº∗ .
Proof. By structural induction on t.
- The image of Γ ⊢ x i : σi under E(F) is given by 〈 y1 , . . . , y|F (σi )| 〉, where for each y j we have
yj
(E 1)
→
→
≡ ωπL ′ (−
y ) = ω F (πL ) (−
y ) = ω F ¹x i º∗ j
j
j
.
- For f : σ1 × · · · × σk → σ of L , the j-th component of the image of Γ ⊢ ω f (t 1 , . . . , t k ): σ
under E(F) is given by
E(F) ω f (t 1 , . . . , t k )
=
=
=
(E 2)
≡
j
E(F)(ω f ) j { y1,i := E(F)(t 1 )i }1≤i≤|σ1 | · · · { yk,i := E(F)(t k )i }1≤i≤|σk |
→
→
→
ω F f j (−
x ){ y1,i := ω F ¹t 1 º∗ i (−
y1 )}1≤i≤|σ1 | · · · { yk,i := ω F ¹t k º∗ i (−
yk )}1≤i≤|σk |
−
→
→
−
→
{ y := ω
ω
( y )}
· · · { y := ω
(−
y )}
F ¹ω f ( z )º∗ j
1,i
→
ω F ¹ω f (t 1 ,...,t k )º∗ (−
x)
j
F ¹t 1 º∗ i
.
1
1≤i≤|σ1 |
k,i
F ¹t k º∗ i
k
1≤i≤|σk |
Next, note that E(F) maps axioms of E(L) to derivable equations of E(L ′ ). Given Γ ⊢ E(L) t ≡ s : σ
49
CHAPTER 3. FIRST-ORDER SYNTACTIC TRANSLATIONS
in E(L), we have
⇒
F¹tº∗
= ¹sº∗
= F¹sº∗
in L ′
⇒
ω F ¹tº∗
= ω F ¹sº∗
in E(L ′ )
⇒
¹tº∗
E(F)(t)i
in L
in E(L ′ ),
≡ E(F)(s)i
(1 ≤ i ≤ |Fσ|)
.
Using the definition of E(F), we obtain the functor
E(−)
:
FOAT → FOEP
L : LS → L
7→ E(L)
F
7→ E(F)
mapping a first-order algebraic theory to its internal language, and an algebraic translation to its
induced syntactic translation.
Having shown how to construct syntactic translations from algebraic translations, and vice versa,
we proceed to show that these constructions are mutually inverse in a categorical sense.
Theorem 3.10 (First-Order Syntactic Categorical Type Theory Correspondence). The categories
FOAT of (multi-sorted) first-order algebraic theories and algebraic translations and FOEP of (multisorted) first-order equational presentations and their syntactic translations are equivalent.
Proof. The equivalence is given by the functors L(−) and E(−) defined above, together with the
natural isomorphism
ξ: IdFOEP → E(−) ◦ L(−)
with component at an equational presentation E given by the syntactic translation isomorphism
ξE : E → E(LE ) witnessing the Presentation/Theory Correspondence of Theorem 3.8, and the natural isomorphism
Ξ: IdFOAT → L(E(−))
with component at an algebraic theory L : LS → L given by the algebraic translation Ξ L : L →
L(E(L)), which we take to be the isomorphism witnessing the Theory/Presentation Correspondence
→
as defined in Theorem 2.17 ((σ1 , . . . , σn ) 7→ (σ1 , . . . , σn ), f 7→ 〈[ω f (−
x )]E(L) 〉). Naturality of ξ and
Ξ establishes the idea that algebraic and syntactic translations are essentially the same. Indeed,
given a first-order syntactic translation τ: E → E ′ , the following diagram commutes.
E
τ
ξE ′
ξE
?
E(LE )
50
- E′
E(L(τ))
-
?
E(LE ′ )
3.4. First-Order Syntactic Categorical Type Theory Correspondence
Evidently, for a sort σ of E ,
E(L(τ))(σ) = L(τ)(σ) = τ(σ) = ξE ′ (τ(σ)) .
Also, for an operator ω̂: σ1 , . . . , σk → σ of E , we have
(E(L(τ)) ◦ ξE )(ω̂) = E(L(τ)) ω f (ω̂) (x 1 , . . . , x k )
→
= ωL(τ)( f (ω̂))i (−
y ) 1≤i≤|τ(σ)|
→
.
=
ω
(−
y)
τ(ω̂)i
1≤i≤|τ(σ)|
Next, for F : L → L ′ an algebraic translation of algebraic theories L : LS → L and L ′ : LS ′ → L ′ ,
naturality of Ξ is given by the diagram
L
F
- L′
Ξ L′
ΞL
?
L(E(L))
L(E(F ))
?
- L(E(L ′ ))
whose commutativity is obvious on the objects of L . For a morphism f : σ1 ×· · ·×σn → σ, we have
→
x )]E(L)
L(E(F)) ◦ Ξ L ( f ) = L(E(F)) [ω f (−
→
= [E(F) ω f (−
x ) ]E(L ′ ) 1≤i≤|E(F )(σ)|
→
= [ω F f (−
x i )i ]E(L ′ ) 1≤i≤|F σ|
= (Ξ L ′ ◦ F)( f )
.
51
CHAPTER 3. FIRST-ORDER SYNTACTIC TRANSLATIONS
52
Chapter 4
SECOND -ORDER SYNTAX
AND
SEMANTICS
The realm of universal algebra is traditionally restricted to first-order languages. In particular, this
leaves out languages with variable-binding. Variable-binding constructs are at the core of fundamental calculi and theories in computer science and logic [Church, 1936, Church, 1940], and incorporating them into algebra has been a main foundational problem.
This chapter reviews the work of Fiore and Hur [Fiore and Hur, 2010] on a conservative extension of
universal algebra from first to second order. We present in Section 4.1 the syntactic machinery surrounding second-order languages. This includes the notion of second-order equational presentation,
which allows the specification of equational theories by means of schematic identities over signatures with variable-binding operators. Second-order equational logic is presented in Section 4.2 as
the deductive system underlying formal reasoning about second-order structure, and its conservativity over first-order equational logic is recalled. Finally, we review the model theory of second-order
equational presentations by means of second-order algebras (Section 4.3), together with its soundness and completeness.
While the main contribution of this work is the abstract categorical presentation of second-order languages via second-order algebraic theories, the details of the syntactic development of this chapter
are crucial for validating the correctness of our definitions. More precisely, properly understanding the subtleties surrounding second-order syntax will enable us to define second-order algebraic
theories (Chapter 5) in a way that legitimately corresponds to second-order equational presentations. At the semantic level, the model theory of second-order universal algebra as presented in
this chapter will yield a definition of second-order functorial semantics (Chapter 7) proven to be its
equivalent.
4.1 Second-Order Syntactic Theory
We present the syntactic theory of second-order languages, that is languages that come equipped
with variable-binding constructs and parameterised metavariables. The development comprises
second-order signatures on top of which second-order terms-in-context are defined. For succinct53
CHAPTER 4. SECOND-ORDER SYNTAX AND SEMANTICS
ness, our exposition restricts to the mono-sorted setting. The generalisation to the multi-sorted
framework can be found in the Appendix to Chapter 4 (4.A).
4.1.1 Second-order signatures
Following the development of Aczel [Aczel, 1978], a (mono-sorted) second-order signature Σ =
(Ω, | − |) is specified by a set of operators Ω and an arity function | − |: Ω → N∗ . For an operator
ω ∈ Ω, we write ω: (n1 , . . . , nk ) whenever it has arity |ω| = (n1 , . . . , nk ). The intended meaning
here is that the operator ω takes k arguments binding ni variables in the i th argument.
Any language with variable binding fits this formalism, including languages with quantifiers
[Aczel, 1980], a fixpoint operator [Klop et al., 1993], and the primitive recursion operator
[Aczel, 1978]. The most prototypical of all second-order languages is the λ-calculus, whose secondorder signature is given next.
Example 4.1. The second-order signature Σλ of the mono-sorted λ-calculus has operators
abs : (1)
and
app : (0, 0) ,
representing λ abstraction and application, respectively.
4.1.2 Second-order terms
Variables and metavariables. Unlike the first-order universe where first-order terms are built up
only from variables and (first-order) operators, second-order terms have metavariables as additional
building blocks. We use the notational convention of denoting variables similar to first-order variables by x, y, z, and metavariables by M, N , L. Metavariables come with an associated natural number
arity, also referred to as its meta-arity. A metavariable
M
of meta-arity m, denoted by
M:
[m], is to
be parameterised by m terms.
Contexts. Second-order terms are considered in contexts with two zones, each respectively declaring
metavariables and variables. Accordingly, we use the following representation for contexts
M1 :
where the metavariables
Mi
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n
,
and variables x j are assumed to be distinct.
Terms. Signatures give rise to terms. These are built up by means of operators from both variables
and metavariables, and hence referred to as second-order. The judgement for second-order terms in
context
ΘÂΓ⊢ t
is defined similar to the second-order syntax of Aczel [Aczel, 1978] by the following rules.
54
4.1. Second-Order Syntactic Theory
(Variables) For x ∈ Γ,
ΘÂΓ⊢ x
(Metavariables) For (M : [m]) ∈ Θ,
Θ Â Γ ⊢ ti
(1 ≤ i ≤ m)
Θ Â Γ ⊢ M[t 1 , . . . , t m ]
(Operators) For ω: (n1 , . . . , nk ),
→
Θ Â Γ, −
x i ⊢ t i (1 ≤ i ≤ k)
→
→
Θ Â Γ ⊢ ω (−
x 1 )t 1 , . . . , (−
x k )t k
→
where −
x i stands for x 1 , . . . , x n(i) .
(i)
i
Terms derived according to the first two rules only via variables and metavariables are referred to
as elementary. Hence, an empty signature with an empty set of operators generates only elementary
terms.
Terms are considered up to the α-equivalence relation induced by stipulating that, for every operator
→
→
→
x are bound in t .
ω: (n , . . . , n ), in the term ω (−
x )t , . . . , (−
x )t the variables −
1
1
k
1
k
i
k
i
Example 4.2. Two sample terms for the signature Σλ of the mono-sorted λ-calculus of Example 4.1
follow:
M:
M:
[1], N : [0] Â − ⊢ app abs (x)M[x] , N [] ,
[1], N : [0] Â − ⊢ M [N[]].
4.1.3 Second-order substitution calculus
The second-order nature of the syntax requires a two-level substitution calculus. Each level respectively accounts for the substitution of variables and metavariables, with the latter operation
depending on the former [Aczel, 1978, Klop et al., 1993, van Raamsdonk, 2003, Fiore, 2008].
Substitution. The operation of capture-avoiding simultaneous substitution of terms for variables
maps
Θ Â x1, . . . , x n ⊢ t
to
and
Θ Â Γ ⊢ ti
(1 ≤ i ≤ n)
Θ Â Γ ⊢ t x i := t i i∈knk
according to the following inductive definition:
- x j x i := t i i∈knk = t j
-
M [. . . , s, . . . ]
x i := t i
i∈knk
= M . . . , s x i := t i i∈knk , . . .
55
CHAPTER 4. SECOND-ORDER SYNTAX AND SEMANTICS
-
ω(. . . , ( y1 , . . . , yk )s, . . . )
x i := t i
with z j ∈
/ dom(Γ) for all j ∈ kkk.
i∈knk
= ω . . . , ( y1 , . . . , yk )s x i := t i , y j := z j i∈knk, j∈kkk , . . .
The (first-order) Substitution Lemma is valid in the second-order setting as well. The proof is
straightforward by induction on the structure of the term t, details of which can be found
in Appendix 4.B.
Lemma 4.3 (Second-Order Substitution Lemma). Given terms
Θ Â Γ ⊢ si
(1 ≤ i ≤ n),
Θ Â Γ ⊢ rj
(1 ≤ j ≤ k),
Θ Â x 1 , . . . , x n , y1 , . . . , yk ⊢ t,
and
we have
o
n
Θ Â Γ ⊢ t x i := si i∈knk y j := r j j∈kkk = t x i := si y j := r j j∈kkk
i∈knk
.
Metasubstitution. The operation of metasubstitution of abstracted terms for metavariables maps
M1 :
[m1 ], . . . , M k : [mk ] Â Γ ⊢ t
to
ΘÂΓ⊢t
and
Mi
→
:= (−
x i )t i
according to the following inductive definition:
- x
Mi
→
:= (−
x i )t i
]
l
i∈kkk
→
:= (−
x i )t i
Mi
M l [s1 , . . . , sm
-
→
ω(. . . , (−
x )s, . . . )
(1 ≤ i ≤ k)
i∈kkk
=x
Mi
-
→
Θ Â Γ, −
x i ⊢ ti
o
n
(i)
−
→
M
:=
(
x
)t
=
t
x
:=
s
i
i i i∈kkk
l
j
i∈kkk
j
→
:= (−
x i )t i
i∈kkk
→
= ω . . . , (−
x )s
Mi
→
:= (−
x i )t i
j∈kml k
i∈kkk , . . .
The operation of metasubstitution is well-behaved, in the sense that it is compatible with substitution
(Substitution-Metasubstitution Lemma) and monoidal, meaning that it is associative (Metasubstitution Lemma I) and has a unit (Metasubstitution Lemma II). Syntactic proofs of all of the following
are detailed in Appendix 4.B.
Lemma 4.4 (Substitution-Metasubstitution Lemma). Given terms
M1 :
and
56
[m1 ], . . . , M k : [mk ] Â Γ ⊢ t i
M1 :
(1 ≤ i ≤ n),
→
Θ Â Γ, −
y j ⊢ sj
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ t,
(1 ≤ j ≤ k),
4.2. Second-Order Equational Logic
we have
ΘÂΓ
→
y j )s j j∈kkk
t x i := t i i∈knk M j := (−
o
n
→
→
y j )s j j∈kkk
t M j := (−
y j )s j j∈kkk x i := t i M j := (−
⊢
=
i∈knk
.
Lemma 4.5 (Metasubstitution Lemma I). Given terms
→
Θ Â Γ, −
x i ⊢ ri
M1 :
and
→
Θ Â Γ, −
y j ⊢ sj
(1 ≤ i ≤ k),
(1 ≤ j ≤ l),
[m1 ], . . . , M k : [mk ], N1 : [n1 ], . . . , N l : [nl ] Â Γ ⊢ t,
we have
ΘÂΓ
⊢
=
t
t
Mi
→
:= (−
x i )ri
Nj
→
:= (−
y j )s j j∈klk
i∈kkk N j
n
Mi
→
:= (−
y j )s j
j∈klk
→
→
y j )s j j∈klk
:= (−
x i )ri N j := (−
o
.
i∈kkk
Lemma 4.6 (Metasubstitution Lemma II). Given terms
M1 :
[m1 ], . . . , M k : [mk ] Â Γ ⊢ t
and
M1 :
(i)
(i)
(i)
(i)
]
⊢ M i [x 1 , . . . , x m
[m1 ], . . . , M k : [mk ] Â Γ, x 1 , . . . , x m
i
i
for 1 ≤ i ≤ k, we have
M1 :
[m1 ], . . . , M k : [mk ] Â Γ ⊢ t
Mi
→
(i)
:= (−
x i )M i [x 1 , . . . , x m
]
(i)
i
i∈kkk
=t
.
4.1.4 Parameterisation
Every second-order term Θ Â Γ ⊢ t can be parameterised to yield a term Θ, Γ̂ Â − ⊢ t̂, where for
Γ = x1, . . . , x n,
Γ̂ = X1 : [0], . . . , X n : [0]
and
t̂ = t x i := X i [] i∈knk
.
The variable context is thus replaced under parameterisation by a metavariable context, yielding
an essentially equivalent term (formally parameterised term) where all its variables are replaced by
metavariables, which do not themselves parameterise any terms. This allows us to intuively think of
metavariables of zero meta-arity as variables, and vice versa.
4.2 Second-Order Equational Logic
We add equations on top of the above constructions to yield second-order equational presentations,
together with rules for equational derivation via Second-Order Equational Logic.
57
CHAPTER 4. SECOND-ORDER SYNTAX AND SEMANTICS
(Axioms)
Θ Â Γ ⊢E s ≡ t
ΘÂΓ⊢s≡t
(Equivalence)
ΘÂΓ⊢t
ΘÂΓ⊢s≡t
ΘÂΓ⊢t ≡t
ΘÂΓ⊢ t ≡s
ΘÂΓ⊢s≡t
ΘÂΓ⊢ t ≡u
ΘÂΓ⊢s≡u
(Extended metasubstitution)
M1 :
→
[m1 ], . . . , M k : [mk ] Â Γ ⊢ s ≡ t
Θ Â ∆, −
x i ⊢ si ≡ t i (1 ≤ i ≤ k)
→
−
→
x i )t i i∈kkk
Θ Â Γ, ∆ ⊢ s M i := ( x i )si i∈kkk ≡ t M i := (−
Figure 4.1: Second-Order Equational Logic
4.2.1 Equational Presentations
A second-order equation is given by a pair of second-order terms Θ Â Γ ⊢ s and Θ Â Γ ⊢ t in context,
written as
ΘÂΓ⊢s≡t
.
A second-order equational presentation E = (Σ, E) is specified by a second-order signature Σ together
with a set of equations E, the axioms of the presentation E , over it. Axioms are usually denoted by
Θ Â Γ ⊢E t ≡ s
to distinguish them from any other equations.
Example 4.7. The equational presentation Eλ = (Σλ , Eλ ) of the mono-sorted λ-calculus extends the
second-order signature Σλ of Example 4.1 with the following axioms.
(β) M : [1], N : [0] Â − ⊢ Eλ app abs (x)M[x] , N [] ≡ M N[]
(η)
F:
[0] Â − ⊢ Eλ abs (x)app(F[], x)
≡
F []
It is worth emphasising that the (mono-sorted) λ-calculus is merely taken as a running example
throughout this dissertation, for it is the most intuitive and widely-known such calculus. We use
it as a reference as a means of familiarisation with and appreciation of second-order syntax. The
expressiveness of the second-order formalism does not, however, rely exclusively on that of the λcalculus. One can directly axiomatise, say, primitive recursion [Aczel, 1978] and predicate logic
[Plotkin, 1998] as second-order equational presentations.
4.2.2 Equational logic
The rules of Second-Order Equational Logic are given in Figure 4.1. Besides the rules for axioms and
equivalence, the logic consists of just one additional rule stating that the operation of metasubstitu58
4.3. Second-Order Universal Algebra
tion in extended metavariable context is a congruence.
The expressive power of this system can be seen through the following two sample derivable rules.
(Substitution)
Θ Â x1, . . . , x n ⊢ s ≡ t
Θ Â Γ ⊢ si ≡ t i
(1 ≤ i ≤ n)
Θ Â Γ ⊢ s{x i := si }i∈knk ≡ t{x i := t i }i∈knk
(Extension)
M1 :
M1 :
[m1 ], . . . , M k : [mk ] Â Γ ⊢ s ≡ t
[m1 + n], . . . , M k : [mk + n] Â Γ, x 1 , . . . , x n ⊢ s# ≡ t #
(i)
(i)
where u# = u{M i := (x 1 , . . . , x n )M i [ y1 , . . . , ym
, x 1 , . . . , x n ]}i∈kkk .
i
4.2.3 Parameterised equations
Performing the operation of parameterisation on a set of equations E to obtain a set of parameterised
equations Ê, we have that all of the following are equivalent:
Θ Â Γ ⊢E s ≡ t
,
Θ, Γ̂ Â − ⊢E ŝ ≡ t̂
Θ Â Γ ⊢ Ê s ≡ t
,
Θ, Γ̂ Â − ⊢ Ê ŝ ≡ t̂
Therefore, and without loss of generality, any set of axioms can be transformed into a parameterised
set of axioms, which in essence represents the same equational presentation. One may restrict to
axioms containing an empty variable context as in the CRSs of Klop [Klop, 1980], but there is no
reason for us to do the same.
4.3 Second-Order Universal Algebra
The model theory of Fiore and Hur [Fiore and Hur, 2010] for second-order equational presentations
is recalled. For our purposes, this is presented here in elementary concrete model-theoretic terms
rather than in abstract monadic terms. The reader is referred to [Fiore and Hur, 2010] for the latter
perspective.
4.3.1 Semantic universe
Recall that we write F for the free cocartesian category on an object. Explicitly, F has N as set of
objects and morphisms m → n given by functions kmk → knk. The second-order model-theoretic
development lies within the semantic universe SetF , the presheaf category of sets in variable contexts [Fiore et al., 1999]. It is a well-known category, and the formalisation of second-order model
theory relies on some of its intrinsic properties. In particular, SetF is bicomplete with limits and colimits computed pointwise [MacLane and Moerdijk, 1992]. We write y for the Yoneda embedding
Fop ,→ SetF .
59
CHAPTER 4. SECOND-ORDER SYNTAX AND SEMANTICS
Substitution. We recall the substitution monoidal structure in the semantic universe SetF as presented in [Fiore et al., 1999]. The unit is given by the presheaf of variables y 1, explicitly the embedding F ,→ Set. This object is a crucial element of the semantic universe SetF , as it provides an arity
for variable binding. The monoidal tensor product X • Y of presheaves X , Y ∈ SetF is given by
X •Y =
A monoid
y1
Z
ν
k∈F
X (k) × Y k
- A
ς
.
A• A
for the substitution monoidal structure equips A ∈ SetF with substitution structure. In particular, the
map νk : y k → Ak , defined as the composite
k
ν
yk ∼
= (y 1)k - Ak
,
induces the embedding
(Ay n × An)(k) → A(k + n) × Ak (k) × An (k) → (A • A)(k) ,
which, together with the multiplication, yield a substitution operation
ςn : Ay n × An → A
for every n ∈ N. These substitution operations provide the interpretations of metavariables.
4.3.2 Second-order algebras and models
Algebras. Every second-order signature Σ = (Ω, | − |) induces a signature endofunctor FΣ : SetF →
SetF given by
FΣ X =
a
Y
ω: (n1 ,...,nk )∈Ω
X y ni
i∈kkk
FΣ -algebras FΣ X → X provide an interpretation
¹ωºX :
Y
X y ni → X
i∈kkk
for every operator ω: (n1 , . . . , nk ) in Σ.
We note that there are canonical natural isomorphisms
a
i∈I
Y
(X i • Y ) ∼
=
i∈I
(X i • Y ) ∼
=
i∈knk
60
a
Xi • Y
Y
i∈knk
Xi • Y
.
4.3. Second-Order Universal Algebra
and, for all points η: y 1 → Y , natural extension maps
η#n : X y n • Y → (X • Y )y n
.
These constructions equip every signature endofunctor FΣ with a pointed strength
̟X ,y1→Y : FΣ (X ) • Y → FΣ (X • Y )
.
This property plays a critical role in the notion of algebra with substitution structure, which depends
on this pointed strength. The extra structure on a presheaf Y in the form of a point ̟: y 1 → Y
reflects the need of fresh variables in the definition of substitution for binding operators. We refer
the reader to [Fiore et al., 1999] and [Fiore, 2008] for a detailed development.
Models. A model for a second-order signature Σ is an algebra equipped with a compatible substitution structure. Formally, Σ-models are defined to be Σ-monoids, which are objects A ∈ SetF equipped
with an FΣ -algebra structure α: FΣ A → A and a monoid structure ν : y 1 → A and ς: A • A → A that
are compatible in the sense that the following diagram commutes.
FΣ (A) • A
̟A,ν
- F (A • A)
Σ
FΣ ς
- F (A)
Σ
α
α•A
?
?
ς
A• A
- A
We denote by Mod(Σ) the category of Σ-models, with morphisms given by maps that are both
FΣ -algebra and monoid homomorphisms.
4.3.3 Soundness and completeness
We review the soundness and completeness of the model theory of Second-Order Equational Logic as
presented in [Fiore and Hur, 2010].
Semantics. A model A ∈ Mod(Σ) for a second-order signature Σ is explicitly given by, for a metavariable context Θ = (M1 : [m1 ], . . . , M k : [mk ]) and variable context Γ = (x 1 , . . . , x n ), a presheaf
¹Θ Â ΓºA =
Y
Ay mi × y n
i∈kkk
of SetF , together with interpretation functions
¹ωºA :
Y
Ay n j → A
j∈klk
for each operator ω: (n1 , . . . , nl ) of Σ. This induces the interpretation of a second-order term Θ Â
Γ ⊢ t in A as a morphism
¹Θ Â Γ ⊢ tºA : ¹Θ Â ΓºA → A
61
CHAPTER 4. SECOND-ORDER SYNTAX AND SEMANTICS
in SetF , which is given by structural induction as follows:
- ¹Θ Â Γ ⊢ x i ºA is the composite
π2
¹Θ Â ΓºA
- yn
πj
νn
- An
- A
- ¹Θ Â Γ ⊢ M i [t 1 , . . . , t mi ]ºA is the composite
ςm i
〈πi π1 , f 〉
- Ay mi × Ami
¹Θ Â ΓºA
.
- A ,
where f = ¹Θ Â Γ ⊢ t j ºA j∈kmi k .
- For an operator ω: (n1 , . . . , nl ) of Σ,
→
→
¹Θ Â Γ ⊢ ω (−
y 1 )t 1 , . . . , (−
y l )t l ºA
is the composite
¹Θ Â ΓºA
〈 f j 〉 j∈klk
-
Q
y n j ¹ωº
-A
j∈klk A
A ,
where f j is the exponential transpose of
Q
y mi
× yn × yn j ∼
=
i∈kkk A
Q
y mi
× y (n + n j )
i∈kkk A
→
¹ΘÂΓ,−
y j ⊢t j ºA
- A .
Equational models. A model A ∈ Mod(Σ) satisfies an equation Θ Â Γ ⊢ s ≡ t, which we write as
A |= (Θ Â Γ ⊢ s ≡ t), if and only if ¹Θ Â Γ ⊢ sºA = ¹Θ Â Γ ⊢ tºA in SetF .
For a second-order equational presentation E = (Σ, E), the category Mod(E ) of E -models is the full
subcategory of Mod(Σ) consisting of the Σ-models that satisfy the axioms E.
Example 4.8. For the signature Σλ of the mono-sorted λ-calculus (Example 4.1), a model
y1
ν
- A
¹absºA : Ay1 → A ,
ς
A• A
¹appºA : A × A → A
of Mod(Σλ ) satisfies the (β) and (η) axioms of Eλ (Example 4.7) if and only if the diagrams
Ay1 × A
¹absºA×idA
?
A× A
l
A
l
ς1
¹appºA
- A
¹appºA◦(idA ×ν)
id
A
?
Ay1
commute, where (g) denotes the unique exponential mate of g.
62
¹absºA
- A
4.3. Second-Order Universal Algebra
Theorem 4.9 (Second-Order Soundness and Completeness). For a second-order equational presentation E = (Σ, E), the judgement Θ Â Γ ⊢ s ≡ t is derivable from E if and only if A |= (Θ Â Γ ⊢ s ≡ t)
for all E -models A.
4.3.4 Conservativity
At the level of equational derivability, the extension of (first-order) universal algebra to the secondorder framework, as presented in this chapter, is conservative.
Clearly, every first-order signature is a second-order signature in which all operators do not bind any
variables in their arguments. Any first-order term Γ ⊢ t can therefore be represented as the secondorder term − Â Γ ⊢ t. Indeed, for a set of first-order equations, if the equation Γ ⊢ s ≡ t is derivable
in first-order equational logic, then its corresponding second-order representative − Â Γ ⊢ s ≡ t is
derivable in second-order equational logic.
The converse statement is what is known as conservativity of second-order equational derivability.
Although this result is not directly utilised in this dissertation, we recall it for the benefit of comprehensiveness, and refer the reader to [Fiore and Hur, 2010] for the proof.
Theorem 4.10 (Conservativity). Second-Order Equational Logic (Figure 4.1) is a conservative extension of First-Order Equational Logic. More precisely, if a second-order equation between first-order terms
− Â Γ ⊢ s ≡ t lying in an empty metavariable context is derivable in second-order equational logic,
then Γ ⊢ s ≡ t is derivable in first-order equational logic.
63
CHAPTER 4. SECOND-ORDER SYNTAX AND SEMANTICS
4.A Appendix to Chapter 4: Multi-Sorted Second-Order Syntax
We present the multi-sorted generalisation of the mono-sorted second-order syntactic theory underlying second-order equational logic.
Signatures. A multi-sorted second-order signature Σ = (S, Ω, | − |) is specified by a set of sorts S, a
set of operators Ω, and an arity function | − |: Ω → (S ∗ × S)∗ × S.
→
→
Notation. We let |−
σ | be the length of the sequence of sorts −
σ = σ1 , . . . , σ|−→
σ |.
→)τ , . . . , (−
→)τ → τ whenever |ω| = (−
→)τ , . . . , (−
→)τ , τ.
For ω ∈ Ω, we typically write ω: (−
σ
σ
σ
σ
1 1
n
n
1 1
n
n
Similar to the mono-sorted universe, the intended meaning here is that ω is an operator of sort τ
→| variables of sorts σ , . . . , σ
taking n arguments, each of which binds ni = |−
σ
i
i,1
i,ni in a term of sort
τi .
Example 4.11.
1. Sorted λ-calculus. The signature of the multi-sorted λ-calculus over a set of base sorts B has set
of sorts Bλ given by
β∈B
σ, τ ∈ Bλ
β ∈ Bλ
σ ⇒ τ ∈ Bλ
.
Given sorts σ, τ ∈ Bλ , the operators of the sorted λ-calculus are given by absσ,τ : (σ)τ → σ ⇒ τ
and appσ,τ : σ ⇒ τ, σ → τ.
2. Predicate logic. The signature Π = (P, Ω P , | − | P ) of predicate logic consists of the set P =
{Prop, ⋆}, which has two sorts, and has operators in Ω P equipped with the arity function
| − | P : (P ∗ × P)∗ × P. One may have simple predicate operators P : ⋆, . . . , ⋆ → Prop, which
essentially allow the formation of atomic predicate propositions. The signature Π furthermore
comes equipped with the following predicate logic operators (note the binding operators of universal and existential quantification):
(Equality)
(Falsum)
64
= : (⋆, ⋆) → Prop
⊥ : (Prop) → Prop
(Truth)
T : Prop → Prop
(Negation)
∼ : Prop → Prop
(Conjunction)
∧ : Prop, Prop → Prop
(Disjunction)
∨ : Prop, Prop → Prop
(Implication)
⊃ : Prop, Prop → Prop
(Universal Q)
∀ : (⋆) Prop → Prop
(Existential Q)
∃ : (⋆) Prop → Prop
4.A. Appendix to Chapter 4: Multi-Sorted Second-Order Syntax
Contexts. The typing contexts have two sorted zones, and they are represented as
M1 :
→]τ , . . . , M : [−
→]τ Â x : σ′ , . . . , x : σ′
[−
σ
σ
1
1
k
k
k
1
n
1
n
,
where all variables and metavariables are assumed to be distinct. Metavariable typings are parameterised sorts: a metavariable of sort [σ1 , . . . , σn ]τ, when parameterised by terms of sort σ1 , . . . , σn ,
will yield a term of sort τ.
Terms. The judgement for terms in context Θ Â Γ ⊢ t : τ is defined by the rules below. As is usual in
the second-order setting, terms are considered up to α-equivalence, but we shall not formalise this
here.
ΘÂΓ⊢ x: τ
Θ Â Γ ⊢ t i : τi
(x : τ) ∈ Γ
(1 ≤ i ≤ n)
Θ Â Γ ⊢ M[t 1 , . . . t n ]: τ
→
→ ⊢ t : τ (1 ≤ i ≤ n)
Θ Â Γ, −
xi : −
σ
i
i
i
−
→
Θ Â Γ ⊢ ω ( x )t , . . . , (−
x→)t : τ
1
1
n
n
→
→
where −
x :−
σ stands for x 1 : σ1 , . . . , x k : σk .
(M : [τ1 , . . . , τ n ]τ) ∈ Θ
→)τ , . . . , (−
→)τ → τ
ω: (−
σ
σ
1 1
n
n
Example 4.12.
1. Sorted λ-calculus. Two sample terms for the signature of the multi-sorted λ-calculus follow:
M:
M:
[σ]τ, N : σ Â − ⊢ app abs (x)M[x] , N [] : τ,
[σ]τ, N : σ Â − ⊢ M [N[]]: τ.
2. Predicate logic. Two sample terms for the signature Π of predicate logic are:
Θ Â x : ⋆, y : ⋆ ⊢ = (x, y): Prop
M : [⋆]Prop  − ⊢ ∃ (x) M [x] : Prop
Equational presentations. A multi-sorted second-order equational presentation E = (Σ, E) is given
by a multi-sorted signature Σ together with a set E of axioms, each of which is a pair of terms in
context.
Remark 4.13. The complete syntactic theory for multi-sorted second-order languages involves definitions of substitution and metasubstitution, multi-sorted second-order equational logic, and lemmas
stating the well-typedness in this framework. These notions are, however, immediately generalisable from the mono-sorted setting of this chapter, and using the multi-sorted framework introduced
in this appendix. For a more proper account, we refer the reader to [Fiore and Hur, 2010].
65
CHAPTER 4. SECOND-ORDER SYNTAX AND SEMANTICS
4.B Appendix to Chapter 4: Proofs of Substitution and Metasubstitution Lemmas
4.B1 Second-Order Substitution Lemma
Given terms
Θ Â Γ ⊢ si
(1 ≤ i ≤ n),
Θ Â Γ ⊢ rj
(1 ≤ j ≤ k),
and
Θ Â x 1 , . . . , x n , y1 , . . . , yk ⊢ t,
we have
o
n
Θ Â Γ ⊢ t x i := si i∈knk y j := r j j∈kkk = t x i := si y j := r j j∈kkk
Proof. We proceed by induction on the structure of the term t:
ΘÂΓ
⊢
=
=
ΘÂΓ
⊢
=
=
=
ΘÂΓ
⊢
=
=
=
66
x h x i := si i∈knk y j := r j j∈kkk
sh y j := r j j∈kkk
o
n
x h x i := si y j := r j j∈kkk
i∈knk
, . . . ] x i := si i∈knk y j := r j j∈kkk
′
M . . . , t x i := si i∈knk y j := r j j∈kkk , . . .
o
n
′
,...
M . . . , t x i := si y j := r j j∈kkk
i∈knk
o
n
′
M [. . . , t , . . . ] x i := si y j := r j j∈kkk
M [. . . , t
′
i∈knk
→
ω(. . . , (−
z )t ′ , . . . ) x i := si i∈knk y j := r j j∈kkk
→
ω . . . , (−
z )t ′ x i := si i∈knk y j := r j j∈kkk , . . .
o
n
→
,...
ω . . . , (−
z )t ′ x i := si y j := r j j∈kkk
i∈knk
o
n
−
→
′
ω(. . . , ( z )t , . . . ) x i := si y j := r j j∈kkk
i∈knk
i∈knk
.
4.B. Appendix to Chapter 4: Proofs of Substitution and Metasubstitution Lemmas
4.B2 Substitution-Metasubstitution Lemma
Given terms
M1 :
[m1 ], . . . , M k : [mk ] Â Γ ⊢ t i
and
M1 :
(1 ≤ i ≤ n),
→
Θ Â Γ, −
y j ⊢ sj
(1 ≤ j ≤ k),
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ t,
we have
ΘÂΓ
⊢
=
→
y j )s j j∈kkk
t x i := t i i∈knk M j := (−
o
n
→
→
y j )s j j∈kkk
t M j := (−
y j )s j j∈kkk x i := t i M j := (−
i∈knk
.
Proof. By induction on term structure:
ΘÂΓ
⊢
=
=
ΘÂΓ
⊢
=
=
=
=
=
ΘÂΓ
⊢
=
=
=
→
y j )s j j∈kkk
x l x i := t i i∈knk M j := (−
→
y j )s j j∈kkk
t l M j := (−
o
n
→
→
y j )s j j∈kkk
y j )s j j∈kkk x i := t i M j := (−
x l M j := (−
i∈knk
→
y j )s j j∈kkk
] x i := t i i∈knk M j := (−
h
′
−
→
′ M h t 1 x i := t i i∈knk , . . . , t m x i := t i i∈knk
M j := ( y j )s j j∈kkk
h
o
n
(h)
→
y j )s j j∈kkk ′
sh x i ′ := t ′i ′ x i := t i i∈knk M j := (−
i ∈kmh k
o
n
(h)
→
−
→
′
y j )s j j∈kkk i∈knk ′
sh x i ′ := t i ′ M j := ( y j )s j j∈kkk x i := t i M j := (−
i ∈kmh k
o
o
n
n
(h)
−
→
−
→
x i := t i M j := ( y j )s j j∈kkk
sh x i ′ := t ′i ′ M j := ( y j )s j j∈kkk ′
i∈knk
i ∈kmh k
o
n
−
→
−
→
′
′
M h [t 1 , . . . , t m ] M j := ( y j )s j j∈kkk x i := t i M j := ( y j )s j j∈kkk
h
′
′
M h [t 1 , . . . , t m
i∈knk
→
→
y j )s j j∈kkk
ω(. . . , (−
z )t ′ , . . . ) x i := t i i∈knk M j := (−
→
→
y j )s j j∈kkk , . . .
ω . . . , (−
z )t ′ x i := t i i∈knk M j := (−
o
n
→
→
→
,...
y j )s j j∈kkk
ω . . . , (−
z )t ′ M j := (−
y j )s j j∈kkk x i := t i M j := (−
i∈knk
o
n
−
→
−
→
−
→
′
ω(. . . , ( z )t , . . . ) M j := ( y j )s j j∈kkk x i := t i M j := ( y j )s j j∈kkk
i∈knk
67
CHAPTER 4. SECOND-ORDER SYNTAX AND SEMANTICS
4.B3 Metasubstitution Lemma I
Given terms
→
Θ Â Γ, −
x i ⊢ ri
and
(1 ≤ i ≤ k),
→
Θ Â Γ, −
y j ⊢ sj
(1 ≤ j ≤ l),
M1 :
[m1 ], . . . , M k : [mk ], N 1 : [n1 ], . . . , N l : [nl ] Â Γ ⊢ t,
→
:= (−
x i )ri
we have
ΘÂΓ
⊢
=
t
t
Mi
Nj
→
:= (−
y j )s j
i∈kkk N j
n
j∈klk M i
→
:= (−
y j )s j
→
:= (−
x i )ri
j∈klk
Nj
→
:= (−
y j )s j
o
j∈klk i∈kkk
.
Proof. By induction on the structure of t. The result is obvious for variable terms x. Furthermore,
in the final induction step, the proof for terms involving operators follows immediately, similar to
the proof of the Second-Order Substitution Lemma (Section 4.B1). We shall hence skip over this last
step as well.
ΘÂΓ
⊢
=
=
=
=
→
→
y j )s j j∈klk
:= (−
x i )ri i∈kkk N j := (−
(h)
→
→
y j )s j j∈klk
x i )ri i∈kkk i ′ ∈kmh k N j := (−
rh x i ′ := t i ′ M i := (−
o
n
(h)
→
→
→
y j )s j j∈klk ′
x i )ri i∈kkk N j := (−
y j )s j j∈klk x i ′ := t i ′ M i := (−
rh N j := (−
i ∈kmh k
o
n
(h)
−
→
−
→
−
→
N j := ( y j )s j j∈klk x ′ := t i ′ M i := ( x i )r i N j := ( y j )s j j∈klk i∈kkk
i
i ′ ∈kmh k
o
n
−
→
−
→
−
→
M h [t 1 , . . . , t m ] N j := ( y j )s j j∈klk M i := ( x i )r i N j := ( y j )s j j∈klk
h
M h [t 1 , . . . , t m
]
h
Mi
i∈kkk
4.B4 Metasubstitution Lemma II
Given terms
M1 :
[m1 ], . . . , M k : [mk ] Â Γ ⊢ t
and
M1 :
(i)
(i)
(i)
(i)
[m1 ], . . . , M k : [mk ] Â Γ, x 1 , . . . , x m
⊢ M i [x 1 , . . . , x m
]
i
i
for 1 ≤ i ≤ k, we have
M1 :
68
[m1 ], . . . , M k : [mk ] Â Γ ⊢ t
Mi
→
(i)
]
:= (−
x i )M i [x 1 , . . . , x m
i
(i)
i∈k
=t
.
4.B. Appendix to Chapter 4: Proofs of Substitution and Metasubstitution Lemmas
Proof. We again proceed by induction on term structure, skipping the first and final step:
ΘÂΓ
⊢
=
=
=
(i)
→
(i)
:= (−
x i )M i [x 1 , . . . , x m
] i∈k
i
(i)
(h)
−
→
(i) (h) (h)
M h [x 1 , . . . , x m ] x j := t j M i := ( x i ) M i [x 1 , . . . , x m ] i∈k j∈km k
h
i
h
(h)
(h) (h)
M h [x 1 , . . . , x m ] x j := t j j∈km k
h
h
M h [t 1 , . . . , t m
h
M h [t 1 , . . . , t m
]
h
Mi
]
69
CHAPTER 4. SECOND-ORDER SYNTAX AND SEMANTICS
70
Chapter 5
SECOND -ORDER ALGEBRAIC THEORIES
We present the crux of this dissertation: a categorical-algebra viewpoint of languages with variable
binding and parameterised metavariables. The core of this development is the notion of second-order
algebraic theory, which is a presentation-independent account of second-order syntactic theory. This
generalises Lawvere’s fundamental work on algebraic theories [Lawvere, 2004] to the second-order
setting.
We begin by recalling the notion of exponentiability (Section 5.1), which will be a fundamental
property in our abstract development. The most elementary second-order algebraic theory, the
second-order theory of equality M, is defined explicitly in Section 5.2. Just as Lawvere theories arise
from the free cartesian category on one object, second-order algebraic theories are defined on top
of M, which we show to be the free cartesian category generated by an exponentiable object. More
scrutiny is devoted to this definition, as it plays a pivotal role in the definition of second-order algebraic theory (Section 5.3). At the syntactic level, the correctness of our definition is established
in Section 5.4 by showing a categorical equivalence between second-order equational presentations
and second-order algebraic theories (Theorem 5.8).
We restrict our treatment to the mono-sorted universe for two main reasons: to mirror Lawvere’s
categorical development of mono-sorted algebraic theories; and, more importantly, to remain in a
simplified framework, which we hope will ease the appreciation of the subtleties of our definitions.
However, just as the multi-sorted generalisation of Lawvere theories to include typing is obtained in
a straightforward manner via indexing over sets of types, the generalisation of our work to the multisorted setting is evident. We finally point out that, having omitted the monadic view of second-order
universal algebra, the important role played by the monadic perspective in our development will not
be considered here.
5.1 Exponentiable objects
Categorical exponential structures are recalled. Just as the cartesian structure characterises firstorder algebraic theories, exponentiability abstractly formalises essential second-order characteristics.
71
CHAPTER 5. SECOND-ORDER ALGEBRAIC THEORIES
Exponential objects. For C a cartesian category and A, B objects of C , an exponential object A ⇒ B
is a universal morphism from − × A: C → C to B. Explicitly, A ⇒ B comes equipped with a mor-
e : (A ⇒ B) × A → B such that for any object C of C and f : C × A → B, there is a unique
l( f ): C → A ⇒ B, the exponential mate of f , making e ◦ (l( f ) × A) = f .
phism
Exponential functors. A cartesian functor F : C → D is exponential if it preserves the exponential
structure in C . Formally, for any exponential A ⇒ B in C , FA ⇒ F B is an exponential object in D
and the exponential mate of
F(A ⇒ B) × FA ∼
= F((A ⇒ B) × A)
F
e- F B
is an isomorphism F(A ⇒ B) → FA ⇒ F B.
Exponentiable objects. Let C be a cartesian category. An object C ∈ C is exponentiable if for all
objects D ∈ C the exponential C ⇒ D exists in C . Given an exponentiable object C, the n-ary
cartesian product C n is obviously exponentiable for all n ∈ N.
5.2 The Second-Order Theory of Equality
In the notion of categorical algebraic theory, the elementary theory of equality plays a pivotal role,
as it represents the most fundamental such theory. We thus proceed to identify the second-order
algebraic theory of equality M. This we do first in syntactic terms, via an explicit description of its
categorical structure, and in abstract terms by establishing its universal property.
5.2.1 Definition
The syntactic viewpoint of second-order theories presented in Section 4.1 leads us to define the
category M with set of objects given by N∗ and morphisms (m1 , . . . , mk ) → (n1 , . . . , nl ) given by
tuples
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x ni ⊢ t i
i∈klk
of elementary terms under the empty second-order signature. The identity on (m1 , . . . , mk ) is given
by
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x mi ⊢ M i [x 1 , . . . , x mi ]
whilst the composition of
and
72
L1 :
M1 :
[l1 ], . . . , L i : [l i ] Â x 1 , . . . , x mp ⊢ s p
[m1 ], . . . , M j : [m j ] Â y1 , . . . , ynq ⊢ t q
p∈k jk :
i∈kkk
;
(l1 , . . . , l i ) → (m1 , . . . , m j )
q∈kkk :
(m1 , . . . , m j ) → (n1 , . . . , nk )
5.2. The Second-Order Theory of Equality
is given via metasubstitution by
L1 :
[l1 ], . . . , L i : [l i ] Â y1 , . . . , ynq ⊢ t q {M p := (x 1 , . . . , x mp )s p } p∈k jk
q∈kkk :
(l1 , . . . , l i ) → (n1 , . . . , nk )
The category M is well-defined, as the identity and associativity axioms hold because of intrinsic
properties given by the Metasubstitution Lemmas (Lemmas 4.4 - 4.6), as seen in the following.
Lemma 5.1. The definition of M above yields a well-defined category.
Proof. Because of the monoidal properties of metasubstitution given by Metasubstitution Lemma I
(Lemma 4.5) and Metasubstitution Lemma II (Lemma 4.6), the associativity and identity axioms
hold in M. Indeed, given morphisms
→
[l1 ], . . . , Lh : [lh ] Â −
x o ⊢ ro o∈kik
→
: [m ], . . . , M : [m ] Â −
y ⊢s
M1
L1 :
N1 :
1
i
i
p
p p∈k jk
→
[n1 ], . . . , N j : [n j ] Â −
z q ⊢ tq
q∈kgk
:
(l1 , . . . , lh ) → (m1 , . . . , mi )
:
(m1 , . . . , mi ) → (n1 , . . . , n j )
:
(n1 , . . . , n j ) → (k1 , . . . , k g )
,
we have, for all q ∈ kgk,
L1 :
→
[l1 ], . . . , L h : [lh ] Â −
zq
⊢
=
→
:= (−
x o )ro o∈kik
o
n
→
→
.
x o )ro o∈kik
t q N p := (−
y p )s p M o := (−
tq
Np
→
:= (−
y p )s p
p∈k jk
Mo
p∈k jk
Also, for a morphism
M1 :
→
[m1 ], . . . , M k : [mk ] Â −
y j ⊢ tj
j∈klk :
(m1 , . . . , mk ) → (n1 , . . . , nl )
and identities
→
→
[m1 ], . . . , M k : [mk ] Â −
x i ⊢ M i [−
x i ] i∈kkk
−
→
−
→ N : [n ], . . . , N : [n ] Â y ⊢ N [ y ]
M1 :
1
1
l
l
i
i
i
i∈klk
:
(m1 , . . . , mk ) → (m1 , . . . , mk )
:
(n1 , . . . , nl ) → (n1 , . . . , nl )
we have, for all j ∈ kkk,
M1 :
→
[m1 ], . . . , M k : [mk ] Â −
y j ⊢ tj
Mj
→
→
:= (−
x i )M i [−
x i ] j∈kkk = t j
,
and for all i ∈ klk,
M1 :
→
→
→
[m1 ], . . . , M k : [mk ] Â −
y i ⊢ N i [−
y i ] N j := (−
y j )t j j∈klk = t i yp( j) := yp( j) p∈kn j k = t i
.
5.2.2 Cartesian structure
The category M comes equipped with a strict cartesian structure, with the terminal object given
by the empty sequence (), the terminal map (m1 , . . . , mk ) → () being the empty tuple 〈〉, and the
73
.
CHAPTER 5. SECOND-ORDER ALGEBRAIC THEORIES
binary product of (m1 , . . . , mk ) and (n1 , . . . , nl ) given by their concatenation (m1 , . . . , mk , n1 , . . . , nl ).
Any object (m1 , . . . , mk ) is thus the cartesian product of the single tuples (mi ), for i ∈ kkk, with
projections
M1 :
(i)
(i)
(i)
(i)
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x m
⊢ M i [x 1 , . . . , x m
] : (m1 , . . . , mk ) → (mi )
i
i
.
Indeed, given morphisms
N1 :
(i)
(i)
[n1 ], . . . , N l : [nl ] Â x 1 , . . . , x m
⊢ qi : (n1 , . . . , nl ) → (mi )
i
for i ∈ kkk, the mediating morphism is
N1 :
(i)
(i)
⊢ qi
[n1 ], . . . , N l : [nl ] Â x 1 , . . . , x m
i
i∈kkk
.
Its uniqueness is evident, as for any
N1 :
( j)
( j)
[n1 ], . . . , N l : [nl ] Â x 1 , . . . , x m
⊢ tj
j
whose composition with the i-th projection is
N1 :
j∈kkk :
(n1 , . . . , nl ) → (m1 , . . . , mk )
(i)
(i)
[n1 ], . . . , N l : [nl ] Â x 1 , . . . , x m
⊢ qi , we have for
i
each i ∈ kkk
N1 :
( j)
( j)
(i)
(i)
( j)
( j)
]{M j := (x 1 , . . . , x m
)t j } j∈kkk = t i
[n1 ], . . . , N l : [nl ] Â x 1 , . . . , x m
⊢ M i [x 1 , . . . , x m
i
j
,
j
which is simply the i-th projection qi .
5.2.3 Exponential structure
In M, the object (0) is exponentiable. For any tuple (m1 , . . . , mk ), the exponential (0) ⇒ (m1 , . . . , mk )
is given by (m1 +1, . . . , mk +1), with evaluation map
e
−
→
m ,1 :
(m1 +1, . . . , mk +1)×(0) → (m1 , . . . , mk )
given by the k-tuple
M1 :
(i)
(i)
(i)
(i)
[m1 + 1], . . . , M k : [mk + 1], N : [0] Â x 1 , . . . , x m
⊢
M i x 1 , . . . , x m , N []
i∈kkk
i
i
.
l
For any (n1 , . . . , nl ), the exponential mate (〈t i 〉i∈kkk ) of a map
N1 :
(i)
(i)
[n1 ], . . . , N l : [nl ], M : [0] Â x 1 , . . . , x m
⊢ ti
is given by
i
N1 :
Clearly, the composite
i∈kkk :
(n1 , . . . , nl ) × (0) → (m1 , . . . , mk )
(i)
(i)
[n1 ], . . . , N l : [nl ] Â x 1 , . . . , x m
, yi ⊢ t i {M := yi } i∈kkk
(n1 , . . . , nl ) × (0)
74
i
l(〈t 〉
i i∈kkk )×(0)
- (m + 1, . . . , m + 1) × (0)
1
k
e−
→
m ,1
.
(m1 , . . . , mk )
5.2. The Second-Order Theory of Equality
equals
=
(i)
(i)
[n1 ], . . . , N l : [nl ], N : [0] Â x 1 , . . . , x m
⊢
i
(i)
( j)
(i)
( j)
M j := (x 1 , . . . , x m , y j )t j {N := y j } j∈kkk i∈kkk
M i x 1 , . . . , x m , N []
i
j
(i)
(i)
N 1 : [n1 ], . . . , N l : [n l ], N : [0] Â x 1 , . . . , x m ⊢ t i i∈kkk .
N1 :
i
Uniqueness of the exponential mate is just as clear. If
N1 :
(i)
(i)
[n1 ], . . . , N l : [nl ], N : [0] Â z1 , . . . , zm
, z ⊢ si
i
(n1 , . . . , nl ) → (m1 + 1, . . . , mk + 1)
i∈kkk :
is such that for i ∈ kkk
N1 :
(i)
( j)
(i)
(i)
( j)
(i)
, N [] {M j := (z1 , . . . , zm
, z)s j } j∈kkk = t i
⊢ Mi x1 , . . . , x m
[n1 ], . . . , N l : [nl ], N : [0] Â x 1 , . . . , x m
i
i
j
then
N1 :
(i)
(i)
[n1 ], . . . , N l : [nl ], N : [0] Â x 1 , . . . , x m
⊢ si = t i
i
for all i ∈ kkk.
We finally point out that more generally, for any n ∈ N, the exponential (0)n ⇒ (m1 , . . . , mk ) is given
by the tuple (m1 + n, . . . , mk + n).
5.2.4 Second-order features via exponentiability
The exponential structure in M embodies attributes intrinsic to second-order languages. First, note
that for each n ∈ N, the metaweakening operation Wn : M → M mapping (m1 , . . . , mk ) to (m1 +
n, . . . , mk + n), and a morphism (m1 , . . . , mk ) → (n1 , . . . , nl ) of the form
M1 :
( j)
[m1 ], . . . , M k : [mk ] Â y1 , . . . , yn( j)j ⊢ t j
j∈klk
to
D
M ’1 :
( j)
( j)
[m′1 + n], . . . , M’k : [m′k + n] Â y1 , . . . , yn( j) , z1 , . . . , zn( j) ⊢
j
n
o
(i)
(i)
(i) ( j)
(i)
, z1 , . . . , zn( j)
)M’i x 1 , . . . , x m
t j M i := (x 1 , . . . , x m
i
i
i∈kkk
E
j∈klk
is in fact the right adjoint (0)n ⇒ (−): M → M to the functor (−) × (0)n : M → M.
Moreover, for any (m1 , . . . , mk ), the resulting bijection
M (m1 , . . . , mk ), (0)n ⇒ (0) ∼
= M (m1 , . . . , mk ) × (0)n, (0)
formalises the correspondence between a second-order term and its parameterisation (Section 4.1.4).
75
,
CHAPTER 5. SECOND-ORDER ALGEBRAIC THEORIES
Indeed, every morphism of M of the form
M1 :
[m1 ], . . . , M k : [mk ], N1 : [0], . . . , N n : [0] Â − ⊢ t : (m1 , . . . , mk ) × (0)n → (0)
is (the single tuple of) the parameterisation of its unique exponential mate
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ t
Ni
:= x i
i∈knk
: (m1 , . . . , mk ) → (0)n ⇒ (0) .
Abstractly, every morphism 〈s〉: (m1 , . . . , mk ) → (n) can be parameterised as
n
exponential mate
n ◦ (〈s〉 × (0) ) is just 〈s〉.
le
e◦
n
〈s〉 × (0)n , whose
Finally, the exponential structure manifests itself in all second-order terms, which, when viewed as
morphisms of M, decompose via unique universal maps.
Lemma 5.2. In the category M, every morphism of the form
decomposes as
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ x i : (m1 , . . . , mk ) → (n)
(m1 , . . . , mk )
l(π
(n) ∼
◦=)
i
- ()
- (n)
l
,
where the unlabelled morphism is the unique terminal map, and (πi ◦ ∼
=) is the exponential mate of
(n)
(n)
πi
the i-th projection () × (0)n ∼
= (0)n −→ (0). Moreover, every morphism
M1 :
decomposes as
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ M i [t 1 , . . . , t mi ] : (m1 , . . . , mk ) → (n)
(m1 , . . . , mk )
D
πi ,t 1 ,...,t mi
E
- (m , nmi )
i
ςmi ,n
- (n)
,
where nmi denotes the sequence n, . . . , n of length mi , ςmi ,n is the exponential mate of
(mi , nmi ) × (0)n
and
e
mi ,n
(mi )×
emi ,n
(mi ) × (0)mi
emi
(0) ,
is the evaluation map associated with the exponential ((0)n ⇒ (0)mi ) = (n)mi .
(n)
Proof. Explicitly, (πi ◦ ∼
=): () × (0)n → (0) is given by N 1 : [0], . . . , N n : [0] Â − ⊢ N i [] and
its unique exponential mate is − Â x 1 , . . . , x n ⊢ N i [] N j := x j j∈knk , which is simply − Â
x 1 , . . . , x n ⊢ x i . Composing this with 〈〉: (m1 , . . . , mk ) → () yields M1 : [m1 ], . . . , M k : [mk ] Â
x 1 , . . . , x n ⊢ x i . Next, the morphism ςmi ,n : (mi , nmi ) → (n) is syntactically given by
76
Mi :
[mi ], N 1 : [0], . . . , N mi : [0] Â x 1 , . . . , x n ⊢ M i
N 1 [x 1 , . . . , x n ], . . . , N m
i
[x 1 , . . . , x n ]
,
5.2. The Second-Order Theory of Equality
and thus composed with 〈πi , t 1 , . . . , t mi 〉
D
Mi :
[mi ], N 1 : [0], . . . , N mi : [0] Â x 1 , . . . , x n
this equals
⊢
Mi :
M i N 1 [x 1 , . . . , x n ], . . . , N m [x 1 , . . . , x n ]
i
Mi
Nj
:= ( y1 , . . . , ymi )M i [ y1 , . . . , ymi ]
E
,
:= (x 1 , . . . , x n )t j j∈kmi k
[mi ], N 1 : [0], . . . , N mi : [0] Â x 1 , . . . , x n ⊢ M i [t 1 , . . . , t mi ]
.
5.2.5 Universal property
The exponential structure in M provides a universal semantic characterisation of M. Loosely speaking, M is the free strict cartesian category on an exponentiable object. We point out the analogy
to the first-order theory of equality L, which is the cartesian category freely generated by a single
object.
Proposition 5.3 (Universal property of M). The category M, together with the exponentiable object
(0) ∈ M, is initial amongst cartesian categories equipped with an exponentiable object and with respect
to cartesian functors that preserve the exponentiable object.
Proof. Let D be a cartesian category equipped with an exponentiable object D. There is a functor
I : M → D mapping the tuple (m1 , . . . , mk ) to (D m1 ⇒ D) × · · · × (D mk ⇒ D), and defined on
morphisms of M by structural induction as follows:
77
CHAPTER 5. SECOND-ORDER ALGEBRAIC THEORIES
•
•
(D m1
M1 :
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ x i : (m1 , . . . , mk ) → (n)
(D m1 ⇒ D) × · · · × (D mk ⇒ D)
!D
- 1
l(π
I
7−→
D ∼
i ◦=)
- (D n ⇒ D)
I
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ M i [t 1 , . . . , t mi ] : (m1 , . . . , mk ) → (n)
7−→
D
ςD
πi ,I 〈t 1 〉,...,I 〈t mi 〉
mi ,n
mk
⇒ D) × · · · × (D ⇒ D)
(D mi ⇒ D) × (D n ⇒ D)mi - (D n ⇒ D)
We superscript cartesian and exponential maps by D to distinguish them from those in M. Note that
I is cartesian by definition and moreover exponential. To see this, note that
I (0) ⇒ (m)
= I(m + 1) = D m+1 ⇒ D ∼
= D ⇒ (D m ⇒ D) = I(0) ⇒ I(m)
and that the exponential mate of I(
e
1,m ):
,
(D m+1 ⇒ D) × D → (D m ⇒ D) in D is the isomorphism
(D m+1 ⇒ D) ∼
= D ⇒ (D m ⇒ D)
.
To see that I is indeed the unique (up to isomorphism) universal functor associated with the initiality
of M, suppose that we are given a functor F : M → D which is cartesian and exponential mapping
(0) to D. Then F is isomorphic to I. This is evident on objects, as we have
F(m1 , . . . , mk ) = F (m1 ) × · · · × (mk )
∼
= F(m1 ) × · · · × F(mk )
= F (0)m1 ⇒ (0) × · · · × F (0)mk ⇒ (0)
∼
F(0)m1 ⇒ F(0) × · · · × F(0)mk ⇒ F(0)
=
= (D m1 ⇒ D) × · · · × (D mk ⇒ D)
= I(m1 , . . . , mk )
.
Given a morphism 〈t〉: (m1 , . . . , mk ) → (n) of M, the fact that I〈t〉 = F〈t〉 is an immediate consequence of the cartesian and exponential property of F and I. More precisely, by induction on the
structure of the term t, we have:
• The map
M1 :
l
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ x i : (m1 , . . . , mk ) → (n)
∼ M
decomposes as (πM
i ◦ =)◦! , and since F preserves the cartesian and exponential structure,
F (πM ◦ ∼
=)◦!M = (πD ◦ ∼
=)◦!D , which is exactly the image under I.
l
78
i
l
i
5.3. Second-Order Algebraic Theories
• Similarly,
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ M i [t 1 , . . . , t mi ] : (m1 , . . . , mk ) → (n) decom-
poses via universal cartesian and exponential morphisms of M, which are preserved by both I
and F, and thus their image under them must be equal.
5.3 Second-Order Algebraic Theories
We extend Lawvere’s fundamental notion of algebraic theory [Lawvere, 2004] to the second-order
universe. Second-order algebraic theories are defined as second-order-structure preserving functors
from the category M to cartesian categories.
Definition 5.4 (Second-order algebraic theories). A second-order algebraic theory consists of a small
cartesian category M and a strict cartesian identity-on-objects functor M : M → M that preserves
the exponentiable object (0).
The most basic example of a second-order algebraic theory is the second-order algebraic theory of
equality given by the category M together with the identity functor. In fact, we formally verify in
Section 5.4 that this is the (second-order) algebraic theory corresponding to a second-order presentation with no operators. This is analogous to the theory of sets corresponding to L in the first-order
setting.
Every second-order algebraic theory has an underlying first-order algebraic theory. To formalise
this, recall that the first-order algebraic theory of equality L is the free strict cartesian category
on an object and consider the unique cartesian functor L → M mapping the generating object to
the generating exponentiable object (0). Then, the first-order algebraic theory underlying a given
second-order algebraic theory M → M is given by L → LM , where L → LM ,→ M is the identityon-objects, full-and-faithful factorisation of L → M → M . In particular, the first-order algebraic
theory of equality I dL : L → L underlies the second-order algebraic theory of equality I dM : M → M.
Second-order algebraic translations. To complete the definition of second-order algebraic theories
from a Lawvere point of view, one requires a notion of morphism between them. To this end, we
define, for second-order algebraic theories M : M → M and M ′ : M → M ′ , a second-order algebraic
translation to be a cartesian functor F : M → M ′ such that
M
M
-
F
′
M
M
- M′
.
The category of second-order algebraic theories. We denote by SOAT the category of secondorder algebraic theories and second-order algebraic translations, with the evident identity and composition.
79
CHAPTER 5. SECOND-ORDER ALGEBRAIC THEORIES
5.4 Second-Order Theory/Presentation Correspondence
We illustrate how to construct second-order algebraic theories from second-order equational presentations, and vice versa, and prove that these constructions are mutually inverse. Only one direction
of this correspondence is shown here, namely the passage from an algebraic theory to a presentation
and back to an algebraic theory. The theory of second-order syntactic translations is required for the
other direction, and this proof is thus postponed to the following chapter.
5.4.1 The theory of a presentation
Classifying categories of second-order equational presentations. For a second-order equational
presentation E = (Σ, E), the classifying category M(E ) has a set of objects N∗ and morphisms
(m1 , . . . , mk ) → (n1 , . . . , nl ) given by tuples
M1 :
(i)
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n(i) ⊢ t i
i
E i∈klk
of equivalence classes of terms generated from Σ under the equivalence relation identifying two
terms if and only if they are provably equal in E from Second-Order Equational Logic (Figure 4.1).
Identities and composition are defined on representatives as in M. Indeed, composition via metasubstitution respects the equivalence relation, as for
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢E t 1 ≡ t 2
and
N:
[n] ⊢ y1 , . . . , yl ⊢E s1 ≡ s2
the equality
M1 :
[m1 ], . . . , M k : [mk ] Â y1 , . . . , yl ⊢E s1 {N := (x 1 , . . . , x n )t 1 } ≡ s2 {N := (x 1 , . . . , x n )t 2 }
is derivable from Second-Order Equational Logic. The categorical associativity and identity axioms
making M(E ) a well-defined category then follow immediately, as do the facts that M(E ) comes
equipped with the same cartesian structure as in M and that (0) is exponentiable in M(E ).
Revisiting the definition of the category M from the viewpoint of classifying categories, observe that
it classifies the most elementary second-order presentation E0 , which has an empty set of operators
and no equations. Indeed, M(E0 ) has morphisms tuples of terms (as the equivalence relation E0
singles out every term), and since all terms are elementary, M = M(E0 ).
Classifying categories of second-order algebraic presentations are the main component when defining theories of presentations.
80
5.4. Second-Order Theory/Presentation Correspondence
Lemma 5.5. For a second-order equational presentation E , the category M(E ) together with the canonical functor ME : M → M(E ) is a second-order algebraic theory.
Proof. The functor ME is the identity on objects and maps a tuple of terms 〈t 1 , . . . , t n 〉 to the tuple
of their equivalence classes [t 1 ]E , . . . , [t n ]E . It preserves the cartesian and exponential structures
of M as we have shown that they are, together with metasubstitution, respected by the equivalence
relation ∼E .
We refer to ME : M → M(E ) as the second-order algebraic theory of E .
Remark 5.6. Consider a second-order signature Σ and its induced second-order algebraic theory
MΣ : M → M(Σ). This construction is justified by considering a signature as just an equational
presentation with an empty set of equations. Because of its universal property and the fact that
every morphism of M decomposes as universal cartesian and exponential morphisms, it is clear
that, since MΣ : M → M(Σ) preserves the cartesian and exponential structure of M, the algebraic
theory MΣ is in this case simply an inclusion functor.
5.4.2 The presentation of a theory
The internal language E(M ) of a second-order algebraic theory M : M → M is the second-order
equational presentation defined as follows:
(Operators) For every f : (m1 , . . . , mk ) → (n) in M , we have an operator ω f of arity (m1 , . . . , mk , 0n ),
where 0n stands for the appearance of 0 n-times.
(Equations) Setting
(1)
(k)
(1)
(k)
(1) (k) (1)
(k)
)M1 x 1 , . . . , x m
, . . . , (x 1 , . . . , x m
)M k x 1 , . . . , x m
, x1, . . . , x n
t f = ω f (x 1 , . . . , x m
1
1
k
k
for every morphism f : (m1 , . . . , mk ) → (n) in M , we let E(M ) have equations
(E 1)
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ s ≡ t M 〈s〉
for every 〈s〉: (m1 , . . . , mk ) → (n) in M, and
(E 2)
M1 :
(i)
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ th ≡ t g {M i := (x 1 , . . . , x n(i) )t f i }i∈klk
i
for every
h
:
(m1 , . . . , mk ) → (n)
g
:
(n1 , . . . , nl ) → (n)
fi
:
(m1 , . . . , mk ) → (ni )
,
1≤i≤l
such that h = g ◦ 〈 f1 , . . . , f l 〉 in M .
We write Σ(M ) and E(M ) for these operators and equations, respectively.
81
CHAPTER 5. SECOND-ORDER ALGEBRAIC THEORIES
Remark 5.7. This procedure of synthesising internal languages from second-order algebraic theories
yields some redundancies in the resulting set of operators. For instance, the operator ω f : (m1 , . . . , mk , 0n )
induced by the morphism f : (m1 , . . . , mk ) → (n) of M is essentially the same as the operator with
the same arity induced by the morphism n ◦ f × (0)n : (m1 , . . . , mk , 0n ) → (0). By essentially the
e
same we mean that the following is derivable from (E 1) and (E 2):
M1 :
e◦
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ t f ≡ t
n
f ×(0)n
.
5.4.3 Towards second-order syntactic categorical type theory correspondence
Having presented the transformation between second-order algebraic theories and equational presentations, we proceed to prove the first part of the mutual invertibility of these constructions.
Theorem 5.8 (Theory/presentation correspondence). Every second-order algebraic theory M : M →
M is isomorphic to the second-order algebraic theory ME(M ) : M → M(E(M )) of its associated secondorder equational presentation.
Proof. We prove the correspondence via an explicit description of the isomorphism and its inverse.
Define the identity-on-objects functor
µ M : M → M(E(M ))
by mapping f : (m1 , . . . , mk ) → (n) of M to
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ t f E(M ) : (m1 , . . . , mk ) → (n) .
Functoriality of µ M is implied by the equational theory of E(M ). More precisely, the identity
M
id(m
1 ,...,mk )
on (m1 , . . . , mk ) in M is mapped to the k-tuple of equivalence classes of
M1 :
(i)
(i)
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x m
i
⊢
tπ(M )
=
t M (π(M) )
=
t M 〈M [x (i) ,...,x (i) ]〉
i
i
i
E1
≡
(−)
for 1 ≤ i ≤ k and πi
mi
1
(i)
(i)
M i [x 1 , . . . , x m ]
i
,
: (m1 , . . . , mk ) → (mi ) the canonical projection in −, which makes the above
tuple indeed the identity in M(E(M )). Similarly, preservation of composition is a consequence
of (E 2) of E(M ). Consider, without loss of generality, the morphisms 〈 f1 , . . . , f l 〉: (m1 , . . . , mk ) →
(n1 , . . . , nl ) and g : (n1 , . . . , nl ) → (n) of M . Then µ M (g)◦µ M (〈 f1 , . . . , f l 〉) is given by the equivalence
class of
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n
⊢
E2
≡
82
tg
Ni
→
:= (−
y i )t f i
t g◦〈 f1 ,...,nl 〉
,
i∈klk
5.4. Second-Order Theory/Presentation Correspondence
making µ M (g) ◦ µ M (〈 f1 , . . . , f l 〉) = µ M (g ◦ 〈 f1 , . . . , nl 〉).
This definition is strong enough to yield an algebraic translation from M : M → M to the classifying
algebraic theory ME(M ) : M → M(E(M )), since for any 〈t〉: (m1 , . . . , mk ) → (n) in M, the morphism
M 〈t〉: (m1 , . . . , mk ) → (n) in M is mapped under µ M to the equivalence class of
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ t M 〈t〉
,
which by (E 1) is provably equal to t, whose equivalence class is the image of t under ME(M ) .
In the other direction, define the identity-on-objects mapping
µ̄ M : M(E(M )) → M
by induction on the structure of representatives of equivalence classes [−]E(M ) as follows:
-
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ x i E(M ) is mapped to
(m1 , . . . , mk )
-
M1 :
!(M )
- ()
l(π
(M ) ∼
◦=)
i
- (n)
.
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ M i [t 1 , . . . , t mi ] E(M ) is mapped to
(m1 , . . . , mk )
(M )
πi
,µ̄ M ([t 1 ]
)
E(M ) ),...,µ̄M ([t mi ]E(M )-
(mi , nmi )
)
ς(M
m ,n
i
(n)
.
- For f : (n1 , . . . , nl ) → ( j) in M ,
M1 :
→
→
y 1 )t 1 , . . . , (−
y l )t l , s1 , . . . , s j
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ ω f (−
E(M )
is mapped under µ̄ M to the composite
(m1 , . . . , mk )
µ̄ M [t 1 ]
E(M ) ,...,µ̄M [t l ]E(M ) ,µ̄M [s1 ]E(M ) ,...,µ̄M [s j ]E(M)
(0)n ⇒
(n + n1 , . . . , n + nl , n j )
j
e ◦( f ×(0) )
j
?
(n)
Note that equivalence classes of elementary terms s are simply mapped to M 〈s〉 under µ̄ M .
We show that the mapping µ̄ M is: (i) well-defined, (ii) functorial, and (iii) an algebraic translation
M(E(M )) → M .
(i) To verify that µ̄ M is well-defined, we show that equal terms (that is representatives of equivalence classes [−]E(M ) ) according to axioms (E 1) and (E 2) of E(M ) are mapped under µ̄ M to
equal morphisms of M . Consider axiom (E 1), and let 〈s〉: (m1 , . . . , mk ) → (n) be a morphism
83
CHAPTER 5. SECOND-ORDER ALGEBRAIC THEORIES
of M. Then the image of t M 〈s〉 E(M ) under µ̄ M is the composite
(m1 , . . . , mk )
l(id
(m1 ,...,mk ,0n ) )
- (0)n ⇒ (m , . . . , m , 0n )
1
k
(0)n ⇒
)
e ◦(M 〈s〉×(0) (n)
n
n
,
which is simply M 〈s〉, and is in turn the image of 〈s〉 under µ̄ M as s is an elementary term. For
the axiom (E 2), let g : (n1 , . . . , nl ) → (n), h: (m1 , . . . , mk ) → (n), and f i : (m1 , . . . , mk ) → (ni )
(for 1 ≤ i ≤ l) be morphisms of M such that g ◦ 〈 f1 , . . . , f l 〉 = h. Then
→
x i )t f i i∈klk E(M )
t g M i := (−
(0)n ⇒ n ◦ g × (0)n
◦ (0)n ⇒
µ̄ M
=
=
=
=
n
(0) ⇒
e
e
e
e
n
n ◦ 〈 f1 , . . . , f l 〉 × (0)n
l
◦ (g ◦ 〈 f1 , . . . , f l 〉) × (0)
◦ (id(m1 ,...,mk ,0n ) )
◦ (id(m1 ,...,mk ,0n ) )
(0)n ⇒ n ◦ h × (0)n
.
µ̄ M th E(M )
n
l
l
◦ (id(m1 ,...,mk ,0n ) )
(ii) For the identity condition of functoriality, note that the identity in M(E(M )) is given by the
equivalence class of an elementary term, and by definition, a morphism f = 〈[t]E(M ) 〉 of
M(E(M )), for t an elementary term, is simply mapped to M (〈t〉) under µ̄ M . Therefore, for
any (m1 , . . . , mk ) in M(E(M )), and since M is a functor, we have that
M(E(M )) 1 ,...,mk )
µ̄ M id(m
M
= M id(m
1 ,...,mk )
M
= id(m
1 ,...,mk )
,
where the superscript in id C identifies the category C the identity is being taken in. Next,
for compositionality, note that, by its definition, µ̄ M commutes with metasubstitution. More
precisely, from the equational theory of E(M ), any morphism of M(E(M )) can be written as
[th ]E(M ) , for h = g ◦ f a morphism of M . By definition, this is mapped under µ̄ M to
µ̄ M [t g ]E(M ) ◦ µ̄ M [t f ]E(M )
(Recall point (i) above for more details.)
84
.
5.4. Second-Order Theory/Presentation Correspondence
(iii) The functor µ̄ M is an algebraic translation. This is an immediate consequence of the fact that
it maps a morphism 〈[s]E(M ) 〉, for s elementary, to M 〈s〉, therefore making
µ̄ M ME(M ) (〈s〉) = M 〈s〉
.
We finally proceed to show that the algebraic translations µ M and µ̄ M are mutually inverse. Trivially,
this is the case on their restrictions on objects. It remains to verify the same on morphisms.
Indeed, the image of a morphism f : (m1 , . . . , mk ) → (n) of M under µ̄ M ◦ µ M is given by
(m1 , . . . , mk )
which is equal to
le
n
l(id
(m1 ,...,mk ,0n ) )
- (0)n ⇒ (m , . . . , m , 0n )
1
k
e ◦( f ×(0) -)) (n)
(0)n ⇒(
n
n
◦ ( f × (0)n) , which is simply f .
In the other direction, we show, by induction on the structure of the term t, that for a morphism
〈[t]E(M ) 〉: (m1 , . . . , mk ) → (n) of M(E(M )),
(µ M ◦ µ̄ M )〈[t]E(M ) 〉 = 〈[t]E(M ) 〉 .
- For M1 : [m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ x i , (µ M ◦ µ̄ M )〈[x i ]E(M ) 〉 is given by the single tuple
of the equivalence class of the term
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ t M 〈x i 〉
,
which by axiom (E 1) of E(M ) is equal to x i .
] E(M ) : (m1 , . . . , mk ) → (n) under µ M ◦ µ̄ M is given, by induction on t 1 , . . . , t mi , by the single tuple containing the equivalence class of the term
- The image of
M1 :
M i [t 1 , . . . , t m
i
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n
⊢
→
M := (−
y i )t M 〈M i [−→
i
y i ]〉
−
→ N j := ( x )t j j∈km k
i
−
−
→
−
→
−
→ →
M i := ( y i ) M i [ y i ]
M i N 1 [ x ], . . . , N m [ x ]
i
−
→ N := ( x )t
t M M N
i
E1
≡
1[
−
→
→
x]
x ],..., N mi [−
j
=
M i [t 1 , . . . , t m
i
]
j j∈kmi k
.
- For f : (n1 , . . . , nl ) → ( j) in M , the image of
→
→
y1 )t 1 , . . . , (−
yl )t l , s1 , . . . , s j E(M ) : (m1 , . . . , mk ) → (n)
ω f (−
85
CHAPTER 5. SECOND-ORDER ALGEBRAIC THEORIES
under µ M ◦ µ̄ M is the single tuple containing the equivalence class of the term
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n
⊢
≡
→
:= (−
y p )t p p∈klk
j
′
−
→ N q := ( x )sq q∈k jk
t f zi := N′i [x 1 , . . . , x n ] i∈k jk
′
−
→ −
→
N := ( x )s
N := ( y )t
t(0)n ⇒
e ◦( f ×(0) )
j
p
=
ωf
zi
ωf
Np
p p∈klk
q q∈k jk
q
→
→
→
→
(−
y1 )N 1 [−
y1 ], . . . , (−
yl )N l [−
yl ], z1 , . . . , z j
:= N ′i [x 1 , . . . , x n ] i∈k jk
′
−
→ →
N := ( x )s
:= (−
y )t
Np
=
p
p
p p∈klk
q
→
→
(−
y1 )t 1 , . . . , (−
yl )t l , s1 , . . . , s j
q q∈k jk
.
Finally, we jump ahead and point out that we have in fact defined natural isomorphisms
µ(−) : I dSOAT → M(E(−))
and
µ̄(−) : M(E(−)) → I dSOAT
with components at a second-order algebraic theory M : M → M given respectively by the algebraic
translations µ M and µ̄ M defined in the proof above. We postpone the proof of this naturality to
the next chapter, where functoriality of M(−) and E(−) will be established by defining syntactic
translations of internal languages as the image of algebraic translations.
86
Chapter 6
SECOND -ORDER SYNTACTIC TRANSLATIONS
Algebraic theories come with an associated notion of algebraic translation, their morphisms. In
the second-order universe, the syntactic morphism counterpart has yet to be formalised. Abstractly,
comparison of equational presentations could be provided via the algebraic translation between the
corresponding classifying algebraic theories. However, as is often the case for the computer scientist,
an explicit transformation at the syntactic level may be preferable.
In this chapter, we distill a notion of second-order syntactic translation between second-order equational presentations that corresponds to the canonical notion of morphism between second-order
algebraic theories. These syntactic translations provide a mathematical formalisation of notions
such as encodings and transforms. The correctness of our definition is once again established by
showing a categorical equivalence between algebraic and syntactic translations. This completes the
Second-Order Syntactic Categorical Type Theory Correspondence, by which second-order algebraic theories and their algebraic translations correspond to second-order equational presentations and their
syntactic translations.
We start by defining syntactic translations of second-order signatures (Section 6.1) and second-order
equational presentations (Section 6.2). The explicit way of going from an algebraic to a syntactic
translation, and back, is demonstrated in Section 6.3. We conclude by showing that these transformations between algebraic and syntactic translations provide an equivalence (Section 6.4).
This work involves a high attention to detail to develop the underlying syntactic machinery. We
stress that the correctness of the notions introduced here can only be established and understood
via a magnified look at the rigorous, yet subtle, technicalities.
6.1 Second-Order Signature Translations
We introduce the canonical notion of morphism between second-order signatures via second-order
syntactic translations.
87
CHAPTER 6. SECOND-ORDER SYNTACTIC TRANSLATIONS
6.1.1 Signature translations
A syntactic translation τ: Σ → Σ′ between second-order signatures is given by a mapping from the
operators of Σ to the terms of Σ′ as follows:
ω: (m1 , . . . , mk )
7→
M1 :
[m1 ], . . . , M k : [mk ] Â − ⊢ τω
Note that the term associated to an operator has an empty variable context and that the metavariable context is determined by the arity of the operator.
6.1.2 Extended translation on terms
A second-order syntactic translation τ: Σ → Σ′ extends to a mapping from the terms of Σ to the
terms of Σ′
TΣ
ΘÂΓ⊢t
→
TΣ′
7→ Θ Â Γ ⊢ τ(t)
according to the following definition by induction on term structure:
- τ(x) = x
- τ
M [t 1 , . . . , t m ]
(1)
= M τ(t 1 ), . . . , τ(t m )
(k)
)t k
)t 1 , . . . (x 1 , . . . , x n(k)
- τ ω (x 1 , . . . , x n(1)
k
1
= τω
Mi
(i)
:= (x 1 , . . . , x n(i)i )τ(t i )
i∈kkk
We refer to this mapping as the translation extension or the induced translation of terms.
Substituting for variables in a term followed by syntactic translation of the resulting term amounts
to the same as term translation followed by substitution, and similarly for metasubstitution. This
subtlety is crucial when defining morphisms of signatures as syntactic translations.
Lemma 6.1 (Compositionality). The extension of a syntactic translation between second-order signatures commutes with substitution and metasubstitution.
Proof. See Appendix 6.A1 for a detailed syntactic proof.
To familiarise the reader with these syntactic definitions, we provide examples of second-order
signature translations.
Example 6.2.
(1) The simplest way to translate a second-order signature is to map it to itself. Every operator can
be mapped to the ‘simplest’ term induced by that operator. More formally, for Σ a second-order
signature, the mapping
ω: n1 , . . . , nl
88
7→
N1 :
→
→
→
→
[n1 ], . . . , N l : [nl ] Â − ⊢ ω (−
y 1 )N1 [−
y 1 ], . . . , (−
y n )N l [−
y l]
6.2. Second-Order Equational Translations
defines a second-order syntactic translation. We will later show that this defines the identity
syntactic translation.
(2) It is well-known that the basic mono-sorted λ-calculus may be used to model simple arithmetic
structures and operations. For instance, Church numerals are a way of formalising natural
numbers via the λ-calculus. The Church numeral n is roughly a function which takes a function
f as argument and returns the n-th composition of f . The encoding of basic operations on
natural numbers, such as addition and multiplication, via Church’s λ-calculus can be formalised
as a syntactic translation as follows:
add : (0, 0) 7→
M:
[0], N : [0] Â − ⊢ λ f x.M f (N f x)
mult : (0, 0) 7→
M:
[0], N : [0] Â − ⊢ λ f .M (N f )
(3) For a more concrete example, consider the Continuation Passing Style (CPS) transform [Plotkin, 1998].
A formalisation of the CPS transform for the λ-calculus can be given via a syntactic translation.
We provide it in informal notation for ease of readability.
app : (0, 0) 7→
: [0], N : [0] Â − ⊢ λk.M [] λm.m(λl.N []l)k
abs : (1) →
7
F : [1] Â − ⊢ λk.k λx.(λl.F [x]l)
M
6.2 Second-Order Equational Translations
6.2.1 Equational translations
A syntactic translation τ: E → E ′ between second-order equational presentations E = (Σ, E) and
E ′ = (Σ′ , E ′ ) is a signature translation which preserves the equational theory of E in the sense that
axioms are mapped to theorems. Formally, it is a syntactic translation τ: Σ → Σ′ such that, for every
axiom Θ Â Γ ⊢E s ≡ t in E, the judgement Θ Â Γ ⊢E ′ τ(s) ≡ τ(t) is derivable from E ′ .
The condition that only axioms are required to be mapped to theorems is strong enough to ensure
that all theorems of E are also mapped to theorems of E ′ , as shown by the next Lemma.
Lemma 6.3. The extension of a syntactic translation between second-order equational presentations
preserves second-order equational derivability.
Proof. One needs to only check the extended metasubstitution derivation rule of Second-Order
Equational Logic (Figure 4.1). Indeed, having
M1 :
[m1 ], . . . , M k : [mk ] Â Γ ⊢E ′ τ(s) ≡ τ(t)
(i)
(i)
and Θ Â Γ′ , x 1 , . . . , x m
⊢E ′ τ(si ) ≡ τ(t i )
i
(1 ≤ i ≤ k)
implies
Θ Â Γ, Γ′ ⊢E ′ τ(s)
Mi
(i)
(i)
:= (x 1 , . . . , x m
)τ(si )
i
i∈kkk
≡ τ(t)
Mi
(i)
(i)
:= (x 1 , . . . , x m
)τ(t i )
i
i∈kkk
89
CHAPTER 6. SECOND-ORDER SYNTACTIC TRANSLATIONS
by extended metasubstitution, which, by the Compositionality Lemma (Lemma 6.1), further gives
Θ Â Γ, Γ′ ⊢E ′ τ s
Mi
(i)
(i)
:= (x 1 , . . . , x m
)τ(si )
i
i∈kkk
≡τ t
Mi
(i)
(i)
:= (x 1 , . . . , x m
)τ(si )
i
i∈kkk
.
6.2.2 The category of second-order equational presentations
Syntactic translation composition. The composite of equational translations τ: E1 → E2 and
τ′ : E2 → E3 is the translation (τ′ ◦ τ): E1 → E3 defined by mapping an operator ω of E1 to the
term τ′ (τω ) of E3 . Its extension on a term t is simply τ′ (τ(t)), which can be verified by structural
induction.
- (τ′ ◦ τ)(x) = x = τ′ τ(x)
- (τ′ ◦ τ)
M [t 1 , . . . , t m ]
(i)
′
(τ ◦ τ)(t 1 ), . . . , (τ′ ◦ τ)(t m )
= M τ′ τ(t 1 ) , . . . , τ′ τ(t m )
= τ′ τ M [t 1 , . . . , t m ]
=
M
(i)
- (τ′ ◦ τ) ω . . . , (x 1 , . . . , x m
)t i , . . .
i
(i)
(i)
)(τ′ ◦ τ)(t i ) i∈kkk
= (τ′ ◦ τ)ω M i := (x 1 , . . . , x m
i
(i)
(i) ′
= τ′ (τω ) M i := (x 1 , . . . , x m
)τ τ(t i ) i∈kkk
i
(i)
(i)
)τ(t i ) i∈kkk
= τ′ τω M i := (x 1 , . . . , x m
i
(i)
′
(i)
= τ τ ω . . . , (x 1 , . . . , x m )t i , . . .
i
Because τ and τ′ preserve equational derivability, the equation Θ Â Γ ⊢ τ′ τ(s) ≡ τ′ τ(t) is a
theorem of E3 whenever Θ Â Γ ⊢ s ≡ t is an axiom of E1 , and thus, the composite (τ′ ◦ τ) is an
equational translation.
Furthermore, composition of equational translations is an associative operation:
(τ′′ ◦ τ′ ) ◦ τ (ω) = (τ′′ ◦ τ′ )(τω ) = τ′′ τ′ (τω ) = τ′′ (τ′ ◦ τ)(ω) =
τ′′ ◦ (τ′ ◦ τ) (ω)
,
where of course all composites above are assumed to be well-defined.
The syntactic identity translation. For a second-order equational presentations E , the syntactic
identity translation τE : E → E is defined by mapping an operator ω: (m1 , . . . , mk ) to the term
M1 :
(1)
(1)
(k)
(k)
(1)
(1)
(k)
(k)
[m1 ], . . . , M k : [mk ] Â − ⊢ ω (x 1 , . . . , x m
)M1 [x 1 , . . . , x m
], . . . , (x 1 , . . . , x m
)M1 [x 1 , . . . , x m
]
1
1
k
k
The extension of τE on terms is just the identity mapping, which is easily verified by structural
induction:
- τE (x) = x
90
.
6.3. Syntactic and Algebraic Translations
- τE (M[t 1 , . . . , t m ]) =
M [τ(t 1 ), . . . , τ(t m )]
=
M [t 1 , . . . , t m ]
→
→
x i )τE (t i ) i∈kkk
- τE ω . . . , (−
x i )t i , . . .
= τEω M i := (−
→
→
→
= ω . . . , (−
x )M [−
x ], . . . M := (−
x )t
i
i
i
→
= ω . . . , (−
x i )t i , . . .
i
i
i i∈kkk
This immediately implies that an axiom Θ Â Γ ⊢E s ≡ t is mapped to itself under τE , making it an
equational translation.
Note that τE is indeed the identity in the space of equational translations and their composition,
since for any τ: E1 → E2 and ω: (m1 , . . . , mk ) an operator of E1 , we have
τE2 τ(ω1 )
and
τ τE1 (ω)
=
=
=
=
=
τ(ω1 )
,
(i)
(i)
(i)
(i)
τ ω . . . , (x 1 , . . . , x m
)M i [x 1 , . . . , x m
], . . .
i
i
(i)
(i)
(i)
(i)
)τ
M i [x 1 , . . . , x m ] i∈kkk
τω M i := (x 1 , . . . , x m
i
i
(i)
(i)
(i)
(i) τω M i := (x 1 , . . . , x m )M i [x 1 , . . . , x m ] i∈kkk
i
τω
i
.
The category of second-order equational presentations. We denote by SOEP the category of
second-order equational presentations and second-order syntactic translations. The previous discussion surrounding composition and identity ascertains that this is a well-defined category.
6.3 Syntactic and Algebraic Translations
The notion of syntactic translation between second-order equational presentations introduced above
is justified by establishing its equivalence with that of algebraic translation between the associated
second-order algebraic theories. With this end in mind, we illustrate how to construct syntactic
translations from algebraic translations, and vice versa.
6.3.1 Induced algebraic translations
A syntactic translation τ: E → E ′ of second-order equational presentations E = (Σ, E) and E ′ =
(Σ′ , E ′ ) induces the algebraic translation
M(τ): M(E ) → M(E ′ )
mapping [t 1 ]E , . . . , [t l ]E to [τ(t 1 )]E ′ , . . . , [τ(t l )]E ′ . Note that the induced algebraic translation M(τ) is essentially specified by the extension of the syntactic translation τ on terms. This
definition respects equivalence since the extension of τ preserves equational derivability, and thus
Θ Â Γ ⊢E s ≡ t implies Θ Â Γ ⊢E ′ τ(s) ≡ τ(t). From the Compositionality Lemma (Lemma 6.1),
we know that extensions of syntactic translations commute with substitution and metasubstitution,
91
CHAPTER 6. SECOND-ORDER SYNTACTIC TRANSLATIONS
which easily yields functoriality of M(τ). Finally, we point out that, since translation extensions act
as the identity on elementary terms, the functor M(τ) commutes with the theories ME : M → M(E )
and ME ′ : M → M(E ′ ), making it indeed an algebraic translation.
This development gives a functor
M(−)
:
SOEP → SOAT
E
τ: E → E ′
7→ ME : M → M(E )
7→ M(τ): M(E ) → M(E ′ )
mapping an equational presentation to its classifying theory, and a syntactic translation to its induced
algebraic translation. Since the extension of the syntactic identity translation τE : E → E is the
identity on terms, it is mapped under M(−) to the identity algebraic translation M(τE ) mapping
. . . , [t]E , . . . to itself. Also, given syntactic translations τ: E1 → E2 and τ′ : E2 → E3 , we have
M(τ′ ◦ τ) [t]E1 = (τ′ ◦ τ)(t) E3 = τ′ τ(t) E3 = M(τ′ ) τ(t) E2 = M(τ′ ) ◦ M(τ) [t]E1
,
which establishes functoriality of M(−).
6.3.2 Induced syntactic translations
An algebraic translation F : M → M ′ between second-order algebraic theories M : M → M and
M ′ : M → M ′ induces the syntactic translation
E(F): E(M ) → E(M ′ ) ,
which, for a morphism f : (m1 , . . . , mk ) → (n) of M , maps the operator ω f of E(M ) to the term
M1 :
[m1 ], . . . , M k : [mk ], N 1 : [0], . . . , N n : [0] Â − ⊢ t F f x i := N i [] i∈knk
,
where we recall that
(1)
(k)
(1)
(k)
(1)
(1)
(k)
(k)
)
M 1 x 1 , . . . , x m , . . . , (x 1 , . . . , x m ) M k x 1 , . . . , x m , x 1 , . . . , x n
t F f = ω F f (x 1 , . . . , x m
1
1
k
k
.
We verify that E(F) is indeed an equational translation by looking at the induced translations on the
terms of the left- and right-hand side of the axioms of E(M ). Recall from Section 5.4.2 that these
axioms are given by (E 1) and (E 2). Consider (E 1), which states that for 〈s〉: (m1 , . . . , mk ) → (n)
of M, we have the equation
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ s ≡ t M 〈s〉 in E(M ). Since s is
elementary, its image under the translation E(F) is also given by M 〈s〉. On the other hand, note that
E( f )(t M 〈s〉 ) = t(F ◦M )〈s〉 = t M ′ 〈s〉 . From the axiom (E 1) of E(M ′ ), we have that s ≡ t M 〈s〉 , and therefore
M1 :
92
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ E(F)(s) ≡ E(F)(t M 〈s〉 )
6.4. Second-Order Syntactic categorical Type Theory Correspondence
in E(M ′ ). Similarly, for the axiom (E 2) of E(M ), and in the notation of Section 5.4.2, we have that
E(F)(th ) = t F h , and on the other hand:
→
x i )t f i i∈klk
E(F) t g M i := (−
→
x i )E(F) t f i i∈klk
= E(F) t g M i := (−
→
x i )t F f i i∈klk .
= t F g M i := (−
Hence, the image of axiom (E 2) of E(M ) under the translation E(F) is just axiom (E 2) of E(M ′ ).
This makes E(F) indeed an equational translation.
We have essentially defined the functor
E(−)
:
SOAT → SOEP
M: M→M
7→ E(M )
F : M → M ′ 7→ E(F): E(M ) → E(M ′ )
mapping a second-order algebraic theory to its internal language, and an algebraic translation to its
induced syntactic translation.
Some more simple syntactic manipulation is needed to show that E(−) is functorial. Given a morphism f : (m1 , . . . , mk ) → (n) in M , the translation E(idM ) maps the operator ω f of E(M ) to the
term
M1 :
[m1 ], . . . , M k : [mk ], N 1 : [], . . . , N n : [] Â − ⊢ t f x i := N i [] i∈knk
,
which is the image of ω f under the syntactic identity translation τE(M ) . Moreover, given algebraic
translations F : M1 → M2 and G : M2 → M3 and a morphism g : (n1 , . . . , n j ) → (l), the image of
ω g of E(M1 ) under the composite translation E(G) ◦ E(F) is given by the term
N1 :
[n1 ], . . . , N j : [n j ], L1 : [], . . . , L l : [] Â −
⊢
E(G) t F g x i := L i [] i∈klk
= E(G)(ω F g )
= t(G◦F )(g) x i := L i [] i∈klk
= E(G ◦ F)(ω g )
.
6.4 Second-Order Syntactic categorical Type Theory Correspondence
6.4.1 Second-order presentation/theory correspondence
Second-order syntactic translations embody the mathematical machinery that enables us to compare second-order equational presentations at the syntactic level without having to revert to their
categorical counterparts. In particular, the question of when two presentations are essentially the
same can now be answered via the notion of syntactic translation.
93
CHAPTER 6. SECOND-ORDER SYNTACTIC TRANSLATIONS
Analogous to the first-order setting (Definition 3.7), a second-order syntactic translation τ: E → E ′
is said to be an isomorphism, if it has an inverse τ̄ yielding the syntactic identity translation on E
(respectively E ′ ) when composed to the left (respectively right) with τ.
This is used to show the second direction of the invertibility of constructing theories from presentations, and vice versa. More precisely, we prove that every second-order equational presentation is
isomorphic to the second-order equational presentation of its associated algebraic theory.
Keeping this objective in mind, define, for a given second-order equational presentation E with
classifying algebraic theory ME : M → M(E ), the natural translation
νE : E → E(ME )
by mapping an operator ω: (m1 , . . . , mk ) of E to the term
M1 :
[m1 ], . . . , M k : [mk ] Â − ⊢ t
[τE ] ω E
,
where we remind the reader that τE (ω) is the image of ω under the identity translation τE , and
hence [τE (ω)]E : (m1 , . . . , mk ) → (0) is a morphism of M(E ).
The fact that the natural translation νE is an equational translation relies on the following special
property of its extension on terms.
Lemma 6.4. For any second-order equational presentation E , the extension of the natural translation
νE : E → E(ME ) on a term
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ s
of E is given by the term
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ t〈[s]E 〉
of E(ME ).
Proof. A detailed syntactic proof can be found in Appendix 6.A2.
Given an axiom
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ t ≡ t ′ of E then, the operators ω〈[t]E 〉 and
ω〈[t ′ ]E 〉 are obviously equal, which makes the terms t〈[t]E 〉 and t〈[t ′ ]E 〉 of E(ME ) syntactically equal.
This implies the equational derivability of
M1 :
94
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢E(ME ) t〈[t]E 〉 ≡ t〈[t ′ ]E 〉
,
6.4. Second-Order Syntactic categorical Type Theory Correspondence
which, together with Lemma 6.4, yields
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢E(ME ) νE (t) ≡ νE (t ′ )
,
making νE indeed an equational translation.
In the other direction, define the opposite natural translation
ν̄E : E(ME ) → E
by mapping, for a morphism 〈[t]E 〉: (m1 , . . . , mk ) → (n) of M(E ), the operator ω〈[t]E 〉 : (m1 , . . . , mk , 0n )
to
M1 :
[m1 ], . . . , M k : [mk ], N 1 : [0], . . . , N n : [0] Â − ⊢ t x i := N i [] i∈knk
.
We point out that this mapping is well-defined in the sense that it respects the equivalence with
respect to E , as from Second-Order Equational Logic we know that the operation of substitution in
extended metavariable context is a congruence.
To verify that, according to this definition, ν̄E is really an equational translation, one needs to show
that the two axioms (E 1) and (E 2) of E(ME ) are mapped under ν̄E to theorems of E . A similar
argument to the verification of the preservation of equations of an induced syntactic translation
(Section 6.3.2) can be used, and so we skip over the details here.
Theorem 6.5 (Second-order presentation/theory correspondence). Every second-order equational
presentation E is isomorphic to the second-order equational presentation E(ME ) of its associated algebraic theory ME : M → M(E ).
Proof. As anticipated, the isomorphism is witnessed by the natural translation νE : E → E(ME ) with
its inverse given by the opposite natural translation ν̄E : E(ME ). Indeed, an operator ω: (m1 , . . . , mk )
of E is mapped under the composite ν̄E ◦ νE to
M1 :
[m1 ], . . . , M k : [mk ] Â − ⊢ ν̄E ω〈[τE (ω)]E 〉
= τE (ω)
.
In the other direction, for a morphism 〈[s]E 〉: (m1 , . . . , mk ) → (n) of M(E ), the operator ω〈[s]E 〉 is
mapped under νE ◦ ν̄E to
M1 :
[m1 ], . . . , M k : [mk ], N 1 : [0], . . . , N n : [0] Â −
⊢
=
=
=
=
νE s x i := N i [] i∈knk
νE (s) x i := νE (N i []) i∈knk
νE (s) x i := N i [] i∈knk
t〈[s]E 〉 x i := N i [] i∈knk
τE(ME ) (ω
) .
〈[s]E 〉
95
CHAPTER 6. SECOND-ORDER SYNTACTIC TRANSLATIONS
6.4.2 Syntactic/algebraic translation correspondence
The constructions of induced algebraic and syntactic translations are shown to be mutually inverse,
thereby establishing them as the correct notions of morphisms of, respectively, algebraic theories and
equational presentations. This equivalence is one of the main results of this dissertation, namely the
Second-Order Syntactic Categorical Type Theory Correspondence.
Theorem 6.6 (Second-Order Syntactic Categorical Type Theory Correspondence). The categories
SOAT and SOEP are equivalent.
Proof. The equivalence is given by the functors
E(−): SOAT → SOEP
M(−): SOEP → SOAT
and
together with the natural transformation µ: IdSOAT → M(E(−)) with component at a second-order
algebraic theory M : M → M given by the isomorphism
µ M : M → M(E(M ))
defining the Theory/Presentation Correspondence of Theorem 5.8, and also the natural transformation ν : IdSOEP → E(M(−)) with component at a second-order equational presentation E = (Σ, E)
given by the isomorphism
νE : E → E(ME )
defining the Presentation/Theory Correspondence of Theorem 6.5. From the very definitions of the
functors M(−) and E(−) and the isomorphisms µ(−) and ν(−) , the diagrams
F
M
- M′
µM ′
µM
?
M(E(M ))
M(E(F ))
?
- M(E(M ′ ))
τ
E
- E′
νE
νE ′
?
E(ME )
E(M(τ))
-
?
E(ME ′ )
commute for any second-order algebraic translation F between algebraic theories M : M → M and
M ′ : M → M ′ , and any second-order syntactic translation τ: E → E ′ of equational presentations E
and E ′ , thereby establishing naturality of µ and ν.
Consider the diagram above on the left; its commutativity is trivial on the objects of M . Given a
morphism f : (m1 , . . . , mk ) → (n) of M , its image under µ M ′ ◦ F is the morphism
96
t F f E(M ) : (m1 , . . . , mk ) → (n)
.
6.4. Second-Order Syntactic categorical Type Theory Correspondence
Going the other way, the image of f under M(E(F)) ◦ µ M is given by
M(E(F)) t f E(M )
=
E(F) t f E(M )
=
E(F)(ω f ){N i := x i }i∈knk E(M )
.
=
t F f E(M )
To verify the commutativity of the diagram to the right, note that the image of an operator ω: n1 , . . . , nl
of E under the composite νE ′ ◦ τ is the term
N1 :
[n1 ], . . . , N l : [nl ] Â − ⊢ t〈[τ(ω)]E ′ 〉
.
On the other hand, the image of ω under E(M(τ)) ◦ νE is given by
E(M(τ)) t〈[tω ]E 〉
=
tM(τ)〈[tω ]E 〉
=
t〈[τ(tω )]E ′ 〉
=
t〈[τ(ω)]E ′ 〉
.
97
CHAPTER 6. SECOND-ORDER SYNTACTIC TRANSLATIONS
6.A Appendix to Chapter 6
6.A1 Proof of Compositionality Lemma
For compositionality with substitution, we show by structural induction on terms t that
τ t{x i := t i }i∈knk
τ x j {x i := t i }i∈knk
-
=
τ(t j )
=
x j {x i := τ(t i )}i∈knk
=
τ(x j ){x i := τ(t i )}i∈knk ,
-
=
=
=
=
=
=
=
α
=
=
=
τ(t) x i := τ(t i ) i∈knk
.
for j ∈ knk.
x i := t i i∈knk
τ M s1 x i := t i i∈knk , . . . , sm x i := t i i∈knk
M τ s1 x i := t i i∈knk , . . . , τ sm x i := t i i∈knk
M τ(s1 ) x i := t i i∈knk , . . . , τ(sm ) x i := t i i∈knk
M τ(s1 ), . . . , τ(sm )
x i := t i i∈knk
τ M [s1 , . . . , sm ] x i := t i i∈knk
τ
=
M [s1 , . . . , sm ]
τ ω . . . , ( y1 , . . . , yk )s, . . . x i := t i i∈knk
τ ω . . . , (z1 , . . . , zk )s x i := t i i∈knk y j := z j j∈kkk , . . .
n
o
τω M := (z1 , . . . , zk )τ s x i := t i i∈knk y j := z j j∈kkk
o
n
τω M := (z1 , . . . , zk )τ(s) x i := t i i∈knk y j := z j j∈kkk
o
n
τω M := ( y1 , . . . , yk )τ(s) x i := t i i∈knk
τ ω . . . , ( y1 , . . . , yk )s, . . .
x i := t i i∈knk
Similarly, for compositionality with metasubstitution, we show by induction on the structure of
terms t that
τ t
-
τ x
=
=
=
98
Mi
(i)
(i)
:= (x 1 , . . . , x k )t i
Mi
i
(i)
(i)
:= (x 1 , . . . , x k )t i
i
i∈knk
i∈knk
τ(x)
(i)
(i)
x M i := (x 1 , . . . , x k )τ(t i ) i∈knk
i
(i)
(i)
τ(x) M i := (x 1 , . . . , x k )t i i∈knk
i
=
τ(t)
Mi
(i)
(i)
:= (x 1 , . . . , x k )τ(t i )
i
i∈knk
.
6.A. Appendix to Chapter 6
(i)
(i)
:= (x 1 , . . . , x k )t i i∈knk
i
o
n
( j)
(i)
(i)
τ t j x l := sl M i := (x 1 , . . . , x k )t i i∈knk
i
l∈km j k
n
o
( j)
(i)
(i)
τ(t j ) x j := τ sl M i := (x 1 , . . . , x k )t i i∈knk
i
l∈km j k
o
n
( j)
(i)
(i)
τ(t j ) x j := τ(sl ) M i := (x 1 , . . . , x k )τ(t i ) i∈knk
i
l∈km j k
(i)
(i)
M i := (x 1 , . . . , x )τ(t i ) i∈knk
M j τ(s1 ), . . . , τ(sm )
j
ki
(i)
(i)
τ M j [s1 , . . . , sm j ] M i := (x 1 , . . . , x k )τ(t i ) i∈knk
-
τ
=
=
=
=
=
M j [s1 , . . . , sm
]
j
Mi
i
(i)
(i)
τ ω . . . , ( y1 , . . . , ym )s, . . . M i := (x 1 , . . . , x k )t i i∈knk
i
(i)
(i)
τ ω . . . , ( y1 , . . . , ym )s M i := (x 1 , . . . , x k )t i i∈knk , . . .
i
n
o
(i)
(i)
τω N := ( y1 , . . . , ym )τ s M i := (x 1 , . . . , x k )τ(t i ) i∈knk
i
o
n
(i)
(i)
τω N := ( y1 , . . . , ym )τ(s) M i := (x 1 , . . . , x k )τ(t i ) i∈knk
i
(i)
(i)
τω N := ( y1 , . . . , ym )τ(s) M i := (x 1 , . . . , x k )τ(t i ) i∈knk
i
(i)
(i)
τ ω . . . , ( y1 , . . . , ym )s, . . .
M i := (x 1 , . . . , x )τ(t i ) i∈knk
k
=
=
=
=
=
i
6.A2 Proof of Lemma 6.4
We proceed by induction on the structure of the term s.
-
νE (x i )
= xi
(E 1)
= t ME 〈x i 〉
= t〈[x i ]E 〉
-
νE
M i [t 1 , . . . , t m
]
:= ( y1 , . . . , ymi )M i [ y1 , . . . , ymi ]
N j := (x 1 , . . . , x n )t j j∈km k
i
M i := ( y1 , . . . , ym )νE M i [ y1 , . . . , ym ]
= νE M i N 1 [x 1 , . . . , x n ], . . . , N mi [x 1 , . . . , x n ]
i
i
N j := (x 1 , . . . , x n )νE (t j ) j∈km k
i
= M i N 1 [x 1 , . . . , x n ], . . . , N mi [x 1 , . . . , x n ] M i := ( y1 , . . . , ymi )M i [ y1 , . . . , ymi ]
N j := (x 1 , . . . , x n )νE (t j ) j∈km k
i
(E 1)
= t〈[t ∗ ]E 〉 N j := (x 1, . . . , x n )t〈[t j ]E 〉 j∈kmi k
(for t ∗ = M i N 1 [x 1 , . . . , x n ], . . . , N mi [x 1 , . . . , x n ] )
= νE
i
M i N 1 [x 1 , . . . , x n ], . . . , N m
i
[x 1 , . . . , x n ]
Mi
(E 2)
= t〈[Mi [t 1 ,...,t m ]]E 〉
i
99
CHAPTER 6. SECOND-ORDER SYNTACTIC TRANSLATIONS
-
→
→
y 1 )t 1 , . . . , (−
yl )t l
νE ω (−
→
yi )νE (t i ) i∈klk
= t〈[τEω ]E 〉 N i := (−
→
yi )t〈[t i ]E 〉 i∈klk
= t〈[τEω ]E 〉 N i := (−
(E 2)
= t〈[τEω ]E 〉◦〈[t 1 ]E ,...,[t l ]E 〉
= t〈[ω
100
→
→
(−
y 1 )t 1 ,...,(−
yl )t l ]E 〉
Chapter 7
SECOND -ORDER FUNCTORIAL SEMANTICS
The main objective of universal algebra is the formalisation of algebraic structures and their models. Lawvere’s seminal thesis gives a categorical presentation of the notion of algebraic model. We
show that his functorial semantics for algebraic theories admits generalisation to the second-order
universe, in which a second-order (set-theoretic) functorial model of a second-order algebraic theory
is given in terms of a suitable functor from the algebraic theory to Set.
This constitutes the essence of this chapter. Having shown the syntactic correctness of the definition of second-order algebraic theory, we establish its semantic correctness, by which Second-Order
Functorial Semantics is shown to correspond to the set-theoretic model-theory of second-order universal algebra.
We start by recalling the theory of clones from classical universal algebra (Section 7.1). Clone structures abstractly describe second-order algebraic structures and will be shown to provide semantics
to second-order equational presentations equivalent to that of second-order set-theoretic models. In
Section 7.2, we show that exponentiable objects induce clones, and use this to introduce a notion
of classifying clone for classifying second-order algebraic theories. The formal definition of secondorder functorial models is given in Section 7.3. In line with one of the main themes throughout this
dissertation, we explicitly describe the transition from classifying clones of equational presentations
(and thereby set-theoretic algebras) to abstract functorial models of their classifying algebraic theories,
and
vice
versa
(Section 7.4). We then show that these constructions are mutually inverse, thereby establishing
the Second-Order Semantic Categorical Type Theory Correspondence.
We conclude by using the theory of functorial semantics to provide a different point of view on
the theory of syntactic translations (Section 7.5). As algebraic translations are essentially functorial
models, we show that syntactic translations can be thought of as syntactic models of equational
presentations. We refer to this development as Translational Semantics.
101
CHAPTER 7. SECOND-ORDER FUNCTORIAL SEMANTICS
7.1 Clone Structures
We recall and develop some aspects of the theory of clones from universal algebra [Cohn, 1965].
Clones provide a presentation of algebras that abstracts away from the details of their corresponding
syntactic equational presentations. In modern first-order universal algebra, one understands by a
clone on a set S the set of all elementary operations on S, which includes projections S n → S for any
n ∈ N and is closed under multiple finitary function composition. A formal categorical definition of
clones suitable to our second-order setting follows next.
7.1.1 Categorical clones
Clones. A clone in a cartesian category C is an N-indexed collection {Cn }n∈N of objects of C
(n)
equipped with variable maps ιi : 1 → Cn , (i ∈ knk), for each n ∈ N, and substitution maps
ςm,n : Cm × (Cn )m → Cn for each m, n ∈ N, such that the following commute:
(n)
idCn ×〈ι1 ,...,ιn(n) 〉
- C × (C )n
n
n
Cn × 1
π
1
-
ς n,
n
Cn
1 × (Cn )m
(m)
ιi
π2
- (C )m
n
×id(Cn )m
πi
?
Cm × (Cn )m
Cl × (Cm )l × (Cn )m
?
ςm,n
ςl,m ×id(Cn )m
- C
n
- C × (C )m
m
n
ϕ
ςm,n
?
Cl × (Cn )l
ςl,n
?
- C
n
where ϕ is the morphism idCl × 〈ςm,n ◦ (πi × id(Cn )m )〉i∈klk .
As is well-known, every clone {Cn }n∈N in C canonically extends to a functor F → C defined by
mapping n to Cn . Moreover, given another cartesian category D, any cartesian functor F : C → D
preserves the clone structure in C , in the sense that every clone {Cn }n∈N of C induces the clone
(n)
{F(Cn )}n∈N with structure maps given by F(ιi ) and F(ςm,n ◦ ∼
=) (for m, n ∈ N and i ∈ knk), where
m
∼
= is the canonical isomorphism F(Cm ) × F(Cn ) → F Cm × (Cn )m .
Categories of clones. Given a cartesian category C , the category Clone(C ) is defined to have
objects clones {Cn }n∈N of C . A clone homomorphism {Cn }n∈N → {Dn }n∈N is an N-indexed family of
102
7.1. Clone Structures
morphisms {hn : Cn → Dn }n∈N of C such that for all m, n ∈ N the following commute:
(C)
ιi
1
Cm × (Cn )m
- C
n
ς(C)
m,n
- C
n
)
ιi
(D
hm ×(hn )m
hn
-
?
Dm × (Dn )m
?
Dn
hn
ς(D)
m,n
?
- D
n
7.1.2 Clones for equational presentations
Signature clones. A clone for a second-order signature Σ in a cartesian category C is given by a
clone {Sn }n∈N in C , together with, for each n ∈ N, natural operator maps
ω̃n : Sn+n1 × · · · × Sn+nl → Sn
for every operator ω: n1 , . . . , nl of Σ, such that, for all n, m ∈ N, the diagram
Q
〈id×υni 〉i∈klk
i∈klk S n+ni
Q
i∈klk S n+ni
× (Sm+ni )n+ni
-
Q
-i∈klk
Q
× (Sm )n
ω̃n ×υ0
?
ςn,m
Sn × (Sm )n
ςn+ni ,m+ni
i∈klk S m+ni
ω̃m
?
- S
m
commutes, where for each k ∈ N, the morphism υk is given by
(m+k)
(Sm )n ∼
= (Sm )n × 1
(S j )n ×〈ιm+i 〉i∈kkk
n
k ∼
n+k
- (S
m+k ) × (S m+k ) = (S m+k )
,
and j is the inclusion kmk ,→ km + kk. Note that at 0, υ0 is just the identity on (Sm )n .
We write Σ-Clone(C ) for the category of Σ-clones in C , with morphisms given by clone homomorphisms which commute with the natural operator maps ω̃n for every operator ω of Σ and n ∈ N.
Remark 7.1. The naturality condition on the operator maps above refers to the canonical action for
any f : m → n in F given by the composite
(n)
Cm ∼
= Cm × 1
(n)
Cm ×〈ι f 1 ,...,ι f m 〉
- C × (C )m
m
n
ςm,n
- C
n
that is available in any clone.
We say that a Σ-clone {Sn }n∈N in a cartesian category C is preserved under a functor F : C → D if
{F(Sn )}n∈N is a Σ-clone in the cartesian category D with structure maps given by the image under
F of the structure maps associated to the clone {Sn }n∈N . It is evident that clones are necessarily
103
CHAPTER 7. SECOND-ORDER FUNCTORIAL SEMANTICS
preserved under cartesian functors.
Lemma 7.2. Cartesian functors preserve clones for second-order signatures.
Term interpretations. A Σ-clone {Sn }n∈N in C induces an interpretation of terms in C . For the
metavariable context Θ = (M1 : [m1 ], . . . , M k : [mk ]) and variable context Γ = (x 1 , . . . , x n ), the interpretation of a term Θ Â Γ ⊢ t under the clone {Sn }n∈N is a morphism
¹Θ Â Γ ⊢ tºS :
Y
S mi → S n
i∈kkk
given by induction on the structure of the term t as follows:
- ¹Θ Â Γ ⊢ x i ºS is the composite
Q
i∈kkk S mi
!
(n)
- ¹Θ Â Γ ⊢ M i [t 1 , . . . , t mi ]ºS is the composite
Q
i∈kkk S mi
ιi
- 1
- S
n
.
〈πi ,¹ΘÂΓ⊢t 1 ºS ,...,¹ΘÂΓ⊢t mi ºS 〉
- S × (S )mi
mi
n
ςmi ,n
- S
n
.
→
→
- For an operator ω: n1 , . . . , nl , ¹Θ Â γ ⊢ ω (−
y1 )t 1 , . . . , (−
yl )t l ºS is the composite
Q
i∈kkk S mi
〈¹ΘÂΓni ⊢t i ºS 〉i∈klk
-
(i)
Q
i∈klk S n+ni
ω̃
Sn
,
(i)
where for i ∈ klk, Γni is the context Γ, y1 , . . . , yl .
i
Given a functor F : C → D, we say that the term interpretation ¹Θ Â Γ ⊢ tºS under the Σ-clone
{S}n∈N in C is preserved under F if F¹Θ Â Γ ⊢ tºS = ¹Θ Â Γ ⊢ tº F S in D. It is again straightforward
to observe that term interpretations are preserved under cartesian functors.
Lemma 7.3. A cartesian functor F : C → D preserves interpretations for terms of a second-order
signature induced by a Σ-clone in a cartesian category C .
Presentation clones. For a second-order equational presentation E = (Σ, E), an E -clone in a cartesian category C is a Σ-clone {Sn }n∈N in C such that for all axioms Θ Â Γ ⊢ E s ≡ t of E , the
morphisms ¹Θ Â Γ ⊢ sºS and ¹Θ Â Γ ⊢ tºS are equal in C . In this case, we say that the clone
{Sn }n∈N satisfies the axioms of E .
We write E -Clone(C ) for the full subcategory of Σ-Clone(C ) consisting of the Σ-clones in C which
satisfy the axioms of the presentation E = (Σ, E).
104
7.1. Clone Structures
7.1.3 Clone semantics
Clones for second-order signatures provide an axiomatisation for variable binding, parameterised
metavariables and simultaneous substitution. We recall here that they are in fact an abstract, yet
equivalent, formalisation of (set-theoretic) second-order model theory as presented in Chapter 4.
Proposition 7.4. For Σ a mono-sorted second-order signature, the category Mod(Σ) of set-theoretic
algebraic models for Σ is equivalent to the category Σ-Clone(Set) of Σ-clones in Set.
Proof. A detailed development of this equivalence appears in [Fiore et al., 1999].
One needs an additional argument to show that the same holds when adding equations, that is
that clones and algebras for second-order equational presentations are equivalent. To this end, let
E = (Σ, E) be a second-order equational presentation and
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢E
s ≡ t an equation of E . Recall from Chapter 4 that a set-theoretic algebra A of Mod(E ) satisfies
all equations of E , and therefore the respective term interpretations ¹sºA and ¹tºA are equal mor-
phisms
Y
Ay mi × y n → A
i∈kkk
l
l
in SetF . Consequently, their corresponding exponential transposes ¹sºA and ¹tºs are equal mor-
phisms
Y
Ay mi → Ay n
.
i∈kkk
Now, under the equivalence of Proposition 7.4, the Σ-algebra A corresponds to the Σ-clone
 = {A(n)}n∈N in Set, which induces the term interpretations ¹sºÂ and ¹tºÂ given by the com-
l
l
ponent at (0) of ¹sºA and ¹tºA, respectively. Therefore,
¹sºÂ = ¹tºÂ :
Y
A(mi ) → A(n)
i∈kkk
in Set. We have thus shown that an equation of E = (Σ, E) satisfied by a Σ-algebra A is also satisfied
by the induced Σ-clone Â.
The other direction is given by soundness and completeness. Suppose the judgement
M1 :
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢E s ≡ t
is satisfied by a Σ-clone, then we know from soundness and completeness of Second-Order Equational Logic (Theorem 4.9) that it is necessarily satisfied by all (Σ, E)-algebras.
A second-order term equation is hence satisfied by a signature algebra if and only if it is satisfied by
the corresponding signature clone in Set. This, together with Proposition 7.4, yields an alternative,
yet equivalent, semantics of second-order equational presentations via abstract clone structures.
Proposition 7.5. For E = (Σ, E) a second-order equational presentation, the categories Mod(E ) of
105
CHAPTER 7. SECOND-ORDER FUNCTORIAL SEMANTICS
second-order E -algebras and E -Clone(Set) of set-theoretic E -clones are equivalent.
7.2 Classifying Clones
Before formalising second-order functorial model theory, we show that every second-order algebraic
theory, and in particular those that classify second-order equational presentations, come equipped
with a canonical clone structure induced by their universal exponentiable object. This will enable us
to link functorial models directly to (set-theoretic) algebraic models via these so-called classifying
clone structures.
7.2.1 The clone of elementary operations
Let C be a cartesian category. An exponentiable object C of C canonically induces the clone
〈C〉 = {C n ⇒ C}n∈N
〈C〉n
= Cn ⇒ C
(n)
with variable maps ιi : 1 → 〈C〉n given by the unique exponential mates of the cartesian projections
(n)
π
i
1 × Cn ∼
= Cn - C
.
The substitution map ςm,n : 〈C〉m × 〈C〉m
n → 〈C〉n is given by the exponential mate of
(C m ⇒ C) × (C n ⇒ C m ) × C n
(C m ⇒C )×evn,m
m
- (C m ⇒ C) × C m evC
,
where evn,m : (C n ⇒ C m ) × C n → C m is the evaluation map associated with the exponential C n ⇒
C m = (C n ⇒ C)m .
We refer to 〈C〉 as the clone of elementary operations on the object C of C . Thus, as it is the case
with every clone, the family 〈C〉 canonically extends to a functor F → C mapping n to 〈C〉n and
f : n → m to C f ⇒ C : 〈C〉n → 〈C〉m .
7.2.2 Classifying clones
A clone for a second-order signature Σ is a clone of elementary operations equipped with appropriate extra structure for the operators of Σ.
Classifying signature clones. Let Σ be a second-order signature and M(Σ) its classifying category.
The classifying clone of a second-order signature Σ is given by the clone of operations 〈0〉 = {(n)}n∈N
on the universal exponentiable object (0) of M(Σ), together with the family
{ f˜ω }ω: (n1 ,...,nl )∈Σ
106
,
7.2. Classifying Clones
where for an operator ω: (n1 , . . . , nl ), fω is given by the morphism
〈ω . . . , (x 1 , . . . , x ni )N i [x 1 , . . . , x ni ], . . . 〉: (n1 , . . . , nl ) → (0)
of M(Σ) and the instance at j ∈ N of the family
f˜ω =
f˜ω
j j∈N
is given by
(0) j ⇒ f ω
- (0) j ⇒ (0) ∼
= ( j)
( j + n1 , . . . , j + n l ) ∼
= (0) j ⇒ (n1 , . . . , nl )
.
It is evident to see that our definition of a classifying clone satisfies the properties of clone structures.
Lemma 7.6. The canonical classifying clone of a second-order signature Σ in its classifying category
M(Σ) is a Σ-clone.
Classifying term interpretation. The classifying clone 〈0〉 induces a canonical interpretation of
terms in M(Σ). For Θ = (M1 : [m1 ], . . . , M k : [mk ]) and Γ = (x 1 , . . . , x n ), a term Θ Â Γ ⊢ t has
interpretation ¹tº〈0〉 under the classifying clone simply given by the morphism
〈t〉: (m1 , . . . , mk ) → (n)
in M(Σ). We verify this by induction on the structure of t:
- ¹Θ Â Γ ⊢ x i º〈0〉 is given by
!
(m1 , . . . , mk )
(n)
ιi
- (n)
- 1
,
which by definition is equal to
(m1 , . . . , mk )
!
- 1
l(π
(n) ∼
i ◦=)
- (n)
,
and this, in return, is equal to 〈x i 〉 by Lemma 5.2.
- Similarly, ¹Θ Â Γ ⊢ M i [t 1 , . . . , t mi ]º〈0〉 is the composite
(m1 , . . . , mk )
πi ,¹t 1 º〈0〉 ,...,¹t mi º〈0〉
- (m , nmi )
i
ςmi ,n
- (n)
,
which by induction on the t j ’s ( j ∈ kmi k) and by Lemma 5.2 is equal to 〈M i [t 1 , . . . , t mi ]〉.
→
→
- For ω: n1 , . . . , nl , ¹Θ Â Γ ⊢ ω (−
y1 )t 1 , . . . , (−
y l )t l º〈0〉 is the composite
(m1 , . . . , mk )
¹t 1 º〈0〉 ,...,¹t l º〈0〉
ω̃
- (n + n , . . . , n + n ) (n)
1
l
.
107
CHAPTER 7. SECOND-ORDER FUNCTORIAL SEMANTICS
By definition of classifying clones, ω̃ = (0)n ⇒ tω , and by induction, the above composite
→
→
simply amounts to ω (−
y )t , . . . , (−
y )f .
1
1
l
l
Classifying presentation clones. For a second-order equational presentation E = (Σ, E), we define
its classifying clone in its classifying category M(E ) in a similar fashion, namely by the clone of
operations 〈0〉 together with the family {( f˜ω )n }n∈N , where for ω: n1 , . . . , nl , the morphism fω is
taken to be the tuple of the equivalence of the same term as in the definition of classifying signature
clones, more precisely
ω . . . , (x 1 , . . . , x ni )N i [x 1 , . . . , x ni ], . . . E : (n1 , . . . , nl ) → (0) .
A similar inductive argument shows that the interpretation for a term Θ Â Γ ⊢ t induced by the
classifying clone 〈0〉 in M(E ) is the morphism 〈[Θ Â Γ ⊢ t]E 〉.
A derivable judgement Θ Â Γ ⊢E s ≡ t of E is therefore satisfied by the classifying clone of E in
M(E ), since 〈[Θ Â Γ ⊢ s]E 〉 and 〈[Θ Â Γ ⊢ t]E 〉 are equal morphisms in M(E ), and therefore
¹sº〈0〉 = ¹tº〈0〉 . Classifying clones therefore provide sound semantics for second-order equational
presentations in their classifying categories.
7.3 Second-Order Functorial Semantics
We extend Lawvere’s functorial semantics for algebraic theories [Lawvere, 2004] from first to second
order.
Definition 7.7 (Second-Order Functorial Model). A second-order functorial model of a second-order
algebraic theory M : M → M is given by a cartesian functor M → C , for C a cartesian category.
We write
Mod(M , C ) for the category of functorial models of M in C , with morphisms (necessarily
monoidal) natural transformations between them. A second-order set-theoretic functorial model of a
second-order algebraic theory M : M → M is simply a cartesian functor from M to Set. We write
Mod(M ) for the category of set-theoretic functorial models of M in Set.
Note that, just as in Lawvere’s first-order definition, we mereley ask for preservation of the cartesian
structure rather than strict preservation. Consequently, functorial models of the same second-order
algebraic theory may differ only by the choice of the cartesian product in Set. However, as we
pointed out earlier, since the cartesian structure in Set is not strictly associative (whereas it is strictly
associative in any first- and second-order algebraic theory), asking for preservation in the definition
of a functorial model avoids the creation of unnatural categories of models.
7.4 Second-Order Semantic Categorical Type Theory Correspondence
We show that classifying clones, and thus second-order algebras, correspond to second-order functorial models.
108
7.4. Second-Order Semantic Categorical Type Theory Correspondence
Proposition 7.8. Let E = (Σ, E) be a second-order equational presentation and ME : M → M(E ) its
classifying algebraic theory, and let C be a cartesian category. The category of E -clones E -Clone(C )
and the category of second-order functorial models
Mod(M , C ) are equivalent.
E
Proof. We provide an explicit description of the equivalence functors. Define
Υ :
Mod(M , C ) −→ E -Clone(C )
E
by mapping a cartesian functor F : M(E ) → C to the clone
F̂ := {F(n)}n∈N
whose structure maps are given by the image under F of the structure maps of the canonical classifying clone 〈n〉 of M(E ). This makes F̂ indeed a clone for the signature Σ, as, by Lemma 7.2, cartesian
functors preserve clone structures. F̂ is moreover a clone for the equational presentation E , as it
satisfies all equations in C : given an equation Θ Â Γ ⊢ s ≡ t of E , we have F〈[s]E 〉 = F〈[t]E 〉 (since
〈[s]E 〉 = 〈[t]E 〉), and therefore we get, by Lemma 7.3, that ¹sº F̂ = F¹sº〈0〉 = F¹tº〈0〉 = ¹tº F̂ .
On morphisms of
Mod(M , C ), Υ is defined by mapping a monoidal natural transformation α: F →
E
G to {αn }n∈N : {F(n)}n∈N → {G(n)}n∈N . This is indeed a homomorphism of E -clones because α is
natural and the clone structure maps of F̂ and Ĝ are the images of those of 〈n〉 under F and G.
Furthermore, note that Υ is functorial: the identity natural transformation id (F ) : F → F is mapped
under Υ to {idn(F ) }n∈N , where each idn(F ) : F(n) → F(n) is simply the identity morphism in C . Similarly, for natural transformations α: F → G and β : G → H, the image of the composite β ◦ α under
Υ is {(β ◦ α)n }n∈N = {βn ◦ αn }n∈N .
In the other direction, define
Ῡ : E -Clone(C ) −→
Mod(M , C )
E
by mapping an E -clone {Cn }n∈N to the functor F (C ) : M(E ) → C , which maps (m1 , . . . , mk ) to
Cm1 × · · · × Cmk . For Θ = (M1 : [m1 ], . . . , M k : [mk ]) and Γ = (x 1 , . . . , x n ), the image of the morphism
〈[Θ Â Γ ⊢ t]E 〉: (m1 , . . . , mk ) → (n)
under F (C ) is defined to be the interpretation ¹tºC of the term t under the clone C. This defini-
tion respects the equivalence relation of E as given an equation Θ Â Γ ⊢E s ≡ t, we know that
¹sº〈n〉 = ¹tº〈n〉 since 〈n〉 is an E -clone, and therefore F (C ) 〈[s]E 〉 = F (C ) 〈[t]E 〉 in C . Moreover, note
that F (C ) is cartesian by definition.
On morphisms of E -Clone(C ), Ῡ is defined by mapping a clone homomorphism
{hn }n∈N : {Cn }n∈N → {Dn }n∈N
109
CHAPTER 7. SECOND-ORDER FUNCTORIAL SEMANTICS
to h̄: F (C ) → F (D) , with component at (m1 , . . . , mk ) given by h̄(m1 ,...,mk ) = hm1 × . . . , ×hmk . Because
clone homomorphisms commute with the clone structure maps, we are ensured that h̄ is a natural
transformation. This can be seen more explicitly by induction on the term structure:
- For 〈[x i ]E 〉: (m1 , . . . , mk ) → (n), the diagram
C m1 × · · · × C m k
!
(C)
ιi
- 1
- C
n
=
hm1 ×···×hmk
?
D m1 × · · · × D m k
1
hn
(D)
ιi
?
- 1
?
- D
n
by uniqueness of the terminal map ! and because h is a homomorphism of clones and hence
(−)
commutes with the clone structure maps ιi
.
- Similarly, for 〈[M i [t 1 , . . . , t mi ]]E 〉: (m1 , . . . , mk ) → (n), the following diagram commutes
C m1 × · · · × C m k
- C × (C )mi
mi
n
(C)
πi ,F (C) 〈[t 1 ]E 〉,...,F (C) 〈[t mi ]E 〉
hmi ×(hn )mi
hm1 ×···×hmk
Dmi × (Dn )mi
D m1 × · · · × D m k i
- C
n
hn
?
?
ς(C)
m ,n
(D)
πi ,F (D) 〈[t 1 ]E 〉,...,F (D) 〈[t mi ]E 〉
ς(D)
m ,n
i
?
- D
n
(D)
by induction on F (−) 〈[t j ]E 〉 for all j ∈ kmi k, by universality of the cartesian map πi , and
because hn commutes with the clone structure maps ς.
→
→
- For ω: n1 , . . . , nl and 〈[ω (−
y 1 )t 1 , . . . , (−
y l )t l ]E 〉, the following diagram commutes for the
same reasons as above:
C m1 × · · · × C m k
hm1 ×···×hmk
F (C) 〈[t 1 ]E 〉,...,F (C) 〈[t l ]E 〉
- C
n+n1 × · · · × C n+nl
ω̃(C)
- C
n
hn+n1 ×···×hn+nl
hn
?
D m1 × · · · × D m k ?
Dn+n1 × · · · × Dn+nl
ω̃(D)
?
- D
n
F (D) 〈[t 1 ]E 〉,...,F (D) 〈[t l ]E 〉
That Ῡ is functorial follows from the fact that natural transformations in
Mod(M , C ) are
E
monoidal. More precisely, an identity homomorphism of clones {idn }n∈N is mapped under Ῡ to
the identity natural transformation with component at (m1 , . . . , mk ) given by idm1 × · · ·× idmk ,
which is equal to id(m1 ,...,mk ) . Similarly, a composite of clone homomorphisms {(g ◦ h)n }n∈N is
mapped to (g ◦ h) with component at (m1 , . . . , mk ) given by
(g ◦ h)m1 × · · · × (g ◦ h)mk = (g ◦ h)(m1 ,...,mk ) = g(m1 ,...,mk ) ◦ h(m1 ,...,mk )
.
Now, we proceed to show that the functors Υ and Ῡ are equivalences. A functorial model F : M(E ) →
C is mapped under Ῡ ◦ Υ to F ( F̂ ) : M(E ) → C , which maps an object (m1 , . . . , mk ) to F(m1 ) × · · · ×
F(m ) ∼
= F(m , . . . , m ) and a morphism 〈[Θ Â Γ ⊢ t] 〉 to ¹tº = F¹tº = F〈[Θ Â Γ ⊢ t] 〉.
k
110
1
k
E
F̂
〈0〉
E
7.4. Second-Order Semantic Categorical Type Theory Correspondence
A natural transformation α: F → G is mapped under Ῡ ◦ Υ to α̂ : F ( F̂ ) → F (Ĝ) and, because it is
monoidal, has component at (m1 , . . . , mk ) given by α̂(m1 ,...,mk ) = αm1 × · · · × αmk = α(m1 ,...,mk ) . In
the other direction, an E -clone {Cn }n∈N is mapped under Υ ◦ Ῡ to the clone F̂ (C ) = {F (C ) (n)}n∈N =
{Cn }n∈N , and an E -clone homomorphism {hn }n∈N : {Cn }n∈N → {Dn }n∈N to {h̄(n) }n∈N = {hn }n∈N .
If we take the cartesian category C to be Set, we then immediately get from Proposition 7.8 together with Proposition 7.5 the correspondence between set-theoretic functorial models, models for
equational presentations, and set-theoretic clone structures.
111
CHAPTER 7. SECOND-ORDER FUNCTORIAL SEMANTICS
Theorem 7.9 (Second-Order Semantic Categorical Type Theory Correspondence). For every secondorder equational presentation E , the category Mod(E ) of E -models and the category of second-order
functorial models
Mod(M ) are equivalent.
E
From the Second-Order Syntactic Categorical Type Theory Correspondence, we also immediately
get the following equivalent formulation of the above semantic correspondence.
Corollary 7.10. For every second-order algebraic theory M : M → M , the category of second-order
functorial models
Mod(M ) and the category of algebraic models Mod(E(M )) are equivalent.
7.5 Translational Semantics
Second-order functorial semantics enables us to take a model of an algebraic theory in any cartesian
category C . We illustrate that this way of abstractly defining algebras for theories has a syntactic
counterpart via syntactic translations, which we refer to as second-order translational semantics.
To this end, consider two second-order equational presentations E and E ′ , their corresponding classifying algebraic theories ME : M → M(E ) and ME ′ : M → M(E ′ ), and let τ: E → E ′ be a secondorder syntactic translation. Note that its induced algebraic translation M(τ): M(E ) → M(E ′ ), which
commutes with the theories ME and ME ′ , is by definition a second-order functorial model of the
theory ME in the cartesian category M(E ′ ). The canonical notion of a morphism of (second-order)
algebraic theories is thereby intuitively providing a model of one algebraic theory into another.
From the categorical equivalence of the Syntactic Categorical Type Theory Correspondence
(Theorem 6.6), second-order syntactic translations can be thought of as syntactic notions of models of one equational presentation into another. Therefore, by explicitly defining the translation
τ: E → E ′ , we implicitly provide a model of the presentation E in E ′ .
We have in this work reviewed first- and second-order set-theoretic semantics for equational presentations, as well as categorical semantics, and finally introduced second-order functorial semantics.
Through the development of syntactic translations, we have thus introduced a less abstract, more
concrete way of giving semantics to equational presentations. We refer to this as (second-order)
Translational Semantics.
112
Chapter 8
CONCLUDING REMARKS
We have incorporated second-order languages into universal algebra by developing a programme
from the viewpoint of Lawvere’s algebraic theories.
The pinnacle of our work is the notion of second-order algebraic theory, which we defined on top of
a base category, the second-order theory of equality M, representing the elementary operators and
equations present in every second-order language. We showed that M can be described abstractly
via the universal property of being the free cartesian category on an exponentiable object.
At the syntactic level, we established the correctness of our definition by showing a categorical
equivalence between second-order equational presentations and second-order algebraic theories.
This equivalence, referred to as the Second-Order Syntactic Categorical Type Theory Correspondence, involved distilling a notion of syntactic translation between second-order equational presentations that corresponds to the canonical notion of morphism between second-order algebraic
theories. Syntactic translations provide a mathematical formalisation of notions such as encodings
and transforms for second-order languages.
On top of this syntactic correspondence, we furthermore established the Second-Order Semantic
Categorical Type Theory Correspondence. This involved generalising Lawvere’s notion of functorial
model of algebraic theories to the second-order setting. By this semantic correspondence, secondorder functorial semantics were shown to correspond to the model theory of second-order universal
algebra.
We now show that the core of the theory surrounding first-order algebraic theories extends to the
second-order universe. Instances of this development are the existence of algebraic functors (Section 8.1) and monad morphisms (Section 8.2) in the second-order universe. Moreover, we define a
notion of syntactic translation homomorphism that allows us to establish a 2-categorical type theory correspondence (Section 8.3). To keep the illustrative nature of these concluding remarks, our
treatment of the various examples will remain at a rather superficial level, with many of the proofs
omitted.
113
CHAPTER 8. CONCLUDING REMARKS
We conclude this chapter by briefly outlining two directions for future research (Section 8.4). The
first proposal is the extension of categorical universal algebra to include dependently-sorted syntax. The second proposal is the formalisation of the theory of syntactic translations in terms of a
framework that allows generic characterisation of relationships amongst algebraic languages.
8.1 Second-Order Algebraic Functors
8.1.1 First-order algebraic categories and their morphisms
The concept of an algebraic functor arising from morphisms of Lawvere theories has been developed
by Lawvere [Lawvere, 2004] and revisited many times since then [Borceux, 1994, Adamek et al., 2009].
It is the canonical notion of morphism between algebraic categories.
Definition 8.1 (Algebraic Category). A category is called algebraic if it is equivalent to the category
of functorial models FMod(L) for some algebraic theory L : L → L .
The simplest example of an algebraic category is the category Set of sets. Its associated algebraic theory is simply L, together with the identity functor IdL : L → L. Every functorial model AIdL : L → Set
is determined up to isomorphism by the set AIdL (1), since any n ∈ L is the n-th cartesian product of
the generator 1. Therefore, we have an equivalence FMod(IdL ) → Set: AIdL 7→ AIdL (1).
The categories of algebras presented in this dissertation are algebraic. Consider for instance a
mono-sorted first-order equational presentation E = (Σ, E) and its classifying algebraic theory
LE : L → L(E ). The category E -Alg of algebras for the equational presentation E is algebraic,
since by the First-Order Semantic Categorical Type Theory Correspondence (Theorem 2.18) it is
equivalent to the category FMod(LE ) of functorial models for its classifying algebraic theory.
Remark 8.2 (Representable functorial models). We recall that the Yoneda transformation yields
canonical functorial models induced by objects of a Lawvere theory. This construction is used in
deriving left adjoints for first-order algebraic functors. For L : L → L an algebraic theory, an object
l ∈ L induces the algebra YL (l) = L (l, −): L → Set, which, together with the Yoneda transformation, defines a full and faithful functor YL : L op → FMod(L).
The theory surrounding algebraic categories is very rich, particularly since they can be given a very
elegant characterisation via universal properties. More specifically, algebraic categories are free
completions of small cocartesian categories under sifted colimits, see [Adamek et al., 2009]. They
can also be characterised as those cocomplete categories which have a strong generator consisting
of perfectly presentable objects, see [Adamek et al., 2009].
We are interested in the natural concept of morphism between such categories. This is given via
preservation of the cartesian structure - the categorical characterisation of canonical algebraic struc114
8.1. Second-Order Algebraic Functors
ture.
Definition 8.3 (Algebraic Functor). Let F : L → L ′ be an algebraic translation of (mono-sorted
first-order) Lawvere theories L : L → L and L ′ : L → L ′ . The functor
FMod(F): FMod(L ′ ) → FMod(L): G 7→ G ◦ F
is called an algebraic functor.
We obtain the following commutative diagram, where the unlabelled arrows are the canonical
(monadic) forgetful functors:
FMod(F )
- FMod(L)
-
FMod(L ′ )
Set
Within the development surrounding algebraic categories, algebraic functors have been defined to
be those functors which preserve limits, filtered colimits and epimorphisms. It is indeed the case
that a functor of algebraic categories is algebraic (in this latter sense) if and only if it is induced by a
morphism of algebraic theories, making the two definitions equivalent. For a proof of the following
fundamental result, see for example [Borceux, 1994] or [Adamek et al., 2009].
Theorem 8.4. A functor between algebraic categories F : A2 → A1 preserves limits, filtered colimits
and epimorphisms if and only if there exists an algebraic translation G : L1 → L2 of algebraic theories
L1 : L → L1 and L2 : L → L2 and equivalences E1 : FMod(L1 ) → A1 and E2 : FMod(L2 ) → A2 such
that F ◦ E2 = E1 ◦ FMod(G) up to natural isomorphism.
It is therefore legitimate to use the notation FMod(G) for algebraic functors, with G being the
algebraic translation inducing it. Moreover, it can be shown that algebraic functors have left adjoints.
This is an immediate consequence of the Adjoint Lifting Theorem.
Theorem 8.5 (Adjoint Lifting Theorem). Let F ◦ U = V ◦ G be a commutative diagram of functors,
where U and V are monadic, and G is the functor C → D. If the category C has coequalisers, then G
has a left adjoint as soon as F has a left adjoint.
Proposition 8.6. Let F : L1 → L2 be an algebraic translation of algebraic theories L1 : L → L1 and
L2 : L → L2 . Then its induced algebraic functor FMod(F): FMod(L2 ) → FMod(L1 ) has a left adjoint
Fe : FMod(L1 ) → FMod(L2 ).
This left adjoint Fe is in fact the essentially unique functor which preserves sifted colimits and makes
the following diagram commute up to natural isomorphism.
op
L1
F op
YL1
- L op
2
YL2
?
e
?
F
FMod(L1 ) - FMod(L2 )
115
CHAPTER 8. CONCLUDING REMARKS
The algebraic importance of these left adjoints is pointed out by Lawvere in his thesis [Lawvere, 2004].
As an example, the adjoint to the algebraic functor induced by an algebraic translation from the theory of monoids to the theory of rings essentially assigns to a given monoid M the monoid ring Z[M ]
with integer coefficients. As Lawvere also points out, the fact that these adjoints form the commutative diagram above implies, for instance, that a free ring can be constructed either as the monoid
ring of a free monoid, or as the tensor ring of a free abelian group. These are well-known facts from
universal algebra, but given a more abstract formulation via algebraic functors and their adjoints.
We finally recall that the resulting algebraic adjunction is monadic, which is an immediate consequence of the following observation. For a detailed proof of this, we refer the reader to [MacLane, 1998]
and [Borceux, 1994].
Proposition 8.7. Let U = V ◦ G be a commutative diagram, where G is a functor C → D. Suppose
both U and V are monadic. If the category C has coequalisers, then the functor G is monadic as well.
8.1.2 Second-order algebraic functors
Just as in the first-order case, every algebraic translation F : M → M ′ between second-order algebraic theories M : M → M and M ′ : M → M ′ contravariantly induces a second-order algebraic
functor
Mod(F): Mod(M ) → Mod(M ) ; S 7→ S ◦ F between the corresponding categories of
′
second-order functorial models. We also obtain the fundamental left adjoint to second-order algebraic functors.
Theorem 8.8. The algebraic functor
Mod(F): Mod(M ) → Mod(M ) induced by a second-order
′
algebraic translation F : M → M ′ has a left adjoint, and the resulting adjunction is monadic.
Proof sketch. It has been shown by Fiore and Hur [Fiore and Hur, 2008a] that in the situation
Mod(M )
′
Mod(F-) Mod(M )
-
SetF
the forgetful functors, given by the unlabelled arrows above, have left adjoints, and that the ad-
Mod(M ) and Mod(M ) have all
coequalisers [Fiore and Hur, 2008a]. The left adjoint to Mod(F) is given by Lan (−): Mod(M ) →
Mod(M ), which maps a functorial model G : M → Set to the left Kan extension Lan (G) of G
′
junction is monadic. Furthermore, the functorial model categories
F
′
F
along F : M → M ′ , that is
F
- M′
Set
F
La
n
-
G
(G
)
M
Finally, from Proposition 8.7, we get that the adjunction Lan F (−) ⊣
116
Mod(F) is monadic.
8.1. Second-Order Algebraic Functors
8.1.3 Syntactically induced second-order algebraic functors
Syntactic translations of second-order equational presentations similarly yield a notion of algebraic
functor which is naturally isomorphic to the one introduced above. We begin by observing that
second-order syntactic signature translations behave essentially as natural transformations between
the corresponding signature endofunctors and their induced monads.
Syntactic translations as natural transformations. For second-order signatures Σ1 and Σ2 , let
FΣ1 be the signature endofunctor induced by Σ1 (Section 4.3.2), and TΣ2 the (underlying functor
of the) induced monad corresponding to Σ2 . More precisely, in the situation
SetFWW hh
((
⊥ Mod(Σ2 )
FΣ 2
TΣ2 is the monad induced by the above adjunction, so that TΣ2 -Alg ∼
= Mod(Σ2 ). Furthermore, recall from Chapter 4 that objects of Mod(Σ2 ) are algebras for the signature endofunctor FΣ2 equipped
with compatible monoid structure.
A translation τ: Σ1 → Σ2 induces a natural transformation ατ : FΣ1 → TΣ2 , which is strong in the
sense that
FΣ1 (X ) • Y
sFΣ
1
FΣ1 (X • Y )
ατX •Y
ατX • Y
?
?
sTΣ
2
TΣ2 (X • Y )
TΣ2 (X ) • Y
commutes for the canonical pointed strengths sFΣ and sTΣ .
1
2
Natural transformations induced in this way by syntactic translations contravariantly induce algebraic functors between categories of set-theoretic algebras, as described next.
Algebraic functors between categories of signature models. For τ: Σ1 → Σ2 a second-order
translation with induced natural transformation ατ : FΣ1 → TΣ2 , let A ∈ Mod(Σ2 ) be a Σ2 -model,
with monoid structure νA : y 1 → A and ςA : A • A → A, and FΣ2 -algebra structure map given by
ϕA : FΣ2 A → A. Denote by δA : TΣ2 A → A the corresponding TΣ2 -algebra structure map induced by
the categorical equivalence Mod(Σ2 ) ∼
= TΣ2 -Alg.
Composing this TΣ2 -algebra structure map δ with natural transformations FΣ1 → TΣ2 essentially
defines the mapping of algebraic functors. More precisely, a second-order signature translation
117
CHAPTER 8. CONCLUDING REMARKS
τ: Σ1 → Σ2 yields the algebraic functor
Mod(τ): Mod(Σ2 ) → Mod(Σ1 )
by mapping A ∈ SetF with structure maps νA : y 1 → A, ςA : A • A → A, and ϕA : FΣ2 A → A to the
algebra with same underlying presheaf A and same monoid maps νA and ςA, but with FΣ1 -algebra
structure map given by the composite
FΣ 1 A
ατA
- T A
Σ2
δA
- A
.
This morphism is compatible with the monoid structure given by νA and ςA because of the strength
of the natural transformation ατ discussed above.
Observe that the substitution structure remains ‘constant’ under the algebraic functor Mod(τ), just
as it is under syntactic translations. The compatibility of the monoid structure with the structure
map of the signature endofunctor can be viewed as an abstract description of the compositionality
of syntactic translations with substitution and metasubstitution (Lemma 6.1). The algebraic functor
Mod(τ) clearly commutes with the canonical forgetful functors into SetF . Using a similar argument
as in Section 8.1.1, one can immediately derive a left adjoint to Mod(τ), with the resulting adjunction being monadic.
Algebraic functors between categories of presentation algebras. We use the notion of algebraic
equational systems developed by Fiore and Hur in [Fiore and Hur, 2007, Fiore and Hur, 2008a] to
derive algebraic functors induced by syntactic translations of second-order equational presentations.
Definition 8.9 (Equational System). An equational system S is given by a pair of functors
L, R: F-Alg → D-Alg between categories of algebras for endofunctors over some base category C .
In the framework of equational presentations, the functorial signature F is a generalisation of the
concept of endofunctor induced by an algebraic signature; the so-called functorial terms L, R generalise the notion of equation; and the endofunctor D corresponds to the arity of the equation. The
category S-Alg of algebras for the equational system S is given by the equaliser S-Alg ,→ F-Alg of
L, R. More explicitly, an S-algebra is simply an F-algebra (A, a : FA → A) such that L(A, a) and R(A, a)
are equal D-algebras on A.
Example 8.10 (Second-Order Equational Systems). Let E = (Σ, E) be a (mono-sorted) second-order
equational presentation and y 1 be the presheaf of variables defined in Section 4.3. The second-order
equational system SE associated with E is given by the signature endofunctor FΣ of its underlying
`
signature Σ, together with the functor ΓE : SetF → SetF defined by ΓE (A) := (ΘÂΓ⊢t≡s)∈E (A• A) + y 1,
and the pair of functors LE , RE : FΣ -Alg ⇉ ΓE -Alg, where
LE (A, ¹−ºA) :=
118
RE (A, ¹−ºA) :=
A, ¹tºA (t≡s)∈E
A, ¹sºA (t≡s)∈E
8.1. Second-Order Algebraic Functors
The category SE -Alg of algebras for the second-order equational system SE is then the equaliser
SE -Alg ,→ FΣ -Alg of LE , RE : FΣ -Alg ⇉ ΓE -Alg.
For a second-order signature Σ, the equational systems formalism allows one to write
Mod(Σ)
⊂
eq
- F ′ -Alg
Σ
- ΓΣ -Alg
,
where FΣ′ (X ) = FΣ (X ) + V + X • X , and the parallel pair encodes the equations of Σ-monoids. For
a second-order equational presentation E = (Σ, E), we further have
Mod(E )
∩
eq
?
ΓΣ -Alg FΣ′ -Alg
- Γ E -Alg
,
where the left parallel pair encodes the Σ-monoids (or substitution structure) as above, and the
parallel pair to the right encodes the equations in E. We therefore get the equivalent equaliser
diagram
Mod(E )
⊂
eq
- F ′ -Alg
Σ
- (ΓΣ + Γ E )-Alg
,
so that in fact one has
Mod(E )
⊂
- Mod(Σ)
- ΓE -Alg
eq
.
The previous discussion shows that the elegance of this abstract formalism of equational systems lies
(partly) in the fact that the category SE -Alg of algebras for SE is in fact isomorphic to the category
Mod(E ) of models for the equational presentation E . We recall some relevant fundamental results.
Proposition 8.11. The category SE -Alg is a cocomplete, full reflective subcategory of FΣ -Alg. Moreover,
the forgetful functor SE -Alg → SetF has a left adjoint, and the resulting adjunction is monadic.
Now, we use this framework to derive algebraic functors between categories of models for secondorder equational presentations, or equivalently, for equational systems. To this end, let E1 = (Σ1 , E1 )
and E2 = (Σ2 , E2 ) be second-order equational presentations, and τ: E1 → E2 a syntactic translation.
119
CHAPTER 8. CONCLUDING REMARKS
Consider the following diagram:
J
⊂ 2
- Mod(Σ )
2
L2
R2
- ΓE2 -Alg
Mod(E2 )
SetF
Mod(τ′ )
Mod(τ)
?
Mod(E1 )
J1
⊂
?
- Mod(Σ )
1
L1
R1
- ΓE1 -Alg
Here, τ′ : Σ1 → Σ2 is the restriction of τ to the underlying signatures of E1 and E2 , and Mod(τ′ ) is
the induced algebraic functor Mod(Σ2 ) → Mod(Σ1 ), as derived above. Without going into the details here, it can be shown that Mod(E2 ) together with the composite functor Mod(τ′ ) ◦ J2 equalise
the pair L1 , R1 . This is intuitively because axioms of E1 are mapped via the syntactic translation τ to
theorems of E2 . Hence, one gets the unique functor Mod(τ) making the above diagram commute.
Furthermore, by the Adjoint Lifting Theorem (Theorem 8.4) and the monadicity result of Proposition 8.7, this functor will have a left adjoint, and the resulting adjunction is monadic.
We refer to Mod(τ): Mod(E2 ) → Mod(E1 ) as the second-order syntactic algebraic functor induced
by the syntactic translation τ: E1 → E2 . Using the Second-Order Semantic Categorical Type Theory Correspondence (Theorem 7.9), this functor can be shown to be naturally isomorphic to the
composite
Mod(E2 ) ∼
=
Mod(M
E2 )
Mod(M(τ))
- Mod(M
E1 )
∼
= Mod(E1 )
,
where for i = 1, 2, MEi : M → M(Ei ) is the algebraic theory classifiying Ei , M(τ) is the algebraic
translation induced by τ, and
Mod(M(τ)) is its induced second-order algebraic functor.
8.2 Second-Order Monad Morphisms
We use the dual of the canonical definition of morphism between monads as in [Street, 1972] to
recall the relation between monads induced by algebraic translations of algebraic theories.
Definition 8.12 (Monad Morphism). Let (T, η, µ) and (T′ , η′ , µ′ ) be monads on a category C . A
120
8.2. Second-Order Monad Morphisms
monad morphism φ : T → T′ is a natural transformation making the following diagrams commute.
TT′
φ T′
- T′ T′
η
Tφ
-
-
T
1C
TT
φ
µ′
µ
′
η
-
-
?
T′
T
φ
?
- T′
Given two monad morphisms φ1 , φ2 : T ⇉ T, a homomorphism of monad morphisms is a natural
transformation σ : 1C → 1C such that φ2 ◦ Tσ = σT′ ◦ φ1 .
Algebraic functors induce monad morphisms, but even stronger, these two fundamental notions of
morphisms correspond bijectively to one another [Borceux, 1994]. We quickly illustrate these constructions and results in the second-order algebraic universe.
Recall that the category Mod(E ) of models for a second-order equational presentation E = (Σ, E)
is isomorphic to the category TE -Alg of algebras for the monad TE induced by the adjunction
Mod(E ) ⇆ SetF . Using the same framework and notation of Section 8.1.3, consider the diagram
1
- T -Alg
E1
U
-
U2
T(τ)
TE2 -Alg
SetF
where T(τ) is the algebraic functor obtained via composition of Mod(τ) with the evident categorical equivalences, and is therefore naturally isomorphic to Mod(τ) and
Mod(M(τ)). Let F
1
and
F2 be the left adjoints to the forgetful functors U1 and U2 , respectively. Moreover, for i = 1, 2, let
the canonical natural transformations of the adjunction Fi ⊣ Ui be given by αi : 1SetF → Ui ◦ Fi and
βi : Fi ◦ Ui → 1TE -Alg .
i
We define the monad morphism τT : TE1 → TE2 induced by the algebraic functor T(τ) to be the
composite
T E1
TE1 α2
- T T = U F U F = U F U T(τ)F
E1 E2
1 1 2 2
1 1 1
2
U1 β1 T(τ)F2
- U T(τ)F = U F = T
1
2
2 2
E2
.
Indeed, it is straightforward to verify that the natural transformation τT is a monad morpshism
according to Definition 8.12. Moreover, the algebraic functor T(τ) maps a TE2 -algebra (A, ϕ) to the
TE1 -algebra (A, ϕ ◦ (τT )A). These constructions in fact define the bijective correspondence between
(second-order) algebraic functors and monad morphisms. For a proof of a similar version of the
following result, we refer the reader to [Borceux, 1994].
Proposition 8.13. Let E1 and E2 be second-order equational presentations. Monad morphisms TE1 →
121
CHAPTER 8. CONCLUDING REMARKS
TE2 and algebraic functors Mod(E2 ) → Mod(E1 ) are in bijective correspondence.
Corollary 8.14. Given second-order algebraic theories M1 : M → M1 and M2 : M → M2 , we have that
monad morphisms TE(M1 ) → TE(M2 ) and algebraic functors
correspondence.
Mod(M ) → Mod(M ) are in bijective
2
1
8.3 2-Categorical Type Theory Correspondence
By considering natural transformations between algebraic translations, one can form the 2-category
of second-order algebraic theories. This can be mirrored syntactically by formalising a concept of
translation homomorphism. We recall some basics of 2-category theory first.
8.3.1 Preliminaries on 2-categories
Recall that a 2-category is a category equipped with a notion of mapping between its morphisms.
Each hom-set itself carries the structure of a category. Abstractly, a 2-category is a category enriched
over Cat, the category of small categories, with the monoidal structure given by products of categories. We quickly review the more explicit definition of the basic elements of 2-category theory
[Borceux, 1994].
2-categories. A 2-category C consists of a class ob(C) of objects or 0-cells, together with, for each
pair of 0-cells A, B ∈ ob(C), a small category C(A, B) whose objects, denoted by f : A → B, are called
1-cells, and whose morphisms, denoted by α: f ⇒ g, are called 2-cells. Composition of 2-cells is
referred to as vertical composition and denoted by •. From the axioms of 2-category theory (see
e.g. [Borceux, 1994]), it follows that 0-cells and 1-cells constitute a category, referred to as the
underlying category of the 2-category.
Given small categories A and B, one may take 1-cells to be functors A → B and 2-cells to be
natural transformations. The most prototypical example of a 2-category is Cat, the 2-category of all
small categories, functors and natural transformations.
Example 8.15.
(1) The 2-category SOAT has 0-cells given by second-order algebraic theories, 1-cells given by their
algebraic translations, and 2-cells given by natural transformations. Composition of 1-cells and
2-cells are the usual composition of functors and natural transformations, respectively.
(2) We define the 2-category SOALG to have second-order algebraic categories as 0-cells, secondorder algebraic functors as 1-cells, and again natural transformations as 2-cells.
We aim to construct the 2-category SOEP of second-order equational presentations. Translation
homomorphisms (defined in the next section) will be taken to be the 2-cells.
122
8.3. 2-Categorical Type Theory Correspondence
2-functors. Given two 2-categories C and D, a 2-functor F : C → D assigns to every 0-cell A of
C a 0-cell FA ∈ ob(D), and to every pair of objects A, B of C a functor FA,B : C(A, B) → D(FA, F B)
satisfying the canonical requirements of compatibility with composition and identity.
Biequivalence. We start by defining internal equivalence of 0-cells. Two objects A and B of a 2category C are internally equivalent in C if there is a pair of 1-cells f : A → B and g : B → A such
that g ◦ f ∼
= idA in the category C(A, A), and f ◦ g ∼
= idB in C(B, B). Two 2-categories C and D are
biequivalent if there is a 2-functor F : C → D which is
1. locally an equivalence, that is for all A, B ∈ ob(C), the functor FA,B : C(A, B) → D(FA, F B) is
an equivalence;
2. surjective up to internal equivalence, that is for all D ∈ ob(D), there exists an object C ∈ ob(C)
such that F C is internally equivalent to D in D.
8.3.2 Translation homomorphisms
Suppose we are given two syntactic translations τ1 , τ2 : E1 ⇉ E2 of second-order equational presentations E1 = (Σ1 , E1 ) and E2 = (Σ2 , E2 ). A syntactic translation homomorphism h: τ1 → τ2 is given
by an N∗ -indexed collection of Σ2 term tuples
M1 :
(i)
(i)
(i)
⊢ h(m
[m1 ], . . . , M k : [mk ] Â x 1 , . . . , x m
i
∗
1 ,...,mk ) i∈kkk (m1 ,...,mk )∈N
,
such that, for all terms M1 : [m1 ], . . . , M k : [mk ] Â x 1 , . . . , x n ⊢ t of Σ1 , the diagram
(m1 , . . . , mk )
(i)
[h(m
1 ,...,mk )
]E2
〈[τ1 (t)]E2 〉
?
(n)
i∈kkk
- (m , . . . , m )
1
k
〈[τ2 (t)]E2 〉
〈[h(n) ]E2 〉
?
- (n)
commutes in the classifying category M(E2 ) of the presentation E2 . Note that this commutativity
condition can be expressed syntactically via substitution and metasubstitution, but we shall not go
into these explicit details here.
Remark 8.16. The choice of the terminology homomorphism for morphisms of syntactic translations
is no coincidence. We observed in Section 7.5 that syntactic translations can be thought of as
syntactic models of equational presentations in equational presentations. Therefore, an appropriate
notion of morphism should commute with the syntactic model structures; more precisely, with the
terms defining the mappings of translations.
A syntactic translation homomorphism is the appropriate formalisation of the notion of morphism
between second-order syntactic translations. Indeed, for equational presentations E1 and E2 , we
obtain the category Trans(E1 , E2 ) with objects second-order syntactic translations E1 → E2 , and
morphisms given by translation homomorphisms.
123
CHAPTER 8. CONCLUDING REMARKS
Proposition 8.17. The category Trans(E1 , E2 ) is equivalent to the category AlgTrans(ME1 , ME2 ) whose
objects are algebraic translations between the classifying algebraic theories ME1 : M → M(E1 ) and
ME2 : M → M(E2 ), and whose morphisms are natural transformations.
Moreover, we obtain a 2-categorical structure over second-order equational presentations (0-cells),
syntactic translations (1-cells), and their homomorphisms (2-cells). We denote the resulting 2category by SOEP. Using the previous Proposition, together with the Second-Order Syntactic Categorical Type Theory Correspondence (Theorem 6.6), we obtain the following fundamental result.
Theorem 8.18 (2-Categorical Type Theory Correspondence). The 2-categories SOAT and SOEP
are biequivalent.
8.4 Future Directions
We discuss two directions for future research. The first of these proposals is to extend the categorical algebra framework further beyond the second-order universe to include type dependency. The
second is to develop a unified mathematical framework for theories of translations.
8.4.1 Dependently-sorted algebraic theories
We advocate the following general methodology for investigating categorical algebraic frameworks
for syntactic equational presentations T :
1. Construct the base category representing the elementary theory of equality corresponding to
T . Morphisms of that category are equivalence classes of terms built over the signature of T
excluding its operators.
2. Classify the base category via a universal structure.
3. Define the algebraic theory corresponding to T as a suitable structure-preserving functor from
the base category into a suitably structured category.
4. Define a functorial model to be a structure preserving functor from the algebraic theory to
Set.
In the universe of dependently-sorted syntax, a mathematical formulation of a system of dependent
sorts has already been developed [Jacobs, 1999, Fiore, 2008]. We recall this framework in the firstorder setting.
First-order sort dependency. In dependently-sorted syntax, a variable x : σ may occur in another
sort σ′ (x): sort [Cartmell, 1986]. Formally, one can specify a first-order dependently-sorted signature to be given by:
- a countable sequence of judgements (Γi ⊢ Si )i≥1 such that every (Γn+1 ⊢ Sn+1 ) is derivable
from (Γ1 ⊢ S1 , . . . , Γn ⊢ Sn ); together with
124
8.4. Future Directions
- a countable sequence of operator judgements (∆ i ⊢ Fi )i≥1 such that every (∆ n+1 ⊢ Fn+1 ) is
derivable from (Γi ⊢ Si )i≥1 and (∆1 ⊢ F1 , . . . , ∆ n ⊢ Fn ).
Abstract syntax and model theory for dependently-sorted algebra has been developed by Cartmell
in [Cartmell, 1986] and [Fiore, 2008] (see also [Pitts, 2000] and [Taylor, 1999]). It would be interesting to investigate the combination of these approaches in the view of the aforementioned
methodology to unify them in the context of Lawvere’s framework for categorical algebra.
8.4.2 Towards a unified theory of translations
We believe that the notions of algebraic and syntactic translations between algebraic theories and
equational presentations, respectively, will gain importance in the ever more pressing problem of
organising and relating theories of computations. By a unified theory of translations we mean a
formal mathematical framework which characterises translations and develops their properties and
relationships. For instance, one my want to define an even more general notion of translation which
allows interpreting different algebraic systems in one another. Other developments in this framework
include the following:
- Give concrete descriptions of so-called universal translations, which include notions of initial
and terminal translations and (co)limit constructions on translations.
- In particular, and because of the essentially (co)cartesian structure of algebraic systems, develop a concrete notion of product and coproduct of translations. Moreover, one may investigate the structure of tensor products of syntactic translations.
- One may seek general criteria for achieving certain canonical relationships amongst algebraic
systems, such as inclusions, equivalences, and conservative extensions.
125
CHAPTER 8. CONCLUDING REMARKS
126
Bibliography
[Aczel, 1978] Aczel, P. (1978). A general church-rosser theorem. Typescript.
[Aczel, 1980] Aczel, P. (1980). Frege structures and the notion of proposition, truth and set. In The
Kleene Symposium, pages 31–59.
[Adamek et al., 2009] Adamek, J., Rosicky, J., and Vitale, E. (2009).
Algebraic theories: A
categorical introduction to general algebra. Monograph, available from http://www.iti.cs.tubs.de/ adamek/adamek.html.
[Birkhoff, 1935] Birkhoff, G. (1935). On the structure of abstract algebras. Proceedings of the
Cambridge Philosophical Society, 31:433–454.
[Borceux, 1994] Borceux, F. (1994). Handbook of Categorical Algebra 1 and 2, volume 51 of Encyclopedia of Mathematics and its Applications. Cambridge University Press.
[Burstall, 1969] Burstall, R. (1969). Proving properties of programs by structural induction. The
Computer Journal, 12(1):41–48.
[Cartmell, 1986] Cartmell, J. (1986). Generalised algebraic theories and contextual categories.
Annals of Pure and Applied Logic, 32:209–243.
[Church, 1936] Church, A. (1936). An unsolvable problem of elementary number theory. American
Journal of Mathematics, 58:354–363.
[Church, 1940] Church, A. (1940). A formulation of the simple theory of types. Journal of Symbolic
Logic, 5:56–68.
[Cohn, 1965] Cohn, P. (1965). Universal Algebra. Harper & Row.
[Fiore, 2008] Fiore, M. (2008). Second-order and dependently-sorted abstract syntax. In LICS
2008, pages 57–68.
[Fiore and Hur, 2007] Fiore, M. and Hur, C.-K. (2007). Equational systems and free constructions.
In ICALP 2007.
[Fiore and Hur, 2008a] Fiore, M. and Hur, C.-K. (2008a). On the construction of free algebras for
equational systems. Theoretical Computer Science, 410:1704–1729.
127
BIBLIOGRAPHY
[Fiore and Hur, 2008b] Fiore, M. and Hur, C.-K. (2008b). Term equational systems and logics. In
MFPS XXIV, pages 171–192.
[Fiore and Hur, 2010] Fiore, M. and Hur, C.-K. (2010). Second-order equational logic. In CSL 2010.
[Fiore and Mahmoud, 2010] Fiore, M. and Mahmoud, O. (2010). Second-order algebraic theories.
In MFPS 2010, volume 6281 of Lecture Notes in Computer Science, pages 368–380.
[Fiore et al., 1999] Fiore, M., Plotkin, G., and Turi, D. (1999). Abstract syntax with variable binding. In LICS 1999, pages 193–202.
[Fujiwara, 1959] Fujiwara, T. (1959). On mappings between algebraic systems. Osaka Mathematical Journal, 11:153–172.
[Fujiwara, 1960] Fujiwara, T. (1960). On mappings between algebraic systems, ii. Osaka Mathematical Journal, 12:253–268.
[Gabbay and Pitts, 2001] Gabbay, M. J. and Pitts, A. M. (2001). A new approach to abstract syntax
with variable binding. Formal Aspects of Computing, 13:341–363.
[Goguen et al., 1978] Goguen, J., Thatcher, J., and Wagner, E. (1978). An initial algebra approach
to the specification, correctness and implementation of abstract data types. In Current Trends in
Programming Methodology, volume IV, pages 80–149. Prentice Hall.
[Goguen, 1991] Goguen, J. A. (1991). A categorical manifesto. In Mathematical Structures in
Computer Science, pages 49–67.
[Goguen and Burstall, 1984a] Goguen, J. A. and Burstall, R. M. (1984a). Some fundamental algebraic tools for the semantics of computation: Part i: Comma categories, colimits, signatures and
theories. Theoretical Computer Science, 31(1-2):175–209.
[Goguen and Burstall, 1984b] Goguen, J. A. and Burstall, R. M. (1984b). Some fundamental algebraic tools for the semantics of computation: Part ii: Signed and abstract theories. Theoretical
Computer Science, 31(3):263–295.
[Hamana, 2005] Hamana, M. (2005). Free σ-monoids: A higher-order syntax with metavariables.
In APLAS 2004, pages 348–363.
[Hyland and Power, 2007] Hyland, M. and Power, J. (2007). The category theoretic understanding
of universal algebra: Lawvere theories and monads. In ENTCS, volume 172, pages 437–458.
[Jacobs, 1999] Jacobs, B. (1999). Categorical Logic and Type Theory, volume 141 of Studies in Logic
and the Foundations of Mathematics. Elsevier.
[Klop, 1980] Klop, J. (1980). Combinatory reduction systems. PhD Thesis, Mathematical Centre
Tracts 127, CWI, Amsterdam.
128
Bibliography
[Klop et al., 1993] Klop, J., van Oostrom, V., and van Raamsdonk, F. (1993). Combinatory reduction
systems: introduction and survey. Theoretical Computer Science, 121:279–308.
[Knuth and Bendix, 1970] Knuth, D. and Bendix, P. (1970). Simple word problems in universal
algebras. In Computational Problems in Abstract Algebra, pages 263–197.
[Lawvere, 2004] Lawvere, F. W. (2004). Functorial semantics of algebraic theories. Republished in:
Reprints in TAC.
[MacLane, 1998] MacLane, S. (1998). Categories for the Working Mathematician, volume 5 of Graduate Texts in Mathematics. Springer.
[MacLane and Moerdijk, 1992] MacLane, S. and Moerdijk, I. (1992). Sheaves in Geometry and
Logic: A First Introduction to Topos Theory. Springer Verlag.
[McCarthy, 1963] McCarthy, J. (1963). Towards a mathematical science of computation. In IFIP
Congress 1962. North-Holland.
[Pfenning and Elliott, 1988] Pfenning, F. and Elliott, C. (1988). Higher-order abstract syntax. In
Proceedings of the ACM SIGPLAN PLDI, pages 199–208.
[Pitts, 2000] Pitts, A. M. (2000). Categorical logic. In Handbook of Logic in Computer Science,
Volume 5. Algebraic and Logical Structures, chapter 2, pages 39–128. Oxford University Press.
[Plotkin, 1998] Plotkin, G. (1998). Binding algebras: A step from universal algebra to type theory.
Invited talk at RTA-98.
[Street, 1972] Street, R. (1972). The formal theory of monads. Journal of Pure and Applied Algebra,
2(2):149–168.
[Tarlecki et al., 1991] Tarlecki, A., Burstall, R. M., and Goguen, J. A. (1991). Some fundamental
algebraic tools for the semantics of computation: Part 3. indexed categories. Theoretical Computer
Science, 91(2):239–264.
[Taylor, 1999] Taylor, P. (1999). Practical Foundations of Mathematics, volume 59 of Cambridge
Studies in Advanced Mathematics. Cambridge University Press.
[van Raamsdonk, 2003] van Raamsdonk, F. (2003). Higher-order rewriting. In Term Rewriting
Systems, volume 55 of Cambridge Tracts in Theoretical Computer Science, pages 588–667.
[Vidal and Tur, 2008] Vidal, J. C. and Tur, J. S. (2008). On the morphisms and transformations of
tsuyoshi fujiwara. Unpublished notes, available from http://www.uv.es/jkliment/Documentos/.
129
BIBLIOGRAPHY
130
Was this manual useful for you? yes no
Thank you for your participation!

* Your assessment is very important for improving the work of artificial intelligence, which forms the content of this project

Download PDF

advertising