Skip to content

feat(Probability/Posterior): Posterior PMFs and Various Lemmas#37938

Open
SamuelSchlesinger wants to merge 5 commits intoleanprover-community:masterfrom
SamuelSchlesinger:master
Open

feat(Probability/Posterior): Posterior PMFs and Various Lemmas#37938
SamuelSchlesinger wants to merge 5 commits intoleanprover-community:masterfrom
SamuelSchlesinger:master

Conversation

@SamuelSchlesinger
Copy link
Copy Markdown

Upstreaming the probability lemmas needed in leanprover/cslib#464.

@github-actions github-actions bot added the new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! label Apr 11, 2026
@github-actions
Copy link
Copy Markdown

Welcome new contributor!

Thank you for contributing to Mathlib! If you haven't done so already, please review our contribution guidelines, as well as the style guide and naming conventions. In particular, we kindly remind contributors that we have guidelines regarding the use of AI when making pull requests.

We use a review queue to manage reviews. If your PR does not appear there, it is probably because it is not successfully building (i.e., it doesn't have a green checkmark), has the awaiting-author tag, or another reason described in the Lifecycle of a PR. The review dashboard has a dedicated webpage which shows whether your PR is on the review queue, and (if not), why.

If you haven't already done so, please come to https://leanprover.zulipchat.com/, introduce yourself, and mention your new PR.

Thank you again for joining our community.

@github-actions
Copy link
Copy Markdown

github-actions bot commented Apr 11, 2026

PR summary c27c098f0d

Import changes for modified files

No significant changes to the import graph

Import changes for all files
Files Import difference
Mathlib.Probability.ProbabilityMassFunction.Posterior (new file) 1517

Declarations diff

+ joint
+ joint_apply
+ mem_support_joint_iff
+ mem_support_posterior_iff
+ posterior
+ posterior_apply
+ posterior_hasSum
+ support_joint
+ support_posterior
+ tsum_joint_fst
+ tsum_joint_snd

You can run this locally as follows
## summary with just the declaration names:
./scripts/pr_summary/declarations_diff.sh <optional_commit>

## more verbose report:
./scripts/pr_summary/declarations_diff.sh long <optional_commit>

The doc-module for scripts/pr_summary/declarations_diff.sh contains some details about this script.


No changes to technical debt.

You can run this locally as

./scripts/reporting/technical-debt-metrics.sh pr_summary
  • The relative value is the weighted sum of the differences with weight given by the inverse of the current value of the statistic.
  • The absolute value is the relative value divided by the total sum of the inverses of the current values (i.e. the weighted average of the differences).

@github-actions github-actions bot added the t-measure-probability Measure theory / Probability theory label Apr 11, 2026
Define `PMF.joint p f` as the joint distribution on `α × β` induced by
a prior `p : PMF α` and a family of distributions `f : α → PMF β`.

Prove `PMF.joint_apply`: evaluating the joint at `(a, b)` gives `p a * f a b`.
Prove `PMF.tsum_joint_fst`: summing the joint distribution over the
first component recovers the marginal `(p.bind f) b`.
Define `PMF.posterior p f b hb` as the posterior distribution `Pr[A = a | B = b]`
given a prior `p`, a family of distributions `f`, and that `b` is in the
support of the marginal `p.bind f`.

Prove `PMF.posterior_hasSum` (posterior probabilities sum to 1) and
`PMF.posterior_apply` (simp lemma for evaluation).
Shorten `joint_apply` by inlining `tsum_eq_single` side conditions.
Shorten `posterior_hasSum` by using `ENNReal.summable.hasSum_iff.2`
instead of intermediate `have` bindings.
Add support lemmas, second marginalization, use `map` in `joint`
definition, expand `posterior_apply` to show the Bayes formula
directly, and document relationship to `Kernel.Posterior`.
@SamuelSchlesinger
Copy link
Copy Markdown
Author

Accidentally closed. I believe the previous CI fail wasn't related to this PR, but I've rebased on master so we'll see :)

@EtienneC30
Copy link
Copy Markdown
Member

EtienneC30 commented Apr 16, 2026

There is ongoing work to deprecate PMF (see https://leanprover.zulipchat.com/#narrow/channel/113489-new-members/topic/generic.20shannon.20entropy.20formalization.20mathlib4/near/584361371), so this can't be added. Also are you aware of ProbabilityTheory.posterior? You should use this definition and provide your results for measures that are sums of Dirac masses.

@EtienneC30 EtienneC30 added the awaiting-author A reviewer has asked the author a question or requested changes. label Apr 16, 2026
@SamuelSchlesinger
Copy link
Copy Markdown
Author

This is very helpful context! I will go back to the drawing board for the cslib work we just merged using it.

Thank you.

@SamuelSchlesinger
Copy link
Copy Markdown
Author

There's a lot of discussion going on in the Zulip, planning to leave this open while we discuss: #CSLib > PMF monad and discrete probability. Let me know if I should just close it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

awaiting-author A reviewer has asked the author a question or requested changes. new-contributor This PR was made by a contributor with at most 5 merged PRs. Welcome to the community! t-measure-probability Measure theory / Probability theory

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants