-
Notifications
You must be signed in to change notification settings - Fork 364
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
[Merged by Bors] - refactor: add an ofNat() elaborator #20169
Conversation
This lemma is malformed; the `n` on the RHS must be a raw literal, but the one on the left is not. Correcting the statement results in `Nat.cast_ofNat` which already exists.
`ofNat(n)` is a shorthand for `no_index (OfNat.ofNat n)`. Its purpose is: * To make it easier to remember to write the `no_index` * To add a place to put a hoverable docstrings explaining the complexities * To make it easier to remove the `no_index`es in future if `DiscrTree`s stops needing them around `ofNat`. This is not exhaustive, but is a step in the right direction. For now, I only target (some of) the declarations with a `See note [no_index around OfNat.ofNat]`. Some theorem statements have been corrected in passing.
PR summary 555c7f825cImport changes for modified filesNo significant changes to the import graph Import changes for all files
Declarations diff
You can run this locally as follows## summary with just the declaration names:
./scripts/declarations_diff.sh <optional_commit>
## more verbose report:
./scripts/declarations_diff.sh long <optional_commit> The doc-module for No changes to technical debt.You can run this locally as
|
This PR/issue depends on:
|
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.
Thanks for doing this clean-up! The diff does what is says. Somebody who knows this corner of mathlib needs to judge if this change is good.
@[to_additive (attr := simp)] | ||
theorem op_ofNat [NatCast α] (n : ℕ) [n.AtLeastTwo] : | ||
op (no_index (OfNat.ofNat n : α)) = OfNat.ofNat n := | ||
op (ofNat(n) : α) = ofNat(n) := |
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.
So, this is one example of fixing a theorem statement, right (as a no_index is also put on the RHS), right?
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.
Arguably this doesn't change the statement, only the indexing of the statement. The corrections I was referring to in the description are the ones where a missing OfNat.ofNat
is added.
@[simp] | ||
theorem sqrt_ofNat (n : ℕ) : Int.sqrt (no_index (OfNat.ofNat n) : ℤ) = Nat.sqrt (OfNat.ofNat n) := | ||
theorem sqrt_ofNat (n : ℕ) : Int.sqrt ofNat(n) = Nat.sqrt ofNat(n) := |
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.
Flagging: this is a change of theorem statement.
bors delegate+ Consider whether you want to wait until the next version release to clean up some of the workarounds. If not, please make a cleanup PR after it lands and ping me. Either way, please merge current master before adding to the queue. Thanks. |
✌️ eric-wieser can now approve this pull request. To approve and merge a pull request, simply reply with |
I think there is going to be a long tail of workarounds as we propagate this and discover more missing |
As this PR is labelled bors merge |
`ofNat(n)` is a shorthand for `no_index (OfNat.ofNat n)`. Its purpose is: * To make it easier to remember to write the `no_index` * To add a place to put a hoverable docstrings explaining the complexities * To make it easier to remove the `no_index`es in future if `DiscrTree`s stops needing them around `ofNat` (leanprover/lean4#2867). This is not exhaustive, but is a step in the right direction. For now, I only target (some of) the declarations with a `See note [no_index around OfNat.ofNat]`. Some theorem statements have been corrected in passing. This exposed two Lean bugs relating to not using `Expr.consumeMData`: * leanprover/lean4#6438 * leanprover/lean4#6467 These are made more likely by this PR adding `no_index` to the RHS of equalities, but were already possible to trigger by using `simp [<- _]` on existing theorems with `no_index` on the LHS.
Pull request successfully merged into master. Build succeeded! And happy new year! 🎉 |
ofNat(n)
is a shorthand forno_index (OfNat.ofNat n)
.Its purpose is:
no_index
no_index
es in future ifDiscrTree
s stops needing them aroundofNat
(DiscrTree doesn't match lemmas withOfNat.ofNat *
to nat literal keys leanprover/lean4#2867).This is not exhaustive, but is a step in the right direction.
For now, I only target (some of) the declarations with a
See note [no_index around OfNat.ofNat]
.Some theorem statements have been corrected in passing.
This exposed two Lean bugs relating to not using
Expr.consumeMData
:no_index
aroundOfNat.ofNat
innorm_cast
leanprover/lean4#6438Int.reduceNeg
simproc produces invalid proofs leanprover/lean4#6467These are made more likely by this PR adding
no_index
to the RHS of equalities, but were already possible to trigger by usingsimp [<- _]
on existing theorems withno_index
on the LHS.Nat.cast_eq_ofNat
#20168