Study notes: Dependent Types from Rocq to Lean 4

Recall questions for Dependent Types from Rocq to Lean 4. Answer each from memory, then open the answer to compare. The link under a question leads to the section it draws on.

Questions

The answers state what the essay says. Lean code in the answers is the essay’s own or a small variation that compiles. The last three questions ask where the essay’s results stop.

The type of a dependent composite

Let C : B → Type w be a family over B, with f : A → B and g : (b : B) → C b. Write the type and the body of their composite. Which of the three rules for dependent functions produces the result type, and what makes that rule the dependent one?

Answer

The composite has type (a : A) → C (f a) and body fun a => g (f a). The body is ordinary composition. The type records the dependency that ordinary function notation suppresses: g selects an element in each fiber, and composing with f gives a section of the family pulled back to A. The result type comes from the application rule. From f:\prod_{x:A}B(x) and a:A it concludes f\,a:B(a). The substitution of the argument into the result type is the dependent part, so applying g to f a produces a term of C (f a). The other two rules form the function type and construct a function by abstraction.

A proof is a small program

Given hPQ : P → Q and hQR : Q → R, write a proof term for P → R. Then follow the tactic proof intro hP, apply hQR, exact hPQ hP, and give the goal after each of the first two steps. Why does the same reading cover ∀? How is negation defined?

Answer

The term is fun hP => hQR (hPQ hP). A proof of P\to Q transforms any proof of P into a proof of Q, so it is a function. After intro hP the context contains a proof of P and the goal is R. Applying hQR reduces that goal to Q, and the final line supplies its proof. The kernel checks the resulting proof term. A proof of \forall x:A,\,P(x) supplies a proof of P(x) for every x, so it is a dependent function. Lean’s ∀ (x : A), B x and (x : A) → B x are the same dependent function type. Negation is \neg P := P\to\bot: assume P and derive a contradiction. Double-negation elimination, \neg\neg P\to P, is a classical principle that these rules do not provide.

Why inductive types are primitive

Which three forms of dependency does the Calculus of Constructions combine, and how are its two sorts related? Pure CoC can encode natural numbers. Why do Rocq and Lean have primitive inductive definitions anyway? What does the proof of strong normalization for CoC say about the extended systems?

Answer

Begin with simply typed functions. Add terms parameterized by types, type constructors parameterized by types, and types parameterized by terms. CoC combines all three. In the two-sort presentation there is a lower sort * and an upper sort \square with *:\square, and there is no axiom \square:\square. Polymorphism permits Church encodings, and an encoded natural number can describe iteration. Pure CoC still does not begin with a primitive natural-number type and the induction principle of ordinary mathematics. Obtaining the desired dependent induction and computational behavior motivates a richer system with primitive inductive definitions. Rocq’s Calculus of Inductive Constructions includes a hierarchy of universes and rules for inductive families, recursive definitions and coinductive constructions. Lean belongs to the same family, with its own universe discipline, definitional proof irrelevance, primitive quotients and rules governing inductives. The 1988 proof covers CoC. Extensions to the calculus require their own metatheoretic arguments.

Which universe?

State the rule that gives the sort of \prod_{x:A}B(x) when A:\mathrm{Sort}\ u and B(x):\mathrm{Sort}\ v. Use it to place Nat → Nat, ∀ P : Prop, P → P and (A : Type) → A → A.

Answer

The product lives in \mathrm{Sort}(\operatorname{imax}(u,v)), where \operatorname{imax}(u,v) is 0 when v=0 and \max(u,v) when v>0. Prop abbreviates Sort 0 and Type u abbreviates Sort (u + 1), so Nat : Type puts Nat in Sort 1, and Type : Type 1 puts Type in Sort 2.

  • Nat → Nat: here u=v=1, so the sort is Sort 1, which is Type.
  • ∀ P : Prop, P → P: the domain Prop lives in Sort 1, so u=1. The codomain P → P is a proposition, so v=0 and the whole type is in Sort 0, which is Prop. Its quantifier ranges over all propositions, including this one.
  • (A : Type) → A → A: the domain Type lives in Sort 2 and the codomain A → A in Sort 1. The sort is Sort 2, which is Type 1. A type of functions ranging over all small types lives higher than those small types.

Impredicative is not Type : Type

What is the impredicativity of Prop, and how does it differ from imposing Type : Type? What is cumulativity, and which of the two systems has it? What does Set mean in each system?

Answer

A proposition may quantify over objects in arbitrarily high fixed universes and remain a proposition. That is the impredicativity of Prop. Data universes are predicative. Type : Type is a different design choice, and impredicativity does not by itself imply it. In the usual expressive dependent calculi, imposing a universal Type : Type permits paradoxes. The hierarchy \mathrm{Sort}\ u:\mathrm{Sort}\ (u+1) lets us quantify over a collection of types without placing that collection inside itself. Cumulativity is Rocq’s embedding of smaller universes into larger ones through its typing discipline. Lean does not automatically regard a type in Type u as an inhabitant of Type (u + 1). Universe polymorphism often removes the need for lifting, and explicit constructions such as ULift are available. Rocq’s Set is a sort for small computational data, which Lean places in Type. Lean’s Set α is the type of predicates on α.

One recursor, three readings

Write the type of the dependent eliminator of the natural numbers. What is its first argument called? Give the three readings of the principle according to what that argument is. How do Lean and Rocq differ in the place they give to recursors?

Answer

\begin{aligned} \operatorname{rec}_{\mathbb N}&: \prod_{C:\mathbb N\to\mathrm{Sort}\ u} C(0)\to{}\\ &\quad\left(\prod_{n:\mathbb N}C(n)\to C(n+1)\right)\to{}\\ &\quad\prod_{n:\mathbb N}C(n). \end{aligned}

The family C is the motive. If C(n) is a proposition, the principle is induction. If it is a data type, it is a recursive construction. If it varies with n, the recursion constructs different types of results at different stages. Lean’s kernel checks inductive declarations and their recursors, and surface recursive definitions are compiled into applications of those principles, including well-founded recursion when needed. Rocq’s core language has primitive fixpoint terms, checked by a guardedness discipline, and its recursors are defined from them.

A head with no empty case

In Vec α n, which argument is a parameter and which is an index, and what is the difference? Why does Vec.head : Vec α (n + 1) → α need only the cons case? Why must List.head? return an Option α?

Answer

The element type α is a parameter: it stays fixed through the declaration. The length is an index: the constructors return different instances of the family, nil : Vec α 0 and cons : α → Vec α n → Vec α (n + 1). The empty constructor cannot inhabit the input type Vec α (n + 1), so there is no empty case to handle. List.head? must return an Option α because its input may be empty. Vec.head requires a nonempty vector, so its result needs no optional wrapper. The mathematical precondition is expressed in the domain of the function.

Strictly positive or not

Assume A and B contain no X. For each of X, A → X, X → A and (X → A) → B, give the polarity of X and say whether the occurrence is strictly positive. Where does the check apply? Which of Vec α n and X → False may be the type of a recursive constructor argument?

Answer

Start with positive polarity. Entering an arrow’s domain flips the sign, and entering its codomain preserves it. Intuitively A → X produces an X and X → A consumes one.

  • X: positive, and strictly positive.
  • A → X: positive, and strictly positive.
  • X → A: negative, so not strictly positive.
  • (X → A) → B: positive after two sign flips, and still not strictly positive.

Strict positivity is stronger than a positive final sign. The path to X must never enter a function’s domain. The check applies inside each constructor argument’s type, and not across the outer arrows that make the constructor a function. So Vec α n is an allowed recursive argument to cons, and a recursive argument of type X → False is forbidden.

What Bad would break

Suppose a type Bad with the constructor mk : (Bad → False) → Bad were admitted. Define a function d : Bad → False without recursion, build a closed term of type False, and reduce it. Why can a decreasing measure attached to d not rescue the construction?

Answer

Define d (mk f) := f (mk f). The definition does not call itself: it applies the function stored in its argument. The constructor lets us store d itself, as mk d : Bad, and d (mk d) is then a closed term of type False. Unfolding d and matching the constructor returns the same term, so d (mk d) reduces to d (mk d) forever. The closed term’s type is the contradiction, and the loop exposes the computational failure. The positivity check blocks the declaration of Bad before either becomes available.

An ordinary recursive-call check has no self-call to inspect in d. It calls a stored function, whose unrestricted type Bad → False imposes no descent condition. Any rank strictly decreasing along the complete reduction cycle would require \mu(t)<\mu(t). Strict positivity restricts the datatypes and eliminators we may introduce. Decreasing measures justify recursive uses of the admitted principles.

Which equation holds by rfl

