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(data/multiset): add some lemmas about filter (eq x) #10626

Closed
wants to merge 3 commits into from

Conversation

Ruben-VandeVelde
Copy link
Collaborator


Open in Gitpod

@Ruben-VandeVelde Ruben-VandeVelde added the awaiting-review The author would like community review of the PR label Dec 5, 2021
Comment on lines 2164 to 2171
begin
ext a,
rw [count_repeat, count_filter],
simp_rw [eq_comm],
split_ifs with ha,
{ subst a },
{ refl }
end
Copy link
Member

Choose a reason for hiding this comment

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

A slight golf:

Suggested change
begin
ext a,
rw [count_repeat, count_filter],
simp_rw [eq_comm],
split_ifs with ha,
{ subst a },
{ refl }
end
begin
ext a,
rw [count_repeat, count_filter],
simp_rw [eq_comm, ←dif_eq_if],
congr' 1 with rfl,
refl,
end

up to you whether you think it's an improvement.

@@ -2152,6 +2160,20 @@ begin
simp only [count_repeat, eq_self_iff_true, if_true, card_repeat]},
end

lemma filter_eq (s : multiset α) (b : α) : s.filter (eq b) = repeat b (count b s) :=
Copy link
Member

Choose a reason for hiding this comment

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

Can you add a variant for (= b) too? Perhaps:

lemma filter_eq' (s : multiset α) (b : α) : s.filter (= b) = repeat b (count b s) :=
begin
  ext a,
  rw [count_repeat, count_filter],
  simp_rw [←dif_eq_if],
  congr' 1 with rfl,
  refl,
end

lemma filter_eq (s : multiset α) (b : α) : s.filter (eq b) = repeat b (count b s) :=
by { simp_rw [←filter_eq', eq_comm], congr }

which also saves needing eq_comm in both proofs.

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Thanks for the suggestion, it helped me find an even shorter proof with if_ctx_congr

@eric-wieser
Copy link
Member

bors d+

Thanks!

@bors
Copy link

bors bot commented Dec 5, 2021

✌️ Ruben-VandeVelde 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 5, 2021
@Ruben-VandeVelde
Copy link
Collaborator Author

bors merge

bors bot pushed a commit that referenced this pull request Dec 6, 2021


Co-authored-by: Eric <wieser.eric@gmail.com>
@bors
Copy link

bors bot commented Dec 6, 2021

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(data/multiset): add some lemmas about filter (eq x) [Merged by Bors] - feat(data/multiset): add some lemmas about filter (eq x) Dec 6, 2021
@bors bors bot closed this Dec 6, 2021
@bors bors bot deleted the multiset-lemmas branch December 6, 2021 21:05
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

2 participants