| | @@ -0,0 +1,174 @@ |
| 1 | +import ErdosSwarm.Erdos530Gap428.Data |
| 2 | +import ErdosSwarm.Erdos530Gap.WindowEnergy |
| 3 | + |
| 4 | +/-! |
| 5 | +# Tent duality for the 1/135 row of Erdős #530 |
| 6 | + |
| 7 | +Equation (5) of `experiments/erdos530/upper-smaller-k/NOTES.md` without the |
| 8 | +local-score term. Each tent of the kernel `W` is the overlap of two boxes of its |
| 9 | +width, so `W` is positive semidefinite: for real weights `c` at real locations `x`, |
| 10 | +`∑ c i * c j * W (x i - x j)` is a nonnegative combination of integrals of squares |
| 11 | +of weighted box sums. Coincident locations and negative weights are allowed. |
| 12 | +`tent_dual` applies this to the seed, with weight `1 / b` at each `y k`, minus the |
| 13 | +signed grid measure. |
| 14 | +-/ |
| 15 | + |
| 16 | +namespace ErdosSwarm.Erdos530Gap428 |
| 17 | + |
| 18 | +open Finset MeasureTheory ErdosSwarm.Erdos530Gap ErdosSwarm.Erdos530Gap.WindowAnalysis |
| 19 | + |
| 20 | +noncomputable section |
| 21 | + |
| 22 | +private lemma box_mul (h a b : ℝ) : |
| 23 | + (fun t => box h a t * box h b t) = |
| 24 | + (Set.Ioc (max (a - h) (b - h)) (min a b)).indicator (fun _ => 1) := by |
| 25 | + rw [← Set.Ioc_inter_Ioc] |
| 26 | + funext t |
| 27 | + by_cases ha : t ∈ Set.Ioc (a - h) a <;> by_cases hb : t ∈ Set.Ioc (b - h) b <;> |
| 28 | + simp [box, ha, hb] |
| 29 | + |
| 30 | +private lemma integrable_box_mul (h a b : ℝ) : Integrable (fun t => box h a t * box h b t) := by |
| 31 | + rw [box_mul] |
| 32 | + exact (integrableOn_const (by simp [Real.volume_Ioc])).integrable_indicator measurableSet_Ioc |
| 33 | + |
| 34 | +/-- Two boxes of width `h` overlap in length `(h - |a - b|)₊`, in either order |
| 35 | +and also when `a = b`. -/ |
| 36 | +private lemma integral_box_mul (h a b : ℝ) : |
| 37 | + (∫ t, box h a t * box h b t) = max (h - |a - b|) 0 := by |
| 38 | + rw [box_mul, integral_indicator_const _ measurableSet_Ioc, Real.volume_real_Ioc, |
| 39 | + smul_eq_mul, mul_one] |
| 40 | + congr 1 |
| 41 | + rcases le_total a b with hab | hab |
| 42 | + · rw [min_eq_left hab, max_eq_right (by linarith), abs_of_nonpos (by linarith)] |
| 43 | + ring |
| 44 | + · rw [min_eq_right hab, max_eq_left (by linarith), abs_of_nonneg (by linarith)] |
| 45 | + ring |
| 46 | + |
| 47 | +/-- The tent of half-width `h` is a positive semidefinite kernel on the line. -/ |
| 48 | +theorem tent_posSemidef {ι : Type*} (s : Finset ι) (c x : ι → ℝ) {h : ℝ} (hh : 0 < h) : |
| 49 | + 0 ≤ ∑ i ∈ s, ∑ j ∈ s, c i * c j * max (1 - |x i - x j| / h) 0 := by |
| 50 | + have hsq : ∀ t, (∑ i ∈ s, c i * box h (x i) t) ^ 2 = |
| 51 | + ∑ i ∈ s, ∑ j ∈ s, c i * c j * (box h (x i) t * box h (x j) t) := by |
| 52 | + intro t |
| 53 | + rw [sq, sum_mul_sum] |
| 54 | + exact sum_congr rfl fun i _ => sum_congr rfl fun j _ => by ring |
| 55 | + have hint : (∫ t, (∑ i ∈ s, c i * box h (x i) t) ^ 2) = |
| 56 | + ∑ i ∈ s, ∑ j ∈ s, c i * c j * max (h - |x i - x j|) 0 := by |
| 57 | + simp only [hsq] |
| 58 | + rw [integral_finsetSum _ fun i _ => |
| 59 | + integrable_finsetSum _ fun j _ => (integrable_box_mul h _ _).const_mul _] |
| 60 | + refine sum_congr rfl fun i _ => ?_ |
| 61 | + rw [integral_finsetSum _ fun j _ => (integrable_box_mul h _ _).const_mul _] |
| 62 | + refine sum_congr rfl fun j _ => ?_ |
| 63 | + rw [integral_const_mul, integral_box_mul] |
| 64 | + have hnn : 0 ≤ ∫ t, (∑ i ∈ s, c i * box h (x i) t) ^ 2 := |
| 65 | + integral_nonneg fun t => sq_nonneg _ |
| 66 | + have hdiv : ∑ i ∈ s, ∑ j ∈ s, c i * c j * max (1 - |x i - x j| / h) 0 = |
| 67 | + (∑ i ∈ s, ∑ j ∈ s, c i * c j * max (h - |x i - x j|) 0) / h := by |
| 68 | + rw [sum_div] |
| 69 | + refine sum_congr rfl fun i _ => ?_ |
| 70 | + rw [sum_div] |
| 71 | + refine sum_congr rfl fun j _ => ?_ |
| 72 | + have hmax : max (1 - |x i - x j| / h) 0 = max (h - |x i - x j|) 0 / h := by |
| 73 | + rw [← max_div_div_right hh.le, zero_div, sub_div, div_self hh.ne'] |
| 74 | + rw [hmax, mul_div_assoc] |
| 75 | + rw [hdiv, ← hint] |
| 76 | + exact div_nonneg hnn hh.le |
| 77 | + |
| 78 | +private lemma list_posSemidef {ι : Type*} (s : Finset ι) (c x : ι → ℝ) (forward : Bool) : |
| 79 | + ∀ L : List (ℕ × ℚ × ℚ), (∀ w ∈ L, 0 < w.1 ∧ 0 ≤ w.2.1 ∧ 0 ≤ w.2.2) → |
| 80 | + 0 ≤ ∑ i ∈ s, ∑ j ∈ s, c i * c j * |
| 81 | + (L.map fun (d, p, n) => |
| 82 | + ((if forward then p else n : ℚ) : ℝ) * max (1 - 28 * |x i - x j| / d) 0).sum |
| 83 | + | [], _ => by simp |
| 84 | + | (d, p, n) :: L, hL => by |
| 85 | + have ih := list_posSemidef s c x forward L fun w hw => hL w (List.mem_cons_of_mem _ hw) |
| 86 | + obtain ⟨hd, hp, hn⟩ := hL (d, p, n) List.mem_cons_self |
| 87 | + have hd' : (0 : ℝ) < d := by exact_mod_cast hd |
| 88 | + have hq : (0 : ℝ) ≤ ((if forward then p else n : ℚ) : ℝ) := by |
| 89 | + cases forward <;> simpa using by assumption |
| 90 | + have hT := tent_posSemidef s c x (h := (d : ℝ) / 28) (by positivity) |
| 91 | + simp only [List.map_cons, List.sum_cons, mul_add, sum_add_distrib] |
| 92 | + refine add_nonneg ?_ ih |
| 93 | + have hrw : ∑ i ∈ s, ∑ j ∈ s, c i * c j * |
| 94 | + (((if forward then p else n : ℚ) : ℝ) * max (1 - 28 * |x i - x j| / d) 0) = |
| 95 | + ((if forward then p else n : ℚ) : ℝ) * |
| 96 | + ∑ i ∈ s, ∑ j ∈ s, c i * c j * max (1 - |x i - x j| / ((d : ℝ) / 28)) 0 := by |
| 97 | + rw [mul_sum] |
| 98 | + refine sum_congr rfl fun i _ => ?_ |
| 99 | + rw [mul_sum] |
| 100 | + refine sum_congr rfl fun j _ => ?_ |
| 101 | + have : 28 * |x i - x j| / d = |x i - x j| / ((d : ℝ) / 28) := by field_simp |
| 102 | + rw [this] |
| 103 | + ring |
| 104 | + rw [hrw] |
| 105 | + exact mul_nonneg hq hT |
| 106 | + |
| 107 | +private lemma windows_nonneg : ∀ w ∈ windows, 0 < w.1 ∧ 0 ≤ w.2.1 ∧ 0 ≤ w.2.2 := by |
| 108 | + intro w hw |
| 109 | + simp only [windows, List.mem_cons, List.not_mem_nil, or_false] at hw |
| 110 | + rcases hw with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> norm_num |
| 111 | + |
| 112 | +/-- The kernel of the 1/135 row is positive semidefinite on the real line. -/ |
| 113 | +theorem W_posSemidef {ι : Type*} (s : Finset ι) (c x : ι → ℝ) : |
| 114 | + 0 ≤ ∑ i ∈ s, ∑ j ∈ s, c i * c j * W (x i - x j) := by |
| 115 | + have ht := list_posSemidef s c x true windows windows_nonneg |
| 116 | + have hf := list_posSemidef s c x false windows windows_nonneg |
| 117 | + have : ∑ i ∈ s, ∑ j ∈ s, c i * c j * W (x i - x j) = |
| 118 | + ∑ i ∈ s, ∑ j ∈ s, c i * c j * weight true (x i - x j) + |
| 119 | + ∑ i ∈ s, ∑ j ∈ s, c i * c j * weight false (x i - x j) := by |
| 120 | + simp only [W, mul_add, sum_add_distrib] |
| 121 | + rw [this] |
| 122 | + exact add_nonneg ht hf |
| 123 | + |
| 124 | +theorem W_sub_comm (u v : ℝ) : W (u - v) = W (v - u) := by |
| 125 | + unfold W weight |
| 126 | + rw [abs_sub_comm] |
| 127 | + |
| 128 | +theorem W_cast (q : ℚ) : ((W q : ℚ) : ℝ) = W (q : ℝ) := by |
| 129 | + simp only [W, weight, windows, List.map_cons, List.map_nil, List.sum_cons, List.sum_nil] |
| 130 | + push_cast |
| 131 | + rfl |
| 132 | + |
| 133 | +/-- 4. Tent duality: twice the pairing of the seed with a signed grid measure, |
| 134 | +minus the grid energy, is at most the energy of the seed. -/ |
| 135 | +theorem tent_dual (S : Finset ℕ) (y : ℕ → ℝ) {b : ℝ} (hb : 0 < b) (a : Node → ℤ) : |
| 136 | + 2 * (∑ k ∈ S, potential a (y k)) / b - (gridEnergy a : ℝ) ≤ |
| 137 | + seedEnergy S y b := by |
| 138 | + have hpsd := W_posSemidef (S.disjSum (univ : Finset Node)) |
| 139 | + (Sum.elim (fun _ => 1 / b) fun k => -(charge a k : ℝ)) |
| 140 | + (Sum.elim y fun k => (node k : ℝ)) |
| 141 | + simp only [sum_disjSum, Sum.elim_inl, Sum.elim_inr, sum_add_distrib] at hpsd |
| 142 | + have hA : ∑ i ∈ S, ∑ k ∈ S, 1 / b * (1 / b) * W (y i - y k) = seedEnergy S y b := by |
| 143 | + rw [seedEnergy, sum_div] |
| 144 | + refine sum_congr rfl fun i _ => ?_ |
| 145 | + rw [sum_div] |
| 146 | + refine sum_congr rfl fun k _ => ?_ |
| 147 | + field_simp |
| 148 | + have hB : ∑ i ∈ S, ∑ k : Node, 1 / b * -(charge a k : ℝ) * W (y i - (node k : ℝ)) = |
| 149 | + -((∑ k ∈ S, potential a (y k)) / b) := by |
| 150 | + rw [sum_div, ← sum_neg_distrib] |
| 151 | + refine sum_congr rfl fun i _ => ?_ |
| 152 | + rw [potential, sum_div, ← sum_neg_distrib] |
| 153 | + refine sum_congr rfl fun k _ => ?_ |
| 154 | + ring |
| 155 | + have hC : ∑ j : Node, ∑ k ∈ S, -(charge a j : ℝ) * (1 / b) * W ((node j : ℝ) - y k) = |
| 156 | + -((∑ k ∈ S, potential a (y k)) / b) := by |
| 157 | + rw [sum_comm, ← hB] |
| 158 | + refine sum_congr rfl fun i _ => sum_congr rfl fun k _ => ?_ |
| 159 | + rw [W_sub_comm] |
| 160 | + ring |
| 161 | + have hD : ∑ j : Node, ∑ k : Node, |
| 162 | + -(charge a j : ℝ) * -(charge a k : ℝ) * W ((node j : ℝ) - (node k : ℝ)) = |
| 163 | + (gridEnergy a : ℝ) := by |
| 164 | + simp only [gridEnergy, gridPotential, Rat.cast_sum, Rat.cast_mul, W_cast, Rat.cast_sub, |
| 165 | + mul_sum] |
| 166 | + refine sum_congr rfl fun j _ => sum_congr rfl fun k _ => ?_ |
| 167 | + ring |
| 168 | + rw [hA, hB, hC, hD] at hpsd |
| 169 | + rw [mul_div_assoc] |
| 170 | + linarith |
| 171 | + |
| 172 | +end |
| 173 | + |
| 174 | +end ErdosSwarm.Erdos530Gap428 |