**JB:** Okay, let’s talk more about how to do first-order classical logic using some category theory. We’ve already got the scaffolding set up: we’re looking at functors

You can think of as a set of predicates whose free variables are chosen from the set *S*. The fact that *B* is a functor captures our ability to substitute variables, or in other words rename them.

But now we want to get existential and universal quantifiers into the game. And we do this using a great idea of Lawvere: *quantifiers are adjoints to substitution*.

To understand this, first notice that a Boolean algebra is a special case of a partially ordered set, or poset for short: if *P, Q* are two elements of our Boolean algebra and *P* implies *Q*, we can write , and this is a partial order: it’s reflexive, transitive and antisymmetric.

Second, notice that a poset is a special case of a category. Given a poset, we get a category whose objects are the elements of our poset, there exists a unique morphism from *P* to *Q* if , and there is no morphism from *P* to *Q* otherwise.

We could digress and say exactly *which* categories come from posets this way, and then exactly *which* categories come from Boolean algebras. If this were a course on category theory I’d do it. But we don’t need this now, so I won’t: if you care, you can look it up by clicking on some of the links I’ve offered. Let’s plunge ahead.

Given two categories *C* and *D*, we can talk about things called functors . In fact we’ve already been talking about them! But when *C* and *D* are posets, a functor boils down to something simple, namely the usual sort of map between posets, a **monotone map**, meaning a function such that

In particular, any homomorphism of Boolean algebras is a monotone map, so we can think of it as a functor.

Are you with me? We’ve got functors running all over the place now. We’ve got a functor

so for any function we get a homomorphism of Boolean algebras

But now we’ve revealed that is itself a functor! Okay? I want to start doing things with this functor, but I can’t tell if I’m going too fast or too slow.

**MW:** Just right! Let’s look at a special case, just to make sure.

Category theorists like to use *n* to stand for their favorite *n*-element set. Let 2 stand for the set {*x*,*y*}, so 2 is an object in FinSet. Let 3 be {*x*,*y*,*z*}. Hmm, I want to think about our two chief examples of Boolean algebras: (a) equivalence classes of formulas; (b) relations in a structure. That would mean we have *two* functors from FinSet to BoolAlg, say *B*_{form} and *B*_{rel}. For the moment let *B* = *B*_{form}. And just to be really specific, let’s say our theory is DLO, dense linear orderings without endpoints. (When we get to *B*_{rel}, we’ll look at .)

So *B*(2) is the set of things like [*x*<*y*] and [¬*x*=*y*] and even [∃*z*(*x*<*z*<*y*)], where the brackets mean “equivalence class”. Thus [*x*<*y*] and [∃*z*(*x*<*z*<*y*)] are the same, since DLO proves that the two formulas are equivalent. Also *x*<*y* implies ¬*x*=*y*, which means that [*x*<*y*]≤[¬*x*=*y*].

*B*(3) contains things like [*x*<*z*<*y*]. Let’s look at two morphisms in FinSet: *f*:{*x*,*y*}→{*x*,*y*,*z*} and *g*:{*x*,*y*,*z*}→{*x*,*y*}. I’ll let *f* be the obvious inclusion map, while *g* is a surjection; we’ll decide later which one.

*B*(*f*) maps *B*(2) to *B*(3). A class like [*x*<*y*] gets sent to an equivalence class of formulas with the three free variables *x*,*y*, and *z*. Now we could be really cool and pretend that *z* is present in *x*<*y*. (“There it is, don’t you see it? Do you need a new pair of glasses?”) Or we could take pity on the reader, and note that is logically equivalent to *x*<*y*.

You want me to notice that *B*(2) and *B*(3) are both categories, of a rather particular kind; also *B*(*f*), as a Boolean algebra homomorphism, is a functor between these categories.

OK, full steam ahead!

**JB:** Thanks for bringing up *both* flavors of example: the more syntactic examples where each Boolean algebra consists of equivalence classes of formulas, and the more semantic examples where is some Boolean algebra of subsets of for some set It’s good to gain intuition from *both*.

Full steam ahead! If you’ve got a functor between categories, a **right adjoint** of is a functor going back, , such that there’s a natural isomorphism

for all This means there’s a natural one-to-one correspondence between morphisms and morphisms

Luckily, we don’t need to think about what ‘natural’ means when *C* and *D* are posets, which is the case we care about now. When a category is a poset, there’s *at most one* morphism from any object to any other. So when *C* and *D* are posets, saying there’s a natural one-to-correspondence between morphisms and morphisms is just saying

There is a morphism iff there is a morphism .

But remember: in a poset we denote the existence of a morphism by ≤. So, we’re just saying

iff .

And remember, *L* and *R*, being functors between mere posets, are called ‘monotone maps’.

Okay, now let’s do something serious. Let’s take a functor

and suppose that for each function , the monotone map

has a right adjoint! Let’s see what this does for us.

Let’s start by looking at a function *f* that’s not surjective. The most important non-surjective function is the unique function from the empty set to a 1-element set. But this is case is confusingly simple, so let’s try a function from a 1-element set to a 2-element set. Let’s take the function

sending *x* to itself.

And let’s suppose our Boolean algebra consists of equivalence classes of formulas, like you were considering. But I won’t keep keep saying ‘equivalence’ classes”, because it gets tiresome; I’ll just call these equivalence classes ‘predicates’ if you don’t mind. We’ve already seen that

sends any predicate in the variable *x* to the same predicate *thought of as a predicate in the variables x and y*. So, it doesn’t do much, at least not visibly.

But now let’s suppose has a right adjoint! This right adjoint will turn any predicate in the variables *x* and *y* into some predicate in just the variable *x*.

*How?* What is ? We can figure it out!

By the definition of right adjoint we know that

iff

for any predicate in . Note at left is being thought of as a predicate in in the variables *x* and *y*: we have silently applied to it. Luckily, only pedants need care.

Can you figure out what must be?

**MW:** Universal quantification. That is, . If *P*(*x*) implies *G*(*x*,*y*) regardless of the value of *y*, then *P*(*x*) implies , and vice versa.

This also makes sense if you think about relations, i.e., *B*_{rel}. Here *B*(*f*) propagates truth-values up along the y-axis, so *B*(*f*) applied to *P* results in a bunch of columns entirely true or entirely false. (This must be where Tarski’s term “cylindric algebra” originates.) This columnized *P* is a subset of *G* if and only if the original *P* is a subset of what you get by squashing *G* flat, using the rule that *all* points in a *G*-column must be true for the squashed-flat point (under the column) to be true.

So of course the left adjoint must be existential quantification. Now we want

iff

Thinking about *B*_{rel} makes this obvious: just change the “squashing” rule to make the point under the column true if a single point in the column is true. From the standpoint of *B*_{form}, this fits right in with an inference rule sometimes found in formal treatments of predicate logic: from , infer *G*(*x*,*c*), where *c* is a newly introduced constant. (Of course we see this mode of reasoning all the time in regular mathematics: “By the lemma, there is a weakly socratic number larger than *x*, let’s call it *c*.”)

OK, guess it’s time to look at a surjection, say *g*:{*x*,*y*}→{*x*}.

**JB:** Okay. But first let me pound the pulpit and loudly repeat the moral: *universal quantifiers are right adjoints, existential quantifiers are left adjoints*. In words:

implies

iff

implies

and

implies

iff

implies .

I can imagine nonexperts in logic being freaked out by these rules, because of how the variable *y* switches from being free to bound, so I should assure them that this is ordinary classical logic, not some weird category-theorist’s version. It might help them to imagine an implicit universal quantifier in front of all unbound variables, so if I just walk up to you and blurt out “*G*(*x*,*y*) implies *P*(*x*),” I mean this is true for all *x* and all *y*. It’s clear then that this is equivalent to saying “∃*y* *G*(*x*,*y*) implies *P*(*x*)”.

It might also help to think of *P* and *G* as functions taking values in the poset of truth values, , and restate the above rules as

iff

and

iff

Again, when I say , what I mean is that this is true for all *x* and all *y*.

This is what you were getting at when you spoke of “propagating truth-values up along the y-axis” and the like. We can think of *P* as a vector of truth values, and *G* as a matrix of truth values. We can turn *P* into a matrix that’s constant on columns by treating *P*(*x*) as a function of *x* and *y* that happens to not depend on *y*. On the other hand, we can turn *G* into a vector in two ways. The left adjoint way gives the vector ∃*y* *G*(*x*,*y*), while right adjoint way gives ∀*y* *G*(*x*,*y*).

You recalled two kinds of functors *B*: FinSet → BoolAlg: the ‘syntactic’ kind *B*_{form}, and the ‘semantic’ kind *B*_{rel}. This makes me want to emphasize that there’s not a big difference between these examples: the main difference is our *attitude* towards them, and our *terminology*.

For example, let’s take the ‘semantic’ example I’ve just been discussing, where

for some set . We can also think of this example more ‘syntactically’. We can make up a language with one *n*-ary formula for each element of *B*_{rel}(*n*), and define all the Boolean operations on these formulas in the obvious way, e.g. by decreeing whenever and take the value on the exact same subset of *V*^{3}. (So, in the end, our Boolean algebra consists of equivalence classes of formulas, which I’m calling ‘predicates’.)

