File size: 5,887 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 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 | import OAI.NumberTheory.Ostmann.Arithmetic.FrequencyTreeSum
import OAI.NumberTheory.Ostmann.Characters.SignedFrequencySum
namespace OAI
/-! # The full arithmetic frequency-tree budget -/
namespace Ostmann
open scoped BigOperators Classical
noncomputable def pairedFrequencyKernel (S : Finset β€) (D : β)
(root left right : S Γ S) : β :=
2 * D ^ 2 *
(((reducedFrequency ((left.1 : β€).natAbs.gcd (right.1 : β€).natAbs) (root.1 : β€).natAbs).lcm
(reducedFrequency ((left.2 : β€).natAbs.gcd (right.2 : β€).natAbs) (root.2 : β€).natAbs) : β) : β)β»ΒΉ
theorem pairedFrequencyKernel_sum_le (S : Finset β€) (N : β) (D : β) (hD : 0 β€ D)
(hS : β s β S, s β 0 β§ s.natAbs β€ N)
(hdiv : β v β S, β w β S, ((v.natAbs.gcd w.natAbs).divisors.card : β) β€ D)
(left right : S Γ S) :
(β root : S Γ S, pairedFrequencyKernel S D root left right) β€
8 * D ^ 4 * (1 + Real.log N) ^ 3 := by
let g := (left.1 : β€).natAbs.gcd (right.1 : β€).natAbs
let h := (left.2 : β€).natAbs.gcd (right.2 : β€).natAbs
have hg : g β 0 := Nat.ne_of_gt (Nat.gcd_pos_of_pos_left _
(Int.natAbs_pos.mpr (hS _ left.1.property).1))
have hh : h β 0 := Nat.ne_of_gt (Nat.gcd_pos_of_pos_left _
(Int.natAbs_pos.mpr (hS _ left.2.property).1))
have hgd : (g.divisors.card : β) β€ D := hdiv _ left.1.property _ right.1.property
have hhd : (h.divisors.card : β) β€ D := hdiv _ left.2.property _ right.2.property
have hpair :
(β s : S, β t : S,
(((reducedFrequency g (s : β€).natAbs).lcm (reducedFrequency h (t : β€).natAbs) : β) : β)β»ΒΉ) =
β s β S, β t β S,
(((reducedFrequency g s.natAbs).lcm (reducedFrequency h t.natAbs) : β) : β)β»ΒΉ := by
rw [Finset.sum_coe_sort S (fun s : β€ => β t : S,
(((reducedFrequency g s.natAbs).lcm (reducedFrequency h (t : β€).natAbs) : β) : β)β»ΒΉ)]
exact Finset.sum_congr rfl fun s _ => Finset.sum_coe_sort S (fun t : β€ =>
(((reducedFrequency g s.natAbs).lcm (reducedFrequency h t.natAbs) : β) : β)β»ΒΉ)
calc
_ = 2 * D ^ 2 * (β s : S, β t : S,
(((reducedFrequency g (s : β€).natAbs).lcm (reducedFrequency h (t : β€).natAbs) : β) : β)β»ΒΉ) := by
simp only [pairedFrequencyKernel, Fintype.sum_prod_type, β Finset.mul_sum, g, h]
_ β€ 2 * D ^ 2 * (4 * (g.divisors.card : β) * h.divisors.card * (1 + Real.log N) ^ 3) := by
rw [hpair]
exact mul_le_mul_of_nonneg_left (signed_reducedFrequency_lcm_sum_le S S N g h hS hS hg hh)
(by positivity)
_ β€ 2 * D ^ 2 * (4 * D * D * (1 + Real.log N) ^ 3) := by
apply mul_le_mul_of_nonneg_left _ (by positivity)
have hlog : 0 β€ (1 + Real.log N) ^ 3 := by
have hbase := Real.log_natCast_nonneg N
positivity
exact mul_le_mul_of_nonneg_right
(mul_le_mul (mul_le_mul_of_nonneg_left hgd (by norm_num)) hhd
(Nat.cast_nonneg _) (by positivity)) hlog
_ = _ := by ring
noncomputable def pairedFrequencyLeaf (S : Finset β€) (V : β) (x : S Γ S) : β :=
if (x.1 : β€).natAbs β€ V β§ (x.2 : β€).natAbs β€ V then 1 else 0
theorem pairedFrequencyLeaf_sum_le (S : Finset β€) (V : β)
(hS : β s β S, s β 0) :
(β x : S Γ S, pairedFrequencyLeaf S V x) β€ (2 * (V : β)) ^ 2 := by
let T := S.filter fun s => s.natAbs β€ V
have hT : β s β T, s β 0 β§ s.natAbs β€ V := by
intro s hs
exact β¨hS s (Finset.mem_filter.mp hs).1, (Finset.mem_filter.mp hs).2β©
have hcard : (T.card : β) β€ 2 * V := by
have hbound := sum_signed_magnitudes_le T V hT (fun _ => (1 : β)) (by intros; norm_num)
simpa using hbound
have hsingle : (β s : S, if (s : β€).natAbs β€ V then (1 : β) else 0) = T.card := by
rw [Finset.sum_coe_sort S (fun s : β€ => if s.natAbs β€ V then (1 : β) else 0)]
simp only [β Finset.sum_filter, Finset.sum_const, nsmul_eq_mul, mul_one, T]
have hterm (x y : S) : pairedFrequencyLeaf S V (x, y) =
(if (x : β€).natAbs β€ V then (1 : β) else 0) *
(if (y : β€).natAbs β€ V then (1 : β) else 0) := by
unfold pairedFrequencyLeaf
split_ifs <;> simp_all
calc
_ = (T.card : β) ^ 2 := by
rw [Fintype.sum_prod_type, pow_two, β hsingle, Finset.sum_mul_sum]
simp only [hterm]
_ β€ _ := pow_le_pow_leftβ (Nat.cast_nonneg _) hcard 2
/-- Root-first elimination leaves only the two histories' leaf frequencies.
The exponent `2^n-1` is the exact number of internal nodes. -/
theorem arithmetic_frequency_tree_sum_le (S : Finset β€) (N V : β) (D : β)
(hD : 0 β€ D) (hS : β s β S, s β 0 β§ s.natAbs β€ N)
(hdiv : β v β S, β w β S, ((v.natAbs.gcd w.natAbs).divisors.card : β) β€ D)
(n : β) :
(β x : FrequencyTree (S Γ S) n,
frequencyTreeWeight (pairedFrequencyKernel S D) (pairedFrequencyLeaf S V) n x) β€
(8 * D ^ 4 * (1 + Real.log N) ^ 3) ^ (2 ^ n - 1) * (2 * (V : β)) ^ (2 * 2 ^ n) := by
have hC : 0 β€ 8 * D ^ 4 * (1 + Real.log N) ^ 3 := by
have hlog := Real.log_natCast_nonneg N
positivity
have hmain := frequencyTree_sum_le (pairedFrequencyKernel S D) (pairedFrequencyLeaf S V)
(8 * D ^ 4 * (1 + Real.log N) ^ 3) (by intros; unfold pairedFrequencyKernel; positivity)
(by intros; unfold pairedFrequencyLeaf; split_ifs <;> norm_num) hC
(pairedFrequencyKernel_sum_le S N D hD hS hdiv) n
apply hmain.trans
have hleaf := pairedFrequencyLeaf_sum_le S V (fun s hs => (hS s hs).1)
calc
_ β€ (8 * D ^ 4 * (1 + Real.log N) ^ 3) ^ (2 ^ n - 1) *
((2 * (V : β)) ^ 2) ^ (2 ^ n) :=
mul_le_mul_of_nonneg_left (pow_le_pow_leftβ
(Finset.sum_nonneg fun x _ => by unfold pairedFrequencyLeaf; split_ifs <;> norm_num)
hleaf _) (pow_nonneg hC _)
_ = _ := by rw [β pow_mul]
end Ostmann
end OAI
|