cfahlgren1's picture
download
raw
22.9 kB
import Mathlib.Algebra.Order.Floor.Ring
import Mathlib.Analysis.Convex.SpecificFunctions.Basic
import Mathlib.Analysis.Real.Sqrt
import Mathlib.Tactic.FieldSimp
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.NormNum
import Mathlib.Tactic.Positivity
import Mathlib.Tactic.Ring
import OAI.Computability.BinPacking.Games.SelectedProfiles
namespace OAI
namespace BinPackingGames.Foundations.Repetition
noncomputable def logTwo (x : ℝ) : ℝ := Real.log x / Real.log 2
@[simp] theorem logTwo_one : logTwo 1 = 0 := by simp [logTwo]
theorem logTwo_inv_le_of_half_pow_le {p : ℝ} (m : ℕ)
(h : (1 / 2 : ℝ) ^ m ≤ p) : logTwo (1 / p) ≤ m := by
have hp : 0 < p := (pow_pos (by norm_num : (0 : ℝ) < 1 / 2) m).trans_le h
have hlog := Real.log_le_log (pow_pos (by norm_num : (0 : ℝ) < 1 / 2) m) h
have hhalf : Real.log (1 / 2 : ℝ) = -Real.log 2 := by
rw [one_div, Real.log_inv]
rw [Real.log_pow, hhalf] at hlog
unfold logTwo
rw [one_div, Real.log_inv]
apply (div_le_iff₀ (Real.log_pos (by norm_num : (1 : ℝ) < 2))).2
nlinarith
theorem contraction_step {v ell : ℝ} {n m : ℕ} {p next : ℝ}
(hv0 : 0 ≤ v) (hv1 : v < 1) (hell : 1 ≤ ell)
(hm : 1 ≤ m) (hmn : m < n) (hp : 0 ≤ p)
(hmono : next ≤ p)
(hprev : p ≤ ((1 + v) / 2) ^ m)
(hcut : 2700 * (m : ℝ) * ell ≤ (1 - v) ^ 2 * ((n : ℝ) - m))
(hstep : next ≤ p * (v + 15 * Real.sqrt
(((m : ℝ) * ell + logTwo (1 / p)) / ((n : ℝ) - m)))) :
next ≤ ((1 + v) / 2) ^ (m + 1) := by
by_cases hsmall : p ≤ ((1 + v) / 2) ^ (m + 1)
· exact hmono.trans hsmall
have hq : (1 / 2 : ℝ) ≤ (1 + v) / 2 := by linarith
have hhalf : (1 / 2 : ℝ) ^ (m + 1) ≤ p :=
(pow_le_pow_left₀ (by norm_num) hq (m + 1)).trans (le_of_not_ge hsmall)
have hlog := logTwo_inv_le_of_half_pow_le (m + 1) hhalf
have hmreal : (1 : ℝ) ≤ m := by exact_mod_cast hm
have hden : 0 < (n : ℝ) - m := by
have hmnreal : (m : ℝ) < n := by exact_mod_cast hmn
linarith
have hmell : (m : ℝ) ≤ (m : ℝ) * ell := by nlinarith
have hbudget : (m : ℝ) * ell + logTwo (1 / p) ≤ 3 * (m : ℝ) * ell := by
simp only [Nat.cast_add, Nat.cast_one] at hlog
nlinarith
have hsqrt : Real.sqrt
(((m : ℝ) * ell + logTwo (1 / p)) / ((n : ℝ) - m)) ≤ (1 - v) / 30 := by
apply (Real.sqrt_le_left (by linarith : 0 ≤ (1 - v) / 30)).2
apply (div_le_iff₀ hden).2
nlinarith
have hfactor : v + 15 * Real.sqrt
(((m : ℝ) * ell + logTwo (1 / p)) / ((n : ℝ) - m)) ≤ (1 + v) / 2 := by
linarith
calc
next ≤ p * (v + 15 * Real.sqrt
(((m : ℝ) * ell + logTwo (1 / p)) / ((n : ℝ) - m))) := hstep
_ ≤ p * ((1 + v) / 2) := mul_le_mul_of_nonneg_left hfactor hp
_ ≤ ((1 + v) / 2) ^ m * ((1 + v) / 2) :=
mul_le_mul_of_nonneg_right hprev (by linarith)
_ = ((1 + v) / 2) ^ (m + 1) := (pow_succ _ _).symm
theorem initial_step {v ell next : ℝ} {n : ℕ}
(hstep : next ≤ 1 * (v + 15 * Real.sqrt
(((0 : ℝ) * ell + logTwo (1 / 1)) / ((n : ℝ) - 0)))) :
next ≤ v := by simpa using hstep
theorem cutoff_step {v ell : ℝ} {n m : ℕ}
(hv0 : 0 ≤ v) (hv1 : v < 1) (hell : 1 ≤ ell)
(hm : (m : ℝ) < (n : ℝ) * (1 - v) ^ 2 / (2925 * ell)) :
2700 * (m : ℝ) * ell ≤ (1 - v) ^ 2 * ((n : ℝ) - m) := by
have hell0 : 0 < ell := by linarith
have hd : (1 - v) ^ 2 ≤ 1 := by nlinarith
have hmul : (m : ℝ) * (2925 * ell) < (n : ℝ) * (1 - v) ^ 2 :=
(lt_div_iff₀ (by positivity : 0 < 2925 * ell)).1 hm
have hdell : (1 - v) ^ 2 ≤ 225 * ell := by linarith
have hprod := mul_le_mul_of_nonneg_left hdell (Nat.cast_nonneg m : (0 : ℝ) ≤ m)
nlinarith
theorem cutoff_le_length {v ell : ℝ} (n : ℕ)
(hv0 : 0 ≤ v) (hv1 : v < 1) (hell : 1 ≤ ell) :
(n : ℝ) * (1 - v) ^ 2 / (2925 * ell) ≤ n := by
have hell0 : 0 < ell := by linarith
apply (div_le_iff₀ (by positivity : 0 < 2925 * ell)).2
have hd : (1 - v) ^ 2 ≤ 2925 * ell := by nlinarith
nlinarith [mul_le_mul_of_nonneg_left hd (Nat.cast_nonneg n : (0 : ℝ) ≤ n)]
def ScalarRecurrence (p : ℕ → ℝ) (n : ℕ) (v ell : ℝ) : Prop :=
∀ m, m < n → p (m + 1) ≤ p m * (v + 15 * Real.sqrt
(((m : ℝ) * ell + logTwo (1 / p m)) / ((n : ℝ) - m)))
theorem decay_to_cutoff (p : ℕ → ℝ) (n : ℕ) {v ell : ℝ}
(hv0 : 0 ≤ v) (hv1 : v < 1) (hell : 1 ≤ ell)
(hp0 : p 0 = 1) (hpnonneg : ∀ m, 0 ≤ p m)
(hpmono : Antitone p) (hrec : ScalarRecurrence p n v ell) :
p n ≤ ((1 + v) / 2) ^
((n : ℝ) * (1 - v) ^ 2 / (2925 * ell)) := by
let T : ℝ := (n : ℝ) * (1 - v) ^ 2 / (2925 * ell)
let M : ℕ := Nat.ceil T
have hMn : M ≤ n := Nat.ceil_le.mpr (cutoff_le_length n hv0 hv1 hell)
have hind : ∀ m, m ≤ M → p m ≤ ((1 + v) / 2) ^ m := by
intro m
induction m with
| zero => intro _; simp [hp0]
| succ m ih =>
intro hmM
have hmM' : m < M := Nat.lt_of_succ_le hmM
have hmn : m < n := hmM'.trans_le hMn
have hprev := ih (Nat.le_of_lt hmM')
by_cases hm0 : m = 0
· subst m
have hinit : p 1 ≤ v := by
have hs := hrec 0 hmn
simpa [hp0] using hs
simpa using hinit.trans (by linarith : v ≤ (1 + v) / 2)
· have hmT : (m : ℝ) < T := Nat.lt_ceil.mp hmM'
exact contraction_step hv0 hv1 hell (Nat.one_le_iff_ne_zero.mpr hm0)
hmn (hpnonneg m) (hpmono (Nat.le_succ m)) hprev
(cutoff_step hv0 hv1 hell hmT) (hrec m hmn)
have hq0 : 0 < (1 + v) / 2 := by linarith
have hq1 : (1 + v) / 2 ≤ 1 := by linarith
calc
p n ≤ p M := hpmono hMn
_ ≤ ((1 + v) / 2) ^ M := hind M le_rfl
_ = ((1 + v) / 2) ^ (M : ℝ) := (Real.rpow_natCast _ _).symm
_ ≤ ((1 + v) / 2) ^ T :=
Real.rpow_le_rpow_of_exponent_ge hq0 hq1 (Nat.le_ceil T)
theorem block_contraction {v : ℝ} (hv0 : 0 ≤ v) (hv1 : v < 1) :
((1 + v) / 2) ^ ((1 - v) ^ 2 / 2925 : ℝ) ≤
1 - (1 - v) ^ 3 / 5850 := by
have hd : (1 - v) ^ 2 ≤ 1 := by nlinarith
have hb := rpow_one_add_le_one_add_mul_self
(s := -(1 - v) / 2) (p := (1 - v) ^ 2 / 2925)
(by linarith) (by positivity) (by nlinarith)
have hbase : 1 + -(1 - v) / 2 = (1 + v) / 2 := by ring
have hrhs : 1 + (1 - v) ^ 2 / 2925 * (-(1 - v) / 2) =
1 - (1 - v) ^ 3 / 5850 := by ring
rwa [hbase, hrhs] at hb
theorem scalar_bound_6000 (p : ℕ → ℝ) (n : ℕ) {v ell : ℝ}
(hv0 : 0 ≤ v) (hv1 : v < 1) (hell : 1 ≤ ell)
(hp0 : p 0 = 1) (hpnonneg : ∀ m, 0 ≤ p m)
(hpmono : Antitone p) (hrec : ScalarRecurrence p n v ell) :
p n ≤ (1 - (1 - v) ^ 3 / 6000) ^ ((n : ℝ) / ell) := by
have hell0 : 0 < ell := by linarith
have hq0 : 0 ≤ (1 + v) / 2 := by linarith
have hexp : 0 ≤ (n : ℝ) / ell := by positivity
have hblock := block_contraction hv0 hv1
have hweak : 1 - (1 - v) ^ 3 / 5850 ≤ 1 - (1 - v) ^ 3 / 6000 := by
have : 0 ≤ (1 - v) ^ 3 := by positivity
nlinarith
calc
p n ≤ ((1 + v) / 2) ^
((n : ℝ) * (1 - v) ^ 2 / (2925 * ell)) :=
decay_to_cutoff p n hv0 hv1 hell hp0 hpnonneg hpmono hrec
_ = (((1 + v) / 2) ^ ((1 - v) ^ 2 / 2925 : ℝ)) ^ ((n : ℝ) / ell) := by
rw [← Real.rpow_mul hq0]
congr 1
ring
_ ≤ (1 - (1 - v) ^ 3 / 6000) ^ ((n : ℝ) / ell) :=
Real.rpow_le_rpow (Real.rpow_nonneg hq0 _) (hblock.trans hweak) hexp
noncomputable def incidenceRate : ℝ := 1 - 1 / (100000 * 192 ^ 3)
theorem incidenceRate_pos : 0 < incidenceRate := by norm_num [incidenceRate]
theorem incidenceRate_lt_one : incidenceRate < 1 := by norm_num [incidenceRate]
theorem incidenceRate_fourth :
1 - (1 / 192 : ℝ) ^ 3 / 6000 ≤ incidenceRate ^ 4 := by
norm_num [incidenceRate]
theorem incidence_rate_comparison (n : ℕ) :
(1 - (1 / 192 : ℝ) ^ 3 / 6000) ^ ((n : ℝ) / 4) ≤ incidenceRate ^ n := by
calc
(1 - (1 / 192 : ℝ) ^ 3 / 6000) ^ ((n : ℝ) / 4)
≤ (incidenceRate ^ 4) ^ ((n : ℝ) / 4) :=
Real.rpow_le_rpow (by norm_num) incidenceRate_fourth (by positivity)
_ = incidenceRate ^ ((4 : ℝ) * ((n : ℝ) / 4)) :=
(Real.rpow_natCast_mul incidenceRate_pos.le 4 ((n : ℝ) / 4)).symm
_ = incidenceRate ^ (n : ℝ) := by congr 1; ring
_ = incidenceRate ^ n := Real.rpow_natCast _ _
theorem scalar_incidence_bound (p : ℕ → ℝ) (n : ℕ) {v : ℝ}
(hv : v ≤ 1 - (1 / 192 : ℝ))
(hp0 : p 0 = 1) (hpnonneg : ∀ m, 0 ≤ p m)
(hpmono : Antitone p) (hrec : ScalarRecurrence p n v 4) :
p n ≤ incidenceRate ^ n := by
have hrec' : ScalarRecurrence p n (1 - (1 / 192 : ℝ)) 4 := by
intro m hm
exact (hrec m hm).trans (mul_le_mul_of_nonneg_left (by linarith) (hpnonneg m))
have hbound := scalar_bound_6000 p n
(v := 1 - (1 / 192 : ℝ)) (ell := 4)
(by norm_num) (by norm_num) (by norm_num) hp0 hpnonneg hpmono hrec'
norm_num only [sub_sub_cancel] at hbound
have hcomparison := incidence_rate_comparison n
norm_num at hcomparison
exact hbound.trans hcomparison
end BinPackingGames.Foundations.Repetition
namespace BinPackingGames.Foundations.Repetition.SelectionSequence
private theorem exists_unused {n : Nat} (S : Finset (Fin n)) (hcard : S.card < n) :
∃ j : Fin n, j ∉ S := by
classical
apply Classical.byContradiction
intro h
have hall : ∀ j : Fin n, j ∈ S := by
intro j
apply Classical.byContradiction
intro hj
exact h ⟨j, hj⟩
have hfull : S = Finset.univ :=
Finset.ext (fun j => iff_of_true (hall j) (Finset.mem_univ j))
have hbad : n < n := by
simpa only [hfull, Finset.card_univ, Fintype.card_fin] using hcard
exact Nat.lt_irrefl n hbad
noncomputable def nextSet {n : Nat}
(Step : Finset (Fin n) → Fin n → Prop)
(witness : ∀ S, S.card < n → ∃ j, j ∉ S ∧ Step S j)
(S : Finset (Fin n)) : Finset (Fin n) :=
if hs : S.card < n then insert (Classical.choose (witness S hs)) S else S
noncomputable def selectedSet {n : Nat}
(Step : Finset (Fin n) → Fin n → Prop)
(witness : ∀ S, S.card < n → ∃ j, j ∉ S ∧ Step S j) : Nat → Finset (Fin n)
| 0 => ∅
| m + 1 => nextSet Step witness (selectedSet Step witness m)
theorem selectedSet_card {n : Nat}
(Step : Finset (Fin n) → Fin n → Prop)
(witness : ∀ S, S.card < n → ∃ j, j ∉ S ∧ Step S j) (m : Nat) :
(selectedSet Step witness m).card = min m n := by
induction m with
| zero => simp [selectedSet]
| succ m ih =>
by_cases hm : m < n
· have hc : (selectedSet Step witness m).card = m := by
simpa only [Nat.min_eq_left (Nat.le_of_lt hm)] using ih
have hs : (selectedSet Step witness m).card < n := by
simpa only [hc] using hm
rw [selectedSet, nextSet, dite_eq_left hs,
Finset.card_insert_of_notMem ((Classical.choose_spec (witness _ hs)).1),
hc, Nat.min_eq_left (Nat.succ_le_of_lt hm)]
· have hc : (selectedSet Step witness m).card = n := by
simpa only [Nat.min_eq_right (Nat.le_of_not_gt hm)] using ih
have hs : ¬(selectedSet Step witness m).card < n := by
rw [hc]
exact Nat.not_lt.mpr (Nat.le_refl n)
rw [selectedSet, nextSet, dite_eq_right hs, hc,
Nat.min_eq_right (Nat.le_trans (Nat.le_of_not_gt hm) (Nat.le_succ m))]
theorem selectedSet_subset_succ {n : Nat}
(Step : Finset (Fin n) → Fin n → Prop)
(witness : ∀ S, S.card < n → ∃ j, j ∉ S ∧ Step S j) (m : Nat) :
selectedSet Step witness m ⊆ selectedSet Step witness (m + 1) := by
change selectedSet Step witness m ⊆ nextSet Step witness (selectedSet Step witness m)
unfold nextSet
split
· exact Finset.subset_insert _ _
· exact le_rfl
theorem selectedSet_monotone {n : Nat}
(Step : Finset (Fin n) → Fin n → Prop)
(witness : ∀ S, S.card < n → ∃ j, j ∉ S ∧ Step S j) :
Monotone (selectedSet Step witness) :=
monotone_nat_of_le_succ (selectedSet_subset_succ Step witness)
theorem selectedSet_univ {n : Nat}
(Step : Finset (Fin n) → Fin n → Prop)
(witness : ∀ S, S.card < n → ∃ j, j ∉ S ∧ Step S j) :
selectedSet Step witness n = Finset.univ := by
apply Finset.eq_of_subset_of_card_le (Finset.subset_univ _)
simp [selectedSet_card]
theorem selectedSet_step {n : Nat}
(Step : Finset (Fin n) → Fin n → Prop)
(witness : ∀ S, S.card < n → ∃ j, j ∉ S ∧ Step S j)
(m : Nat) (hm : m < n) :
∃ j, j ∉ selectedSet Step witness m ∧
selectedSet Step witness (m + 1) = insert j (selectedSet Step witness m) ∧
Step (selectedSet Step witness m) j := by
have hc : (selectedSet Step witness m).card = m := by
rw [selectedSet_card, Nat.min_eq_left (Nat.le_of_lt hm)]
have hs : (selectedSet Step witness m).card < n := by simpa only [hc] using hm
let j := Classical.choose (witness (selectedSet Step witness m) hs)
have hj := Classical.choose_spec (witness (selectedSet Step witness m) hs)
refine ⟨j, hj.1, ?_, hj.2⟩
simp only [selectedSet, nextSet, dite_eq_left hs, j]
def SetStep {n : Nat} (P : Finset (Fin n) → ℝ) (v ell : ℝ)
(S : Finset (Fin n)) (j : Fin n) : Prop :=
P (insert j S) ≤ P S *
(v + 15 * Real.sqrt (((S.card : ℝ) * ell + logTwo (1 / P S)) /
((n : ℝ) - S.card)))
theorem totalSetStep {n : Nat} (P : Finset (Fin n) → ℝ) (v ell : ℝ)
(hnonneg : ∀ S, 0 ≤ P S) (hanti : Antitone P)
(hpositive : ∀ S, S.card < n → 0 < P S →
∃ j, j ∉ S ∧ SetStep P v ell S j) :
∀ S, S.card < n → ∃ j, j ∉ S ∧ SetStep P v ell S j := by
intro S hcard
by_cases hp : 0 < P S
· exact hpositive S hcard hp
· obtain ⟨j, hj⟩ := exists_unused S hcard
have hz : P S = 0 := le_antisymm (le_of_not_gt hp) (hnonneg S)
have hnext : P (insert j S) = 0 := le_antisymm
((hanti (Finset.subset_insert j S)).trans (le_of_eq hz)) (hnonneg (insert j S))
refine ⟨j, hj, ?_⟩
simpa only [SetStep, hnext, hz, zero_mul] using (le_refl (0 : ℝ))
theorem exists_scalar_sequence {n : Nat} (P : Finset (Fin n) → ℝ) (v ell : ℝ)
(hempty : P ∅ = 1) (hnonneg : ∀ S, 0 ≤ P S) (hanti : Antitone P)
(hpositive : ∀ S, S.card < n → 0 < P S →
∃ j, j ∉ S ∧ SetStep P v ell S j) :
∃ p : Nat → ℝ, p 0 = 1 ∧ (∀ m, 0 ≤ p m) ∧ Antitone p ∧
ScalarRecurrence p n v ell ∧ p n = P Finset.univ := by
let witness := totalSetStep P v ell hnonneg hanti hpositive
let sets := selectedSet (SetStep P v ell) witness
let p := fun m => P (sets m)
refine ⟨p, ?_, ?_, ?_, ?_, ?_⟩
· change P (selectedSet (SetStep P v ell) witness 0) = 1
simpa only [selectedSet] using hempty
· intro m
exact hnonneg (sets m)
· intro i j hij
exact hanti (selectedSet_monotone (SetStep P v ell) witness hij)
· intro m hm
obtain ⟨j, _, hnext, hbound⟩ :=
selectedSet_step (SetStep P v ell) witness m hm
have hc : (selectedSet (SetStep P v ell) witness m).card = m := by
rw [selectedSet_card, Nat.min_eq_left (Nat.le_of_lt hm)]
change P (selectedSet (SetStep P v ell) witness (m + 1)) ≤ _
rw [hnext]
simpa only [SetStep, hc] using hbound
· change P (selectedSet (SetStep P v ell) witness n) = P Finset.univ
rw [selectedSet_univ]
open BinPackingGames.Foundations.Games
variable {Q₁ Q₂ A₁ A₂ : Type*}
variable [Fintype Q₁] [Fintype Q₂] [Fintype A₁] [Fintype A₂]
variable [Nonempty A₁] [Nonempty A₂]
def ConditionalCoordinateBound (G : Game Q₁ Q₂ A₁ A₂) (n : Nat)
(strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂))
(ell : ℝ) : Prop :=
∀ (S : Finset (Fin n)) (_hcard : S.card < n)
(hp : 0 < G.selectedSuccess strategy S),
∃ j, j ∉ S ∧
(((G.repetition n).questions.condition (G.selectedWins strategy S) hp).probability
(G.coordinateWin strategy j)) ≤
G.value + 15 * Real.sqrt
(((S.card : ℝ) * ell + logTwo (1 / G.selectedSuccess strategy S)) /
((n : ℝ) - S.card))
theorem repetition_success_le_of_conditionalCoordinateBound
(G : Game Q₁ Q₂ A₁ A₂) (n : Nat)
(strategy : Strategy (Fin n → Q₁) (Fin n → Q₂) (Fin n → A₁) (Fin n → A₂))
{v ell : ℝ} (hvalue : G.value ≤ v) (hv1 : v < 1) (hell : 1 ≤ ell)
(hcoordinate : ConditionalCoordinateBound G n strategy ell) :
(G.repetition n).success strategy ≤
(1 - (1 - v)^3 / 6000)^((n : ℝ) / ell) := by
have hpositive : ∀ S : Finset (Fin n), S.card < n →
0 < G.selectedSuccess strategy S →
∃ j, j ∉ S ∧ SetStep (G.selectedSuccess strategy) v ell S j := by
intro S hcard hp
obtain ⟨j, hj, hbound⟩ := hcoordinate S hcard hp
refine ⟨j, hj, ?_⟩
change G.selectedSuccess strategy (insert j S) ≤ _
rw [G.selectedSuccess_insert strategy S j hp]
exact mul_le_mul_of_nonneg_left
(hbound.trans (add_le_add hvalue (le_refl _))) (le_of_lt hp)
obtain ⟨p, hp0, hpnonneg, hpmono, hrec, hpn⟩ :=
exists_scalar_sequence (G.selectedSuccess strategy) v ell
(G.selectedSuccess_empty strategy) (G.selectedSuccess_nonnegative strategy)
(G.selectedSuccess_antitone strategy) hpositive
have hbound := scalar_bound_6000 p n
(G.value_nonnegative.trans hvalue) hv1 hell hp0 hpnonneg hpmono hrec
rw [hpn, G.selectedSuccess_univ strategy] at hbound
exact hbound
end BinPackingGames.Foundations.Repetition.SelectionSequence
namespace BinPackingGames.Foundations.Repetition
open scoped BigOperators
open Games
noncomputable section
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
end BinPackingGames.Foundations.Repetition
end OAI

Xet Storage Details

Size:
22.9 kB
·
Xet hash:
9b9dbcaba878b99161e2f8ac1fcb289e1ee5ff24e445624ba1525586ea5467d7

Xet efficiently stores files, intelligently splitting them into unique chunks and accelerating uploads and downloads. More info.