Dependent Types and Fibrations
Appendix C
Dependent Types and Fibrations
Types that vary with context require machinery that tracks the variation. A query valid against one schema is nonsense against another; a recommendation "best" for one user is irrelevant to the next. This appendix provides the formal vocabulary: dependent types from type theory and fibrations from category theory.
Dependent Types
A dependent type is a family of types indexed by values of another type. If is a type and assigns a type to each , then is a dependent type over . The fiber over is the type .
Given and , the Π-type is the type of functions that, given any , return a value of type . When is constant, this reduces to the ordinary function type .
The Σ-type is the type of pairs where and . When is constant, this reduces to the ordinary product .
Π-types correspond to universal quantification (); Σ-types to existential quantification () with a witness. This is the propositions-as-types correspondence.
Fibrations
A functor is a fibration if it satisfies the lifting property: for every morphism in and every object in with , there exists a cartesian lift of to . The fiber over is the subcategory of objects mapping to .
Given a fibration and morphism , the reindexing functor sends objects in the fiber over to objects in the fiber over . This is the functorial version of substitution.
Correspondence
| Type Theory | Fibration |
|---|---|
| Type family | Fibration |
| Fiber | Fiber category |
| Substitution | Reindexing |
| Π-type | Right adjoint to reindexing |
| Σ-type | Left adjoint to reindexing |
The Third Mode's predicates are fibered: "valid query" depends on schema, "best option" depends on preference context, "permitted action" depends on authorization context. Fibrations make this dependence explicit and reindexing coherent. See A14.