74 Link 32 (from 7, 8, 14, 20): sameness as a kind

From here on, sameness is read as link 14 reads a statement: as a kind that has things. There is one way to make such a thing, the \(E(x,x)\) of link 7, and one way to use one, which is link 8 together with the leastness of link 20, read with things kept:

\begin{align*} \mathrm {refl}_x &: \mathrm {Id}(x,x), \\ c(x) : C(x,x,\mathrm {refl}_x) &\ \Rightarrow \ J(c)(x,y,p) : C(x,y,p), \qquad J(c)(x,x,\mathrm {refl}_x) = c(x) . \end{align*}

The four operations are four choices of \(C\) and \(c\).

Operation \(C(x,y,p)\) \(c(x)\) At \(\mathrm {refl}\)
transport \(\mathrm {tr}(p)\) \(Q(x) \to Q(y)\) \(\mathrm {id}\) \(\mathrm {tr}(\mathrm {refl}) = \mathrm {id}\)
reversal \(p^{-1}\) \(\mathrm {Id}(y,x)\) \(\mathrm {refl}_x\) \(\mathrm {refl}^{-1} = \mathrm {refl}\)
joining \(p \cdot q\) \(\mathrm {Id}(y,z) \to \mathrm {Id}(x,z)\) \(q \mapsto q\) \(\mathrm {refl} \cdot q = q\)
application \(\mathrm {ap}_f(p)\) \(\mathrm {Id}(f\,x, f\,y)\) \(\mathrm {refl}_{f\,x}\) \(\mathrm {ap}_f(\mathrm {refl}) = \mathrm {refl}\)

Each law is proved by taking \(C\) to be “the two sides are the same” and computing both sides at \(\mathrm {refl}\).

\begin{align*} p \cdot \mathrm {refl} = p &: & \mathrm {refl} \cdot \mathrm {refl} &= \mathrm {refl}, \\ p^{-1} \cdot p = \mathrm {refl} &: & \mathrm {refl}^{-1} \cdot \mathrm {refl} &= \mathrm {refl} \cdot \mathrm {refl} = \mathrm {refl}, \\ p \cdot p^{-1} = \mathrm {refl} &: & \mathrm {refl} \cdot \mathrm {refl}^{-1} &= \mathrm {refl}^{-1} = \mathrm {refl}, \\ (p^{-1})^{-1} = p &: & (\mathrm {refl}^{-1})^{-1} &= \mathrm {refl}, \\ (p \cdot q) \cdot r = p \cdot (q \cdot r) &: & (\mathrm {refl} \cdot q) \cdot r &= q \cdot r = \mathrm {refl} \cdot (q \cdot r) . \end{align*}
\begin{align*} \mathrm {ap}_f(p \cdot q) = \mathrm {ap}_f(p) \cdot \mathrm {ap}_f(q) &: & \mathrm {ap}_f(\mathrm {refl} \cdot q) &= \mathrm {ap}_f(q) = \mathrm {refl} \cdot \mathrm {ap}_f(q), \\ \mathrm {ap}_{g \circ f}(p) = \mathrm {ap}_g(\mathrm {ap}_f(p)) &: & \mathrm {refl} &= \mathrm {refl}, \\ \mathrm {ap}_{\mathrm {id}}(p) = p &: & \mathrm {refl} &= \mathrm {refl} . \end{align*}

The laws are not equations but things of an \(\mathrm {Id}\) of an \(\mathrm {Id}\), and between those there are laws again. This is the tower of levels.

Contraction. The paths out of \(a\) contract to \((a, \mathrm {refl}_a)\):

\begin{align*} C(a,y,p) &:= \mathrm {Id}\bigl ((a,\mathrm {refl}_a),\ (y,p)\bigr ), & c(a) &:= \mathrm {refl} . \end{align*}

This is “sameness is least” (link 20) with things kept.

Pairs and functions.

\begin{align*} \mathrm {Id}\bigl ((x,y),(x',y')\bigr ) &\simeq \mathrm {Id}(x,x') \times \mathrm {Id}(y,y'), \\ \mathrm {Id}(f,g) &\simeq \text {for all } x,\ \mathrm {Id}(f\,x,\ g\,x) . \end{align*}

The first is link 13 (by \(\mathrm {ap}_{\pi _1}\), \(\mathrm {ap}_{\pi _2}\) and \(J\) twice). In the second, the map from left to right is \(\mathrm {ap}\); the map back is assumed, and is the extensionality of link 12 with things kept.

Loops. The statement \(a=a\) is itself a kind:

\begin{align*} \Omega (X,a) &:= \mathrm {Id}(a,a) . \end{align*}

74.1 Link 33 (from 17, 32): levels

\begin{align*} \mathrm {isContr}(A) &:= \Sigma _{c}\, \Pi _{x}\, \mathrm {Id}(c,x), \\ \mathrm {isProp}(A) &:= \Pi _{x,y}\, \mathrm {Id}(x,y), \\ \mathrm {isSet}(A) &:= \Pi _{x,y}\, \mathrm {isProp}\bigl (\mathrm {Id}(x,y)\bigr ) . \end{align*}

If \(h\) witnesses \(\mathrm {isContr}(A)\) then \(h(x)^{-1} \cdot h(y)\) is a thing of \(\mathrm {Id}(x,y)\), so \(A\) is a proposition. If \(f : \Pi _{x,y}\,\mathrm {Id}(x,y)\) then, for every \(p : \mathrm {Id}(x,y)\),

\begin{align*} p &= f(x,x)^{-1} \cdot f(x,y) && \bigl (J:\ \mathrm {refl} = f(x,x)^{-1} \cdot f(x,x)\bigr ), \end{align*}

so any two such \(p\) are the same, and \(A\) is a set. The truncation \(\lVert A \rVert \) is the kind made from \(|a|\) for \(a : A\) together with the rule that any two of its things are the same. It is already a proposition, so

\begin{align*} \lVert \lVert A \rVert \rVert &\simeq \lVert A \rVert , & \mathrm {Fix}(\lVert - \rVert ) &= \text {propositions}, & \mathrm {Fix}(\lVert - \rVert _0) &= \text {sets} . \end{align*}

There are maps \(A \to \lVert A \rVert \to \neg \neg A\), and “some \(x\), \(P\)” is \(\lVert \Sigma _x P \rVert \); the “some” of link 18 is this pressed once more by \(\neg \neg \). The idempotent \(\neg \neg \) of link 17 is one of these, with the two-valued statements as fixed points. Links 1–31 are the computation at the level of sets: a level chosen, not a collapse.

74.2 Link 34 (from 2, 3, 4): simplices

Let \(X_n\) be the \((n+1)\)-tuples. Deleting a place and writing a place twice are \(\pi \) and \(\Delta \) at position \(i\):

\begin{align*} d_i(x_0,\dots ,x_n) &:= (x_0,\dots ,\widehat {x_i},\dots ,x_n), & s_i(x_0,\dots ,x_n) &:= (x_0,\dots ,x_i,x_i,\dots ,x_n) . \end{align*}
\begin{align*} d_i\,s_i &= \mathrm {id} = d_{i+1}\,s_i && \text {(link 4)}, \\ d_i\,d_j &= d_{j-1}\,d_i && (i < j), \\ s_i\,s_j &= s_{j+1}\,s_i && (i \le j) . \end{align*}

For \(n = 1\) these are links 2 and 3: \(d_1 = \pi _1\), \(d_0 = \pi _2\), \(s_0 = \Delta \). The boundary of link 31 is \(\partial = \sum _i d_i\). In a kind \(X\), a \(0\)-simplex is a point, a \(1\)-simplex is \((x,y,p)\) with \(p : \mathrm {Id}(x,y)\), and a \(2\)-simplex is \((p,q,r,\alpha )\) with \(\alpha : \mathrm {Id}(p \cdot q,\ r)\).

74.3 Link 35 (from 11, 32, 33, 34): \(\infty \)-groupoids, categories, \(\infty \)-categories

“Exactly one filler” is read as \(\mathrm {isContr}\) of the kind of fillers.

Every kind is an \(\infty \)-groupoid. The fillers of a triangle contract:

\begin{align*} \text {inner } (p,q) &: & \Sigma _{r}\, \mathrm {Id}(p \cdot q,\ r) &\quad \text {centre } (p \cdot q,\ \mathrm {refl}), \\ \text {outer } (p,r) &: & \Sigma _{q}\, \mathrm {Id}(p \cdot q,\ r) \simeq \Sigma _{q}\, \mathrm {Id}(q,\ p^{-1} \cdot r) &\quad \text {centre } (p^{-1} \cdot r,\ \mathrm {refl}) . \end{align*}

The first is the contraction of link 32. The second moves \(p\) across by the reversal laws. Joining is the inner filler and reversal is the outer filler, so link 8 was the filling condition in dimension two.

Categories. When the arrows between two objects form a set, link 11 gives a category: the identity, the composite, and the laws.

\(\infty \)-categories. When the arrows form a kind, the condition is

\begin{align*} \text {for all composable } (f,g):\quad \mathrm {isContr}\bigl (\Sigma _{h}\ \text {``$h$ is a composite of $f$ and $g$''}\bigr ) . \end{align*}

The composite \(g \circ f\) is the centre, and the unit laws and associativity hold as things one level up.

Example Arrows from \(x\) to \(y\) Structure
any kind \(X\) \(\mathrm {Id}(x,y)\) \(\infty \)-groupoid
all kinds \(A \to B\) \(\infty \)-category

74.4 Link 36 (from 6, 22, 23, 27, 31, 32, 33): the \(\infty \)-topos, stability, the circle

All kinds. Pairs (links 5, 10), functions (link 11), sameness (link 32) and a kind \(\mathcal {U}\) of all kinds make the \(\infty \)-topos. \(\mathcal {U}\) is the \(2^X\) of link 19 one level up: a family of kinds over \(A\) is a map \(A \to \mathcal {U}\), and the propositions are \(\mathrm {Fix}(\lVert - \rVert )\) inside it.

Smaller toposes. They are the fixed points of idempotents \(\bigcirc \) with \(\bigcirc \bigcirc A \simeq \bigcirc A\).

\(\bigcirc \) Fixed points
\(\lVert - \rVert _n\) kinds with nothing above level \(n\)
\(\neg \neg \) two-valued (links 12–18)
sheafification (link 27) sheaves

Loops and suspension. \(\Sigma X\) is the kind made from two points \(N\), \(S\) and a path from \(N\) to \(S\) for each thing of \(X\). A map out of it sends \(N\) and \(S\) to points and each \(x\) to a path between them, so

\begin{align*} (\Sigma X \to Y) &\simeq (X \to \Omega Y), \end{align*}

an adjunction of the shape of link 6. A stable object is a sequence with \(E_n \simeq \Omega E_{n+1}\), and the \(\partial \partial = 0\) of link 31 is its two-valued shadow.

The circle. \(S^1\) is the kind made from a point \(b\) and a loop \(\ell : \mathrm {Id}(b,b)\). The loop taken \(n\) times is \(\ell ^{\,n}\), by the iteration of link 22 for \(n \ge 0\) and with \(\ell ^{-1}\) for \(n < 0\) (link 23).

Step 1: a family over the circle. A family over \(S^1\) is a kind for \(b\) and a way to carry it around \(\ell \):

\begin{align*} \mathrm {code}(b) &:= \mathbb {Z}, & \mathrm {tr}^{\mathrm {code}}(\ell ) &:= (n \mapsto n+1) . \end{align*}

The second line uses that \(n \mapsto n+1\) has the inverse \(n \mapsto n-1\), so it is a sameness of kinds.

Step 2: from paths to numbers, at every point. For any \(x\) and \(p : \mathrm {Id}(b,x)\),

\begin{align*} \mathrm {enc}_x(p) &:= \mathrm {tr}^{\mathrm {code}}(p)(0) \ :\ \mathrm {code}(x) . \end{align*}

Step 3: from numbers to paths, at every point. A map \(\mathrm {dec}_x : \mathrm {code}(x) \to \mathrm {Id}(b,x)\) is given at \(b\) and must agree with itself after going round \(\ell \):

\begin{align*} \mathrm {dec}_b(n) &:= \ell ^{\,n}, \\ \text {round } \ell :\quad \mathrm {dec}_b(n-1) \cdot \ell &= \ell ^{\,n-1} \cdot \ell \\ &= \ell ^{\,n} \\ &= \mathrm {dec}_b(n) . \end{align*}

Step 4: paths to numbers and back. Because \(x\) is free, \(J\) applies: it is enough to compute at \(x = b\), \(p = \mathrm {refl}\).

\begin{align*} \mathrm {dec}_b(\mathrm {enc}_b(\mathrm {refl})) &= \mathrm {dec}_b\bigl (\mathrm {tr}^{\mathrm {code}}(\mathrm {refl})(0)\bigr ) \\ &= \mathrm {dec}_b(0) \\ &= \ell ^{\,0} \\ &= \mathrm {refl} . \end{align*}

Hence \(\mathrm {dec}_x(\mathrm {enc}_x(p)) = p\) for every \(x\) and \(p\).

Step 5: numbers to paths and back. By induction on \(n\) (link 21), using that transport along a joined path is transport twice:

\begin{align*} \mathrm {enc}_b(\ell ^{\,0}) &= \mathrm {tr}^{\mathrm {code}}(\mathrm {refl})(0) = 0, \\ \mathrm {enc}_b(\ell ^{\,n+1}) &= \mathrm {tr}^{\mathrm {code}}(\ell )\bigl (\mathrm {tr}^{\mathrm {code}}(\ell ^{\,n})(0)\bigr ) \\ &= \mathrm {enc}_b(\ell ^{\,n}) + 1 \\ &= n + 1 , \end{align*}

and in the same way \(\mathrm {enc}_b(\ell ^{\,n-1}) = n - 1\) with \(\ell ^{-1}\).

Steps 4 and 5 at \(x = b\) give

\begin{align*} \Omega (S^1) = \mathrm {Id}(b,b) &\simeq \mathbb {Z} . \end{align*}

The things of \(a=a\) on the circle are the integers. The method is that of link 21, where \(0 \neq S(n)\) was shown by the reading \(\mathrm {code}(0) = 1\), \(\mathrm {code}(S\,n) = 0\).

74.5 What links 32–36 use

Assumed Used in
\(J\): sameness is made by \(\mathrm {refl}\) alone, with things kept all of link 32
sameness of functions is sameness at every value links 32, 33
the kind \(\mathcal {U}\) of all kinds link 36
two kinds that map back and forth are the same the line \(\mathrm {code}(\ell )\) only
kinds made with paths (\(\lVert - \rVert \), \(\Sigma X\), \(S^1\)) links 33, 36

74.6 Cubical Agda— Verified

Links 1–31 use none of these. Links 32, 33, 35 and the circle of link 36 are checked in the Cubical Agda file OneMoveHigher.agda (Listing 6), with the options –cubical –safe –guardedness and the cubical library; the file checks with no errors and, being –safe, with no postulates. In it the four operations and their laws, the contraction, the passage from contractible to proposition to set, the idempotence of truncation, and the contraction of the fillers of both triangles are proved from \(J\). The equivalence \(\mathrm {Id}(b,b) \simeq \mathbb {Z}\) is taken from the library. Two rows of the table are theorems there and not assumptions: sameness of functions at every value, and sameness of kinds that map back and forth. Link 34 and the stable part of link 36 are in the text only. The Lean core treats all proofs of a sameness as one, so these levels are checked in Cubical Agda and not in OneMove.lean.

PIC

Figure 15: OneMoveHigher.agda checked by Agda 2.8.0.2 with –cubical –safe –guardedness and the cubical library. The file contains no postulates and the check ends with exit code 0.

Listing 6: OneMoveHigher.agda: sameness as a kind.

OneMoveHigher.agda

