Lecture 5: Higher Inductive Types

HIT: Inductive types where equality is also taken into account.

More precisely: it’s an inductive type where you can postulate equalities in the constructors.

  • Interval
  • Truncation
  • Circle
  • Suspension

Hedberg theorem

Hedberg theorem: a type $A$ with a decidable equality is an $HSet$

(cf. Hedberg.v)

\[\texttt{dec_eq} \; A ≝ ∀a, b: A. (a=b) + ¬(a=b)\] \[Hedberg: \; ∀A:Type, \texttt{dec_eq} \; A ⟶ IsHSet \; A\]

ex: Bool has decidable equality

Inductive Bool: Type
    | true: Bool
    | false: Bool
\[∀b_1, b_2, (b_1 = b_2) + ¬(b_1 = b_2)\]

Induction/pattern matching on $b_1, b_2$:

  • $(true = true) + ¬(true = true)$

    • $inl \; (refl \; true)$
  • $(true = false) + ¬(true = false)$

    • $inr$
    • But you can’t prove $true = false ⟶ ⊥$ directly ⟹ generalize over the first argument:
      Q: forall b: Bool (e: b = false) match b
          | true => False
          | false => True
      end
    

    Then

      path_induction on e
          * : PFalse  True
    

    Now to show $true = false ⟶ ⊥$:

    \[λe. Q \; true \; e: ⊥\]

Thomas Streicher’s property

