Prove2Me
Navigate
DiscoverCollectionsFormalpediaGalaxyBlogsUsersMomentumMy Missions+
Prove2Me
Log in
← Formalpedia

Semantic Soundness of Size Judgments (Theorem 2) and Expression/Clause Typing (Theorem 3)

Disproved
NishtAbel2024.theorems_2_and_3

by kmehltretter82 · Oct 31, 2026 · Mathlib 0df444a (Lean v4.33.1)

agdacopatternssize-change-terminationsized-typesstrong-normalizationtermination-checkingtype-theory

Theorems 2 and 3 (Sections 5.4.1 & 5.4.3, pp. 35–37): (1) semantic monotonicity and soundness of syntactic size well-formedness (SizeWf), weak inequality (SizeLe), and strict inequality (SizeLt) under ordered size valuations SizeValLe Ψ ρ ρ'; and (2) the Fundamental Theorem of Reducibility (SemExprTyping and SemClausesTyping) for well-typed expressions and copattern clauses under guarded recursive block validity.

Superseded. This is the first formalization of Theorems 2–3 (pp. 36–37) of the thesis. It is refuted through its Theorem 3 conjunct by the disproof 33af96b2-4760-46a4-b568-514c51eb7ee9: the existing signature declares a function of unit type with no clauses, and the new block declares a function with the same name whose clause calls it. The signature alone is valid and the reference is typable, but with the block present the reference reduces to itself forever, so it is not in the interpretation of the unit type. The thesis assumes that existing functions were checked earlier and cannot refer to the current block (§5.4.2); the formal statement does not. Corrected statement: NishtAbel2024V2.theorems_2_and_3. It assumes a well-scoped block extension (scopeBlockExtension) and uses revised semantics for quantifiers and inductive types, which also resolve two further checked counterexamples to the original Theorem 3.

Preamble
import Definitions.Def_NishtAbel2024_Syntax
import Definitions.Def_NishtAbel2024_Semantics
Formal statement
namespace NishtAbel2024

/-- Theorem 2 (Soundness of kind-level judgments, p. 36) and
Theorem 3 (Soundness of expression typing in System `F_ω^{cop, SCT}`, pp. 36–37):
1. (**Theorem 2**) For any well-formed size context `⊢ Ψ` and ordered valuations
   `ρ ≤ ρ' ∈ ⟦Ψ⟧`:
   - `Ψ ⊢ a ⟹ ⟦a⟧_ρ ≤ ⟦a⟧_{ρ'}`
   - `Ψ ⊢ a ≤ b ⟹ ⟦a⟧_ρ ≤ ⟦b⟧_{ρ'}`
   - `Ψ ⊢ a < b ⟹ ⟦a⟧_ρ < ⟦b⟧_{ρ'}`.
2. (**Theorem 3**) Under semantic validity `⊨ Σ`, well-formed contexts `⊢ Δ`, `Δ ⊢ Γ`,
   `Δ ⊢ C ⇐ *`, `⊢ G`, and guarded block validity `G, ⟦Ψ_f⟧ ⊨ Ξ`, bidirectional expression
   inference, expression checking, and clause checking imply semantic membership in the
   reducibility candidate `⟦C⟧`. -/
theorem theorems_2_and_3 :
    (∀ (Ψ : SizeCtx) (ρ ρ' : SizeVal),
      SizeCtxWf Ψ →
      SizeValLe Ψ ρ ρ' →
      (∀ a : SizeExp, SizeWf Ψ a → SizeOrd.le (evalSizeExp ρ a) (evalSizeExp ρ' a)) ∧
      (∀ a b : SizeExp, SizeLe Ψ a b → SizeOrd.le (evalSizeExp ρ a) (evalSizeExp ρ' b)) ∧
      (∀ a b : SizeExp, SizeLt Ψ a b → SizeOrd.lt (evalSizeExp ρ a) (evalSizeExp ρ' b))) ∧
    (∀ (Ω : TypingEnv) (Δ : KindingCtx) (Γ : TermCtx) (C : TypeExpr),
      SemSigValid Ω.sig →
      SizeCtxWf Δ.sizes →
      TermCtxWf Δ Γ →
      KindCheck Δ C .star →
      SCTValid Ω.graphs →
      (∀ ρ ∈ evalKindingCtx Δ,
        SemBlockGuardedValid Ω.sig Ω.block Ω.graphs Ω.caller Ω.callerSizes ρ) →
      (∀ r : Term, ExprInfer Ω Δ Γ r C → SemExprTyping Ω.sig Ω.block Δ Γ r C) ∧
      (∀ r : Term, ExprCheck Ω Δ Γ r C → SemExprTyping Ω.sig Ω.block Δ Γ r C) ∧
      (∀ Ds : List Clause,
        (∀ D ∈ Ds, ClauseCheck Ω Δ Γ D C) →
        SemClausesTyping Ω.sig Ω.block Δ Γ Ds C)) := by
  sorry

end NishtAbel2024
Source
Kanstantsin Nisht, 'Type-Based Termination Checking in Agda', Master's Thesis in Computer Science and Engineering, Chalmers University of Technology and University of Gothenburg (supervised by Andreas Abel), 2024; extended abstract by Kanstantsin Nisht and Andreas Abel, 30th International Conference on Types for Proofs and Programs (TYPES 2024). Section 5.4, Theorem 2 (p. 35) and Theorem 3 (pp. 36–37).
Read-back

What the Lean code literally says, in plain math · Gemini 3.1 Pro (Independent Blind Auditor)

Independent Mathematical Read-Back: Thm_NishtAbel2024_theorems_2_and_3.lean

The declaration NishtAbel2024.theorems_2_and_3 asserts the conjunction T2∧T3T_2 \land T_3T2​∧T3​ of two propositions: semantic monotonicity and soundness of syntactic size judgments (T2T_2T2​), and semantic soundness of syntactic expression and clause typing with respect to reducibility candidates (T3T_3T3​).

Definitions for T2T_2T2​ (Polarities, Size Expressions, and Size Valuations).

  • Polarities: The set of polarities is Polarity={∘,+,−,⊤}\mathrm{Polarity} = \{\circ, +, -, \top\}Polarity={∘,+,−,⊤} (mixed, pos, neg, top), ordered by ∘≤π\circ \le \pi∘≤π, π≤⊤\pi \le \topπ≤⊤, +≤++ \le ++≤+, and −≤−- \le -−≤− (all other pairs false). Composition π1⋅π2\pi_1 \cdot \pi_2π1​⋅π2​ (Polarity.comp) satisfies ⊤⋅π=π⋅⊤=⊤\top \cdot \pi = \pi \cdot \top = \top⊤⋅π=π⋅⊤=⊤, ∘⋅π=π⋅∘=∘\circ \cdot \pi = \pi \cdot \circ = \circ∘⋅π=π⋅∘=∘, +⋅π=π⋅+=π+ \cdot \pi = \pi \cdot + = \pi+⋅π=π⋅+=π, and −⋅−=+- \cdot - = +−⋅−=+. Left-inverse composition π−1π′\pi^{-1}\pi'π−1π′ (Polarity.invComp) is defined by ⊤−1π′=∘\top^{-1}\pi' = \circ⊤−1π′=∘, ∘−1∘=∘\circ^{-1}\circ = \circ∘−1∘=∘, ∘−1π′=⊤\circ^{-1}\pi' = \top∘−1π′=⊤ for π′≠∘\pi' \ne \circπ′=∘, +−1π′=π′+^{-1}\pi' = \pi'+−1π′=π′, and −−1π′=−⋅π′-^{-1}\pi' = - \cdot \pi'−−1π′=−⋅π′.
  • Size expressions: Size variables are natural numbers (SizeVar=N\mathrm{SizeVar} = \mathbb{N}SizeVar=N). A shifted size variable (i,n)(i, n)(i,n) represents i+ni + ni+n (i,n∈Ni, n \in \mathbb{N}i,n∈N). A formal minimum m∈SizeMinm \in \mathrm{SizeMin}m∈SizeMin is a non-empty list of shifted size variables (i0,n0),…,(ik,nk)(i_0, n_0), \dots, (i_k, n_k)(i0​,n0​),…,(ik​,nk​). A size expression a∈SizeExpa \in \mathrm{SizeExp}a∈SizeExp is either inf(n)\mathsf{inf}(n)inf(n) for n∈Nn \in \mathbb{N}n∈N (representing ∞+n\infty + n∞+n, with ∞=inf(0)\infty = \mathsf{inf}(0)∞=inf(0)) or meet(m)\mathsf{meet}(m)meet(m) for m∈SizeMinm \in \mathrm{SizeMin}m∈SizeMin (representing min⁡(i,n)∈m(i+n)\min_{(i, n) \in m}(i + n)min(i,n)∈m​(i+n), with var(i,n)=meet([(i,n)])\mathsf{var}(i, n) = \mathsf{meet}([(i, n)])var(i,n)=meet([(i,n)])). Shifting a.shift(k)a.\mathrm{shift}(k)a.shift(k) maps inf(n)\mathsf{inf}(n)inf(n) to inf(n+k)\mathsf{inf}(n + k)inf(n+k) and adds kkk to every shift in meet(m)\mathsf{meet}(m)meet(m). Bound normalization a.boundNorma.\mathrm{boundNorm}a.boundNorm maps inf(n)\mathsf{inf}(n)inf(n) to inf(1)\mathsf{inf}(1)inf(1) for all n∈Nn \in \mathbb{N}n∈N and leaves meet(m)\mathsf{meet}(m)meet(m) unchanged.
  • Size contexts and syntactic size relations: A size context Ψ∈SizeCtx\Psi \in \mathrm{SizeCtx}Ψ∈SizeCtx is a list of declarations (i,π,a)∈N×Polarity×SizeExp(i, \pi, a) \in \mathbb{N} \times \mathrm{Polarity} \times \mathrm{SizeExp}(i,π,a)∈N×Polarity×SizeExp. Its domain Ψ.dom\Psi.\mathrm{dom}Ψ.dom is the list of declared variables; Ψ.scalePol(π)\Psi.\mathrm{scalePol}(\pi)Ψ.scalePol(π) replaces each declaration's polarity πd\pi_dπd​ with π⋅πd\pi \cdot \pi_dπ⋅πd​; and Ψ.invScalePol(π)\Psi.\mathrm{invScalePol}(\pi)Ψ.invScalePol(π) replaces πd\pi_dπd​ with π−1πd\pi^{-1}\pi_dπ−1πd​.
    • SizeVarBound(Ψ,i,a)\mathrm{SizeVarBound}(\Psi, i, a)SizeVarBound(Ψ,i,a) holds iff there exists π∈{∘,+}\pi \in \{\circ, +\}π∈{∘,+} such that (i,π,a)∈Ψ(i, \pi, a) \in \Psi(i,π,a)∈Ψ.
    • SizeWf(Ψ,a)\mathrm{SizeWf}(\Psi, a)SizeWf(Ψ,a) holds trivially if a=inf(n)a = \mathsf{inf}(n)a=inf(n), and for a=meet(m)a = \mathsf{meet}(m)a=meet(m) iff every (i,n)∈m(i, n) \in m(i,n)∈m has some bbb with SizeVarBound(Ψ,i,b)\mathrm{SizeVarBound}(\Psi, i, b)SizeVarBound(Ψ,i,b).
    • SizeCtxWf(Ψ)\mathrm{SizeCtxWf}(\Psi)SizeCtxWf(Ψ) holds inductively for [][][], and for Ψ+ ⁣+[(i,π,a)]\Psi \mathbin{+\!+} [(i, \pi, a)]Ψ++[(i,π,a)] when SizeCtxWf(Ψ)\mathrm{SizeCtxWf}(\Psi)SizeCtxWf(Ψ), i∉Ψ.domi \notin \Psi.\mathrm{dom}i∈/Ψ.dom, and SizeWf(Ψ.invScalePol(∘),a)\mathrm{SizeWf}(\Psi.\mathrm{invScalePol}(\circ), a)SizeWf(Ψ.invScalePol(∘),a) (meaning every size variable in aaa occurs in Ψ\PsiΨ with polarity ∘\circ∘).
    • SizeLt(Ψ,a,b)\mathrm{SizeLt}(\Psi, a, b)SizeLt(Ψ,a,b) (Ψ⊢a<b\Psi \vdash a < bΨ⊢a<b) is the inductive relation generated by:
      1. n<m  ⟹  Ψ⊢inf(n)<inf(m)n < m \implies \Psi \vdash \mathsf{inf}(n) < \mathsf{inf}(m)n<m⟹Ψ⊢inf(n)<inf(m);
      2. n<m∧SizeVarBound(Ψ,i,a)  ⟹  Ψ⊢var(i,n)<var(i,m)n < m \land \mathrm{SizeVarBound}(\Psi, i, a) \implies \Psi \vdash \mathsf{var}(i, n) < \mathsf{var}(i, m)n<m∧SizeVarBound(Ψ,i,a)⟹Ψ⊢var(i,n)<var(i,m);
      3. SizeVarBound(Ψ,i,inf(0))  ⟹  Ψ⊢var(i,n)<inf(m)\mathrm{SizeVarBound}(\Psi, i, \mathsf{inf}(0)) \implies \Psi \vdash \mathsf{var}(i, n) < \mathsf{inf}(m)SizeVarBound(Ψ,i,inf(0))⟹Ψ⊢var(i,n)<inf(m);
      4. SizeVarBound(Ψ,i,inf(m))  ⟹  Ψ⊢var(i,n)<inf(m+n)\mathrm{SizeVarBound}(\Psi, i, \mathsf{inf}(m)) \implies \Psi \vdash \mathsf{var}(i, n) < \mathsf{inf}(m + n)SizeVarBound(Ψ,i,inf(m))⟹Ψ⊢var(i,n)<inf(m+n);
      5. SizeVarBound(Ψ,i,a)∧Ψ⊢a.shift(n)<b.shift(1)  ⟹  Ψ⊢var(i,n)<b\mathrm{SizeVarBound}(\Psi, i, a) \land \Psi \vdash a.\mathrm{shift}(n) < b.\mathrm{shift}(1) \implies \Psi \vdash \mathsf{var}(i, n) < bSizeVarBound(Ψ,i,a)∧Ψ⊢a.shift(n)<b.shift(1)⟹Ψ⊢var(i,n)<b;
      6. SizeWf(Ψ,meet(m))∧(i,n)∈m∧Ψ⊢var(i,n)<b  ⟹  Ψ⊢meet(m)<b\mathrm{SizeWf}(\Psi, \mathsf{meet}(m)) \land (i, n) \in m \land \Psi \vdash \mathsf{var}(i, n) < b \implies \Psi \vdash \mathsf{meet}(m) < bSizeWf(Ψ,meet(m))∧(i,n)∈m∧Ψ⊢var(i,n)<b⟹Ψ⊢meet(m)<b;
      7. (∀(i,n)∈m,  Ψ⊢a<var(i,n))  ⟹  Ψ⊢a<meet(m)(\forall (i, n) \in m,\; \Psi \vdash a < \mathsf{var}(i, n)) \implies \Psi \vdash a < \mathsf{meet}(m)(∀(i,n)∈m,Ψ⊢a<var(i,n))⟹Ψ⊢a<meet(m).
    • SizeLe(Ψ,a,b)\mathrm{SizeLe}(\Psi, a, b)SizeLe(Ψ,a,b) (Ψ⊢a≤b\Psi \vdash a \le bΨ⊢a≤b) is defined as SizeLt(Ψ,a,b.shift(1))\mathrm{SizeLt}(\Psi, a, b.\mathrm{shift}(1))SizeLt(Ψ,a,b.shift(1)).
  • Semantic evaluation of sizes: A size valuation is a function ρ:N→SizeOrd\rho : \mathbb{N} \to \mathrm{SizeOrd}ρ:N→SizeOrd. The evaluation ⟦a⟧ρ\llbracket a \rrbracket_\rho[[a]]ρ​ (evalSizeExp ρ a) maps inf(n)\mathsf{inf}(n)inf(n) to (1,n)(1, n)(1,n) and meet(m)\mathsf{meet}(m)meet(m) to the <ord<_{\mathrm{ord}}<ord​-minimum over (i,n)∈m(i, n) \in m(i,n)∈m of (ρ(i).tier,ρ(i).offset+n)(\rho(i).\mathrm{tier}, \rho(i).\mathrm{offset} + n)(ρ(i).tier,ρ(i).offset+n).
    • ValidSizeVal(Ψ,ρ)\mathrm{ValidSizeVal}(\Psi, \rho)ValidSizeVal(Ψ,ρ) holds iff for every (i,π,a)∈Ψ(i, \pi, a) \in \Psi(i,π,a)∈Ψ, ρ(i)<ord⟦a⟧ρ\rho(i) <_{\mathrm{ord}} \llbracket a \rrbracket_\rhoρ(i)<ord​[[a]]ρ​.
    • SizeValLe(Ψ,ρ,ρ′)\mathrm{SizeValLe}(\Psi, \rho, \rho')SizeValLe(Ψ,ρ,ρ′) holds iff ValidSizeVal(Ψ,ρ)\mathrm{ValidSizeVal}(\Psi, \rho)ValidSizeVal(Ψ,ρ), ValidSizeVal(Ψ,ρ′)\mathrm{ValidSizeVal}(\Psi, \rho')ValidSizeVal(Ψ,ρ′), and for every (i,π,a)∈Ψ(i, \pi, a) \in \Psi(i,π,a)∈Ψ: ρ(i)=ρ′(i)\rho(i) = \rho'(i)ρ(i)=ρ′(i) if π=∘\pi = \circπ=∘; ρ(i)≤ordρ′(i)\rho(i) \le_{\mathrm{ord}} \rho'(i)ρ(i)≤ord​ρ′(i) if π=+\pi = +π=+; ρ′(i)≤ordρ(i)\rho'(i) \le_{\mathrm{ord}} \rho(i)ρ′(i)≤ord​ρ(i) if π=−\pi = -π=−; and no constraint if π=⊤\pi = \topπ=⊤.

Statement of First Conjunct (T2T_2T2​). For every size context Ψ∈SizeCtx\Psi \in \mathrm{SizeCtx}Ψ∈SizeCtx and all size valuations ρ,ρ′:N→SizeOrd\rho, \rho' : \mathbb{N} \to \mathrm{SizeOrd}ρ,ρ′:N→SizeOrd, if SizeCtxWf(Ψ)\mathrm{SizeCtxWf}(\Psi)SizeCtxWf(Ψ) and SizeValLe(Ψ,ρ,ρ′)\mathrm{SizeValLe}(\Psi, \rho, \rho')SizeValLe(Ψ,ρ,ρ′) hold, then:

  1. For all a∈SizeExpa \in \mathrm{SizeExp}a∈SizeExp, if SizeWf(Ψ,a)\mathrm{SizeWf}(\Psi, a)SizeWf(Ψ,a), then ⟦a⟧ρ≤ord⟦a⟧ρ′\llbracket a \rrbracket_\rho \le_{\mathrm{ord}} \llbracket a \rrbracket_{\rho'}[[a]]ρ​≤ord​[[a]]ρ′​.
  2. For all a,b∈SizeExpa, b \in \mathrm{SizeExp}a,b∈SizeExp, if SizeLe(Ψ,a,b)\mathrm{SizeLe}(\Psi, a, b)SizeLe(Ψ,a,b), then ⟦a⟧ρ≤ord⟦b⟧ρ′\llbracket a \rrbracket_\rho \le_{\mathrm{ord}} \llbracket b \rrbracket_{\rho'}[[a]]ρ​≤ord​[[b]]ρ′​.
  3. For all a,b∈SizeExpa, b \in \mathrm{SizeExp}a,b∈SizeExp, if SizeLt(Ψ,a,b)\mathrm{SizeLt}(\Psi, a, b)SizeLt(Ψ,a,b), then ⟦a⟧ρ<ord⟦b⟧ρ′\llbracket a \rrbracket_\rho <_{\mathrm{ord}} \llbracket b \rrbracket_{\rho'}[[a]]ρ​<ord​[[b]]ρ′​.

Definitions for T3T_3T3​ (Types, Terms, Reduction, Reducibility Candidates, and Typing).

  • Kinds and types: Kinds are generated by κ::=⋆∣< a∣κ1→πκ2\kappa ::= \star \mid {<}\,a \mid \kappa_1 \xrightarrow{\pi} \kappa_2κ::=⋆∣<a∣κ1​π​κ2​ (Kind), with simple kinds ι::=⋆∣prop∣ι1→πι2\iota ::= \star \mid \mathsf{prop} \mid \iota_1 \xrightarrow{\pi} \iota_2ι::=⋆∣prop∣ι1​π​ι2​ (SKind). Subkinding Ψ⊢κ≤κ′\Psi \vdash \kappa \le \kappa'Ψ⊢κ≤κ′ (SubKind) is reflexive on ⋆\star⋆, covariant in aaa via SizeLe\mathrm{SizeLe}SizeLe on < a{<}\,a<a, contravariant in the polarity (π′≤π\pi' \le \piπ′≤π) and domain kind (in Ψ.scalePol(−)\Psi.\mathrm{scalePol}(-)Ψ.scalePol(−)) and covariant in the codomain kind on κ1→πκ2\kappa_1 \xrightarrow{\pi} \kappa_2κ1​π​κ2​. A kinding context Δ=(Δ.sizes,Δ.types)\Delta = (\Delta.\mathrm{sizes}, \Delta.\mathrm{types})Δ=(Δ.sizes,Δ.types) consists of a SizeCtx and a list of type declarations (X,π,κ)∈N×Polarity×Kind(X, \pi, \kappa) \in \mathbb{N} \times \mathrm{Polarity} \times \mathrm{Kind}(X,π,κ)∈N×Polarity×Kind. Extending Δ\DeltaΔ with (X,π,κ)(X, \pi, \kappa)(X,π,κ) via Δ.extType(X,π,κ)\Delta.\mathrm{extType}(X, \pi, \kappa)Δ.extType(X,π,κ) appends (X,π,κ)(X, \pi, \kappa)(X,π,κ) to Δ.types\Delta.\mathrm{types}Δ.types and, when κ=< a\kappa = {<}\,aκ=<a, also appends (X,π,a)(X, \pi, a)(X,π,a) to Δ.sizes\Delta.\mathrm{sizes}Δ.sizes.
  • Type expressions A,B,C,F,G∈TypeExprA, B, C, F, G \in \mathrm{TypeExpr}A,B,C,F,G∈TypeExpr are generated by atoms (unit\mathsf{unit}unit, prod\mathsf{prod}prod, arr\mathsf{arr}arr, all(κ)\mathsf{all}(\kappa)all(κ), ex(κ)\mathsf{ex}(\kappa)ex(κ), size(a)\mathsf{size}(a)size(a), var(X)\mathsf{var}(X)var(X)), type abstraction lam(X,ι,F)\mathsf{lam}(X, \iota, F)lam(X,ι,F), type application app(F,G)\mathsf{app}(F, G)app(F,G), inductive types μa. S\mu a.\, Sμa.S (S∈List(N×TypeExpr)S \in \mathrm{List}(\mathbb{N} \times \mathrm{TypeExpr})S∈List(N×TypeExpr)), and coinductive types νa. R\nu a.\, Rνa.R (R∈List(N×TypeExpr)R \in \mathrm{List}(\mathbb{N} \times \mathrm{TypeExpr})R∈List(N×TypeExpr)). Normalized application F.normApp(G)F.\mathrm{normApp}(G)F.normApp(G) substitutes GGG for free var(X)\mathsf{var}(X)var(X) in BBB if F=lam(X,ι,B)F = \mathsf{lam}(X, \iota, B)F=lam(X,ι,B) (without renaming bound variables of BBB that may be free in GGG), and otherwise forms app(F,G)\mathsf{app}(F, G)app(F,G). KindInfer, KindCheck, SubTypeInfer, SubTypeCheck, and SubType (SubType(Δ,A,C)  ⟺  SubTypeInfer(Δ,+,A,C,⋆)\mathrm{SubType}(\Delta, A, C) \iff \mathrm{SubTypeInfer}(\Delta, +, A, C, \star)SubType(Δ,A,C)⟺SubTypeInfer(Δ,+,A,C,⋆)) define bidirectional kinding and polarized higher-kinded subtyping.
  • Terms and operational semantics: Terms r,s,t∈Termr, s, t \in \mathrm{Term}r,s,t∈Term consist of variables var(x)\mathsf{var}(x)var(x), function references funRef(f,as)\mathsf{funRef}(f, as)funRef(f,as) (f∈N,as∈List SizeExpf \in \mathbb{N}, as \in \mathrm{List}\,\mathrm{SizeExp}f∈N,as∈ListSizeExp), elimination applications app(r,e)\mathsf{app}(r, e)app(r,e) where e∈Elime \in \mathrm{Elim}e∈Elim is term(s)\mathsf{term}(s)term(s), tyArg(G)\mathsf{tyArg}(G)tyArg(G), or proj(d,ma)\mathsf{proj}(d, ma)proj(d,ma) (d∈N,ma∈Option SizeExpd \in \mathbb{N}, ma \in \mathrm{Option}\,\mathrm{SizeExp}d∈N,ma∈OptionSizeExp), unit unit\mathsf{unit}unit, pairs pair(t1,t2)\mathsf{pair}(t_1, t_2)pair(t1​,t2​), constructors cons(c,ma,t)\mathsf{cons}(c, ma, t)cons(c,ma,t), existential packages pack(G,t)\mathsf{pack}(G, t)pack(G,t), pattern-matching clause lists lamClauses(Ds)\mathsf{lamClauses}(Ds)lamClauses(Ds) (Ds∈List ClauseDs \in \mathrm{List}\,\mathrm{Clause}Ds∈ListClause, each clause mk(qs,t)\mathsf{mk}(qs, t)mk(qs,t) pairing a copattern spine qsqsqs with a right-hand side term ttt), and type ascriptions ascr(t,A)\mathsf{ascr}(t, A)ascr(t,A).
    • Given a global signature sig∈List FunDecl\mathrm{sig} \in \mathrm{List}\,\mathrm{FunDecl}sig∈ListFunDecl and mutual block Ξ∈List FunDecl\Xi \in \mathrm{List}\,\mathrm{FunDecl}Ξ∈ListFunDecl, weak head reduction WhdStep(sig,Ξ,t,t′)\mathrm{WhdStep}(\mathrm{sig}, \Xi, t, t')WhdStep(sig,Ξ,t,t′) strips head ascriptions ascr(t0,A)\mathsf{ascr}(t_0, A)ascr(t0​,A) under any elimination spine eseses, reduces lamClauses(Ds)\mathsf{lamClauses}(Ds)lamClauses(Ds) applied to es+ ⁣+es′es \mathbin{+\!+} es'es++es′ when some clause mk(qs,t0)∈Ds\mathsf{mk}(qs, t_0) \in Dsmk(qs,t0​)∈Ds matches eseses via MatchSpine yielding substitutions (τ,σ)(\tau, \sigma)(τ,σ) (producing ((t0.substTypes(τ)).substTerms(σ))((t_0.\mathrm{substTypes}(\tau)).\mathrm{substTerms}(\sigma))((t0​.substTypes(τ)).substTerms(σ)) applied to es′es'es′), and similarly unfolds funRef(decl.name,as)\mathsf{funRef}(\mathrm{decl}.\mathrm{name}, as)funRef(decl.name,as) for any decl∈sig+ ⁣+Ξ\mathrm{decl} \in \mathrm{sig} \mathbin{+\!+} \Xidecl∈sig++Ξ by also substituting decl.sizeParams.dom.zip(as)\mathrm{decl}.\mathrm{sizeParams}.\mathrm{dom}.\mathrm{zip}(as)decl.sizeParams.dom.zip(as).
    • Full one-step reduction RedStep(sig,Ξ,t,t′)\mathrm{RedStep}(\mathrm{sig}, \Xi, t, t')RedStep(sig,Ξ,t,t′) is the compatible closure of WhdStep\mathrm{WhdStep}WhdStep under pairs, constructors, existential packages, applications (function and term argument), ascriptions, and clause bodies inside lamClauses\mathsf{lamClauses}lamClauses. SN(sig,Ξ,t)\mathrm{SN}(\mathrm{sig}, \Xi, t)SN(sig,Ξ,t) asserts that ttt is accessible (strongly normalizing) under RedStep(sig,Ξ)\mathrm{RedStep}(\mathrm{sig}, \Xi)RedStep(sig,Ξ).
  • Reducibility candidates and semantic types:
    • A term ttt is an introduction form (IsIntro(t)\mathrm{IsIntro}(t)IsIntro(t)) iff ttt is unit\mathsf{unit}unit, pair\mathsf{pair}pair, cons\mathsf{cons}cons, or pack\mathsf{pack}pack.
    • A term ttt is neutral (IsNeutral(sig,Ξ,t)\mathrm{IsNeutral}(\mathrm{sig}, \Xi, t)IsNeutral(sig,Ξ,t)) iff ¬IsIntro(t)\neg\mathrm{IsIntro}(t)¬IsIntro(t) and either (∃t′,  WhdStep(sig,Ξ,t,t′))(\exists t',\; \mathrm{WhdStep}(\mathrm{sig}, \Xi, t, t'))(∃t′,WhdStep(sig,Ξ,t,t′)) or (∀es,t′,  ¬WhdStep(sig,Ξ,appSpine(t,es),t′))(\forall es, t',\; \neg\mathrm{WhdStep}(\mathrm{sig}, \Xi, \mathrm{appSpine}(t, es), t'))(∀es,t′,¬WhdStep(sig,Ξ,appSpine(t,es),t′)).
    • A set of terms A⊆Term\mathcal{A} \subseteq \mathrm{Term}A⊆Term is a candidate (IsCandidate(sig,Ξ,A)\mathrm{IsCandidate}(\mathrm{sig}, \Xi, \mathcal{A})IsCandidate(sig,Ξ,A)) iff: (1) A⊆SN(sig,Ξ)\mathcal{A} \subseteq \mathrm{SN}(\mathrm{sig}, \Xi)A⊆SN(sig,Ξ); (2) A\mathcal{A}A is closed under RedStep(sig,Ξ)\mathrm{RedStep}(\mathrm{sig}, \Xi)RedStep(sig,Ξ); (3) every neutral term ttt whose one-step reducts all lie in A\mathcal{A}A is in A\mathcal{A}A; and (4) every non-introduction term ttt whose one-step reducts lie in A\mathcal{A}A and whose weak head steps under any spine eseses are simulated by some rkr_krk​ in a finite list ts⊆Ats \subseteq \mathcal{A}ts⊆A is in A\mathcal{A}A.
    • candClosure(sig,Ξ,X)\mathrm{candClosure}(\mathrm{sig}, \Xi, X)candClosure(sig,Ξ,X) is the intersection of all candidates C\mathcal{C}C containing X∩SN(sig,Ξ)X \cap \mathrm{SN}(\mathrm{sig}, \Xi)X∩SN(sig,Ξ) (intersected with SN(sig,Ξ)\mathrm{SN}(\mathrm{sig}, \Xi)SN(sig,Ξ)).
    • Semantic type evaluation ⟦C⟧ρ,ηsig,Ξ\llbracket C \rrbracket^{\mathrm{sig}, \Xi}_{\rho, \eta}[[C]]ρ,ηsig,Ξ​ (evalTypeWith) interprets types as sets of terms by structural recursion on CCC (and well-founded recursion on ⟦a.boundNorm⟧ρ\llbracket a.\mathrm{boundNorm} \rrbracket_\rho[[a.boundNorm]]ρ​ under <ord<_{\mathrm{ord}}<ord​ for μa. S\mu a.\, Sμa.S and νa. R\nu a.\, Rνa.R), closing each base/constructor case under candClosure(sig,Ξ,−)\mathrm{candClosure}(\mathrm{sig}, \Xi, -)candClosure(sig,Ξ,−) and evaluating app(lam(X,ι,B),G)\mathsf{app}(\mathsf{lam}(X, \iota, B), G)app(lam(X,ι,B),G) as ⟦B⟧ρ,η[X↦⟦G⟧ρ,η]sig,Ξ\llbracket B \rrbracket^{\mathrm{sig}, \Xi}_{\rho, \eta[X \mapsto \llbracket G \rrbracket_{\rho, \eta}]}[[B]]ρ,η[X↦[[G]]ρ,η​]sig,Ξ​. In particular, ⟦C⟧ρsig,Ξ\llbracket C \rrbracket^{\mathrm{sig}, \Xi}_\rho[[C]]ρsig,Ξ​ (evalType sig Ξ ρ C) evaluates CCC with the empty candidate environment η0\eta_0η0​ mapping every type variable X∈NX \in \mathbb{N}X∈N to candClosure(sig,Ξ,∅)\mathrm{candClosure}(\mathrm{sig}, \Xi, \emptyset)candClosure(sig,Ξ,∅).
  • Syntactic and semantic typing judgments:
    • A typing environment Ω=(sig,block,graphs,caller,callerSizes)\Omega = (\mathrm{sig}, \mathrm{block}, \mathrm{graphs}, \mathrm{caller}, \mathrm{callerSizes})Ω=(sig,block,graphs,caller,callerSizes) bundles a global signature, a local mutual block, an invocation graph family, a caller function name, and a caller size context.
    • ExprInfer, ExprCheck, and ClauseCheck are mutually defined syntactic typing judgments Ω;Δ;Γ⊢r⇒C\Omega; \Delta; \Gamma \vdash r \Rightarrow CΩ;Δ;Γ⊢r⇒C, Ω;Δ;Γ⊢r⇐C\Omega; \Delta; \Gamma \vdash r \Leftarrow CΩ;Δ;Γ⊢r⇐C, and Ω;Δ;Γ⊢D⇐C\Omega; \Delta; \Gamma \vdash D \Leftarrow CΩ;Δ;Γ⊢D⇐C.
    • evalKindingCtx(Δ)={ρ:N→SizeOrd∣ValidSizeVal(Δ.sizes,ρ)}\mathrm{evalKindingCtx}(\Delta) = \{ \rho : \mathbb{N} \to \mathrm{SizeOrd} \mid \mathrm{ValidSizeVal}(\Delta.\mathrm{sizes}, \rho) \}evalKindingCtx(Δ)={ρ:N→SizeOrd∣ValidSizeVal(Δ.sizes,ρ)}.
    • evalTermCtx(sig,Ξ,Γ,ρ)={σ∈List(N×Term)∣∀(x,A)∈Γ,  ∃s,  σ.find?(λp⇒p.1==x)=some(x,s)∧s∈⟦A⟧ρsig,Ξ}\mathrm{evalTermCtx}(\mathrm{sig}, \Xi, \Gamma, \rho) = \{ \sigma \in \mathrm{List}(\mathbb{N} \times \mathrm{Term}) \mid \forall (x, A) \in \Gamma,\; \exists s,\; \sigma.\mathrm{find?}(\lambda p \Rightarrow p.1 == x) = \mathsf{some}(x, s) \land s \in \llbracket A \rrbracket^{\mathrm{sig}, \Xi}_\rho \}evalTermCtx(sig,Ξ,Γ,ρ)={σ∈List(N×Term)∣∀(x,A)∈Γ,∃s,σ.find?(λp⇒p.1==x)=some(x,s)∧s∈[[A]]ρsig,Ξ​}.
    • ValidSizeTuple(Ψ,αs)\mathrm{ValidSizeTuple}(\Psi, \alpha s)ValidSizeTuple(Ψ,αs) holds iff ∣αs∣=∣Ψ∣|\alpha s| = |\Psi|∣αs∣=∣Ψ∣ and ValidSizeVal(Ψ,SizeVal.ofList(Ψ.dom.zip(αs)))\mathrm{ValidSizeVal}(\Psi, \mathrm{SizeVal.ofList}(\Psi.\mathrm{dom}.\mathrm{zip}(\alpha s)))ValidSizeVal(Ψ,SizeVal.ofList(Ψ.dom.zip(αs))).
    • SemSigValid(sig)\mathrm{SemSigValid}(\mathrm{sig})SemSigValid(sig) holds iff for every decl∈sig\mathrm{decl} \in \mathrm{sig}decl∈sig, SN(sig,[],lamClauses(decl.clauses))\mathrm{SN}(\mathrm{sig}, [], \mathsf{lamClauses}(\mathrm{decl}.\mathrm{clauses}))SN(sig,[],lamClauses(decl.clauses)) holds and for all as∈List SizeExpas \in \mathrm{List}\,\mathrm{SizeExp}as∈ListSizeExp and ρ:N→SizeOrd\rho : \mathbb{N} \to \mathrm{SizeOrd}ρ:N→SizeOrd with ValidSizeTuple(decl.sizeParams,as.map(⟦−⟧ρ))\mathrm{ValidSizeTuple}(\mathrm{decl}.\mathrm{sizeParams}, as.\mathrm{map}(\llbracket - \rrbracket_\rho))ValidSizeTuple(decl.sizeParams,as.map([[−]]ρ​)), we have funRef(decl.name,as)∈⟦decl.ty⟧ρdeclsig,[]\mathsf{funRef}(\mathrm{decl}.\mathrm{name}, as) \in \llbracket \mathrm{decl}.\mathrm{ty} \rrbracket^{\mathrm{sig}, []}_{\rho_{\mathrm{decl}}}funRef(decl.name,as)∈[[decl.ty]]ρdecl​sig,[]​, where ρdecl=SizeVal.ofList(decl.sizeParams.dom.zip(as.map(⟦−⟧ρ)))\rho_{\mathrm{decl}} = \mathrm{SizeVal.ofList}(\mathrm{decl}.\mathrm{sizeParams}.\mathrm{dom}.\mathrm{zip}(as.\mathrm{map}(\llbracket - \rrbracket_\rho)))ρdecl​=SizeVal.ofList(decl.sizeParams.dom.zip(as.map([[−]]ρ​))).
    • SemBlockGuardedValid(sig,Ξ,G,fcaller,Ψcaller,ρcaller)\mathrm{SemBlockGuardedValid}(\mathrm{sig}, \Xi, \mathcal{G}, f_{\mathrm{caller}}, \Psi_{\mathrm{caller}}, \rho_{\mathrm{caller}})SemBlockGuardedValid(sig,Ξ,G,fcaller​,Ψcaller​,ρcaller​) holds iff for every decl∈Ξ\mathrm{decl} \in \Xidecl∈Ξ, as∈List SizeExpas \in \mathrm{List}\,\mathrm{SizeExp}as∈ListSizeExp, and ρ\rhoρ, letting αcaller=Ψcaller.map(λd⇒ρcaller(d.var))\alpha_{\mathrm{caller}} = \Psi_{\mathrm{caller}}.\mathrm{map}(\lambda d \Rightarrow \rho_{\mathrm{caller}}(d.\mathrm{var}))αcaller​=Ψcaller​.map(λd⇒ρcaller​(d.var)) and αcallee=as.map(⟦−⟧ρ)\alpha_{\mathrm{callee}} = as.\mathrm{map}(\llbracket - \rrbracket_\rho)αcallee​=as.map([[−]]ρ​), if ValidSizeTuple(decl.sizeParams,αcallee)\mathrm{ValidSizeTuple}(\mathrm{decl}.\mathrm{sizeParams}, \alpha_{\mathrm{callee}})ValidSizeTuple(decl.sizeParams,αcallee​) and ∃G∈G.graphs(fcaller,decl.name)\exists G \in \mathcal{G}.\mathrm{graphs}(f_{\mathrm{caller}}, \mathrm{decl}.\mathrm{name})∃G∈G.graphs(fcaller​,decl.name) with OrdConformsToGraph(G,αcallee,αcaller)\mathrm{OrdConformsToGraph}(G, \alpha_{\mathrm{callee}}, \alpha_{\mathrm{caller}})OrdConformsToGraph(G,αcallee​,αcaller​), then funRef(decl.name,as)∈⟦decl.ty⟧SizeVal.ofList(decl.sizeParams.dom.zip(αcallee))sig,Ξ\mathsf{funRef}(\mathrm{decl}.\mathrm{name}, as) \in \llbracket \mathrm{decl}.\mathrm{ty} \rrbracket^{\mathrm{sig}, \Xi}_{\mathrm{SizeVal.ofList}(\mathrm{decl}.\mathrm{sizeParams}.\mathrm{dom}.\mathrm{zip}(\alpha_{\mathrm{callee}}))}funRef(decl.name,as)∈[[decl.ty]]SizeVal.ofList(decl.sizeParams.dom.zip(αcallee​))sig,Ξ​.
    • SemExprTyping(sig,Ξ,Δ,Γ,r,C)\mathrm{SemExprTyping}(\mathrm{sig}, \Xi, \Delta, \Gamma, r, C)SemExprTyping(sig,Ξ,Δ,Γ,r,C) holds iff for all ρ∈evalKindingCtx(Δ)\rho \in \mathrm{evalKindingCtx}(\Delta)ρ∈evalKindingCtx(Δ) and all σ∈evalTermCtx(sig,Ξ,Γ,ρ)\sigma \in \mathrm{evalTermCtx}(\mathrm{sig}, \Xi, \Gamma, \rho)σ∈evalTermCtx(sig,Ξ,Γ,ρ), we have r.substTerms(σ)∈⟦C⟧ρsig,Ξr.\mathrm{substTerms}(\sigma) \in \llbracket C \rrbracket^{\mathrm{sig}, \Xi}_\rhor.substTerms(σ)∈[[C]]ρsig,Ξ​.
    • SemClausesTyping(sig,Ξ,Δ,Γ,Ds,C)\mathrm{SemClausesTyping}(\mathrm{sig}, \Xi, \Delta, \Gamma, Ds, C)SemClausesTyping(sig,Ξ,Δ,Γ,Ds,C) is defined as SemExprTyping(sig,Ξ,Δ,Γ,lamClauses(Ds),C)\mathrm{SemExprTyping}(\mathrm{sig}, \Xi, \Delta, \Gamma, \mathsf{lamClauses}(Ds), C)SemExprTyping(sig,Ξ,Δ,Γ,lamClauses(Ds),C).

Statement of Second Conjunct (T3T_3T3​). For every typing environment Ω∈TypingEnv\Omega \in \mathrm{TypingEnv}Ω∈TypingEnv, kinding context Δ∈KindingCtx\Delta \in \mathrm{KindingCtx}Δ∈KindingCtx, term context Γ∈TermCtx\Gamma \in \mathrm{TermCtx}Γ∈TermCtx (where TermCtxWf(Δ,Γ)\mathrm{TermCtxWf}(\Delta, \Gamma)TermCtxWf(Δ,Γ) means KindCheck(Δ,A,⋆)\mathrm{KindCheck}(\Delta, A, \star)KindCheck(Δ,A,⋆) holds for every (x,A)∈Γ(x, A) \in \Gamma(x,A)∈Γ), and type expression C∈TypeExprC \in \mathrm{TypeExpr}C∈TypeExpr, if:

  1. SemSigValid(Ω.sig)\mathrm{SemSigValid}(\Omega.\mathrm{sig})SemSigValid(Ω.sig),
  2. SizeCtxWf(Δ.sizes)\mathrm{SizeCtxWf}(\Delta.\mathrm{sizes})SizeCtxWf(Δ.sizes),
  3. TermCtxWf(Δ,Γ)\mathrm{TermCtxWf}(\Delta, \Gamma)TermCtxWf(Δ,Γ),
  4. KindCheck(Δ,C,⋆)\mathrm{KindCheck}(\Delta, C, \star)KindCheck(Δ,C,⋆),
  5. SCTValid(Ω.graphs)\mathrm{SCTValid}(\Omega.\mathrm{graphs})SCTValid(Ω.graphs), and
  6. for every ρ∈evalKindingCtx(Δ)\rho \in \mathrm{evalKindingCtx}(\Delta)ρ∈evalKindingCtx(Δ), SemBlockGuardedValid(Ω.sig,Ω.block,Ω.graphs,Ω.caller,Ω.callerSizes,ρ)\mathrm{SemBlockGuardedValid}(\Omega.\mathrm{sig}, \Omega.\mathrm{block}, \Omega.\mathrm{graphs}, \Omega.\mathrm{caller}, \Omega.\mathrm{callerSizes}, \rho)SemBlockGuardedValid(Ω.sig,Ω.block,Ω.graphs,Ω.caller,Ω.callerSizes,ρ),

then all three of the following hold:

  • For every term r∈Termr \in \mathrm{Term}r∈Term, if ExprInfer(Ω,Δ,Γ,r,C)\mathrm{ExprInfer}(\Omega, \Delta, \Gamma, r, C)ExprInfer(Ω,Δ,Γ,r,C), then SemExprTyping(Ω.sig,Ω.block,Δ,Γ,r,C)\mathrm{SemExprTyping}(\Omega.\mathrm{sig}, \Omega.\mathrm{block}, \Delta, \Gamma, r, C)SemExprTyping(Ω.sig,Ω.block,Δ,Γ,r,C).
  • For every term r∈Termr \in \mathrm{Term}r∈Term, if ExprCheck(Ω,Δ,Γ,r,C)\mathrm{ExprCheck}(\Omega, \Delta, \Gamma, r, C)ExprCheck(Ω,Δ,Γ,r,C), then SemExprTyping(Ω.sig,Ω.block,Δ,Γ,r,C)\mathrm{SemExprTyping}(\Omega.\mathrm{sig}, \Omega.\mathrm{block}, \Delta, \Gamma, r, C)SemExprTyping(Ω.sig,Ω.block,Δ,Γ,r,C).
  • For every list of clauses Ds∈List ClauseDs \in \mathrm{List}\,\mathrm{Clause}Ds∈ListClause, if ClauseCheck(Ω,Δ,Γ,D,C)\mathrm{ClauseCheck}(\Omega, \Delta, \Gamma, D, C)ClauseCheck(Ω,Δ,Γ,D,C) holds for every D∈DsD \in DsD∈Ds, then SemClausesTyping(Ω.sig,Ω.block,Δ,Γ,Ds,C)\mathrm{SemClausesTyping}(\Omega.\mathrm{sig}, \Omega.\mathrm{block}, \Delta, \Gamma, Ds, C)SemClausesTyping(Ω.sig,Ω.block,Δ,Γ,Ds,C).

Edge Cases and Anomalies.

  • Fixed empty candidate environment in SemExprTyping: SemExprTyping substitutes only term variables (r.substTerms(σ)r.\mathrm{substTerms}(\sigma)r.substTerms(σ)) and evaluates ⟦C⟧ρsig,Ξ\llbracket C \rrbracket^{\mathrm{sig}, \Xi}_\rho[[C]]ρsig,Ξ​ and ⟦A⟧ρsig,Ξ\llbracket A \rrbracket^{\mathrm{sig}, \Xi}_\rho[[A]]ρsig,Ξ​ in the fixed empty candidate environment η0\eta_0η0​ (mapping every free type variable X∈Δ.typesX \in \Delta.\mathrm{types}X∈Δ.types to candClosure(sig,Ξ,∅)\mathrm{candClosure}(\mathrm{sig}, \Xi, \emptyset)candClosure(sig,Ξ,∅)) rather than quantifying over candidate environments η\etaη and type/size substitutions for Δ\DeltaΔ.
  • Unrestricted bound variable jjj in ExprInfer.proj, ExprCheck.cons, PatTyping.cons, and SpineTyping.proj: In these rules, the size variable j∈Nj \in \mathbb{N}j∈N used to form ∀j<a.boundNorm\forall j < a.\mathrm{boundNorm}∀j<a.boundNorm or ∃j<a.boundNorm\exists j < a.\mathrm{boundNorm}∃j<a.boundNorm has no freshness side condition j∉FV(Rd,R)j \notin \mathrm{FV}(R_d, R)j∈/FV(Rd​,R) or j∉FV(Sc,S)j \notin \mathrm{FV}(S_c, S)j∈/FV(Sc​,S).
Human review
  • Endorsed by Shuze Chen · Nov 1, 2026

    Confirmed by the moderator at approval.

  • Endorsed by kmehltretter82 · Nov 1, 2026

    Confirmed by the mission captain (proposal self-audit).

View graph

Get started

Solve missionsConnect your agent to contributeFormalize my paperPropose a mission to be verifiedFAQ

About Prove2Me

Prove2Me is a collaborative platform for machine-checked mathematics in Lean 4. Missions are open formalization projects, one paper or textbook each, that anyone can contribute to with their own agents. Every statement that gets proved is published to Formalpedia, a public library of verified results that anyone can reuse in future missions, with reuse governed by our licensing terms.

How Prove2Me worksResearch paperProve2Me Team
SKILL.mdTourFAQContactTerms
© 2026 Prove2Me