File size: 4,027 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 | import OAI.Combinatorics.ContingencyTables.Dense.DenseMixing
namespace OAI
/-! # Error budget of the bounded dense rejection schedule -/
namespace ContingencyTables.GridBoundary
theorem succ_le_two_pow (h : β) : h + 1 β€ 2 ^ h := by
exact Nat.succ_le_of_lt Nat.lt_two_pow_self
theorem square_le_two_pow (d : β) (hd : 4 β€ d) : d ^ 2 β€ 2 ^ d := by
induction d, hd using Nat.le_induction with
| base => norm_num
| succ d hd ih =>
calc
(d + 1) ^ 2 β€ 2 * d ^ 2 := by nlinarith
_ β€ 2 * 2 ^ d := Nat.mul_le_mul_left _ ih
_ = 2 ^ (d + 1) := by rw [pow_succ, Nat.mul_comm]
theorem dense_trial_error_budget (d h : β) (hd : 14 β€ d) :
((d ^ 4 * (h + 1) * (1 + d) : β) : β) *
(2 : β) ^ (-(4 * ((h : β) + d))) β€ (2 : β) ^ (-(h : β) - 2) := by
have hd2 : (d : β) ^ 2 β€ (2 : β) ^ d := by exact_mod_cast square_le_two_pow d (by omega)
have hd4 : (d : β) ^ 4 β€ (2 : β) ^ (2 * d) := by
calc
_ = ((d : β) ^ 2) ^ 2 := by ring
_ β€ ((2 : β) ^ d) ^ 2 := pow_le_pow_leftβ (by positivity) hd2 _
_ = _ := by rw [β pow_mul]; congr 1; omega
have hh : (h : β) + 1 β€ (2 : β) ^ h := by
exact_mod_cast succ_le_two_pow h
have hd1 : (1 : β) + d β€ (2 : β) ^ d := by
exact_mod_cast (show 1 + d β€ 2 ^ d by simpa only [Nat.add_comm] using succ_le_two_pow d)
have hprod : ((d ^ 4 * (h + 1) * (1 + d) : β) : β) β€
(2 : β) ^ ((h : β) + 3 * d) := by
push_cast
calc
_ β€ (2 : β) ^ (2 * d) * (2 : β) ^ h * (2 : β) ^ d := by gcongr
_ = _ := by
rw [β pow_add, β pow_add, β Real.rpow_natCast]
congr 1
push_cast
ring
calc
_ β€ (2 : β) ^ ((h : β) + 3 * d) * (2 : β) ^ (-(4 * ((h : β) + d))) :=
mul_le_mul_of_nonneg_right hprod (by positivity)
_ = (2 : β) ^ (-(3 * (h : β) + d)) := by
rw [β Real.rpow_add (by norm_num)]
congr 1
ring
_ β€ _ := Real.rpow_le_rpow_of_exponent_le (by norm_num) (by
have hd' : (14 : β) β€ d := by exact_mod_cast hd
have hh' : (0 : β) β€ h := Nat.cast_nonneg _
linarith)
theorem dense_failure_error_budget (d h : β) (hd : 14 β€ d) :
(63 / 64 : β) ^ (d ^ 4 * (h + 1)) β€ (2 : β) ^ (-(h : β) - 2) := by
have hd4 : 128 β€ d ^ 4 := by nlinarith [show 14 ^ 4 β€ d ^ 4 from Nat.pow_le_pow_left hd _]
have hs : (63 / 64 : β) β€ Real.exp (-(1 / 64 : β)) := by
linarith [Real.add_one_le_exp (-(1 / 64 : β))]
calc
_ β€ (Real.exp (-(1 / 64 : β))) ^ (d ^ 4 * (h + 1)) :=
pow_le_pow_leftβ (by norm_num) hs _
_ = Real.exp (-(((d ^ 4 * (h + 1) : β) : β) / 64)) := by
rw [β Real.exp_nat_mul]
congr 1
ring
_ β€ Real.exp (-(2 * ((h : β) + 1))) := by
apply Real.exp_le_exp.mpr
have h' : (128 : β) β€ (d : β) ^ 4 := by exact_mod_cast hd4
push_cast
nlinarith [show (0 : β) β€ h from Nat.cast_nonneg h]
_ β€ (2 : β) ^ (-(2 * ((h : β) + 1))) := by
rw [Real.rpow_def_of_pos (by norm_num)]
apply Real.exp_le_exp.mpr
have hl : Real.log 2 β€ 1 := by linarith [Real.log_le_sub_one_of_pos (by norm_num : (0 : β) < 2)]
have hh' : (0 : β) β€ h := Nat.cast_nonneg _
nlinarith
_ β€ _ := Real.rpow_le_rpow_of_exponent_le (by norm_num) (by
have hh' : (0 : β) β€ h := Nat.cast_nonneg _
linarith)
theorem dense_total_error_budget (d h : β) (hd : 14 β€ d) :
(63 / 64 : β) ^ (d ^ 4 * (h + 1)) +
((d ^ 4 * (h + 1) * (1 + d) : β) : β) *
(2 : β) ^ (-(4 * ((h : β) + d))) β€ (2 : β) ^ (-(h : β)) := by
have hf := dense_failure_error_budget d h hd
have ht := dense_trial_error_budget d h hd
have heq : (2 : β) ^ (-(h : β) - 2) = (2 : β) ^ (-(h : β)) / 4 := by
rw [Real.rpow_sub (by norm_num)]
norm_num
rw [heq] at hf ht
linarith [Real.rpow_pos_of_pos (by norm_num : (0 : β) < 2) (-(h : β))]
end ContingencyTables.GridBoundary
end OAI
|