A proof assistant based on type theory has to reject non-terminating definitions:
a function that loops can inhabit any type, including the empty one, and so proves
everything. Agda therefore checks every recursive definition for termination
before accepting it. Purely syntactic checks, which require some argument to
become structurally smaller at each recursive call, reject many terminating
programs, for example recursion through a higher-order function such as map,
or corecursive definitions by copattern matching whose productivity depends on
sizes rather than syntax.
Two lines of work address this. Size-change termination (Lee, Jones and Ben-Amram, 2001) abstracts each call into a graph recording which arguments decrease, and accepts a program when every infinite call sequence would force an infinite descent. Sized types record an upper bound on the depth of data in its type, so that termination follows from typing. Kanstantsin Nisht's 2024 master's thesis, supervised by Andreas Abel, combines the two in a type-based termination checker for Agda-style programs. Sizes are inferred automatically, and termination is checked by size-change analysis over the inferred sizes. The thesis proves that every program the checker accepts is well-typed and strongly normalizing. This mission formalizes that soundness proof in Lean.
System is a higher-order polymorphic lambda calculus with copattern matching. Its kinds carry polarities that record how a type operator uses its argument. Size expressions are or minima of size variables, and size contexts bound each size variable from above. Sized inductive and coinductive types and are indexed by a size . Programs are sequences of mutual blocks of functions defined by copattern clauses, checked against a global signature of previously accepted functions.
Termination is certified by an invocation-graph family , which
assigns to each pair of functions a set of bipartite graphs relating the caller's
size arguments to the callee's by or . The size-change criterion
(SCTValid) requires a strict self-decrease in every
idempotent graph of the closure. Semantically, types denote Girard–Tait
reducibility candidates of strongly normalizing terms. Sizes denote ordinals, and
(SemMutualBlockValid) says that every function in
belongs to the interpretation of its type.
Algorithm 2 takes a block written without sizes, in System . It encodes each declared type with fresh size variables, elaborates patterns and clause bodies while emitting size constraints, solves the constraints with Algorithm 1, builds the invocation-graph family of the calls, and accepts the block if the size-change criterion holds. The result is a size-annotated block .
If a new block extends a valid, closed signature without forward references, and
Algorithm 2 accepts it, then the annotated block is well-typed and every function
in it is strongly normalizing. Lean name: NishtAbel2024V2.theorem_15.
The result. Theorem 15 is the soundness guarantee a proof assistant needs before it can adopt the checker: accepted definitions cannot be used to derive a contradiction through non-termination. Theorem 6 shows that the type system subsumes lexicographic termination: every block typable in with a lexicographic size measure is typable in once the measure is erased. The semantic results, Theorems 1–5, apply to any front end that produces derivations in , not only to Algorithm 2.
Formalizing it. The thesis's proofs are on paper. Formalizing them showed that the first Lean statements of Theorems 2–3, 4–6, 7–9 with Lemmas 3–5, 10–12, 13–14 and 15 were all false. Each has a machine-checked counterexample, and each refuted statement records the reason on its own page. Theorems 2–6 and 15 were stated without the thesis's scope discipline: an existing function could share a name with, or refer to, a function of the new block, forming a loop through the existing signature that the size-change check of the new block does not see. Theorem 11 checked one occurrence of a rigid size variable where the thesis requires all occurrences to lie in least fixpoints. Theorems 13–14 omitted well-formedness of the global signature. The Lemma 5 statement allowed inputs that the thesis's encoding never produces. The counterexamples show where the paper argument depends on assumptions it states informally. They do not refute the thesis's theorems under those assumptions.
As of November 2026, Lemma 1 and Theorem 1 are proved over the original definitions, with no statement over the corrected definitions yet. The corrected Theorems 7–14 are proved, and the corrected Theorems 2–6 and 15 are open. The milestone list shows the current state.
The central step is Theorem 4: a mutual block is strongly normalizing once its calls satisfy the size-change criterion. Induction on a single size argument does not suffice, because mutually recursive calls may decrease different arguments along different call paths. Strong normalization of one function therefore depends on the whole call structure of the block, and the semantic typing of Theorem 3 has to hold uniformly while the existing signature stays fixed.
On the inference side, constraint solving is sound only if no constraint forces a flexible size variable below a rigid one. Establishing this (Theorems 10–12) requires tracking the polarity of every size occurrence through higher-kinded type operators, including operators that ignore an argument. The first formal attempts show that a statement of these invariants close to the prose is false, so finding a provable statement is itself part of the work.
Lean names with the suffix V2 (namespace NishtAbel2024V2) are the corrected
statements, built on three definition modules: NishtAbel2024V2_Syntax,
NishtAbel2024V2_Semantics and NishtAbel2024V2_Inference. The namespace
NishtAbel2024 holds the first formalization, whose refuted statements remain on
the platform with their disproofs. The corrected statements commit to the
following conventions.
scopeBlockExtension; scopeOrderedBlocks for programs).SemSigValidIn).PostcheckedAlgorithm2Accepts). Corrected Theorem 13 and the typing half of Theorem 15 therefore rest on this check. The thesis's stronger claim, that inference always produces well-typed output from a well-formed signature, is not part of the targets.CheckedConstraintSolver.checkedSolve, which returns Algorithm 1's substitution only when a finite coherence certificate succeeds.GuardedCompareTypes, SafeInferTerm and SafeCheckTerm; the last two erase to the original inference judgments.CheckUse) instead of stating the thesis's four-way classification.The main goal does not assume that the new block terminates. It assumes validity of the existing signature only, so the strong normalization conclusion is not built into the hypotheses.
Several proved milestones (scope stability, Theorem 2 size soundness, a guarded
Theorem 10, Theorems 7–9, Lemma 3, and the lexicographic graph construction of
Theorem 6) are stated over the original NishtAbel2024 definitions. They are
correct results about that model but do not transfer to the corrected
definitions. Contributions are welcome for:
namespace NishtAbel2024V5
theorem theorem_15 (W sig Ξ Ξannot : List FunDecl)
(hsigwf : ∀ g ∈ sig, SizeCtxWf g.sizeParams ∧ KindingC g.sizeParams [] g.ty .star)
(hacc : Algorithm2Accepts sig Ξ Ξannot)
(hW : ∀ d ∈ sig ++ Ξannot, d ∈ W)
(hnames : (W.map FunDecl.name).Nodup)
(hclosed : ∀ d ∈ W, (Tm.lam d.clauses).Closed)
(hsig : SemValid W sig) :
BlockTy sig Ξannot ∧ SemValid W Ξannot := by sorry
end NishtAbel2024V5The main end-to-end soundness theorem of Nisht and Abel (2024) (Chapter 6, Section 6.5, Theorem 15, p. 59), uniting algorithmic size inference, constraint solving, size-change termination checking, and the ordinal reducibility semantics of System .\n\nLet be a closed run-time world of function declarations with distinct names containing , where every global signature declaration is well-kinded (SizeCtxWf g.sizeParams ∧ KindingC g.sizeParams [] g.ty .star) and semantically valid in (SemValid W sig). If Algorithm 2 accepts the unsized mutual block and produces the size-annotated block (Algorithm2Accepts sig Ξ Ξannot), then:\n
\n\nIn particular, is both syntactically well-typed in System (BlockTy sig Ξannot) and semantically valid / strongly normalizing in (SemValid W Ξannot).
No open leaves. Every sub-goal is proved or awaiting decomposition.