Main Soundness Theorem: Type Safety and Strong Normalization of Algorithm 2 (Theorem 15)
DisprovedNishtAbel2024.theorem_15Theorem 15 (Section 6.5, p. 59): For any semantically valid global signature sig (SemSigValid sig) and any unannotated System F_ω^c mutual block Ξ accepted by Algorithm 2 (Algorithm2Accepts sig Ξ Ξannot), the resulting size-annotated mutual block Ξannot is well-typed in System F_ω^{cop, SCT} (MutualBlockTyping sig Ξannot) and semantically valid / strongly normalizing (SemMutualBlockValid sig Ξannot).
Superseded. This is the first formalization of Theorem 15 (p. 59) of the
thesis. It is refuted by the accepted disproof
9195b5f7-de63-4b2b-bba7-b74cad323453: an existing global function returns a
function that is only added later, in the new block, and the new function returns
the existing one. Algorithm 2 accepts the new block, since it contains no
recursive call within the block, yet the two functions reduce to each other
forever. The formal statement lets the existing signature refer to functions
defined after it, which the thesis's scope discipline excludes, so the
counterexample does not refute Theorem 15 as stated in the thesis. Corrected
statement: NishtAbel2024V2.theorem_15. It assumes a well-scoped block extension
(scopeBlockExtension) and Algorithm 2 extended with a final type check of each
size-annotated clause (PostcheckedAlgorithm2Accepts).
import Definitions.Def_NishtAbel2024_Syntax import Definitions.Def_NishtAbel2024_Semantics import Definitions.Def_NishtAbel2024_Inference
namespace NishtAbel2024
/-- Theorem 15 (Soundness of termination checking, Section 6.5, p. 59):
If `⊨ Σ` (`SemSigValid sig`) and Algorithm 2 accepts a mutually recursive block `Ξ`
(`Algorithm2Accepts sig Ξ Ξannot`), then the size-annotated block `Ξannot` is well-typed in
System `F_ω^{cop, SCT}` (`MutualBlockTyping sig Ξannot`) and is semantically sound / strongly
normalizing (`SemMutualBlockValid sig Ξannot`). -/
theorem theorem_15
(sig : GlobalSig) (Ξ Ξannot : MutualBlock)
(hsig : SemSigValid sig)
(hacc : Algorithm2Accepts sig Ξ Ξannot) :
MutualBlockTyping sig Ξannot ∧ SemMutualBlockValid sig Ξannot := by
sorry
end NishtAbel2024Read-back
What the Lean code literally says, in plain math · Gemini 3.1 Pro (Independent Blind Auditor)
Independent Mathematical Read-Back: Thm_NishtAbel2024_theorem_15.lean
The theorem theorem_15 asserts that for any global signature sig (List FunDecl) and any unannotated and annotated mutual blocks (List FunDecl), if sig is semantically valid (hsig : SemSigValid sig) and Algorithm 2 accepts producing (hacc : Algorithm2Accepts sig Ξ Ξannot), then is both syntactically well-typed (MutualBlockTyping sig Ξannot) and semantically valid (SemMutualBlockValid sig Ξannot).
Unfolded hypotheses:
-
Semantic validity of the global signature (
SemSigValid sig): For every function declaration :- The clause-lambda term
.lamClauses decl.clausesis strongly normalizing (SN sig []) under the contextual reduction relationRedStep sig []generated by weak-head reductionWhdStep sig [](which strips type ascriptions and fires /copattern-matching rules for.lamClausesand for function references.funRef g aswith along elimination spines viaMatchSpine). - For every list of size expressions
asand every ordinal valuation (whereSizeOrdrepresents ordinals ordered lexicographically, withevalSizeExp ρ (.inf n) = (1, n)andevalSizeExp ρ (.meet m)taking the minimum of shifted valuations), ifValidSizeTuple decl.sizeParams (as.map (evalSizeExp ρ))holds (meaning and under the valuation mapping the -th parameter variable ofdecl.sizeParamsto and other variables to , every satisfies ), then the term.funRef decl.name asbelongs to the semantic reducibility candidate interpretationevalType sig [] ρ₀ decl.ty(defined by structural recursion onTypeExprand well-founded transfinite recursion alongSizeOrd.ltfor and fixpoints using Girard/Tait reducibility candidatescandClosure).
- The clause-lambda term
-
Acceptance by Algorithm 2 (
Algorithm2Accepts sig Ξ Ξannot): There exists an invocation graph family such that:SCTValid 𝒢holds: (a) for all and , , , and ; and (b) for every and every graph in the transitive composition closureInvGraphClosure 𝒢 f f G, if , then there exists with .- For every , .
- and are in one-to-one elementwise correspondence (
List.Forall₂) such that for each paired :- ,
EncodeType .neg .pos KindingCtx.empty decl.ty decl'.sizeParams decl'.ty,SignatureFixpointHygiene (KindingCtx.empty.extSizes decl'.sizeParams) decl'.ty,SizeCtxWf decl'.sizeParams,KindCheck (KindingCtx.empty.extSizes decl'.sizeParams) decl'.ty .star, anddecl.clausesanddecl'.clausesare in one-to-one elementwise correspondence (List.Forall₂) such that for each paired , there exist a copattern spine and term with and a nonempty witness ofAlgorithm2ClauseRun sig Ξannot 𝒢 decl'.name decl'.sizeParams decl'.ty qs t D', meaning:InferSpine (KindingCtx.empty.extSizes decl'.sizeParams) qs decl'.ty C' Γ Δ' Ψ₂ qs',KindingCtxConsistentExt (KindingCtx.empty.extSizes decl'.sizeParams) Δ'(every kind in is well-formed in the -scaled size context, and every size bound in is either or for some in the extended size domain),SizeCtxWf (decl'.sizeParams ++ Ψ₂),CheckTerm sig Ξannot ((decl'.sizeParams ++ Ψ₂).map (fun d => (d.var, d.pol))) Γ ((KindingCtx.empty.extSizes decl'.sizeParams).append ⟨Ψ₂, Δ'⟩) C' t Φ Cs T t', and- letting , and
LocalCallsConform Ξannot 𝒢 decl'.name decl'.sizeParams (decl'.sizeParams ++ Ψ₂) (t'.applyFlex φstar).
Unfolded conclusion: The conjunction of:
- Target mutual-block typing (
MutualBlockTyping sig Ξannot): There exists an invocation graph family such thatSCTValid 𝒢holds, for all , and for every , setting and , we haveSizeCtxWf decl'.sizeParams,KindCheck Δ₀ decl'.ty .star, andClauseCheck Ω Δ₀ [] D' decl'.tyfor every (meaning has a derivation ofSpineTyping Δ₀ Δ' Γ' decl'.ty qs' C',KindingCtxConsistentExt Δ₀ Δ', andExprCheck Ω (Δ₀.extDecls Δ') Γ' u C'). - Semantic validity of the annotated mutual block (
SemMutualBlockValid sig Ξannot): For every :.lamClauses decl'.clausesis strongly normalizing (SN (sig ++ Ξannot) []) underRedStep (sig ++ Ξannot) [], and- for every list of size expressions
asand ordinal valuation , ifValidSizeTuple decl'.sizeParams (as.map (evalSizeExp ρ))holds, then.funRef decl'.name asbelongs toevalType (sig ++ Ξannot) [] (SizeVal.ofList (decl'.sizeParams.dom.zip (as.map (evalSizeExp ρ)))) decl'.ty.
Degenerate cases, vacuous hypotheses, and anomalies:
- Explicit target well-formedness hypotheses in
Algorithm2Accepts:Algorithm2Acceptsexplicitly includesSignatureFixpointHygiene (KindingCtx.empty.extSizes decl'.sizeParams) decl'.ty,SizeCtxWf decl'.sizeParams,KindCheck (KindingCtx.empty.extSizes decl'.sizeParams) decl'.ty .star, and (insideAlgorithm2ClauseRun)KindingCtxConsistentExt (KindingCtx.empty.extSizes Ψ₁) Δ'andSizeCtxWf (Ψ₁ ++ Ψ₂)as part of the acceptance predicate rather than deriving them solely from unannotated inputs. - Duplicate function names in : Neither
Algorithm2AcceptsnorMutualBlockTypingrequires function names in or to be distinct; inLocalCallsConform, a call.funRef g asquantifies universally over all with .
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.