Lean Kernel Arena / bugs/nested-rec-hijack

Test "bugs/nested-rec-hijack"

Expected: ✋ reject · Size: 12.8 KB · Lines: 212 · lean4export: 3.1.0 · Lean: 4.36.0 · 📄 Declaration · 🔗 Source

Proof of False from an ordinary safe definition named Tree.rec_1 hijacking the auxiliary recursor of a nested inductive type.

The export declares Pair (f : Prop → Prop) : Type 1 (mk (p : Prop) (h : f p)) and Box (α : Type) : Type (mk (val : α)), and defines an ordinary safe function def Tree.rec_1.{u} taking 6 arguments and returning Pair.mk (fun _ => True) False True.intro.

It then declares a nested inductive Tree : Type (leaf : Tree, node : Box Tree → Tree, numNested: 1) whose recs list contains only Tree.rec (whose node rule calls Tree.rec_1.{u}) and omits Tree.rec_1. A checker that does not reject a nested inductive when a generated auxiliary recursor name (Tree.rec_1) is missing from the block and occupied by a non-recursor declaration admits Tree.rec with its rule pointing at the pre-declared def Tree.rec_1.

Instantiating Tree.rec with motive Pair (fun p => p) on Tree.node (Box.mk Tree.leaf) evaluates through the hijacked Tree.rec_1 to Pair.mk (fun _ => True) False True.intro at static type Pair (fun p => p), whose second projection Pair.1 has type (Tree.rec ...).0 ≡ False (inconsistent : False), without axioms.

rpylean accepted this export because nested inductive checking did not verify that every generated auxiliary recursor name (T.rec_k) was declared as a matching recursor in the same block.

Checker Result ⏱️ 🧠
nano-lean ✋ 1.03 ms 26.2 MB
gruszka ✋ 1.88 ms 84.0 MB
mathgraph ✋ 0.953 ms 21.8 MB
sokonanoda ✋ 0.950 ms 21.8 MB
pestka ✋ 2.29 ms 16.6 MB
kefir ✋ 0.695 ms 6.2 MB
kefir-wasm ✋ 116 ms 83.6 MB
con-ron ✋ 29.3 ms 41.6 MB
con-ron-stream ✋ 29.9 ms 47.2 MB
con-agua ✋ 20.6 ms 14.3 MB
nanobruijn ✋ 1.20 ms 11.8 MB
nanoda ✋ 0.852 ms 3.3 MB
con-leche ✋ 4.45 ms 25.3 MB
pestka-wasm ✋ 515 ms 313.1 MB
official-nightly ✋ 34.0 ms 98.1 MB
eink0rn ✋ 1.64 ms 12.0 MB
official ✋ 32.9 ms 102.2 MB
ind-models ✋ 101 ms 111.4 MB
kiota ✋ 0.974 ms 11.3 MB
tenet ✋ 144 ms 46.2 MB
tenet-hs ✋ 1.85 ms 10.1 MB
logos-kernel ✋ 0.503 ms 4.7 MB
evmlean ✋ 1.67 s 253.6 MB
mini 🚫 34.5 ms 73.3 MB
overfull ✋ 29.6 s 46.8 MB
lean4lean ✋ 30.6 ms 100.4 MB
lean4cobol ✋ 7.66 ms 13.8 MB
tenet-jvm ✋ 128 ms 76.9 MB
nanoclo ✋ 0.890 ms 47.6 MB
vow-lean-kernel ✋ 183 ms 14.4 MB
canonical-min 🚫 387 ms 1.1 GB
lazylean ✋ 1.34 ms 21.3 MB
rpylean 👍 0.989 ms 10.8 MB
metalean-slow 👍 30.7 ms 74.1 MB
metalean-fast 👍 30.7 ms 71.4 MB
nanoclo-fortran ✋ 1.35 ms 4.5 MB