-
Notifications
You must be signed in to change notification settings - Fork 297
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/basic): Add decidable_nonempty
for finsets.
#15170
Conversation
Not sure if this failure is related to the commit or not. |
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 failure is caused by this application of tauto
:
mathlib/src/algebra/big_operators/basic.lean
Line 1189 in 05a33f9
have y = x ∨ y = g x hx, by simp [hy] at hy₁; tauto, |
Replacing it with sorry
makes the error go away.
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.
This seems like a better proof to me:
instance _root_.multiset.decidable_exists_mem {P : α → Prop} [decidable_pred P] (m : multiset α) :
decidable (∃ a ∈ m, P a) :=
quotient.rec_on_subsingleton m list.decidable_exists_mem
instance decidable_exists_mem {P : α → Prop} [decidable_pred P] (s : finset α) :
decidable (∃ a ∈ s, P a) :=
s.val.decidable_exists_mem
instance decidable_nonempty {s : finset α} : decidable (s.nonempty) :=
decidable_of_iff (∃ a ∈ s, true) $ by simp_rw [exists_prop, and_true, finset.nonempty]
where obviously the multiset
instance belongs in another file.
I also added I could also add nonempty lemmas for list. Also, the forall and exists lemmas for list are in a very odd place - so I could move them somewhere more appropriate. What do you think? |
Since you were able to put the new lemmas in the right place without any import trouble, I don't think moving the list lemmas is worth the effort. This looks good now - can you update the PR description? |
finset
and multiset
.
Description updated. |
PR title also doesn't match the commit guidelines (it's missing the prefix) |
Oh bother. Should it be feat(data/finset/basic) (despite the multiset lemmas?) |
finset
and multiset
.finset
and multiset
.
Shall I remove these duplicate instances and just push |
@linesthatinterlace: Please do; removing the existing |
finset
and multiset
.decidable_nonempty
for finsets.
Done; let's see if removing those causes any build issues... |
Yes: counter to what @YaelDillies said, the list versions do appear to be used. Do we have the dependent list versions? |
We have |
The dependent |
No, I think they might use |
Current state:
I am, if I am honest, unsure what we "should" have for each of these, and what they should be called. Do we want |
Note that my last comment should really wait for another PR. This one is now ready to go, I think - the total changes just remove the list instances we don't need and adds decidable_nonempty. @eric-wieser, are you now happy? |
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.
Looks good to me, thanks. Please remove the parentheses, then feel free to merge.
bors d+
✌️ linesthatinterlace can now approve this pull request. To approve and merge a pull request, simply reply with |
Co-authored-by: Kyle Miller <kmill31415@gmail.com>
bors r+ |
Also remove some redundant decidable instances in multiset and list. Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Wrenna Robson <34025592+linesthatinterlace@users.noreply.github.com>
Pull request successfully merged into master. Build succeeded: |
decidable_nonempty
for finsets.decidable_nonempty
for finsets.
Also remove some redundant decidable instances in multiset and list. Co-authored-by: Eric Wieser <wieser.eric@gmail.com> Co-authored-by: Wrenna Robson <34025592+linesthatinterlace@users.noreply.github.com>
Also remove some redundant decidable instances in multiset and list.
Note: as we have the nonempty predicate, we can define a decidable instance for it without worrying about diamond issues. This is always possible, even if there is no decidable equality on the underlying type.