13 One Source: Place and Read, from the Floor to Every Type Theory

A single source generates everything here. Placing a mark and reading it back form an adjunction whose two triangle identities are the two directions of \(a=a\), and the same two identities are Yoneda at \(\mathrm {id}\). From this source the following are derived as corollaries, each using only the ones before it:

The intensional, extensional, cubical, directed and univalent type theories differ only in the level at which the second triangle identity is available (C28). Each of them returns the floor in turn (C29).

S (the source). Placing a mark in a place and reading it back are adjoint, with the two triangle identities

\begin{equation} \text {(i)}\ \ \mathrm {read}\circ \mathrm {place}=\mathrm {id}, \qquad \text {(ii)}\ \ \mathrm {place}\circ \mathrm {read}=\mathrm {id}. \tag{207}\end{equation}
These are the two directions of \(a=a\). They are also Yoneda at \(\mathrm {id}\). In \(\mathrm {Nat}(\mathrm {Hom}(A,-),F)\cong F(A)\), let reading be evaluation at \(\mathrm {id}_A\) and placing be extension by naturality. Then
\begin{align} \text {(i)}:&\quad \mathrm {read}(\mathrm {place}\,x)=F(\mathrm {id}_A)(x)=x, \tag{208}\\ \text {(ii)}:&\quad \mathrm {place}(\mathrm {read}\,\eta )_B(f)=F(f)\bigl (\eta _A(\mathrm {id}_A)\bigr )=\eta _B(f\circ \mathrm {id}_A)=\eta _B(f). \tag{209}\end{align}

So S, the two directions of \(a=a\), and Yoneda at \(\mathrm {id}\) are one source.

The floor

C1 (identity). Placing a mark in one place and reading it is \(\mathrm {id}_A\), by (i) at one place.

C2 (diagonal). Placing one mark in two places gives \(\Delta (a)=(a,a)\). Reading either place returns the mark, so \(\pi _1\Delta =\mathrm {id}=\pi _2\Delta \) by (i). The two places are named \(\mathbf 2=\{\text {first},\text {second}\}\).

C3 (swap). Reading the two places in the opposite order and placing gives \(\sigma (x,y)=(y,x)\). Then

\begin{equation} \sigma \Delta (a)=\sigma (a,a)=(a,a), \qquad \sigma ^2(x,y)=\sigma (y,x)=(x,y), \tag{210}\end{equation}
the second by (i) and (ii) applied twice.

C4 (extensionality of pairs).

\begin{equation} (x,y)=(x',y')\iff x=x'\ \text {and}\ y=y' . \tag{211}\end{equation}
(\(\Rightarrow \)) Read both sides: \(x=\pi _1(x,y)=\pi _1(x',y')=x'\) by (i), and likewise \(y=y'\). (\(\Leftarrow \)) Place: \((x,y)=\mathrm {place}(x,y)=\mathrm {place}(x',y')=(x',y')\) by (ii).

C5 (extensionality of families). A map \(f:A\to B\) is a filling of \(A\) places. C4 at \(A\) places gives

\begin{equation} f=g\iff f(a)=g(a)\ \text {for every }a, \tag{212}\end{equation}
with (\(\Leftarrow \)) being (ii) in the form \(f=\mathrm {place}(\mathrm {read}\,f)\). Extensionality is the second triangle identity.

C6 (parts and their meet). A part is a map \(p:A\to \mathbf 2\) (C5). Place two parts on one mark by C2 and read “both first”:

\begin{equation} (pq)(a)=\text {first}\iff p(a)=\text {first}\ \text {and}\ q(a)=\text {first}. \tag{213}\end{equation}

Each identity is checked place by place, by C5.

C7 (order). Put \(p\le q\iff pq=p\).

C8 (complement, meet, join). Let \(\neg p=\sigma \circ p\), which exchanges first and second.

C9 (sums; tags are injective). A mark of \(A\sqcup B\) is a pair \((t,c)\) of a place name and a content. By C4,

