Skip to content

fix: export proofs in variable binders of a public section - #15394

Open
marcelolynch wants to merge 1 commit into
leanprover:masterfrom
marcelolynch:fix-section-var-aux-names
Open

marcelolynch wants to merge 1 commit into
leanprover:masterfrom
marcelolynch:fix-section-var-aux-names

Conversation

@marcelolynch

@marcelolynch marcelolynch commented Sep 29, 2026 •

Copy link
Copy Markdown
Contributor

This PR fixes proofs in variable binders inside public section, for example proofs from an auto-param. Public declarations that include such a variable referred to an auxiliary theorem that was not exported, so a module file that used these declarations failed with unknown constant.

Command.runTermElabM elaborates the section variables again for each declaration, before the declaration name sets the prefix for auxiliary names. In an exporting context, mkAuxLemma caches the abstracted proof as public, but the command-level name generator gives it a private name, so addDecl does not export it. runTermElabM now elaborates the section variables with a public, macro-scoped prefix when the environment is exporting. The macro scope keeps the names unique across modules. The previous generator is restored before elabFn runs.

This PR does not change the related case where a metaprogram adds a public declaration whose type mentions a private constant (#15401).

Fixes #15393.

🤖 Generated with Claude Code

@github-actions github-actions Bot added the toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN label Sep 29, 2026
@marcelolynch
marcelolynch force-pushed the fix-section-var-aux-names branch from 1631711 to a3e2793 Compare September 29, 2026 03:18
This PR fixes proofs in `variable` binders inside `public section`. Such a proof became an auxiliary theorem with a private name that was not exported, but the public declarations that include the variable mention it. A `module` file that used these declarations failed with `unknown constant`. These auxiliary theorems now get public names and are exported.

Fixes leanprover#15393.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

This branch has not been deployed

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

Labels

toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

1 participant