-
Notifications
You must be signed in to change notification settings - Fork 3
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
Refactor: use Lebesgue integrals and non-negative divergence functions #174
Open
RemyDegenne
wants to merge
89
commits into
master
Choose a base branch
from
ennreal
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains 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
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
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
f
was convex and continuous on[0,∞)
.Since
f
is 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:
f
at zero,f 0 : ℝ
. The math definition requires that the value at 0 should be equal to the limit off
at 0 from the right. If the limit is finite that's fine, we can simply require thatf
should 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 offDiv
by taking the "dual" off
(see issue Skew symmetry ofhellingerDiv
should be generalized #25 about generalizing skew symmetry).fDiv
takes 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
DivFunction
is defined as follows.derivAtTop
is 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 : ℝ → ℝ
fromf
to 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 fieldsone
andrightDerivOne
ofDivFunction
.What we gain, what we lose
Gain:
if
to 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 = 0
can'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 = 0
is too restrictive. The conjugatex * f (1/x)
will not be aDivFunction
unlessf
actually 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)
.