Test "perf/let-ladder"
Expected: 👍 accept · Size: 457.6 KB · Lines: 10.4 k · lean4export: 3.1.0 · Lean: 4.34.1 · Timeout: 50.0 s · 📄 Declaration · 🔗 Source
The declaration to check has type Nat and value
let x₃ := 0; x₃ + (let x₂ := 0; x₂ + (let x₁ := 0; x₁ + (x₃ + (x₂ + (x₁ + 0)))))
shown at n=3: n let bindings, each separated from the next by an addition,
over an innermost sum that names every binding.
Substituting a binding into the body before checking it traverses O(n) nodes at each of the n bindings, for Θ(n²) in time and in allocated nodes. Recording the binding and reading it where the body names it costs O(1) per binding, for Θ(n).
The additions are what keep the bindings apart: a run of adjacent lets could
be opened by a single substitution; not so here.
Nat.add is the only application head, so no beta reduction is involved.
N=2000 in the Lean source.
| Checker | Result | ⏱️ | 🧠 | |||
|---|---|---|---|---|---|---|
| sokonanoda | 👍 | 4 ms | (÷229) | 52.0 MB | (÷6.2) | |
| mathgraph | 👍 | 142 ms | (÷7.1) | 93.4 MB | (÷3.4) | |
| nanoclo | 👍 | 5 ms | (÷189) | 67.4 MB | (÷4.7) | |
| con-ron | 👍 | 767 ms | (-24%) | 667.0 MB | (×2.1) | |
| nanobruijn | 👍 | 1.7 s | (+64%) | 824.2 MB | (×2.6) | |
| nanoda | 👍 | 700 ms | (-31%) | 306.2 MB | (-4%) | |
| lazylean | 👍 | 366 ms | (÷2.8) | 36.9 MB | (÷8.7) | |
| con-leche | 👍 | 470 ms | (÷2.2) | 221.8 MB | (-31%) | |
| eink0rn | 👍 | 1.6 s | (+61%) | 549.5 MB | (+72%) | |
| official | 👍 | 1.0 s | (0%) | 319.9 MB | (0%) | |
| ind-models | 👍 | 1.1 s | (+7%) | 341.4 MB | (+7%) | |
| lean4lean | 👍 | 1.0 s | (+2%) | 347.4 MB | (+9%) | |
| tenet | 👍 | 1.6 s | (+60%) | 331.0 MB | (+3%) | |
| tenet-hs | 👍 | 1.9 s | (+89%) | 634.7 MB | (+98%) | |
| lean4cobol | 👍 | 17.1 s | (×17) | 420.6 MB | (+31%) | |
| evmlean | 🚫 | 8.7 s | 403.2 MB | |||
| mini | 👍 | 1.3 s | (+28%) | 1.0 GB | (×3.2) | |
| overfull | ⌛ | 0 ms | 0 B | |||
| metalean-slow | 🚫 | 81 ms | 79.2 MB | |||
| tenet-jvm | 👍 | 1.3 s | (+33%) | 447.1 MB | (+40%) | |
| nanoclo-fortran | 👍 | 21 ms | (÷48) | 13.1 MB | (÷24) | |
| kiota | 👍 | 588 ms | (-42%) | 530.6 MB | (+66%) | |
| metalean-fast | ⌛ | 0 ms | 0 B | |||
| canonical-min | ✋ | 416 ms | 1.1 GB | |||
| rpylean | ✋ | 1.5 s | 957.8 MB | |||
| vow-lean-kernel | 👍 | 31.6 s | (×31) | 525.9 MB | (+64%) | |
| parse-only | 👍 | 53 ms | (÷19) | 67.8 MB | (÷4.7) |