Repository navigation
v0.14.0
Regula v0.14.0 reads one Lean release, leanprover/lean4:v4.35.0, and refuses any other. It is a breaking release (bumping 0.13.0 to 0.14.0 under pre-1.0 Semantic Versioning): RG1013 now refuses claimed modules whose files are not module files under both verdicts (including the files lake new generates at Lean v4.35.0), RG1011 refuses replaced compiled code and foreign claimed-module @[csimp] entries, RG1012 refuses direct panic forms in claimed definitions and opaque constants, RG1006 also refuses direct Lean.Order.fix (partial_fixpoint) mentions in claimed definitions and opaque constants, and every registered rule now emits a proved-safe, 2-space-indented fix: ... guidance line beneath each finding. All eleven checks (RG1001 to RG1006, RG1010 to RG1013, and RG2001) ship in v0.14.0, together with the standalone Lean 4 engineering standard in STANDARD.md and the noncomputable boundary documentation. The README and specification/README.md at the tag state each check and what is proved of it.
Use it. Put leanprover/lean4:v4.35.0 in lean-toolchain, and add this to lakefile.toml, with one profile in lintDriverArgs:
lintDriver = "regula/lint"
lintDriverArgs = ["standard-logical"]
[[require]]
name = "regula"
git = "https://github.com/rbeauchamp/regula"
rev = "v0.14.0"Run lake update regula, and then run these two commands in order on one build, from the project's own directory with no option of Lake's and REGULA_FULL unset:
lake build --wfail
lake lintBREAKING CHANGE — upgrading from v0.13.0.
- Change
revto"v0.14.0"and runlake update regula. For the full verdict, build a clone of the tagv0.14.0. - RG1013 (
modulefiles): Every claimed Lean file must be amodulefile (start withmodule, usingpublic section,@[expose], orimport allwhere other files unfold bodies). The files thatlake newgenerates at Leanv4.35.0have nomoduleheader and fail RG1013 until migrated. Lean refuses amodulefile that imports a non-modulefile, so dependencies imported by claimed modules must also bemodulefiles (Mathlib.leanand each file belowMathlib/at Mathlib's tagv4.35.0were measured asmodulefiles). - Additional new refusals: Projects that v0.13.0 passed can now get findings or
incompletefrom RG1011 (@[implemented_by],@[extern],@[init]/@[builtin_init]naming an initialization function on claimed definitions, exported claimed-module@[csimp]entries targeting theorems not declared in any claimed module, and loader RG2001 checks for hidden module-local entries or missing claimed module indices), RG1012 (direct panic forms in claimeddef/opaquevalues), and RG1006'sLean.Order.fix(partial_fixpoint) clause on claimeddef/opaquevalues. - Diagnostic output format: Each finding of a registered rule keeps its primary line (
RGxxxx <subject>: <reason>) unchanged and adds one 2-space-indentedfix: ...guidance line directly beneath it, escaping LF and CR. The finding count line and final verdict line are unchanged.
The two verdicts
- The proof verdict, from
lake build --wfailandlake linton one build, means that the proofs of the claimed modules are sound and use only axioms that the profile allows, that Lean read each claimed module as amodulefile (RG1013), that no claimed constant has@[implemented_by]or@[extern], no claimed definition has an initialization function by@[init]or@[builtin_init], and every exported (globalorscoped)@[csimp]entry registered in a claimed module names a theorem declared in some claimed module (RG1011, with loader checks under RG2001), that no claimed definition or opaque constant directly mentions a panic form (RG1012) orLean.Order.fix(RG1006), and that no claimed constant violates RG1001 to RG1006—for a project that places no file or code aimed at the checker or the toolchain. Beyond those checks, the proof verdict says nothing about compiled execution or whether a claimed data-valued definition has executable code (attribute [local csimp], dependency-registered@[csimp], dependency and toolchain constants,noncomputabledefinitions, and RG1006-exempted constants added by build-time code stay outside it).lake build --wfailis Lake's own command and the replay is Lean's ownKernel.Environment.replay: Regula makes no claim of its own about what they decide, and proves which constants it gives the replay. - A project that may be aimed at the checker needs the full verdict. The two commands run in the project's own Lake, so a project written to attack the checker can make them print a pass whatever its build holds, an unsound proof included, by four routes: a library loaded from the project's own library directory into the checker, a doctored copy of Regula from its configuration or package directory, a
lakefile.lean, or code that runs while it builds. The full verdict closes each of them. A project with a dependency or with Mathlib in its imports gets only the proof verdict, so Regula gives no verdict that holds of such a project if it is aimed at the checker. - The full verdict, from
REGULA_FULL=DIR lake exe lint PROFILEin a checkout of Regula built apart from the project (git clone --branch v0.14.0 https://github.com/rbeauchamp/regula, thenlake build lintin it), also means that no code written in the project ran while Lake built the files that the check read, and that no file installed anything that replaces what the compiler runs for a definition. That rests on hypotheses H1 to H5 and the rest of the list of assumptions below. No proof here can examine Lean's own program, so a route that H2 misses would be a false pass. Only a project with norequireinlakefile.tomland no Mathlib in its imports can have this verdict; for any other project the full gate builds nothing, says that only a proof verdict is possible, and exits with 3.
The last line of a run names its verdict, such as regula: proof verdict: fail, and a pass ends that line with the directory it audited.
Where the claim holds
The claim holds only for these named configurations:
- Lean
v4.35.0, at commiteb6cafb7290e8bd5f2937522d8d804f58f02bafc, withlakeandleanthat toolchain's programs. - For the proof verdict,
lake lintfrom the project's own directory, with no option of Lake's andREGULA_FULLunset. For the full verdict,REGULA_FULL=DIR lake exe lint PROFILEfrom the directory of a checkout of Regula built apart from the project, with no option of Lake's. - Two platforms, on which the operating-system assumptions were observed: macOS 27.2 on Apple silicon (arm64) and Ubuntu 24.04.5 LTS on x86-64. The 8-step local gate ran on macOS 27.2 (arm64) and on GitHub's
ubuntu-24.04(x86-64) runner at this release.
Outside the contract, and not defects: Windows, another release of macOS, another distribution, release or architecture of Linux, another Lean, starting the full gate from a project's Lake, lake -d, lake -f and every other option of Lake's, starting through lake test or lake env, and lake lint with REGULA_FULL set. Also outside: for a proof verdict, a project that places a file or code aimed at the checker or the toolchain, and what the code of a claimed module or of a dependency does while it is built; another process that changes the project, the checker's tree or a build during a run; a call that does not return, and a TMPDIR that names nothing; what a theorem means to a reader; and anything about a dependency's code.
The list of assumptions remains 18 entries (Assumption in specification/RegulaSpecification/Assumptions.lean), each with its pinned source at Lean v4.35.0: Lean holds kernel, h6, replay, compiler, h1, h2, usedConstants, leanImport, leanVersion and platform; Lake holds lakeLoad, h3, h5, lakeCommands and lakeStart; the operating system holds h4, files and processes. leanImport now also cites Lean's getInitFnNameFor?, getModuleIdx?, getModuleEntries (including Lean.Compiler.CSimp.ext.ext.getModuleEntries), and ModuleData.isModule.
What is proved
Lean checks these theorems of the specification package about the definitions that the checker runs, under the hypotheses each states:
- Each registered rule, RG1001 to RG1006 and RG1011 to RG1013, reports a subject exactly when it violates the rule over Regula's closed input (
rg1001_exacttorg1006_exact,rg1011_exacttorg1013_exact,rg1011_attributed), with the specification and checker registries proved equal (registry_rules), and linked to Lean's loaded environment (pass_iff,pass_floor,pass_held). - Every finding of a registered rule carries non-blank guidance by type (
finding_guidance_nonblank), and diagnostic serialization keeps the primary finding line unchanged while emitting one 2-space-indentedfix: ...line with LF and CR escaped (detailText_guidanceLine,say_guidanceLine_spec). - The replay receives exactly the claim's cone (
mem_cone_env,replayConstants_env), each claimed constant is in it (claimed_inCone), each claimed theorem is kept or replayed under a fresh name (claimed_theorem_replayed,copy_name_fresh), single-pass table preparation agrees withdecision(decisionPrepared_eq), and exit 0 requires replay success (plain_exit_zero,full_exit_zero). - The language check admits a project exactly when everything it reads is in the closed set (
decision_admitted_iff), every non-pass rests on the published closed list of refusals (run_meets), a run with no refusal on which the rules hold passes (plain_owed,full_owed,run_plain_owed,run_full_owed), and the specification build fails for any unlisted operation, route, premise, or toolchain version (Assumption.ofOp,run_route,meaning,readAt_pinned).
A pass does not mean that the code is correct. No checker can say that a theorem states what its author meant, so theorem statements stay the reader's to read.
Changes since v0.13.0
New and widened checks
- RG1011 — replaced compiled code (#551, #554, #578): Refuses claimed constants with
@[implemented_by]or@[extern], claimed definitions for which@[init]or@[builtin_init]names an initialization function (admittinginitializeopaque constants and bare startup hooks), and exported (globalorscoped)@[csimp]entries registered in a claimed module whose theorem is not declared in any claimed module'smoduleData(admitting exported@[csimp]on claimed theorems, including one-line claimed alias theorems). Hidden module-local replacement entries and missing claimed module indices are refused by the loader asincomplete(RG2001). - RG1012 — hidden panics (#553): Refuses claimed definitions and opaque constants whose values directly mention
panicCore,panic,panicWithPos,panicWithPosWithDecl, or a non-theorem constant whose macro-erased last string component contains!(coveringxs[i]!,Option.get!,List.head!,String.toNat!,Array.back!,Array.set!,panic!,unreachable!, andassert!). Theorems,xs[i]?, anddbg_traceare not refused. - RG1013 —
modulefiles (Breaking; #559): Refuses claimed modules whose.oleandoes not record them asmodulefiles, under both verdicts. - RG1006 —
partial_fixpoint/Lean.Order.fix(#577): Refuses claimed definitions and opaque constants whose values directly mentionLean.Order.fix, leaving theorems (such as realized dependency.eq_deflemmas) andLean.Order.lfp_monotone(inductive_fixpoint,coinductive_fixpoint,coinductive) admitted.
Actionable fix guidance and engineering standard
- Proved-safe fix guidance (#579): Every finding of all nine registered rules emits a non-blank, branch-tailored Lean
v4.35.0remediation line (fix: ...) directly beneath the primary finding line, enforced intrinsically byRegula.Closed.Guidanceand proved safe against verdict-line forgery. - Standalone Lean 4 engineering standard and documentation (#546, #572, #574): Adds
STANDARD.mdcovering intrinsic typing, spec-first design, certifying algorithms and total search, pure effects, module boundaries, and compile-time erasure / runtime gaps with an enforcement-status table; sharpensREADME.mdfor engineers using Lean 4 with coding agents; and documents thenoncomputableenforcement boundary (including the macOS arm64noncomputable def main/libLeanExport.alinking observation) after the owner decided to add no rule or profile fornoncomputable.
Architecture, performance, proofs, and repository infrastructure
- Modular rule registry (#550): Each rule lives in an isolated module pair (
lean/Regula/Rules/RGnnnn.leanandspecification/RegulaSpecification/Rules/RGnnnn.lean) with one registry per package proved equal (registry_rules). - Single-pass tables and linear hot paths (#573): Builds
Tablesonce per run (Facts.prepare,decisionPrepared) and replaces quadratic lookups (including binary search over strictly sorted language tables). - Intrinsic types, constructive proofs, and proof-surface shrinkage (#575, #576, #581): Replaces subject and path sentinels with intrinsic types and constructive proofs, carries
Readerphases in an intrinsicStagetype, and shrinks the reader and loader proof surface without weakening any theorem statement. - Specification
modulemigration and config-copy removal (#557, #558, #562): Migrates allspecification/files tomodulefiles (updatinglean-intentto3db11da) unfolding checker bodies viaimport all, and removes the unverified copy of the rootlakefile.tomlkey list from the specification. - GitHub
gateCI workflow (#555, #556): Adds.github/workflows/gate.ymlrunninglean --run lean/Regula/DiagnosticsGate.lean localonubuntu-24.04, installing Lean by the SHA-256 digest of its release archive without elan.
Full Changelog: v0.13.0...v0.14.0