Download lean/OAI/Probability/PosteriorReplicas/Information/GraphKL.lean from roseking/openAI-math-dataset: direct link, hf CLI and curl.
- Browser
- Download file 4.93 kB
-
https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Probability/PosteriorReplicas/Information/GraphKL.lean
- Command line
-
hf download hf://datasets/roseking/openAI-math-dataset/lean/OAI/Probability/PosteriorReplicas/Information/GraphKL.lean
-
curl -L -o GraphKL.lean https://huggingface.co/datasets/roseking/openAI-math-dataset/resolve/main/lean/OAI/Probability/PosteriorReplicas/Information/GraphKL.lean
4.93 kB
Lean 4 · 9
declarations statementsfull
lemma klDiv_map_leftInverse {X Y : Type*} [MeasurableSpace X] [MeasurableSpace Y]
(μ ν : Measure X) [IsFiniteMeasure μ] [IsFiniteMeasure ν]
{f : X → Y} {g : Y → X} (hf : Measurable f) (hg : Measurable g)
(hgf : Function.LeftInverse g f) : klDiv (μ.map f) (ν.map f) = klDiv μ ν := by proof · 4 lines
apply le_antisymm (klDiv_map_le _ _ hf)
have h := klDiv_map_le (μ.map f) (ν.map f) hg
have he : g ∘ f = id := funext hgf
simpa only [Measure.map_map hg hf, he, Measure.map_id] using hlemma compProd_prod_right {Z X Y : Type*} [MeasurableSpace Z] [MeasurableSpace X] [MeasurableSpace Y]
(μ : Measure Z) [SFinite μ] (κ : Kernel Z X) [IsSFiniteKernel κ]
(ν : Measure Y) [SFinite ν] :
((μ ⊗ₘ κ).prod ν).map MeasurableEquiv.prodAssoc = μ ⊗ₘ (κ ×ₖ Kernel.const Z ν) := by proof · 5 lines
have hk : κ ×ₖ Kernel.const Z ν = κ ⊗ₖ Kernel.const (Z × X) ν := by
ext z s hs
rw [Kernel.prod_apply' _ _ _ hs, Kernel.compProd_apply hs]
rfl
rw [hk, ← Measure.compProd_const, Measure.compProd_assoc']def attachSide {X Y Z : Type*} [MeasurableSpace X] [MeasurableSpace Y] [MeasurableSpace Z]
(g : X → Z) (q : Measure (X × Y)) : Measure (Z × (X × Y)) := body · 1 line
q.map (fun z => (g z.1, z))instance attachSide_finite {X Y Z : Type*} [MeasurableSpace X] [MeasurableSpace Y] [MeasurableSpace Z]
(g : X → Z) (q : Measure (X × Y)) [IsFiniteMeasure q] :
IsFiniteMeasure (attachSide g q) := by body · 2 lines
unfold attachSide infer_instance
lemma attachSide_probability {X Y Z : Type*} [MeasurableSpace X] [MeasurableSpace Y] [MeasurableSpace Z]
{g : X → Z} (hg : Measurable g) (q : Measure (X × Y)) [IsProbabilityMeasure q] :
IsProbabilityMeasure (attachSide g q) := proof · 1 line
(Measure.isProbabilityMeasure_map_iff (by fun_prop)).mpr inferInstancelemma attachSide_first_pair {X Y Z : Type*} [MeasurableSpace X] [MeasurableSpace Y] [MeasurableSpace Z]
{g : X → Z} (hg : Measurable g) (q : Measure (X × Y)) :
(attachSide g q).map (fun z => (z.1,z.2.1)) = q.fst.map (fun x => (g x,x)) := by proof · 3 lines
unfold attachSide Measure.fst
rw [Measure.map_map (by fun_prop) (by fun_prop), Measure.map_map (by fun_prop) measurable_fst]
rfllemma compProd_condKernel_fst {Z X Y : Type*}
[MeasurableSpace Z] [MeasurableSpace X] [MeasurableSpace Y]
[StandardBorelSpace X] [StandardBorelSpace Y] [Nonempty X] [Nonempty Y]
(q : Measure (Z × (X × Y))) [IsFiniteMeasure q] :
q.fst ⊗ₘ q.condKernel.fst = q.map (fun z => (z.1,z.2.1)) := by proof · 2 lines
rw [Kernel.fst_eq, Measure.compProd_map measurable_fst, Measure.disintegrate q q.condKernel]
rfllemma attachSide_conditional_reference {X Y Z : Type*}
[MeasurableSpace X] [MeasurableSpace Y] [MeasurableSpace Z]
[StandardBorelSpace X] [StandardBorelSpace Y] [Nonempty X] [Nonempty Y]
{g : X → Z} (hg : Measurable g) (q : Measure (X × Y)) [IsProbabilityMeasure q]
(ν : Measure Y) [IsProbabilityMeasure ν] :
let r := attachSide g q proof · 11 lines
r.fst ⊗ₘ (r.condKernel.fst ×ₖ Kernel.const Z ν) = attachSide g (q.fst.prod ν) := by
let := attachSide_probability hg q
dsimp only
rw [← compProd_prod_right, compProd_condKernel_fst, attachSide_first_pair hg]
have hp : (q.fst.map (fun x => (g x,x))).prod ν =
(q.fst.prod ν).map (Prod.map (fun x => (g x,x)) id) := by
simpa only [Measure.map_id] using Measure.map_prod_map q.fst ν
(show Measurable (fun x => (g x,x)) by fun_prop) measurable_id
rw [hp]
rw [Measure.map_map (by fun_prop) (by fun_prop)]
rfllemma mutualInformation_attachSide_chain {X Y Z : Type*}
[MeasurableSpace X] [MeasurableSpace Y] [MeasurableSpace Z]
[StandardBorelSpace X] [StandardBorelSpace Y] [Nonempty X] [Nonempty Y]
{g : X → Z} (hg : Measurable g) (q : Measure (X × Y)) [IsProbabilityMeasure q] :
let r := attachSide g q proof · 18 lines
klDiv q (q.fst.prod q.snd) = cmi r +
klDiv (q.map (fun z => (g z.1,z.2))) ((q.fst.map g).prod q.snd) := by
let := attachSide_probability hg q
dsimp only
have h := klDiv_conditional_chain (attachSide g q) q.snd
rw [attachSide_conditional_reference hg] at h
have he : klDiv (attachSide g q) (attachSide g (q.fst.prod q.snd)) = klDiv q (q.fst.prod q.snd) :=
klDiv_map_leftInverse _ _ (by fun_prop) measurable_snd (fun _ => rfl)
rw [he] at h
have hf : (attachSide g q).fst = q.fst.map g := by
unfold attachSide Measure.fst
rw [Measure.map_map measurable_fst (by fun_prop), Measure.map_map hg measurable_fst]
rfl
have hy : (attachSide g q).map (fun z => (z.1,z.2.2)) =
q.map (fun z => (g z.1,z.2)) := by
rw [attachSide, Measure.map_map (by fun_prop) (by fun_prop)]
rfl
rwa [hf,hy] at hOutline