Lectures onType Theory
Chapter 143
Chapter 143Core route

Categorical Logic, Hyperdoctrines, and Internal Languages

Let X and Y be sets and f:XY a function. A predicate on Y is a subset VY, and substituting f into it produces the predicate f1(V)X. Two further operations turn a predicate on X back into a predicate on Y: f(U):={yYy=f(x) for some xU},f(U):={yYxU for every x with f(x)=y}. Take Y=N, X=N×N, f(m,n)=m, and U={(m,n)mn}. Then f(U)=N, because every m has some n above it, and f(U)=, because no m is below every n. These are the sets denoted by n.mn and n.mn.

The three operations are not independent. For UX and VY, f(U)VUf1(V),f1(V)UVf(U), each of which is checked by expanding both sides on an element. Read the first as a rule of inference: a proof of V from x.U is the same thing as a proof of V from U, in a context where V does not mention x. That is the elimination rule for the existential quantifier, and the side condition “x not free in V” is not a restriction imposed on the rule but the statement that V is a predicate on Y rather than on X.

Equation 143.2 says that f and f are adjoint to f1 in the sense of exercise 142.11: in a preorder an adjunction is exactly a pair of two-way rules. This chapter takes that observation as a definition, proves what it forces, and stops where the proofs stop.

Predicates and reindexing

Fix a set X and let P(X) be its powerset, preordered by inclusion and regarded as a category as in example 142.5: one arrow UU when UU, none otherwise. Meets are intersections, joins are unions, the top element is X and the bottom is . One further operation is needed before any quantifier appears.

Definition 143.1 — Heyting algebra

A Heyting algebra is a preorder H with finite meets , and finite joins , in the sense of example 142.5 and its dual, together with a binary operation satisfying, for all a,b,cH, abca(bc). A homomorphism of Heyting algebras is a monotone map that preserves each of , , , and up to the equivalence of the preorder. We write Heyt for the category of Heyting algebras and homomorphisms.

Equation 143.3 is the statement that ()b(b), so a Heyting algebra is a preorder that is cartesian closed in the sense of definition 142.26 and also has finite joins. Nothing else is assumed: a(a)= is not required and generally fails.

Example 143.2 — The powerset is a Heyting algebra

In P(X) put VW:={xXxV implies xW}, which is (XV)W. For UVW and xU: if xV then xW, so xVW; conversely if UVW and xUV then xW. This algebra is Boolean, since V(V)=V(XV)=X.

Example 143.3 — A Heyting algebra that is not Boolean

Let O(R) be the open subsets of the real line ordered by inclusion, with intersection and union. Both are open, so these are meets and joins. Put VW:=int((RV)W), the largest open set contained in the displayed union; (143.3) holds because an open U is contained in that union exactly when it is contained in its interior. Take V=R{0}. Then V=int{0}=, so V(V)=VR. Excluded middle therefore fails in this algebra, while every clause of definition 143.1 holds.

Proposition 143.4 — Inverse image is a homomorphism

For f:XY the map f:=f1():P(Y)P(X) preserves ,,, and , and idX=idP(X),(gf)=fgfor g:YZ.

Proof of Proposition 143.4 — Inverse image is a homomorphism

Proof. Each clause is an equality of subsets, checked on an element xX. For the meet, xf1(VW) iff f(x)V and f(x)W iff xf1(V)f1(W); joins, and are the same calculation. For implication, xf1(VW)(f(x)V implies f(x)W)(xfV implies xfW), which is xfVfW. For (143.4), x(gf)1(W) iff g(f(x))W iff f(x)g1(W) iff xf1(g1(W)); and idX1(V)=V. ◻

The second equation of (143.4) is an identity of operations, not an isomorphism. It is the same strictness that equation 142.11 demanded of type substitution, and here it holds on the nose because f is defined by a formula rather than by a universal property.

Exercise 143.1

★☆☆ In any Heyting algebra put ¬a:=(a). Prove a¬¬a from (143.3) alone, and exhibit an element of O(R) with ¬¬aa.

Exercise 143.2

★★☆ Show that the direct image f of (143.1) preserves and but need not preserve : take f:{0,1}{} and two disjoint singletons. Which clause of corollary 142.24 explains why f preserves while f need not?

Quantifiers as adjoints

Theorem 143.5 — The powerset quantifiers

Let f:XY. With f and f as in (143.1) and f=f1(), fff as functors between the preorders P(X) and P(Y).

Proof of Theorem 143.5 — The powerset quantifiers

Proof. All three maps are monotone: if UU then every witness for f(U) is one for f(U), every y all of whose preimages lie in U has them all in U, and inverse images preserve inclusion. By exercise 142.11 an adjunction between preorders is exactly the displayed two-way rule, so it suffices to prove (143.2).

First rule. Suppose f(U)V and let xU. Then f(x)f(U) by taking x itself as the witness, so f(x)V, that is, xf1(V). Conversely suppose Uf1(V) and let yf(U), say y=f(x) with xU. Then xf1(V), so y=f(x)V.

Second rule. Suppose f1(V)U and let yV. For every x with f(x)=y we have xf1(V), hence xU; so yf(U). Conversely suppose Vf(U) and let xf1(V). Then f(x)Vf(U), and x is a preimage of f(x), so xU. ◻

Specialize to the projection that discards one variable. Let Γ and A be sets and p:Γ×AΓ the first projection. Then p(V)=V×A adds a dummy variable, and p(U)={g(g,a)U for some aA},p(U)={g(g,a)U for all aA}, so the two-way rules read a.UVUpV,pVUVa.U, each read in both directions. The premise “a does not occur free in V” of the usual -elimination and -introduction rules is carried entirely by the requirement that V be an element of P(Γ).

Proposition 143.6 — Weakening is a right adjoint, hence preserves meets

In any preorder-valued situation with ff, the map f preserves all meets that exist. In particular f()= and f(VW)=fVfW.

Proof of Proposition 143.6 — Weakening is a right adjoint, hence preserves meets

Proof. Theorem 142.23 applied to the adjunction ff: a right adjoint preserves limits, and in a preorder the limits are exactly the meets. Corollary 142.24 names the two instances used. ◻

Lawvere records this consequence in the paper that introduced the notion: “the existence of existential quantification implies that substitution commutes with conjunction; usually substitution does not commute with implication” (Adjointness in Foundations, physical page 12). The powerset is one of the cases where substitution does commute with implication, by proposition 143.4; exercise 143.4 gives a hyperdoctrine where it does not.

Hyperdoctrines

The powerset construction used three facts about Set: it has finite products, so contexts can be formed; each P(X) is a Heyting algebra; and reindexing has both adjoints. One further condition is needed, and it is the condition that makes substitution commute with quantification.

Definition 143.7 — Beck–Chevalley condition

Let C be a category with finite products and P:CopHeyt a functor such that each P(f), written f, has adjoints fff. The Beck–Chevalley condition requires that for every pullback square Mathematical diagramDiagram in C and every φP(B), h(fφ)=g(kφ),h(fφ)=g(kφ).

Definition 143.8 — Hyperdoctrine

A hyperdoctrine is a pair (C,P) where C is a category with finite products and P:CopHeyt is a functor such that for every arrow f of C the homomorphism f has a left adjoint f and a right adjoint f, and the Beck–Chevalley condition (143.6) holds for every pullback square that exists in C.

The base is required to have finite products only. That is enough for the condition to be usable, because the squares the interpretation actually needs are always pullbacks.

Lemma 143.9 — Substitution squares are pullbacks

Let C have finite products, let σ:ΔΓ, and let A be an object. Write p:Γ×AΓ and q:Δ×AΔ for the first projections and σ×idA:=σq,pr2. Then Mathematical diagramDiagram is a pullback square.

Proof of Lemma 143.9 — Substitution squares are pullbacks

Proof. It commutes: pσq,pr2=σq by (142.2). Let u:XΔ and v:XΓ×A satisfy σu=pv, and put m:=u,pr2v:XΔ×A. Then qm=u, and (σ×idA)m=lemma142.2(2)σqm, pr2m=(142.2)σu, pr2v=hyp.pv,pr2v=lemma142.2v. If m also satisfies the two equations then qm=u and pr2m=pr2(σ×idA)m=pr2v, so m=qm,pr2m=m by lemma 142.2(1). ◻

This is the posetal formulation, following Awodey, Introduction to Categorical Logic, Definition 3.4.1 (physical page 176 of the course draft). Lawvere’s original definition, Adjointness in Foundations, physical pages 11–12, is more general in two respects recorded here and not used later: his base T is required to be cartesian closed, and his P(X) is a cartesian closed category of attributes whose arrows are deductions, so that two proofs of the same entailment may differ. Definition 143.8 is the special case in which each P(X) is a preorder, that is, in which entailment is proof-irrelevant, and in which the base is only required to have finite limits. No theorem below is transferred from the proof-relevant setting.

Example 143.10 — The powerset hyperdoctrine

C=Set, which has finite products by example 142.4 and in fact all finite limits by proposition 142.9, and P(X)=P(X) with f=f1(). Proposition 143.4 makes P a functor into Heyt and theorem 143.5 supplies the adjoints; Beck–Chevalley is theorem 143.11 below.

Proof of Theorem 143.11 — Beck–Chevalley in the powerset

Proof. By proposition 142.9 the pullback square may be taken to be D={(c,b)C×Bh(c)=f(b)},g(c,b)=c,k(c,b)=b, since any other pullback of the same pair differs from this one by a unique isomorphism commuting with g and k, and both sides of (143.6) are transported along that isomorphism. Let φB and cC.

Existential clause. ch(fφ)h(c)fφdefinition of hh(c)=f(b) for some bφdefinition of f(c,b)D for some bφdefinition of Dc=g(d) for some dkφdefinitions of g,kcg(kφ)definition of g. The middle step is where the square being a pullback is used: an element of D over c is exactly a b with h(c)=f(b), so the two existential statements have the same witnesses.

Universal clause. ch(fφ) says that every b with f(b)=h(c) lies in φ, and cg(kφ) says that every dD with g(d)=c lies in kφ. The elements d with g(d)=c are the pairs (c,b) with f(b)=h(c), and (c,b)kφ means bφ; so the two statements quantify over the same b and assert the same thing. ◻

Example 143.12 — Beck–Chevalley fails for a commuting square that is not a pullback

Let A={0,1}, B={b}, C={c}, D=, with f(b)=0, h(c)=0, and g,k the empty maps. The square commutes, since both composites have empty domain. Take φ={b}. Then fφ={0} and h(fφ)={c}, whereas kφ= and g()=. So (143.6) fails. The square is not a pullback: the pullback of f along h is {(c,b)}, a one-element set, not . The condition is therefore a condition on pullback squares and not on commuting squares.

Proposition 143.13 — Frobenius

In the powerset hyperdoctrine, for f:XY, UX and VY, f(UfV)=f(U)V.

Proof of Proposition 143.13 — Frobenius

Proof. Let yY. Membership in the left-hand side says: there is x with f(x)=y, xU and f(x)V. Membership in the right-hand side says: there is x with f(x)=y and xU, and moreover yV. Since f(x)=y, the two conditions f(x)V and yV are the same statement, and it does not depend on x; so it may be moved outside the existential quantifier in either direction. ◻

Equation 143.7 is what allows an existential hypothesis to be eliminated in the presence of other hypotheses. Without it, the rule (143.5) discharges a.U only when the ambient context of assumptions is empty.

Exercise 143.3

★★☆ Derive the usual sequent form of -elimination, ΘUpVΘpUV(Θ,VP(Γ), UP(Γ×A)), from (143.5) together with (143.7), and identify the step at which Frobenius is used.

Exercise 143.4

★★★ Let C=Set and let P(X) be the Heyting algebra of O(R)-valued predicates, that is, functions XO(R) ordered pointwise, with the operations of example 143.3 computed pointwise and f(ψ)=ψf. Verify that (C,P) is a hyperdoctrine with f(φ)(y)=f(x)=yφ(x) and f(φ)(y)=intf(x)=yφ(x). Then decide whether f preserves , and give the smallest example that settles it.

Exercise 143.5

★★☆ Specialize (143.6) to the pullback square formed by a map σ:ΔΓ and the projection p:Γ×AΓ, and read the resulting equation as the syntactic law (a.φ)[σ]=a.(φ[σ×idA]). Which arrow of the square is σ×idA?

Equality and comprehension

Equality is not a primitive of definition 143.8. It is constructed from one adjoint at one arrow, the diagonal.

Definition 143.14 — Equality predicate

Let (C,P) be a hyperdoctrine and A an object of C. Let δA:=idA,idA:AA×A be the diagonal. Put EqA:=δA()P(A×A).

Theorem 143.15 — Lawvere's law

For every ρP(A×A), EqAρin P(A×A)δAρin P(A). Consequently EqA is reflexive, in the sense δAEqA, and it is the least reflexive element of P(A×A).

Proof of Theorem 143.15 — Lawvere's law

Proof. Equation 143.8 is the adjunction δAδA read as a two-way rule (exercise 142.11), instantiated at P(A) and ρP(A×A). Reflexivity is the instance ρ:=EqA of the direction from left to right, applied to EqAEqA. If ρ is any reflexive element, the direction from right to left gives EqAρ. ◻

Writing ρ with its two variables displayed, δAρ is ρ(x,x), so (143.8) is the two-way rule x:Aρ(x,x)x:A,y:AEqA(x,y)ρ(x,y) read in both directions: EqA is the least reflexive relation. The upward direction is the introduction rule for equality and the downward direction is substitution of equals, so the elimination rule is not an extra assumption.

Example 143.16 — Equality in the powerset

For a set A, δA(a)=(a,a) and =A, so EqA=δA(A)={(a,a)aA}, the diagonal subset. Reflexivity says AδA1(EqA), which holds because (a,a)EqA; and any ρ containing every (a,a) contains the diagonal.

A predicate carves out a subobject only if the base category has the objects to carve with. That is an extra requirement.

Definition 143.17 — Comprehension

A hyperdoctrine (C,P) has comprehension if for every object Γ and every φP(Γ) there are an object {Γφ} and an arrow iφ:{Γφ}Γ such that iφφ, and such that every f:ΔΓ with fφ factors as f=iφf¯ for exactly one f¯.

Proposition 143.18 — The powerset hyperdoctrine has comprehension

Take {Γφ}:=φ as a set and iφ the inclusion. Then definition 143.17 holds, and iφ is a monomorphism.

Proof of Proposition 143.18 — The powerset hyperdoctrine has comprehension

Proof. iφ1(φ)=φ, which is the top element of P(φ), so the first condition holds. Let f:ΔΓ satisfy Δf1(φ), that is, f(d)φ for every d. Then f¯(d):=f(d) is a function Δφ with iφf¯=f, and it is the only one, since iφ is injective. Injectivity also gives the monomorphism claim by proposition 141.29. ◻

Example 143.19 — Comprehension is a genuine extra condition

Let T be the empty theory over one sort S with no function symbols and one unary relation symbol R, and let (CT,PT) be its syntactic hyperdoctrine (theorem 143.28). An arrow Δ(x:S) of CT is a term of sort S in context Δ, hence a variable of Δ. Suppose {(x:S)R(x)} existed with structure map iR. Taking f:=iR itself in the factorization clause is not needed; it is enough that the first clause gives iRR(x), that is, a variable z of the context {(x:S)R(x)} with R(z) derivable in T. No such sequent is derivable in the empty theory: the interpretation of example 143.10 that sends S to a two-element set and R to a proper nonempty subset satisfies every axiom of T and refutes R(z), so by theorem 143.24 the sequent has no derivation. Hence (CT,PT) has no comprehension.

The calculus and its interpretation

Definition 143.20 — Signature, terms, formulas, sequents

A first-order signature Σ consists of a set of sorts; a set of function symbols, each with an arity (S1,,Sn)S of sorts; and a set of relation symbols, each with an arity (S1,,Sn). A context Γ=x1:S1,,xn:Sn declares distinct variables. Terms and formulas in context are generated by (x:S)ΓΓx:SΓti:Si (1in)Γf(t1,,tn):S(f:(S1,,Sn)S),φ::=R(t1,,tn)t=Stφφφφφφx:S.φx:S.φ, where every ti is a term of the declared sort and the two quantifiers bind x in a context extended by x:S. A sequent Γφψ has φ,ψ formulas in context Γ. A theory is a set of sequents, its axioms.

The rules are those of intuitionistic first-order logic in sequent form, with one formula on the left.

Definition 143.21 — Derivable sequents

The derivable sequents of a theory T are generated by the axioms of T together with Id ΓφφCut ΓφχΓχψΓφψSubst ΓφψΔφ[σ]ψ[σ] for every σ:ΔΓ, a list of terms of Δ of the sorts of Γ; the lattice rules ΓφΓφΓφψ1Γφψ2Γφψ1ψ2Γψ1ψ2ψiΓψiψ1ψ2Γψ1χΓψ2χΓψ1ψ2χ the two-way implication rule ΓφψχΓφψχ(both directions), the two-way quantifier rules, for φ formulas over Γ,x:S and ψ over Γ, Γ,x:SφψΓx:S.φψΓ,x:SψφΓψx:S.φ(both directions), where ψ on the upper line abbreviates its weakening to Γ,x:S; the Frobenius rule Γθx:S.φχΓx:S.(θφ)χ(both directions); and the equality rules, for ρ a formula over Γ,x:S,y:S, Γ,x:Sρ[x/y]Γ,x:S,y:Sx=Syρ(both directions).

The two-way rules are the two-way rules of (143.2), (143.3) and (143.8), transcribed. This is the exact respect in which the calculus is designed for the semantics: each connective is presented by the adjunction that will interpret it, so the soundness proof has one case per adjunction rather than one case per introduction and elimination rule.

Definition 143.22 — Interpretation

Let (C,P) be a hyperdoctrine. A structure M for Σ assigns an object [[S]] to each sort, an arrow [[f]]:[[S1]]××[[Sn]][[S]] to each function symbol, and an element [[R]]P([[S1]]××[[Sn]]) to each relation symbol. Put [[Γ]]:=[[S1]]××[[Sn]] for Γ=x1:S1,,xn:Sn. Terms are interpreted as arrows by [[Γxi:Si]]:=pri,[[Γf(t1,,tn):S]]:=[[f]][[t1]],,[[tn]], and formulas as elements of P([[Γ]]) by [[R(t1,,tn)]]:=[[t1]],,[[tn]][[R]],[[t=St]]:=[[t]],[[t]]Eq[[S]],[[φψ]]:=[[φ]][[ψ]],[[φψ]]:=[[φ]][[ψ]], with ,, interpreted by the corresponding operations of P([[Γ]]), and [[x:S.φ]]:=p[[φ]],[[x:S.φ]]:=p[[φ]], where p:[[Γ]]×[[S]][[Γ]] is the first projection and [[φ]]P([[Γ]]×[[S]]) is the interpretation of φ in the context Γ,x:S. A sequent Γφψ is valid in M when [[φ]][[ψ]] in P([[Γ]]).

The soundness proof needs one lemma, and that lemma is where Beck–Chevalley is used.

Lemma 143.23 — Substitution

Let σ:ΔΓ be a list of terms and write [[σ]]:=[[σ1]],,[[σn]]:[[Δ]][[Γ]]. Then for every term Γt:S and every formula φ over Γ, [[t[σ]]]=[[t]][[σ]],[[φ[σ]]]=[[σ]][[φ]].

Proof of Lemma 143.23 — Substitution

Proof. Terms. Induct on t. For t=xi, t[σ]=σi and [[xi]][[σ]]=pri[[σ]]=[[σi]] by (142.2). For t=f(t1,,tk), [[f(t)[σ]]]=def.[[f]][[t1[σ]]],=IH[[f]][[t1]][[σ]],=lemma142.2(2)[[f(t)]][[σ]].

Formulas. Induct on φ.

Atomic. For R(t), the term clause and lemma 142.2(2) give [[ti[σ]]]=[[ti]][[σ]], and P is a functor, so ([[ti]][[σ]])=[[σ]][[ti]] by (143.4). The equality formula is the same calculation with Eq[[S]] in place of [[R]].

Propositional. [[σ]] is a Heyting homomorphism by definition 143.8, so it commutes with ,,,,; combine with the induction hypotheses.

Quantifier. Let φ be a formula over Γ,x:S, and let p:[[Γ]]×[[S]][[Γ]] and q:[[Δ]]×[[S]][[Δ]] be the first projections. The substitution σ extends to σ+:=(σ,x) on the extended contexts, and [[σ+]]=[[σ]]×id[[S]]. The square Mathematical diagramDiagram is a pullback by lemma 143.9. Hence Beck–Chevalley (143.6) applies: [[(x:S.φ)[σ]]]=def.q[[φ[σ+]]]=IHq([[σ+]][[φ]])=(143.6)[[σ]](p[[φ]])=def.[[σ]][[x:S.φ]], and the universal clause of (143.6) gives the same for . ◻

Theorem 143.24 — Soundness

Let M be a structure in a hyperdoctrine (C,P) in which every axiom of T is valid. Then every sequent derivable in T is valid in M.

Proof of Theorem 143.24 — Soundness

Proof. Induct on the derivation. Axioms are valid by hypothesis.

Id and Cut. Reflexivity and transitivity of in P([[Γ]]).

Subst. By the induction hypothesis [[φ]][[ψ]] in P([[Γ]]). Applying the monotone map [[σ]] gives [[σ]][[φ]][[σ]][[ψ]], which by lemma 143.23 is [[φ[σ]]][[ψ[σ]]].

Lattice rules. Each is a clause of the universal property of the meet or join in P([[Γ]]); for instance the rule with two premises concluding φψ1ψ2 is the existence half of definition 142.1 in the preorder P([[Γ]]).

Implication. The two-way rule is (143.3) at [[φ]],[[ψ]],[[χ]].

Quantifiers. The two-way rule for is the adjunction pp evaluated at [[φ]] and [[ψ]], once it is checked that the weakening of ψ to Γ,x:S is interpreted as p[[ψ]]; that check is lemma 143.23 for the substitution that forgets x. The rule for is the adjunction pp.

Frobenius. By proposition 143.13 in the powerset case, and in general by the hypothesis that the hyperdoctrine satisfies (143.7); proposition 143.25 shows that Beck–Chevalley together with the adjunctions already forces it when C has finite products, so no further assumption is needed.

