Skip to content

fix: module system: remove WellFounded-specific hacks#9143

Merged
Kha merged 1 commit intomasterfrom
joachim/module-wf-opaque
Jul 2, 2025
Merged

fix: module system: remove WellFounded-specific hacks#9143
Kha merged 1 commit intomasterfrom
joachim/module-wf-opaque

Conversation

@nomeata
Copy link
Copy Markdown
Collaborator

@nomeata nomeata commented Jul 1, 2025

This PR removes a rather ugly hack in the module system, exposing the bodies of theorems whose type mention WellFounded.

The original motivation was that reducing well-founded definitions (e.g. in by rfl) requires reducing proofs, so they need to be available.

But reducing proofs is generally fraught with peril, and we have been nudging our users away from using it for a while, e.g. in #5182. Since the module system is opt-in and users will gradually migrate to it, it may be reasonable to expect them to avoid reducing well-founded recursion in the process

This way we don't need hacks like this (which, without evidence, I believe would be incomplete anyways) and we get the nice guarantee that within the module system, theorems bodies are always private.

This PR removes a rather ugly hack in the module system, exposing
the bodies of theorems whose type mention `WellFounded`.

The original motivation was that reducing well-founded definitions (e.g.
in `by rfl`) requires reducing proofs, so they need to be available.

But reducing proofs is generally fraught with peril, and we have been
nudging our users away from using it for a while, e.g. in #5182. Since
the module system is opt-in and users will gradually migrate to it, it
may be reasonable to expect them to avoid reducing well-founded
recursion in the process

This way we don't need hacks like this (which, without evidence, I
believe would be incomplete anyways) and we get the nice guarantee that
within the module system, theorems bodies are always private.
@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 Jul 1, 2025
@leanprover-bot
Copy link
Copy Markdown
Collaborator

Reference manual CI status:

  • ❗ Reference manual CI can not be attempted yet, as the nightly-testing-2025-07-01 tag does not exist there yet. We will retry when you push more commits. If you rebase your branch onto nightly-with-manual, reference manual CI should run now. You can force reference manual CI using the force-manual-ci label. (2025-07-01 22:36:34)

ghost pushed a commit to leanprover-community/batteries that referenced this pull request Jul 1, 2025
ghost pushed a commit to leanprover-community/mathlib4-nightly-testing that referenced this pull request Jul 1, 2025
@ghost ghost added the builds-mathlib CI has verified that Mathlib builds against this PR label Jul 1, 2025
@ghost
Copy link
Copy Markdown

ghost commented Jul 1, 2025

Mathlib CI status (docs):

@nomeata nomeata added the changelog-language Language features and metaprograms label Jul 2, 2025
@nomeata nomeata requested a review from Kha July 2, 2025 07:08
@nomeata nomeata marked this pull request as ready for review July 2, 2025 07:08
@nomeata nomeata requested a review from kim-em as a code owner July 2, 2025 07:08
@Kha Kha added this pull request to the merge queue Jul 2, 2025
Merged via the queue into master with commit 977ae92 Jul 2, 2025
28 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

builds-mathlib CI has verified that Mathlib builds against this PR changelog-language Language features and metaprograms toolchain-available A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants