math / data /lean /OAI /Computability /BinPacking /Games /QuestionMarginal.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
47.6 kB
import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Algebra.Order.BigOperators.Group.Finset
import Mathlib.Data.Fintype.BigOperators
import Mathlib.Data.Fintype.Sum
import Mathlib.Basic.Real.Basic
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.Positivity
import Mathlib.Tactic.Ring
import OAI.Computability.BinPacking.Games.LocalSimulation
import OAI.Computability.BinPacking.Information.SideInformation
namespace OAI
noncomputable section
namespace BinPackingGames.Foundations.Repetition
section
open scoped BigOperators
variable {ΞΉ Ξ± Ξ² : Type*} [Fintype ΞΉ] [DecidableEq Ξ±] [DecidableEq Ξ²]
def revealedProductWeight (weight : ΞΉ β†’ Ξ± β†’ Ξ² β†’ ℝ) (mask : ΞΉ β†’ Bool)
(fixedLeft : ΞΉ β†’ Ξ±) (fixedRight : ΞΉ β†’ Ξ²) (x : ΞΉ β†’ Ξ±) (y : ΞΉ β†’ Ξ²) : ℝ :=
∏ i, weight i (x i) (y i) *
(if mask i then (if y i = fixedRight i then 1 else 0)
else (if x i = fixedLeft i then 1 else 0))
def revealedLeftWeight (weight : ΞΉ β†’ Ξ± β†’ Ξ² β†’ ℝ) (mask : ΞΉ β†’ Bool)
(fixedLeft : ΞΉ β†’ Ξ±) (fixedRight : ΞΉ β†’ Ξ²) (x : ΞΉ β†’ Ξ±) : ℝ :=
∏ i, if mask i then weight i (x i) (fixedRight i)
else (if x i = fixedLeft i then 1 else 0)
def revealedRightWeight (weight : ΞΉ β†’ Ξ± β†’ Ξ² β†’ ℝ) (mask : ΞΉ β†’ Bool)
(fixedLeft : ΞΉ β†’ Ξ±) (fixedRight : ΞΉ β†’ Ξ²) (y : ΞΉ β†’ Ξ²) : ℝ :=
∏ i, if mask i then (if y i = fixedRight i then 1 else 0)
else weight i (fixedLeft i) (y i)
theorem revealedProductWeight_factorizes (weight : ΞΉ β†’ Ξ± β†’ Ξ² β†’ ℝ) (mask : ΞΉ β†’ Bool)
(fixedLeft : ΞΉ β†’ Ξ±) (fixedRight : ΞΉ β†’ Ξ²) (x : ΞΉ β†’ Ξ±) (y : ΞΉ β†’ Ξ²) :
revealedProductWeight weight mask fixedLeft fixedRight x y =
revealedLeftWeight weight mask fixedLeft fixedRight x *
revealedRightWeight weight mask fixedLeft fixedRight y := by
unfold revealedProductWeight revealedLeftWeight revealedRightWeight
rw [← Finset.prod_mul_distrib]
apply Finset.prod_congr rfl
intro i _
by_cases hm : mask i = true
Β· by_cases hy : y i = fixedRight i <;> simp [hm, hy]
Β· by_cases hx : x i = fixedLeft i <;> simp [hm, hx]
theorem revealedProductWeight_local_restrictions
(weight : ΞΉ β†’ Ξ± β†’ Ξ² β†’ ℝ) (mask : ΞΉ β†’ Bool)
(fixedLeft : ΞΉ β†’ Ξ±) (fixedRight : ΞΉ β†’ Ξ²)
(leftTest : (ΞΉ β†’ Ξ±) β†’ ℝ) (rightTest : (ΞΉ β†’ Ξ²) β†’ ℝ)
(x : ΞΉ β†’ Ξ±) (y : ΞΉ β†’ Ξ²) :
revealedProductWeight weight mask fixedLeft fixedRight x y * leftTest x * rightTest y =
(revealedLeftWeight weight mask fixedLeft fixedRight x * leftTest x) *
(revealedRightWeight weight mask fixedLeft fixedRight y * rightTest y) := by
rw [revealedProductWeight_factorizes]
ring
variable {X Y : Type*} [Fintype X] [Fintype Y]
theorem productWeight_mass (left : X β†’ ℝ) (right : Y β†’ ℝ) :
(βˆ‘ xy : X Γ— Y, left xy.1 * right xy.2) =
(βˆ‘ x, left x) * (βˆ‘ y, right y) := by
rw [Fintype.sum_prod_type]
simp only [← Finset.mul_sum, ← Finset.sum_mul]
def normalizedWeight (weight : X β†’ ℝ) : X β†’ ℝ :=
fun x => weight x / βˆ‘ x', weight x'
theorem normalizedWeight_isProbability (weight : X β†’ ℝ)
(hweight : βˆ€ x, 0 ≀ weight x) (hmass : 0 < βˆ‘ x, weight x) :
(βˆ€ x, 0 ≀ normalizedWeight weight x) ∧ (βˆ‘ x, normalizedWeight weight x) = 1 := by
constructor
Β· intro x
exact div_nonneg (hweight x) hmass.le
Β· simp only [normalizedWeight, div_eq_mul_inv, ← Finset.sum_mul, mul_inv_cancelβ‚€ hmass.ne']
theorem normalized_productWeight (left : X β†’ ℝ) (right : Y β†’ ℝ)
(hleft : 0 < βˆ‘ x, left x) (hright : 0 < βˆ‘ y, right y) (xy : X Γ— Y) :
normalizedWeight (fun z : X Γ— Y => left z.1 * right z.2) xy =
normalizedWeight left xy.1 * normalizedWeight right xy.2 := by
unfold normalizedWeight
rw [productWeight_mass]
field_simp
theorem normalized_rectangle_restriction
(left : X β†’ ℝ) (right : Y β†’ ℝ) (leftTest : X β†’ ℝ) (rightTest : Y β†’ ℝ)
(hleft : 0 < βˆ‘ x, left x * leftTest x)
(hright : 0 < βˆ‘ y, right y * rightTest y) (xy : X Γ— Y) :
normalizedWeight
(fun z : X Γ— Y => left z.1 * right z.2 * leftTest z.1 * rightTest z.2) xy =
normalizedWeight (fun x => left x * leftTest x) xy.1 *
normalizedWeight (fun y => right y * rightTest y) xy.2 := by
have hfun : (fun z : X Γ— Y => left z.1 * right z.2 * leftTest z.1 * rightTest z.2) =
(fun z : X Γ— Y => (left z.1 * leftTest z.1) * (right z.2 * rightTest z.2)) := by
funext z
ring
rw [hfun]
exact normalized_productWeight _ _ hleft hright xy
end
section
open scoped BigOperators
open Games
variable {X Y : Type*} [Fintype X] [Fintype Y]
def normalizeOr (w : X β†’ ℝ) (hw : βˆ€ x, 0 ≀ w x)
(fallback : FiniteDistribution X) : FiniteDistribution X :=
if h : 0 < βˆ‘ x, w x then
{ weight := normalizedWeight w
nonnegative := (normalizedWeight_isProbability w hw h).1
normalized := (normalizedWeight_isProbability w hw h).2 }
else fallback
theorem sum_mul_normalizeOr (w : X β†’ ℝ) (hw : βˆ€ x, 0 ≀ w x)
(fallback : FiniteDistribution X) (x : X) :
(βˆ‘ z, w z) * (normalizeOr w hw fallback).weight x = w x := by
classical
have hs : 0 ≀ βˆ‘ z, w z := Finset.sum_nonneg (fun z _ => hw z)
by_cases h : 0 < βˆ‘ z, w z
Β· simp only [normalizeOr, dite_eq_left h, normalizedWeight]
field_simp
Β· have hz : βˆ‘ z, w z = 0 := le_antisymm (le_of_not_gt h) hs
have hx : w x = 0 := by
apply le_antisymm _ (hw x)
have hl := Finset.single_le_sum (fun z _ => hw z) (Finset.mem_univ x)
simpa only [hz] using hl
simp [normalizeOr, hz, hx]
theorem local_completion_recombination
(left : X β†’ ℝ) (right : Y β†’ ℝ)
(hl : βˆ€ x, 0 ≀ left x) (hr : βˆ€ y, 0 ≀ right y)
(defaultLeft : FiniteDistribution X) (defaultRight : FiniteDistribution Y)
(c : ℝ) (x : X) (y : Y) :
(c * (βˆ‘ z, left z) * (βˆ‘ z, right z)) *
((normalizeOr left hl defaultLeft).weight x *
(normalizeOr right hr defaultRight).weight y) = c * left x * right y := by
calc
_ = c * ((βˆ‘ z, left z) * (normalizeOr left hl defaultLeft).weight x) *
((βˆ‘ z, right z) * (normalizeOr right hr defaultRight).weight y) := by ring
_ = _ := by rw [sum_mul_normalizeOr, sum_mul_normalizeOr]
theorem factorized_completion_row
(left : X β†’ ℝ) (right : Y β†’ ℝ)
(hl : βˆ€ x, 0 ≀ left x) (hr : βˆ€ y, 0 ≀ right y)
(defaultLeft : FiniteDistribution X) (defaultRight : FiniteDistribution Y)
(c : ℝ) (xy : X Γ— Y) :
(βˆ‘ z : X Γ— Y, c * left z.1 * right z.2) *
((normalizeOr left hl defaultLeft).product
(normalizeOr right hr defaultRight)).weight xy = c * left xy.1 * right xy.2 := by
have hm : (βˆ‘ z : X Γ— Y, c * left z.1 * right z.2) =
c * (βˆ‘ z, left z) * (βˆ‘ z, right z) := by
simp_rw [mul_assoc, ← Finset.mul_sum]
rw [productWeight_mass]
rw [hm]
exact local_completion_recombination left right hl hr defaultLeft defaultRight c xy.1 xy.2
end
section
open scoped BigOperators
open Games Information
variable {X Y : Type*} [Fintype X] [Fintype Y] [DecidableEq X] [DecidableEq Y]
def revealEndpoint (q : X Γ— Y) (side : Bool) : X βŠ• Y :=
if side then Sum.inr q.2 else Sum.inl q.1
def revealLaw (ΞΌ : FiniteDistribution (X Γ— Y)) :
FiniteDistribution ((X Γ— Y) Γ— (X βŠ• Y)) :=
(ΞΌ.product (FiniteDistribution.uniform Bool)).pushforward
(fun z => (z.1, revealEndpoint z.1 z.2))
theorem revealLaw_weight (ΞΌ : FiniteDistribution (X Γ— Y)) (q : X Γ— Y) (r : X βŠ• Y) :
(revealLaw ΞΌ).weight (q,r) =
(if r = Sum.inl q.1 then ΞΌ.weight q / 2 else 0) +
(if r = Sum.inr q.2 then ΞΌ.weight q / 2 else 0) := by
classical
rcases q with ⟨x,y⟩
simp only [revealLaw, FiniteDistribution.pushforward, FiniteDistribution.product,
Fintype.sum_prod_type, Prod.mk.injEq, ite_and]
simp [revealEndpoint, FiniteDistribution.uniform, div_eq_mul_inv, add_comm, eq_comm]
def revealFirstLaw (ΞΌ : FiniteDistribution (X Γ— Y)) :
FiniteDistribution ((X βŠ• Y) Γ— (X Γ— Y)) :=
(revealLaw ΞΌ).transport (Equiv.prodComm _ _)
omit [DecidableEq X] [DecidableEq Y] in
@[simp] theorem revealFirstLaw_weight (ΞΌ : FiniteDistribution (X Γ— Y))
(r : X βŠ• Y) (q : X Γ— Y) :
(revealFirstLaw ΞΌ).weight (r,q) = (revealLaw ΞΌ).weight (q,r) := rfl
def revealFallback (ΞΌ : FiniteDistribution (X Γ— Y)) (r : X βŠ• Y) :
FiniteDistribution (X Γ— Y) :=
match r with
| Sum.inl x => ΞΌ.pushforward (fun q => (x,q.2))
| Sum.inr y => ΞΌ.pushforward (fun q => (q.1,y))
def revealProfile (ΞΌ : FiniteDistribution (X Γ— Y)) (r : X βŠ• Y) :
FiniteDistribution (X Γ— Y) :=
gameConditionalKernel (revealFirstLaw ΞΌ) (revealFallback ΞΌ r) r
theorem revealProfile_inl_support (ΞΌ : FiniteDistribution (X Γ— Y))
(x : X) (q : X Γ— Y) (h : q.1 β‰  x) :
(revealProfile ΞΌ (Sum.inl x)).weight q = 0 := by
classical
rcases q with ⟨x',y⟩
dsimp at h
simp only [revealProfile, gameConditionalKernel, toGameLaw, conditionalKernel]
split
Β· simp [revealFallback, FiniteDistribution.pushforward, Fintype.sum_prod_type,
Prod.mk.injEq, Ne.symm h]
Β· simp [revealLaw_weight, Ne.symm h]
theorem revealProfile_inr_support (ΞΌ : FiniteDistribution (X Γ— Y))
(y : Y) (q : X Γ— Y) (h : q.2 β‰  y) :
(revealProfile ΞΌ (Sum.inr y)).weight q = 0 := by
classical
rcases q with ⟨x,y'⟩
dsimp at h
simp only [revealProfile, gameConditionalKernel, toGameLaw, conditionalKernel]
split
Β· simp [revealFallback, FiniteDistribution.pushforward, Fintype.sum_prod_type,
Prod.mk.injEq, Ne.symm h]
Β· simp [revealLaw_weight, Ne.symm h]
def revealInputLaw (ΞΌ : FiniteDistribution (X Γ— Y)) : FiniteDistribution (X βŠ• Y) :=
(revealLaw ΞΌ).pushforward Prod.snd
theorem revealInputLaw_weight (ΞΌ : FiniteDistribution (X Γ— Y)) (r : X βŠ• Y) :
(revealInputLaw ΞΌ).weight r = firstMarginal (revealFirstLaw ΞΌ).weight r := by
classical
cases r <;>
simp [revealInputLaw, FiniteDistribution.pushforward, firstMarginal, Fintype.sum_prod_type]
theorem reveal_profile_recombination (ΞΌ : FiniteDistribution (X Γ— Y))
(r : X βŠ• Y) (q : X Γ— Y) :
(revealInputLaw ΞΌ).weight r * (revealProfile ΞΌ r).weight q =
(revealLaw ΞΌ).weight (q,r) := by
rw [revealInputLaw_weight]
exact gameConditionalKernel_recombine (revealFirstLaw ΞΌ) (revealFallback ΞΌ r) r q
theorem reveal_profile_inl_recombination (ΞΌ : FiniteDistribution (X Γ— Y))
(x : X) (q : X Γ— Y) :
(revealInputLaw ΞΌ).weight (Sum.inl x) * (revealProfile ΞΌ (Sum.inl x)).weight q =
if x = q.1 then ΞΌ.weight q / 2 else 0 := by
rw [reveal_profile_recombination, revealLaw_weight]
simp
theorem reveal_profile_inr_recombination (ΞΌ : FiniteDistribution (X Γ— Y))
(y : Y) (q : X Γ— Y) :
(revealInputLaw ΞΌ).weight (Sum.inr y) * (revealProfile ΞΌ (Sum.inr y)).weight q =
if y = q.2 then ΞΌ.weight q / 2 else 0 := by
rw [reveal_profile_recombination, revealLaw_weight]
simp
theorem revealInputLaw_inl (ΞΌ : FiniteDistribution (X Γ— Y)) (x : X) :
(revealInputLaw ΞΌ).weight (Sum.inl x) = (βˆ‘ y, ΞΌ.weight (x,y)) / 2 := by
classical
rw [revealInputLaw_weight]
simp [firstMarginal, Fintype.sum_prod_type, revealLaw_weight, div_eq_mul_inv]
rw [Finset.sum_comm]
simp [← Finset.sum_mul]
theorem revealInputLaw_inr (ΞΌ : FiniteDistribution (X Γ— Y)) (y : Y) :
(revealInputLaw ΞΌ).weight (Sum.inr y) = (βˆ‘ x, ΞΌ.weight (x,y)) / 2 := by
classical
rw [revealInputLaw_weight]
simp [firstMarginal, Fintype.sum_prod_type, revealLaw_weight,
div_eq_mul_inv, ← Finset.sum_mul]
theorem revealProfile_inl_diagonal (ΞΌ : FiniteDistribution (X Γ— Y)) (x : X) (y : Y) :
(revealProfile ΞΌ (Sum.inl x)).weight (x,y) =
conditionalKernel ΞΌ.weight (ΞΌ.pushforward Prod.snd).weight x y := by
classical
have hm : firstMarginal (revealFirstLaw ΞΌ).weight (Sum.inl x) =
firstMarginal ΞΌ.weight x / 2 := by
rw [← revealInputLaw_weight, revealInputLaw_inl]
rfl
have hf : (revealFallback ΞΌ (Sum.inl x)).weight (x,y) =
(ΞΌ.pushforward Prod.snd).weight y := by
simp [revealFallback, FiniteDistribution.pushforward, Prod.mk.injEq]
apply Finset.sum_congr rfl
intro q _
by_cases hq : q.2 = y <;> simp [hq]
simp only [revealProfile, gameConditionalKernel, toGameLaw, conditionalKernel, hm]
by_cases h : firstMarginal ΞΌ.weight x = 0
Β· simpa [h] using hf
Β· have hh : firstMarginal ΞΌ.weight x / 2 β‰  0 := div_ne_zero h (by norm_num)
simp only [ite_eq_right h, ite_eq_right hh, revealFirstLaw_weight, revealLaw_weight,
ite_true, Sum.inl_ne_inr, ite_false, add_zero]
field_simp
theorem revealProfile_inr_diagonal (ΞΌ : FiniteDistribution (X Γ— Y)) (x : X) (y : Y) :
(revealProfile ΞΌ (Sum.inr y)).weight (x,y) =
conditionalKernel (ΞΌ.transport (Equiv.prodComm X Y)).weight
(ΞΌ.pushforward Prod.fst).weight y x := by
classical
have hm : firstMarginal (revealFirstLaw ΞΌ).weight (Sum.inr y) =
firstMarginal (ΞΌ.transport (Equiv.prodComm X Y)).weight y / 2 := by
rw [← revealInputLaw_weight, revealInputLaw_inr]
rfl
have hf : (revealFallback ΞΌ (Sum.inr y)).weight (x,y) =
(ΞΌ.pushforward Prod.fst).weight x := by
simp [revealFallback, FiniteDistribution.pushforward, Prod.mk.injEq]
apply Finset.sum_congr rfl
intro q _
by_cases hq : q.1 = x <;> simp [hq]
simp only [revealProfile, gameConditionalKernel, toGameLaw, conditionalKernel, hm]
by_cases h : firstMarginal (ΞΌ.transport (Equiv.prodComm X Y)).weight y = 0
Β· simpa [h] using hf
Β· have hh : firstMarginal (ΞΌ.transport (Equiv.prodComm X Y)).weight y / 2 β‰  0 :=
div_ne_zero h (by norm_num)
simp only [ite_eq_right h, ite_eq_right hh, revealFirstLaw_weight, revealLaw_weight,
ite_true, Sum.inr_ne_inl, ite_false, zero_add]
change (ΞΌ.weight (x,y) / 2) / (firstMarginal (ΞΌ.transport (Equiv.prodComm X Y)).weight y / 2) =
ΞΌ.weight (x,y) / firstMarginal (ΞΌ.transport (Equiv.prodComm X Y)).weight y
field_simp
theorem revealLaw_sum_left (ΞΌ : FiniteDistribution (X Γ— Y)) (q : X Γ— Y) :
(βˆ‘ x, (revealLaw ΞΌ).weight (q, Sum.inl x)) = ΞΌ.weight q / 2 := by
classical
simp [revealLaw_weight]
theorem revealLaw_sum_right (ΞΌ : FiniteDistribution (X Γ— Y)) (q : X Γ— Y) :
(βˆ‘ y, (revealLaw ΞΌ).weight (q, Sum.inr y)) = ΞΌ.weight q / 2 := by
classical
simp [revealLaw_weight]
theorem revealLaw_forget (ΞΌ : FiniteDistribution (X Γ— Y)) :
(revealLaw ΞΌ).pushforward Prod.fst = ΞΌ := by
classical
apply FiniteDistribution.eq_of_weight_eq
intro q
rcases q with ⟨x,y⟩
simp [FiniteDistribution.pushforward, Fintype.sum_prod_type,
Finset.sum_ite_irrel, revealLaw_weight]
theorem reveal_product_factorization {ΞΉ : Type*} [Fintype ΞΉ]
(ΞΌ : FiniteDistribution (X Γ— Y)) (r : ΞΉ β†’ X βŠ• Y) (q : ΞΉ β†’ X Γ— Y) :
(∏ i, (revealInputLaw μ).weight (r i)) *
(∏ i, (revealProfile μ (r i)).weight (q i)) =
∏ i, (revealLaw μ).weight (q i,r i) := by
rw [← Finset.prod_mul_distrib]
apply Finset.prod_congr rfl
intro i _
exact reveal_profile_recombination ΞΌ (r i) (q i)
theorem reveal_product_forget {ΞΉ : Type*} [Fintype ΞΉ] [DecidableEq ΞΉ]
(ΞΌ : FiniteDistribution (X Γ— Y)) (q : ΞΉ β†’ X Γ— Y) :
(βˆ‘ r : ΞΉ β†’ X βŠ• Y,
(∏ i, (revealInputLaw μ).weight (r i)) *
(∏ i, (revealProfile μ (r i)).weight (q i))) =
∏ i, μ.weight (q i) := by
classical
simp_rw [reveal_product_factorization]
calc
_ = ∏ i, βˆ‘ r : X βŠ• Y, (revealLaw ΞΌ).weight (q i,r) :=
(Fintype.prod_sum (fun (i : ΞΉ) (r : X βŠ• Y) => (revealLaw ΞΌ).weight (q i,r))).symm
_ = _ := by
apply Finset.prod_congr rfl
intro i _
rw [Fintype.sum_sum_type, revealLaw_sum_left, revealLaw_sum_right]
ring
theorem reveal_product_expectation {ΞΉ : Type*} [Fintype ΞΉ] [DecidableEq ΞΉ]
(ΞΌ : FiniteDistribution (X Γ— Y)) (f : (ΞΉ β†’ X Γ— Y) β†’ ℝ) :
(βˆ‘ r : ΞΉ β†’ X βŠ• Y,
(∏ i, (revealInputLaw μ).weight (r i)) *
βˆ‘ q : ΞΉ β†’ X Γ— Y, (∏ i, (revealProfile ΞΌ (r i)).weight (q i)) * f q) =
βˆ‘ q : ΞΉ β†’ X Γ— Y, (∏ i, ΞΌ.weight (q i)) * f q := by
classical
simp_rw [Finset.mul_sum]
rw [Finset.sum_comm]
apply Finset.sum_congr rfl
intro q _
simp_rw [← mul_assoc, ← Finset.sum_mul]
rw [reveal_product_forget]
end
section
open scoped BigOperators
open Games Information
def mergeCoordinates {Ξ© : Type*} {n : Nat} (selected : Finset (Fin n))
(fixed : selected β†’ Ξ©) (remaining : {i : Fin n // i βˆ‰ selected} β†’ Ξ©) : Fin n β†’ Ξ© :=
fun i => if h : i ∈ selected then fixed ⟨i,h⟩ else remaining ⟨i,h⟩
def coordinateSplitEquiv {Ξ© : Type*} {n : Nat} (selected : Finset (Fin n)) :
(Fin n β†’ Ξ©) ≃ ((selected β†’ Ξ©) Γ— ({i : Fin n // i βˆ‰ selected} β†’ Ξ©)) where
toFun x := (fun i => x i.1, fun i => x i.1)
invFun x := mergeCoordinates selected x.1 x.2
left_inv x := by funext i; simp [mergeCoordinates]
right_inv x := by
apply Prod.ext <;> funext i <;> simp [mergeCoordinates, i.property]
theorem iid_coordinate_split {Ξ© : Type*} [Fintype Ξ©] {n : Nat}
(ΞΌ : FiniteDistribution Ξ©) (selected : Finset (Fin n)) :
(ΞΌ.iid n).transport (coordinateSplitEquiv selected) =
(FiniteDistribution.table (fun _ : selected => ΞΌ)).product
(FiniteDistribution.table (fun _ : {i : Fin n // i βˆ‰ selected} => ΞΌ)) := by
classical
apply FiniteDistribution.eq_of_weight_eq
intro x
change (∏ i, μ.weight (mergeCoordinates selected x.1 x.2 i)) =
(∏ i : selected, μ.weight (x.1 i)) *
∏ i : {i : Fin n // i βˆ‰ selected}, ΞΌ.weight (x.2 i)
have h := Fintype.prod_subtype_mul_prod_subtype (fun i : Fin n => i ∈ selected)
(fun i => ΞΌ.weight (mergeCoordinates selected x.1 x.2 i))
have hi : Subtype.fintype (fun i : Fin n => i ∈ selected) =
Finset.Subtype.fintype selected := Subsingleton.elim _ _
rw [hi] at h
calc
_ = (∏ i : {i : Fin n // i ∈ selected},
ΞΌ.weight (mergeCoordinates selected x.1 x.2 i.1)) *
∏ i : {i : Fin n // i βˆ‰ selected},
ΞΌ.weight (mergeCoordinates selected x.1 x.2 i.1) := h.symm
_ = _ := by
congr 1 <;> apply Finset.prod_congr rfl <;> intro i _ <;>
simp [mergeCoordinates, i.property]
variable {Q₁ Qβ‚‚ A₁ Aβ‚‚ : Type*}
[Fintype Q₁] [Fintype Qβ‚‚] [Fintype A₁] [Fintype Aβ‚‚]
[DecidableEq Q₁] [DecidableEq Qβ‚‚]
{n : Nat}
abbrev SelectedLabels (selected : Finset (Fin n)) :=
(selected β†’ A₁) Γ— (selected β†’ Aβ‚‚)
def selectedQuestionTuple (selected : Finset (Fin n))
(fixed : selected β†’ Q₁ Γ— Qβ‚‚)
(remaining : {i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚) :
(Fin n β†’ Q₁) Γ— (Fin n β†’ Qβ‚‚) :=
(fun i => (mergeCoordinates selected fixed remaining i).1,
fun i => (mergeCoordinates selected fixed remaining i).2)
def selectedAnswerLabel
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (questions : (Fin n β†’ Q₁) Γ— (Fin n β†’ Qβ‚‚)) :
SelectedLabels (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected :=
(fun i => strategy.1 questions.1 i.1, fun i => strategy.2 questions.2 i.1)
def selectedLikelihood (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (fixed : selected β†’ Q₁ Γ— Qβ‚‚)
(label : SelectedLabels (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected)
(remaining : {i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚) : ℝ := by
classical
let questions := selectedQuestionTuple selected fixed remaining
exact if selectedAnswerLabel strategy selected questions = label then
(if G.selectedWins strategy selected questions then 1 else 0) else 0
omit [DecidableEq Q₁] [DecidableEq Qβ‚‚] in
theorem selectedLikelihood_nonnegative (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (fixed : selected β†’ Q₁ Γ— Qβ‚‚)
(label : SelectedLabels (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected)
(remaining : {i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚) :
0 ≀ selectedLikelihood G strategy selected fixed label remaining := by
classical
dsimp only [selectedLikelihood]
split_ifs <;> norm_num
omit [DecidableEq Q₁] [DecidableEq Qβ‚‚] in
theorem selectedLikelihood_sum (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (fixed : selected β†’ Q₁ Γ— Qβ‚‚)
(remaining : {i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚) :
(βˆ‘ label, selectedLikelihood G strategy selected fixed label remaining) =
if G.selectedWins strategy selected (selectedQuestionTuple selected fixed remaining)
then 1 else 0 := by
classical
simp [selectedLikelihood]
omit [DecidableEq Q₁] [DecidableEq Qβ‚‚] in
theorem selectedLikelihood_sum_le_one (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (fixed : selected β†’ Q₁ Γ— Qβ‚‚)
(remaining : {i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚) :
(βˆ‘ label, selectedLikelihood G strategy selected fixed label remaining) ≀ 1 := by
rw [selectedLikelihood_sum]
split <;> norm_num
def selectedSplitLaw (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚) (selected : Finset (Fin n)) :
FiniteDistribution ((selected β†’ Q₁ Γ— Qβ‚‚) Γ—
({i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚)) :=
(FiniteDistribution.table (fun _ : selected => G.questions)).product
(FiniteDistribution.table (fun _ : {i : Fin n // i βˆ‰ selected} => G.questions))
omit [DecidableEq Q₁] [DecidableEq Qβ‚‚] in
theorem selectedSplit_probability (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) :
(selectedSplitLaw G selected).probability
(fun q => G.selectedWins strategy selected (selectedQuestionTuple selected q.1 q.2)) =
G.selectedSuccess strategy selected := by
rw [selectedSplitLaw, ← iid_coordinate_split, FiniteDistribution.probability_transport]
change (G.questions.iid n).probability _ =
((G.questions.iid n).transport (Game.tupleQuestionEquiv n)).probability _
rw [FiniteDistribution.probability_transport]
apply congrArg (G.questions.iid n).probability
funext q
congr 1
apply Prod.ext <;> funext i <;>
simp [selectedQuestionTuple, coordinateSplitEquiv, mergeCoordinates, Game.tupleQuestionEquiv]
abbrev SelectedInput (Q₁ Qβ‚‚ : Type*) {n : Nat} (selected : Finset (Fin n)) :=
(selected β†’ Q₁ Γ— Qβ‚‚) Γ— ({i : Fin n // i βˆ‰ selected} β†’ Q₁ βŠ• Qβ‚‚)
def selectedInputLaw (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚) (selected : Finset (Fin n)) :
FiniteDistribution (SelectedInput Q₁ Qβ‚‚ selected) :=
(FiniteDistribution.table (fun _ : selected => G.questions)).product
(FiniteDistribution.table (fun _ : {i : Fin n // i βˆ‰ selected} => revealInputLaw G.questions))
def selectedInputProfile (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚) (selected : Finset (Fin n))
(t : SelectedInput Q₁ Qβ‚‚ selected) (i : {i : Fin n // i βˆ‰ selected}) :
FiniteDistribution (Q₁ Γ— Qβ‚‚) := revealProfile G.questions (t.2 i)
def selectedSideMass (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n))
(tv : SelectedInput Q₁ Qβ‚‚ selected Γ— SelectedLabels (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected) : ℝ :=
βˆ‘ u, independentProduct (fun i => (selectedInputProfile G selected tv.1 i).weight) u *
selectedLikelihood G strategy selected tv.1.1 tv.2 u
omit [DecidableEq Q₁] [DecidableEq Qβ‚‚] in
theorem selectedSideMass_sum (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (t : SelectedInput Q₁ Qβ‚‚ selected) :
(βˆ‘ v, selectedSideMass G strategy selected (t,v)) =
βˆ‘ u, independentProduct (fun i => (selectedInputProfile G selected t i).weight) u *
(if G.selectedWins strategy selected (selectedQuestionTuple selected t.1 u)
then 1 else 0) := by
classical
simp only [selectedSideMass]
rw [Finset.sum_comm]
simp_rw [← Finset.mul_sum, selectedLikelihood_sum]
theorem selectedSideMass_total (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) :
(βˆ‘ tv, (selectedInputLaw G selected).weight tv.1 *
selectedSideMass G strategy selected tv) = G.selectedSuccess strategy selected := by
classical
rw [Fintype.sum_prod_type]
simp_rw [← Finset.mul_sum, selectedSideMass_sum]
rw [Fintype.sum_prod_type]
simp only [selectedInputLaw, FiniteDistribution.product, FiniteDistribution.table,
selectedInputProfile, independentProduct]
simp_rw [mul_assoc, ← Finset.mul_sum]
have hforget (fixed : selected β†’ Q₁ Γ— Qβ‚‚) :=
reveal_product_expectation G.questions
(fun u : {i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚ =>
if G.selectedWins strategy selected (selectedQuestionTuple selected fixed u)
then (1 : ℝ) else 0)
simp_rw [hforget]
have h := selectedSplit_probability G strategy selected
simpa [selectedSplitLaw, FiniteDistribution.probability, FiniteDistribution.product,
FiniteDistribution.table, Fintype.sum_prod_type, Finset.mul_sum, mul_ite, mul_assoc] using h
def selectedSideWeight (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n))
(tv : SelectedInput Q₁ Qβ‚‚ selected Γ— SelectedLabels (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected) : ℝ :=
(selectedInputLaw G selected).weight tv.1 * selectedSideMass G strategy selected tv /
G.selectedSuccess strategy selected
theorem selected_information_bound [Nonempty A₁] [Nonempty Aβ‚‚]
(G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected) :
(βˆ‘ i : {i : Fin n // i βˆ‰ selected}, totalVariation
(fun tva : (SelectedInput Q₁ Qβ‚‚ selected Γ—
SelectedLabels (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected) Γ— (Q₁ Γ— Qβ‚‚) =>
selectedSideWeight G strategy selected tva.1 * coordinateMarginal
(posteriorOrOriginal
(independentProduct (fun j => (selectedInputProfile G selected tva.1.1 j).weight))
(selectedLikelihood G strategy selected tva.1.1.1 tva.1.2)
(selectedSideMass G strategy selected tva.1)) i tva.2)
(fun tva => selectedSideWeight G strategy selected tva.1 *
(selectedInputProfile G selected tva.1.1 i).weight tva.2)) ≀
Real.sqrt ((Fintype.card {i : Fin n // i βˆ‰ selected} : ℝ) *
(Real.log (Fintype.card (SelectedLabels (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected) : ℝ) +
Real.log (1 / G.selectedSuccess strategy selected))) := by
exact finite_side_information_bound (selectedInputLaw G selected).weight
(fun t i => (selectedInputProfile G selected t i).weight)
(fun tv => selectedLikelihood G strategy selected tv.1.1 tv.2)
(selectedSideMass G strategy selected) (selectedSideWeight G strategy selected)
(gameLaw_isProbability _) (fun t i => gameLaw_isProbability _)
(fun tv => selectedLikelihood_nonnegative G strategy selected tv.1.1 tv.2)
(fun t => selectedLikelihood_sum_le_one G strategy selected t.1)
(fun _ => rfl) positive (selectedSideMass_total G strategy selected) (fun _ => rfl)
end
section
open scoped BigOperators
variable {S X Y : Type*} [Fintype S] [Fintype X] [Fintype Y]
[DecidableEq X] [DecidableEq Y]
def maskedJoint (p : S Γ— (X Γ— Y) β†’ ℝ) : (S Γ— (X βŠ• Y)) Γ— (X Γ— Y) β†’ ℝ := fun z =>
(if z.1.2 = Sum.inl z.2.1 then p (z.1.1, z.2) / 2 else 0) +
(if z.1.2 = Sum.inr z.2.2 then p (z.1.1, z.2) / 2 else 0)
def maskedModel (ΞΌ : Games.FiniteDistribution (X Γ— Y)) (p : S Γ— (X Γ— Y) β†’ ℝ) :
(S Γ— (X βŠ• Y)) Γ— (X Γ— Y) β†’ ℝ := fun z =>
Information.firstMarginal (maskedJoint p) z.1 * (revealProfile ΞΌ z.1.2).weight z.2
def leftRevealModel (ΞΌ : Games.FiniteDistribution (X Γ— Y)) (p : S Γ— (X Γ— Y) β†’ ℝ) :
S Γ— (X Γ— Y) β†’ ℝ := fun z =>
(βˆ‘ y, p (z.1, (z.2.1, y))) * (revealProfile ΞΌ (Sum.inl z.2.1)).weight z.2
def rightRevealModel (ΞΌ : Games.FiniteDistribution (X Γ— Y)) (p : S Γ— (X Γ— Y) β†’ ℝ) :
S Γ— (X Γ— Y) β†’ ℝ := fun z =>
(βˆ‘ x, p (z.1, (x, z.2.2))) * (revealProfile ΞΌ (Sum.inr z.2.2)).weight z.2
theorem sum_maskedJoint (p : S Γ— (X Γ— Y) β†’ ℝ) :
(βˆ‘ z, maskedJoint p z) = βˆ‘ z, p z := by
classical
have hrow (s : S) (q : X Γ— Y) :
(βˆ‘ r : X βŠ• Y, maskedJoint p ((s,r),q)) = p (s,q) := by
simp [maskedJoint]
calc
_ = βˆ‘ s : S, βˆ‘ r : X βŠ• Y, βˆ‘ q : X Γ— Y, maskedJoint p ((s,r),q) := by
simp only [Fintype.sum_prod_type]
_ = βˆ‘ s : S, βˆ‘ q : X Γ— Y, p (s,q) := by
apply Finset.sum_congr rfl
intro s _
rw [Finset.sum_comm]
simp_rw [hrow]
_ = _ := (Fintype.sum_prod_type _).symm
theorem maskedJoint_isProbability_iff (p : S Γ— (X Γ— Y) β†’ ℝ) :
Information.IsProbability (maskedJoint p) ↔ Information.IsProbability p := by
classical
constructor
Β· intro h
constructor
Β· intro z
have hp := h.1 ((z.1,Sum.inl z.2.1),z.2)
simp [maskedJoint] at hp
linarith
Β· rw [← sum_maskedJoint]
exact h.2
Β· intro h
constructor
Β· intro z
have hp : 0 ≀ p (z.1.1,z.2) / 2 := div_nonneg (h.1 _) (by norm_num)
dsimp [maskedJoint]
split_ifs <;> linarith
Β· rw [sum_maskedJoint]
exact h.2
omit [Fintype S] in
theorem maskedJoint_firstMarginal_inl (p : S Γ— (X Γ— Y) β†’ ℝ) (s : S) (x : X) :
Information.firstMarginal (maskedJoint p) (s, Sum.inl x) =
(βˆ‘ y, p (s, (x, y))) / 2 := by
simp [Information.firstMarginal, maskedJoint, Fintype.sum_prod_type,
div_eq_mul_inv, Finset.sum_mul]
rw [Finset.sum_comm]
simp
omit [Fintype S] in
theorem maskedJoint_firstMarginal_inr (p : S Γ— (X Γ— Y) β†’ ℝ) (s : S) (y : Y) :
Information.firstMarginal (maskedJoint p) (s, Sum.inr y) =
(βˆ‘ x, p (s, (x, y))) / 2 := by
simp [Information.firstMarginal, maskedJoint, Fintype.sum_prod_type,
div_eq_mul_inv, Finset.sum_mul]
private theorem abs_half_sub_half_mul (a b c : ℝ) :
|a / 2 - b / 2 * c| = |a - b * c| / 2 := by
rw [show a / 2 - b / 2 * c = (a - b * c) / 2 by ring, abs_div]
norm_num
omit [Fintype S] in
theorem abs_masked_inl (ΞΌ : Games.FiniteDistribution (X Γ— Y))
(p : S Γ— (X Γ— Y) β†’ ℝ) (s : S) (u x : X) (y : Y) :
|maskedJoint p ((s, Sum.inl u), (x, y)) - maskedModel ΞΌ p ((s, Sum.inl u), (x, y))| =
if x = u then |p (s, (x, y)) - leftRevealModel ΞΌ p (s, (x, y))| / 2 else 0 := by
by_cases hx : x = u
Β· subst x
simp only [maskedModel, maskedJoint_firstMarginal_inl]
simpa [maskedJoint, leftRevealModel] using
abs_half_sub_half_mul (p (s, (u, y))) (βˆ‘ v, p (s, (u, v)))
((revealProfile ΞΌ (Sum.inl u)).weight (u, y))
Β· have hs := revealProfile_inl_support ΞΌ u (x, y) hx
simp [maskedJoint, maskedModel, hs, hx, Ne.symm hx]
omit [Fintype S] in
theorem abs_masked_inr (ΞΌ : Games.FiniteDistribution (X Γ— Y))
(p : S Γ— (X Γ— Y) β†’ ℝ) (s : S) (v : Y) (x : X) (y : Y) :
|maskedJoint p ((s, Sum.inr v), (x, y)) - maskedModel ΞΌ p ((s, Sum.inr v), (x, y))| =
if y = v then |p (s, (x, y)) - rightRevealModel ΞΌ p (s, (x, y))| / 2 else 0 := by
by_cases hy : y = v
Β· subst y
simp only [maskedModel, maskedJoint_firstMarginal_inr]
simpa [maskedJoint, rightRevealModel] using
abs_half_sub_half_mul (p (s, (x, v))) (βˆ‘ u, p (s, (u, v)))
((revealProfile ΞΌ (Sum.inr v)).weight (x, v))
Β· have hs := revealProfile_inr_support ΞΌ v (x, y) hy
simp [maskedJoint, maskedModel, hs, hy, Ne.symm hy]
theorem masked_totalVariation_identity (ΞΌ : Games.FiniteDistribution (X Γ— Y))
(p : S Γ— (X Γ— Y) β†’ ℝ) :
2 * Information.totalVariation (maskedJoint p) (maskedModel ΞΌ p) =
Information.totalVariation p (leftRevealModel ΞΌ p) +
Information.totalVariation p (rightRevealModel ΞΌ p) := by
have hleft (s : S) :
(βˆ‘ u : X, βˆ‘ q : X Γ— Y,
|maskedJoint p ((s, Sum.inl u), q) - maskedModel ΞΌ p ((s, Sum.inl u), q)|) =
(βˆ‘ q : X Γ— Y, |p (s, q) - leftRevealModel ΞΌ p (s, q)|) / 2 := by
simp_rw [Fintype.sum_prod_type, abs_masked_inl]
simp [Finset.sum_ite_irrel, div_eq_mul_inv, Finset.sum_mul]
have hright (s : S) :
(βˆ‘ v : Y, βˆ‘ q : X Γ— Y,
|maskedJoint p ((s, Sum.inr v), q) - maskedModel ΞΌ p ((s, Sum.inr v), q)|) =
(βˆ‘ q : X Γ— Y, |p (s, q) - rightRevealModel ΞΌ p (s, q)|) / 2 := by
have hcollapse :
(βˆ‘ v : Y, βˆ‘ q : X Γ— Y,
|maskedJoint p ((s, Sum.inr v), q) - maskedModel ΞΌ p ((s, Sum.inr v), q)|) =
βˆ‘ v : Y, βˆ‘ x : X, |p (s, (x, v)) - rightRevealModel ΞΌ p (s, (x, v))| / 2 := by
simp [Fintype.sum_prod_type, abs_masked_inr]
rw [hcollapse, Finset.sum_comm]
simp [Fintype.sum_prod_type, div_eq_mul_inv, Finset.sum_mul]
have hmass :
(βˆ‘ z : (S Γ— (X βŠ• Y)) Γ— (X Γ— Y), |maskedJoint p z - maskedModel ΞΌ p z|) =
((βˆ‘ z : S Γ— (X Γ— Y), |p z - leftRevealModel ΞΌ p z|) +
(βˆ‘ z : S Γ— (X Γ— Y), |p z - rightRevealModel ΞΌ p z|)) / 2 := by
calc
_ = βˆ‘ s : S,
((βˆ‘ u : X, βˆ‘ q : X Γ— Y, |maskedJoint p ((s, Sum.inl u), q) - maskedModel ΞΌ p ((s, Sum.inl u), q)|) +
(βˆ‘ v : Y, βˆ‘ q : X Γ— Y, |maskedJoint p ((s, Sum.inr v), q) - maskedModel ΞΌ p ((s, Sum.inr v), q)|)) := by
simp only [Fintype.sum_prod_type, Fintype.sum_sum_type]
_ = βˆ‘ s : S,
((βˆ‘ q : X Γ— Y, |p (s, q) - leftRevealModel ΞΌ p (s, q)|) / 2 +
(βˆ‘ q : X Γ— Y, |p (s, q) - rightRevealModel ΞΌ p (s, q)|) / 2) := by
simp_rw [hleft, hright]
_ = _ := by
simp [Fintype.sum_prod_type, div_eq_mul_inv, Finset.sum_add_distrib, Finset.sum_mul, add_mul]
unfold Information.totalVariation
rw [hmass]
ring
theorem leftRevealModel_totalVariation_le (ΞΌ : Games.FiniteDistribution (X Γ— Y))
(p : S Γ— (X Γ— Y) β†’ ℝ) :
Information.totalVariation p (leftRevealModel ΞΌ p) ≀
2 * Information.totalVariation (maskedJoint p) (maskedModel ΞΌ p) := by
rw [masked_totalVariation_identity]
linarith [Information.totalVariation_nonneg p (rightRevealModel ΞΌ p)]
theorem rightRevealModel_totalVariation_le (ΞΌ : Games.FiniteDistribution (X Γ— Y))
(p : S Γ— (X Γ— Y) β†’ ℝ) :
Information.totalVariation p (rightRevealModel ΞΌ p) ≀
2 * Information.totalVariation (maskedJoint p) (maskedModel ΞΌ p) := by
rw [masked_totalVariation_identity]
linarith [Information.totalVariation_nonneg p (leftRevealModel ΞΌ p)]
end
section
open scoped BigOperators
open Games Information
variable {Q₁ Qβ‚‚ A₁ Aβ‚‚ : Type*}
[Fintype Q₁] [Fintype Qβ‚‚] [Fintype A₁] [Fintype Aβ‚‚]
[DecidableEq Q₁] [DecidableEq Qβ‚‚] {n : Nat}
def selectedJointWeight (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n))
(z : (SelectedInput Q₁ Qβ‚‚ selected Γ— SelectedLabels (A₁ := A₁) (Aβ‚‚ := Aβ‚‚) selected) Γ—
({i : Fin n // i βˆ‰ selected} β†’ Q₁ Γ— Qβ‚‚)) : ℝ :=
(selectedInputLaw G selected).weight z.1.1 *
independentProduct (fun i => (selectedInputProfile G selected z.1.1 i).weight) z.2 *
selectedLikelihood G strategy selected z.1.1.1 z.1.2 z.2 /
G.selectedSuccess strategy selected
omit [DecidableEq Q₁] [DecidableEq Qβ‚‚] in
theorem selectedJointWeight_nonnegative (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (z) : 0 ≀ selectedJointWeight G strategy selected z := by
apply div_nonneg
Β· exact mul_nonneg
(mul_nonneg ((selectedInputLaw G selected).nonnegative _)
((independentProduct_isProbability _
(fun i => gameLaw_isProbability (selectedInputProfile G selected z.1.1 i))).1 z.2))
(selectedLikelihood_nonnegative G strategy selected z.1.1.1 z.1.2 z.2)
Β· exact G.selectedSuccess_nonnegative strategy selected
omit [DecidableEq Q₁] [DecidableEq Qβ‚‚] in
theorem selectedJointWeight_firstMarginal (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (tv) :
firstMarginal (selectedJointWeight G strategy selected) tv =
selectedSideWeight G strategy selected tv := by
simp only [firstMarginal, selectedJointWeight, selectedSideWeight, selectedSideMass,
div_eq_mul_inv, Finset.mul_sum, Finset.sum_mul]
apply Finset.sum_congr rfl
intro i _
ring
theorem selectedJointWeight_isProbability (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected) :
IsProbability (selectedJointWeight G strategy selected) := by
constructor
Β· exact selectedJointWeight_nonnegative G strategy selected
Β· rw [Fintype.sum_prod_type]
change (βˆ‘ tv, firstMarginal (selectedJointWeight G strategy selected) tv) = 1
simp_rw [selectedJointWeight_firstMarginal, selectedSideWeight, div_eq_mul_inv]
rw [← Finset.sum_mul, selectedSideMass_total, mul_inv_cancelβ‚€ positive.ne']
def selectedJointLaw (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected) :=
toGameLaw (selectedJointWeight G strategy selected)
(selectedJointWeight_isProbability G strategy selected positive)
theorem selectedJointWeight_factorization (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (tv) (u) :
selectedJointWeight G strategy selected (tv,u) =
(∏ i : selected, G.questions.weight (tv.1.1 i)) *
(∏ i : {i : Fin n // i βˆ‰ selected}, (revealLaw G.questions).weight (u i,tv.1.2 i)) *
selectedLikelihood G strategy selected tv.1.1 tv.2 u /
G.selectedSuccess strategy selected := by
unfold selectedJointWeight
simp only [selectedInputLaw, FiniteDistribution.product, FiniteDistribution.table,
independentProduct, selectedInputProfile]
rw [mul_assoc (∏ i : selected, G.questions.weight (tv.1.1 i)), reveal_product_factorization]
end
open scoped BigOperators
open Games Information
variable {Q₁ Qβ‚‚ A₁ Aβ‚‚ : Type*}
[Fintype Q₁] [Fintype Qβ‚‚] [Fintype A₁] [Fintype Aβ‚‚]
[DecidableEq Q₁] [DecidableEq Qβ‚‚]
{n : Nat}
def selectedTupleLikelihood (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (questions : Fin n β†’ Q₁ Γ— Qβ‚‚) : ℝ :=
if G.selectedWins strategy selected (Game.tupleQuestionEquiv n questions) then 1 else 0
omit [DecidableEq Q₁] [DecidableEq Qβ‚‚] in
theorem selectedTupleLikelihood_nonnegative (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (questions : Fin n β†’ Q₁ Γ— Qβ‚‚) :
0 ≀ selectedTupleLikelihood G strategy selected questions := by
unfold selectedTupleLikelihood
split <;> norm_num
omit [DecidableEq Q₁] [DecidableEq Qβ‚‚] in
theorem selectedTupleLikelihood_le_one (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (questions : Fin n β†’ Q₁ Γ— Qβ‚‚) :
selectedTupleLikelihood G strategy selected questions ≀ 1 := by
unfold selectedTupleLikelihood
split <;> norm_num
omit [DecidableEq Q₁] [DecidableEq Qβ‚‚] in
theorem selectedTupleLikelihood_mass (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) :
(βˆ‘ questions, independentProduct (fun _ : Fin n => G.questions.weight) questions *
selectedTupleLikelihood G strategy selected questions) =
G.selectedSuccess strategy selected := by
classical
change _ = ((G.questions.iid n).transport (Game.tupleQuestionEquiv n)).probability
(G.selectedWins strategy selected)
rw [FiniteDistribution.probability_transport]
simp only [FiniteDistribution.probability, FiniteDistribution.iid, independentProduct,
selectedTupleLikelihood, mul_ite, mul_one, mul_zero]
def selectedQuestionMarginal (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected)
(i : Fin n) : FiniteDistribution (Q₁ Γ— Qβ‚‚) :=
((G.repetition n).questions.condition (G.selectedWins strategy selected) positive).pushforward
(fun questions => (questions.1 i, questions.2 i))
theorem selectedQuestionMarginal_weight (G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected)
(i : Fin n) :
(selectedQuestionMarginal G strategy selected positive i).weight =
coordinateMarginal
(posterior (independentProduct (fun _ : Fin n => G.questions.weight))
(selectedTupleLikelihood G strategy selected) (G.selectedSuccess strategy selected)) i := by
classical
funext a
simp only [selectedQuestionMarginal, FiniteDistribution.pushforward,
FiniteDistribution.condition, coordinateMarginal]
refine Fintype.sum_equiv (Game.tupleQuestionEquiv (Q₁ := Q₁) (Qβ‚‚ := Qβ‚‚) n).symm _ _ ?_
intro questions
cases he : G.selectedWins strategy selected questions <;>
simp [Game.repetition_question_weight, Game.tupleQuestionEquiv,
posterior, independentProduct, selectedTupleLikelihood, Game.selectedSuccess, he]
theorem selectedQuestionMarginal_totalVariation_sq_sum_le_log
(G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected) :
(βˆ‘ i : Fin n,
(selectedQuestionMarginal G strategy selected positive i).totalVariation G.questions ^ 2) ≀
Real.log (1 / G.selectedSuccess strategy selected) := by
classical
change (βˆ‘ i : Fin n, Information.totalVariation
(selectedQuestionMarginal G strategy selected positive i).weight G.questions.weight ^ 2) ≀ _
simp_rw [selectedQuestionMarginal_weight]
exact posterior_coordinate_totalVariation_sq_sum_le_log
(fun _ : Fin n => G.questions.weight) (fun _ => gameLaw_isProbability G.questions)
(selectedTupleLikelihood G strategy selected)
(selectedTupleLikelihood_nonnegative G strategy selected)
(selectedTupleLikelihood_le_one G strategy selected)
positive (selectedTupleLikelihood_mass G strategy selected)
theorem unselectedQuestionMarginal_totalVariation_sq_sum_le_log
(G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected) :
(βˆ‘ i : {i : Fin n // i βˆ‰ selected},
(selectedQuestionMarginal G strategy selected positive i.1).totalVariation G.questions ^ 2) ≀
Real.log (1 / G.selectedSuccess strategy selected) := by
classical
let d : Fin n β†’ ℝ := fun i =>
(selectedQuestionMarginal G strategy selected positive i).totalVariation G.questions
have hfull := selectedQuestionMarginal_totalVariation_sq_sum_le_log G strategy selected positive
have hsplit := Fintype.sum_subtype_add_sum_subtype (fun i : Fin n => i ∈ selected)
(fun i => d i ^ 2)
have hinst : Subtype.fintype (fun i : Fin n => i ∈ selected) =
Finset.Subtype.fintype selected := Subsingleton.elim _ _
rw [hinst] at hsplit
have hselected : 0 ≀ βˆ‘ i : {i : Fin n // i ∈ selected}, d i.1 ^ 2 :=
Finset.sum_nonneg (fun _ _ => sq_nonneg _)
change (βˆ‘ i : {i : Fin n // i βˆ‰ selected}, d i.1 ^ 2) ≀ _
change (βˆ‘ i : Fin n, d i ^ 2) ≀ _ at hfull
linarith
theorem unselectedQuestionMarginal_totalVariation_sum_le_sqrt
(G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected) :
(βˆ‘ i : {i : Fin n // i βˆ‰ selected},
(selectedQuestionMarginal G strategy selected positive i.1).totalVariation G.questions) ≀
Real.sqrt ((Fintype.card {i : Fin n // i βˆ‰ selected} : ℝ) *
Real.log (1 / G.selectedSuccess strategy selected)) := by
classical
let d : {i : Fin n // i βˆ‰ selected} β†’ ℝ := fun i =>
(selectedQuestionMarginal G strategy selected positive i.1).totalVariation G.questions
have hsq := unselectedQuestionMarginal_totalVariation_sq_sum_le_log G strategy selected positive
have hcs := Finset.sum_mul_sq_le_sq_mul_sq
(Finset.univ : Finset {i : Fin n // i βˆ‰ selected}) d (fun _ => (1 : ℝ))
simp only [mul_one, one_pow, Finset.sum_const, Finset.card_univ, nsmul_eq_mul, mul_one] at hcs
have hln : 0 ≀ Real.log (1 / G.selectedSuccess strategy selected) :=
(Finset.sum_nonneg (fun _ _ => sq_nonneg _)).trans hsq
have hcard : 0 ≀ (Fintype.card {i : Fin n // i βˆ‰ selected} : ℝ) := Nat.cast_nonneg _
have hmul := mul_le_mul_of_nonneg_left hsq hcard
have hsqrt := Real.sq_sqrt (mul_nonneg hcard hln)
have hsqrtpos := Real.sqrt_nonneg
((Fintype.card {i : Fin n // i βˆ‰ selected} : ℝ) *
Real.log (1 / G.selectedSuccess strategy selected))
change (βˆ‘ i, d i) ≀ _
change (βˆ‘ i, d i ^ 2) ≀ _ at hsq
change (Fintype.card {i : Fin n // i βˆ‰ selected} : ℝ) * (βˆ‘ i, d i ^ 2) ≀ _ at hmul
nlinarith
theorem unselectedQuestionMarginal_totalVariation_sum_le_sqrt_sub_card
(G : Game Q₁ Qβ‚‚ A₁ Aβ‚‚)
(strategy : Strategy (Fin n β†’ Q₁) (Fin n β†’ Qβ‚‚) (Fin n β†’ A₁) (Fin n β†’ Aβ‚‚))
(selected : Finset (Fin n)) (positive : 0 < G.selectedSuccess strategy selected) :
(βˆ‘ i : {i : Fin n // i βˆ‰ selected},
(selectedQuestionMarginal G strategy selected positive i.1).totalVariation G.questions) ≀
Real.sqrt (((n - selected.card : Nat) : ℝ) *
Real.log (1 / G.selectedSuccess strategy selected)) := by
classical
have hcard : Fintype.card {i : Fin n // i βˆ‰ selected} = n - selected.card := by
simp
simpa only [hcard] using
unselectedQuestionMarginal_totalVariation_sum_le_sqrt G strategy selected positive
end BinPackingGames.Foundations.Repetition
end
end OAI