Exported binder names and binder info depend on what else is exported

オープン
#58 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

@JoAdo07 がすでに取り組んでいます。

2026年10月28日 から。

  • #59 @JoAdo07 による — オープン

評価

難易度
3/5
見積もり時間
1〜2日
初心者へのやさしさ
76/100
issue の種類
バグ
明瞭さ
明確に書かれている
活発さ
活発
領域
tooling

調査の方向性

Start with Export.lean and find visitedExprs : HashMap Expr Nat, then inspect how Expr equality and hashing are implemented before changing its key behavior. Locate the repository’s export tests and add coverage showing that the same declaration exports identical binder names and binder info regardless of what was exported first. Done means α-equivalent expressions with different binders are not incorrectly deduplicated, while exports remain valid for kernel checking.

索引モデルが issue の本文から書いたものです。

説明

Export.lean deduplicates expressions with visitedExprs : HashMap Expr Nat, which uses Lean's BEq Expr (α-equivalence: binder names and binder info are ignored). When two expressions differ only in binder names or binder info, whichever is visited first gets an index, and later occurrences reuse it. So the binders printed for a declaration depend on which declarations were exported before it.

Example. Exporting Lean.Grind.not_not as part of a small closure versus as part of the closure of Complex.exists_root (same Mathlib commit, same toolchain) gives different binders for the same declaration: one export has a binder named a with one binder info, and the other has p with another.

It doesn't affect checking: kernels ignore binder names and info. But it means an export isn't a function of the declaration alone, which breaks anything that hashes or caches exported declarations, or diffs exports. We hit this content-addressing declarations: across those two exports, the binder differences alone changed the hashes of thousands of the 18,322 shared declarations.

Also: exporting all of Mathlib at once (lean4export Mathlib, no constants listed) stalled for over 20 minutes after about 650k declarations, with lean4export using CPU but writing nothing. Exporting the same constants in chunks of about 6,000 (each chunk's modules, with its constants listed) finished every chunk in under 90 s.

Possible fix. Key visitedExprs on structural equality (Expr.equal), for example through a wrapper whose BEq is Expr.equal. Hashable Expr already ignores binder names, so it can stay. Exports get slightly larger, because α-equivalent copies are no longer shared, but each declaration's export no longer depends on what else is exported.

(We work around it downstream by dropping binder names and info, but other consumers likely want the real names.)

主要言語
Lean
スター
52
フォーク
30
PR マージ指標
30日以内にマージされた PR はありません

環境構築

このプロジェクトには開発コンテナ、Dockerfile、コントリビューションガイドがありません。まず README を読み、一般的な手順ははじめてのコントリビューションガイドを参照してください。

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

leanprover/lean4export のほかの issue

leanprover/lean4export の issue をすべて見る

似ている issue

DevTools の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。