In dependent type theory, tell me about categories of contexts. What are their properties? Is it a special combination of properties or similar to some other well known categories?
Assistant
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.
In dependent‐type‐theory folklore one often packages “all of the contexts and substitutions” into a single category
Ctx(T) :=
• Obj(Ctx) = contexts Γ = (x₁:A₁, x₂:A₂(x₁), …, xₙ:Aₙ(x₁,…,xₙ₋₁))
• Hom(Δ, Γ) = substitutions σ:Δ→Γ (i.e. a tuple of terms in Δ giving each variable of Γ)
What extra structure does Ctx(T) carry? It is not just any category, but carries exactly the combinatorial data needed to interpret dependent types. Two equivalent axiomatizations are especially popular:
Terminal object
– The empty context · is terminal in Ctx.
– Playing the role of “no hypotheses.”
Context‐extension (comprehension)
For each Γ⊢A type there is
– An extended context Γ·A
– A projection p: Γ·A→Γ
– A “generic” term q∈Tm(Γ·A, A[p])
These data satisfy the universal property of comprehension:
every map σ:Δ→Γ and every term t∈Tm(Δ,A[σ]) factors uniquely through p.
Substitution‐stability (pullbacks)
Whenever you have
σ:Δ→Γ and context‐extension p:Γ·A→Γ
you can form a pullback square
code
Δ·A[σ] --σ⁎--> Γ·A
| |
p′ p
↓ ↓
Δ --σ--> Γ
so context extension is stable under substitution.
(Optional) Type‐formers ↔ adjoints in fibers
– Σ–types give left adjoints to pullback functors
– Π–types give right adjoints to pullback functors
– identity types give diagonals + factorization
– universes give display‐map classifiers
– …
In fact, if your theory has Π‐ and Σ‐types strictly, then Ctx(T) is a locally cartesian closed category (LCCC). If it only has Σ and a strict unit, it’s a finite-limit category.
Equivalences with other frameworks
Contextual categories ⟺ Categories with families ⟺ Categories with attributes ⟺ Comprehension categories ⟺ C-systems
These are all “different windows” on the same underlying structure.
––––––––––––––––––––––––––––––––––––––––––––––––––––––––––––
Is this a “well–known” category? Yes:
– In simple type theory (no dependency) Ctx is just the free cartesian category on your base types.
– With dependency and Π, Σ you get the free locally cartesian closed category.
– In practice you often embed Ctx(T) into a presheaf category on a small base of raw contexts (this is the classical “Presheaf model” of DTT).
So, in a nutshell:
• Ctx(T) is not arbitrary—it is a contextual/comprehension category.
• Its defining features are a terminal object, stable context‐extension (display maps), and—once you add type‐formers—(local) cartesian closure.
• Up to equivalence, these are exactly the well-known notions of categories with families or Cartmell’s C-systems.
This special bundle of properties is what makes Ctx(T) the canonical “semantic home” for dependent types.
User
Please explain the morphisms.
Assistant
In the category of contexts Ctx(T), every arrow is literally a substitution σ from one context into another. Concretely:
Definition of a context
A context Γ of length n is a telescope
Γ = (x₁:A₁, x₂:A₂(x₁), …, xₙ:Aₙ(x₁,…,xₙ₋₁))
where each Aᵢ may depend on the earlier variables.
What is a morphism σ: Δ → Γ?
If
Δ = (y₁:B₁, …, yₖ:Bₖ(y₁,…,yₖ₋₁))
then a substitution σ picking out Γ‐data in Δ is a tuple of terms
σ = (σ₁, σ₂, …, σₙ)
with
σ₁ ∈ Tm(Δ, A₁)
σ₂ ∈ Tm(Δ, A₂[σ₁/x₁])
…
σᵢ ∈ Tm(Δ, Aᵢ[σ₁/x₁,…,σᵢ₋₁/xᵢ₋₁])
…
σₙ ∈ Tm(Δ, Aₙ[σ₁,…,σₙ₋₁])
In words: to give a map Δ→Γ you must exhibit for each variable xᵢ of Γ a term σᵢ in Δ of the correct (already‐substituted) type.
Identities and composition
• Identity on Γ is just the “variable” substitution
id_Γ = (x₁,…,xₙ)
sending each xᵢ to itself.
• Composition σ: Δ→Γ and τ: Γ→Θ is “plug‐in‐all‐the‐terms,” i.e.
(τ∘σ)ᵢ = τᵢ[σ/x]
you substitute σ’s components into τ’s.
Universal description via comprehension
If p: Γ·A→Γ is the projection from the extended context, then one shows a bijection
Hom(Δ,Γ·A) ≃ { (σ:Δ→Γ) × t∈Tm(Δ, A[σ]) }
i.e. a map into Γ·A is exactly a substitution σ to the base plus a “choice of a term of type A[σ].”
Examples
• The unique map to the empty context
!: Δ→·
is the empty tuple ().
• A projection from an extended context
p: (Γ,x:A) → Γ
is the substitution p = (x₁,…,xₙ) dropping the last variable.
• Given Γ⊢A and Δ⊢t:A[σ], we get
⟨σ,t⟩ : Δ → (Γ·A)
by “extending” σ with the last component t.
Key properties of these morphisms
• They are stable under pullback (substitution into types and terms).
• Every arrow factors (uniquely up to iso) as a projection from some context‐extension followed by a renaming.
• They organize all the substitution‐action that underlies dependent types.
In summary, in Ctx(T)
– objects = contexts (telescopes)
– arrows = substitution‐tuples that feed one context’s variables with terms in another
– composition = “substitute and re‐normalize”
This is exactly the categorical incarnation of “doing simultaneous substitutions” in your syntax.