cfahlgren1/math / lean /OAI /Analysis /Littlewood /SlotParameters.lean
cfahlgren1's picture
download
raw
12.2 kB
import OAI.Analysis.Littlewood.SlotGraph
namespace OAI
universe uV
/-! Parameter choices for the concrete signed-slot packing. The chunk
length is chosen first and remains fixed while the prime modulus grows. -/
namespace AsymptoticallyMinimalLittlewood.Packing
noncomputable section
open Filter Topology
open scoped BigOperators
def chunkCount (B q : โ„•) : โ„• := (q-1)/B
lemma chunkCount_bounds {B q : โ„•} (hB : 0<B) (hq : 0<q) :
B*chunkCount B q<q โˆง qโ‰คB*(chunkCount B q+1) := by
have hm := Nat.mod_lt (q-1) hB
have he := Nat.mod_add_div (q-1) B
dsimp [chunkCount]
constructor
ยท have hd := Nat.mul_div_le (q-1) B
omega
ยท nlinarith only [hm,he,show q-1+1=q by omega]
lemma chunkCount_pos {B q : โ„•} (hB : 0<B) (hq : B<q) : 0<chunkCount B q := by
exact Nat.div_pos (by omega) hB
lemma chunkCount_ratio_error {B q : โ„•} (hB : 0<B) (hq : 0<q) :
|(chunkCount B q : โ„)/q-1/(B : โ„)|โ‰ค1/(q : โ„) := by
obtain โŸจhlo,hhiโŸฉ := chunkCount_bounds hB hq
have hB' : (0 : โ„)<B := by exact_mod_cast hB
have hq' : (0 : โ„)<q := by exact_mod_cast hq
have hlo' : (B : โ„)*chunkCount B qโ‰คq := by exact_mod_cast hlo.le
have hhi' : (q : โ„)โ‰คB*(chunkCount B q+1) := by exact_mod_cast hhi
rw [abs_le]
constructor
ยท apply (mul_le_mul_iff_of_pos_right (mul_pos hB' hq')).mp
field_simp
nlinarith only [hhi']
ยท apply (mul_le_mul_iff_of_pos_right (mul_pos hB' hq')).mp
field_simp
nlinarith only [hlo']
lemma chunkCount_ratio_tendsto {B : โ„•} (hB : 0<B) :
Tendsto (fun q : โ„• โ†ฆ (chunkCount B q : โ„)/q) atTop (๐“ (1/(B : โ„))) := by
rw [tendsto_iff_norm_sub_tendsto_zero]
apply squeeze_zero' (Filter.Eventually.of_forall (fun q โ†ฆ norm_nonneg _))
ยท filter_upwards [eventually_gt_atTop (0 : โ„•)] with q hq
simpa only [Real.norm_eq_abs] using chunkCount_ratio_error hB hq
ยท exact tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop
def packingAV (r L R q : โ„•) : โ„ :=
let k := (chunkCount (2*R*L) q : โ„)/(q : โ„)
let u := 1/(q : โ„)
3*(2*(((r-1 : โ„•) : โ„)*(1-2*((R : โ„)-2)*L*k)+
2*((r-1 : โ„•) : โ„)^2*(2*(R : โ„)*L+1)*u)+
((r-1 : โ„•) : โ„)^2*(1-2*((R : โ„)-2)*L*k+2*((R : โ„)-2)*L*u))
def packingNV (r L R q : โ„•) : โ„ :=
(r : โ„)*((R : โ„)-1)*((chunkCount (2*R*L) q : โ„)/(q : โ„))
def packingALimit (r R : โ„•) : โ„ :=
6*(2*((r-1 : โ„•) : โ„)+((r-1 : โ„•) : โ„)^2)/(R : โ„)
def packingNLimit (r L R : โ„•) : โ„ :=
(r : โ„)*(1-1/(R : โ„))/(2*(L : โ„))
lemma packingAV_tendsto {r L R : โ„•} (hL : 0<L) (hR : 0<R) :
Tendsto (packingAV r L R) atTop (๐“ (packingALimit r R)) := by
have hk := chunkCount_ratio_tendsto (show 0<2*R*L by positivity)
have hq : Tendsto (fun q : โ„• โ†ฆ 1/(q : โ„)) atTop (๐“ (0 : โ„)) :=
tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop
let a := ((r-1 : โ„•) : โ„)
let c := 2*((R : โ„)-2)*L
have hb := tendsto_const_nhds (x := (1 : โ„)) |>.sub (hk.const_mul c)
have ht := (((hb.const_mul a).add (hq.const_mul (2*a^2*(2*(R : โ„)*L+1)))).const_mul 2 |>.add
((hb.add (hq.const_mul c)).const_mul (a^2))).const_mul 3
have he : 3*(2*(a*(1-c*(1/((2*R*L : โ„•) : โ„)))+
2*a^2*(2*(R : โ„)*L+1)*0)+a^2*(1-c*(1/((2*R*L : โ„•) : โ„))+c*0)) =
packingALimit r R := by
dsimp [a,c,packingALimit]
have hRn : (R : โ„)โ‰ 0 := by exact_mod_cast hR.ne'
have hLn : (L : โ„)โ‰ 0 := by exact_mod_cast hL.ne'
push_cast
field_simp
ring
rw [he] at ht
exact ht
lemma packingNV_tendsto {r L R : โ„•} (hL : 0<L) (hR : 0<R) :
Tendsto (packingNV r L R) atTop (๐“ (packingNLimit r L R)) := by
have hk := chunkCount_ratio_tendsto (show 0<2*R*L by positivity)
have ht := hk.const_mul ((r : โ„)*((R : โ„)-1))
have he : (r : โ„)*((R : โ„)-1)*(1/((2*R*L : โ„•) : โ„))=packingNLimit r L R := by
dsimp [packingNLimit]
have hRn : (R : โ„)โ‰ 0 := by exact_mod_cast hR.ne'
have hLn : (L : โ„)โ‰ 0 := by exact_mod_cast hL.ne'
push_cast
field_simp
rw [he] at ht
exact ht
lemma packingALimit_tendsto (r : โ„•) :
Tendsto (packingALimit r) atTop (๐“ (0 : โ„)) := by
exact tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop
lemma packingNLimit_tendsto (r L : โ„•) :
Tendsto (packingNLimit r L) atTop (๐“ ((r : โ„)/(2*L))) := by
have hq : Tendsto (fun R : โ„• โ†ฆ 1/(R : โ„)) atTop (๐“ (0 : โ„)) :=
tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop
unfold packingNLimit
simpa only [sub_zero, mul_one] using
(((tendsto_const_nhds (x := (1 : โ„))).sub hq).const_mul (r : โ„)).div_const (2*L)
def packingBV (r L R : โ„•) (e p : โ„) (q : โ„•) : โ„ :=
(r : โ„)*max (packingAV r L R q) 0/(e*p/2)^2
def packingBLimit (r R : โ„•) (e p : โ„) : โ„ :=
(r : โ„)*packingALimit r R/(e*p/2)^2
lemma packingBV_nonneg (r L R q : โ„•) (e p : โ„) :
0โ‰คpackingBV r L R e p q := by
exact div_nonneg (mul_nonneg (Nat.cast_nonneg _) (le_max_right _ _)) (sq_nonneg _)
lemma packingBV_tendsto {r L R : โ„•} (hL : 0<L) (hR : 0<R) (e p : โ„) :
Tendsto (packingBV r L R e p) atTop (๐“ (packingBLimit r R e p)) := by
have hA : 0โ‰คpackingALimit r R := by unfold packingALimit; positivity
have h := (((packingAV_tendsto (r := r) hL hR).max
(tendsto_const_nhds (x := (0 : โ„)))).const_mul (r : โ„)).div_const ((e*p/2)^2)
unfold packingBV packingBLimit
simpa only [max_eq_left hA] using h
lemma packingBLimit_tendsto (r : โ„•) (e p : โ„) :
Tendsto (fun R โ†ฆ packingBLimit r R e p) atTop (๐“ (0 : โ„)) := by
have h := ((packingALimit_tendsto r).const_mul (r : โ„)).div_const ((e*p/2)^2)
unfold packingBLimit
simpa only [mul_zero,zero_div] using h
lemma packing_choose_R {r L : โ„•} (hr : 0<r) (hL : 0<L)
{e p ฮท t : โ„} (he : 0<e) (hp : 0<p)
(hmargin : (r : โ„)*t<(1-ฮท)*((r : โ„)/(2*L))) :
โˆƒ R : โ„•, 3โ‰คR โˆง
packingBLimit r R e p<e*p/2 โˆง
0<packingNLimit r L R-packingBLimit r R e p โˆง
packingNLimit r L R<(r : โ„) โˆง
(r : โ„)*t<(1-ฮท)*(packingNLimit r L R-packingBLimit r R e p) := by
have hNpos : (0 : โ„)<(r : โ„)/(2*L) := by positivity
have hNlt : (r : โ„)/(2*L)<r := by
have hl : (1 : โ„)โ‰คL := by exact_mod_cast hL
have hr' : (0 : โ„)<r := by exact_mod_cast hr
apply (div_lt_iffโ‚€ (by positivity : (0 : โ„)<2*L)).mpr
nlinarith
have hN := packingNLimit_tendsto r L
have hB := packingBLimit_tendsto r e p
have hS := hN.sub hB
have hSp : Tendsto (fun R โ†ฆ packingNLimit r L R-packingBLimit r R e p) atTop
(๐“ ((r : โ„)/(2*L))) := by simpa using hS
have hev : โˆ€แถ  R : โ„• in atTop, 3โ‰คR โˆง
packingBLimit r R e p<e*p/2 โˆง
0<packingNLimit r L R-packingBLimit r R e p โˆง
packingNLimit r L R<(r : โ„) โˆง
(r : โ„)*t<(1-ฮท)*(packingNLimit r L R-packingBLimit r R e p) := by
filter_upwards [eventually_ge_atTop 3,
hB.eventually (gt_mem_nhds (show (0 : โ„)<e*p/2 by positivity)),
hSp.eventually (lt_mem_nhds hNpos),hN.eventually (gt_mem_nhds hNlt),
(hSp.const_mul (1-ฮท)).eventually (lt_mem_nhds hmargin)] with R hR h1 h2 h3 h4
exact โŸจhR,h1,h2,h3,h4โŸฉ
exact hev.exists
lemma packing_eventual_parameters {r L R : โ„•} (hL : 0<L) (hR : 0<R)
{e p ฮท t T : โ„} (he : 0<e) (hp : 0<p)
(hB : packingBLimit r R e p<e*p/2)
(hS : 0<packingNLimit r L R-packingBLimit r R e p)
(hN : packingNLimit r L R<(r : โ„))
(hM : (r : โ„)*t<(1-ฮท)*(packingNLimit r L R-packingBLimit r R e p)) :
โˆ€แถ  q : โ„• in atTop,
1/(q : โ„)โ‰คe*p โˆง T/(q : โ„)โ‰คp โˆง
T/(q : โ„)โ‰คpackingNV r L R q-packingBV r L R e p q โˆง
packingBV r L R e p qโ‰คe*p/2 โˆง packingNV r L R qโ‰ค(r : โ„) โˆง
(r : โ„)*t<(1-ฮท)*(packingNV r L R q-packingBV r L R e p q) := by
have hNt := packingNV_tendsto (r := r) hL hR
have hBt := packingBV_tendsto (r := r) hL hR e p
have hSt := hNt.sub hBt
have hq : Tendsto (fun q : โ„• โ†ฆ 1/(q : โ„)) atTop (๐“ (0 : โ„)) :=
tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop
have hT : Tendsto (fun q : โ„• โ†ฆ T/(q : โ„)) atTop (๐“ (0 : โ„)) :=
tendsto_const_nhds.div_atTop tendsto_natCast_atTop_atTop
filter_upwards [hq.eventually (gt_mem_nhds (mul_pos he hp)),
hT.eventually (gt_mem_nhds hp),hT.eventually_lt hSt hS,
hBt.eventually (gt_mem_nhds hB),hNt.eventually (gt_mem_nhds hN),
(hSt.const_mul (1-ฮท)).eventually (lt_mem_nhds hM)] with q h1 h2 h3 h4 h5 h6
exact โŸจh1.le,h2.le,h3.le,h4.le,h5.le,h6โŸฉ
end
end AsymptoticallyMinimalLittlewood.Packing
namespace AsymptoticallyMinimalLittlewood.Packing
noncomputable section
open scoped BigOperators
open Finset Nibble Filter Topology
attribute [local instance] Classical.propDecidable
lemma concrete_slot_variance_le_av {r q : โ„•} [Fact q.Prime]
(d : Fin r โ†’ โ„•) (R : โ„•) (iโ‚€ : Fin r) (hR : 2โ‰คR)
(hq' : 2*R*periodLength (oddLengths d)<q)
{V : Type uV} [AddCommGroup V] [Module (ZMod q) V] [Fintype V] [DecidableEq V]
(g : Fin r โ†’ V โ†’โ‚—[ZMod q] ZMod q)
(hg : โˆ€ i, Function.Surjective (g i))
(hpair : โˆ€ i j, iโ‰ j โ†’ Function.Surjective ((g i).prod (g j))) (i : Fin r) :
let K := chunkCount (2*R*periodLength (oddLengths d)) q
avg (fun ฯ‰ : SlotChoices d K โ†ฆ avg (fun s : ZMod q โ†ฆ
(slotDensity g (fun j t โ†ฆ slotHit d R K q j ฯ‰ t) i s-
(1/(2*periodLength (oddLengths d) : โ„))^(r-1))^2)) โ‰ค
packingAV r (periodLength (oddLengths d)) R q := by
dsimp only
let L := periodLength (oddLengths d)
let K := chunkCount (2*R*L) q
have hL : 0<L := periodLength_pos d iโ‚€
have hq0 : 0<q := (Fact.out : q.Prime).pos
have hq : 2*(K*(R*L))<q := by
have h := (chunkCount_bounds (show 0<2*R*L by positivity) hq0).1
dsimp [K]
nlinarith only [h]
have hK : 0<K := chunkCount_pos (by positivity) hq'
have h := concrete_slot_variance d R K iโ‚€ hK hq g hg hpair i
have hcat : (catalogSet d R K q).cardโ‰คq := by
simpa only [ZMod.card] using (Finset.card_le_univ (catalogSet d R K q))
have hc := catalogSet_card d R K q iโ‚€ hq
have hs : ((shortResidues q (R*L)).card : โ„)โ‰ค2*(R : โ„)*L+1 := by
simpa only [Nat.cast_add,Nat.cast_mul,Nat.cast_ofNat,Nat.cast_one,mul_assoc] using
(Nat.cast_le.mpr (shortResidues_card q (R*L)) : ((shortResidues q (R*L)).card : โ„)โ‰ค((2*(R*L)+1 : โ„•) : โ„))
have hR2 : ((R-2 : โ„•) : โ„)=(R : โ„)-2 := by rw [Nat.cast_sub hR]; norm_num
have hqpos : (0 : โ„)<q := by exact_mod_cast hq0
apply h.trans
rw [Nat.cast_add,Nat.cast_sub hcat]
simp only [hc,Nat.cast_mul,Nat.cast_ofNat,hR2]
change 3*(2*(((r-1 : โ„•) : โ„)*((q : โ„)-2*(K : โ„)*(((R : โ„)-2)*L))/q+
2*((r-1 : โ„•) : โ„)^2*((shortResidues q (R*L)).card : โ„)/q)+
((r-1 : โ„•) : โ„)^2*((q : โ„)-2*(K : โ„)*(((R : โ„)-2)*L)+2*(((R : โ„)-2)*L))/q)โ‰ค_
have hshort := div_le_div_of_nonneg_right
(mul_le_mul_of_nonneg_left hs (by positivity : (0 : โ„)โ‰ค2*((r-1 : โ„•) : โ„)^2)) hqpos.le
dsimp [packingAV]
change _โ‰ค3*(2*(((r-1 : โ„•) : โ„)*(1-2*((R : โ„)-2)*L*((K : โ„)/q))+
2*((r-1 : โ„•) : โ„)^2*(2*(R : โ„)*L+1)*(1/q))+
((r-1 : โ„•) : โ„)^2*(1-2*((R : โ„)-2)*L*((K : โ„)/q)+2*((R : โ„)-2)*L*(1/q)))
have hqne := hqpos.ne'
field_simp at hshort โŠข
nlinarith only [hshort]
lemma concrete_slot_nv {r q R : โ„•} [Fact q.Prime]
(d : Fin r โ†’ โ„•) (iโ‚€ : Fin r) (hR : 1โ‰คR)
(ฯ‰ : SlotChoices d (chunkCount (2*R*periodLength (oddLengths d)) q)) :
((slotVertices (fun i t โ†ฆ slotHit d R
(chunkCount (2*R*periodLength (oddLengths d)) q) q i ฯ‰ t)).card : โ„)=
(q : โ„)*packingNV r (periodLength (oddLengths d)) R q := by
have hL := periodLength_pos d iโ‚€
have hq0 := (Fact.out : q.Prime).pos
have hq : 2*(chunkCount (2*R*periodLength (oddLengths d)) q*
(R*periodLength (oddLengths d)))<q := by
have h := (chunkCount_bounds (show 0<2*R*periodLength (oddLengths d) by positivity) hq0).1
nlinarith only [h]
rw [concrete_slot_vertices_card d R _ hq]
simp only [Nat.cast_mul,Nat.cast_sub hR,Nat.cast_one]
unfold packingNV
have hqne : (q : โ„)โ‰ 0 := by exact_mod_cast hq0.ne'
field_simp
end
end AsymptoticallyMinimalLittlewood.Packing
end OAI

Xet Storage Details

Size:
12.2 kB
ยท
Xet hash:
e45dbf3a581d452ff07de1aaf72c9ed9fcddabb1b8e3a22d8f164100d576ebb8

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