Equality. Write δ for the arrow id[[Γ]]×δ[[S]], the diagonal of [[S]] taken in the context Γ. By lemma 143.23, [[ρ[x/y]]] is δ[[ρ]], and the two-way rule is then theorem 143.15 at [[ρ]]. ◻

Proposition 143.25 — Frobenius from Beck–Chevalley

Let (C,P) be a hyperdoctrine and p:Γ×AΓ a product projection. Then for θP(Γ) and φP(Γ×A), p(pθφ)=θpφ.

Proof of Proposition 143.25 — Frobenius from Beck–Chevalley

Proof. From left to right. Both pθφφ and pθφpθ hold. Applying the monotone p to the first gives p(pθφ)pφ. For the second, the adjunction pp turns pθφpθ into p(pθφ)θ. The two together give the inequality into the meet.

From right to left. By (143.3) it suffices to show pφ(θp(pθφ)), and by pp this is equivalent to φp(θp(pθφ)). Now p preserves , being a Heyting homomorphism, so the right-hand side is pθpp(pθφ), and by (143.3) again the displayed inequality is equivalent to φpθpp(pθφ), which is the unit of the adjunction pp at the element pθφ. ◻

Remark 143.26 — What is not proved here

Theorem 143.24 is one direction. No completeness theorem is asserted in this chapter, for either the powerset hyperdoctrine or the class of all hyperdoctrines. A completeness statement requires a fixed calculus, a fixed class of models, and a theorem signature naming which sequents are recovered; the syntactic construction of section 143.6 produces a hyperdoctrine but is not by itself such a theorem, because the canonical structure in it validates exactly the derivable sequents by construction, which is a restatement rather than a completeness proof for an independently given class.

The syntactic hyperdoctrine and the internal language

Every theory produces a hyperdoctrine, and every hyperdoctrine produces a theory. Both constructions are performed here; neither is claimed to invert the other.

The first construction needs one fact about the equality rule of definition 143.21, and that fact is what makes substitution well defined on provable-equality classes of terms.

Lemma 143.27 — Equality is a congruence

In every theory T the following are derivable, for Γ,x:S,y:S a context, t a term with a distinguished variable of sort S, and φ a formula with a distinguished variable of sort S:

  1. Γ,x:Sx=Sx;

  2. Γ,x:S,y:Sx=Syy=Sx;

  3. Γ,x:S,y:Sx=Syt[x]=t[y];

  4. Γ,x:S,y:Sx=Syφ[x]φ[y].

Proof of Lemma 143.27 — Equality is a congruence

Proof. Each clause instantiates the two-way equality rule at a chosen ρ.

(1) Take ρ:=(x=Sy). The lower line is x=Syx=Sy, an instance of Id, so the upward direction gives the upper line ρ[x/y], which is x=Sx.

(2) Take ρ:=(y=Sx). Then ρ[x/y] is x=Sx, derivable by (1), so the downward direction gives x=Syy=Sx.

(3) Take ρ:=(t[x]=t[y]). Then ρ[x/y] is t[x]=t[x], which is derived from (1) by Subst along the substitution sending the distinguished variable to t[x]. The downward direction gives the claim.

(4) Take ρ:=(φ[x]φ[y]). Then ρ[x/y] is φ[x]φ[x], and φ[x]φ[x] follows from φ[x]φ[x] by the two-way implication rule. The downward direction gives the claim. ◻

Theorem 143.28 — The syntactic hyperdoctrine

Let T be a theory over Σ. Define

  • CT: objects are the contexts over Σ; an arrow ΔΓ is a list σ=(t1,,tn) of terms of Δ with ti of the sort of the i-th declaration of Γ, taken modulo the equivalence identifying σ and σ when Δti=ti is derivable for each i; composition is substitution and the identity is the variable list;

  • PT(Γ): the formulas over Γ, preordered by φψ when Γφψ is derivable, and σφ:=φ[σ].

Then (CT,PT) is a hyperdoctrine.

Proof of Theorem 143.28 — The syntactic hyperdoctrine

Proof. CT is a category with finite products. Composition is well defined on equivalence classes: if ti=ti is derivable over Δ and uj=uj over Ξ, then ti[u]=ti[u] is derivable by lemma 143.27(3) applied once for each variable, together with Subst and transitivity. The category laws are those of proposition 141.7, which hold already for representatives. The empty context is terminal and concatenation is a product, by the proof of proposition 142.7, which used only entrywise composition.

PT(Γ) is a Heyting algebra. The lattice rules of definition 143.21 are exactly the universal properties of ,,, in the preorder, and the two-way implication rule is (143.3).

