Lean Kernel Arena (Preview) / bugs/open-term-cache-context

Test "bugs/open-term-cache-context"

Expected: ✋ reject · Size: 1.7 KB · Lines: 32 · lean4export: 3.2.0 · Lean: 4.38.0-nightly-2026-12-03 · 📄 Declaration · 🔗 Source

Proof of ∀ P : Prop, P via a type cache for open terms that ignores the types of the enclosing binders.

-- A := ∀ P : Prop, P,  B := ∀ P : Prop, P → P
theorem openDagContextLeakFalse : ∀ P : Prop, P :=
  (fun f : A → A =>
    (fun (g : A → A) (h : B → A) => h (fun P p => p))
      (fun x : A => f x) (fun y : B => f y))
  (fun z : A => z)

fun y : B => f y is ill typed. The bodies f x and f y are the same expression #1 #0, so the export shares one node between them, at the same binder depth. A checker that caches the inferred type of an open subterm by its identity and binder depth alone reuses the type computed under x : A when it meets the node under y : B, so h turns the trivial proof of B into a proof of A. The file has no axioms and no other declarations.

ocaml4lean accepted this export with the open-term inference of its perf/kernel-overhaul branch (ocaml4lean #7; the repository is no longer online). Found while reading that branch.

Checker Result ⏱️ 🧠
gruszka ✋ 1.76 ms 54.1 MB
nano-lean ✋ 0.460 ms 10.2 MB
pestka ✋ 1.99 ms 16.1 MB
con-leche ✋ 3.90 ms 23.2 MB
con-ron ✋ 28.3 ms 43.7 MB
nucleus ✋ 24.5 ms 13.6 MB
official ✋ 42.3 ms 113.8 MB