`simp` fails when it tries to apply a private lemma in the public scope
I maintainer di solito rispondono entro 1 giorno
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Idoneità per principianti
- 30/100
- Tipo di issue
- Bug
- Chiarezza
- Specificata chiaramente
- Stato di attività
- Attiva
- Ambito
- compilers
Direzione di ricerca
Start from the minimal reproduction in the issue: a public section with a private @[simp] theorem x_eq used by simp -failIfUnchanged at h inside an @[expose] definition. The failure is an "Unknown constant" error for the private name, so look at how simp collects and resolves candidate lemmas when run in the public scope. Done means the reproduction no longer errors and simp leaves h unchanged, with private lemmas skipped or handled correctly in that scope.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
Prerequisites
- Check that your issue is not already filed:
https://github.com/leanprover/lean4/issues - 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, for example on
https://live.lean-lang.org/#project=lean-nightly
(You can also use the settings there to switch to “Lean nightly”) - When reporting a perceived soundness bug: Does it affect
lake check --paranoid?
If in doubt, please reach out on [email protected] for responsible disclosure.
Description
When simp is run in the public scope and it tries to apply a private (or privately imported) lemma, it fails with an "Unknown constant" error, even if in the end, that lemma wouldn't have been applied (for example, due to typeclass assumptions). Ideally, simp would apply only public lemmas when run in the public scope.
Context
Mathlib's simps attribute has an option to call simp on the generated lemmas, which is currently run in the public scope. This caused an error in an existing definition in a PR which added a private import to a file, even though the lemma simp tried applying wouldn't have been used because of its typeclass assumptions. See the discussion of https://github.com/leanprover-community/mathlib4/pull/46130 for details. However, this issue can be reproduced without any metaprogramming by constructing a definition using tactics.
Steps to Reproduce
module
public section
def x := 0
@[simp]
private theorem x_eq (_ : False) : x = 0 := rfl
@[expose]
def a (h : x = 0) : Nat := by
simp -failIfUnchanged at h
exact 0
Expected behavior: simp does nothing.
Actual behavior: simp fails with "Unknown constant _private.«external:file:///lean-nightly/lean-nightly.lean».0.x_eq".
Versions
Lean 4.38.0-nightly-2026-11-20
Additional Information
[Additional information, configuration or data that might be necessary to reproduce the issue]
Impact
Add 👍 to issues you consider important. If others are impacted by this issue, please ask them to add 👍 to it.
- Lingua principale
- Lean
- Stelle
- 10.3k
- Fork
- 1.1k
- Merge medio
- 19h 8m
- PR unite (30g)
- 421
Preparare l'ambiente
- Nessun Dockerfile né file Docker Compose
- Ha un modello di pull request
- Leggi la guida per i contributori
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Altre issue di leanprover/lean4
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
leanprover/lean4#16681 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
leanprover/lean4#16305 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 86/100
leanprover/lean4#16299 ·
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 72/100
leanprover/lean4#16257 ·
I maintainer di solito rispondono entro 1 giorno
-
`IO.FS.realPath` reports every failure as `noFileOrDirectory` instead of classifying by `errno`Apertabug
Difficoltà 2/5 1-3 ore Idoneità per principianti 66/100
leanprover/lean4#15683 ·
I maintainer di solito rispondono entro 1 giorno
Tutte le issue di leanprover/lean4
Issue simili
-
node:url: url.parse and url.resolve report name parse/resolve instead of Node's urlParse/urlResolveApertaarea:stdlib effort:S impact:low parity type:bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
I maintainer di solito rispondono entro 1 giorno
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
bad-antics/lateralus-lang#880 · 1 commento ·
I maintainer di solito rispondono entro 1 giorno
-
bug fixed form parser medium priority tokenizer
Difficoltà 2/5 1-3 ore Idoneità per principianti 68/100
I maintainer di solito rispondono entro 1 giorno
-
bug
Difficoltà 1/5 Meno di un'ora Idoneità per principianti 80/100
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 76/100
swc-project/swc-next-issues#817 ·