Lean Kernel Arena (Preview) / perf/prop-struct-projections

Test "perf/prop-struct-projections"

Expected: 👍 accept · Size: 406.5 KB · Lines: 8.6 k · lean4export: 3.2.0 · Lean: 4.38.0-nightly-2026-12-03 · Timeout: 40.0 s · 📄 Declaration · 🔗 Source

The declarations to check are the N projection functions of

structure Wide (n : Nat) : Prop where
  (h0 : n + 0 = 0 + n)  …  (h{N-1} : n + (N-1) = (N-1) + n)

reached through a theorem that rebuilds a Wide n from all of them.

Wide is a proposition, so for a projection out of it every earlier field that a later field's type uses must itself be a proposition (as official's infer_proj checked it when this test was added). A checker that instantiates the parameter n first and then steps through the fields tests "is field j used later" against the cached loose-variable range of the binder body, constant time per field: Θ(N²) for all N projections.

A checker that asks the question of the stored constructor type instead walks the rest of the telescope for every earlier field of every projection, and the parameter n, a loose bound variable in every field's type there, defeats any loose-variable cutoff: no field is used later, so every walk goes to the end, for Θ(N³).

N=200 in the Lean source. Lean 4.35 built a propositional structure's casesOn from all its projections, so the same cost appeared for every such structure there (e.g. the bv_decide structure benchmarks of the Lean test suite).

Checker Result ⏱️ 🧠
gruszka 👍 8.23 ms (÷12) 122.2 MB (+2%)
nano-lean 👍 9.96 ms (÷9.6) 115.3 MB (-3%)
pestka 👍 30.4 ms (÷3.1) 29.4 MB (÷4.1)
con-leche 👍 65.7 ms (-31%) 39.6 MB (÷3.0)
con-ron 👍 66.9 ms (-30%) 58.0 MB (÷2.1)
nucleus 🚫 111 ms 15.3 MB
official 👍 95.3 ms 119.5 MB