Type theory MOC

𝚷-types

𝚷-types, also known as dependent function types or dependent products, are motivated in several ways:

  1. 𝚷-types internalize hypothetical judgements.
  2. 𝚷-types generalize binary products ( ×) to a product of a family of types indexed by another type.
  3. 𝚷-types generalize functions ( →) so that the codomain can depend on the input.
  4. 𝚷-types correspond to spaces of sections.
  5. 𝚷-types correspond to universal quantification (∀) over elements of some type.

The core idea is that given a type family (fibration) Γ,𝑥 :𝐴 ⊢𝐵(𝑥), a term

Γ⊢𝑓:∏𝑥:𝐴𝐵(𝑥)

corresponds to a section

Γ,𝑥:𝐴⊢𝑓(𝑥):𝐵(𝑥)

and vice versa.

Standard presentation

Here we give a formal presentation of 𝚷-types in the cartesian calculus of substitutions, following Principles of dependent type theory. #m/def/type The formation, introduction, and elimination rules are given by1

Γ.𝐴⊢𝐵Γ⊢𝚷Γ(𝐴,𝐵)(Π)Γ.𝐴⊢𝑏:𝐵Γ⊢𝜆Γ,𝐴,𝐵(𝑏):𝚷(𝐴,𝐵)(ΠI) Γ⊢𝑎:𝐴Γ⊢𝑓:𝚷(𝐴,𝐵)Γ⊢𝐚𝐩𝐩Γ,𝐴,𝐵(𝑓,𝑎):𝐵[𝐢𝐝.𝑎](ΠE)

while we also have the substitution naturality rules2

Δ⊢𝛾:ΓΓ.𝐴⊢𝐵Δ⊢𝚷(𝐴,𝐵)[𝛾]=𝚷(𝐴[𝛾].𝐵[𝛾.𝐴])(Π-N) Δ⊢𝛾:ΓΓ.𝐴⊢𝑏:𝐵Δ⊢𝜆(𝑏)[𝛾]=𝜆(𝑏[𝛾.𝐴]):𝚷(𝐴,𝐵)[𝛾](ΠI-N) Δ⊢𝛾:ΓΓ⊢𝑎:𝐴Γ⊢𝑓:𝚷(𝐴,𝐵)Δ⊢𝐚𝐩𝐩(𝑓,𝑎)[𝛾]=𝐚𝐩𝐩(𝑓[𝛾],𝑎[𝛾]):𝐵[𝛾.𝑎[𝛾]](ΠE-N)

and judgemental equality rules for 𝛽-computation and 𝜂-unicity

Γ⊢𝑎:𝐴Γ.𝐴⊢𝑏:𝐵Γ⊢𝐚𝐩𝐩(𝜆(𝑏),𝑎)=𝑏[𝐢𝐝.𝑎]:𝐵[𝐢𝐝.𝑎](Π𝛽) Γ⊢𝑓:𝚷(𝐴,𝐵)Γ⊢𝑓=𝜆(𝐚𝐩𝐩(𝑓[𝐩],𝐪)):𝚷(𝐴,𝐵)(Π𝜂)
Meta-well-typed

To show that ΠE-N is meta-well-typed, we show that both terms have the claimed type. First note,

Δ⊢𝛾:ΓΓ⊢𝑎:𝐴Γ⊢𝑓:𝚷(𝐴,𝐵)Γ⊢𝐚𝐩𝐩(𝑓,𝑎):𝐵[𝐢𝐝.𝑎](ΠE)Δ⊢𝐚𝐩𝐩(𝑓,𝑎)[𝛾]:𝐵[𝐢𝐝.𝑎∘𝛾]

and by ^P2, 𝐢𝐝.𝑎 ∘𝛾 =𝛾.𝑎[𝛾]. On the other hand,

Δ⊢𝛾:ΓΓ⊢𝑎:𝐴Δ⊢𝑎[𝛾]:𝐴[𝛾]Δ⊢𝛾:ΓΓ⊢𝑓:𝚷(𝐴,𝐵)Δ⊢𝑓[𝛾]:𝚷(𝐴,𝐵)[𝛾]Δ⊢𝑓[𝛾]:𝚷(𝐴[𝛾],𝐵[𝛾.𝐴])Δ⊢𝐚𝐩𝐩(𝑓[𝛾],𝑎[𝛾]):𝐵[𝛾.𝐴∘𝐢𝐝.𝑎[𝛾]](ΠE)

Now ^P2 gives 𝐢𝐝.𝑎 ∘𝛾 =𝛾.𝑎[𝛾], and ^P1 gives 𝛾.𝐴 ∘𝐢𝐝.𝑎[𝛾] =𝛾.𝑎[𝛾], so the types agree.

To see that Π𝜂 is meta-well-typed, note

Γ⊢𝐴Γ.𝐴⊢𝐪:𝐴[𝐩](V)Γ⊢𝐴Γ.𝐴⊢𝐩:Γ(W)Γ⊢𝑓:𝚷(𝐴,𝐵)Γ.𝐴⊢𝑓[𝐩]:𝚷(𝐴,𝐵)[𝐩]Γ.𝐴⊢𝑓[𝐩]:𝚷(𝐴[𝐩],𝐵[𝐩.𝐴])(=Π-N)Γ.𝐴⊢𝐚𝐩𝐩(𝑓[𝐩],𝐪):𝐵[𝐩.𝐴∘𝐢𝐝.𝐪](ΠE)Γ.𝐴⊢𝐚𝐩𝐩(𝑓[𝐩],𝐪):𝐵(=*)Γ⊢𝜆(𝐚𝐩𝐩(𝑓[𝐩],𝐪)):Π(𝐴,𝐵)(ΠI)

where =* is conversion along the equality

𝐩.𝐴∘𝐢𝐝.𝐪=(𝐩∘𝐢𝐝).𝐪[𝐢𝐝]=𝐢𝐝

which follows from ^P1 and 𝜂𝐩𝐪.

Internalizing judgemental structure

In terms of Internalizing judgemental structure, we can formalize the correspondence described in the core idea with an operation

𝚷Γ:⎛⎜ ⎜⎝∐𝐴∈Ty⁡(Γ)Ty⁡(Γ.𝐴)⎞⎟ ⎟⎠→Ty⁡(Γ)

natural in Γ with a family of bijections

𝜄Γ,𝐴,𝐵:Tm⁡(Γ,𝚷Γ(𝐴,𝐵))≅Tm⁡(Γ.𝐴,𝐵)

also natural in Γ. Translation directly into inference rules gives us almost exactly those given above, except that ΠE would look more like

Γ⊢𝑓:𝚷(𝐴,𝐵)Γ.𝐴⊢𝜆−1Γ,𝐴,𝐵(𝑓):𝐵(ΠE′)

with the naturality rule

Δ⊢𝛾:ΓΓ⊢𝑓:𝚷(𝐴,𝐵)Δ.𝐴[𝛾]⊢𝜆−1(𝑓)[𝛾.𝐴]=𝜆−1(𝑓[𝛾]):𝐵[𝛾.𝐴](ΠE′-N)

and the judgemental equality rules

Γ.𝐴⊢𝑏:𝐵Γ.𝐴⊢𝜆−1(𝜆(𝑏))=𝑏:𝐵(Π𝛽′) Γ⊢𝑓:𝚷(𝐴,𝐵)Γ⊢𝑓=𝜆(𝜆−1(𝑓)):𝚷(𝐴,𝐵)(Π𝜂′)

These are however more awkward to use since they restrict the shape of contexts. The rules presented above are derivable from these by defining 𝐚𝐩𝐩Γ,𝐴,𝐵(𝑓,𝑎) :=𝜆−1Γ,𝐴,𝐵(𝑓)[𝐢𝐝.𝑎]:

Proof

The derivation

Γ⊢𝑎:𝐴Γ⊢𝐢𝐝.𝑎:Γ.𝐴Γ⊢𝑓:𝚷(𝐴,𝐵)Γ.𝐴⊢𝜆−1(𝑓):𝐵(ΠE′)Γ⊢𝜆−1(𝑓)[𝐢𝐝.𝑎]:𝐵[𝐢𝐝.𝑎]Γ⊢𝐚𝐩𝐩(𝑓,𝑎):𝐵[𝐢𝐝.𝑎](=)

gives ΠE.

Noting that 𝛾.𝐴 ∘𝐢𝐝.𝑎[𝛾] =𝛾.𝑎[𝛾] =𝐢𝐝.𝑎 ∘𝛾 by ^P1 and ^P2, the derivation

Γ⊢𝑎:𝐴Δ⊢𝛾:ΓΔ⊢𝑎[𝛾]:𝐴[𝛾]Δ⊢𝐢𝐝.𝑎[𝛾]:Δ.𝐴[𝛾]Δ⊢𝛾:ΓΓ⊢𝑓:𝚷(𝐴,𝐵)Δ.𝐴[𝛾]⊢𝜆−1(𝑓)[𝛾.𝐴]=𝜆−1(𝑓[𝛾]):𝐵[𝛾.𝐴](ΠE′-N)Δ⊢𝜆−1(𝑓)[𝛾.𝐴∘𝐢𝐝.𝑎[𝛾]]=𝜆−1(𝑓[𝛾])[𝐢𝐝.𝑎[𝛾]]:𝐵[𝛾.𝐴∘𝐢𝐝.𝑎[𝛾]]Δ⊢𝜆−1(𝑓)[𝐢𝐝.𝑎∘𝛾]=𝜆−1(𝑓[𝛾])[𝐢𝐝.𝑎[𝛾]]:𝐵[𝛾.𝑎[𝛾]](=)Δ⊢𝐚𝐩𝐩(𝑓,𝑎)[𝛾]=𝐚𝐩𝐩(𝑓[𝛾],𝑎[𝛾]):𝐵[𝛾.𝑎[𝛾]](=)

gives ΠE-N.

The derivation

Γ⊢𝑎:𝐴Γ⊢𝐢𝐝.𝑎:Γ.𝐴Γ.𝐴⊢𝑏:𝐵Γ.𝐴⊢𝜆−1(𝜆(𝑏))=𝑏:𝐵(Π𝛽′)Γ⊢𝜆−1(𝜆(𝑏))[𝐢𝐝.𝑎]=𝑏[𝐢𝐝.𝑎]Γ⊢𝐚𝐩𝐩(𝜆(𝑏),𝑎)=𝑏[𝐢𝐝.𝑎]:𝐵[𝐢𝐝.𝑎](=)

gives Π𝜂.

Noting 𝐢𝐝 =𝐩.𝐪 =𝐩.𝐴 ∘𝐢𝐝.𝐪 by ^P1, the derivation

Γ⊢𝑓:𝚷(𝐴,𝐵)Γ⊢𝑓=𝜆(𝜆−1(𝑓)):𝚷(𝐴,𝐵)(Π𝜂′)Γ⊢𝑓=𝜆(𝜆−1(𝑓))[𝐩.𝐴∘𝐢𝐝.𝐪]:𝚷(𝐴,𝐵)(=)Γ⊢𝑓=𝜆(𝜆−1(𝑓[𝐩])[𝐢𝐝.𝐪]):𝚷(𝐴,𝐵)Γ⊢𝑓=𝜆(𝐚𝐩𝐩(𝑓[𝐩],𝐪)):𝚷(𝐴,𝐵)(=)

gives Π𝜂′.


#state/tidy | #lang/en | #SemBr

Footnotes

  1. For brevity and laziness, the premisses of the 𝚷 formation rule will be considered presuppositions. ↩

  2. Where we invoke Substitution extension by a type. ↩