feat(Probability/ProbabilityMassFunction): total variation distance and MetricSpace instance#35826
Conversation
d4dd027 to
2ad4f9d
Compare
PR summary 5e5be118ffImport changes for modified filesNo significant changes to the import graph Import changes for all files
|
…nd MetricSpace instance Made-with: Cursor
2ad4f9d to
fdf603e
Compare
|
|
||
| /-- Symmetric absolute difference in `ℝ≥0∞`, defined as `(a - b) + (b - a)`. | ||
| Satisfies `(absDiff a b).toReal = |a.toReal - b.toReal|` when both arguments are finite. -/ | ||
| protected noncomputable def absDiff (a b : ℝ≥0∞) : ℝ≥0∞ := (a - b) + (b - a) |
There was a problem hiding this comment.
Does this satisfy the axioms of an EMetricSpace? Could this be renamed edist and turned into an instance of that?
There was a problem hiding this comment.
I don't think we should as it would create a diamond. From Opus:
Good observation — absDiff does satisfy the EMetricSpace axioms (all four are proved in the file). However, the induced metric topology disagrees with the existing order topology on ℝ≥0∞: under absDiff, finite values are at infinite distance from ⊤ (since absDiff n ⊤ = ∞), so sequences like n → ∞ don't converge, unlike in the order topology. Since EMetricSpace extends TopologicalSpace, this would create a diamond. The absDiff is intended as a pointwise building block for PMF.etvDist, and the MetricSpace instance lives on PMF α where the topologies are consistent.
|
t-measure-probability |
- Update tsum_ite_eq call to new API (function + SummationFilter) - Remove unused [DecidableEq β] from etvDist_map_le, tvDist_map_le types - Use classical in proofs instead, per linter guidance Made-with: Cursor
Both AbsDiff.lean and TotalVariation.lean need the `module` declaration and `public import` to comply with the new module system. Made-with: Cursor
Declarations in module files are private by default in Lean 4.29. Add @[expose] public section to export all declarations. Made-with: Cursor
BoltonBailey
left a comment
There was a problem hiding this comment.
Seems like a good definition to have, and nice to get the data processing inequality too, thanks!
|
I don't think we should have this. Total variation should just be a special case of a more general definition for arbitrary measures (possibly based on MeasureTheory.VectorMeasure.variation). Moreover we are planning to move away from PMF to use directly sums of Dirac masses. |
Define total variation distance on probability mass functions, provide
a
MetricSpaceinstance, and prove the data processing inequality.The extended TV distance
PMF.etvDistis defined inℝ≥0∞as(1/2) ∑ x, absDiff (p x) (q x), using a new symmetric absolutedifference
ENNReal.absDiff. The real-valuedPMF.tvDistis itstoReal.New definitions:
ENNReal.absDiff: symmetric absolute difference(a - b) + (b - a)PMF.etvDist: extended total variation distancePMF.tvDist: real-valued total variation distancePMF.instMetricSpace:MetricSpaceinstance onPMF αMain results:
ENNReal.absDiff_triangle: triangle inequality forabsDiffENNReal.absDiff_tsum_le: subadditivity over infinite sumsPMF.etvDist_le_one: TV distance is at most 1PMF.etvDist_map_le: data processing inequality (deterministic maps)PMF.etvDist_bind_right_le: data processing inequality (Markov kernels)PMF.etvDist_option_punit: closed form for binary distributionsSupersedes #33680 with a complete, sorry-free implementation.
See Zulip discussion:
https://leanprover.zulipchat.com/#narrow/channel/217875-Is-there-code-for-X.3F/topic/total.20variation.20distance.20between.20two.20PMFs
This PR was authored with the support of Claude (Cursor IDE).
This PR provides a complete formalization of total variation distance for PMFs, including:
ENNReal.absDiff(Mathlib/Data/ENNReal/AbsDiff.lean): A symmetric absolute differencefor
ℝ≥0∞with triangle inequality, connection to real absolute value, and algebraic properties.The tsum-related lemmas (
absDiff_tsum_le,tsum_fiber) are placed in the TV distance fileto avoid pulling topology imports into
Data.ENNReal.PMF.etvDist/PMF.tvDist(Mathlib/Probability/ProbabilityMassFunction/TotalVariation.lean):Total variation distance with a
MetricSpaceinstance, data processing inequality for bothdeterministic maps and Markov kernels, and a closed form for binary distributions.
Compared to #33680, this PR:
sorrysℝ≥0∞first (following Mathlib convention foredist/dist)Made with Cursor