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] - feat(logic/function/iterate): Cancelling iterates #17956
Conversation
src/logic/function/iterate.lean
Outdated
lemma iterate_cancel_of_ge (hf : injective f) (hnm : n ≤ m) (ha : f^[m] a = (f^[n] a)) : | ||
f^[m - n] a = a := | ||
hf.iterate n $ by rwa [←iterate_add_apply, nat.add_sub_of_le hnm] | ||
|
||
lemma iterate_cancel_of_le (hf : injective f) (hmn : m ≤ n) (ha : f^[m] a = (f^[n] a)) : | ||
a = (f^[n - m]) a := | ||
(iterate_cancel_of_ge hf hmn ha.symm).symm |
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.
What are your thoughts on a spelling without sub
in the goal?
lemma iterate_cancel_of_iterate_add (hf : injective f) (ha : f^[m + n] a = (f^[n] a)) :
f^[m] a = a :=
sorry
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.
The entire point of this lemma is the sub
spelling, because rewriting m = n + (m - n)
is very hard in other contexts (there will be several occurrences of m
).
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.
I'm afraid I don't follow; can you give an example of hoow you intend to use thie lemma?
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.
Here is my use case
mathlib/src/combinatorics/additive/mathlib.lean
Lines 410 to 426 in 431a78f
-- TODO: Golfable if we had an API for the order of an element under a permutation | |
@[to_additive] lemma mem_stabilizer_finset' {s : finset β} : | |
a ∈ stabilizer α s ↔ ∀ ⦃b⦄, b ∈ s → a • b ∈ s := | |
begin | |
rw mem_stabilizer_finset, | |
refine ⟨λ h b, (h _).2, λ h b, ⟨λ hab, _, λ hb, h hb⟩⟩, | |
have : s.card < (finset.range (s.card + 1)).card := by simp, | |
obtain ⟨m, n, hmn, hb⟩ : ∃ m n, m < n ∧ (((•) a)^[m]) b = (((•) a)^[n]) b, | |
{ obtain ⟨m, -, n, -, hmn, hb⟩ := | |
finset.exists_ne_map_eq_of_card_lt_of_maps_to this (λ n hn, maps_to.iterate h n hab), | |
obtain hmn | hnm := (nat.succ_ne_succ.2 hmn).lt_or_lt, | |
{ exact ⟨_, _, hmn, hb⟩ }, | |
{ exact ⟨_, _, hnm, hb.symm⟩ } }, | |
rw [iterate_cancel_of_le (mul_action.injective _) hmn.le hb, | |
←tsub_add_cancel_of_le (nat.succ_le_iff.2 $ tsub_pos_of_lt hmn)], | |
exact maps_to.iterate h (n - m - 1) hab, | |
end |
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.
I think the sub spelling is useful, but the add version could be useful too - can we just have both?
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.
Here's one. I will update the mathlib4 PR once you're happy with it.
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.
Mind merging this new lemma into your branch linked above, so I can see if it leads to a shorter proof?
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.
Done
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.
I am not using this lemma in branch kneser
anymore. However, Sébastien's suggestion now justifies the sub spelling.
bors d+ I'm not super happy with the name "cancel" because the cancellation only disappears from one side; but have no other suggestions. Are either of these true as iffs (keeping injectivity as a hypothesis)? Thanks! Don't forget to adjust the forward port. |
✌️ YaelDillies can now approve this pull request. To approve and merge a pull request, simply reply with |
mathlib4 PR approved bors merge |
We can cancel iterates of an injective function.
Pull request successfully merged into master. Build succeeded: |
We can cancel iterates of an injective function.
Match leanprover-community/mathlib4#1046