You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
--verdict: the kernel runs out of fuel on conversion_shared_cells_once.bend, which bend2 checks by sharing (2.0.34) #1193
cd tests/check
bun ../../bend2/main.ts conversion_shared_cells_once.bend --verdict
On main (eb8f58b1, Bend 2.0.34).
What happened
bend2 checks the file, but the kernel rejects it:
$ bun ../../bend2/main.ts conversion_shared_cells_once.bend --check-only
ALL PROOFS CHECK
Use --verdict for mathematical validity.
$ bun ../../bend2/main.ts conversion_shared_cells_once.bend --verdict
SOME PROOFS FAIL
Sorry - this is a mismatch between the TypeScript implementation, and the formalized BendTT kernel. ...
Running the kernel directly on the emitted book (9.8 KB) shows why:
$ bun ../../bend2/main.ts conversion_shared_cells_once.bend -o csc.bendtt
$ ~/.bend/bendtt/<hash>/bendtt csc.bendtt
SOME PROOFS FAIL
In agree_32:
out of fuel
It takes about 7 s to give up.
The test came in with 2.0.34 (#1071, PR #1151, 7d8a3eb0), which made bend2's conversion compare a shared graph once. As the test's own comment says, each of the 32 levels of both roots uses the level below twice, so comparing them as a tree takes about 2^32 steps. bend2 now avoids that blowup; the kernel in bend2/bendtt.lean doesn't, so it runs out of fuel on agree_32.
This wasn't caught because the normal gates don't run --verdict: gates/test.ts checks each test with --checkup, and gates/_run.ts runs repo, test, perf and ping. Only gates/safe.ts tests runs the kernel over the corpus. In a local --verdict sweep of all 1,522 files in tests/, this is the only kernel mismatch.
Expected
Either the kernel's conversion shares equal subterms the way bend2's now does (so agree_32 checks within its fuel), or the mismatch is recorded as a known limit of the kernel. Sharing in the kernel means bendtt.lean's proofs have to cover it.
Timings on main (e78dc9c), with the kernel built from bend2/bendtt.lean:
agree_16: ALL PROOFS CHECK in 0.6 s
agree_20, agree_24, agree_32: out of fuel after about 7 s, reported as a mismatch
This was the only ! (false reject) that gates/safe.ts found in tests (1635 files). Since #1556 makes the safe gate exit 1 on !, it cut conversion_shared_cells_once.bend from 32 levels to 16. The test can go back to 32 once the kernel compares shared cells once. (#1555 was a duplicate of this issue and is now closed.)
#1593 by @GunnarZarncke has the same cause and has been closed as a duplicate of this issue. Here's what it adds:
A smaller repro (kernel_copy_shared.bend). Each step of run and dbl uses the previous value twice. bend shares that value, so its check time stays flat as n grows. The kernel copies it at every use, so its cost doubles with each level:
A real-world case. He hit this while proving an ARM64 trap handler correct by running its machine code symbolically, where each state reads the previous one. Written the obvious way, the kernel got 5 steps in before it used 13 GB. The 80-step paths had to be cut into 154 segments of at most 8 steps, joined by a composition lemma, and the full kernel check took about 7 minutes (demos/hypervisor/SPEC.md §14, on the hypervisor branch of his fork).
Two possible fixes:
the kernel evaluates a copied argument once and reuses it, or
bend warns when a definition's unshared size would go over the kernel's fuel. Today nothing warns until --verdict runs.
Activity
test(bend): use exact upstream kernel-gap discriminator
Lorenzobattistela commentedon Oct 14, 2026
Timings on main (e78dc9c), with the kernel built from
bend2/bendtt.lean:agree_16: ALL PROOFS CHECK in 0.6 sagree_20,agree_24,agree_32: out of fuel after about 7 s, reported as a mismatchThis was the only
!(false reject) thatgates/safe.tsfound intests(1635 files). Since #1556 makes the safe gate exit 1 on!, it cutconversion_shared_cells_once.bendfrom 32 levels to 16. The test can go back to 32 once the kernel compares shared cells once. (#1555 was a duplicate of this issue and is now closed.)Lorenzobattistela commentedon Oct 16, 2026
#1593 by @GunnarZarncke has the same cause and has been closed as a duplicate of this issue. Here's what it adds:
A smaller repro (
kernel_copy_shared.bend). Each step ofrunanddbluses the previous value twice. bend shares that value, so its check time stays flat as n grows. The kernel copies it at every use, so its cost doubles with each level:A regression test on main...GunnarZarncke:bend:kernel-copies-unshared. It passes
gates/test.ts(it prints its#|line on every lane), andgates/safe.tsshould classify it as a false reject.A real-world case. He hit this while proving an ARM64 trap handler correct by running its machine code symbolically, where each state reads the previous one. Written the obvious way, the kernel got 5 steps in before it used 13 GB. The 80-step paths had to be cut into 154 segments of at most 8 steps, joined by a composition lemma, and the full kernel check took about 7 minutes (
demos/hypervisor/SPEC.md§14, on thehypervisorbranch of his fork).Two possible fixes:
--verdictruns.Since
--verdictreports a kernel "out of fuel" as a TypeScript/kernel mismatch, without the def or the reason (2.0.36) #1535, the "out of fuel" reason is shown, but the "Sorry - this is a mismatch…" text is still printed after it.For reference, #1556 cut
agree_32to 16 levels as a workaround, and #1555 tracks restoring it.wi001 commentedon Oct 24, 2026
Another case, still on 2.0.39: the kernel runs out of fuel when a lemma's type
contains a large computation, which
bendaccepts.Reproduce: in
busy_beaver/bb2.bendof https://github.com/wi001/bend2-trials,change
check2toA.check(TM.machine2(a0, a1, b0, b1), 6n, 1n, 100n)(dropthe
match u) and runbend PROOF.bend --verdict. It fails inbb2_elim.elim_a0.w.Workaround: start
check2with a match on a variableu, so the checks inlemma types stay unevaluated.