\begin{equation} (t,c)=(t',c')\iff t=t'\ \text {and}\ c=c' . \tag{214}\end{equation}
Since first \(\neq \) second, marks with different tags differ, and marks with the same tag are equal exactly when their contents are.

C10 (an inverse forces injectivity). If \(gf=\mathrm {id}\) and \(f(x)=f(y)\), then substituting into \(g\) gives \(x=gf(x)=gf(y)=y\).

C11 (currying). The places of \(A\times B\) are pairs of places. Put \(\hat F(a)(b)=F(a,b)\) and \(\check G(a,b)=G(a)(b)\). Then

\begin{equation} \check {\hat F}(a,b)=F(a,b), \qquad \hat {\check G}(a)(b)=G(a)(b), \tag{215}\end{equation}
so both round trips are \(\mathrm {id}\) by C5. Currying regroups places.

C12 (distributivity). Put \(\varphi (a,(t,c))=(t,(a,c))\) and \(\psi (t,(a,c))=(a,(t,c))\). Both composites \(\psi \varphi \) and \(\varphi \psi \) are \(\mathrm {id}\) by C4, so

\begin{equation} A\times (B\sqcup C)\cong (A\times B)\sqcup (A\times C). \tag{216}\end{equation}
\(A\times \varnothing \) has no marks, since the second place cannot be filled. \(A\times 1\cong A\), since \(1\) has the single mark \(\ast \) and \((a,\ast )\leftrightarrow a\) is a round trip by C4.

C13 (some \(\dashv \) weakening \(\dashv \) all). For \(\pi :A\times B\to A\), put

\begin{equation} \pi ^*p=p\times B, \qquad (\exists _\pi q)(a)\iff (a,b)\in q\ \text {for some }b, \qquad (\forall _\pi q)(a)\iff (a,b)\in q\ \text {for every }b . \tag{217}\end{equation}
Checking C7 place by place,
\begin{equation} \exists _\pi q\le p\iff q\le \pi ^*p, \qquad \pi ^*p\le q\iff p\le \forall _\pi q . \tag{218}\end{equation}

