math / data /lean /OAI /Computability /DepthThree /FinalParameterBounds.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
6.2 kB
import OAI.Computability.DepthThree.AsymptoticBounds
import OAI.Computability.DepthThree.ReversePathRecurrence
import Mathlib.Algebra.Order.Floor.Semiring
import Mathlib.Data.Nat.Choose.Bounds
import Mathlib.Algebra.Order.Archimedean.Real.Basic
import Mathlib.Tactic.FieldSimp
import Lean.Elab.Tactic.Omega
namespace OAI
noncomputable section
open scoped BigOperators
namespace DepthThreeLowerBound
def liveProbability (B : ℝ) (d : β„•) : ℝ := B / Real.sqrt (d : ℝ)
def degreeCutoff (s : ℝ) (d : β„•) : β„• :=
Nat.ceil (3 * (s + 1) * Real.sqrt (d : ℝ))
def factorialBase (B s : ℝ) : ℝ := 4 * B * (3 * (s + 1) + 1)
theorem liveProbability_pos (B : ℝ) (hB : 0 < B) (d : β„•) (hd : 0 < d) :
0 < liveProbability B d :=
div_pos hB (Real.sqrt_pos.mpr (Nat.cast_pos.mpr hd))
theorem liveProbability_mul_dimension (B : ℝ) (d : β„•) (hd : 0 < d) :
liveProbability B d * (d : ℝ) = B * Real.sqrt (d : ℝ) := by
have hroot : Real.sqrt (d : ℝ) β‰  0 :=
(Real.sqrt_pos.mpr (Nat.cast_pos.mpr hd)).ne'
unfold liveProbability
calc
B / Real.sqrt (d : ℝ) * (d : ℝ) =
B / Real.sqrt (d : ℝ) * (Real.sqrt (d : ℝ) * Real.sqrt (d : ℝ)) := by
rw [Real.mul_self_sqrt (Nat.cast_nonneg d)]
_ = B * Real.sqrt (d : ℝ) := by
rw [← mul_assoc, div_mul_cancelβ‚€ _ hroot]
theorem degreeCutoff_lower (s : ℝ) (d : β„•) :
3 * (s + 1) * Real.sqrt (d : ℝ) ≀ (degreeCutoff s d : ℝ) :=
Nat.le_ceil _
theorem degreeCutoff_upper (s : ℝ) (hs : 0 ≀ s) (d : β„•) (hd : 1 ≀ d) :
(degreeCutoff s d : ℝ) ≀ (3 * (s + 1) + 1) * Real.sqrt (d : ℝ) := by
have hroot : (1 : ℝ) ≀ Real.sqrt (d : ℝ) :=
Real.one_le_sqrt.mpr (by exact_mod_cast hd)
have hnonneg : 0 ≀ 3 * (s + 1) * Real.sqrt (d : ℝ) :=
mul_nonneg (by linarith) (Real.sqrt_nonneg _)
have hceil := Nat.ceil_lt_add_one hnonneg
change (degreeCutoff s d : ℝ) < 3 * (s + 1) * Real.sqrt (d : ℝ) + 1 at hceil
nlinarith
theorem exists_liveProbability_threshold (B : ℝ) (hB : 0 < B) :
βˆƒ D : β„•, 1 ≀ D ∧ βˆ€ d : β„•, D ≀ d β†’
0 < liveProbability B d ∧ liveProbability B d ≀ 1 / 2 := by
obtain ⟨D, hD⟩ := exists_nat_ge (max (1 : ℝ) ((2 * B) ^ 2))
have hDone : 1 ≀ D := by
exact_mod_cast (le_max_left (1 : ℝ) ((2 * B) ^ 2)).trans hD
refine ⟨D, hDone, ?_⟩
intro d hd
have hdone : 1 ≀ d := hDone.trans hd
have hrootpos : 0 < Real.sqrt (d : ℝ) :=
Real.sqrt_pos.mpr (Nat.cast_pos.mpr (by omega : 0 < d))
have hsq : (2 * B) ^ 2 ≀ (d : ℝ) :=
((le_max_right (1 : ℝ) ((2 * B) ^ 2)).trans hD).trans (Nat.cast_le.mpr hd)
have hroot : 2 * B ≀ Real.sqrt (d : ℝ) := Real.le_sqrt_of_sq_le hsq
refine ⟨liveProbability_pos B hB d (by omega), ?_⟩
change B / Real.sqrt (d : ℝ) ≀ 1 / 2
apply (div_le_iffβ‚€ hrootpos).mpr
linarith
theorem scaled_cutoff_le_factorialBase (B s : ℝ) (hB : 0 ≀ B) (hs : 0 ≀ s)
(d : β„•) (hd : 1 ≀ d) (hp : liveProbability B d ≀ 1 / 2) :
(2 * liveProbability B d / (1 - liveProbability B d)) *
(degreeCutoff s d : ℝ) ≀ factorialBase B s := by
have hrootpos : 0 < Real.sqrt (d : ℝ) :=
Real.sqrt_pos.mpr (Nat.cast_pos.mpr (by omega : 0 < d))
have hp0 : 0 ≀ liveProbability B d := div_nonneg hB (Real.sqrt_nonneg _)
have hΞ± : 2 * liveProbability B d / (1 - liveProbability B d) ≀
4 * liveProbability B d := by
calc
2 * liveProbability B d / (1 - liveProbability B d) ≀
2 * liveProbability B d / (1 / 2) :=
div_le_div_of_nonneg_left (by linarith) (by norm_num) (by linarith)
_ = 4 * liveProbability B d := by ring
calc
(2 * liveProbability B d / (1 - liveProbability B d)) *
(degreeCutoff s d : ℝ) ≀
(4 * liveProbability B d) * (degreeCutoff s d : ℝ) :=
mul_le_mul_of_nonneg_right hΞ± (Nat.cast_nonneg _)
_ ≀ (4 * liveProbability B d) *
((3 * (s + 1) + 1) * Real.sqrt (d : ℝ)) :=
mul_le_mul_of_nonneg_left (degreeCutoff_upper s hs d hd) (by linarith)
_ = factorialBase B s := by
unfold liveProbability factorialBase
field_simp [hrootpos.ne']
theorem reverseTheta_le_factorial_tail (Ξ± Q : ℝ) (hΞ± : 0 ≀ Ξ±) (b k : β„•)
(hΞ±k : Ξ± * (k : ℝ) ≀ Q) :
reverseTheta Ξ± b k ≀
βˆ‘ β„“ ∈ Finset.Ico (b + 1) (k + 1), Q ^ β„“ / (β„“.factorial : ℝ) := by
have hset : (Finset.range (k + 1)).filter (fun β„“ => b < β„“) =
Finset.Ico (b + 1) (k + 1) := by
ext β„“
simp only [Finset.mem_filter, Finset.mem_range, Finset.mem_Ico]
omega
unfold reverseTheta
rw [← Finset.sum_filter, hset]
apply Finset.sum_le_sum
intro β„“ hβ„“
calc
(k.choose β„“ : ℝ) * Ξ± ^ β„“ ≀
((k : ℝ) ^ β„“ / (β„“.factorial : ℝ)) * Ξ± ^ β„“ :=
mul_le_mul_of_nonneg_right (Nat.choose_le_pow_div β„“ k) (pow_nonneg hΞ± _)
_ = (Ξ± * (k : ℝ)) ^ β„“ / (β„“.factorial : ℝ) := by
rw [mul_pow]
ring
_ ≀ Q ^ β„“ / (β„“.factorial : ℝ) :=
div_le_div_of_nonneg_right
(pow_le_pow_leftβ‚€ (mul_nonneg hΞ± (Nat.cast_nonneg k)) hΞ±k β„“)
(Nat.cast_nonneg _)
theorem exists_final_parameter_width (B s : ℝ) (hB : 0 < B) (hs : 0 ≀ s) :
βˆƒ b : β„•, 1 ≀ b ∧ βˆƒ D : β„•, 1 ≀ D ∧ βˆ€ d : β„•, D ≀ d β†’
0 < liveProbability B d ∧ liveProbability B d ≀ 1 / 2 ∧
reverseTheta (2 * liveProbability B d / (1 - liveProbability B d))
b (degreeCutoff s d) ≀ 1 / 2 := by
have hQ : 0 ≀ factorialBase B s :=
mul_nonneg (mul_nonneg (by norm_num) hB.le) (by linarith)
obtain ⟨b, hb, htail⟩ := exists_factorial_tail_width (factorialBase B s) hQ
obtain ⟨D, hD, hprob⟩ := exists_liveProbability_threshold B hB
refine ⟨b, hb, D, hD, ?_⟩
intro d hd
obtain ⟨hp0, hphalf⟩ := hprob d hd
refine ⟨hp0, hphalf, ?_⟩
have hΞ± : 0 ≀ 2 * liveProbability B d / (1 - liveProbability B d) :=
div_nonneg (by linarith) (by linarith)
exact (reverseTheta_le_factorial_tail _ _ hΞ± b (degreeCutoff s d)
(scaled_cutoff_le_factorialBase B s hB.le hs d (hD.trans hd) hphalf)).trans
(htail (degreeCutoff s d))
end DepthThreeLowerBound
end
end OAI