Task #180: merge t180 — Aeneas 420 → 78 s: a 2 M-word minor heap, uses_go's dispatch nested
What changed
* scripts/extract.sh runs Aeneas with OCAMLRUNPARAM="s=2M${OCAMLRUNPARAM:+,$OCAMLRUNPARAM}"
(a caller's own setting is appended, so it still wins), with the reason in a comment
citing #178/#180. CI gets it: ci.yml -> scripts/gates.sh -> extract.sh --check.
Not in the green stamp's key: GC parameters do not change Aeneas's output (byte-identical,
checked again), and the line itself is keyed because the script is hashed.
* crates/con-ron-core/src/frontend/olean/lazy.rs uses_go: the ten-arm `t == K && n == M`
else-if chain is now nested tests (tag, then field count), with a `//` comment saying why.
The doc comment and the con-leche citation are unchanged and still correct. Regenerated
in the same commit: Funs.lean 139 613 -> 127 756 lines, uses_go_loop 12 071 -> 214.
* match (t, n) was measured too: 186 lines, 127 728 total, 111 s / 79 s (default / s=2M),
which is the same as nested. Aeneas emits it as `match t with | 0#uscalar => ...`, and
the Theorem 2 proof is written for `if`s, so I kept the nested form. (I did not try the
match form against the proof.)
* Twin (Arena/Frontend/Olean/Lazy.lean usesGo) mirrors con-leche's match: unchanged.
Theorem 2 (Refine2/Frontend/Olean/Lazy.lean uses_go_loop_ok): same case split. The kid
arms now peel the inner field-count computation first. The constant and literal arms
add Aeneas.Std.bind_assoc / bind_ok to their simp. Theorem 1 does not mention uses_go.
* Other `} else if ... && ...` chains in con-ron-core: 21 arms in 18 functions, at most 3
per function. The largest generated is display_letter_like at 265 lines, and none is
near the 2 000-line bar, so none were rewritten. They are listed with sizes in DESIGN.
Measured (Aeneas alone, one run each, 96 cores shared, load 12-59, so wall times are
indicative only)
master, default 420 s 18.5 GB
master, s=2M 274 s 36.3 GB (output identical)
nested, default 109 s 18.4 GB
nested, s=2M 78 s 20.1 GB (what lands; extract.sh write run: 87 s total)
match, default 111 s 18.4 GB
match, s=2M 79 s 21.4 GB
Init instructions:u (release con-ron): 165 595 838 947 before, 165 595 458 503 after
(-0.0002 %). The checker's work is unchanged.
Note: s=2M on the unfixed crate peaked at 36 GB. With the fix it is ~20 GB.
Gates: LAKE_JOBS=4 scripts/gates.sh, all 16 steps OK (lake-build 385 s). extract-check
was skipped on the green stamp my extract.sh write run had written for this tree. Master
did not move, so no merge was needed.
Left: the §3.4 style rule "one condition per `if` in an else-if chain" (from #178) is only
in the #178/#180 task sections and is not lint-enforced. The upstream drafts in
_tmp/corpus/aeneas-slow/ are still unfiled, as asked. Scratch: _tmp/t180/ (~2 GB of
.llbc) can go.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01WD3k8haktuYLxJTGDzTuAq
This is the external Lean checker con-leche, ported to Rust very closely.
This was written by AI under supervision from Joachim Breitner at the Lean FRO. This README is genuinely human written; the rest of the repository is not. The file OVERVIEW.md contains a much more detailed, AI written exposition of the project.
The point of this exercise is that with con-leche having a formal consistency proof, any remaining unsoundness bugs are most likely found in Lean’s compiler or runtime (including the bignum library used). Such a bug will very unlikely exist in the Rust compiler or runtime at the same time, so by checking a proof with both con-leche and con-ron, you gain a high level of protection against that class of bugs.
It is also a goal of con-ron to have good performance; verified code should not be slower than unverified.
A previous version of con-ron translated the Lean code of con-leche very closely. This worked, but led to unsatisfying performance, because con-leche uses data structures that worked well on Lean but poorly in Rust.
Therefore, con-ron now deviates from con-leche in term representation and its approach to caching and memoization, while still sticking close to con-leche's algorithm.
To that end, con-ron implements a twin of con-leche's pure checking algorithm, still in Lean, but using data structures that closely match what we want to use in the Rust implementation. This twin is proven to be (partially) correct wrt the pure implementation by a simulation (Theorem 1). The Rust implementation is then proven (partially) correct to the twin by Theorem 2, via the Aeneas-generated model. Theorem 1 has a sibling in con-leche, where the pure checker is related to the actual caching implementation. Theorem 2 is kept as mechanical as possible (and our bespoke lockstep tactic automates much of it).
In the end we can compose all these to the end-to-end main consistency theorem main_json_model and main corollary main_no_False, together with the other main theorems in MainTheorem.lean: con-leche‘s main theorems, word for word, about con-ron’s binary.
As in con-leche, the theorems cover the driver too (parsing the arguments, reading the files, the modes): it is written once against a trait modelling the IO, and the theorems are about a model of how the IO could behave, under certain resonable assumptions; more details in the OVERVIEW.
This is not a high assurance verification effort, given the reliance on Aeneas as a Rust-to-Lean translator. The goal is to make it very plausible that the Rust implementation follows the Lean implementation very closely.
Like nanoda, we cons-hash expressions and put them into one big data structure (the DAG), with two tiers (a persistent one and a scratch tier for the per-declaration intermediates) and an EIdx (a u32) pointing into that data structure, with one bit indicating which tier to use.
To further refine this approach, our DAG does not store an enum ExprView. Rust sizes enums by the largest member, which is wasteful when most nodes are Expr.app. Instead, we have one array per constructor, with just the fields stored there, and the EIdx reserves four bits to indicate which constructor this is. This leads to very compact, uniform arrays and some operations (e.g. is_app) can be resolved without dereferencing. Names, levels and level lists are also hash-consed.
After the rewrite to use better data structures, performance of con-ron is rather good, often better than with con-leche or nanoda.
Unsolicited PRs against this repo are unlikely to be useful; well-written issues with bug reports or feature requests are welcome.