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(measure_theory/probability_mass_function): Add definitions for filtering pmfs on a predicate #6033
Conversation
…iltering pmfs on a predicate
I would like to be able to loosen the |
Indeed you can remove completely the fintype assumption. Your lemma |
I ended up using |
def filter (p : pmf α) (s : set α) (h : ∃ a ∈ s, p a ≠ 0) : pmf α := | ||
pmf.normalize (s.indicator p) $ nnreal.tsum_indicator_ne_zero p.2.summable h | ||
|
||
lemma filter_apply (p : pmf α) {s : set α} {h : ∃ a ∈ s, p a ≠ 0} {a : α} : |
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 h
and a
parameters should be explicit here, as they can not be inferred from anything. If you want to rewrite, this is not a problem (rw filter_apply
will work just fine), but if you want to do something else being able to specify the parameters may help. Same thing in all the other lemmas: a parameter should be implicit only when it can be inferred from subsequent parameters.
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 had assumed it was also fine if the parameter could be inferred from the return type, but I see how that could cause issues if multiple patterns in the target match the return type. I've changed these all to be explicit now.
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.
Almost there! I have left a final minor comment. Once you're done with it, you can merge yourself.
bors d+
end | ||
|
||
lemma filter_apply_ne_zero_iff (p : pmf α) {s : set α} (h : ∃ a ∈ s, p a ≠ 0) (a : α) : | ||
(p.filter s h) a ≠ 0 ↔ a ∈ p.support ∧ a ∈ s := |
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.
can you write the right hand side as being a member of the intersection? Also, this lemma and the previous one would be good simp lemmas.
✌️ dtumad can now approve this pull request. To approve and merge a pull request, simply reply with |
bors r+ |
…iltering pmfs on a predicate (#6033)
Pull request successfully merged into master. Build succeeded: |
…iltering pmfs on a predicate (#6033)
No description provided.