σ is a homomorphism and PT is a functor. Substitution commutes with every propositional connective by the definition of substitution on formulas, so σ preserves each operation on the nose; it is monotone by Subst. Functoriality (στ)=τσ is the syntactic law φ[σ][τ]=φ[στ], and id=id is φ[x]=φ.

Adjoints along a projection. For p:Γ×(x:S)Γ the two-way quantifier rules of definition 143.21 state precisely x:S.()px:S.().

Adjoints along an arbitrary arrow. Let σ=(t1,,tn):ΔΓ with Δ=y1:R1,,ym:Rm and Γ=x1:S1,,xn:Sn. Write Eσ:=i=1n(xi=Siti), a formula over the concatenated context ΓΔ, and for φ over Δ put σφ:=y1:R1ym:Rm.(Eσφ),σφ:=y1:R1ym:Rm.(Eσφ), both formulas over Γ. We verify the two adjunctions.

Existential. Suppose Γσφψ. Applying the iterated -rule upward gives ΓΔEσφψ. Substitute σ for the variables of Γ by Subst; this replaces each xi by ti, turning Eσ into i(ti=ti), which is derivable from by lemma 143.27(1). Hence Δφψ[σ], which is φσψ.

Conversely suppose Δφψ[σ]. Weakening to ΓΔ and using lemma 143.27(4) once for each i, the hypothesis Eσ rewrites ψ[σ] into ψ: ΓΔEσφEσψ[σ]ψ. The iterated -rule downward gives Γσφψ.

Universal. Suppose Γσψφ read in Δ, that is, Δψ[σ]φ. Weaken to ΓΔ and use lemma 143.27(4) in the other direction: Eσψψ[σ]φ, so ΓΔψEσφ by the implication rule. The iterated -rule gives Γψσφ. Conversely, from Γψσφ the -rule gives ΓΔψEσφ; substituting σ for the variables of Γ makes Eσ derivable from as above, so Δψ[σ]φ.

Beck–Chevalley. By lemma 143.9 the squares to be checked are formed by a substitution σ:ΔΓ and a projection, and there the condition reads (x:S.φ)[σ]=x:S.(φ[σ+]), where σ+ extends σ by xx and the bound variable is chosen outside the variables of Δ and the terms of σ. That is the definition of substitution into a quantified formula, so both sides are the same formula and in particular provably equivalent. The universal clause is identical. For a pullback square that is not of this form, the condition follows by factoring the substitution through the product projections, using the strict functoriality just proved. ◻

Definition 143.29 — Internal language

Let (C,P) be a hyperdoctrine. Its internal language is the signature ΣC,P whose sorts are the objects of C, whose function symbols g:(A1,,An)B are the arrows g:A1××AnB of C, and whose relation symbols φ:(A1,,An) are the elements φP(A1××An). Its internal theory TC,P has as axioms every sequent Γαβ that is valid in the canonical structure MC,P, which interprets each sort, function symbol and relation symbol by the object, arrow and predicate it names.

Theorem 143.30 — The canonical structure computes names

In the canonical structure of definition 143.29:

  1. [[Γg(x1,,xn):B]]=g for the context Γ=x1:A1,,xn:An;

  2. [[φ(x1,,xn)]]=φ;

  3. a sequent is derivable in TC,P only if it is valid in MC,P.

Proof of Theorem 143.30 — The canonical structure computes names

Proof. (1) By lemma 142.2(1) the pairing of all the projections is the identity, pr1,,prn=idA1××An, so definition 143.22 gives [[g(x)]]=[[g]]pr1,,prn=gid=g.

(2) The same calculation: [[φ(x)]]=pr1,,prnφ=idφ=φ by (143.4).

(3) Every axiom of TC,P is valid in MC,P by construction, so theorem 143.24 applies. ◻

The converse of theorem 143.30(3) is immediate here, since the axioms were taken to be all valid sequents; that is why it is not a completeness theorem. The mathematical content of the two constructions is that they translate between the two vocabularies without loss on atoms (clauses (1) and (2)) and preserve derivability in one direction (clause (3)). A theorem relating a syntactically presented theory to the class of all its hyperdoctrine models requires a separately frozen statement and is not proved here (remark 143.26).

Example 143.31 — Reading a hyperdoctrine as a logic

Take the powerset hyperdoctrine. Its internal language has one sort for each set, one function symbol for each function, and one relation symbol for each subset of a finite product. The canonical structure interprets them back as themselves, and a sequent x:AU(x)V(x) is valid exactly when UV. A derivation of that sequent from the propositional and quantifier rules is therefore a proof of an inclusion of subsets, written without mentioning elements.

Exercise 143.6

