Task #178: merge t178 — why Aeneas got ~4x slower: uses_go's && chain and OCaml 5.5's minor GC Analysis only: DESIGN.md `### Task #178` added; no code, script or proof changed, so the gates were not run (doc-only, per CLAUDE.md). Method: Aeneas run alone on saved .llbc files with extract.sh's flags plus -diagnose-translation, which reports wall time per function. Every run went through flock _tmp/aeneas.lock, with timeout 1200, time -v and perf stat. The old toolchain was rebuilt with nix from the flake at 20d34c2b^ (Aeneas 557eff83, OCaml 5.2.1). The pre-loops crate is 8b088905. Each run was done once, on a shared machine with load between 17 and 100, so wall times are noisy. The 2x2 (wall time; the second figure is uses_go's own time): - Aeneas 557eff83, crate before #158: 210 s; uses_go 163 s. - Aeneas 557eff83, crate now: 240 s; uses_go 180 s. One cheap function, kahn, is unsupported by this Aeneas and was skipped. - Aeneas 1dc8ad31, crate before #158: 400 s; uses_go 340 s. - Aeneas 1dc8ad31, crate now: 485 s, 32.3 GB peak; uses_go 409 s. So #162 doubles the time, and the loops of #158–#169 add only 15–20 %. Cause 1: frontend::olean::lazy::uses_go (added by #143 on Nov 6, after the 93 s baseline). It sets the wall time under both Aeneas versions: it alone runs 75–85 % of the whole run. Its 10-arm `else if t == K && n == M` dispatch is the problem. Charon's control-flow reconstruction copies the shared "false" target of each `&&` into both branches, so the LLBC doubles per arm. Result: uses_go_loop is 12 071 of Funs.lean's 139 613 lines; the next largest function has 831. Testing one condition per `if` instead (nested, same function) brings it to 210 lines. Cause 2: commit 1d323d1c inside #162's range (OCaml 5.2.1 → 5.5.1, no translation change). On one .llbc it goes from 245 s / 25.6 T instructions to 503 s / 81.5 T. The 96 domains spend the time synchronising for minor collections. A larger minor heap fixes it, and the output is byte-identical to the committed Funs.lean: - crate now, OCAMLRUNPARAM=s=2M: 485 → 276 s. - nested uses_go plus s=2M: 79 s, 5.3 T instructions, 19.8 GB peak (vs 485 s, 63.9 T, 32.3 GB today). Proposed, not applied: 1. extract.sh: run Aeneas with OCAMLRUNPARAM=s=2M (one line, no proof impact). 2. uses_go: the nested dispatch. uses_go_loop_ok already splits on the tag and then on the field count. 3. Upstream drafts, not filed, in _tmp/corpus/aeneas-slow/ISSUE.md: one for Charon (the exponential copying of `&&` chains), one for Aeneas (OCaml 5.5, minor heap / pool size). The reproducer (gen.py, repro.sh, repro-out.txt) is in the same directory. Left: _tmp/t178/ (about 2.5 GB of .llbc files and the run logs) can be deleted. 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.