math / data /lean /OAI /NumberTheory /TwoPoint /Bounds /ActualPaddingIntegerBounds.lean
introvoyz045's picture
Migrated from GitHub
4a56cd6 verified
Raw History Blame Contribute Delete
13 kB
import OAI.NumberTheory.TwoPoint.Bounds.PaddingActiveState
import OAI.NumberTheory.TwoPoint.Bounds.ActiveStateComparison
import OAI.NumberTheory.TwoPoint.Bounds.ResidueLawUniform
namespace OAI
/-! Truncated padding weights on actual integer intervals. The finite
active-state comparison is used only after the degree restriction. -/
namespace TwoPointCorrelations
open Finset Filter
open scoped Classical
lemma uniformAverage_pi_product {ΞΉ : Type*} [Fintype ΞΉ] [DecidableEq ΞΉ]
{Ξ² : ΞΉ β†’ Type*} [βˆ€ i, Fintype (Ξ² i)] (f : (i : ΞΉ) β†’ Ξ² i β†’ ℝ) :
uniformAverage (fun x : βˆ€ i, Ξ² i => ∏ i, f i (x i)) =
∏ i, uniformAverage (f i) := by
simp only [uniformAverage, Fintype.card_pi, Nat.cast_prod]
rw [← Fintype.prod_sum, prod_div_distrib]
lemma uniformAverage_padding_factor (p : β„•) [NeZero p] (site : β„€) :
uniformAverage (fun z : ZMod p => if z + (site : ZMod p) = 0 then (5 : ℝ) else 1) =
1 + 4 / (p : ℝ) := by
have he (z : ZMod p) : z + (site : ZMod p) = 0 ↔ z = -(site : ZMod p) := by
constructor <;> intro h <;> linear_combination h
have hf (z : ZMod p) :
(if z = -(site : ZMod p) then (5 : ℝ) else 1) =
1 + if z = -(site : ZMod p) then (4 : ℝ) else 0 := by
split_ifs <;> norm_num
simp only [he, hf, uniformAverage, sum_add_distrib, sum_const,
card_univ, nsmul_eq_mul, mul_one, sum_ite_eq', mem_univ, ite_true, ZMod.card]
have hp : (p : ℝ) β‰  0 := by exact_mod_cast NeZero.ne p
field_simp
noncomputable def primeStateTruncatedWeight {m : β„•} (s : Fin m β†’ β„•) [βˆ€ i, NeZero (s i)]
(M : β„•) (site : β„€) (z : βˆ€ i, ZMod (s i)) : ℝ :=
let S := activeState (fun i => decide (z i + (site : ZMod (s i)) = 0))
if S.card ≀ M then (5 : ℝ) ^ S.card else 0
lemma activeState_five_pow {m : β„•} (x : BooleanCube m) :
(5 : ℝ) ^ (activeState x).card = ∏ i, if x i then (5 : ℝ) else 1 := by
rw [← prod_const]
simp only [activeState, prod_filter]
lemma primeStateTruncatedWeight_average_le {m : β„•} (s : Fin m β†’ β„•)
[βˆ€ i, NeZero (s i)] (M : β„•) (site : β„€) :
uniformAverage (primeStateTruncatedWeight s M site) ≀
∏ i, (1 + 4 / (s i : ℝ)) := by
calc
_ ≀ uniformAverage (fun z : βˆ€ i, ZMod (s i) =>
(5 : ℝ) ^ (activeState (fun i => decide (z i + (site : ZMod (s i)) = 0))).card) := by
unfold uniformAverage
apply div_le_div_of_nonneg_right _ (Nat.cast_nonneg _)
apply sum_le_sum
intro z _
dsimp only [primeStateTruncatedWeight]
split_ifs
Β· exact le_rfl
Β· positivity
_ = uniformAverage (fun z : βˆ€ i, ZMod (s i) =>
∏ i, if z i + (site : ZMod (s i)) = 0 then (5 : ℝ) else 1) := by
simp only [activeState_five_pow, decide_eq_true_eq]
_ = _ := by
rw [uniformAverage_pi_product
(fun i (z : ZMod (s i)) => if z + (site : ZMod (s i)) = 0 then (5 : ℝ) else 1)]
simp only [uniformAverage_padding_factor]
lemma padding_state_coefficient_bound (L : ℝ) (r : β„•)
(hL : 4800 ≀ L) (hr : (r : ℝ) ≀ 400 * Real.log L) :
(5 : ℝ) ^ r ≀ Real.exp (L ^ 4) := by
have hL0 : 0 ≀ L := by linarith
have hlog : Real.log L ≀ L :=
(Real.log_le_sub_one_of_pos (by linarith)).trans (by linarith)
have hpow : 2000 * L ≀ L ^ 4 := by
have h1 := mul_nonneg hL0 (show 0 ≀ L - 2000 by linarith)
have h2 := mul_nonneg (sq_nonneg L) (show 0 ≀ L ^ 2 - 1 by nlinarith)
nlinarith
calc
_ ≀ (Real.exp 5) ^ r := pow_le_pow_leftβ‚€ (by norm_num)
(by linarith [Real.add_one_le_exp (5 : ℝ)]) r
_ = Real.exp (r * 5) := by rw [Real.exp_nat_mul]
_ ≀ _ := Real.exp_le_exp.mpr (by nlinarith)
theorem BravermanDepth22Input.eventually_prime_state_weight (hBr : BravermanDepth22Input) :
βˆƒ A : β„•, 1000 ≀ A ∧ βˆ€αΆ  L : ℝ in atTop,
βˆ€ (m : β„•) (s : Fin m β†’ β„•) [βˆ€ i, NeZero (s i)],
0 < m β†’ (m : ℝ) ≀ Real.exp L β†’
Pairwise (fun i j => (s i).Coprime (s j)) β†’
(βˆ€ i, (s i : ℝ) ≀ Real.exp L) β†’
βˆ€ (site : β„€) (a N : β„•), Real.exp (L ^ A / 2) ≀ (N : ℝ) β†’
uniformAverage (fun x : Fin N => primeStateTruncatedWeight s
⌊400 * Real.log LβŒ‹β‚Š site (fun i => (a + x.val : ZMod (s i)))) ≀
(∏ i, (1 + 4 / (s i : ℝ))) + Real.exp (-(L ^ 9)) := by
obtain ⟨A, hA, hcompare⟩ := hBr.eventually_active_state_comparison
refine ⟨A, hA, ?_⟩
filter_upwards [hcompare, eventually_ge_atTop (4800 : ℝ)] with L hcompare hL
intro m s _ hm hmL hcop hs site a N hN
let M : β„• := ⌊400 * Real.log LβŒ‹β‚Š
have hlog : 0 ≀ 400 * Real.log L :=
mul_nonneg (by norm_num) (Real.log_nonneg (by linarith))
have hM : (M : ℝ) ≀ 400 * Real.log L := Nat.floor_le hlog
let f : (Fin 1 β†’ Finset (Fin m)) β†’ ℝ := fun S => (5 : ℝ) ^ (S 0).card
have hf : βˆ€ b : Fin 1 β†’ boundedActiveStates m M,
|f (fun r => (b r).val)| ≀ Real.exp (L ^ 4) := by
intro b
dsimp [f]
rw [abs_of_nonneg (pow_nonneg (by norm_num) _)]
apply padding_state_coefficient_bound L _ hL
exact (Nat.cast_le.mpr (mem_boundedActiveStates.mp (b 0).property)).trans hM
have hc := hcompare m s hm (by linarith) hcop hs 1 m m M hmL hM
(by norm_num; linarith)
(fun i => i) (fun i z => decide (z + (site : ZMod (s i)) = 0))
(fun _ i => i) f hf a N hN
have he (z : βˆ€ i, ZMod (s i)) :
(if βˆ€ r : Fin 1,
(activeState (fun i => residueCircuitInputs s (fun i => i)
(fun i z => decide (z + (site : ZMod (s i)) = 0)) z i)).card ≀ M
then f (fun _ => activeState (fun i => residueCircuitInputs s (fun i => i)
(fun i z => decide (z + (site : ZMod (s i)) = 0)) z i)) else 0) =
primeStateTruncatedWeight s M site z := by
simp only [residueCircuitInputs, f, primeStateTruncatedWeight, forall_const]
dsimp only at hc
simp only [he] at hc
have hb := primeStateTruncatedWeight_average_le s M site
linarith [(le_abs_self
(uniformAverage (fun x : Fin N => primeStateTruncatedWeight s M site
(fun i => (a + x.val : ZMod (s i)))) -
uniformAverage (primeStateTruncatedWeight s M site))).trans hc]
lemma primeStateTruncatedWeight_actual {m : β„•} (Q : Finset β„•) (e : Fin m ≃ Q)
[βˆ€ i, NeZero (e i).val] (M : β„•) (site n : β„€) :
primeStateTruncatedWeight (fun i => (e i).val) M site
(fun i => (n : ZMod (e i).val)) =
if actualPaddingDegree Q (n + site) ≀ M then actualPaddingWeight Q (n + site) else 0 := by
have hs : activeState (fun i => decide ((n : ZMod (e i).val) +
(site : ZMod (e i).val) = 0)) = paddingActiveState Q e (n + site) := by
apply (paddingActiveState_residue Q e _ (n + site) _).symm
intro i
exact Int.cast_add n site
simp only [primeStateTruncatedWeight, hs, paddingActiveState_card, actualPaddingWeight]
lemma primeSet_card_le_exp (Q : Finset β„•) (hQ : βˆ€ p ∈ Q, p.Prime)
(L : ℝ) (hupper : βˆ€ p ∈ Q, (p : ℝ) ≀ Real.exp L) :
(Q.card : ℝ) ≀ Real.exp L := by
have hs : Q βŠ† Icc 1 ⌊Real.exp LβŒ‹β‚Š := by
intro p hp
exact mem_Icc.mpr ⟨(hQ p hp).one_lt.le,
(Nat.le_floor_iff (Real.exp_pos L).le).mpr (hupper p hp)⟩
have hc : Q.card ≀ ⌊Real.exp LβŒ‹β‚Š := by
simpa only [Nat.card_Icc, Nat.add_sub_cancel] using card_le_card hs
exact (Nat.cast_le.mpr hc).trans (Nat.floor_le (Real.exp_pos L).le)
lemma paddingTiltNormalizer_one_le (Q : Finset β„•) : 1 ≀ paddingTiltNormalizer Q := by
calc
1 = ∏ _p : Q, (1 : ℝ) := by simp
_ ≀ paddingTiltNormalizer Q := by
apply prod_le_prodβ‚€
Β· intro p _
exact zero_le_one
Β· intro p _
exact le_add_of_nonneg_right (by positivity)
/-- The manuscript's truncated-weight estimate, for literal integer
sites and every permitted interval and offset. -/
theorem BravermanDepth22Input.eventually_actual_padding_weight (hBr : BravermanDepth22Input) :
βˆƒ A : β„•, 1000 ≀ A ∧ βˆ€αΆ  L : ℝ in atTop,
βˆ€ (Q : Finset β„•), (βˆ€ p ∈ Q, p.Prime) β†’
(βˆ€ p ∈ Q, (p : ℝ) ≀ Real.exp L) β†’
βˆ€ (site : β„€) (a N : β„•), Real.exp (L ^ A / 2) ≀ (N : ℝ) β†’
let T := uniformAverage (fun x : Fin N =>
(actualPaddingVertex Q (((a + x.val : β„•) : β„€) + site)) ^ 2 *
if actualPaddingDegreeCut Q L (((a + x.val : β„•) : β„€) + site) then 1 else 0)
T ≀ paddingTiltNormalizer Q + Real.exp (-(L ^ 9)) ∧
T ≀ 2 * paddingTiltNormalizer Q := by
obtain ⟨A, hA, hb⟩ := hBr.eventually_prime_state_weight
refine ⟨A, hA, ?_⟩
filter_upwards [hb, eventually_ge_atTop (4800 : ℝ)] with L hb hL
intro Q hQ hupper site a N hN
have hL0 : 0 ≀ L := by linarith
have hlog : 0 ≀ 400 * Real.log L :=
mul_nonneg (by norm_num) (Real.log_nonneg (by linarith))
have hmain : uniformAverage (fun x : Fin N =>
(actualPaddingVertex Q (((a + x.val : β„•) : β„€) + site)) ^ 2 *
if actualPaddingDegreeCut Q L (((a + x.val : β„•) : β„€) + site) then 1 else 0) ≀
paddingTiltNormalizer Q + Real.exp (-(L ^ 9)) := by
by_cases hne : Q.Nonempty
Β· let m := Fintype.card Q
let e : Fin m ≃ Q := (Fintype.equivFin Q).symm
let s := fun i : Fin m => (e i).val
let (i : Fin m) : NeZero (s i) := ⟨(hQ _ (e i).property).ne_zero⟩
have hm : 0 < m := Fintype.card_pos_iff.mpr ⟨⟨hne.choose, hne.choose_spec⟩⟩
have hmL : (m : ℝ) ≀ Real.exp L := by
simpa only [m, Fintype.card_coe] using primeSet_card_le_exp Q hQ L hupper
have hcop : Pairwise (fun i j => (s i).Coprime (s j)) := by
intro i j hij
apply (Nat.coprime_primes (hQ _ (e i).property) (hQ _ (e j).property)).mpr
intro he
exact hij (e.injective (Subtype.ext he))
have hs (i : Fin m) : (s i : ℝ) ≀ Real.exp L := hupper _ (e i).property
have hh := hb m s hm hmL hcop hs site a N hN
have heval (x : Fin N) : primeStateTruncatedWeight s ⌊400 * Real.log LβŒ‹β‚Š site
(fun i => (a + x.val : ZMod (s i))) =
(actualPaddingVertex Q (((a + x.val : β„•) : β„€) + site)) ^ 2 *
if actualPaddingDegreeCut Q L (((a + x.val : β„•) : β„€) + site) then 1 else 0 := by
have hx := primeStateTruncatedWeight_actual Q e ⌊400 * Real.log LβŒ‹β‚Š site
((a + x.val : β„•) : β„€)
simp only [Nat.cast_add, Int.cast_add, Int.cast_natCast] at hx
rw [hx]
simp only [Nat.le_floor_iff hlog, actualPaddingVertex_sq,
actualPaddingDegreeCut, Nat.cast_add]
split_ifs <;> simp
have hnorm : (∏ i, (1 + 4 / (s i : ℝ))) = paddingTiltNormalizer Q :=
e.prod_comp (fun p : Q => 1 + 4 / (p.val : ℝ))
simpa only [heval, hnorm] using hh
Β· have hQempty : Q = βˆ… := not_nonempty_iff_eq_empty.mp hne
subst Q
have hNpos : 0 < N := by exact_mod_cast (Real.exp_pos _).trans_le hN
let : NeZero N := ⟨by omega⟩
have hf (x : Fin N) :
(actualPaddingVertex βˆ… (((a + x.val : β„•) : β„€) + site)) ^ 2 *
(if actualPaddingDegreeCut βˆ… L (((a + x.val : β„•) : β„€) + site)
then (1 : ℝ) else 0) = 1 := by
simp only [actualPaddingVertex_sq, actualPaddingWeight, actualPaddingDegree,
filter_empty, card_empty, pow_zero, actualPaddingDegreeCut, Nat.cast_zero,
hlog, ite_true, mul_one]
simp only [hf, uniformAverage_const]
have hnorm : paddingTiltNormalizer βˆ… = 1 := by simp [paddingTiltNormalizer]
rw [hnorm]
linarith [Real.exp_pos (-(L ^ 9))]
dsimp only
refine ⟨hmain, ?_⟩
have he : Real.exp (-(L ^ 9)) ≀ 1 :=
Real.exp_le_one_iff.mpr (neg_nonpos.mpr (pow_nonneg hL0 _))
have hS := paddingTiltNormalizer_one_le Q
linarith
/-- Summing over any fixed finite collection of offsets costs its cardinality. -/
theorem BravermanDepth22Input.eventually_actual_padding_weight_sum
(hBr : BravermanDepth22Input) :
βˆƒ A : β„•, 1000 ≀ A ∧ βˆ€αΆ  L : ℝ in atTop,
βˆ€ (Q : Finset β„•), (βˆ€ p ∈ Q, p.Prime) β†’
(βˆ€ p ∈ Q, (p : ℝ) ≀ Real.exp L) β†’
βˆ€ {ΞΉ : Type*} [DecidableEq ΞΉ] (offsets : Finset ΞΉ) (site : ΞΉ β†’ β„€)
(a N : β„•), Real.exp (L ^ A / 2) ≀ (N : ℝ) β†’
(βˆ‘ i ∈ offsets, uniformAverage (fun x : Fin N =>
(actualPaddingVertex Q (((a + x.val : β„•) : β„€) + site i)) ^ 2 *
if actualPaddingDegreeCut Q L (((a + x.val : β„•) : β„€) + site i)
then 1 else 0)) ≀
2 * (offsets.card : ℝ) * paddingTiltNormalizer Q := by
obtain ⟨A, hA, hb⟩ := hBr.eventually_actual_padding_weight
refine ⟨A, hA, ?_⟩
filter_upwards [hb] with L hb
intro Q hQ hupper ΞΉ _ offsets site a N hN
calc
_ ≀ βˆ‘ _i ∈ offsets, 2 * paddingTiltNormalizer Q := by
apply sum_le_sum
intro i _
exact (hb Q hQ hupper (site i) a N hN).2
_ = _ := by rw [sum_const, nsmul_eq_mul]; ring
end TwoPointCorrelations
end OAI