Okay—full steam ahead! Having looked at a function that’s an injection but not a surjection, it’s time to look at a function that’s a surjection but not an injection.

The simplest example is the one you described. Category theorists would call it the unique function from 2 to 1, but let’s call it

.

First let’s think a minute about

.

This takes any predicate *P*(*x*,*y*) and maps it to *P*(*x*,*x*).

So, what would a right adjoint of *B*(*g*) be like? It would need to map any predicate *G*(*x*) to a predicate *H*(*x*,*y*) such that

iff

for all predicates *P*(*x*,*y*).

What must *H*(*x*,*y*) be, to make this true? It must be cooked up from *G*(*x*) somehow.

**MW:** Before answering that, I want to elaborate on the “semantics to syntax” conversion you sketched. You can take it one step further: given a structure *M* for a language *L*, introduce names (i.e., constants) for all elements in the domain of *M*. Then *all* information about *M* can be translated into syntax. Logicians call this the “method of diagrams”; it became a powerful tool in the hands of Abraham Robinson and others.

For example, if a formula is universal (a string of universal quantifiers in front of a quantifier-free formula), then it’s downwards absolute: “as above, so below”. Using the method of diagrams, you can show the converse: any downwards absolute formula is equivalent to a universal one. (This is just an outline—for a precise statement, consult the textbooks.)

OK, surjections. For the right adjoint, assume that . Then we must have . Next we make use of a fact about Boolean algebras: if and only if . This gives . We can run the whole argument in reverse, too, so we get

iff

This is our right adjoint!

Next let’s figure out the left adjoint. We want to find *H* such that

iff

To get *H*, we just copy *G* “along the diagonal”. As a predicate:

*H*(*x*,*y*) ≡ *G*(*x*) ˄ *x*=*y*

This reminds me of the meaning of “qualified quantifiers”, like (∀*x*<*y*)φ(*x*) and (∃*x*<*y*)φ(*x*). For the existential case, we explicate this using a conjunction: ∃*x*[*x*<*y ˄ *φ(*x*)]. For the universal case, we use an implication: ∀*x*[*x*<*y → *φ(*x*)].

**JB:** Thanks for explaining the method of diagrams! When we really get rolling into original research, we should find some slick category-theoretic way to say what it does.

And now, let celebrate: *Hurrah!* We’ve gotten equality to emerge from thin air, by demanding that our Boolean algebra homomorphism *B*(*g*) has a right and left adjoint!

The right adjoint gives

iff .

while the left adjoint gives

iff

So quantifiers and equality are not merely things our ancestors stuck into the predicate calculus because they were so very wise: these concepts arise automatically from some general principles!

The appearance of the implication or ‘material conditional’ when we do the right adjoint and the conjunction when we do the left adjoint can’t be an accident. Any element *p* of a Boolean algebra *B* gives an operation on *B*

.

This is a functor from *B* to itself, and it has a right adjoint that does this:

This is easy to check: it just says that

iff

So, serious categorical logicians say *implication is right adjoint to conjunction*. We skipped over a whole mini-course where I’d motivate Boolean algebras—and the more general Heyting algebras, which are the generalization of Boolean algebras to intuitionistic logic—starting from category theory. I wanted to get straight to the predicate calculus, so I decided to take propositional calculus for granted! But the way implication shows up as a right adjoint is very nice.

I’m not quite sure how this connects to what you just said about “qualified quantifiers”, but it must be related. Indeed you used it in your argument.

**MW:** Hmm, and here’s another thing: the injection *f* we just looked at is a right inverse to *g*. I wonder if that shakes loose anything interesting.

**JB:** Wow! Nice idea! I think it does.

If *f*, *g* are monotone maps of posets that have right adjoints, say *f** and *g**, then the composite *gf*, if it exists, will also have a right adjoint (*gf*)*, given by

(*gf*)* = *f** *g** .

This is absurdly easy to see straight from the definition of adjoint I gave earlier—the definition in the case of posets.

So your observation definitely *does* shake something loose. In our example *gf* is the identity, so the right adjoint of *gf* must be the right adjoint of the identity, which—as you can easily check—is the identity! So, it must be that *f** *g** is the identity.

What does it mean, concretely, to say that the right adjoint of *g*, followed by the right adjoint of *f*, gets us back to where we started? It should be some law of logic involving equality and universal quantifiers!

**MW:** As it’s time to walk the dog, this will have to wait for the next post. Maybe I’ll try explaining it to him!

**JB:** I think cats are better at category theory: dogs are too dogmatic. But let me know how it goes.