File size: 9,140 Bytes
4a56cd6 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 | import Mathlib
import OAI.Combinatorics.IndependentSets.Repetition.Scalar
import OAI.Combinatorics.IndependentSets.Repetition.CoordinateCompletion
namespace OAI
noncomputable section
namespace IndependentSetsGames.Foundations.Repetition
section
open scoped BigOperators
open Games CorrelatedSampling
variable {Qβ Qβ Aβ Aβ S : Type*}
[Fintype Qβ] [Fintype Qβ] [Fintype Aβ] [Fintype Aβ] [Fintype S]
[Nonempty Aβ] [Nonempty Aβ] [Nonempty S]
[DecidableEq Qβ] [DecidableEq Qβ] [DecidableEq S] {n : Nat}
theorem coordinate_probability_le_value_of_local_completion
(G : Game Qβ Qβ Aβ Aβ) (j : Fin n)
(strategy : Strategy (Fin n β Qβ) (Fin n β Qβ) (Fin n β Aβ) (Fin n β Aβ))
(Ο : FiniteDistribution ((Qβ Γ Qβ) Γ S))
(profileL : Qβ β FiniteDistribution S) (profileR : Qβ β FiniteDistribution S)
(completionL : Qβ Γ S β FiniteDistribution (Fin n β Qβ))
(completionR : Qβ Γ S β FiniteDistribution (Fin n β Qβ))
(supportL : β q xs, (completionL q).weight xs β 0 β xs j = q.1)
(supportR : β q ys, (completionR q).weight ys β 0 β ys j = q.1)
(fallback : S) :
(Ο.mixture (fun z => (completionL (z.1.1,z.2)).product
(completionR (z.1.2,z.2)))).probability (G.coordinateWin strategy j) β€
G.value +
(2 * Information.totalVariation Ο.weight
(fun z => G.questions.weight z.1 * (profileL z.1.1).weight z.2) +
2 * Information.totalVariation Ο.weight
(fun z => G.questions.weight z.1 * (profileR z.1.2).weight z.2)) := by
let targetLaw := Ο.mixture (fun z => (completionL (z.1.1,z.2)).product (completionR (z.1.2,z.2)))
let Ξ΄ := 2 * Information.totalVariation Ο.weight
(fun z => G.questions.weight z.1 * (profileL z.1.1).weight z.2) +
2 * Information.totalVariation Ο.weight
(fun z => G.questions.weight z.1 * (profileR z.1.2).weight z.2)
change targetLaw.probability (G.coordinateWin strategy j) β€ G.value + Ξ΄
by_contra h
have gap : 0 < targetLaw.probability (G.coordinateWin strategy j) - (G.value + Ξ΄) :=
sub_pos.mpr (lt_of_not_ge h)
let Ξ· := (targetLaw.probability (G.coordinateWin strategy j) - (G.value + Ξ΄)) / 2
have hΞ· : 0 < Ξ· := by dsimp [Ξ·]; linarith
obtain β¨N,hNβ© := samplerOutputLaw_arbitrarily_close Ο G.questions profileL profileR fallback Ξ· hΞ·
let thresholds := sharedProfileThresholds profileL profileR
let Ξ³ := traceSeedLaw (rectangleDistribution (Ξ± := S) thresholds) N
let sL := samplerLocal thresholds profileL fallback N
let sR := samplerLocal thresholds profileR fallback N
have hvariation := CompletedSampling.coordinateOutputLaw_totalVariation_le
G.questions Ξ³ j sL sR completionL completionR supportL supportR Ο
have hclose : (CompletedSampling.coordinateOutputLaw G.questions Ξ³ j sL sR completionL completionR).totalVariation targetLaw β€ Ξ΄ + Ξ· :=
hvariation.trans hN
have hsuccess := G.coordinate_probability_le_value_add_embedding_distance j targetLaw
(CompletedSampling.seedLaw Ξ³ completionL completionR)
(CompletedSampling.coordinateLeft j sL) (CompletedSampling.coordinateRight j sR)
(CompletedSampling.coordinateLeft_preserves j sL)
(CompletedSampling.coordinateRight_preserves j sR) strategy
have hsym : targetLaw.totalVariation
(G.localEmbeddingLaw (CompletedSampling.seedLaw Ξ³ completionL completionR)
(CompletedSampling.coordinateLeft j sL) (CompletedSampling.coordinateRight j sR)) =
(CompletedSampling.coordinateOutputLaw G.questions Ξ³ j sL sR completionL completionR).totalVariation targetLaw := by
unfold FiniteDistribution.totalVariation
congr 1
apply Finset.sum_congr rfl
intro q _
exact abs_sub_comm _ _
rw [hsym] at hsuccess
dsimp [Ξ·] at hclose
linarith
end
open scoped BigOperators
open Games
variable {Qβ Qβ Aβ Aβ : Type*}
[Fintype Qβ] [Fintype Qβ] [Fintype Aβ] [Fintype Aβ]
[DecidableEq Qβ] [DecidableEq Qβ] {n : β}
theorem selectedLabels_card (selected : Finset (Fin n)) :
Fintype.card (SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected) =
(Fintype.card Aβ * Fintype.card Aβ) ^ selected.card := by
simp [SelectedLabels, Fintype.card_prod, mul_pow]
theorem unusedCoordinates_card (selected : Finset (Fin n)) :
Fintype.card {i : Fin n // i β selected} = n - selected.card := by
classical
simp
theorem unusedCoordinates_card_real (selected : Finset (Fin n)) :
(Fintype.card {i : Fin n // i β selected} : β) = (n : β) - selected.card := by
have hs : selected.card β€ n := by simpa using Finset.card_le_univ selected
rw [unusedCoordinates_card, Nat.cast_sub hs]
theorem log_le_logTwo {x : β} (hx : 1 β€ x) : Real.log x β€ logTwo x := by
have hlog : 0 β€ Real.log x := Real.log_nonneg hx
have htwo : 0 < Real.log 2 := Real.log_pos (by norm_num)
have htwo_le : Real.log 2 β€ 1 := by
convert Real.log_le_sub_one_of_pos (by norm_num : (0 : β) < 2) using 1
norm_num
unfold logTwo
apply (le_div_iffβ htwo).2
simpa using mul_le_mul_of_nonneg_left htwo_le hlog
theorem selectedLabels_log_le [Nonempty Aβ] [Nonempty Aβ]
(selected : Finset (Fin n)) (ell : β)
(hell : logTwo ((Fintype.card Aβ : β) * (Fintype.card Aβ : β)) β€ ell) :
Real.log (Fintype.card (SelectedLabels (Aβ := Aβ) (Aβ := Aβ) selected) : β) β€
(selected.card : β) * ell := by
have ha : (1 : β) β€ Fintype.card Aβ := by exact_mod_cast Fintype.card_pos (Ξ± := Aβ)
have hb : (1 : β) β€ Fintype.card Aβ := by exact_mod_cast Fintype.card_pos (Ξ± := Aβ)
have hab : (1 : β) β€ (Fintype.card Aβ : β) * (Fintype.card Aβ : β) := by nlinarith
rw [selectedLabels_card, Nat.cast_pow, Nat.cast_mul, Real.log_pow]
exact mul_le_mul_of_nonneg_left ((log_le_logTwo hab).trans hell) (Nat.cast_nonneg _)
omit [DecidableEq Qβ] [DecidableEq Qβ] in
theorem selectedInformationRadius_le [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)
(ell : β)
(hell : logTwo ((Fintype.card Aβ : β) * (Fintype.card Aβ : β)) β€ ell) :
selectedInformationRadius G strategy selected β€
Real.sqrt (((n : β) - selected.card) *
((selected.card : β) * ell + logTwo (1 / G.selectedSuccess strategy selected))) := by
have hprob : 1 β€ 1 / G.selectedSuccess strategy selected := by
apply (le_div_iffβ positive).2
simpa using G.selectedSuccess_le_one strategy selected
have hbudget := add_le_add (selectedLabels_log_le (Aβ := Aβ) (Aβ := Aβ) selected ell hell)
(log_le_logTwo hprob)
unfold selectedInformationRadius
rw [β unusedCoordinates_card_real selected]
apply Real.sqrt_le_sqrt
exact mul_le_mul_of_nonneg_left hbudget (Nat.cast_nonneg _)
theorem sqrt_budget_factor (a b : β) (ha : 0 < a) :
Real.sqrt (a * b) = a * Real.sqrt (b / a) := by
have he : a * b = a ^ 2 * (b / a) := by
field_simp
rw [he, Real.sqrt_mul (sq_nonneg a), Real.sqrt_sq (le_of_lt ha)]
omit [DecidableEq Qβ] [DecidableEq Qβ] in
theorem exists_coordinate_le_information_budget [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)
(ell : β)
(hell : logTwo ((Fintype.card Aβ : β) * (Fintype.card Aβ : β)) β€ ell)
(hselected : selected.card < n)
(error : {i : Fin n // i β selected} β β)
(hsum : (β j, error j) β€ 15 * selectedInformationRadius G strategy selected) :
β j : {i : Fin n // i β selected}, error j β€ 15 * Real.sqrt
(((selected.card : β) * ell + logTwo (1 / G.selectedSuccess strategy selected)) /
((n : β) - selected.card)) := by
classical
have hcard : 0 < Fintype.card {i : Fin n // i β selected} := by
rw [unusedCoordinates_card]
exact Nat.sub_pos_of_lt hselected
let : Nonempty {i : Fin n // i β selected} := Fintype.card_pos_iff.mp hcard
have hden : 0 < (n : β) - selected.card := by
rw [β unusedCoordinates_card_real selected]
exact_mod_cast hcard
have htotal := hsum.trans (mul_le_mul_of_nonneg_left
(selectedInformationRadius_le G strategy selected positive ell hell) (by norm_num : (0 : β) β€ 15))
rw [sqrt_budget_factor _ _ hden] at htotal
have havg : (β j, error j) β€ β _j : {i : Fin n // i β selected},
15 * Real.sqrt
(((selected.card : β) * ell + logTwo (1 / G.selectedSuccess strategy selected)) /
((n : β) - selected.card)) := by
simpa only [Finset.sum_const, Finset.card_univ, nsmul_eq_mul,
unusedCoordinates_card_real, mul_assoc, mul_left_comm] using htotal
obtain β¨j, _, hjβ© := Finset.exists_le_of_sum_le Finset.univ_nonempty havg
exact β¨j, hjβ©
end IndependentSetsGames.Foundations.Repetition
end
end OAI
|