C13\('\) (dependent types: some and all along a family). Let \(B\) be a family over \(A\), so that each \(a\) has its own kind \(B(a)\), and let

\begin{equation} \pi :\ \textstyle \sum _{a:A}B(a)\to A,\qquad \pi (a,b)=a, \tag{219}\end{equation}
be the projection of its total kind, whose marks are pairs read by C4. Weakening along \(\pi \) and its two adjoints are
\begin{equation} \begin {aligned} \pi ^*p &= \{(a,b):\ a\in p\},\\ (\textstyle \sum _\pi q)(a) &\iff (a,b)\in q\ \text {for some }b:B(a),\\ (\textstyle \prod _\pi q)(a) &\iff (a,b)\in q\ \text {for every }b:B(a). \end {aligned} \tag{220}\end{equation}
The proof of C13 goes through place by place with \(B(a)\) in place of \(B\):
\begin{equation} \textstyle \sum _\pi q\le p\iff q\le \pi ^*p, \qquad \pi ^*p\le q\iff p\le \prod _\pi q . \tag{221}\end{equation}
Keeping witnesses instead of truth values (S1), these become the dependent sum and product types \(\sum _{a:A}B(a)\) and \(\prod _{a:A}B(a)\). C13 is the case of a constant family, \(B(a)=B\). A family is itself a map \(A\to \mathcal U\) into a kind of kinds (C16), so universes enter as the codomain of families. Dependent elimination, with motives that depend on the term, comes from Frobenius at \(\Delta \) (C24). With C13\('\), every former of dependent type theory is a corollary: \(\Sigma \), \(\Pi \), \(\mathrm {Id}\), inductive and coinductive types, and universes.

C14 (fixed points, algebras, coalgebras). With \(\Delta \) the part of \(X\times X\) whose two readings agree (C2, C4),

\begin{equation} x\in \mathrm {Fix}(f)\iff (f(x),x)\in \Delta \iff f(x)=x, \qquad \mathrm {Fix}(f)=\langle f,\mathrm {id}\rangle ^*\Delta . \tag{222}\end{equation}
For an act \(\Phi \) built from \(\sqcup \), \(\times \), \(1\), \(\varnothing \), the statement \(X=\Phi X\) has two halves.

Half As a map On parts
algebra \(\Phi X\to X\) \(\Phi P\le P\) (closed)
coalgebra \(X\to \Phi X\) \(P\le \Phi P\) (self-sustaining)
both \(X\cong \Phi X\) \(\Phi P=P\), by antisymmetry (C7)

C15 (least and greatest; leastness is the counit). Index the closed parts by \(C\) with membership \(M\subseteq C\times A\), and put \(\mu \Phi =\forall _CM\) and \(\nu \Phi =\exists \) over self-sustaining parts.

C16 (finite kinds, induction, Peano). With \(\Phi (\mathcal X)=\{\varnothing \}\cup \{K\sqcup 1:\ K\in \mathcal X\}\), the finite kinds are \(\mu \Phi \), and induction is the counit of C15. Let \(\mathbb N\) be their sizes, with \(0=|\varnothing |\) and \(S|K|=|K\sqcup 1|\).

C17 (\([0,S]\) is an isomorphism). The map \([0,S]:1\sqcup \mathbb N\to \mathbb N\) is onto, since \(\mu \Phi \le \Phi \mu \Phi \) says every finite kind is \(\varnothing \) or \(K\sqcup 1\). It is one-to-one by C16. Its inverse, the coalgebra that reads “zero, or successor of which number”, gives unique decomposition.

C18 (the closed graph is a subalgebra). Place the two algebra structures side by side on \(\mathbb N\times A\) (C2):

\begin{equation} \ast \mapsto (0,a), \qquad (n,x)\mapsto (Sn,s(x)). \tag{223}\end{equation}
A closed relation is a closed part of this product algebra (C14), and the graph \(G\) is the least one (C15).

C19 (initiality).

C20 (addition, multiplication, laws). Sizes are isomorphism classes, so an isomorphism of kinds is \(a=a\) on sizes.

\begin{align} m+0&=|K\sqcup \varnothing |=|K|=m, & m+Sn&=|(K\sqcup L)\sqcup 1|=S(m+n), \tag{224}\\ m\cdot 0&=|K\times \varnothing |=0, & m\cdot Sn&=|(K\times L)\sqcup (K\times 1)|=mn+m . \tag{225}\end{align}

Each pair of equations has exactly one solution, by C19. Commutativity is C3, associativity is regrouping (C4), and distributivity is C12.

C21 (infinity). A mark of \(\nu (1\sqcup X)\) is determined by the tags read off at each unfolding, which is C5 applied to the places “step \(1\), step \(2\), …”. So

\begin{equation} \nu (1\sqcup X)=\mathbb N\cup \{\infty \}, \qquad S\infty =\infty ,\quad \infty \in \mathrm {Fix}(S)\ (\text {C14}). \tag{226}\end{equation}
If \(Sx=x\), every tag of \(x\) reads “successor”, as for \(\infty \), so \(x=\infty \) by C5. On the least side, \(Sn\neq n\) (C16).
Type theory

C22 (judgements). \(a:A\) is the mark \(a\) placed in a place of kind \(A\). A context is a row of places. Judgemental equality \(a\equiv b\) is S at the level of judgements. Substitution is (i), and weakening is \(\pi ^*\) (C13).

C23 (\(\beta \) and \(\eta \) are the triangle identities). Each type former is an adjunction already derived.

Former Adjunction Source
\(\times \) \(\Delta \dashv \times \) C2, C4
\(\to \) \(-\times A\dashv A\to -\) C11
\(\Sigma \), \(\Pi \) \(\exists \dashv \pi ^*\dashv \forall \) C13
\(+\) \(\sqcup \dashv \Delta \) C9
\(\mathbb N\) initial algebra C15–C19
coinductive types terminal coalgebra C21

An adjunction has two triangle identities, and these are \(\beta \) and \(\eta \). For \(\to \), the unit is \(\eta _X:X\to (A\to X\times A)\), \(x\mapsto \lambda a.(x,a)\), and the counit is \(\mathrm {ev}:(A\to B)\times A\to B\).

\begin{align} \text {first triangle}:&\quad (x,a)\mapsto \bigl (\lambda a'.(x,a'),\,a\bigr )\mapsto (x,a), &&\text {that is }(\lambda a'.t)\,a\equiv t[a/a']\ \ (\beta ), \tag{227}\\ \text {second triangle}:&\quad f\mapsto \lambda a.(f,a)\mapsto \lambda a.\,\mathrm {ev}(f,a)=\lambda a.\,f\,a\equiv f, &&\text {that is }\eta . \tag{228}\end{align}

For \(\times \), \(\beta \) is \(\pi _1(a,b)\equiv a\) and \(\eta \) is \((\pi _1p,\pi _2p)\equiv p\). In every case \(\beta \) is (i) and \(\eta \) is (ii).

C24 (identity types). \(\mathrm {Id}_A=\Sigma _\Delta 1\), some along the diagonal (C13 at \(\Delta \)).

The second triangle says that a map out of \(\mathrm {Id}_A\) equals the \(J\)-extension of its value at \(\mathrm {refl}\). In Martin-Löf type theory this holds only up to identification, as a consequence of \(J\), and not judgementally. This is where the type theories part.

C25 (the interval is the shape of \(a=a\)). The interval \(I\) has the two places \(0,1\) of C2 joined by one link. The operations \(\wedge ,\vee ,\neg \) of C6–C8 extend to it, giving a De Morgan algebra with connections \(i\wedge j\) and reversal \(1-i\). Put

\begin{equation} \mathrm {Path}_A(a,b)=\{p:I\to A\ \mid \ p\,0\equiv a,\ p\,1\equiv b\}, \qquad \mathrm {refl}_a=\lambda i.\,a . \tag{229}\end{equation}
The based path space is contractible, with centre \((a,\mathrm {refl}_a)\) and contraction
\begin{equation} j\mapsto \bigl (p\,j,\ \lambda i.\,p(i\wedge j)\bigr ), \tag{230}\end{equation}
which is \((a,\lambda i.a)\) at \(j=0\) and \((b,p)\) at \(j=1\). With transport along \(I\), paths satisfy \(J\). C25 rebuilds the identity of C24 from the shape of \(a=a\).

C26 (function extensionality is currying). Given \(h:\prod _x\mathrm {Path}(f\,x,g\,x)\), regroup the places \(I\) and \(A\) (C11):

\begin{equation} \lambda i.\lambda x.\,h\,x\,i:\mathrm {Path}(f,g), \qquad (\lambda i.\lambda x.\,h\,x\,i)\,0\equiv \lambda x.\,h\,x\,0\equiv \lambda x.\,f\,x\equiv f , \tag{231}\end{equation}
and likewise at \(1\) the endpoint is \(g\). Only \(\beta \), \(\eta \) (C23) and currying (C11) are used. Extensionality is (ii) at the level of paths.

C27 (univalence is (ii) on the universe). Read a type through its equivalences, and place a path from an equivalence. The second triangle on the universe is

\begin{equation} (A=B)\simeq (A\simeq B), \tag{232}\end{equation}
which is univalence. In cubical type theory it is a theorem, through Glue types. In the HoTT Book it is an axiom. Univalence implies function extensionality (Voevodsky), which is C26 on the universe.

C28 (five type theories, one choice).

Theory (i) Where (ii) holds Consequence
intensional MLTT judgements, \(J\) judgements only (\(\eta \)) funext not derivable
extensional MLTT judgements identity, by reflection funext; UIP, level \(0\)
cubical (CCHM) judgements paths, maps out of \(I\) funext (C26), univalence (C27)
directed (Riehl–Shulman) judgements maps out of \(\mathbb 2\) hom types, Segal and Rezk types
HoTT Book judgements, \(J\) universe, by axiom univalence, hence funext

The five are one source with (ii) placed at different levels: in judgements only, forced into identity by reflection, unfolded along an interval, or imposed on the universe.

C29 (the converse: every type theory returns the floor).

Floor In any of the type theories
S \(\beta \), \(\eta \) (C23) and the computation rule of \(J\) (C24)
Yoneda based path induction \(J\)
\(\Delta \), \(\sigma \) \(\lambda x.(x,x)\), \(\lambda (x,y).(y,x)\); \(\sigma \sigma \equiv \mathrm {id}\) by \(\beta \) and \(\eta \)
C4, C5 \(\eta \) for pairs; for functions, C26, reflection or univalence
C6–C8 propositions (\((-1)\)-types), truncation \(\|A\|\)
C13 \(\Sigma \), weakening, \(\Pi \)
C15–C19 the eliminator of \(\mathbb N\): induction and recursion
C21 conatural numbers
categories, \((\infty ,n)\) Segal and Rezk types

C30 (one statement).

\begin{equation} \begin {gathered} a=a\ \equiv \ \text {S}\ \equiv \ \text {Yoneda at }\mathrm {id}\\ \Downarrow \\ \text {C1--C21: the floor}\qquad \text {C22--C27: type theory}\\ \Downarrow \\ \text {C28: every type theory is a choice of level for (ii)}\\ \Downarrow \\ \text {C29: each returns the floor} \end {gathered} \tag{233}\end{equation}

13.1 Formal Proof Assistants as Corollaries

A proof assistant mechanises the judgements of C22. Its kernel checks each step by the two triangle identities of S, as conversion. Libraries such as Lean’s mathlib are built from type formers that are already corollaries (C13, C15–C19, C23, C24). What separates one system from another is where the second identity (ii) is made available (C28): in judgements only, by reflection, by an interval, on the universe, by a quotient, or by axioms of set theory. Lean obtains function extensionality from a quotient, obtains univalence for propositions as propext, cuts the identity tower at level \(0\) by proof irrelevance, and becomes Boolean through choice.

C31 (a kernel is C22 run by a machine). A proof is a term, that is, a placement \(t:A\) (C22). Checking it means deciding judgemental equality \(\equiv \), which the kernel does with

Conversion What it checks Source
\(\beta \) reading a placement (i), C23
\(\eta \) placing what is read (ii), C23
\(\delta \) unfolding a definition \(a=a\) on names (C1)
\(\iota \) a recursor applied to a constructor initiality (C19)

Propositions are types and proofs are their marks, which is LG10 read through C23.

C32 (Lean’s core, piece by piece).

Primitive of Lean 4

What it is

Source

\(\Pi \)-types, \(\lambda \), application

right adjoint of weakening

C13, C23

inductive types, recursors

initial algebras, initiality

C15–C19

structures with \(\eta \)

products with (ii) judgemental

C4, C23

Eq and Eq.rec

identity type and \(J\)

C24

Prop, proof irrelevance

\((-1)\)-types, judgementally truncated

S2, IC9

Quot, Quot.sound

related marks become equal

(ii) for a relation

propext

\((p\leftrightarrow q)\to p=q\)

(ii) on the universe at level \(-1\) (C27)

Classical.choice

a mark from inhabitation

LG3

The three axioms of Lean 4 are propext, Quot.sound and Classical.choice. Each is a placement of (ii) or of choice at a definite level.

C33 (function extensionality from a quotient). In Lean 4, funext is a theorem, not an axiom. Given \(h:\forall x,\ f\,x=g\,x\):

This is C5 obtained a fifth way. (ii) is supplied by declaring related marks equal, and evaluation, which is (i), carries it back to functions.

C34 (proof irrelevance cuts the tower at level \(0\)). Eq lives in Prop, and any two proofs of a proposition are judgementally equal. So any \(p,q:a=b\) satisfy \(p\equiv q\), which is uniqueness of identity proofs. Every type is a set in the sense of IC9. Univalence cannot be added, since it would identify the two distinct automorphisms of \(\mathbf 2\) with distinct paths in the universe, while UIP makes all such paths equal. Definitional proof irrelevance together with an impredicative Prop is also known to break normalisation in corner cases (Abel–Coquand).

C35 (propext is univalence for propositions). For \((-1)\)-types, an equivalence is a pair of implications. C27 at level \(-1\) reads

\begin{equation} (p=q)\simeq (p\leftrightarrow q), \tag{234}\end{equation}
and propext is its non-trivial direction. Lean has univalence exactly at the level where UIP does not contradict it.

C36 (excluded middle from choice). In Lean 4 core, Classical.em is proved from choice, propext and funext, which is Diaconescu’s argument. So \(\Omega \) is Boolean (LG3), and Lean’s logic is the first row of LG11.

C37 (mathlib’s mathematics, read as corollaries).

mathlib Construction Source
Set \(\alpha \) \(:=\alpha \to \) Prop parts as maps to truth values C6
order classes, lattices \(\le \), \(\sqcap \), \(\sqcup \), complements C6–C8
\(\mathbb N\) inductive, Nat.rec C15–C19
\(\mathbb Z\) two tagged copies, ofNat, negSucc C9
\(\mathbb Q\) reduced numerator and denominator normal form of pairs
\(\mathbb R\) completion of Cauchy sequences, a quotient C33, V3
\(\mathbb C\) \(\mathbb R\times \mathbb R\) with \(J^2=-1\) D9, D10
category theory yoneda, Adjunction D0, FL4

Each definition in the library is a choice of presentation for an object already fixed by a universal property (V1), so the library and the chain agree up to unique isomorphism.

C38 (other assistants: one table).

System

Base

Where (ii) lives

Lean 4

CIC, impredicative Prop

quotients, propext; UIP by proof irrelevance

Rocq (Coq)

CIC

judgements; funext and propext as optional axioms

Agda

intensional MLTT

judgements; pattern matching gives axiom K by default

Cubical Agda

cubical type theory

interval: funext and univalence are theorems

Isabelle/HOL, HOL Light

classical higher-order logic

extensionality and choice as axioms

Metamath (set.mm)

first-order ZFC

extensionality axiom of set theory

Mizar

Tarski–Grothendieck set theory

extensionality axiom of set theory

The set-theoretic systems place (ii) as the axiom of extensionality, which is C5 for membership. The higher-order systems place it as an axiom on functions. The cubical system obtains it by currying (C26). Lean obtains it from a quotient (C33).

C39 (the converse). Each system returns the floor: \(\mathrm {refl}\) and its eliminator give \(a=a\) and \(J\); the recursor of \(\mathbb N\) gives induction and recursion; \(\eta \) gives C4; its form of (ii) gives C5. From these, C1–C21 follow as before (C29).

C40 (one statement). A formal library is S run by a machine, with a chosen level for (ii).

\begin{equation} \begin {gathered} a=a\ \equiv \ \text {S}\ \equiv \ \text {Yoneda at }\mathrm {id}\\ \Downarrow \\ \text {kernel}=\text {(i) and (ii) as conversion (C31)}\\ \Downarrow \\ \text {Lean: }J,\ \text {quotient},\ \texttt {propext},\ \text {proof irrelevance},\ \text {choice (C32--C36)}\\ \Downarrow \\ \text {mathlib: numbers, order, sets, categories as corollaries (C37)}\\ \Downarrow \\ \text {every assistant: a level for (ii) (C38)}\ \to \ \text {each returns the floor (C39)} \end {gathered} \tag{235}\end{equation}

Remark 13.1 (CIC and HOL in the classification). Both are already points of C28.

CIC is intensional, inductive and impredicative at level \(-1\). HOL is the \(\to \)-fragment with (ii) as an axiom and \(\Omega =\mathbf 2\). Both are S with (ii) placed at a different level.