File size: 12,532 Bytes
760f90e | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Positivity
import OAI.Computability.UniqueGames.Decoding.UniformConditioning
import OAI.Computability.UniqueGames.Foundations.Conditioning
import OAI.Computability.UniqueGames.Foundations.MixtureLemmas
namespace OAI
section
namespace UniqueGamesTheorem.Decoder.VisibleTransfer
open UniqueGamesTheorem.Foundations.Games
open scoped BigOperators
noncomputable section
variable {Ω D : Type*} [Fintype Ω] [Fintype D]
/-- The part of an event in one actual visible-data fiber. -/
def fiberEvent (observe : Ω → D) (d : D) (event : Ω → Bool) : Ω → Bool := by
classical
exact fun x => decide (observe x = d) && event x
def fiberMass (μ : FiniteDistribution Ω) (observe : Ω → D)
(d : D) (event : Ω → Bool) : ℝ :=
μ.probability (fiberEvent observe d event)
omit [Fintype D] in
theorem fiberMass_nonnegative (μ : FiniteDistribution Ω) (observe : Ω → D)
(d : D) (event : Ω → Bool) : 0 ≤ fiberMass μ observe d event :=
μ.probability_nonnegative _
omit [Fintype D] in
theorem fiberMass_mono (μ : FiniteDistribution Ω) (observe : Ω → D)
(d : D) {event event' : Ω → Bool}
(h : ∀ x, event x = true → event' x = true) :
fiberMass μ observe d event ≤ fiberMass μ observe d event' := by
apply μ.probability_mono
intro x hx
simp only [fiberEvent, Bool.and_eq_true, decide_eq_true_eq] at hx ⊢
exact ⟨hx.1, h x hx.2⟩
theorem sum_fiberMass (μ : FiniteDistribution Ω) (observe : Ω → D)
(event : Ω → Bool) :
∑ d, fiberMass μ observe d event = μ.probability event := by
classical
unfold fiberMass FiniteDistribution.probability fiberEvent
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro x _
cases event x <;> simp
theorem observation_weight (μ : FiniteDistribution Ω) (observe : Ω → D) (d : D) :
(μ.pushforward observe).weight d = fiberMass μ observe d (fun _ => true) := by
classical
simp [FiniteDistribution.pushforward, fiberMass, FiniteDistribution.probability,
fiberEvent]
/-- Positive projected column-slice mass and sufficient conditional target
agreement. Both quantities are computed after fixing actual visible data. -/
def visibleWitness (μ : FiniteDistribution Ω) (observe : Ω → D)
(slice targetHit : Ω → Bool) (threshold : ℝ) (d : D) : Bool := by
classical
exact decide (0 < fiberMass μ observe d slice ∧
threshold * fiberMass μ observe d slice ≤
fiberMass μ observe d (fun x => slice x && targetHit x))
/-- The positive part of the witness margin is paid for by the probability of
the actual observed data, rather than by the larger hidden sample space. -/
theorem witness_margin_le_visible_probability
(μ : FiniteDistribution Ω) (observe : Ω → D)
(slice targetHit : Ω → Bool) (threshold : ℝ) (hthreshold : 0 ≤ threshold) :
μ.probability (fun x => slice x && targetHit x) - threshold * μ.probability slice ≤
(μ.pushforward observe).probability (visibleWitness μ observe slice targetHit threshold) := by
classical
have pointwise (d : D) :
fiberMass μ observe d (fun x => slice x && targetHit x) -
threshold * fiberMass μ observe d slice ≤
if visibleWitness μ observe slice targetHit threshold d then
(μ.pushforward observe).weight d else 0 := by
have hs := fiberMass_nonnegative μ observe d slice
have hm := fiberMass_nonnegative μ observe d (fun x => slice x && targetHit x)
have hms : fiberMass μ observe d (fun x => slice x && targetHit x) ≤
fiberMass μ observe d slice := by
apply fiberMass_mono
intro x hx
simp only [Bool.and_eq_true] at hx
exact hx.1
have hmo : fiberMass μ observe d (fun x => slice x && targetHit x) ≤
(μ.pushforward observe).weight d := by
rw [observation_weight]
exact fiberMass_mono μ observe d (fun _ _ => rfl)
by_cases hgood : visibleWitness μ observe slice targetHit threshold d = true
· simp only [hgood, ↓reduceIte]
exact (sub_le_self _ (mul_nonneg hthreshold hs)).trans hmo
· simp only [hgood, Bool.false_eq_true, ↓reduceIte]
by_cases hpos : 0 < fiberMass μ observe d slice
· have hnot : ¬ threshold * fiberMass μ observe d slice ≤
fiberMass μ observe d (fun x => slice x && targetHit x) := by
intro hle
exact hgood (by simp [visibleWitness, hpos, hle])
linarith
· have hzero : fiberMass μ observe d slice = 0 := le_antisymm (le_of_not_gt hpos) hs
rw [hzero, mul_zero, sub_zero]
exact hms.trans_eq hzero
have hsum := Finset.sum_le_sum (s := Finset.univ) fun d _ => pointwise d
simpa only [Finset.sum_sub_distrib, ← Finset.mul_sum, sum_fiberMass,
FiniteDistribution.probability] using hsum
omit [Fintype D] in
/-- On every selected datum the conditional distribution is defined on an
actual nonempty positive-mass slice and has the promised target agreement. -/
theorem visibleWitness_conditional
(μ : FiniteDistribution Ω) (observe : Ω → D)
(slice targetHit : Ω → Bool) (threshold : ℝ) (d : D)
(h : visibleWitness μ observe slice targetHit threshold d = true) :
∃ hpositive : 0 < μ.probability (fiberEvent observe d slice),
threshold ≤ (μ.condition (fiberEvent observe d slice) hpositive).probability targetHit := by
classical
have hh : 0 < fiberMass μ observe d slice ∧
threshold * fiberMass μ observe d slice ≤
fiberMass μ observe d (fun x => slice x && targetHit x) := by
simpa only [visibleWitness, decide_eq_true_eq] using h
unfold fiberMass at hh
refine ⟨hh.1, ?_⟩
rw [FiniteDistribution.probability_condition]
have hsame : (fun x => fiberEvent observe d slice x && targetHit x) =
fiberEvent observe d (fun x => slice x && targetHit x) := by
funext x
simp [fiberEvent, Bool.and_assoc]
rw [hsame]
exact (le_div_iff₀ hh.1).mpr hh.2
omit [Fintype D] in
/-- Goodness is inherited from any event whose membership requires good
visible advice. Positivity supplies an actual supporting hidden sample. -/
theorem visibleWitness_good
(μ : FiniteDistribution Ω) (observe : Ω → D)
(slice targetHit : Ω → Bool) (threshold : ℝ)
(good : D → Prop) (hslice : ∀ x, slice x = true → good (observe x))
(d : D) (h : visibleWitness μ observe slice targetHit threshold d = true) :
good d := by
classical
have hpos : 0 < fiberMass μ observe d slice := by
have hh := of_decide_eq_true h
exact hh.1
by_contra hbad
have hempty : fiberEvent observe d slice = fun _ => false := by
funext x
apply Bool.eq_false_iff.mpr
intro hx
have hh : observe x = d ∧ slice x = true := by
simpa only [fiberEvent, Bool.and_eq_true, decide_eq_true_eq] using hx
exact hbad (hh.1 ▸ hslice x hh.2)
unfold fiberMass at hpos
rw [hempty, FiniteDistribution.probability_false] at hpos
exact (lt_irrefl 0) hpos
/-- A pair of full-table event probabilities transfers with error
`(1 + threshold) * TV`. This estimate precedes all conditioning. -/
theorem margin_transfer (μ ν : FiniteDistribution Ω)
(slice targetHit : Ω → Bool) (threshold : ℝ) (hthreshold : 0 ≤ threshold) :
μ.probability (fun x => slice x && targetHit x) - threshold * μ.probability slice -
(1 + threshold) * μ.totalVariation ν ≤
ν.probability (fun x => slice x && targetHit x) - threshold * ν.probability slice := by
have hm := μ.probability_sub_le_totalVariation ν (fun x => slice x && targetHit x)
have hs := ν.probability_sub_le_totalVariation μ slice
rw [FiniteDistribution.totalVariation_comm] at hs
have hscaled := mul_le_mul_of_nonneg_left hs hthreshold
nlinarith
/-- The whole-table comparison and the exact finite disintegration combine
without any assumption on conditional projection laws. -/
theorem wholeTable_transfer_to_visibleWitness
{Γ : Type*} [Fintype Γ]
(unrestricted : FiniteDistribution Ω) (actual : FiniteDistribution Γ)
(pad : Γ → Ω) (observe : Γ → D) (slice targetHit : Ω → Bool)
(threshold γ : ℝ) (hthreshold : 0 ≤ threshold)
(hmargin : γ ≤
unrestricted.probability (fun x => slice x && targetHit x) -
threshold * unrestricted.probability slice -
(1 + threshold) * unrestricted.totalVariation (actual.pushforward pad)) :
γ ≤ (actual.pushforward observe).probability
(visibleWitness actual observe (fun x => slice (pad x))
(fun x => targetHit (pad x)) threshold) := by
have transferred := margin_transfer unrestricted (actual.pushforward pad)
slice targetHit threshold hthreshold
simp only [FiniteDistribution.probability_pushforward] at transferred
exact (hmargin.trans transferred).trans
(witness_margin_le_visible_probability actual observe
(fun x => slice (pad x)) (fun x => targetHit (pad x)) threshold hthreshold)
theorem projected_witness_mass
{Γ : Type*} [Fintype Γ]
(unrestricted : FiniteDistribution Ω) (actual : FiniteDistribution Γ)
(pad : Γ → Ω) (observe : Γ → D) (slice targetHit : Ω → Bool)
(α g₀ c : ℝ) (hα : 0 ≤ α)
(hslice : g₀ * c ≤ unrestricted.probability slice)
(hagreement : (α / 2) * unrestricted.probability slice ≤
unrestricted.probability (fun x => slice x && targetHit x))
(herror : (1 + α / 4) * unrestricted.totalVariation (actual.pushforward pad) ≤
α * g₀ * c / 8) :
α * g₀ * c / 8 ≤ (actual.pushforward observe).probability
(visibleWitness actual observe (fun x => slice (pad x))
(fun x => targetHit (pad x)) (α / 4)) := by
apply wholeTable_transfer_to_visibleWitness unrestricted actual pad observe slice targetHit
(α / 4) (α * g₀ * c / 8) (by positivity)
have hscaled := mul_le_mul_of_nonneg_left hslice (show 0 ≤ α / 4 by positivity)
nlinarith
end
end UniqueGamesTheorem.Decoder.VisibleTransfer
end
section
namespace UniqueGamesTheorem.Decoder.UniformFibers
open Foundations.Games
open scoped BigOperators Classical
noncomputable section
variable {Ω D Y : Type*}
def selectedFiberEquiv (observe : Ω → D) (d : D) (slice : Ω → Bool)
(e : Y ≃ {x : Ω // observe x = d}) :
{x : Ω // VisibleTransfer.fiberEvent observe d slice x = true} ≃
{y : Y // slice (e y).val = true} where
toFun x := by
have hx : observe x.val = d ∧ slice x.val = true := by
simpa only [VisibleTransfer.fiberEvent, Bool.and_eq_true, decide_eq_true_eq] using x.property
refine ⟨e.symm ⟨x.val, hx.1⟩, ?_⟩
simpa only [Equiv.apply_symm_apply] using hx.2
invFun y := ⟨(e y.val).val, by
simp only [VisibleTransfer.fiberEvent, Bool.and_eq_true, decide_eq_true_eq]
exact ⟨(e y.val).property, y.property⟩⟩
left_inv x := by
apply Subtype.ext
dsimp
simp only [Equiv.apply_symm_apply]
right_inv y := by
apply Subtype.ext
exact e.symm_apply_apply y.val
theorem selectedFiberEquiv_point (observe : Ω → D) (d : D) (slice : Ω → Bool)
(e : Y ≃ {x : Ω // observe x = d})
(x : {x : Ω // VisibleTransfer.fiberEvent observe d slice x = true}) :
(e (selectedFiberEquiv observe d slice e x).val).val = x.val := by
exact congrArg Subtype.val (e.apply_symm_apply _)
/-- Conditioning after fixing the complete datum and the selected column
event leaves precisely the uniform restricted private fiber. -/
theorem conditional_probability [Fintype Ω] [Fintype Y]
(μ : FiniteDistribution Ω) (observe : Ω → D) (d : D)
(slice event : Ω → Bool)
(positive : 0 < μ.probability (VisibleTransfer.fiberEvent observe d slice))
(c : ℝ) (hconstant : ∀ x, observe x = d → μ.weight x = c)
(e : Y ≃ {x : Ω // observe x = d}) :
(μ.condition (VisibleTransfer.fiberEvent observe d slice) positive).probability event =
𝔼 y : {y : Y // slice (e y).val = true},
if event (e y.val).val then (1 : ℝ) else 0 := by
apply UniformConditioning.condition_probability_equiv μ
(VisibleTransfer.fiberEvent observe d slice) event positive c
(fun x hx => hconstant x (by
have h : observe x = d ∧ slice x = true := by
simpa only [VisibleTransfer.fiberEvent, Bool.and_eq_true, decide_eq_true_eq] using hx
exact h.1))
(selectedFiberEquiv observe d slice e)
(fun y => event (e y.val).val)
intro x
rw [selectedFiberEquiv_point]
end
end UniqueGamesTheorem.Decoder.UniformFibers
end
end OAI
|