Repository navigation
Conversation
…ted` and `cyclicPermutations`
PR summary 570ff68990Import changes for modified filesNo significant changes to the import graph Import changes for all files
Declarations diffNo declarations were harmed in the making of this PR! 🐙 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
|
| @[simp] | ||
| theorem getElem_rotate (l : List α) (n : ℕ) (k : Nat) (h : k < (l.rotate n).length) : | ||
| (l.rotate n)[k] = | ||
| l[(k + n) % l.length]'(mod_lt _ (length_rotate l n ▸ k.zero_le.trans_lt h)) := by |
There was a problem hiding this comment.
This is the only one I'm not entirely sure if this is a simp-lemma, and if it should be a simp-lemma, why is getElem?_rotate above not marked as simp?
There was a problem hiding this comment.
Sorry for the slow reply — I got pulled away for a while.
In an earlier revision of this PR, I had marked both getElem_rotate and getElem?_rotate (and also rotate'_nil) with [simp]. That revision did not pass Mathlib CI, so in a follow-up I removed [simp] from getElem?_rotate and rotate'_nil, but kept [simp] on getElem_rotate.
I still think [simp] on getElem_rotate is reasonable: it is a normalization lemma for defined indexing, rewriting (l.rotate n)[k] to indexing on l, i.e. it eliminates rotate from getElem terms.
By contrast, getElem?_rotate requires the side condition m < l.length. That extra hypothesis is often not available to simp, so using it as a global simp rule is less robust and can make simp behavior less predictable. This is similar to the pattern in List.Iterate, where getElem_iterate is [simp] but getElem?_iterate is not.
I will also update the PR description so it matches the final code state.
There was a problem hiding this comment.
I see, the LHS of getElem?_rotate is not in simp-NF, and there is the simp lemma getElem?_pos : c[i]? = some (c[i]'h) which takes care of the getElem?. (which the simpNF linter reports) 👍
As for rotate'_simp it does not need to be simp as "simp can prove this"
There was a problem hiding this comment.
Pull request overview
This PR adds @[simp] attributes to several theorems in Mathlib/Data/List/Rotate.lean to improve automation when working with list rotations. The changes allow the simplifier to automatically apply these lemmas when simplifying expressions involving rotated lists.
Changes:
- Added
@[simp]to 7 theorems involving list rotation operations - Enables automatic simplification of nested rotations, modulo operations, indexing, and functor laws
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
joneugster
left a comment
There was a problem hiding this comment.
Thank you for the PR and thank you for updating the PR description!
Remember to comment
-awaiting-author
on the PR once you addressed all comments to ensure reviewers see the PR again!
I suggest
maintainer merge
| @[simp] | ||
| theorem getElem_rotate (l : List α) (n : ℕ) (k : Nat) (h : k < (l.rotate n).length) : | ||
| (l.rotate n)[k] = | ||
| l[(k + n) % l.length]'(mod_lt _ (length_rotate l n ▸ k.zero_le.trans_lt h)) := by |
There was a problem hiding this comment.
I see, the LHS of getElem?_rotate is not in simp-NF, and there is the simp lemma getElem?_pos : c[i]? = some (c[i]'h) which takes care of the getElem?. (which the simpNF linter reports) 👍
As for rotate'_simp it does not need to be simp as "simp can prove this"
|
🚀 Pull request has been placed on the maintainer queue by joneugster. |
|
-awaiting-author |
* Refs #7987 (SC: Data/List/Rotate) * Add `@[simp]` to: `rotate_mod`, `rotate'_rotate'`, `rotate'_mod`, `rotate_rotate`, `getElem_rotate`, `head?_rotate`, `map_rotate`. * Verification: `lake build Mathlib.Data.List.Rotate`. Co-authored-by: Junye Ji <[email protected]>
|
Pull request successfully merged into master. Build succeeded: |
) * Refs leanprover-community#7987 (SC: Data/List/Rotate) * Add `@[simp]` to: `rotate_mod`, `rotate'_rotate'`, `rotate'_mod`, `rotate_rotate`, `getElem_rotate`, `head?_rotate`, `map_rotate`. * Verification: `lake build Mathlib.Data.List.Rotate`. Co-authored-by: Junye Ji <[email protected]>
) * Refs leanprover-community#7987 (SC: Data/List/Rotate) * Add `@[simp]` to: `rotate_mod`, `rotate'_rotate'`, `rotate'_mod`, `rotate_rotate`, `getElem_rotate`, `head?_rotate`, `map_rotate`. * Verification: `lake build Mathlib.Data.List.Rotate`. Co-authored-by: Junye Ji <[email protected]>
) * Refs leanprover-community#7987 (SC: Data/List/Rotate) * Add `@[simp]` to: `rotate_mod`, `rotate'_rotate'`, `rotate'_mod`, `rotate_rotate`, `getElem_rotate`, `head?_rotate`, `map_rotate`. * Verification: `lake build Mathlib.Data.List.Rotate`. Co-authored-by: Junye Ji <[email protected]>
@[simp]to:rotate_mod,rotate'_rotate',rotate'_mod,rotate_rotate,getElem_rotate,head?_rotate,map_rotate.lake build Mathlib.Data.List.Rotate.