Skip to content

v0.14.0

Choose a tag to compare

@rbeauchamp rbeauchamp released this 21 Nov 20:41
· 26 commits to main since this release
Immutable release. Only release title and notes can be modified.
v0.14.0
f9cfcdb

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 lint

BREAKING CHANGE — upgrading from v0.13.0.

  • Change rev to "v0.14.0" and run lake update regula. For the full verdict, build a clone of the tag v0.14.0.
  • RG1013 (module files): Every claimed Lean file must be a module file (start with module, using public section, @[expose], or import all where other files unfold bodies). The files that lake new generates at Lean v4.35.0 have no module header and fail RG1013 until migrated. Lean refuses a module file that imports a non-module file, so dependencies imported by claimed modules must also be module files (Mathlib.lean and each file below Mathlib/ at Mathlib's tag v4.35.0 were measured as module files).
  • Additional new refusals: Projects that v0.13.0 passed can now get findings or incomplete from 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 claimed def/opaque values), and RG1006's Lean.Order.fix (partial_fixpoint) clause on claimed def/opaque values.
  • Diagnostic output format: Each finding of a registered rule keeps its primary line (RGxxxx <subject>: <reason>) unchanged and adds one 2-space-indented fix: ... 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 --wfail and lake lint on 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 a module file (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 (global or scoped) @[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) or Lean.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, noncomputable definitions, and RG1006-exempted constants added by build-time code stay outside it). lake build --wfail is Lake's own command and the replay is Lean's own Kernel.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 PROFILE in a checkout of Regula built apart from the project (git clone --branch v0.14.0 https://github.com/rbeauchamp/regula, then lake build lint in 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 no require in lakefile.toml and 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 commit eb6cafb7290e8bd5f2937522d8d804f58f02bafc, with lake and lean that toolchain's programs.
  • For the proof verdict, lake lint from the project's own directory, with no option of Lake's and REGULA_FULL unset. For the full verdict, REGULA_FULL=DIR lake exe lint PROFILE from 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_exact to rg1006_exact, rg1011_exact to rg1013_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-indented fix: ... 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 with decision (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 (admitting initialize opaque constants and bare startup hooks), and exported (global or scoped) @[csimp] entries registered in a claimed module whose theorem is not declared in any claimed module's moduleData (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 as incomplete (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 ! (covering xs[i]!, Option.get!, List.head!, String.toNat!, Array.back!, Array.set!, panic!, unreachable!, and assert!). Theorems, xs[i]?, and dbg_trace are not refused.
  • RG1013 — module files (Breaking; #559): Refuses claimed modules whose .olean does not record them as module files, under both verdicts.
  • RG1006 — partial_fixpoint / Lean.Order.fix (#577): Refuses claimed definitions and opaque constants whose values directly mention Lean.Order.fix, leaving theorems (such as realized dependency .eq_def lemmas) and Lean.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.0 remediation line ( fix: ...) directly beneath the primary finding line, enforced intrinsically by Regula.Closed.Guidance and proved safe against verdict-line forgery.
  • Standalone Lean 4 engineering standard and documentation (#546, #572, #574): Adds STANDARD.md covering 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; sharpens README.md for engineers using Lean 4 with coding agents; and documents the noncomputable enforcement boundary (including the macOS arm64 noncomputable def main / libLeanExport.a linking observation) after the owner decided to add no rule or profile for noncomputable.

Architecture, performance, proofs, and repository infrastructure

  • Modular rule registry (#550): Each rule lives in an isolated module pair (lean/Regula/Rules/RGnnnn.lean and specification/RegulaSpecification/Rules/RGnnnn.lean) with one registry per package proved equal (registry_rules).
  • Single-pass tables and linear hot paths (#573): Builds Tables once 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 Reader phases in an intrinsic Stage type, and shrinks the reader and loader proof surface without weakening any theorem statement.
  • Specification module migration and config-copy removal (#557, #558, #562): Migrates all specification/ files to module files (updating lean-intent to 3db11da) unfolding checker bodies via import all, and removes the unverified copy of the root lakefile.toml key list from the specification.
  • GitHub gate CI workflow (#555, #556): Adds .github/workflows/gate.yml running lean --run lean/Regula/DiagnosticsGate.lean local on ubuntu-24.04, installing Lean by the SHA-256 digest of its release archive without elan.

Full Changelog: v0.13.0...v0.14.0