Skip to content

Conversation

@kim-em
Copy link
Collaborator

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

This PR fixes a compatibility issue between library_note and the Lean export format.

The Problem

Since PR #1545 (merged Dec 9, 2025), library_note creates actual declarations in the LibraryNote namespace. When library notes have human-readable names with spaces like «norm_num lemma function equality», this creates declarations like:

LibraryNote.«norm_num lemma function equality»

The current Lean export format (used by lean4export and consumed by external type checkers like nanoda_lib) does not support whitespace in declaration names. This means Mathlib cannot be exported and verified by external type checkers.

See discussion:

The Fix

This PR encodes spaces as underscores in declaration names while preserving the original name (with spaces) in the environment extension for #help note lookup.

For example:

  • library_note «my library note» now creates LibraryNote.my_library_note
  • #help note "my" still finds and displays the note correctly

Why This Matters

This fix is essential for enabling external verification of Mathlib. Without it:

  • lean4export cannot export Mathlib
  • nanoda_lib (an independent Lean 4 type checker in Rust) cannot verify Mathlib
  • Other external tools that consume the export format are blocked

The export format may be generalized to JSON in the future (see the GitHub issue above), but this fix provides immediate compatibility with the current format.

🤖 Prepared with Claude Code

@github-actions github-actions bot added the awaiting-review This PR is ready for review; the author thinks it is ready to be merged. label Jan 6, 2026
leanprover-community-mathlib4-bot added a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Jan 6, 2026
@kim-em kim-em force-pushed the fix-library-note-export-format branch 2 times, most recently from 51a04d6 to beba113 Compare January 6, 2026 02:33
…t compatibility

The Lean export format (used by `lean4export` and consumed by external type checkers
like `nanoda_lib`) does not support whitespace in declaration names. Since PR #1545,
`library_note` creates actual declarations like `LibraryNote.«my note»`, which contain
literal spaces and cannot be exported.

This PR encodes spaces as underscores in declaration names while preserving the
original name (with spaces) in the environment extension for `#help note` lookup.

For example, `library_note «my library note»` now creates a declaration named
`LibraryNote.my_library_note` instead of `LibraryNote.«my library note»`.

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

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@leanprover-community-bot
Copy link
Collaborator

Mathlib CI status (docs):

@fgdorais
Copy link
Collaborator

fgdorais commented Jan 6, 2026

Looks fine to me. Note that this isn't a solution to the underlying issue since Lean does allow identifiers with spaces.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-review This PR is ready for review; the author thinks it is ready to be merged. builds-mathlib

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants