Skip to content

Conversation

@kim-em
Copy link
Contributor

@kim-em kim-em commented Jan 6, 2026

This PR cherry-picks a fix from the ammkrn fork that normalizes the nonDep flag to false for letE expressions during export.

Original commit: ammkrn@eb023e5

The Problem

Lean's BEq implementation for Expr considers the nonDep flag when comparing expressions. However, nonDep is just an optimization hint that doesn't affect semantics - it indicates whether the body of a let-binding uses the bound variable.

Without normalization, semantically identical expressions can appear twice in the export with different indices:

  • Once with nonDep = true
  • Once with nonDep = false

External type checkers expect unique indices for identical expressions, causing parse errors like:

assertion `left == right` failed
  left: (152289, true)
 right: (152276, false)

The Fix

Always normalize nonDep to false during export, as originally implemented by @ammkrn.

Testing

With this fix, nanoda_lib successfully verifies:

  • Lean's Init library (50,499 declarations)
  • Batteries (109,792 declarations)

🤖 Prepared with Claude Code

The `BEq` implementation for `Expr` considers the `nonDep` flag, but
`nonDep` is just an optimization hint that doesn't affect semantics.
External type checkers (e.g., nanoda_lib) treat expressions as identical
regardless of this flag.

Without normalization, the same expression can appear twice with different
indices (once with `nonDep = true`, once with `nonDep = false`), causing
parse errors in external type checkers that expect unique indices.

This fix was originally implemented in the ammkrn fork:
ammkrn@eb023e5

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
mathlib-bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Jan 6, 2026
This PR adds a new daily CI job that verifies Mathlib using [nanoda_lib](https://github.com/ammkrn/nanoda_lib), an independent Lean 4 type checker written in Rust.

Like lean4checker, this runs daily on both master and nightly-testing, and reports results to Zulip (in the `nightly-testing` stream, topic `nanoda` for successes and `nanoda failure` for failures).

**Temporary workaround**: This uses a fork of lean4export with leanprover/lean4export#11 applied, which fixes nonDep normalization for export. Once that PR is merged, we can switch back to the official repo.

🤖 Prepared with Claude Code
kim-em added a commit to kim-em/mathlib4 that referenced this pull request Jan 6, 2026
…3648)

This PR adds a new daily CI job that verifies Mathlib using [nanoda_lib](https://github.com/ammkrn/nanoda_lib), an independent Lean 4 type checker written in Rust.

Like lean4checker, this runs daily on both master and nightly-testing, and reports results to Zulip (in the `nightly-testing` stream, topic `nanoda` for successes and `nanoda failure` for failures).

**Temporary workaround**: This uses a fork of lean4export with leanprover/lean4export#11 applied, which fixes nonDep normalization for export. Once that PR is merged, we can switch back to the official repo.

🤖 Prepared with Claude Code
@hargoniX hargoniX merged commit bd93e5e into leanprover:master Jan 7, 2026
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants