Skip to content
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

Closed
wants to merge 6 commits into from

Conversation

YaelDillies
Copy link
Collaborator

@YaelDillies YaelDillies commented Dec 15, 2022

We can cancel iterates of an injective function.


Match leanprover-community/mathlib4#1046

Open in Gitpod

@YaelDillies YaelDillies added the awaiting-review The author would like community review of the PR label Dec 15, 2022
Comment on lines 171 to 177
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
Copy link
Member

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

Copy link
Collaborator Author

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).

Copy link
Member

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?

Copy link
Collaborator Author

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

-- 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

Copy link
Collaborator

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?

Copy link
Collaborator Author

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.

Copy link
Member

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?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done

Copy link
Collaborator Author

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.

@sgouezel sgouezel added awaiting-author A reviewer has asked the author a question or requested changes and removed awaiting-review The author would like community review of the PR labels Dec 25, 2022
@YaelDillies YaelDillies added awaiting-review The author would like community review of the PR and removed awaiting-author A reviewer has asked the author a question or requested changes labels Dec 25, 2022
@eric-wieser
Copy link
Member

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.

@bors
Copy link

bors bot commented Dec 26, 2022

✌️ YaelDillies can now approve this pull request. To approve and merge a pull request, simply reply with bors r+. More detailed instructions are available here.

@github-actions github-actions bot added delegated The PR author may merge after reviewing final suggestions. and removed awaiting-review The author would like community review of the PR labels Dec 26, 2022
@YaelDillies
Copy link
Collaborator Author

mathlib4 PR approved

bors merge

bors bot pushed a commit that referenced this pull request Jan 6, 2023
We can cancel iterates of an injective function.
@bors
Copy link

bors bot commented Jan 6, 2023

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(logic/function/iterate): Cancelling iterates [Merged by Bors] - feat(logic/function/iterate): Cancelling iterates Jan 6, 2023
@bors bors bot closed this Jan 6, 2023
@YaelDillies YaelDillies deleted the iterate_cancel branch January 6, 2023 16:34
bors bot pushed a commit to leanprover-community/mathlib4 that referenced this pull request Jan 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
delegated The PR author may merge after reviewing final suggestions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants