Lecture 4: Simply typed λ-calculus as CCC

Teacher: Paul-André Melliès

\[\newcommand\xto\xrightarrow \newcommand\xfrom\xleftarrow\]


An adjoint pair is a pair of functors

\[\begin{xy} \xymatrix{ A \ar@/^/[r]^{ L } \ar@{<-}@/_/[r]_{ R } & B \\ } \end{xy}\]

equipped with a family of bijections:

\[ϕ_{a, b}: B(La, b) ≅ A(a, Rb)\]

natural in $a$ and $b$.

This operation defines functors:

\[B(L\bullet, \bullet): A^{op} × B ⟶ Set\\ A(\bullet, R\bullet): A × B^{op} ⟶ Set\]

NB: in Homotopy Type Theory, we don’t currently know how to deal with these opposite categories.

Naturality here amounts to every commutative square

\[\begin{xy} \xymatrix{ LA \ar[rr]^{ g } \ar@{<-}[d]_{ Lh_A } && B \ar[d]^{ h_B } \\ LA' \ar[rr]_{ f } && B' } \end{xy}\]

being turned into a commutative square:

\[\begin{xy} \xymatrix{ A \ar[rr]^{ ϕ_{A,B}(g) } \ar@{<-}[d]_{ h_A } && RB \ar[d]^{ Rh_B } \\ A' \ar[rr]_{ ϕ_{A',B'}(f) } && RB' } \end{xy}\]

Mac Lane’s Parameter theorem

In a cartesian category, we already know that the cartesian product defines a bifunctor.

Similarly, in a CCC: (Mac Lane’s Parameter theorem) the family of cartesian exponentiations

\[(A ⇒ \bullet)_{A ∈ 𝒞}: 𝒞 ⟶ 𝒞\]

defines a unique bifunctor:

\[A, B ⟼ A ⇒ B: 𝒞^{op} × 𝒞 ⟶ 𝒞\]

such that the bijections $ϕ_{A, B, C}$ are natural in $A, B, C$.

Every CCC is enriched over itself

In a cartesian closed category, the functor ${\rm Hom}$ functors as:

\[𝒞^{op} × 𝒞 \xto {⇒} 𝒞 \xto{𝒞(1,\bullet)} Set\]

NB: the terminal object $1$ exists, as $𝒞$ is cartesian (in the category of types, $1$ is the empty context: closed terms: $1 \xto t A$)

NB: the converse is not true: a category may be enriched over itself but not cartesian closed.

Example: Topological spaces: not cartesian closed. But a sub-category thereof is:

the category of compactly generated topological spaces (in which every set is closed iff its intersection with every compact is closed) and continuous functios is a CCC.

Simply typed $λ$-calculus as CCC

Inference rules/typing judgement:

Logical rules

\[\cfrac{}{x:A ⊢ x:A}\text{(variable)}\\ \, \\ \cfrac{Γ, x:A ⊢ P:B}{Γ ⊢ λx.P:A ⇒ B}\text{(abstraction)}\\ \, \\ \cfrac{Γ ⊢ P: A ⇒ B \qquad Δ ⊢ Q:A}{Γ, Δ ⊢ PQ: B}\text{(abstraction)}\]

Structural rules

\[\cfrac{Γ ⊢ P:B}{Γ, x:A ⊢ P:B}\text{(weakening)}\\ \, \\ \cfrac{Γ, x:A, y:A ⊢ P:B}{Γ, z:A ⊢ P[x←z, y←z]: B}\text{(contraction)}\\ \, \\ \cfrac{Γ, x:A, y:B, Δ ⊢ P: C}{Γ, y:B,x:A, Δ ⊢ P: C}\text{(exchange)}\]
\[x_1: A_1, …, x_k:A_k ⊢ P:B\]

will be interpreted as

\[A_1 × ⋯ × A_k \xto P B\]

For every type variable $α$, we’re given an object $ξ(α)$

Interpretation of a type $A$: $⟦A⟧$

Then, by structural induction, we define $⟦\bullet⟧$ for every type.

Every sequent \(x_1: A_1, …, x_k:A_k ⊢ P:B\) is translated into \(⟦A_1⟧ × ⟦A_k⟧ ⟶ ⟦B⟧\)

by induction on the derivation tree:

  • Variable: \(⟦A⟧ \xto {id_{⟦A⟧}} ⟦A⟧\)

  • Lambda/Curryfication: \(A × Γ \xto f B\) becomes, by adjunction: \(Γ \xto {ϕ_{A,Γ,B}(f)} A ⇒ B\)

  • Application: \(Γ \xto f A \qquad \text{ and } \qquad Δ \xto g A⇒B\)

    \[Γ × Δ \xto {f × g} A × (A ⇒ B) \xto {eval_{A,B}} B\]
  • Contraction \(Γ × A × A \xto f B\) becomes \(Γ × A \xto {Γ × δ_A} Γ × A × A \xto f B\)

  • Weakening \(Γ × A \xto {π_1} Γ \xto f B\)

    which is isomorphic to

    \[Γ × A \xto {Γ × wk} Γ × 1 ≃ Γ \xto f B\]
  • Exchange: analogous

Soundness theorem

In every CCC $𝒞$, the interpretation $⟦\bullet⟧$ is an invariant modulo $β, η$.

If $Γ ⊢ (λx. M): A⇒B$ and $Δ ⊢ N:A$:

\[⟦Γ, Δ ⊢ (λx. M)N: B⟧ = ⟦Γ, Δ ⊢ M[x:=N]: B⟧\]

If $Γ ⊢ M: A ⇒ B$:

\[⟦Γ, Δ ⊢ (λx. Mx): A ⇒ B⟧ = ⟦Γ ⊢ M: A ⇒ B⟧\]

Proof: Similar to the one of subject reduction (preservation of type by $β$-reduction and $η$-expansion): by induction on the typing judgment.

Linear Logic: an intermediate notion

Leave a comment