-
Notifications
You must be signed in to change notification settings - Fork 580
feat: explicit defeq
attribute
#8419
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Draft
nomeata
wants to merge
43
commits into
nightly-with-mathlib
Choose a base branch
from
joachim/dsimp-attr
base: nightly-with-mathlib
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Draft
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
… update on the branch
…a stage0 update on the branch" This reverts commit 9535f2e.
Rob23oba
reviewed
May 20, 2025
f694af3
to
88c553f
Compare
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
May 20, 2025
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
May 20, 2025
Mathlib CI status (docs):
|
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
May 20, 2025
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
May 20, 2025
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
May 21, 2025
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
May 21, 2025
1a1eb75
to
16e9976
Compare
This PR adds the `@[expose]` attribute to many functions (and changes some theorems to be by `:= (rfl)`) in preparation for the `@[defeq]` attribute change in #8419.
…lean4 into joachim/defeq-attr-adapat
3695c03
to
04a2875
Compare
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
May 27, 2025
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
May 27, 2025
github-merge-queue bot
pushed a commit
that referenced
this pull request
May 28, 2025
This PR adds the `@[expose]` attribute to many functions (and changes some theorems to be by `:= (rfl)`) in preparation for the `@[defeq]` attribute change in #8419.
bb2092f
to
ae54e5b
Compare
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
May 28, 2025
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
May 28, 2025
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Labels
breaks-mathlib
This is not necessarily a blocker for merging: but there needs to be a plan
changelog-language
Language features, tactics, and metaprograms
changes-stage0
Contains stage0 changes, merge manually using rebase
toolchain-available
A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR introduces an explicit
defeq
attribute to mark theorems that can be used bydsimp
. The benefit of an explicit attribute over the prior logic of looking at the proof body is that we can reliably omit theorem bodies across module boundaries. It also helps with intra-file parallelism.If a theorem is syntactically defined by
:= rfl
, then the attribute is assumed and need not given explicitly. This is a purely syntactic check and can be fooled, e.g. if in the current namespace,rfl
is not actually “the”rfl
ofEq
. In that case, some other syntax has be used, such as:= (rfl)
. This is also the way to go if a theorem can be proved bydefeq
, but one does not actually wantdsimp
to use this fact.The
defeq
attribute will look at the type of the declaration, not the body, to check if it really holds definitionally. Because of different reduction settings, this can sometimes go wrong. Then one should also write:= (rfl)
, if one does not want this to be a defeq theorem. (If one does then this is currently not possible, but it’s probably a bad idea anyways).The
set_option debug.tactic.simp.checkDefEqAttr true
,dsimp
will warn if could not apply a lemma due to a missingdefeq
attribute.With
set_option backward.dsimp.useDefEqAttr.get false
one can revert to the old behavior of inferring rfl-ness based on the theorem body.Both options will go away eventually (too bad we can’t mark them as deprecated right away, see #7969)
Meta programs that generate theorems (e.g. equational theorems) can use
inferDefEqAttr
to set the attribute based on the theorem body of the just created declaration.This builds on #8501 to update Init to
@[expose]
a fair amount of definitions that, if not exposed, would prevent some existing:= rfl
theorems from beingdefeq
theorems. In the interest of starting backwards compatible, I exposed these function. Hopefully many can be un-exposed later again.A mathlib adaption branch exists that includes both the meta programming fixes and changes to the theorems (e.g. changing
:= by rfl
to:= rfl
).With the module system there is now no special handling for
defeq
theorem bodies, because we don’t look at the body anymore. The previous hack is removed. Thedefeq
-ness of the theorem needs to be checked in the context of the theorem’s type; the error message contains a hint if the defeq check fails because of the exported context.TODO:
private
theorems or definitions, the defeq check should run inwithoutExporting
. But it seems that not even the type check for aprivate theorem
happens in that context yet, so maybe not there yet?