[Merged by Bors] - chore(PartENat): golf and improve ofNat support#8002
Closed
[Merged by Bors] - chore(PartENat): golf and improve ofNat support#8002
ofNat support#8002Conversation
Closed
1 task
Member
|
!bench |
Collaborator
|
Here are the benchmark results for commit fb7f2f8. Benchmark Metric Change
================================================================================
+ ~Mathlib.Analysis.NormedSpace.Multilinear instructions -2.5%
+ ~Mathlib.LinearAlgebra.FreeModule.PID instructions -5.6%
+ ~Mathlib.RepresentationTheory.GroupCohomology.Resolution instructions -3.4% |
eric-wieser
reviewed
Nov 2, 2023
eric-wieser
reviewed
Nov 2, 2023
Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
These can be inferred by `[StrictOrderedSemiring R]`.
|
This PR/issue depends on: |
eric-wieser
reviewed
Nov 8, 2023
eric-wieser
reviewed
Nov 8, 2023
Member
|
bors d+ Pleaes merge once CI passes. Thanks, and sorry for letting this sit for a little. |
Contributor
|
✌️ timotree3 can now approve this pull request. To approve and merge a pull request, simply reply with |
Member
|
bors merge |
Member
|
!bench |
Collaborator
|
Here are the benchmark results for commit 385cee0. Benchmark Metric Change
================================================================================
+ ~Mathlib.LinearAlgebra.FreeModule.PID instructions -9.5%
- ~Mathlib.RepresentationTheory.GroupCohomology.Resolution instructions 1.9% |
mathlib-bors bot
pushed a commit
that referenced
this pull request
Nov 8, 2023
This PR adds simp lemmas for `OfNat.ofNat n : PartENat`, `0 : PartENat`, and `1 : PartENat` in every place where there was a simp lemma for `((n : ℕ) : PartENat)`. This is necessary for simp confluence in the presence of lemmas such as `Nat.cast_ofNat`. In addition, instances for `CharZero` and `ZeroLEOneClass` are provided so that the lemmas from `Data/Nat/Cast/Order.lean` will apply, golfing some proofs. Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
Contributor
|
Pull request successfully merged into master. Build succeeded: |
ofNat supportofNat support
grunweg
pushed a commit
that referenced
this pull request
Dec 15, 2023
This PR adds simp lemmas for `OfNat.ofNat n : PartENat`, `0 : PartENat`, and `1 : PartENat` in every place where there was a simp lemma for `((n : ℕ) : PartENat)`. This is necessary for simp confluence in the presence of lemmas such as `Nat.cast_ofNat`. In addition, instances for `CharZero` and `ZeroLEOneClass` are provided so that the lemmas from `Data/Nat/Cast/Order.lean` will apply, golfing some proofs. Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
mathlib-bors bot
pushed a commit
that referenced
this pull request
Feb 26, 2024
…sts (#8006) I loogled for every occurrence of `"cast", Nat` and `"natCast"` and where the casted nat was `n`, and made sure there were corresponding `@[simp]` lemmas for `0`, `1`, and `OfNat.ofNat n`. This is necessary in general for simp confluence. Example: ```lean import Mathlib variable {α : Type*} [LinearOrderedRing α] (m n : ℕ) [m.AtLeastTwo] [n.AtLeastTwo] example : ((OfNat.ofNat m : ℕ) : α) ≤ ((OfNat.ofNat n : ℕ) : α) ↔ (OfNat.ofNat m : ℕ) ≤ (OfNat.ofNat n : ℕ) := by simp only [Nat.cast_le] -- this `@[simp]` lemma can apply example : ((OfNat.ofNat m : ℕ) : α) ≤ ((OfNat.ofNat n : ℕ) : α) ↔ (OfNat.ofNat m : α) ≤ (OfNat.ofNat n : α) := by simp only [Nat.cast_ofNat] -- and so can this one example : (OfNat.ofNat m : α) ≤ (OfNat.ofNat n : α) ↔ (OfNat.ofNat m : ℕ) ≤ (OfNat.ofNat n : ℕ) := by simp -- fails! `simp` doesn't have a lemma to bridge their results. confluence issue. ``` As far as I know, the only file this PR leaves with `ofNat` gaps is `PartENat.lean`. #8002 is addressing that file in parallel. Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
riccardobrasca
pushed a commit
that referenced
this pull request
Mar 1, 2024
…sts (#8006) I loogled for every occurrence of `"cast", Nat` and `"natCast"` and where the casted nat was `n`, and made sure there were corresponding `@[simp]` lemmas for `0`, `1`, and `OfNat.ofNat n`. This is necessary in general for simp confluence. Example: ```lean import Mathlib variable {α : Type*} [LinearOrderedRing α] (m n : ℕ) [m.AtLeastTwo] [n.AtLeastTwo] example : ((OfNat.ofNat m : ℕ) : α) ≤ ((OfNat.ofNat n : ℕ) : α) ↔ (OfNat.ofNat m : ℕ) ≤ (OfNat.ofNat n : ℕ) := by simp only [Nat.cast_le] -- this `@[simp]` lemma can apply example : ((OfNat.ofNat m : ℕ) : α) ≤ ((OfNat.ofNat n : ℕ) : α) ↔ (OfNat.ofNat m : α) ≤ (OfNat.ofNat n : α) := by simp only [Nat.cast_ofNat] -- and so can this one example : (OfNat.ofNat m : α) ≤ (OfNat.ofNat n : α) ↔ (OfNat.ofNat m : ℕ) ≤ (OfNat.ofNat n : ℕ) := by simp -- fails! `simp` doesn't have a lemma to bridge their results. confluence issue. ``` As far as I know, the only file this PR leaves with `ofNat` gaps is `PartENat.lean`. #8002 is addressing that file in parallel. Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
dagurtomas
pushed a commit
that referenced
this pull request
Mar 22, 2024
…sts (#8006) I loogled for every occurrence of `"cast", Nat` and `"natCast"` and where the casted nat was `n`, and made sure there were corresponding `@[simp]` lemmas for `0`, `1`, and `OfNat.ofNat n`. This is necessary in general for simp confluence. Example: ```lean import Mathlib variable {α : Type*} [LinearOrderedRing α] (m n : ℕ) [m.AtLeastTwo] [n.AtLeastTwo] example : ((OfNat.ofNat m : ℕ) : α) ≤ ((OfNat.ofNat n : ℕ) : α) ↔ (OfNat.ofNat m : ℕ) ≤ (OfNat.ofNat n : ℕ) := by simp only [Nat.cast_le] -- this `@[simp]` lemma can apply example : ((OfNat.ofNat m : ℕ) : α) ≤ ((OfNat.ofNat n : ℕ) : α) ↔ (OfNat.ofNat m : α) ≤ (OfNat.ofNat n : α) := by simp only [Nat.cast_ofNat] -- and so can this one example : (OfNat.ofNat m : α) ≤ (OfNat.ofNat n : α) ↔ (OfNat.ofNat m : ℕ) ≤ (OfNat.ofNat n : ℕ) := by simp -- fails! `simp` doesn't have a lemma to bridge their results. confluence issue. ``` As far as I know, the only file this PR leaves with `ofNat` gaps is `PartENat.lean`. #8002 is addressing that file in parallel. Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
xgenereux
pushed a commit
that referenced
this pull request
Apr 15, 2024
…sts (#8006) I loogled for every occurrence of `"cast", Nat` and `"natCast"` and where the casted nat was `n`, and made sure there were corresponding `@[simp]` lemmas for `0`, `1`, and `OfNat.ofNat n`. This is necessary in general for simp confluence. Example: ```lean import Mathlib variable {α : Type*} [LinearOrderedRing α] (m n : ℕ) [m.AtLeastTwo] [n.AtLeastTwo] example : ((OfNat.ofNat m : ℕ) : α) ≤ ((OfNat.ofNat n : ℕ) : α) ↔ (OfNat.ofNat m : ℕ) ≤ (OfNat.ofNat n : ℕ) := by simp only [Nat.cast_le] -- this `@[simp]` lemma can apply example : ((OfNat.ofNat m : ℕ) : α) ≤ ((OfNat.ofNat n : ℕ) : α) ↔ (OfNat.ofNat m : α) ≤ (OfNat.ofNat n : α) := by simp only [Nat.cast_ofNat] -- and so can this one example : (OfNat.ofNat m : α) ≤ (OfNat.ofNat n : α) ↔ (OfNat.ofNat m : ℕ) ≤ (OfNat.ofNat n : ℕ) := by simp -- fails! `simp` doesn't have a lemma to bridge their results. confluence issue. ``` As far as I know, the only file this PR leaves with `ofNat` gaps is `PartENat.lean`. #8002 is addressing that file in parallel. Co-authored-by: Eric Wieser <wieser.eric@gmail.com>
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 adds simp lemmas for
OfNat.ofNat n : PartENat,0 : PartENat, and1 : PartENatin every place where there was a simp lemma for((n : ℕ) : PartENat). This is necessary for simp confluence in the presence of lemmas such asNat.cast_ofNat. In addition, instances forCharZeroandZeroLEOneClassare provided so that the lemmas fromData/Nat/Cast/Order.leanwill apply, golfing some proofs.[Nontrivial R]#8129