Test "perf/folded-constant-first"
Expected: 👍 accept · Size: 52.0 KB · Lines: 1.3 k · lean4export: 3.1.0 · Lean: 4.29.1 · Timeout: 50.0 s · 📄 Declaration · 🔗 Source
The declaration to check compares
tagged (count #n) and (false, count #n)
where tagged m = (isZero m, m), so unfolding the left side leaves the same
application count #n in both components, forced by isZero in one and
plain in the other.
The plain occurrences are identical, for Θ(1); the forced one evaluates
count #n once. The order matters for a checker that leaves a constant
unfolded once it reduces it: reducing the forced component first replaces
count #n by its value on one side, and the plain comparison then faces a
folded application against an evaluated one. Here the forcing component
comes first; folded-constant-last.lean swaps them, and the ratio between
the two files is what that costs.
N=1000 in the Lean source. From Courant and Leroy, POPL 2026, §10, where the two orders cost Rocq 3 × 10⁻⁵ s and 0.078 s.
| Checker | Result | ⏱️ | 🧠 | |||
|---|---|---|---|---|---|---|
| mathgraph | 👍 | 3 ms | (÷16) | 48.2 MB | (-30%) | |
| sokonanoda | 👍 | 3 ms | (÷16) | 46.2 MB | (-33%) | |
| nanoclo | 👍 | 4 ms | (÷10) | 60.4 MB | (-12%) | |
| con-ron | 👍 | 32 ms | (-21%) | 70.8 MB | (+3%) | |
| lazylean | 👍 | 5 ms | (÷8.1) | 24.6 MB | (÷2.8) | |
| nanoda | 👍 | 7 ms | (÷5.8) | 4.4 MB | (÷16) | |
| nanobruijn | 👍 | 7 ms | (÷5.6) | 15.8 MB | (÷4.4) | |
| con-leche | 👍 | 21 ms | (-47%) | 32.8 MB | (÷2.1) | |
| eink0rn | 👍 | 6 ms | (÷6.8) | 17.9 MB | (÷3.9) | |
| ind-models | 👍 | 79 ms | (+94%) | 111.5 MB | (+62%) | |
| official | 👍 | 40 ms | (0%) | 68.9 MB | (0%) | |
| lean4lean | 👍 | 47 ms | (+15%) | 100.9 MB | (+46%) | |
| tenet | 👍 | 160 ms | (×3.9) | 51.4 MB | (-25%) | |
| nanoclo-fortran | 👍 | 9 ms | (÷4.5) | 8.0 MB | (÷8.6) | |
| lean4cobol | 👍 | 182 ms | (×4.5) | 27.8 MB | (÷2.5) | |
| evmlean | 🚫 | 2.3 s | 138.3 MB | |||
| mini | 💥 | 45.1 s | 90.0 MB | |||
| overfull | 💥 | 1.8 m | 48.9 MB | |||
| kiota | 👍 | 8 ms | (÷5.0) | 18.4 MB | (÷3.7) | |
| canonical-min | 🚫 | 390 ms | 1.1 GB | |||
| rpylean | 👍 | 7 ms | (÷5.5) | 16.1 MB | (÷4.3) | |
| vow-lean-kernel | 👍 | 217 ms | (×5.3) | 22.4 MB | (÷3.1) | |
| official-v4.28.0 | 👍 | 48 ms | (+19%) | 78.8 MB | (+14%) | |
| still-nanoda | 👍 | 7 ms | (÷5.9) | 4.6 MB | (÷15) | |
| nyaya | ✋ | 17 ms | 13.2 MB | |||
| parse-only | 👍 | 30 ms | (-26%) | 65.3 MB | (-5%) |