`simp` fails when it tries to apply a private lemma in the public scope
メンテナーはふだん 1 日以内に返信
まだ誰も着手していません。
評価
- 難易度
- 4/5
- 見積もり時間
- 3〜5日
- 初心者へのやさしさ
- 30/100
- issue の種類
- バグ
- 明瞭さ
- 明確に書かれている
- 活発さ
- 活発
- 領域
- compilers
調査の方向性
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.
索引モデルが issue の本文から書いたものです。
説明
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.
- 主要言語
- Lean
- スター
- 10.3k
- フォーク
- 1.1k
- 平均マージ
- 19時間 8分
- マージ済み PR(30日)
- 421
環境構築
- Dockerfile・Docker Compose ファイルなし
- プルリクエストのテンプレートあり
- コントリビューションガイドを読む
はじめの一歩
- issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
- 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
- リポジトリをフォークし、ブランチを切って変更します。
- issue 番号を参照したプルリクエストを送ります。
leanprover/lean4 のほかの issue
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
leanprover/lean4#16713 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 70/100
leanprover/lean4#16711 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
leanprover/lean4#16681 · コメント 3 件 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 78/100
leanprover/lean4#16305 ·
メンテナーはふだん 1 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 86/100
leanprover/lean4#16299 ·
メンテナーはふだん 1 日以内に返信
leanprover/lean4 の issue をすべて見る
似ている issue
-
難易度 2/5 1〜3時間 初心者へのやさしさ 82/100
メンテナーはふだん 1 日以内に返信
-
std: `SliceIndex<str>` missing for `std::ops` ranges, so generic `R: SliceIndex<str>` bounds failオープン
難易度 2/5 1〜3時間 初心者へのやさしさ 72/100
メンテナーはふだん 1 日以内に返信
-
area-CodeGen-coreclr untriaged
難易度 2/5 1〜3時間 初心者へのやさしさ 65/100
dotnet/runtime#138181 · コメント 1 件 ·
メンテナーはふだん 1 日以内に返信
-
bug
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
メンテナーはふだん 3 日以内に返信
-
難易度 2/5 1〜3時間 初心者へのやさしさ 74/100
aptos-labs/aptos-core#21083 ·
メンテナーはふだん 1 日以内に返信