-
Notifications
You must be signed in to change notification settings - Fork 451
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
fix: subst notation (heq ▸ h) should fail if it does't subst #3994
Merged
Conversation
This file contains 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
The subst notation substitues in the expected type, if present, or in the type of the argument, if no expected type is known. If there is an expected type it already fails if it cannot find the equations' left hand side or right hand side. But if the expected type is not known and the equation's lhs is not present in the second argument's type, it will happily do a no-op-substitution. This is inconsistent and unlikely what the user intended to do, so we now print an error message now. This still only looks for the lhs; search for the rhs as well seems prudent, but I’ll leave that for a separate PR, to better diagnose the impact on mathlib.
nomeata
commented
Apr 26, 2024
Comment on lines
+7
to
+16
def ex4 (heq : foo = bar) (P : Nat → Prop) (h : P 3) := heq ▸ h -- error | ||
def ex5 (heq : foo = bar) (P : Nat → Prop) (h : P 3) : P 4 := heq ▸ h -- error | ||
def ex6 (heq : foo = bar) (P : Nat → Prop) (h : P 3) : P bar := heq ▸ h | ||
|
||
def ex7 (heq : bar = foo) (P : Nat → Prop) (h : P foo) := heq ▸ h -- error | ||
def ex8 (heq : bar = foo) (P : Nat → Prop) (h : P foo) : P 4 := heq ▸ h -- error | ||
def ex9 (heq : bar = foo) (P : Nat → Prop) (h : P foo) : P bar := heq ▸ h | ||
def ex10 (heq : bar = foo) (P : Nat → Prop) (h : P 3) := heq ▸ h -- error | ||
def ex11 (heq : bar = foo) (P : Nat → Prop) (h : P 3) : P 4 := heq ▸ h -- error | ||
def ex12 (heq : bar = foo) (P : Nat → Prop) (h : P 3) : P bar := heq ▸ h |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Previously, ex4
, ex7
and ex10
would not err.
github-actions
bot
added
the
toolchain-available
A toolchain is available for this PR, at leanprover/lean4-pr-releases:pr-release-NNNN
label
Apr 26, 2024
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
Apr 26, 2024
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
Apr 26, 2024
leanprover-community-mathlib4-bot
added
the
breaks-mathlib
This is not necessarily a blocker for merging: but there needs to be a plan
label
Apr 26, 2024
Mathlib CI status (docs):
|
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
Apr 26, 2024
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
Apr 26, 2024
nomeata
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
Apr 26, 2024
nomeata
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
Apr 26, 2024
nomeata
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
Apr 26, 2024
refactor: avoid useless subst while working on leanprover/lean4#3994 I found a few uses of ▸ that do not actually do any rewriting. I plan to make this an error, but of course dropping them is already useful now.
leanprover-community-mathlib4-bot
added
builds-mathlib
CI has verified that Mathlib builds against this PR
and removed
breaks-mathlib
This is not necessarily a blocker for merging: but there needs to be a plan
labels
Apr 26, 2024
nomeata
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
Apr 26, 2024
while working on leanprover/lean4#3994 I found a few uses of ▸ that do not actually do any rewriting. I plan to make this an error, but of course dropping them is already useful now.
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/batteries
that referenced
this pull request
Apr 26, 2024
leanprover-community-mathlib4-bot
added a commit
to leanprover-community/mathlib4
that referenced
this pull request
Apr 26, 2024
leodemoura
approved these changes
Apr 28, 2024
I've merged |
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
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.
The subst notation substitues in the expected type, if present, or in
the type of the argument, if no expected type is known.
If there is an expected type it already fails if it cannot find the
equations' left hand side or right hand side. But if the expected type
is not known and the equation's lhs is not present in the second
argument's type, it will happily do a no-op-substitution.
This is inconsistent and unlikely what the user intended to do, so we
now print an error message now.
This still only looks for the lhs; search for the rhs as well seems
prudent, but I’ll leave that for a separate PR, to better diagnose the
impact on mathlib.
This triggers a small number of pointless uses of subst in mathlib, see
leanprover-community/mathlib4#12451