addLeft recurses on its first argument: addLeft 0 m is m, and addLeft (n + 1) m is Nat.succ (addLeft n m). For an arbitrary n, which of addLeft 0 n = n and addLeft n 0 = n does rfl prove, and why? Prove the other.

Answer

rfl proves addLeft 0 n = n. The defining equation makes addLeft 0 n compute to n even though n is unknown. The kernel’s conversion relation recognizes the two sides as definitionally equal, so a proof of n = n also proves the equation. No induction lemma is needed. In addLeft n 0 = n, an unknown n does not reveal whether the first argument is zero or a successor, so computation alone cannot finish. Induction does:

theorem addLeft_zero (n : Nat) : addLeft n 0 = n := by
  induction n with
  | zero => rfl
  | succ n ih =>
      change Nat.succ (addLeft n 0) = Nat.succ n
      exact congrArg Nat.succ ih

The successor case lifts the induction hypothesis through the function Nat.succ.

Two equalities and a transport

Distinguish definitional from propositional equality. What does the elimination principle of propositional equality justify? The essay’s resizeVec takes h : n = m and xs : Vec α n and returns a Vec α m. Given xs : Vec α (0 + n), write a term of type Vec α n, and say what changes in the vector.

Answer

Definitional equality belongs to the machinery of typing and conversion. It lets the checker treat suitable expressions interchangeably. Propositional equality, written a = b, is a type inside the language, and a proof inhabiting it can be passed to other functions. It is an inductive family with reflexivity as its constructor. Its elimination principle says that equal things can be substituted in dependent families. That justifies transporting an object from B(a) to B(b) using a proof of a=b, and resizeVec h xs is transport (Vec α) h xs. The term asked for is resizeVec (Nat.zero_add n) xs, where Nat.zero_add n proves 0 + n = n. Nothing about the vector’s entries changes. The equality proof justifies changing the index that appears in its type. A mathematically equal length may still require explicit transport if the two length expressions are not definitionally interchangeable.

What makes an equality available

Which rules does Lean’s conversion include? How does the kernel’s test relate to the relation those rules specify? For writing proofs, which three questions does the essay ask of an equality, and which Lean move does each answer suggest?

Answer

Conversion includes beta reduction of function applications, delta unfolding of definitions, iota reduction of recursors and zeta substitution of let-bound values. It also includes function and structure eta rules, proof irrelevance and quotient computation. The kernel implements an algorithmic conversion test, which is distinct from the declarative relation specified by the rules. Conversion is often explained as reducing both expressions to the same normal form, but reducing every term to a normal form cannot provide a general implementation. The three questions are these. Does the equality follow by unfolding and computation? Is it an induction theorem? Does it use extensionality? The corresponding moves are rfl or change, induction or rewriting, and an explicit extensionality principle.

Injectivity of a composite

IsInjective f is defined as ∀ ⦃x y : A⦄, f x = f y → x = y. To prove IsInjective (fun x => g (f x)) from hf : IsInjective f and hg : IsInjective g, the proof begins with intro x y h. Write the context and goal at that point. Finish the proof with three tactics, then write the whole proof as one fun expression. What does #print axioms report for the theorem? What do the double braces do?

Answer
x y : A
h : g (f x) = g (f y)
⊢ x = y

The remaining tactics work backward. apply hf asks for f x = f y. Then apply hg asks for g (f x) = g (f y), and exact h supplies it. As a single term the proof is fun _ _ h => hf (hg h). #print axioms lists the axioms a theorem depends on, and for this theorem it reports none. The double braces make x and y strict implicit arguments. Lean infers them, but only once a later explicit argument, here the equality, is supplied. So hf on its own still denotes the whole quantified statement.

Standing in for a dependent argument

Lean gives replication the signature (n : Nat) → α → Vec α n, and it can use an ordinary addition function in the result type of a concatenation. What does a GADT supply on its own? What does Haskell use in place of the dependent argument, and what in place of the addition? What does the OCaml encoding use in place of the addition?

Answer

A GADT’s constructors can specify different result indices, and matching a constructor introduces type equations within the branch. That captures an important part of indexed inductive families: Haskell and OCaml both rule out the empty constructor at the input type of a head function. It does not by itself supply arbitrary dependence on ordinary terms.

For replication Haskell uses a singleton, with replicateVec :: SNat n -> a -> Vec n a. The singleton connects a type-level index to its runtime representative. For each finite natural-number index it has exactly one fully defined constructor-shaped value, and matching it reveals the index’s structure. The cost of the technique is maintaining the connection between an ordinary representation and an index.

For concatenation Haskell uses the type family Add, a separate type-level addition whose equations reduce as the vector match reveals n. The OCaml encoding replaces that function with its graph: a relation plus carrying evidence that three indices satisfy addition. PlusZ witnesses 0+m=m, and PlusS lifts evidence for n+m=k to evidence for (n+1)+m=k+1. Both versions enforce the result length. The OCaml interface carries an explicit witness and does not ask the checker to evaluate a type family.

What general dependency adds

Write the type of a motive for vector induction in Lean. What can it depend on that a GADT match does not make available? Why does the essay say that expressive specifications are not yet a logic?

Answer

The motive has the form M:\prod_{n:\mathbb N}\operatorname{Vec}(A,n)\to\mathrm{Prop}. The proposition can depend on the entire vector and its entries, and not only on its length. A GADT match exposes constructor and index equations. It does not automatically make the matched value available as an argument to a type-level predicate. More dependencies can be encoded by representing more data in indices. General dependent products and elimination remove the need to construct that representation separately for each domain.

Haskell accepts a definition fake :: p with body fake = fake, where p can be any ordinary type. OCaml likewise permits computations that diverge or raise exceptions at any desired result type. Neither computation produces, for example, an equality witness. The rules controlling proofs matter independently of how richly a datatype can be indexed.

Two proofs of one bound

Why does xs[0]'h₁ = xs[0]'h₂ hold by rfl for any two proofs h₁ h₂ : 0 < xs.size? What might a proof-relevant system do instead? How do Rocq’s ordinary Prop, an axiom of proof irrelevance, and SProp each compare with Lean’s Prop here?

Answer

Lean identifies all proofs of a fixed proposition definitionally, so h₁ = h₂ holds by rfl for any h₁ h₂ : P. Once the proposition is fixed, the identity of its proof is irrelevant to conversion. The two array accesses differ only in their proof arguments, and proof irrelevance makes those interchangeable by conversion. A proof-relevant system might instead establish independence from the proofs with a separate lemma. Ordinary Rocq Prop does not have this general definitional identification. One can assume propositional proof irrelevance in Rocq, but an axiom proving h₁ = h₂ does not make the checker identify the terms directly. Modern Rocq also has SProp, a separate sort with definitional proof irrelevance and its own restrictions.

A witness you may not project

Both {x : α // P x} and ∃ x, P x involve a witness. Write the map from the first to the second. What does the reverse map need? Derive from proof irrelevance why an existential proof cannot have a computational projection. Name the controlled exceptions to the restriction.

Answer

The subtype is data, and its stored witness can be projected. From w : {x : α // P x} the term ⟨w.val, w.property⟩ proves ∃ x, P x. The existential belongs to Prop, so its inhabitants are proofs. Its ordinary eliminator lets us reason about a witness to establish another proposition, and does not generally expose the witness as computational data. The reverse map is ⟨Classical.choose h, Classical.choose_spec h⟩. It uses classical choice and is marked noncomputable.

Suppose one existential proof used witness 0 and another used witness 1. Proof irrelevance identifies the proofs of that same existential proposition. A computational projection that distinguished them would make the identification incompatible with computation. Classical.choose selects an unspecified witness satisfying the predicate, and it need not return the witness used to construct the proof. For a fixed predicate, changing the existential proof cannot change that selection.

The exceptions are these. Empty propositions and suitable single-constructor propositions have stronger elimination rules, and equality supports transport. The restriction concerns which distinctions a recursor is allowed to observe.

Equal or merely equisatisfiable

Why are any two proved propositions equal? Take F=p\land q\land r, G=r\land p\land q and H=p\lor q\lor r as predicates on assignments. Which of them are equal, and by which principles? Find an assignment where F and H disagree. What does propext equate in their case? How many truth functions of three Boolean inputs are there?

Answer

propext turns an equivalence P ↔︎ Q into an equality P = Q. Given proofs a : A and b : B, the functions fun _ => b and fun _ => a prove the two implications, so A = B. F and G agree at every assignment, so propext and funext together give F = G. F and H disagree at (p,q,r)=(\mathrm{True},\mathrm{False},\mathrm{False}), where H holds and F fails. They are merely equisatisfiable: each has a satisfying assignment. So propext equates the propositions ∃ ρ, F ρ and ∃ ρ, H ρ, and it does not equate the predicates. Classically Prop has two values up to propositional equality, yet three Boolean inputs permit 2^{2^3}=256 distinct truth functions.

A quotient by parity

State the computation rule of Quot.lift. Let SameParity a b be a % 2 = b % 2, and let parityValue be Quot.lift (fun n => n % 2) (fun _ _ h => h). What is parityValue (Quot.mk SameParity 5), and does the equation hold by rfl? How is Quot.mk SameParity 1 = Quot.mk SameParity 3 proved? Which axioms does the proof funext (fun x => propext (h x)) of subsetExt depend on, and why?

Answer

To define a function on the quotient, supply a function f on representatives and a proof h that it respects r. The rule is \operatorname{Quot.lift}\ f\ h\ (\operatorname{Quot.mk}\ r\ a)\equiv f(a). So parityValue (Quot.mk SameParity 5) computes to 5 % 2, which is 1, and the equation holds by rfl. The second equation is proved by Quot.sound (by rfl). The argument is a proof of SameParity 1 3, that is of 1 % 2 = 3 % 2. Quotient soundness supplies the equality without making the representatives definitionally identical. #print axioms subsetExt reports propext and Quot.sound. The second appears because Lean derives function extensionality from quotients.

Function extensionality from a quotient

Let Q be the quotient of A\to B by pointwise equality, and suppose h:\forall x,\;f(x)=g(x). Derive f=g. Say which step is an axiom and which steps are built-in rules. Why not lift the identity function directly?

Answer

Quot.sound h supplies [f]=[g] in Q. Fix an input x. Evaluation f\mapsto f(x) respects the relation, since the required proof is the hypothesis of pointwise equality applied at x. Hence Quot.lift defines \operatorname{eval}_x:Q\to B with \operatorname{eval}_x([f])\equiv f(x). Set \operatorname{rebuild}(q):=\lambda x.\operatorname{eval}_x(q). The crucial calculation is definitional:

\operatorname{rebuild}([f])\equiv\lambda x.\operatorname{eval}_x([f])\equiv\lambda x.f(x)\equiv f.

The final step uses function η-equality, which identifies fun x => f x with f. That rule concerns the expansion of one function. It does not assume that arbitrary pointwise-equal functions are equal. Ordinary congruence applied to [f]=[g] gives \operatorname{rebuild}([f])=\operatorname{rebuild}([g]), whose endpoints are definitionally f and g. In Lean the proof is congrArg rebuild (Quot.sound h).

The reported dependency is only Quot.sound. Quotient reduction and η-equality are built-in rules. Lifting fun f => f directly would require proving f\sim g\Rightarrow f=g, which is the goal. The derivation instead fixes x, lifts evaluation using h x, and then abstracts over x. No representative is selected by choice.

Rocq against Lean 4

For each of five features, say what Rocq does and what Lean 4 does: ordinary Prop, data universes, general quotients, recursive definitions, function extensionality. Which other foundational branch did Lean 2 support, and why is modern Lean not a homotopy type theory? Which two kernel changes does Carneiro single out as affecting the metatheory?

Answer
  • Ordinary Prop is impredicative in both. Rocq’s has no general definitional proof irrelevance, and Lean’s is definitionally proof irrelevant.
  • Data universes form a cumulative hierarchy in Rocq. Lean’s hierarchy is noncumulative, with universe polymorphism and lifts.
  • General quotients in Rocq are usually setoids or further constructions. Lean has primitive quotient support.
  • Recursive definitions in Rocq are core fixpoints subject to guardedness rules. In Lean, surface recursion is translated to recursors.
  • Function extensionality is an additional principle in ordinary CIC. In Lean it is derived using primitive quotients.

Lean 2 supported a separate HoTT mode with proof irrelevance disabled and univalence postulated. Modern Lean’s mainstream foundation follows the proof-irrelevant branch. Its equality proofs live in a proof-irrelevant Prop, and the resulting uniqueness of equality proofs is incompatible with the general higher structure sought in univalent foundations. Lean also does not implement equality reflection, the rule that every proved equality becomes a conversion rule.

Carneiro’s Lean4Lean paper identifies kernel support for nested inductive types and eta for structures. A nested inductive type places recursion underneath another type constructor, as a rose tree contains a List of subtrees. Structure eta identifies a structure with the result of rebuilding it from its fields. Such rules remove bookkeeping from proofs, but their interaction with other conversion rules needs justification.

Four properties, not one

Define strong normalization, canonicity, consistency and decidability of type checking. How can normalization establish consistency? What other route to consistency does the essay name?

Answer

Strong normalization says every reduction sequence from a well-typed term terminates. Canonicity, in a specified fragment and with specified axioms, says closed terms of data types compute to appropriate canonical values, such as numerals. Consistency says there is no closed proof of False under the designated assumptions. Decidability of type checking says an algorithm settles every typing judgment, including every question of definitional equality. The properties interact, but they are not synonyms.

Normalization and an analysis of normal forms can establish consistency. If every closed proof normalizes, and no normal form can inhabit False, then no such proof exists. A semantic model offers another route: interpret types as suitable objects and False as empty, then prove that derivable judgments preserve the interpretation.

A cast that does not wait

For a variable h : A = A, why does cast h x = x hold by rfl, although h cannot be unfolded to reveal a reflexivity constructor? What does #reduce give for fun (h : Nat = Nat) => cast h (37 : Nat)? What is the crucial condition on the cast? Would assuming proof irrelevance as a theorem have the same effect?

Answer

Transport along reflexivity does nothing: cast rfl x reduces to x. Definitional proof irrelevance identifies h with reflexivity at the fixed proposition A = A, and Lean’s equality recursor supports the corresponding computation. The operational rule is \operatorname{cast}_{A,A}(h,x)\longrightarrow x. So #reduce gives fun h => 37. The crucial condition is that the endpoints coincide definitionally. A cast between arbitrary propositionally equal types need not disappear. Merely assuming a theorem of propositional proof irrelevance would not automatically install this computational rule. The rule belongs to conversion and reduction, and a theorem saying that two proofs are equal does not supply it.

Typing the diagonal

Let T:=\prod_{P:\mathrm{Prop}}(P\to P) and D:=T\to T, and let i:D be the identity on proofs of T. For a variable z:T, give the types of z\,D, of z\,D\,i and of z\,D\,i\,z, and define d:D. What work does impredicativity do? Repeat the attempt with T_u:=\prod_{A:\mathrm{Type}\ u}(A\to A) and say where it fails.

Answer

Instantiating z at the proposition D gives z\,D : D\to D. Then z\,D\,i : D, which is T\to T, and so z\,D\,i\,z : T. Define d:D by d(z):=z\,D\,i\,z. This resembles self-application, but every application has a legitimate type: z is instantiated at a proposition which itself mentions the type of z. Quantifying over Prop leaves T inside Prop, so D is an allowed argument to z. With the predicative T_u the construction fails. T_u lives in Type (u + 1), and so does T_u\to T_u. That function type is too large to pass as the Type u argument of a term of T_u. The attempted self-application climbs out of its permitted universe.

Around the loop

From proofs a:A and b:B, propext yields e(a,b):A=B. Use it to define w:T, set L:=d(w), and reduce L until it returns to itself. Name the contribution of each of the three ingredients. Is L at least weakly normalizing?

Answer

Given any proposition P and proof p:P, we have proofs i:D and p:P, hence e(i,p):D=P. Cast d:D along this equality: w(P,p):=\operatorname{cast}_{D,P}(e(i,p),d):P. That is the type required for w:T. Now reduce:

L=d(w)\longrightarrow w\,D\,i\,w\longrightarrow\bigl(\operatorname{cast}_{D,D}(e(i,i),d)\bigr)\,w\longrightarrow d(w).

Unfolding d exposes an application of w. Unfolding that application exposes a cast with matching endpoints. The cast exposes d because its endpoints agree, without evaluating the propext proof to reflexivity. Otherwise the computation would remain stuck at the cast.

Impredicativity permits the instantiation at D. Propositional extensionality supplies the casts between inhabited propositions. Proof-irrelevant cast reduction removes the cast when the loop returns to D. The definitions are ordinary and nonrecursive, and #print axioms reports only propext.

Strong normalization requires every reduction sequence to terminate, and the cycle alone refutes it. Weak normalization requires at least one sequence reaching a normal form. For d\,w itself, Abel and Coquand establish that there is not even a weak head normal form. So the term is not weakly normalizing either, and choosing another reduction order does not rescue it. A looping subterm can sometimes be discarded: (\lambda t:T.\;0)(d\,w) reduces to 0 by contracting the outer application.

An undecidable conversion

Acc is a proposition, yet its recursor may eliminate into data. How can that recursor keep computing on a proof that is only a variable? Sketch how Carneiro turns this into a proof that definitional equality is undecidable. What follows for the kernel’s conversion check? Does any of it give a proof of False?

Answer

The recursor computes when the proof is built by intro. Any proof a : Acc r x yields, by projection, the argument that intro would need. Proof irrelevance then makes a definitionally equal to intro applied to those projections. The rebuilt proof lets the recursor take one more step, and the rebuilding can be repeated indefinitely.

Carneiro fixes a decidable predicate P on natural numbers and takes the relation >, which is not well-founded. A function defined by the recursor tests P(n) and continues to n+1 while it holds, returning false at the first failure. Assume a proof a : Acc (· > ·) 0 as a hypothesis. No such proof exists, but definitional equality must still be decided in that context. The function’s result at 0 is then definitionally equal to false exactly when P fails somewhere. Halting of a Turing machine has this form, so no algorithm decides definitional equality.

The kernel’s conversion check is therefore a decidable approximation. It does not search for rebuilt proofs, so it can fail to confirm equalities that the rules permit. The algorithmic relation is not transitive, and typing based on it fails subject reduction: reducing a well-typed term can produce one the checker rejects at the same type. Neither result yields a proof of False. Both concern completeness. The kernel may reject terms the declared rules accept, but should not accept terms they reject. In practice Lean avoids depending on such reductions: definitions by well-founded recursion are irreducible by default, and their defining equations are used as theorems.

A finite dependent product

Take A=\{0,1\}, B(0)=\{a,b\} and B(1)=\{c\}. List the elements of the dependent product in the set interpretation. What does applying the first of them to 1 denote? Why does beta reduction preserve the meaning? Why is it not enough to let a universe contain all sets?

Answer

A type is interpreted as a set, a family as a set-valued assignment, and a dependent function as a graph selecting one element from each fiber. There are 2\times1=2 such graphs: \{(0,a),(1,c)\} and \{(0,b),(1,c)\}. A lambda expression specifying the first choice denotes the first graph, and applying it to 1 denotes c. Beta reduction preserves that meaning because substituting an argument in a body agrees with evaluating the body in an environment assigning that argument to the bound variable. This is the semantic substitution lemma behind the computation rule. The aim in general is that \Gamma\vdash t:A implies \llbracket t\rrbracket_\rho\in\llbracket A\rrbracket_\rho for every environment \rho satisfying \Gamma.

To interpret universes we need collections of sets with the closure properties demanded by the typing rules. Merely saying that a universe should contain all sets does not produce a set. Which closure conditions we choose, and whether product formation remains in the same universe, determine the required set-theoretic assumptions.

The constant graph

Interpret false as \varnothing and true as 1=\{\star\}. What does the ordinary product \prod_{x:A}1 contain, and why does that stand in the way of an impredicative, proof-irrelevant model? How does Carneiro’s thesis handle the difficulty? Work out why Barras’s shortcut succeeds.

Answer

The product is a singleton containing the constant graph g_A=\{(a,\star)\mid a\in A\}. Its sole element is g_A, not necessarily \star, and changing A changes the graph. So the products of true propositions over different domains do not automatically become the same designated truth value 1. To keep quantification impredicative and proofs irrelevant, a model must reconcile these representations with abstraction, application and substitution.

Carneiro’s thesis proves unique typing first: each term has one type up to definitional equality. The model can then tell which products land in Prop and interpret them differently. Barras’s shortcut uses Aczel’s encoding, which represents a function f as the set of pairs (x,y) with y\in f(x). Take \star=\varnothing. The constant function to \star then has no pairs, because \varnothing has no members. It is the empty set, which is \star itself, whatever its domain.

Semantics first, and its price

Which order of work does Bice reverse? In his universes, at which level does a dependent product land, and why can that level not be lowered to 0 when the fibers are propositions? Work out what the doubly negated product \neg\neg\prod denotes. What does this truncation do to the loop?

Answer

A typical paper on dependent types opens with pages of inference rules and explains their meaning later, if at all. Bice’s two systems start from set interpretations and admit only inference rules that are sound for them. An interpretation assigns sets to constants and variables, and nothing else affects it.

The price is impredicativity. A dependent product whose domain lives at level m and whose fibers live at level n lands at level \max(m+1,n). The m+1 cannot be lowered to 0, even when the fibers are propositions. Identifying all singletons would force it, but would forget each function’s domain, which is the g_A problem.

Bice simulates impredicativity instead. His first system defines universal quantification as a doubly negated product. \neg X := X\to\bot denotes \{\varnothing\} when X is empty and \varnothing otherwise. So \neg\neg\prod denotes \{\varnothing\} when the product is nonempty and \varnothing when it is empty: always one of the two propositions. A proof of \neg\neg\prod_{P}(P\to P) is not a function that accepts a proposition, so the instantiation at D cannot be written.

What the loop shows

The term loop does not normalize. Is that a contradiction? Does it force every type check to diverge? Which systems is the claim about? What is lost, and why can a semantic consistency proof still succeed? What does the #reduce diagnostic establish?

Answer

There is no contradiction: T already has the proof fun P p => p. Proof irrelevance identifies loop with it, but does not supply a computational reduction to it. A checker can recognize proofs of the same proposition without reducing them, so the example does not force every type check to diverge. The claim is about this combination of rules: impredicativity, propositional extensionality and proof-irrelevant cast reduction. It is not about every system that has some notion of proof irrelevance.

What is lost is one route to consistency, the one through normalization and an analysis of normal forms. Losing that method does not exhibit a proof of False. In a successful proof-irrelevant model of the rules, loop and the elementary proof of T would have the same denotation, and every step around the loop would preserve it. Soundness requires preservation of meaning. Termination requires an additional argument ruling out infinite computation, and equality of meanings supplies no decreasing measure.

The accompanying Lean file checks that #reduce (proofs := true) ReductionLoop.loop reaches a bounded recursion limit. This diagnostic corroborates the behavior. The reduction argument establishes divergence.

What a consistency proof covers

What did Carneiro’s thesis prove, and what gap was later reported in it? What does con-leche prove, relative to which assumption, and about which checker? Does a public consistency proof cover Lean 4 as the official kernel implements it?

Answer

The 2019 thesis proved Lean 3’s type theory consistent relative to ZFC with n inaccessible cardinals for every finite n. Lean 4’s extensions need further work beyond that argument. A gap was found while formalizing the thesis. The affected theorems are unique typing and definitional inversion, which rest on a confluence argument, and they are now listed as conjectures. The thesis’s soundness proof used unique typing, though the thesis itself notes that Barras’s encoding avoids that dependency.

con-leche constructs a set-theoretic interpretation and proves that every environment accepted by its verified checker has a model. False denotes the empty set, so no accepted theorem can inhabit it. The result is relative: the accepted declarations are consistent if set theory with an ω-chain of Grothendieck universes is. Its checker deliberately differs from the official kernel, including in its handling of inductives. So the result covers con-leche’s accepted declarations without automatically covering everything the official kernel accepts. The proof is itself a Lean development, checked by the official kernel, so Lean also serves as the metatheory. Connecting the theorem to an executable checker also requires accounting for its parsing, runtime and input handling.

No public proof covers Lean 4 as the official kernel implements it.

What a successful build is evidence of

Name the four questions the essay separates about an individual formalization, and what would answer each. Which of them does #print axioms answer? What is a successful build evidence of? Sort the claims of Moses’s critique: on normalization, on consistency, on implementations, on mistranslated statements, and the forecast that Lean accepts some proof of False.

Answer
  • Does the formal statement express the intended mathematics? Inspect definitions, hypotheses, quantifiers and representations.
  • Does the proof depend only on acceptable assumptions? Inspect its transitive axiom dependencies.
  • Does the checker implement its stated rules correctly? This takes implementation analysis, verification and independent rechecking.
  • Are those rules consistent under the chosen foundations? This takes a metatheoretic argument for the precise formal system.

Success at one level does not discharge the others. A correct kernel can check an unintended theorem, and a plausible mathematical theory can have a defective implementation. #print axioms answers the dependency question. A successful build provides evidence about a particular checking run. Assessing its trust assumptions also requires knowing how tactics, native computation and imported artifacts enter that run.

The normalization claim is correct. It costs one route to consistency and is no evidence of inconsistency. The consistency claim stands as written. The strongest evidence concerns implementations: kernel bugs, nested inductives, and validation tools run without isolation. It belongs to the third question, and de Moura’s postmortem confirms it. The warning about mistranslated statements belongs to the first question. The forecast that current Lean accepts some proof of False is a judgment about implementation risk, which the foundational results neither support nor refute.

Terms

Introduced in this essay: