`simp` fails when it tries to apply a private lemma in the public scope
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 4/5
- Tiempo estimado
- 3-5 días
- Aptitud para principiantes
- 30/100
- Tipo de issue
- Error
- Claridad
- Bien especificado
- Estado de actividad
- Activo
- Área
- compilers
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- Lean
- Estrellas
- 10.3k
- Forks
- 1.1k
- Merge medio
- 19 h 8 min
- PR fusionados (30 d)
- 421
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Tiene una plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de leanprover/lean4
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
leanprover/lean4#16681 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 78/100
leanprover/lean4#16305 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 86/100
leanprover/lean4#16299 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 72/100
leanprover/lean4#16257 ·
Los mantenedores suelen responder en 1 día
-
`IO.FS.realPath` reports every failure as `noFileOrDirectory` instead of classifying by `errno`Abiertobug
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
leanprover/lean4#15683 ·
Los mantenedores suelen responder en 1 día
Todos los issues de leanprover/lean4
Issues similares
-
area-CodeGen-coreclr untriaged
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
dotnet/runtime#138181 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
aptos-labs/aptos-core#21083 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 66/100
sagemathinc/sagebrush#1864 ·
Los mantenedores suelen responder en 1 día
-
clang:frontend clang:openmp crash
Dificultad 2/5 1-3 horas Aptitud para principiantes 62/100
llvm/llvm-project#245442 · 1 comentario ·
Los mantenedores suelen responder en 1 día
-
bug package: lang-core
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día