Repository navigation
Description
Prerequisites
- Check that your issue is not already filed. This is the recursor analogue of leanchecker accepts constructor entries whose map key differs from the embedded name #15100 (constructor entries) and leanchecker treats arbitrary quotInfo entries as canonical quotient declarations #15101 (quotInfo entries), both closed. Those reports did not cover the same shape for a
RecursorVal. - Reduce the issue to a minimal, self-contained, reproducible test case. Avoid dependencies to Mathlib or Batteries.
- Test your test case against the latest nightly release. (Reproduced on v4.33.1 and v4.35.0. The relevant lines of
src/Lean/Replay.leanandsrc/LeanChecker.leanare unchanged onmasteras of 2026-11-22.)
I reported this privately to the Lean FRO first. They suggested filing it here as a description of the behaviour.
Description
ModuleData documents the invariant constNames = constants.map (·.name). The default (non---fresh) leanchecker path builds its replay map from these two parallel arrays (replayFromImports in src/LeanChecker.lean). It does not check that constNames[i] == constants[i].name.
For a .recInfo entry, Replay.lean fetches the entry by its map key. Recursor checking, however, is postponed under the embedded RecursorVal.name, and checkPostponedRecursors re-checks the entry under that embedded name. So if an .olean stores an edited RecursorVal under a map key that differs from its embedded name, that entry is never compared with a kernel-generated declaration.
Concretely, start from an inductive T and append one entry to its .olean. The entry's constNames key is renamed, but its ConstantInfo is still the RecursorVal named T.rec, with the type changed to False. Then:
leanchecker Editedexits0.leanchecker Consexits0.ConsimportsEditedand declarestheorem t : False := @renamed.leanchecker --fresh Consexits1withunknown constant 'renamed'.
This matches the constructor case in #15100, with recInfo in place of ctorInfo.
Context
leanchecker is documented as a detector for environment tampering, not an external verifier, and ordinary .olean import trusts artifacts by design. The gap is the one #15100 describes. The replay map is keyed by constNames, but constructor and recursor entries are postponed and re-checked under their embedded names. An entry stored under a non-matching key therefore skips that comparison. #15100 showed this for ctorInfo and #15101 for quotInfo. recInfo behaves the same way.
Steps to Reproduce
In a fresh empty directory, with lean and leanchecker from a v4.33.1 toolchain on PATH (no network needed):
cat > Seed.lean <<'LEAN'
inductive T where
| mk
LEAN
cat > Gen.lean <<'LEAN'
import Lean
open Lean
-- Read Seed.olean, append one entry: constNames key `renamed`, but the ConstantInfo
-- is still the RecursorVal named `T.rec`, retyped to `False`. Key != embedded name.
def main : IO Unit := do
let (data, _region) ← readModuleData "Seed.olean"
let some ri := data.constants.find? (fun ci => ci.name == `T.rec)
| throw <| IO.userError "no T.rec"
let .recInfo rv := ri | throw <| IO.userError "T.rec not a rec"
let edited : ConstantInfo := .recInfo
{ rv with name := `T.rec, levelParams := [], type := .const ``False [], isUnsafe := false }
saveModuleData "Edited.olean" `Edited
{ data with constNames := data.constNames.push `renamed, constants := data.constants.push edited }
IO.println "GEN_DONE"
LEAN
cat > Cons.lean <<'LEAN'
import Edited
theorem t : False := @renamed
LEAN
export LEAN_PATH=$PWD
lean Seed.lean -o Seed.olean # exit 0
lean --run Gen.lean # writes Edited.olean, prints GEN_DONE, exit 0
lean Cons.lean -o Cons.olean # exit 0 (import trusts the artifact)
leanchecker -v Edited # (1)
leanchecker -v Cons # (2)
leanchecker -v --fresh Edited # (3)
leanchecker -v --fresh Cons # (4)Expected behavior
leanchecker rejects Edited. The appended entry's map key renamed does not match its embedded name T.rec, and no kernel-generated declaration named renamed exists. A replay-map key should identify the same declaration as the entry's ConstantInfo.name.
Actual behavior
Steps (1)–(3) exit 0. Only --fresh on the consuming module reports the entry. Measured output, with exit codes:
# (1) leanchecker -v Edited
replaying Edited
# exit 0
# (2) leanchecker -v Cons
replaying Cons
# exit 0
# (3) leanchecker -v --fresh Edited
replaying Edited with --fresh
# exit 0 (nothing in Edited itself refers to `renamed`)
# (4) leanchecker -v --fresh Cons
replaying Cons with --fresh
uncaught exception: while replaying declaration 't':
(kernel) unknown constant 'renamed'
# exit 1
Versions
Lean (version 4.33.1, x86_64-unknown-linux-gnu, commit 819816b2e0a3bf405af45ae5c7af2491d8f5bee6, Release)
Also reproduced on 4.35.0 (eb6cafb7), on Linux x86_64. The relevant lines of src/Lean/Replay.lean and src/LeanChecker.lean are unchanged on master as of 2026-11-22.
Additional Information
leanchecker --freshreports the entry when run on the consuming module:(kernel) unknown constant 'renamed', exit 1 (step 4). OnEditedalone it passes, because nothing inEditedrefers torenamed.import Editedcompilestheorem t : False := @renamedwith exit 0. Ordinary import trusts artifacts by design, and leanchecker accepts constructor entries whose map key differs from the embedded name #15100 describes the same downstream behaviour for its constructor case.- Export path, measured on exactly these files.
lean4export Cons t(exit 0) writes no declaration record forrenamed: the name appears only as a reference in the value oft. Every checker run on the export reportsrenamedas unknown:leanchecker --from-exportexits 1 with(kernel) unknown constant 'renamed'. This is the 4.35.0 binary, plain and paranoid build.- nanoda exits 101:
declaration t depends on renamed which was not found. - con-ron on the export exits 1:
rejected: unknown constant [at theorem t]. - con-ron's direct
.oleanreader (--olean) refusesEdited.oleanitself with exit 3: the name table (constNames) does not list its constants' names.
One possible approach (optional): when building the replay map, require constNames[i] == constants[i].name with no duplicates, before any dependency traversal. This would cover #15100, #15101 and this variant. Checking the same constNames = constants.map (·.name) invariant while loading ModuleData would add a second layer.
Impact
Writing such an entry requires editing an .olean file. Ordinary import and leanchecker --fresh on the consuming module behave as described above, and export-based checking reports the entry (measured above). Filing for tracking, in line with #15100 and #15101.
Activity
nomeata commentedon Nov 22, 2026
Thanks, not severe but worth fixing id say.
fix: reject replay map entries stored under a different name (leanpro…