Introduction To Categorical Logic: Steven Awodey Andrej Bauer September 14, 2009
Introduction To Categorical Logic: Steven Awodey Andrej Bauer September 14, 2009
Introduction To Categorical Logic: Steven Awodey Andrej Bauer September 14, 2009
Steven Awodey
Andrej Bauer
Contents
1 Algebraic Theories
1.1 Algebraic Theories . . . . . . . . . .
1.1.1 Models of Algebraic Theories
1.1.2 Theories as categories . . . .
1.1.3 Models as Functors . . . . . .
1.1.4 Completeness . . . . . . . . .
1.1.5 Functorial Semantics . . . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
.
5
5
8
12
13
18
21
CONTENTS
Chapter 1
Algebraic Theories
Algebraic theories are descriptions of structures determined by operations and equations.
There are familiar examples from elementary algebra, such as groups, but also many concepts that are not evidently algebraic, such as adjoint functors, can be given algebraic
formulations. Thus the scope of algebraic theories is actually much greater than first appears. On the other hand, all such algebraic notions have in common some quite deep and
general properties, from the existence of free algebras to Lawveres duality theory. The
most important of these are presented in this chapter. The development also serves as a
first example and template for the scheme of functorial semantics, to be applied to other
logical notions in later chapters.
1.1
Algebraic Theories
We begin with a general approach to algebraic structures such as groups, rings, modules,
and lattices. These are characterized by axiomatizations which involve only variables,
constants, operations, and equations. It is important that the operations are defined
everywhere, which excludes two important examples: fields because the inverse of 0 is
undefined, and categories because composition is defined only for some pairs of morphisms.
Let us start with the quintessential algebraic theorythe theory of groups. A group
can be described as a set G with a binary operation : G G G, satisfying the two
axioms:
x, y, z G . (x y) z = x (y z)
e G . x G . y G . (e x = x e = x x y = y x = e)
Taking a closer look at the logical form of these axioms, we see that the second one, which
expresses the existence of a unit and inverse elements, is somewhat unsatisfactory because
it involves nested quantifiers. Not only does this complicate the interpretation, but it is
not really necessary, since the unit element and inverse operation in a group are uniquely
determined. Thus we can add them to the structure and reformulate as follows. We require
[DRAFT: September 14, 2009]
Algebraic Theories
ex=x
x1 x = e
Notice that the universal quantifier x G is no longer needed in stating the axioms,
since we interpret all variables as ranging over all elements of G. Nor do we really need
to explicitly mention the particular set G in the specification. Finally, since the constant
e can be regarded as a nullary operation, i.e., a function e : 1 G, the specification of
the group concept consists solely of operations and equations. This leads us to the general
definition of an algebraic theory.
Definition 1.1.1 A signature for an algebraic theory consists of a family of sets {k }kN .
The elements of k are called the k-ary operations. In particular, the elements of 0 are
the nullary operations or constants.
The terms of a signature are expressions constructed inductively by the following
rules:
1. variables x, y, z, . . . , are terms,
2. if t1 , . . . , tk are terms and f k is a k-ary operation then f (t1 , . . . , tk ) is a term.
Definition 1.1.2 (cf. Definition ??) An algebraic theory T = (T , AT ) is given by a
signature T and a set AT of axioms, which are equations between terms (formally, pairs
of terms).
Algebraic theories are also called equational theories.
Example 1.1.3 The theory of a commutative ring with unit is an algebraic theory. There
are two nullary operations (constants) 0 and 1, a unary operation , and two binary
operations + and . The equations are:
(x + y) + z = x + (y + z)
x+0=x
0+x=x
x + (x) = 0
(x) + x = 0
x+y =y+x
(x y) z = x (y z)
x1=x
1x=x
(x + y) z = x z + y z
z (x + y) = z x + z y
xy =yx
Example 1.1.4 The empty theory with no operations and no equations is the theory
of a set.
[DRAFT: September 14, 2009]
Example 1.1.5 The theory with one constant and no equations is the theory of a pointed
set, cf. Example ??.
Example 1.1.6 Let R be a ring. There is an algebraic theory of left R-modules. It has
one constant 0, a unary operation , a binary operation +, and for each a R a unary
operation a, called scalar multiplication by a. The following equations hold:
(x + y) + z = x + (y + z) ,
x+0=x,
x + (x) = 0 ,
x+y =y+x,
0+x=x,
(x) + x = 0 .
a(b x) = (ab) x ,
(a + b) x = a x + b x .
Algebraic Theories
1.1.1
Let us now consider what a model of an algebraic theory is. In classical algebra, a group is
given by a set G, an element e G, a function m : G G G and a function i : G G,
satisfying the group axioms:
m:GGG,
i:GG.
m 2
0 m
GG
(1.1)
m
GG
/G
[DRAFT: September 14, 2009]
Similarly, the axioms for the unit and the inverse are expressed by commutativity of the
following diagrams:
1G e
e 1G
GGo
v1G
HH
vv
HH
v
HH
vv
HH
vv
v
m vvv
0 HHHHH
1
v
HH
vv
v
H# {vv
G 1 HH
h1G , ii
!G
hi, 1G i
/GGo
(1.2)
!G
Go
Moreover, this formulation makes sense in any category C with finite products. So we can
define a group in C to consist of an object G equipped with arrows:
m
GG
GO o
e
1
such that the above diagrams (1.1) and (1.2) expressing the group equations commute.
There is also an obvious corresponding generalization of a group homomorphism in Set
to homomorphisms of groups in C. Namely, an arrow in C between groups h : M N is a
homomorphism if it commutes with the interpretations of the basic operations m, i, and e,
h mM = mN h2
h iM = iN h
h eM = eN
as indicated in:
M2
mM
h2 / 2
N
mN
M
iM
h /
N
iN
/N
eM
= /
1
eN
Together with the evident composition and identity arrows inherited from C, this gives a
category of groups in C which we denote:
Group(C)
In general, we define an interpretation I of a theory T in a category C with finite
products to consist of an object I C and, for each basic operation f of arity k, a
morphism f I : I k I. (More formally, I is the tuple consisting of an underlying set
|I| and the interpretations f I , but we shall write simply I for |I|.) In particular, basic
constants are interpreted as morphisms 1 I. The interpretation can be extended to all
terms as follows: a general term t is always interpreted together with a context of variables
x1 , . . . , xn , where the variables appearing in t are among the variables appearing in the
context. We write
x1 , . . . , x n | t
(1.3)
[DRAFT: September 14, 2009]
10
Algebraic Theories
uI = v I .
hk / k
N
fN
N
[DRAFT: September 14, 2009]
11
12
1.1.2
Algebraic Theories
Theories as categories
x1 = x e ,
x y = (x e) (y e) .
There may be various reasons why we prefer to work with one formulation of group theory
rather than another, but this should not be reflected in the general idea of what a group
is. We want to avoid particular choices of basic constants, operations, and axioms. This is
akin to the situation where an algebra is presented by generators and relations: the algebra
itself is regarded as independent of any particular choice of presentation. Similarly, one
usually prefers a basis-free theory of vector spaces: it is better to formulate the idea of a
vector space without speaking explicitly of vector bases, even though every vector space
has one. Without a doubt, vector bases are important, but they really are an auxiliary
concept.
As a first step, we could simply take all operations built from unit, multiplication, and
inverse as basic, and all valid equations of group theory as axioms. But we can go a step
further and collect all the operations into a category, thus forgetting about which ones were
basic and which ones derived, and which equalities were axioms. We first describe
this construction of a category CT for a general algebraic theory T, and then determine
another characterization of it.
As objects of CT we take contexts, i.e. sequences of variables,
[x1 , . . . , xn ] .
(n 0)
13
(1 i n)
The identity morphism on [x1 , . . . , xn ] is (x1 , . . . , xn ). It is easy to verify that these specifications are well-defined on equivalence classes, and make CT a category.
Definition 1.1.14 The category CT just defined is called the syntactic category of the
theory T.
The syntactic category CT contains the same algebraic information as the theory T
from which it was built, but in a syntax-invariant way. Any two different presentations
of T like the ones for groups mentioned above will give rise to essentially the same
category CT . But there is also a much more important sense in which CT represents T, as
we next show.
Exercise 1.1.15 Show that the syntactic category CT has all finite products.
1.1.3
Models as Functors
Let T be an arbitrary algebraic theory and CT the syntactic category constructed from
T as in the foregoing section. It is easy to show that the product in CT of two objects
[x1 , . . . , xn ] and [x1 , . . . , xm ] is the object [x1 , . . . , xn+m ], and that CT has all finite products
(including 1 = [], the empty context). Moreover, there is a T-model U in CT consisting
of the language itself: The underlying object is the context U = [x1 ] of length one, and
each operation symbol f of, say, arity k is interpreted as itself,
f U = [ x1 , . . . , xk | f (x1 , . . . , xk ) ] : U k = [x1 , . . . , xk ] [x1 ] = U.
The axioms are of course all satisfied, since for any terms s, t:
U |= s = t sU = tU T ` s = t.
(1.5)
This syntactic model U in CT is universal in the following sense: any model M in any
category C with finite products is the image of U under an essentially unique, finite product
[DRAFT: September 14, 2009]
14
Algebraic Theories
preserving functor CT C. In a certain sense, then, CT is the free finite product category
with a model of T. We now proceed to make this more precise.
First, observe that any FP-functor F : CT C takes U to a model F U in C, just
because FP-functors preserve models of algebraic theories, as is easily seen. Moreover, any
natural transformation : F G between FP-functors determines a homomorphism of
models h = U : F U GU , since clearly, for any basic operation f ,
h f F U = f GU hk
by naturality. In more detail, suppose f : U U U is a basic operation, then there is a
commutative diagram,
FU FU
hh
/
GU GU
fFU
F (U U )
=
U U
Ff
G(U U )
f GU
Gf
FU
h = U
/ GU
where the upper square commutes by preservation of products, and the lower one by
naturality. Thus the operation evaluation at U determines a functor,
evalU : HomFP (CT , C) Mod(T, C)
(1.6)
from the category of finite product preserving functors CT C, with natural transformations as arrows, into the category of T-models in C.
Proposition 1.1.16 The functor (1.6) is an equivalence of categories, natural in C.
Proof. Let M be any model in an FP-category C. Then the assignment f 7 f M given
by the interpretation determines a functor M ] : CT C, defined on objects by
M ] [x1 , . . . , xk ] = M k
and on morphisms by
M ] (t1 , . . . , tn ) = ht1 M , . . . , tn M i.
In detail, M ] is defined on morphisms
[x1 , . . . , xk | t ] : [x1 , . . . , xk ] [x1 , . . . , xn ]
in CT by the following rules:
[DRAFT: September 14, 2009]
15
1. The morphism
(xi ) : [x1 , . . . , xk ] [x1 ]
is mapped to the i-th projection
i : M k M.
2. The morphism
(f (t1 , . . . , tm )) : [x1 , . . . , xk ] [x1 ]
is mapped to the composite
M ] t1 , . . . , M ] tm
/
M ]f
/M
(1.7)
16
Algebraic Theories
Mod(T, F )
HomFP (CT , D)
evalU
Mod(T, C)
= Mod(T, F )(evalU (M ))
= Mod(T, F ) evalU (M ).
(1.9)
17
V]
U
the composites of which are necessarily isomorphic to the respective identity functors, since
e.g. U ] (V ] (U ))
= U ] (V )
= U.
We have now shown not only that every algebraic theory has a classifying category, but
also that the syntactic category is essentially determined by that distinguishing property.
We record this as the following.
Theorem 1.1.19 Every algebraic theory T has the syntactic category CT as a classifying
category.
Example 1.1.20 Let us see what the foregoing definitions give us in the case of group
theory G = TGroup . Recall that the category G consists of contexts [x1 , . . . , xn ] and terms
built from variables and the basic group operations. A finite product preserving functor
M : G Set is then determined up to natural isomorphism by its action on the context [x1 ]
and the terms representing the basic operations. If we set
G = M [x1 ] ,
i = M (x1 | x1 1 ) ,
e = M ( | e) ,
m = M (x1 , x2 | x1 x2 ) ,
then (G, e, i, m) is a just a group with unit e, inverse i and multiplication m. That G
satisfies the axioms for groups follows from functoriality of M . Conversely, any group
(G, e, i, m) determines a finite product preserving functor MG : G Set defined by
MG [x1 , . . . , xn ] = Gn ,
MG (x1 | x1 1 ) = i ,
[DRAFT: September 14, 2009]
MG ( | e) ,
MG (x1 , x2 | x1 x2 ) = m .
18
Algebraic Theories
This shows that ModSet (G) is indeed equivalent to Group, provided both categories have
the same notion of morphisms.
Suppose then that (G, eG , iG , mG ) and (H, eH , iH , mH ) are groups, and let : MG =
MH be a natural transformation between the corresponding functors. Then is already
determined by its component at [x1 ] because by naturality the following diagram commutes,
for 1 k n:
[x1 ,...,xn ]
/ Hn
Gn
Gk = k
Hk = k
[x1 ]
0 0 /
H H
mG
mh
Similar commutative squares show that 0 preserves the unit and commutes with the inverse
operation, therefore 0 : G H is indeed a group homomorphism. Conversely, a group
homomorphism 0 : G H determines a natural transformation : G = H whose
component at [x1 , . . . , xn ] is the n-fold product 0 0 : Gn H n . This demonstrates
that
ModSet (G) ' Group .
Example 1.1.21 Recall from ??that a group G in the functor category SetC is essentially
the same thing as a functor G : C Group. From the point of view of algebras as functors,
this amounts to the observation that product-preserving functors G Hom(C, Set) correspond (by exponential transposition) to functors C HomF P (G, Set), where the latter
Hom-set consists just of product-preserving functors. Indeed, the correspondence extends
to natural transformations to give an equivalance of categories,
Group(SetC ) ' (Group(Set))C ' GroupC .
1.1.4
Completeness
19
satisfies the equation; this is just the soundness of the equational calculus with respect to
models in categories. The converse statement is:
Every model of T satisfies s = t. T proves equation s = t. .
This property is called completeness, and (together with soundness) it says that the calculus
of equations suffices for proving all (and only) the ones that hold in the semantics. This
holds in an especially strong sense for categorical semantics, as shown by the following.
Theorem 1.1.22 (Completeness for algebraic theories) Suppose T is an algebraic
theory. Then there exists an FP- category C and a model U ModC (T) with the property
that, for every equation s = t between terms of the theory T,
U |= s = t T ` s = t.
That is, satisfaction by U is equivalent to provability in T. Thus the equational calculus of
algebraic theories is complete with respect to general categorical semantics.
Proof. This follows from the classifying category theorem 1.1.19 as follows: Let C = CT
the classifying category and U the universal model. If T ` s = t, then by the syntactic
construction of CT we have sU = tU . Any model M in an FP-category C has a classifying
functor M ] : CT C, which preserves the interpretations of s and t in the sense that (up
to canonical isomorphism):
]
M ] (sU ) = sM (U ) = sM
and similarly for t. Thus from sU = tU we can infer sM = tM , i.e. M |= s = t.
Conversely, if U |= s = t, then sU = tU . But by the syntactic construction of CT , it
then must be the case that T ` s = t.
Finally, note that M |= s = t for every model M if and only if this holds in the universal
model U .
Definition 1.1.23 A single model with the property mentioned in the theorem, of satisfying all and only those equations that are provable from the theory, shall be said to be
logically generic.
Thus, by the foregoing, the universal model is logically generic. Classically, it is seldom
the case that there exists a single, logically generic model; instead, for the sake of completeness, we consider the range of all models in Set. Completeness with respect to a restricted
range of models is of course a stronger statement than general completeness. Toward this
classical result, we first consider completeness with respect to variable models in Set, i.e.
op
models in presheaf categories SetC .
Proposition 1.1.24 Let T be an algebraic theory. The Yoneda embedding
cT
y : CT C
is a generic model for T.
20
Algebraic Theories
Proof. Consider the evaluation functors evC : SetC Set for all C C. These are
clearly jointly faithful, and they preserve all limits and colimits, since these are constructed
pointwise in presheaves.
Proposition 1.1.27 Suppose T is an algebraic theory. For every equation s = t between
terms of the theory T,
M |= s = t
Thus the equational calculus of algebraic theories is complete with respect to Set-valued
semantics.
Exercise 1.1.28 The universal group U is a functor Gop Set. In the last example we
described the object part of U . What is the action of U on morphisms?
[DRAFT: September 14, 2009]
21
Exercise 1.1.29 Let s be a term of group theory with variables x1 , . . . , xn . On one hand
we can think of s as an element of the free group Un , and on the other we can consider
the interpretation of s in the universal group U , namely a natural transformation U s :
U n = U . Suppose t is another term of group theory with variables x1 , . . . , xn . Show that
U s = U t if, and only if, s = t in the free group Un .
1.1.5
Functorial Semantics
Let us now summarize our treatment of algebraic theories so far. We have reformulated
the traditional logical notions in terms of algebraic or categorical ones. The traditional
approach to logic may be described as involving four different parts:
Type theory
There is an underlying type theory, which is a calculus of types and terms. For
algebraic theories the calculus of types is trivial, since there is only one type which
is not even explicitly mentioned. The terms are built from variables and basic
operations.
Logic A variety of different kinds of logic can be considered. Algebraic theories have a
very simple kind of logic that only involves equations between terms and equational
reasoning.
Theory
A theory is given by basic types, basic terms, and axioms. The types and the terms
are expressed in the type theory of the system, and the axioms are be expressed in
the logic of the system.
Interpretations and Models
The type theory and logic of a logical system can be interpreted in any category
of the appropriate kind. For algebraic theories we considered categories with finite
products. The interpretation is denotational, in the sense that the types and terms
of the theory are assigned to objects and morphisms (which they denote) by
induction on the structure of types, terms, and logical formulas. An interpretation
of a theory is a model if it satisfies all the axioms of the theory, where in the present
case the notion of satisfaction just means that the arrows interpreting the terms
occurring in the equations are actually equal.
The alternative approach developed here called functorial semantics may be
summarized as follows:
Theories are categories
From a theory we can construct a category which expresses essentially the same
information as the theory but is syntax-invariant, in the sense that it does not depend on a particular presentation by (basic) operations and axioms. The structure
of the category reflects the underlying type theory and logic. For example, single
sorted algebraic theories give rise to categories with finite products.
[DRAFT: September 14, 2009]
22
Algebraic Theories