introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
10 kB
import Mathlib
import OAI.Combinatorics.IndependentSets.Repetition.Rectangle
namespace OAI
noncomputable section
namespace IndependentSetsGames.Foundations.CorrelatedSampling
section
variable {Οƒ Ξ± : Type*} [Fintype Οƒ] [DecidableEq Οƒ] [DecidableEq Ξ±]
variable [Fintype Ξ±] [Nonempty Ξ±]
theorem rectangle_label_diagonal_bound (thresholds : List ℝ) (p q : Ξ± β†’ ℝ)
(fallback a : Ξ±)
(hpm : βˆ€ x, p x ∈ thresholds) (hqm : βˆ€ x, q x ∈ thresholds)
(hp0 : βˆ€ x, 0 ≀ p x) (hq0 : βˆ€ x, 0 ≀ q x)
(hp1 : βˆ€ x, p x ≀ 1) (hq1 : βˆ€ x, q x ≀ 1)
(hpsum : βˆ‘ x, p x = 1) (hqsum : βˆ‘ x, q x = 1) (n : Nat) :
min (p a) (q a) / (1 + totalVariation p q) *
(1 - eventMass (rectangleWeight thresholds)
(fun s => !(rectangleAccept thresholds p s || rectangleAccept thresholds q s)) ^ n) ≀
traceAverage (rectangleWeight thresholds) n
(localDiagonal (rectangleAccept thresholds p) (rectangleAccept thresholds q)
Prod.fst fallback a) := by
have hc : 0 < (Fintype.card Ξ± : ℝ) := by exact_mod_cast Fintype.card_pos
have hU : 0 < unionMass p q := by
rw [unionMass_eq p q hpsum hqsum]
linarith [totalVariation_nonneg p q]
have hmass := rectangle_union_mass thresholds p q hpm hqm hp0 hq0 hp1 hq1
have hu : 0 < eventMass (rectangleWeight thresholds)
(fun s => rectangleAccept thresholds p s || rectangleAccept thresholds q s) := by
rw [hmass]
exact div_pos hU hc
have h := finite_label_diagonal_bound (rectangleWeight thresholds)
(rectangleAccept thresholds p) (rectangleAccept thresholds q) Prod.fst fallback a
(rectangleWeight_nonnegative thresholds) (rectangleWeight_normalized thresholds) hu n
unfold goodLabel at h
rw [rectangle_common_label_mass thresholds p q a hpm hqm hp0 hq0 hp1 hq1, hmass] at h
have hratio : (min (p a) (q a) / (Fintype.card Ξ± : ℝ)) /
(unionMass p q / (Fintype.card Ξ± : ℝ)) = min (p a) (q a) / unionMass p q := by
field_simp
rw [hratio, unionMass_eq p q hpsum hqsum] at h
exact h
end
open scoped BigOperators
def profileThresholds {ΞΊ S : Type*} [Fintype ΞΊ] [Fintype S]
(P : ΞΊ β†’ S β†’ ℝ) : List ℝ := by
classical
exact (Finset.univ.toList : List (ΞΊ Γ— S)).map (fun ks => P ks.1 ks.2)
theorem mem_profileThresholds {ΞΊ S : Type*} [Fintype ΞΊ] [Fintype S]
(P : ΞΊ β†’ S β†’ ℝ) (k : ΞΊ) (s : S) : P k s ∈ profileThresholds P := by
classical
exact List.mem_map.mpr ⟨(k, s), by simp, rfl⟩
theorem distribution_weight_le_one {S : Type*} [Fintype S]
(ΞΌ : Games.FiniteDistribution S) (s : S) : ΞΌ.weight s ≀ 1 := by
calc
ΞΌ.weight s ≀ βˆ‘ t, ΞΌ.weight t :=
Finset.single_le_sum (fun t _ => ΞΌ.nonnegative t) (Finset.mem_univ s)
_ = 1 := ΞΌ.normalized
variable {Q₁ Qβ‚‚ S : Type*} [Fintype Q₁] [Fintype Qβ‚‚] [Fintype S]
def sharedProfileThresholds (L : Q₁ β†’ Games.FiniteDistribution S)
(R : Qβ‚‚ β†’ Games.FiniteDistribution S) : List ℝ :=
profileThresholds (fun (k : Q₁ βŠ• Qβ‚‚) s => (Sum.elim L R k).weight s)
theorem left_mem_sharedProfileThresholds (L : Q₁ β†’ Games.FiniteDistribution S)
(R : Qβ‚‚ β†’ Games.FiniteDistribution S) (x : Q₁) (s : S) :
(L x).weight s ∈ sharedProfileThresholds L R := by
exact mem_profileThresholds _ (Sum.inl x) s
theorem right_mem_sharedProfileThresholds (L : Q₁ β†’ Games.FiniteDistribution S)
(R : Qβ‚‚ β†’ Games.FiniteDistribution S) (y : Qβ‚‚) (s : S) :
(R y).weight s ∈ sharedProfileThresholds L R := by
exact mem_profileThresholds _ (Sum.inr y) s
abbrev SharedProfileSeed (L : Q₁ β†’ Games.FiniteDistribution S)
(R : Qβ‚‚ β†’ Games.FiniteDistribution S) :=
RectangleSeed (sharedProfileThresholds L R) S
def sharedProfileLeft (L : Q₁ β†’ Games.FiniteDistribution S)
(R : Qβ‚‚ β†’ Games.FiniteDistribution S) (x : Q₁) : SharedProfileSeed L R β†’ Bool :=
rectangleAccept (sharedProfileThresholds L R) (L x).weight
def sharedProfileRight (L : Q₁ β†’ Games.FiniteDistribution S)
(R : Qβ‚‚ β†’ Games.FiniteDistribution S) (y : Qβ‚‚) : SharedProfileSeed L R β†’ Bool :=
rectangleAccept (sharedProfileThresholds L R) (R y).weight
def sharedProfileReject (L : Q₁ β†’ Games.FiniteDistribution S)
(R : Qβ‚‚ β†’ Games.FiniteDistribution S) (x : Q₁) (y : Qβ‚‚) : ℝ :=
eventMass (rectangleWeight (sharedProfileThresholds L R))
(fun s => !(sharedProfileLeft L R x s || sharedProfileRight L R y s))
def uniformRejectionRate (S : Type*) [Fintype S] : ℝ :=
1 - 1 / (Fintype.card S : ℝ)
theorem uniformRejectionRate_nonnegative (S : Type*) [Fintype S] [Nonempty S] :
0 ≀ uniformRejectionRate S := by
have hc : (0 : ℝ) < Fintype.card S := by
exact_mod_cast (Fintype.card_pos : 0 < Fintype.card S)
have hc₁ : (1 : ℝ) ≀ Fintype.card S := by
exact_mod_cast (Nat.succ_le_of_lt (Fintype.card_pos : 0 < Fintype.card S))
apply sub_nonneg.mpr
exact (div_le_iffβ‚€ hc).2 (by simpa using hc₁)
theorem uniformRejectionRate_lt_one (S : Type*) [Fintype S] [Nonempty S] :
uniformRejectionRate S < 1 := by
have hc : (0 : ℝ) < Fintype.card S := by
exact_mod_cast (Fintype.card_pos : 0 < Fintype.card S)
have hp : (0 : ℝ) < 1 / (Fintype.card S : ℝ) := div_pos (by norm_num) hc
dsimp [uniformRejectionRate]
linarith
theorem sharedProfileReject_nonnegative [Nonempty S]
(L : Q₁ β†’ Games.FiniteDistribution S) (R : Qβ‚‚ β†’ Games.FiniteDistribution S)
(x : Q₁) (y : Qβ‚‚) : 0 ≀ sharedProfileReject L R x y := by
exact eventMass_nonneg _ _
(rectangleDistribution (Ξ± := S) (sharedProfileThresholds L R)).nonnegative
theorem sharedProfile_reject_le_rate [Nonempty S]
(L : Q₁ β†’ Games.FiniteDistribution S) (R : Qβ‚‚ β†’ Games.FiniteDistribution S)
(x : Q₁) (y : Qβ‚‚) : sharedProfileReject L R x y ≀ uniformRejectionRate S := by
let thresholds := sharedProfileThresholds L R
have hsum : (βˆ‘ s : RectangleSeed thresholds S, rectangleWeight thresholds s) = 1 :=
(rectangleDistribution (Ξ± := S) thresholds).normalized
have hcomp := eventMass_complement (rectangleWeight thresholds)
(fun s => sharedProfileLeft L R x s || sharedProfileRight L R y s) hsum
have hu : eventMass (rectangleWeight thresholds)
(fun s => sharedProfileLeft L R x s || sharedProfileRight L R y s) =
(1 + totalVariation (L x).weight (R y).weight) / (Fintype.card S : ℝ) := by
change eventMass (rectangleWeight thresholds)
(fun s => rectangleAccept thresholds (L x).weight s ||
rectangleAccept thresholds (R y).weight s) = _
rw [rectangle_union_mass thresholds (L x).weight (R y).weight
(left_mem_sharedProfileThresholds L R x)
(right_mem_sharedProfileThresholds L R y)
(L x).nonnegative (R y).nonnegative
(distribution_weight_le_one (L x)) (distribution_weight_le_one (R y))]
rw [unionMass_eq (L x).weight (R y).weight (L x).normalized (R y).normalized]
have hc : (0 : ℝ) < Fintype.card S := by
exact_mod_cast (Fintype.card_pos : 0 < Fintype.card S)
have htv := totalVariation_nonneg (L x).weight (R y).weight
have hquot : 1 / (Fintype.card S : ℝ) ≀
(1 + totalVariation (L x).weight (R y).weight) / (Fintype.card S : ℝ) :=
(div_le_div_iff_of_pos_right hc).2 (by linarith)
rw [hu] at hcomp
change eventMass (rectangleWeight thresholds)
(fun s => !(sharedProfileLeft L R x s || sharedProfileRight L R y s)) ≀
1 - 1 / (Fintype.card S : ℝ)
linarith
private theorem nonnegative_powers_mono (a b : ℝ) (ha : 0 ≀ a) (hab : a ≀ b)
(n : β„•) : a ^ n ≀ b ^ n := by
have hb : 0 ≀ b := le_trans ha hab
induction n with
| zero => simp
| succ n ih =>
rw [pow_succ, pow_succ]
exact mul_le_mul ih hab ha (pow_nonneg hb n)
theorem sharedProfile_label_diagonal_bound [Nonempty S] [DecidableEq S]
(L : Q₁ β†’ Games.FiniteDistribution S) (R : Qβ‚‚ β†’ Games.FiniteDistribution S)
(x : Q₁) (y : Qβ‚‚) (fallback a : S) (n : β„•) :
min ((L x).weight a) ((R y).weight a) /
(1 + totalVariation (L x).weight (R y).weight) *
(1 - uniformRejectionRate S ^ n) ≀
traceAverage (rectangleWeight (sharedProfileThresholds L R)) n
(localDiagonal (sharedProfileLeft L R x) (sharedProfileRight L R y)
Prod.fst fallback a) := by
have hp := nonnegative_powers_mono (sharedProfileReject L R x y)
(uniformRejectionRate S) (sharedProfileReject_nonnegative L R x y)
(sharedProfile_reject_le_rate L R x y) n
have htv := totalVariation_nonneg (L x).weight (R y).weight
have hm : 0 ≀ min ((L x).weight a) ((R y).weight a) /
(1 + totalVariation (L x).weight (R y).weight) :=
div_nonneg (le_min ((L x).nonnegative a) ((R y).nonnegative a)) (by linarith)
have hsurv :
min ((L x).weight a) ((R y).weight a) /
(1 + totalVariation (L x).weight (R y).weight) *
(1 - uniformRejectionRate S ^ n) ≀
min ((L x).weight a) ((R y).weight a) /
(1 + totalVariation (L x).weight (R y).weight) *
(1 - sharedProfileReject L R x y ^ n) :=
mul_le_mul_of_nonneg_left (by linarith) hm
refine hsurv.trans ?_
simpa only [sharedProfileReject, sharedProfileLeft, sharedProfileRight] using
rectangle_label_diagonal_bound (sharedProfileThresholds L R)
(L x).weight (R y).weight fallback a
(left_mem_sharedProfileThresholds L R x)
(right_mem_sharedProfileThresholds L R y)
(L x).nonnegative (R y).nonnegative
(distribution_weight_le_one (L x)) (distribution_weight_le_one (R y))
(L x).normalized (R y).normalized n
theorem exists_uniformRejectionRate_pow_lt (S : Type*) [Fintype S] [Nonempty S]
(Ξ· : ℝ) (hΞ· : 0 < Ξ·) : βˆƒ n : β„•, uniformRejectionRate S ^ n < Ξ· := by
have ht := tendsto_pow_atTop_nhds_zero_of_lt_one
(uniformRejectionRate_nonnegative S) (uniformRejectionRate_lt_one S)
exact (ht.eventually (gt_mem_nhds hΞ·)).exists
end IndependentSetsGames.Foundations.CorrelatedSampling
end
end OAI