File size: 5,228 Bytes
760f90e | 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 | import Mathlib.Algebra.BigOperators.Ring.Finset
import Mathlib.Algebra.Order.BigOperators.Ring.Finset
import Mathlib.Basic.Real.Basic
import Mathlib.Tactic.Linarith
import Mathlib.Tactic.NormNum
import Mathlib.Tactic.Ring
namespace OAI
section
noncomputable section
open scoped BigOperators
namespace UniqueGamesTheorem.Appendix.DyadicError
private theorem pow_le_one_aux (q : ℝ) (hq0 : 0 ≤ q) (hq1 : q ≤ 1) (n : ℕ) :
q^n ≤ 1 := by
induction n with
| zero => simp
| succ n ih =>
rw [pow_succ]
exact (mul_le_mul_of_nonneg_right ih hq0).trans (by simpa using hq1)
private theorem pow_antitone_aux (q : ℝ) (hq0 : 0 ≤ q) (hq1 : q ≤ 1)
(a b : ℕ) (hab : a ≤ b) : q^b ≤ q^a := by
have hb : a + (b-a) = b :=
(Nat.add_comm a (b-a)).trans (Nat.sub_add_cancel hab)
calc
q^b = q^(a+(b-a)) := congrArg (fun n : ℕ => q^n) hb.symm
_ = q^a * q^(b-a) := by rw [pow_add]
_ ≤ q^a * 1 := mul_le_mul_of_nonneg_left
(pow_le_one_aux q hq0 hq1 (b-a)) (pow_nonneg hq0 a)
_ = q^a := mul_one _
theorem half_power_le_quarter (d n : ℕ) (hd : 1 ≤ d) :
(1/2 : ℝ)^(3*d*n) ≤ (1/4 : ℝ)^n := by
have h3 : 2 ≤ 3*d := le_trans (by decide : 2 ≤ 3)
(by simpa using Nat.mul_le_mul_left 3 hd)
have hexp : 2*n ≤ 3*d*n := Nat.mul_le_mul_right n h3
calc
(1/2 : ℝ)^(3*d*n) ≤ (1/2 : ℝ)^(2*n) :=
pow_antitone_aux (1/2) (by norm_num) (by norm_num) _ _ hexp
_ = (1/4 : ℝ)^n := by
rw [pow_mul]
congr 1
norm_num
def quarterSum (n : ℕ) : ℝ := ∑ i ∈ Finset.range n, (1/4 : ℝ)^i
theorem quarterSum_nonneg (n : ℕ) : 0 ≤ quarterSum n := by
unfold quarterSum
exact Finset.sum_nonneg (fun i _ => pow_nonneg (by norm_num : (0:ℝ)≤1/4) i)
theorem quarterSum_residual (n : ℕ) :
quarterSum n + (4/3 : ℝ)*(1/4 : ℝ)^n = 4/3 := by
induction n with
| zero => norm_num [quarterSum]
| succ n ih =>
have hstep : quarterSum (n+1) = quarterSum n + (1/4 : ℝ)^n := by
exact Finset.sum_range_succ _ _
rw [hstep, pow_succ]
nlinarith
theorem quarterSum_le (n : ℕ) : quarterSum n ≤ (4/3 : ℝ) := by
have hp : (0 : ℝ) ≤ (1/4 : ℝ)^n := pow_nonneg (by norm_num) n
have h := quarterSum_residual n
nlinarith
def quarterError (n : ℕ) : ℝ :=
∑ i ∈ Finset.range n, ∑ j ∈ Finset.range n,
if i=0 ∧ j=0 then 0 else (1/4 : ℝ)^(i+j)
theorem quarterError_add_one (n : ℕ) (hn : 0 < n) :
quarterError n + 1 = (quarterSum n)^2 := by
have h0 : (0 : ℕ) ∈ Finset.range n := Finset.mem_range.mpr hn
have hpair (i j : ℕ) :
(if i=0 ∧ j=0 then (0:ℝ) else (1/4 : ℝ)^(i+j)) +
(if i=0 ∧ j=0 then (1:ℝ) else 0) =
(1/4 : ℝ)^i * (1/4 : ℝ)^j := by
by_cases hi : i=0 <;> by_cases hj : j=0 <;> simp [hi,hj,pow_add]
have hsum : quarterError n +
(∑ i ∈ Finset.range n, ∑ j ∈ Finset.range n,
if i=0 ∧ j=0 then (1:ℝ) else 0) =
∑ i ∈ Finset.range n, ∑ j ∈ Finset.range n,
(1/4 : ℝ)^i * (1/4 : ℝ)^j := by
unfold quarterError
rw [← Finset.sum_add_distrib]
apply Finset.sum_congr rfl
intro i _
rw [← Finset.sum_add_distrib]
apply Finset.sum_congr rfl
intro j _
exact hpair i j
have hinner (i : ℕ) :
(∑ j ∈ Finset.range n, if i=0 ∧ j=0 then (1:ℝ) else 0) =
if i=0 then 1 else 0 := by
by_cases hi : i=0
· simp [hi,h0]
· simp [hi]
have hdelta : (∑ i ∈ Finset.range n, ∑ j ∈ Finset.range n,
if i=0 ∧ j=0 then (1:ℝ) else 0) = 1 := by
simp_rw [hinner]
simp [h0]
have hproduct : (∑ i ∈ Finset.range n, ∑ j ∈ Finset.range n,
(1/4 : ℝ)^i * (1/4 : ℝ)^j) = (quarterSum n)^2 := by
simp only [quarterSum,pow_two,Finset.sum_mul,Finset.mul_sum]
exact Finset.sum_comm
rw [hdelta,hproduct] at hsum
exact hsum
theorem quarterError_le_seven_ninths (n : ℕ) (hn : 0 < n) :
quarterError n ≤ (7/9 : ℝ) := by
have hbound := quarterSum_le n
have hnonneg := quarterSum_nonneg n
have hsq := mul_le_mul hbound hbound hnonneg (by norm_num : (0:ℝ)≤4/3)
have hid := quarterError_add_one n hn
nlinarith
def dyadicError (d : ℕ) : ℝ :=
∑ i ∈ Finset.range (d+1), ∑ j ∈ Finset.range (d+1),
if i=0 ∧ j=0 then 0 else (1/2 : ℝ)^(3*d*(i+j))
theorem dyadicError_le_quarterError (d : ℕ) (hd : 1 ≤ d) :
dyadicError d ≤ quarterError (d+1) := by
unfold dyadicError quarterError
apply Finset.sum_le_sum
intro i _
apply Finset.sum_le_sum
intro j _
by_cases hzero : i=0 ∧ j=0
· simp [hzero]
· simp only [hzero]
exact half_power_le_quarter d (i+j) hd
theorem dyadicError_le_seven_ninths (d : ℕ) (hd : 1 ≤ d) :
dyadicError d ≤ (7/9 : ℝ) :=
(dyadicError_le_quarterError d hd).trans
(quarterError_le_seven_ninths (d+1) (Nat.succ_pos d))
theorem finite_dyadic_error_le_one (d : ℕ) (hd : 1 ≤ d) :
(∑ i ∈ Finset.range (d+1), ∑ j ∈ Finset.range (d+1),
if i=0 ∧ j=0 then 0 else (1/2 : ℝ)^(3*d*(i+j))) ≤ 1 := by
change dyadicError d ≤ 1
exact (dyadicError_le_seven_ninths d hd).trans (by norm_num)
end UniqueGamesTheorem.Appendix.DyadicError
end
end
end OAI
|