Res Agentica
Reading

No saved reading position.

Reading

No saved reading position.

Dependent Types and Fibrations

Appendix C

3 min read
Aa
Text size

Types that vary with context require machinery that tracks the variation. A query may require a field another schema lacks; a recommendation can change when the declared preference ordering changes. This appendix provides the formal vocabulary: dependent types from type theory and fibrations from category theory.

Dependent Types

Dependent Type

A dependent type is a family of types indexed by values of another type. If BB is a type and P:B→UP : B \to \mathcal{U} assigns a type P(b)P(b) to each b:Bb : B, then PP is a dependent type over BB. The fiber over bb is the type P(b)P(b).

Π-Type (Dependent Product)

Given BB and P:B→UP : B \to \mathcal{U}, the Π-type Πb:BP(b)\Pi_{b : B} P(b) is the type of functions that, given any b:Bb : B, return a value of type P(b)P(b). When PP is constant, this reduces to the ordinary function type B→PB \to P.

Σ-Type (Dependent Sum)

The Σ-type Σb:BP(b)\Sigma_{b : B} P(b) is the type of pairs (b,p)(b, p) where b:Bb : B and p:P(b)p : P(b). When PP is constant, this reduces to the ordinary product B×PB \times P.

Π-types correspond to universal quantification (∀b. P(b)\forall b.\, P(b)); Σ-types to existential quantification (∃b. P(b)\exists b.\, P(b)) with a witness. This is the propositions-as-types correspondence.

Fibrations

Fibration

A functor p:E→Bp : \mathcal{E} \to \mathcal{B} is a fibration if it satisfies the lifting property: for every morphism f:B′→Bf : B' \to B in B\mathcal{B} and every object EE in E\mathcal{E} with p(E)=Bp(E) = B, there exists a cartesian lift of ff to E\mathcal{E}. The fiber over BB has the objects mapping to BB and the arrows mapping to idB\mathrm{id}_B.

Reindexing

After choosing cartesian lifts in a fibration p:E→Bp : \mathcal{E} \to \mathcal{B}, a morphism f:B′→Bf : B' \to B induces a reindexing functor f∗:EB→EB′f^* : \mathcal{E}_B \to \mathcal{E}_{B'} that sends objects in the fiber over BB to objects in the fiber over B′B'. This is the functorial version of substitution.

Correspondence

Type TheoryFibration
Type family P:B→UP : B \to \mathcal{U}Fibration p:E→Bp : \mathcal{E} \to \mathcal{B}
Fiber P(b)P(b)Fiber category Eb\mathcal{E}_b
Substitution P[f]P[f]Reindexing f∗f^*
Π-type Πb:BP(b)\Pi_{b:B} P(b)Right adjoint to reindexing
Σ-type Σb:BP(b)\Sigma_{b:B} P(b)Left adjoint to reindexing

The adjoints interpreting Π- and Σ-types require additional structure; a fibration alone does not supply them. The Third Mode uses this language to specify context dependence: "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.

← Back to AppendicesBack to The Proofs →

Search the book

Use ↑ ↓ to move through results; Escape to close.

Search every published chapter, section and reference.

    In this chapter