Download data/lean/OAI/Computability/BinPacking/Games/QuestionMarginal.lean from introvoyz045/math: direct link, hf CLI and curl.
- Browser
- Download file 47.6 kB
-
https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/BinPacking/Games/QuestionMarginal.lean
- Command line
-
hf download hf://datasets/introvoyz045/math/data/lean/OAI/Computability/BinPacking/Games/QuestionMarginal.lean
-
curl -L -o QuestionMarginal.lean https://huggingface.co/datasets/introvoyz045/math/resolve/main/data/lean/OAI/Computability/BinPacking/Games/QuestionMarginal.lean
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 | |