{-# OPTIONS --cubical --safe --guardedness #-}

{-
  OneMoveHigher.agda
  Links 32, 33, 35, 36 of the chain: sameness as a kind.

  Everything in links 32-35 is proved from J alone (plus one cubical
  line for the reversed singleton).  The circle of link 36 is taken
  from the cubical library.

  Link 34 (simplices) and the stable part of link 36 are in the text
  only.
-}

module OneMoveHigher where

open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Isomorphism using (Iso)
open import Cubical.Data.Int using (ℤ)
open import Cubical.HITs.S1.Base using (S¹; base; loop; ΩS¹Isoℤ)

private
  variable
    ℓ ℓ' : Level

------------------------------------------------------------------------
-- Link 32: sameness as a kind.  One way to make (refl), one way to
-- use (J).  The four operations and their laws.

module Link32 {A : Type ℓ} where

  -- reversal
  inv : {x y : A} → x ≡ y → y ≡ x
  inv {x = x} p = J (λ y _ → y ≡ x) refl p

  inv-refl : {x : A} → inv (refl {x = x}) ≡ refl
  inv-refl {x = x} = JRefl (λ y _ → y ≡ x) refl

  -- joining
  cat : {x y z : A} → x ≡ y → y ≡ z → x ≡ z
  cat {x = x} {z = z} p = J (λ y _ → y ≡ z → x ≡ z) (λ q → q) p

  cat-refl : {x z : A} (q : x ≡ z) → cat refl q ≡ q
  cat-refl {x = x} {z = z} q i =
    JRefl (λ y _ → y ≡ z → x ≡ z) (λ q → q) i q

  -- application
  ap : {B : Type ℓ'} (f : A → B) {x y : A} → x ≡ y → f x ≡ f y
  ap f {x = x} p = J (λ y _ → f x ≡ f y) refl p

  ap-refl : {B : Type ℓ'} (f : A → B) {x : A} → ap f (refl {x = x}) ≡ refl
  ap-refl f {x = x} = JRefl (λ y _ → f x ≡ f y) refl

  -- transport
  tr : (Q : A → Type ℓ') {x y : A} → x ≡ y → Q x → Q y
  tr Q {x = x} p = J (λ y _ → Q x → Q y) (λ u → u) p

  tr-refl : (Q : A → Type ℓ') {x : A} (u : Q x) → tr Q refl u ≡ u
  tr-refl Q {x = x} u i = JRefl (λ y _ → Q x → Q y) (λ u → u) i u

  -- the laws: put p at refl and compute

  cat-refl-r : {x y : A} (p : x ≡ y) → cat p refl ≡ p
  cat-refl-r {x = x} p = J (λ y p → cat p refl ≡ p) (cat-refl refl) p

  inv-l : {x y : A} (p : x ≡ y) → cat (inv p) p ≡ refl
  inv-l {x = x} p =
    J (λ y p → cat (inv p) p ≡ refl)
      (cong (λ r → cat r refl) inv-refl ∙ cat-refl refl)
      p

  inv-r : {x y : A} (p : x ≡ y) → cat p (inv p) ≡ refl
  inv-r {x = x} p =
    J (λ y p → cat p (inv p) ≡ refl)
      (cat-refl (inv refl) ∙ inv-refl)
      p

  inv-inv : {x y : A} (p : x ≡ y) → inv (inv p) ≡ p
  inv-inv {x = x} p =
    J (λ y p → inv (inv p) ≡ p)
      (cong inv inv-refl ∙ inv-refl)
      p

  assoc : {x y z w : A} (p : x ≡ y) (q : y ≡ z) (r : z ≡ w)
        → cat (cat p q) r ≡ cat p (cat q r)
  assoc {x = x} {z = z} p q r =
    J (λ y p → (q : y ≡ z) → cat (cat p q) r ≡ cat p (cat q r))
      (λ q → cong (λ s → cat s r) (cat-refl q) ∙ sym (cat-refl (cat q r)))
      p q

  -- contraction: the paths out of a contract to (a , refl)
  contr-out : (a y : A) (p : a ≡ y)
            → Path (Σ[ x ∈ A ] (a ≡ x)) (a , refl) (y , p)
  contr-out a y p =
    J (λ y p → Path (Σ[ x ∈ A ] (a ≡ x)) (a , refl) (y , p)) refl p

  -- the paths into r contract to (r , refl)
  contr-in : (r : A) → isContr (Σ[ q ∈ A ] (q ≡ r))
  contr-in r =
    (r , refl) , (λ s i → (snd s (~ i) , (λ j → snd s (~ i ∨ j))))

  -- sameness of functions is sameness at every value
  funext' : {B : Type ℓ'} {f g : A → B} → ((x : A) → f x ≡ g x) → f ≡ g
  funext' h i x = h x i

  -- a = a as a kind
  Loop : A → Type ℓ
  Loop a = a ≡ a

open Link32

------------------------------------------------------------------------
-- Link 33: levels.

module Link33 where

  contr→prop : {A : Type ℓ} → isContr A → isProp A
  contr→prop (c , h) x y = cat (inv (h x)) (h y)

  prop-key : {A : Type ℓ} (f : isProp A) {x y : A} (p : x ≡ y)
           → p ≡ cat (inv (f x x)) (f x y)
  prop-key f {x = x} p =
    J (λ y p → p ≡ cat (inv (f x x)) (f x y)) (sym (inv-l (f x x))) p

  prop→set : {A : Type ℓ} → isProp A → isSet A
  prop→set f x y p q = prop-key f p ∙ sym (prop-key f q)

  -- pressing a kind flat: the truncation, and that it is idempotent
  data Tr (A : Type ℓ) : Type ℓ where
    inc : A → Tr A
    sq  : (x y : Tr A) → x ≡ y

  recTr : {A : Type ℓ} {P : Type ℓ'} → isProp P → (A → P) → Tr A → P
  recTr h f (inc a) = f a
  recTr h f (sq x y i) = h (recTr h f x) (recTr h f y) i

  flatten : {A : Type ℓ} → Tr (Tr A) → Tr A
  flatten = recTr sq (λ t → t)

  flatten-inc : {A : Type ℓ} (t : Tr A) → flatten (inc t) ≡ t
  flatten-inc t = refl

  inc-flatten : {A : Type ℓ} (t : Tr (Tr A)) → inc (flatten t) ≡ t
  inc-flatten t = sq (inc (flatten t)) t

------------------------------------------------------------------------
-- Link 35: every kind is an ∞-groupoid in dimension two: the fillers
-- of a triangle contract.

module Link35 {A : Type ℓ} where

  -- inner triangle: joining
  inner : {x y z : A} (p : x ≡ y) (q : y ≡ z)
        → isContr (Σ[ r ∈ x ≡ z ] (cat p q ≡ r))
  inner p q =
    (cat p q , refl) , (λ s → contr-out (cat p q) (fst s) (snd s))

  -- outer triangle: reversal
  outer : {x y z : A} (p : x ≡ y) (r : x ≡ z)
        → isContr (Σ[ q ∈ y ≡ z ] (cat p q ≡ r))
  outer {x = x} {z = z} p =
    J (λ y p → (r : x ≡ z) → isContr (Σ[ q ∈ y ≡ z ] (cat p q ≡ r)))
      (λ r → subst isContr
               (λ i → Σ[ q ∈ x ≡ z ] (cat-refl q (~ i) ≡ r))
               (contr-in r))
      p

------------------------------------------------------------------------
-- Link 36: the circle.  The things of base = base are the integers.

module Link36 where

  circle : Iso (base ≡ base) ℤ
  circle = ΩS¹Isoℤ

74.7 Link 37 (from 2, 3, 4, 10, 11, 12): triangles, \(K\) and \(S\), lambda

The two triangles are the idempotent law and the fixed-point law. The unit and the counit are not new. They are the idempotent \(a \times b\) of link 10 and the idempotent \([b \to c]\) of link 11, written with the places grouped differently.

\begin{align*} \eta (x)(y) &:= (a \times b)(x,y) = (a\,x,\ b\,y), \\ \varepsilon (f,y) &:= [b \to c](f)(y) = c\bigl (f(b\,y)\bigr ) . \end{align*}

The first triangle says that \(a \times b\) is idempotent (link 10):

\begin{align*} \varepsilon (\eta (x), y) &= (a \times b)\bigl (\eta (x)(b\,y)\bigr ) \\ &= (a \times b)\bigl ((a \times b)(x,\ b\,y)\bigr ) \\ &= (a \times b)(x,\ b\,y) && \text {($a \times b$ is idempotent)} \\ &= (a\,x,\ b\,b\,y) \\ &= (a\,x,\ b\,y) && \text {($b$ is idempotent)} \\ &= \eta (x)(y) . \end{align*}

The second triangle says that an arrow is a fixed point of the sandwich (link 11):

\begin{align*} \bigl (y \mapsto \varepsilon (f,y)\bigr ) &= \bigl (y \mapsto c(f(b\,y))\bigr ) \\ &= [b \to c](f) \\ &= f && \text {($f$ is a fixed point)} . \end{align*}

So the triangles are the one move of this section, cut in two.

Triangle 1: idempotent, \(e\,e = e\) Triangle 2: fixed point, \(e\,x = x\)
\(\Delta \dashv \times \) \(e_1 e_1 = e_1\) (link 4 to link 7) \(p = (\pi _1 p, \pi _2 p)\) (link 5)
currying \((a \times b)(a \times b) = a \times b\) (link 10) \(f = [b \to c](f)\) (link 11)

For \(a = b = c = \mathrm {id}\) they take the familiar form

\begin{align*} \varepsilon (\eta (x), y) &= (x,y), & \bigl (y \mapsto \varepsilon (f,y)\bigr ) &= f . \end{align*}

\(K\) and \(S\). Reading \(\eta \) with \(\pi _1\) gives \(K\); placing with \(\Delta \) and then applying \(\varepsilon \) gives \(S\).

\begin{align*} K(x)(y) &:= \pi _1\bigl (\eta (x)(y)\bigr ) \\ &= \pi _1(x,y) \\ &= x, \\[4pt] S(f)(g)(x) &:= \varepsilon \bigl (f(\pi _1 \Delta x),\ g(\pi _2 \Delta x)\bigr ) \\ &= \varepsilon (f\,x,\ g\,x) \\ &= f\,x\,(g\,x) . \end{align*}

\(K\) discards (link 3) and \(S\) uses twice (link 2). Joined, they give link 4:

\begin{align*} S\,K\,K\,x &= K\,x\,(K\,x) \\ &= \pi _1(x,\ K\,x) \\ &= x , \end{align*}

and the second triangle removes \(x\): \(SKK = \mathrm {id}\).

Erasing a variable. For a written expression \(t\), define \([x]\,t\) by its shape:

\begin{align*} [x]\,x &:= SKK, \\ [x]\,c &:= K\,c && \text {($x$ does not occur in $c$)}, \\ [x]\,(t\,u) &:= S\,([x]t)\,([x]u) . \end{align*}

The \(\beta \) rule. \(([x]t)\,u = t[u/x]\), by the three cases:

\begin{align*} ([x]x)\,u &= SKK\,u = u = x[u/x], \\ ([x]c)\,u &= K\,c\,u = c = c[u/x], \\ \bigl ([x](t_1 t_2)\bigr )\,u &= S\,([x]t_1)\,([x]t_2)\,u \\ &= \bigl ([x]t_1\,u\bigr )\bigl ([x]t_2\,u\bigr ) \\ &= t_1[u/x]\ t_2[u/x] = (t_1 t_2)[u/x] . \end{align*}

Writing \(\lambda x.\,t := [x]\,t\),

\begin{align*} (\lambda x.\,t)\,u &= t[u/x] . \end{align*}

The \(\lambda \) is an abbreviation for an expression in \(S\) and \(K\), and \(\beta \) is a computation from the equations of \(S\) and \(K\).

The \(\eta \) rule is the second triangle. If \(x\) does not occur in \(f\),

\begin{align*} \lambda x.\,f\,x &= S\,(K\,f)\,(SKK), \\ S\,(K\,f)\,(SKK)\,u &= K\,f\,u\,(SKK\,u) \\ &= f\,u , \end{align*}

and the second triangle removes \(u\): \(\lambda x.\,f\,x = f\). So one more case may be used when erasing: \([x](f\,x) := f\) when \(x\) does not occur in \(f\).

Composition and duplication, by erasing. For \(\lambda g.\,\lambda f.\,\lambda x.\,g\,(f\,x)\):

\begin{align*} [x]\bigl (g\,(f\,x)\bigr ) &= S\,([x]g)\,\bigl ([x](f\,x)\bigr ) = S\,(K\,g)\,f, \\ [f]\bigl (S\,(K\,g)\,f\bigr ) &= S\,(K\,g), \\ [g]\bigl (S\,(K\,g)\bigr ) &= S\,([g]S)\,\bigl ([g](K\,g)\bigr ) = S\,(K\,S)\,K . \end{align*}

So \(S(KS)K\) is not found by hand; it is what erasing returns. For \(\lambda f.\,\lambda x.\,f\,x\,x\):

\begin{align*} [x](f\,x\,x) &= S\,\bigl ([x](f\,x)\bigr )\,([x]x) = S\,f\,(SKK), \\ [f]\bigl (S\,f\,(SKK)\bigr ) &= S\,\bigl ([f](S\,f)\bigr )\,\bigl ([f](SKK)\bigr ) = S\,S\,\bigl (K\,(SKK)\bigr ), \\ S\,S\,\bigl (K(SKK)\bigr )\,f\,x &= S\,f\,(SKK)\,x = f\,x\,(SKK\,x) = f\,x\,x . \end{align*}

Read as statements. By link 14 the three cases of erasing are the three steps of “from a proof of \(Q\) under the assumption \(P\), a proof of \(P \Rightarrow Q\)”.

Erasing In a proof
\([x]\,x = SKK\) the assumption itself: \(P \Rightarrow P\)
\([x]\,c = K\,c\) a line that does not use it: from \(Q\), \(P \Rightarrow Q\)
\([x](t\,u) = S\,([x]t)\,([x]u)\) a line obtained by detachment

The places return. Pairs, readings and the diagonal are expressions in \(S\) and \(K\):

\begin{align*} \langle a,b \rangle &:= \lambda k.\,k\,a\,b, \\ \pi _1 := \lambda p.\,p\,K &: \quad \pi _1\langle a,b \rangle = K\,a\,b = a, \\ \pi _2 := \lambda p.\,p\,(K\,\mathrm {id}) &: \quad \pi _2\langle a,b \rangle = K\,\mathrm {id}\,a\,b = \mathrm {id}\,b = b, \\ \Delta := \lambda x.\,\langle x,x \rangle &: \quad \pi _1(\Delta x) = x . \end{align*}

Links 2–4 gave \(K\) and \(S\), and \(K\) and \(S\) give links 2–4 back. The two truth values are \(K\) and \(K\,\mathrm {id}\), and negation exchanges them, as \(\sigma \) does.

The untyped side. Without types every \(f\) has a fixed point:

\begin{align*} Y\,f &:= \bigl (\lambda x.\,f(x\,x)\bigr )\bigl (\lambda x.\,f(x\,x)\bigr ) \\ &= f\Bigl (\bigl (\lambda x.\,f(x\,x)\bigr )\bigl (\lambda x.\,f(x\,x)\bigr )\Bigr ) \\ &= f\,(Y\,f) . \end{align*}

Applied to negation this would give \(P = \neg P\), hence \(1 = 0\). So the logic of links 9–18 is carried out on the typed side, inside the fixed points of idempotents. The untyped side is the standing assumption of this section: idempotents are themselves things that maps can be applied to.

What is checked. The two triangles are the statements tri_one, tri_two and tri_two_arr of OneMove.lean, and \(SKK\) and \(S(KS)K\) are SKK and Bc_app. Erasing is a rule on written expressions and is not in the file; \(Y\) has no type and cannot be.

74.8 Higher categories: iterating \(a=a\)

A proof of \(a=a\) is a path (Section 756). Two paths can again be compared, and so can two comparisons. Asking “\(=\)” again at every level, without end, is all that a higher category is.

74.9 The levels

level what where it already appeared
\(0\) points the points of a kind
\(1\) paths \(p:a=b\) joining, inverting (Section 756.3)
\(2\) paths between paths \(p\cdot (q\cdot r)=(p\cdot q)\cdot r\) was a path, not an equation
\(3\) paths between those the two ways to re-bracket four paths agree
\(\vdots \) without end the whole of a level (C26)

A kind with all its levels is an \(\infty \)-groupoid: every path can be inverted. An \(\infty \)-category is the same with arrows at level \(1\) that need not be invertible.

74.10 Shapes: simplices come from \(\mathbb N\)

Let \([n]=\mathrm {Fin}(n+1)=\{0<1<\dots <n\}\) (Section 69.6), with the maps that keep the order. Leaving out the place \(i\) is the face \(d_i\), and using the place \(i\) twice is the degeneracy \(s_i\): the acts \(\pi \) and \(\Delta \) of Section 755.1, on ordered places.

Counting. The maps \([m]\to [n]\) are the weakly increasing words of length \(m+1\) in \(n+1\) letters, \(\binom {m+n+1}{m+1}\) of them: \(6\) for \([1]\to [2]\), \(10\) for \([2]\to [2]\), \(35\) for \([3]\to [3]\).

The identity of faces. For \(i<j\), \(d_i\,d_j=d_{j-1}\,d_i\): on \((0123)\), leaving out \(3\) and then place \(1\) gives \((02)\), and leaving out \(1\) and then place \(2\) gives \((02)\).

A simplicial kind assigns to each \([n]\) a kind of \(n\)-simplices, with faces and degeneracies: a family glued along the maps of the shapes, as a sheaf is (Section 71.6).

74.11 Filling horns is closing lids

The horn \(\Lambda ^{n}_{k}\) is the \(n\)-simplex without its inside and without the face opposite the corner \(k\): an open box (Section 756.3).

horns that can be filled name what it is
all Kan complex an \(\infty \)-groupoid
the inner ones, \(0<k<n\) quasi-category an \(\infty \)-category
the inner ones, in exactly one way nerve of a category a category

Filling \(\Lambda ^{2}_{1}\), two arrows end to start, gives a composite together with the triangle that witnesses it. Filling the inner horns of dimension \(3\) is associativity, and the next dimension is the agreement of re-bracketings. Every law becomes “a filler exists”. The composite is not one arrow; the kind of composites has exactly one point (Section 756.4).

74.12 The nerve tells \(\mathbb F_2\) from \(B\)

For a system with one object, an \(n\)-simplex of the nerve is a word of \(n\) arrows; a \(2\)-simplex is \((a,b,c)\) with \(c=a\cdot b\).

\(\mathbb F_2\). There are \(2^{n}\) simplices in dimension \(n\). The outer horn with \(a\) and \(c\) given asks for \(b\) with \(a+b=c\); it is \(b=c-a\), and the only one. All horns can be filled: the nerve of \(\mathbb F_2\) is an \(\infty \)-groupoid.

\(B\). With \(1+1=1\), the outer horn \(a=1\), \(c=0\) asks for \(b\) with \(1\vee b=0\); there is none. The inner horn is filled by \(a\vee b\). The nerve of \(B\) is a category and not a groupoid.

So an invertible arrow (\(\sigma \)) gives a groupoid, and an idempotent one (\(c_0\)) only a category (Section 755.6). As a space the nerve of \(\mathbb F_2\) is \(S^{\infty }/\{\pm 1\}\): the top of the ladder \(S^{0},S^{1},S^{3},\dots \) of Section 70.5, divided by the sign.

74.13 Cutting off levels

level name in the chain
\(-2\) exactly one point \(1\)
\(-1\) at most one point statements, “some”
\(0\) sets the whole first road, where (A) holds
\(1\) groupoids \(S^{1}\); the kinds with \(2=2\) in two ways
\(\infty \) \(\infty \)-groupoids the kinds of the second road

Each level is contained in the next. With arrows that need not be invertible the same ladder reads: orders, categories, \(\infty \)-categories. The first road is the theory cut off at level \(0\).

74.14 Loops, suspension, and their adjunction

Loops. \(\Omega X=(\mathrm {base}=\mathrm {base})\): the pullback of the point along itself.

Suspension. \(\Sigma X\) is the least kind with two points and a path between them for each point of \(X\) (Section 756.8); so an arrow \(\Sigma A\to B\) is two points of \(B\) and a path between them for each point of \(A\). Then \(\Sigma S^{0}=S^{1}\), and \(\Sigma S^{1}=S^{2}\).

Adjunction. \(\Sigma \dashv \Omega \) for kinds with a chosen point: an arrow \(\Sigma A\to B\) is an arrow \(A\to \Omega B\), sending \(a\) to the path of \(a\) followed by the path of the chosen point backwards. For \(A=S^{0}\) both sides are one loop in \(B\).

Homotopy groups. \(\pi _n(X)\) is \(\Omega ^{n}X\) cut off at level \(0\); \(\pi _1(S^{1})=\mathbb Z\) (Section 756.9).

From level \(2\) on, loops commute. Paths between paths can be joined in two directions, \(\cdot \) and \(\circ \), with the same unit and with the square \((a\cdot b)\circ (c\cdot d)=(a\circ c)\cdot (b\circ d)\). Then

\begin{align} a\circ b&=(a\cdot 1)\circ (1\cdot b)=(a\circ 1)\cdot (1\circ b)=a\cdot b, \tag{1770}\\ a\circ b&=(1\cdot a)\circ (b\cdot 1)=(1\circ b)\cdot (a\circ 1)=b\cdot a, \tag{1771}\end{align}

so \(a\cdot b=b\cdot a\): \(\pi _n\) is commutative for \(n\ge 2\). It is a square that closes, as on the torus.

74.15 Families, the ladder of spheres, and what lies beyond

A kind over a kind (Section 757.4) is a family whose fibres are carried along paths. Keeping only the direction of a pair of numbers gives, at each step of the ladder of Section 70.5, a family of spheres over a sphere:

\[ S^{1}\to S^{1},\qquad S^{3}\to S^{2},\qquad S^{7}\to S^{4},\qquad S^{15}\to S^{8}, \]
with fibres \(S^{0},S^{1},S^{3},S^{7}\).

The kind of all kinds. The \(\infty \)-groupoids with their arrows have limits, colimits, and a kind \(\mathcal U\) of kinds; univalence (Section 756.7) says that \(\mathcal U\) classifies families. Cut off at level \(0\) this is the category of sets.

Inverting suspension. A sequence \(E_n\) with \(\Omega E_{n+1}=E_n\) is \(\Sigma \) inverted, as \(\mathbb Z\) was \(s\) inverted (Section 69.9); in it every level commutes. With \(K(\mathbb Z,1)=S^{1}\) and \(\Omega K(\mathbb Z,n+1)=K(\mathbb Z,n)\), the arrows \(X\to K(\mathbb Z,n)\) cut off at level \(0\) are the cohomology of \(X\): what fails to glue, as in Section 71.9.

74.16 What is used

\[ \begin {aligned} a=a\ &\xrightarrow {\ \text {again}\ }\ \text {paths at every level}\ \xrightarrow {\ [n]=\mathrm {Fin}(n+1)\ }\ \text {simplices}\\ &\xrightarrow {\ \text {horns}\ }\ \begin {cases}\text {all: }\infty \text {-groupoids}\\ \text {inner: }\infty \text {-categories}\end {cases} \ \to \ \Omega ,\ \Sigma \ \to \ \pi _n \end {aligned} \]

The counts, the identity of faces, the horns of \(\mathbb F_2\) and of \(B\), and the argument for commutativity are computed in full. The following are stated and not computed: that Kan complexes are the \(\infty \)-groupoids of Section 74.9; the theory of limits, adjoints and representable functors in quasi-categories; the families of spheres; and the last two paragraphs of Section 74.15. Categories with non-invertible arrows above level \(1\) are not treated.

74.17 Lean 4 and Cubical Agda — Verified

The file Simplex.lean (core Lean 4, no axioms) checks the identity of faces on the \(3\)-simplex, the counts \(6,10,20,35\) of order-preserving maps, that every horn of dimension \(2\) of the nerve of \(\mathbb F_2\) has exactly one filler, that the nerve of \(B\) fills the inner horn and has an outer horn with no filler, associativity of both, and the count \(2^{n}\). The file Higher.agda (Cubical Agda, –safe) checks that associativity, the unit and the inverse are paths between paths and that the two re-bracketings of four paths agree; the inclusions of levels \(-2\) to \(1\), with \(2\) a set and the loops of the circle a set; that loops at level \(2\) commute; that \(\Sigma S^{0}\) is the circle; that an arrow out of a suspension is two points and a family of paths; and \(\pi _1(S^{1})=\mathbb Z\). Commutativity, the pentagon and the last statement are taken from the library.

PIC

Figure 16: The file Higher.agda checked by Cubical Agda (Agda 2.8.0.2) with the cubical library, under –safe: exit code \(0\), no errors and no warnings.

PIC

Figure 17: The file Simplex.lean in the Lean 4 web editor (Lean v4.37.0-rc1): no errors and no warnings. All eleven #print axioms lines report that no axioms are used.

Listing 7: Higher.agda: paths at every level.

Higher.agda

{-# OPTIONS --cubical --safe --guardedness #-}

{-
  Higher.agda
  Iterating "=": paths, paths between paths, and so on.
  Checked in Cubical Agda with the cubical library, under --safe.
-}

module Higher where

open import Cubical.Foundations.Prelude
open import Cubical.Foundations.Equiv
open import Cubical.Foundations.Isomorphism
open import Cubical.Foundations.HLevels
open import Cubical.Foundations.GroupoidLaws
open import Cubical.Foundations.Pointed
open import Cubical.Data.Nat
open import Cubical.Data.Bool
open import Cubical.Data.Int
open import Cubical.Data.Sigma
open import Cubical.HITs.S1
open import Cubical.HITs.Susp
open import Cubical.Homotopy.Loopspace

private
  variable
    ℓ : Level
    A B : Type ℓ

------------------------------------------------------------------------
-- 1. The laws are paths, one level up
------------------------------------------------------------------------

-- level 2: associativity is a path between paths
assoc₂ : {a b c d : A} (p : a ≡ b) (q : b ≡ c) (r : c ≡ d)
       → p ∙ (q ∙ r) ≡ (p ∙ q) ∙ r
assoc₂ = assoc

unitʳ : {a b : A} (p : a ≡ b) → p ≡ p ∙ refl
unitʳ = rUnit

inv₂ : {a b : A} (p : a ≡ b) → p ∙ sym p ≡ refl
inv₂ = rCancel

-- level 3: the two ways of re-bracketing four paths agree
pentagon : {a b c d e : A} (p : a ≡ b) (q : b ≡ c) (r : c ≡ d) (s : d ≡ e)
         → assoc p q (r ∙ s) ∙ assoc (p ∙ q) r s
         ≡ cong (p ∙_) (assoc q r s) ∙∙ assoc p (q ∙ r) s ∙∙ cong (_∙ s) (assoc p q r)
pentagon = pentagonIdentity

------------------------------------------------------------------------
-- 2. Levels
------------------------------------------------------------------------

level₋₂→₋₁ : isContr A → isProp A
level₋₂→₋₁ = isContr→isProp

level₋₁→₀ : isProp A → isSet A
level₋₁→₀ = isProp→isSet

level₀→₁ : isSet A → isGroupoid A
level₀→₁ = isSet→isGroupoid

two-is-a-set : isSet Bool
two-is-a-set = isSetBool

loops-of-circle-are-a-set : isSet (base ≡ base)
loops-of-circle-are-a-set = isSetΩS¹

------------------------------------------------------------------------
-- 3. From level 2 on, loops commute
------------------------------------------------------------------------

commute₂ : {a : A} (α β : Path (a ≡ a) refl refl) → α ∙ β ≡ β ∙ α
commute₂ {A = A} {a = a} = EH {A = (A , a)} 0

------------------------------------------------------------------------
-- 4. Suspension and loops
------------------------------------------------------------------------

-- the suspension of two points is the circle
ΣS⁰ : S¹ ≃ Susp Bool
ΣS⁰ = S¹≃SuspBool

-- an arrow out of a suspension is two points and a path for each point of A
susp-out : (Susp A → B) → Σ[ n ∈ B ] Σ[ s ∈ B ] (A → n ≡ s)
susp-out f = f north , f south , λ a i → f (merid a i)

susp-in : Σ[ n ∈ B ] Σ[ s ∈ B ] (A → n ≡ s) → Susp A → B
susp-in (n , s , m) north = n
susp-in (n , s , m) south = s
susp-in (n , s , m) (merid a i) = m a i

susp-out-in : (d : Σ[ n ∈ B ] Σ[ s ∈ B ] (A → n ≡ s)) → susp-out (susp-in d) ≡ d
susp-out-in d = refl

susp-in-out : (f : Susp A → B) → susp-in (susp-out f) ≡ f
susp-in-out f = funExt λ { north → refl ; south → refl ; (merid a i) → refl }

-- suspension is left adjoint to loops: a point of A gives a loop
toΩ : (a₀ : A) (f : Susp A → B) → A → f north ≡ f north
toΩ a₀ f a = (λ i → f (merid a i)) ∙ (λ i → f (merid a₀ (~ i)))

toΩ-base : (a₀ : A) (f : Susp A → B) → toΩ a₀ f a₀ ≡ refl
toΩ-base a₀ f = rCancel (λ i → f (merid a₀ i))

------------------------------------------------------------------------
-- 5. The first homotopy group of the circle
------------------------------------------------------------------------

π₁S¹ : (base ≡ base) ≡ ℤ
π₁S¹ = ΩS¹≡ℤ

Listing 8: Simplex.lean: simplices and horns.

Simplex.lean

/-
  Simplex.lean
  The shapes of higher categories: simplices from finite orders, and the
  horns of the nerves of F₂ and of B.  Core Lean 4, no axioms.
-/

namespace Simplex

/-! ## 1. Faces: leaving out the entry at place `i` -/

def face {α : Type} : Nat → List α → List α
  | _, [] => []
  | 0, _ :: xs => xs
  | i + 1, x :: xs => x :: face i xs

/-- The simplicial identity `dᵢ dⱼ = dⱼ₋₁ dᵢ` for `i < j`, on the 3-simplex. -/
theorem simplicial_identity :
    ∀ i, i < 4 → ∀ j, j < 4 → i < j →
      face i (face j [0, 1, 2, 3]) = face (j - 1) (face i [0, 1, 2, 3]) := by
  decide

/-! ## 2. Counting order-preserving maps `[m] → [n]` -/

/-- All lists of length `len` with entries below `k`. -/
def lists (k : Nat) : Nat → List (List Nat)
  | 0 => [[]]
  | len + 1 => (List.range k).flatMap (fun x => (lists k len).map (fun l => x :: l))

def incr : List Nat → Bool
  | [] => true
  | [_] => true
  | x :: y :: l => decide (x ≤ y) && incr (y :: l)

/-- The order-preserving maps `[m] → [n]`: weakly increasing lists of length
    `m + 1` with entries below `n + 1`. -/
def mono (len _lo k : Nat) : List (List Nat) := (lists k len).filter incr

/-- `[1] → [2]`: six, three of them injective (the edges of the triangle). -/
theorem maps_1_2 : (mono 2 0 3).length = 6 := by decide
/-- `[2] → [2]`: ten, one injective. -/
theorem maps_2_2 : (mono 3 0 3).length = 10 := by decide
/-- `[2] → [3]`: twenty; `[3] → [3]`: thirty-five. -/
theorem maps_2_3 : (mono 3 0 4).length = 20 := by decide
theorem maps_3_3 : (mono 4 0 4).length = 35 := by decide

/-! ## 3. The nerve of a monoid with two elements: horns of dimension 2

A 2-simplex is a triple `(a, b, c)` with `c = a · b`.
Inner horn: `a, b` given.  Outer horns: `a, c` given, or `b, c` given. -/

def xor (a b : Bool) : Bool := a != b
def or' (a b : Bool) : Bool := a || b

/-- `F₂`: the inner horn has exactly one filler. -/
theorem F2_inner : ∀ a b : Bool, ∃ c, c = xor a b := by decide
/-- `F₂`: both outer horns have a filler, and only one. -/
theorem F2_outer_left : ∀ a c : Bool, ∃ b, xor a b = c := by decide
theorem F2_outer_right : ∀ b c : Bool, ∃ a, xor a b = c := by decide
theorem F2_outer_unique : ∀ a b b' : Bool, xor a b = xor a b' → b = b' := by decide

/-- `B`: the inner horn has a filler ... -/
theorem B_inner : ∀ a b : Bool, ∃ c, c = or' a b := by decide
/-- ... but an outer horn has none: `1 ∨ b = 0` has no solution. -/
theorem B_outer_fails : ¬ ∃ b : Bool, or' true b = false := by decide

/-! ## 4. Dimension 3: the inner horn is associativity -/

theorem F2_assoc : ∀ a b c : Bool, xor (xor a b) c = xor a (xor b c) := by decide
theorem B_assoc : ∀ a b c : Bool, or' (or' a b) c = or' a (or' b c) := by decide

/-! ## 5. The nerve of `F₂` has `2ⁿ` simplices in dimension `n` -/

def words : Nat → List (List Bool)
  | 0 => [[]]
  | n + 1 => (words n).map (fun l => false :: l) ++ (words n).map (fun l => true :: l)

theorem nerve_count :
    (words 0).length = 1 ∧ (words 1).length = 2 ∧ (words 2).length = 4
      ∧ (words 3).length = 8 ∧ (words 4).length = 16 := by decide

end Simplex

#print axioms Simplex.simplicial_identity
#print axioms Simplex.maps_1_2
#print axioms Simplex.maps_3_3
#print axioms Simplex.F2_outer_left
#print axioms Simplex.F2_outer_right
#print axioms Simplex.F2_outer_unique
#print axioms Simplex.B_inner
#print axioms Simplex.B_outer_fails
#print axioms Simplex.F2_assoc
#print axioms Simplex.B_assoc
#print axioms Simplex.nerve_count