← The Framework

Component 3: The Presheaf Category

The state space as an elementary topos.

A single presheaf (Component 2) is one data state. The category of all presheaves on the schema : denoted Ont : is the space of all possible states. It is an elementary topos, and that single fact gives us a complete query algebra, a subobject classifier for filters, exponentials for function types, and an internal logic : none of which we designed; all of it follows from the choice of presheaves over a small category.

1. The Functor Category

Definition 1.1 : Ont

The ontology category is the functor category Ont = [OntSchop, Set].

A natural transformation α is a family of functions {αO : Φ(O) → Φ′(O)} satisfying the naturality condition: αOiΦ(L) = Φ′(L) ∘ αOj for every link type L : OiOj. In words: the transition preserves the link structure.

Nobody enumerates this category : it is typically a proper class. But knowing Φ lives in it tells you exactly which operations are structurally available.

2. Limits and Colimits

Theorem 2.1 : Componentwise Computation

Limits and colimits in [OntSchop, Set] are computed componentwise: for a diagram D : JOnt,

(lim D)(O) = limj D(j)(O),   (colim D)(O) = colimj D(j)(O)

Set has all small limits and colimits, so [OntSchop, Set] inherits them.

What does this buy us concretely?

Example 2.2 : Products, Coproducts, Pullbacks

Product Φ × Ψ: at each O, take Φ(O) × Ψ(O). The product of two data states is the state containing pairs : one object from each source. This is enrichment: combining two datasets.

Coproduct ΦΨ: at each O, take the disjoint union. This is merge.

Pullback along Φα Ψβ Γ: at each O, take {(x, z) | αO(x) = βO(z)}. This is a join on a common key.

3. The Subobject Classifier

Definition 3.1 : Subobject Classifier Ω

The subobject classifier in Ont is the presheaf Ω(O) = {sieves on O in OntSch}. A sieve on O is a set of morphisms into O closed under precomposition. The maximal sieve (all morphisms) represents "true"; the empty sieve represents "false."

Proposition 3.2 : Characteristic Morphisms

For every subobject m : AΦ, there exists a unique characteristic morphism χA : Φ → Ω making the following a pullback:

A 1
Φ Ω

(m vertical, χ horizontal; pullback)

Every subset of the data (every filter, every "object set" in the UI) corresponds uniquely to a morphism into Ω. Filters are first-class citizens of the category, and they compose by the algebra of Ω.

4. Exponentials

Definition 4.1 : Exponential Objects

For Φ, ΨOnt, the exponential ΨΦ is given by ΨΦ(O) = Ont(y(O) × Φ, Ψ). The universal property Hom(Γ × Φ, Ψ) ≅ Hom(Γ, ΨΦ) is categorified currying.

What this means in practice: functions on objects are themselves objects in the topos. A server-side function that takes a set of persons and returns a set of companies lives in Φ(Company)Φ(Person). The topos promotes these to first-class data.

5. Internal Logic

An elementary topos carries an internal logic (intuitionistic, not classical), so the law of excluded middle fails in general, but we still get conjunction, disjunction, implication, and quantifiers, all internal to Ω.

Definition 5.1 : Internal Language

In the internal language of Ont:

Proposition 5.2 : Quantification as Adjunction

For a link type L : O₁ → O₂, the pullback L* : Sub(Φ(O₂)) → Sub(Φ(O₁)) has left and right adjoints:

LL* ⊣ ∀L

Here ∃L(A) = {y | ∃xA, wL(x) = y} ("there exists a linked object in A") and ∀L(A) = {y | ∀x, wL(x) = yxA} ("all linked objects are in A"). These are the "exists" and "forall" queries across links, and the adjunction guarantees they compose correctly with pullbacks.

6. The Yoneda Embedding

Theorem 6.1 : Yoneda Embedding

y : OntSch ↪ [OntSchop, Set] is full and faithful. Morphisms between entity types in the schema correspond exactly to natural transformations between their representables. The schema embeds faithfully into the topos.

Corollary 6.2 : Density Theorem

Every presheaf Φ is a colimit of representables: Φ ≅ colim(O, x) ∈ ∫ Φ y(O), where ∫ Φ is the category of elements : objects are pairs (O, x) with xΦ(O), morphisms are link types preserving the element. Every data state is "built up" from individual objects. The category of elements is the flattened view: the total set of all objects across all types, with their relationships.

7. Universality

Here is the punchline.

Remark 7.1

The presheaf topos [OntSchop, Set] is the free cocompletion of OntSch: the smallest category containing the schema that has all small colimits. Any cocomplete category receiving a functor from OntSch factors uniquely through it.

There is no design choice here. Given a schema, the presheaf topos is uniquely determined. The query algebra, the filter system, the function types, the security predicates : all of it is a consequence of this single universal construction. The platform is not designed; it is generated.


Summary

Ont = [OntSchop, Set] is an elementary topos. Limits and colimits give joins, merges, and intersections. Ω makes filters first-class. Exponentials make function spaces first-class. The internal logic provides ∃ and ∀ across links as adjunctions. Every presheaf is a colimit of representables. The whole thing is canonical : free cocompletion of the schema.

Next: Component 4: The Edit Monad, composable state transitions on this topos.