★☆☆ Check directly that the empty context is terminal in CT and that the concatenation of two contexts satisfies definition 142.1, naming the rule of definition 143.21 used for the uniqueness clause.

Exercise 143.7

★★☆ For σ:ΔΓ in a hyperdoctrine define the graph of σ as idΔ,σ()P(Δ×Γ). Compute it in the powerset hyperdoctrine, and prove that in CT it is provably equivalent to Eσ from the proof of theorem 143.28.

Exercise 143.8

★☆☆ Derive transitivity, Γ,x,y,zx=yy=zx=z, from lemma 143.27 by choosing an appropriate ρ. One line.

Suggested first pass.

Begin with exercise 143.9 and exercise 143.10, then complete exercise 143.13.

Exercise 143.9

★★☆ Write out the omitted lattice cases of theorem 143.24 in full: the two projection rules for , the two injection rules for , and the case rule for . For each, name the clause of the universal property in the preorder P([[Γ]]) that it instantiates.

Exercise 143.10

★★☆ Let C=Set and let f:XY be surjective. Show that ff=id on P(Y) and that f is injective. Then exhibit a non-surjective f for which ffid, and locate the failing inclusion.

Exercise 143.11

★★☆ The powerset hyperdoctrine has Boolean fibers (example 143.2). Show that adding the sequent Γφ(φ) for all Γ,φ to definition 143.21 remains sound for it, and that the resulting calculus is not sound for the hyperdoctrine of exercise 143.4. Give the refuting instance.

Exercise 143.12

★★★ Suppose (C,P) has comprehension (definition 143.17). Prove that the assignment φ{Γφ} extends to a functor P(Γ)C/Γ right adjoint to the functor sending f:ΔΓ to f(). Check both triangle identities of (142.6) in the powerset hyperdoctrine.

Exercise 143.13

★★★ Practical project.hyperdoctrine-sequent-checker Implement a checker for validity of first-order sequents in a finite powerset hyperdoctrine. The input is: a finite list of sorts, each with a finite carrier given as a list of elements; a finite list of function symbols, each with an explicit table; a finite list of relation symbols, each with an explicit list of satisfying tuples; and a sequent Γφψ of definition 143.20. The program computes [[φ]] and [[ψ]] as subsets of the finite set [[Γ]], by the clauses of definition 143.22, and reports whether [[φ]][[ψ]].

Invariant. Every intermediate value is a subset of the product carrier of the context in which its formula lives; the program checks the arity and sort of each subterm before evaluating, and rejects an ill-sorted input rather than producing a subset of the wrong set.

Concrete result. For a valid sequent the program prints valid; for an invalid one it prints invalid together with one element of [[φ]][[ψ]], displayed as a tuple of carrier elements, which is a counterexample to the sequent.

Acceptance test. Use one sort S with carrier {0,1,2}, one binary relation symbol R interpreted as {(m,n)mn}, and check the following four inputs. The sequent x:Sy:S.R(x,y) must print valid; the sequent x:Sy:S.R(x,y) must print invalid with counterexample x=1 or x=2; the Frobenius equation (143.7) must be confirmed in both directions on θ:=R(x,x) and φ:=R(x,y); and the Beck–Chevalley equation (143.6) must be confirmed for the square of lemma 143.9 with σ the constant map at 0. A run reporting the second sequent valid has interpreted p as a union rather than the intersection required by (143.1).

Sources. Hyperdoctrines and the reading of quantifiers as adjoints to substitution are due to F. W. Lawvere, Adjointness in Foundations, Dialectica 23 (1969), 281–296, reprinted in Reprints in Theory and Applications of Categories 16 (2006); the four data of a hyperdoctrine and the powerset and higher-order-theory examples are on physical pages 11–13 of that reprint, and the observation that the existence of forces substitution to commute with conjunction is on page 12. The equality predicate as δ() and comprehension as an adjoint are developed in Lawvere’s companion paper Equality in hyperdoctrines and comprehension schema as an adjoint functor, Proceedings of Symposia in Pure Mathematics 17 (1970), 1–14. The posetal definition used here, together with the syntactic, powerset and subobject examples, is Awodey, Introduction to Categorical Logic, Definition 3.4.1 and the surrounding section (course draft of 15 September 2024, physical pages 176–178) [Awo24]; the systematic fibrational treatment, including the proof-relevant version of definition 143.8, is Jacobs [Jac99], and a book-length bridge from typed calculi to these models is Asperti and Longo [AL91]. The realizability quotients that turn a hyperdoctrine into a category of extensional objects are the subject of chapter 144, whose construction and invariant differ from the ones proved here.

Search the book

Type to search the local edition.