Streicher K:
\[\underbrace{IsHSet \; A }_{∀(x, y: A), (e, e': x=y). \; e=e'} ≃ ∀x:A, (p: x=x). p = refl \; x\]

Proof: straightforward.


Theorem: Equality is also $HProp$

\[(R: A → A → Type) \, (HR: ∀x,y. IsHProp \, (R \, x \, y)) \\ (Rrefl: ∀x. R \, x \, x) \; (Req: ∀x, y:A. R \, x \, y → x=y). IsHSet \; A\] \[∀x:A, (p: x=x). p=refl_x\] \[\texttt{transport} \; (fun: X ⇒ X = x) \; p \; (Req \; x \; x \; (Rrefl \; x)) \overset{\text{naturality}}{ = } Req \; x \; x \; \underbrace{\texttt{transport} \; (fun: X ⇒ X = x) \; p \; (Rrefl \, x)}_{R \, x \, x} \\ p \, @ \, Req \; x \; x \; (Rrefl \; x) = Req \; x \; x (Rrefl \; x)\]

Any decidable proposition is classical:

\[\texttt{dec_to_classical}: ∀P: Type, (P + ¬ P) ⟶ (¬¬ P ⟶ P)\]
λ P (x: P + ¬P) (f: ¬¬P)
    match x with
        | inl p => p
        | inr n => match (f n): 
                    | aburd (f n) (* ∀A. ⊥ ⟶ A *)
                end.
    end.

The following property uses functional extensionality:

\[∀A. (B: A ⟶ Type) \, (∀x. IsHProp \; (B \, x)) ⟶ IsHProp \; (\prod_x B \, x)\] \[∀A: Type, IsHProp (¬ A) \\ R ≝ λ x, y. ¬¬(x=y)\\ Req ≝ λx, y. \texttt{dec_to_classical} \; (x=y) \; (\texttt{dec_eq} \; A)\\ Rrefl ≝ λ x. η(refl_x)\]

NB: This proof is a bit overkill: it uses extensionality. Look at Hedberg_alt in the Hedberg.v file for a more direct proof without functional extensionality.

Not all types are $HSet$

We’re not in Topos Theory: not every type is a Set.

  • $𝔹: Type$ (Bool)
  • $p: 𝔹 = 𝔹$
  • $¬(p = refl_{𝔹})$
flip: 𝔹 -> 𝔹.
    λb. match b with
        | true => false
        | false => true
    end.

Can we prove $p$?: By univalence, it suffices to provide an equivalence

\[𝔹 ≃ 𝔹\]

Then:

  • $¬(p = refl_{𝔹})$
  • $¬(∀b. flip \; b = id_𝔹 \; b)$
  • $¬(flip \; false = false) ≡ ¬(true = false)$

HITs

HIT    
Interval Contractible 0-Type
(Propositional) Truncation hProp 1-Type
Circle   3-Type
Suspension    

The Interval HIT $𝕀$

Inductive 𝕀: Type :=
    | 0𝕀 : 𝕀
    | 1𝕀 : 𝕀
    | seg: 0𝕀 = 1𝕀

Recursor

\[𝕀_{rec} \; (A: Type) \; (a, b: A) \; (s: a=b): 𝕀 ⟶ A\]
  • $𝕀_{rec} \; A \; a \; b \; s \; 0_𝕀 ≡ a$
  • $𝕀_{rec} \; A \; a \; b \; s \; 1_𝕀 ≡ b$
  • \[ap \; (𝕀_{rec} \; A \; a \; b \; s) \; seg = s: 𝕀_{rec} \; A \; a \; b \; s \; 0_{𝕀} = 𝕀_{rec} \; A \; a \; b \; s \; 1_{𝕀} ≡ a=b\]

Eliminator (for induction)

\[𝕀_{ind} \; (P: 𝕀 ⟶ Type) \; (a: P \, 0_{𝕀}) \; (b: P \, 1_{𝕀}) \; (s: \underbrace{seg \# a}_{≡ \texttt{transport} \; P \; seg \; a: P \, 1_{𝕀}} = b): ∀i: 𝕀. P \; i\]
  • $𝕀_{ind} \; A \; a \; b \; s \; 0_𝕀 ≡ a$
  • $𝕀_{ind} \; A \; a \; b \; s \; 1_𝕀 ≡ b$
  • \[ap \; (𝕀_{ind} \; P \; a \; b \; s) \; seg = s: seg \# (\underbrace{𝕀_{ind} \; P \; a \; b \; s \; 0_{𝕀}}_{≡ a}) = \underbrace{𝕀_{ind} \; P \; a \; b \; s \; 1_{𝕀}}_{≡ b}\]
\[ap: ∀A, B. (f: A ⟶ B) \; (x, y: A): x=y ⟶ fx = fy\] \[ap \; D: ∀A. (B: A ⟶ Type) \; (f: ∀x. B \, x) \; (x, y: A) \; (e: x=y): \underbrace{e \# (f \, x)}_{\texttt{transport} \; B \; e \; (f \, x)} = f \, y\]

$𝕀$ is contractible

\[IsContr \; 𝕀 \\ center: 0_{𝕀}: 𝕀 \\ P: ∀x: 𝕀. 0_{𝕀} = x\]

And

  • $P \; 0𝕀: 0_𝕀 = 0_𝕀 ≝ refl{0_𝕀}$
  • $P \; 1_𝕀: 0_𝕀 = 1_𝕀 ≝ seg$
\[seg = seg \, @ \, refl_{0_𝕀} = seg \# refl_{0_𝕀} = seg\]

$𝕀$ implies Functional Equality

If $𝕀$ exists in the type theory, then functional equality holds.

\[∀(A, B) \; (f, g: A ⟶ B), (e: ∀x, f \, x = g \, x) ⟶ f = g\]

Let

\[p ≝ λx:A. 𝕀_{rec} \; B \; (f \, x) \; (g \, x) \; (e \, x): A ⟶ (𝕀 ⟶ B)\]

Let

\[q ≝ λi, x. p \, x \, i: 𝕀 ⟶ (A ⟶ B)\]

Then one concludes with

\[ap \; q \; seg : q \; 0_𝕀 = q \; 1_𝕀\]

How to define HITs in Coq

Module Export Interval.
    Private Inductive Int: Type :=
        | zero: Int.
        | one: Int.

Axiom seg : zero = one.

Propositional Truncation

Inductive A : Type :=
    | tr: A  A
    | tr_eq: x, y: A. x=y

Recursor

\[\texttt{Squash_rec} \; (B: Type) \; (f: A ⟶ B)\; (HB: IsHProp \; B): \Vert A \Vert ⟶ B\]
  • $\texttt{Squash_rec} \; B \; f \; HB \; (tr \, a) ≡ f \, a$

  • \[∀x, y:A. ap \; (\texttt{Squash_rec} \; B \; f \; HB) (\texttt{tr_eq} x \; y) = HB \; (\underbrace{\texttt{Squash_rec} \; B \; f \; HB \; x}_{ = \; \texttt{Squash_rec} \; B \; f \; HB \; y \,: \; B})\]

NB: If $A$ is a mere proposition, then $\Vert A \Vert$ is equivalent to $A$:

\[A: HProp ⟶ \Vert A \Vert ≃ A\]

Eliminator

\[\texttt{Squash_ind} \; A \; (P: \Vert A \Vert ⟶ Type) \; (f: ∀x:A. P \; (tr \; x)) \; (HP: ∀x: A. IsHProp \; (P \, x)): ∀x: \Vert A \Vert. P \; x\]

Let

\[p ≝ \texttt{Squash_rec} \; (P \, x) \; f' \; (HP \, x) \; x\]

where

\[f' ≝ λy. \texttt{tr_eq} \; x \; (tr \, y)\#(f \, y): ∀y:A. P \, x\]

The Circle $S^1$

Inductive S^1 :=
    | base: S^1
    | loop: base=base

Eliminator

\[S^1\_ind \; (P: S^1 ⟶ Type) \; (b: P \; base) \; (l: loop \# b = b): ∀x: S^1. P \, x\]
  • $S^1_ind \; P \; b \; l \; base ≡ b$
  • \[ap \; D \; (S^1\_ind \; P \; b \; l) \; loop = l: loop\#b = b\]

NB: Next, we’ll see that there are strong connections with homotopy theory. We’ll show in HoTT that:

\[\Pi_1(S^1) = ℤ\]

$S^1$ is not contractible

\[¬ ∀x: S^1, p: x = x. p = refl_x\]

Why? Because we can show that

\[¬(loop = refl_{base})\]

Indeed: Assuming $A: Type, ¬(IsHSet \; A), e: loop = refl_{base}$, then you can show $∀x: A, p: x=x. p = refl_x$

Canonical Suspension

Leave a comment