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

未关闭
#58 0 条评论 0 个 reaction 已指派 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. Fork 仓库,在一个分支上完成修改。
  4. 提交 Pull Request,并在描述里引用这个 Issue 编号。

leanprover/lean4export 的其他 Issue

查看 leanprover/lean4export 的全部 Issue

相似的 Issue

更多 DevTools Issue

把新 issue 发到你的邮箱

精选适合新手参与的 GitHub issue 摘要。