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/finset): add card_insert_of_mem #3137

Closed
wants to merge 2 commits into from

Conversation

kbuzzard
Copy link
Member


A Zulip user was asking where this function was; they found card_insert_of_not_mem. Note that insert_eq_of_mem is strictly stronger (the cardinalities are equal because the finsets are equal). Is this worth putting in the library?

@kbuzzard kbuzzard added the awaiting-review The author would like community review of the PR label Jun 22, 2020
@robertylewis robertylewis changed the title feat(data.finset): add card_insert_of_mem feat(data/finset): add card_insert_of_mem Jun 22, 2020
@@ -1395,6 +1395,9 @@ by cases s; simp only [multiset.card_eq_one, finset.card, ← val_inj, singleton
by simpa only [card_cons, card, insert_val] using
congr_arg multiset.card (ndinsert_of_not_mem h)

@[simp] theorem card_insert_of_mem [decidable_eq α] {a : α} {s : finset α}
Copy link
Member

Choose a reason for hiding this comment

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

I think this shouldn't be a simp lemma because insert_eq_of_mem is already. This is proved by simp [h]. @gebner should the linter have caught this, or does it not do conditional rules?

Copy link
Member Author

Choose a reason for hiding this comment

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

I am unfortunately still showing my ignorance of how simp works. I think that I used to tag nothing with simp, and now I tag everything! But I do understand "we will not gain anything by telling the simplifier this, because in every case when it can apply, something else (a bit simpler) also applies". I'll remove the tag.

Copy link
Member

Choose a reason for hiding this comment

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

@robertylewis Conditional rules are out-of-scope, yes. We still check that the lhs is in simp normal-form though.

Copy link
Member

Choose a reason for hiding this comment

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

I am unfortunately still showing my ignorance of how simp works. I think that I used to tag nothing with simp, and now I tag everything! But I do understand "we will not gain anything by telling the simplifier this, because in every case when it can apply, something else (a bit simpler) also applies". I'll remove the tag.

There's a difference between "unconditional" and "conditional" simp rules. This one is conditional, because of the hypothesis a ∈ s. If the rewrite rule matches, then simp will try to prove a ∈ s, and only go ahead with the original rewrite if this succeeds.

The linter that checks for

we will not gain anything by telling the simplifier this,

doesn't handle conditional rules, so it didn't notice the issue here.

@robertylewis
Copy link
Member

The CI failure looks like a GitHub glitch, so,

bors merge

@github-actions github-actions bot added ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.) and removed awaiting-review The author would like community review of the PR labels Jun 22, 2020
bors bot pushed a commit that referenced this pull request Jun 22, 2020
@bors
Copy link

bors bot commented Jun 22, 2020

Pull request successfully merged into master.

Build succeeded:

@bors bors bot changed the title feat(data/finset): add card_insert_of_mem [Merged by Bors] - feat(data/finset): add card_insert_of_mem Jun 22, 2020
@bors bors bot closed this Jun 22, 2020
@bors bors bot deleted the card-insert-of-mem branch June 22, 2020 21:51
cipher1024 pushed a commit to cipher1024/mathlib that referenced this pull request Mar 15, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
ready-to-merge All that is left is for bors to build and merge this PR. (Remember you need to say `bors r+`.)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants