Refactor: use Lebesgue integrals and non-negative divergence functions#174
Open
RemyDegenne wants to merge 89 commits intomasterfrom
Open
Refactor: use Lebesgue integrals and non-negative divergence functions#174RemyDegenne wants to merge 89 commits intomasterfrom
RemyDegenne wants to merge 89 commits intomasterfrom
Conversation
the old statement was false, I needed to add the hp `x ≠ ∞`, I also fixes the dependencies
`hadDeriv...` instead of `hasDeriv...`
I had strengthen the hp `0 ≤ x` to `0 < x`, with the former hp the result is false.
I had to add the hp `c = 0 → a ≠ 1`, because if `c = 0` and `a = 1` the result is false
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
New design for f-divergences
We change the definition of f-divergences to use functions
ℝ≥0∞ → ℝ≥0∞with specific properties bundled in a structure and Lebesgue integrals.Closes #154
Old design
Before the refactor, the definition of the f-divergence was as follows.
Then most results assumed that
fwas convex and continuous on[0,∞).Since
fis only used composed with a Radon-Nikodym derivative inf ((∂μ/∂ν) x).toReal, it would be more natural to useℝ≥0∞for its domain. But if we do so we lose the ability (in Mathlib) to talk about its derivatives, which is essential for some of our proofs. We thus settled forℝ. For the codomain, we usedℝin a Bochner integral with the idea that the divergence should be allowed to have negative values: the Kullback-Leibler divergence expressed as∫ x, llr μ ν x ∂μtakes negative values if the measures don't have the same total mass.Here are some issues with the current design:
fat zero,f 0 : ℝ. The math definition requires that the value at 0 should be equal to the limit offat 0 from the right. If the limit is finite that's fine, we can simply require thatfshould be continuous at 0. However, if the limit at 0 is infinite, our current definition cannot encode the math definition. That was not an issue until now but it prevents us from writing desirable statements like the invariance offDivby taking the "dual" off(see issue Skew symmetry ofhellingerDivshould be generalized #25 about generalizing skew symmetry).fDivtakes values inEReal, which is a pain to work with. We don't need the negative infinity though.New design
The new definition is this.
A
DivFunctionis defined as follows.derivAtTopis also redesigned to take values inℝ≥0∞.Why we can use
ℝ≥0∞ → ℝ≥0∞after allℝpreviously to be able to talk about derivatives and to use some convexity lemmas from Mathlib (notably Jensen). This is needed only in specific places. The new approach is to useℝ≥0∞ → ℝ≥0∞everywhere in integral computations and to define a functionf.realFun : ℝ → ℝfromfto use in the places where derivatives and convexity are needed:ℝ≥0∞to be able to integrate with Lebesgue integrals and not worry about integrability. That means that our f-divergences have to be nonnegative, and the KL definition discussed above cannot work. However, since any f-divergence (in the math sense) is invariant by addinga + b*(x-1)on probability measures, we can simply subtractf 1 + rightDeriv f 1 * (x - 1)from the function to turn it into another one with same f-divergence on probability measures, but for which the f-divergence is nonnegative for all finite measures. We choose to enforce that for our new definition of f-divergences through the fieldsoneandrightDerivOneofDivFunction.What we gain, what we lose
Gain:
ifto deal with integrability conditions, and don't have to have separate lemmas for the cases where the divergences are infinite.ℝ≥0∞instead ofEReal, which is a big gain in usability.Lose:
ℝ≥0∞.a = 0can't be an f-divergence any more because of its discontinuity at 0. We have to do a special case for it if we want to define it in the old way. Currently the new code has the split only at the level of the Rényi divergence.TODO
rightDeriv f.realFun 1 = 0is too restrictive. The conjugatex * f (1/x)will not be aDivFunctionunlessfactually has a derivative at 1 (because the right derivative of that one at 1 is the left derivative off). That's not the case for the function that gives TV for example. After the first refactor builds, we should replace that rightDeriv condition by a constraint on the subderivative :0 ∈ ∂f(1).