| | @@ -0,0 +1,154 @@ |
| 1 | +import ErdosSwarm.Erdos530Gap.WindowCells |
| 2 | +import ErdosSwarm.Erdos530Gap.WindowIntegrals |
| 3 | + |
| 4 | +/-! |
| 5 | +# The five-window row has a positive margin |
| 6 | + |
| 7 | +This proves the rational certificate in the appendix of |
| 8 | +`experiments/erdos530/paper/gap.tex`. The one-sided profiles and the endpoint ramps |
| 9 | +give bounds on the first and second moments that hold throughout each position cell. |
| 10 | +The cross term with the left ramp is retained up to distance 50. This is the numerical |
| 11 | +step of the covering argument that refines Phal and Gemini's Lemma 4.4. |
| 12 | +-/ |
| 13 | + |
| 14 | +namespace ErdosSwarm.Erdos530Gap |
| 15 | + |
| 16 | +open MeasureTheory Set WindowQuadrature |
| 17 | + |
| 18 | +private lemma integral_prefix {f : ℝ → ℝ} (hf : Continuous f) (h₀ : ∀ x, 0 ≤ f x) |
| 19 | + {a b : ℝ} (ha : 0 ≤ a) (hab : a ≤ b) : |
| 20 | + (∫ x in (0 : ℝ)..a, f x) ≤ ∫ x in (0 : ℝ)..b, f x := |
| 21 | + intervalIntegral.integral_mono_interval le_rfl ha hab (Filter.Eventually.of_forall h₀) |
| 22 | + (hf.intervalIntegrable _ _) |
| 23 | + |
| 24 | +private lemma integral_prefix_mono {f g : ℝ → ℝ} (hf : Continuous f) (hg : Continuous g) |
| 25 | + (hg₀ : ∀ x, 0 ≤ g x) {a b : ℝ} (ha : 0 ≤ a) (hab : a ≤ b) (h : ∀ x, f x ≤ g x) : |
| 26 | + (∫ x in (0 : ℝ)..a, f x) ≤ ∫ x in (0 : ℝ)..b, g x := |
| 27 | + (intervalIntegral.integral_mono ha (hf.intervalIntegrable _ _) (hg.intervalIntegrable _ _) h).trans |
| 28 | + (integral_prefix hg hg₀ ha hab) |
| 29 | + |
| 30 | +private lemma moment {n t : ℝ} (ht : 0 ≤ t) (hn : 50 ≤ n - t) |
| 31 | + (g : ℝ → ℝ) (hg : Continuous g) (hz : g 0 = 0) : |
| 32 | + (∫ u in (0 : ℝ)..n, g (kernel t u)) = |
| 33 | + (∫ v in (0 : ℝ)..50, g (Row.forward v)) + |
| 34 | + ∫ v in (0 : ℝ)..min t 50, g (Row.backward v) := by |
| 35 | + rw [split_kernel (fun _ w => g w) (hg.comp continuous_snd) ht (by linarith)] |
| 36 | + rw [truncate_integral (f := fun x => g (Row.forward x)) (hg.comp continuous_forward) (fun x hx => by simp [forward_zero hx, hz]), |
| 37 | + min_eq_right hn, truncate_integral (f := fun x => g (Row.backward x)) (hg.comp continuous_backward) |
| 38 | + (fun x hx => by simp [backward_zero hx, hz]) t] |
| 39 | + |
| 40 | +private lemma cross_nonneg {n : ℝ} (hn : 0 ≤ n) (t : ℝ) : |
| 41 | + 0 ≤ ∫ u in (0 : ℝ)..n, kernel t u * boundary n u := |
| 42 | + intervalIntegral.integral_nonneg_of_forall hn fun u => |
| 43 | + mul_nonneg (kernel_nonneg t u) (boundary_nonneg n u) |
| 44 | + |
| 45 | +/-- Move each displacement to the rightmost allowed position of the cell in the left |
| 46 | +ramp. The monotone ramp there gives a lower bound for both signs of displacement. -/ |
| 47 | +private lemma cross_bound {n t a b : ℝ} (ht : 0 ≤ t) (hn : 50 ≤ n - t) |
| 48 | + (ha : 0 ≤ a) (hat : a ≤ t) (htb : t ≤ b) : |
| 49 | + overlap a b ≤ ∫ u in (0 : ℝ)..n, kernel t u * boundary n u := by |
| 50 | + rw [split_kernel (fun u w => w * boundary n u) (by unfold Function.uncurry; fun_prop) |
| 51 | + ht (by linarith)] |
| 52 | + apply add_le_add |
| 53 | + · refine integral_prefix_mono (by fun_prop) (by fun_prop) ?_ (by norm_num) hn ?_ |
| 54 | + · exact fun x => mul_nonneg (forward_nonneg x) (boundary_nonneg _ _) |
| 55 | + · intro v |
| 56 | + exact mul_le_mul_of_nonneg_left ((ramp_antitone (add_le_add htb (le_rfl (a := v)))).trans |
| 57 | + (le_add_of_nonneg_right (ramp_nonneg _))) (forward_nonneg v) |
| 58 | + · refine integral_prefix_mono (by fun_prop) (by fun_prop) ?_ ha hat ?_ |
| 59 | + · exact fun x => mul_nonneg (backward_nonneg x) (boundary_nonneg _ _) |
| 60 | + · intro v |
| 61 | + exact mul_le_mul_of_nonneg_left ((ramp_antitone (sub_le_sub_right htb v)).trans |
| 62 | + (le_add_of_nonneg_right (ramp_nonneg _))) (backward_nonneg v) |
| 63 | + |
| 64 | +private lemma variance_eq {τ κ z : ℝ} (hτ : 0 < τ) : |
| 65 | + let t := z / τ |
| 66 | + let n := 1 / τ |
| 67 | + Row.varianceBound τ κ z = |
| 68 | + (∫ u in (0 : ℝ)..n, kernel t u ^ 2) + |
| 69 | + (κ / 48) ^ 2 * (∫ u in (0 : ℝ)..n, boundary n u ^ 2) - |
| 70 | + (2 * κ / 48) * ∫ u in (0 : ℝ)..n, kernel t u * boundary n u := by |
| 71 | + dsimp only |
| 72 | + let t := z / τ |
| 73 | + let n := 1 / τ |
| 74 | + have hn : Row.varianceBound τ κ z = ∫ u in (0 : ℝ)..n, (kernel t u - κ * boundary n u / 48) ^ 2 := by |
| 75 | + simpa only [Row.varianceBound, n, t, boundary, sub_div] using |
| 76 | + rescale (fun u w => (w - κ * boundary n u / 48) ^ 2) hτ z |
| 77 | + have hp (u : ℝ) : (kernel t u - κ * boundary n u / 48) ^ 2 = |
| 78 | + kernel t u ^ 2 + (κ / 48) ^ 2 * boundary n u ^ 2 - (2 * κ / 48) * (kernel t u * boundary n u) := by ring |
| 79 | + have hk := integrable_kernel (fun _ w => w ^ 2) (by unfold Function.uncurry; fun_prop) t 0 n |
| 80 | + have hc := integrable_kernel (fun u w => w * boundary n u) |
| 81 | + (by unfold Function.uncurry; fun_prop) t 0 n |
| 82 | + have hb : IntervalIntegrable (fun u => boundary n u ^ 2) volume 0 n := |
| 83 | + ((continuous_boundary n).pow 2).intervalIntegrable 0 n |
| 84 | + rw [hn] |
| 85 | + simp_rw [hp] |
| 86 | + rw [intervalIntegral.integral_sub (hk.add (hb.const_mul _)) (hc.const_mul _), |
| 87 | + intervalIntegral.integral_add hk (hb.const_mul _), |
| 88 | + intervalIntegral.integral_const_mul, intervalIntegral.integral_const_mul] |
| 89 | + |
| 90 | +private lemma variance_le {τ κ z a b : ℝ} {near : Bool} (hτ : 0 < τ) |
| 91 | + (hκ : 99 / 100 ≤ κ) (hκ' : κ ≤ 1) (hn : 100 ≤ 1 / τ) (ht : 0 ≤ z / τ) |
| 92 | + (hspan : 50 ≤ 1 / τ - z / τ) (ha : 0 ≤ a) (hat : a ≤ min (z / τ) 50) |
| 93 | + (htb : min (z / τ) 50 ≤ b) (hnear : near = true → z / τ ≤ b) : |
| 94 | + Row.varianceBound τ κ z ≤ squares b - 2 * (99 / 100) / 48 * (if near then overlap a b else 0) := by |
| 95 | + let t := z / τ |
| 96 | + let n := 1 / τ |
| 97 | + have h₁ := moment ht hspan (fun x => x ^ 2) (by fun_prop) (by norm_num) |
| 98 | + have h₂ := integral_prefix (continuous_backward.pow 2) (fun _ => sq_nonneg _) |
| 99 | + (le_min ht (by norm_num)) htb |
| 100 | + have hleft : (∫ u in (0 : ℝ)..n, kernel t u ^ 2) ≤ |
| 101 | + (∫ v in (0 : ℝ)..50, Row.forward v ^ 2) + ∫ v in (0 : ℝ)..b, Row.backward v ^ 2 := by |
| 102 | + rw [h₁]; exact add_le_add le_rfl h₂ |
| 103 | + have hP : 0 ≤ ∫ u in (0 : ℝ)..50, Row.ramp u ^ 2 := |
| 104 | + intervalIntegral.integral_nonneg_of_forall (by norm_num) fun _ => sq_nonneg _ |
| 105 | + have hright : (κ / 48) ^ 2 * (∫ u in (0 : ℝ)..n, boundary n u ^ 2) ≤ |
| 106 | + 2 / 48 ^ 2 * ∫ u in (0 : ℝ)..50, Row.ramp u ^ 2 := by |
| 107 | + rw [boundary_square hn, ← mul_assoc] |
| 108 | + apply mul_le_mul_of_nonneg_right _ hP |
| 109 | + have h₀ : 0 ≤ κ := by linarith |
| 110 | + nlinarith only [sq_le_sq' (by linarith : -1 ≤ κ) hκ'] |
| 111 | + have hJ : (if near then overlap a b else 0) ≤ ∫ u in (0 : ℝ)..n, kernel t u * boundary n u := by |
| 112 | + cases near |
| 113 | + · exact cross_nonneg (by dsimp [n]; positivity) t |
| 114 | + · exact cross_bound ht hspan ha (hat.trans (min_le_left _ _)) (hnear rfl) |
| 115 | + have hcross : 2 * (99 / 100) / 48 * (if near then overlap a b else 0) ≤ |
| 116 | + (2 * κ / 48) * ∫ u in (0 : ℝ)..n, kernel t u * boundary n u := |
| 117 | + (mul_le_mul_of_nonneg_left hJ (by norm_num)).trans |
| 118 | + (mul_le_mul_of_nonneg_right (by linarith) (cross_nonneg (by dsimp [n]; positivity) t)) |
| 119 | + rw [variance_eq hτ] |
| 120 | + exact sub_le_sub (add_le_add hleft hright) hcross |
| 121 | + |
| 122 | +/-- The five-window lower score exceeds the covering threshold at every position |
| 123 | +on the left half, uniformly for all deficits up to one percent. -/ |
| 124 | +theorem row_margin {τ κ z : ℝ} (hτ : 0 < τ) (hτ' : τ ≤ 1 / 100) |
| 125 | + (hκ : 1 - τ ≤ κ) (hκ' : κ ≤ 1) (hz : 0 ≤ z) (hz' : z ≤ 1 / 2) : |
| 126 | + 48 + Row.peak / 10000 < Row.lowerScore τ κ z := by |
| 127 | + have hκ₀ : (99 : ℝ) / 100 ≤ κ := by linarith |
| 128 | + have ht : 0 ≤ z / τ := div_nonneg hz hτ.le |
| 129 | + have hn : (100 : ℝ) ≤ 1 / τ := (le_div_iff₀ hτ).mpr (by linarith) |
| 130 | + have hspan : (50 : ℝ) ≤ 1 / τ - z / τ := by |
| 131 | + rw [← sub_div, le_div_iff₀ hτ]; linarith |
| 132 | + obtain ⟨a, b, near, ha, _, hat, htb, hnear, hgood⟩ := exists_cell ht |
| 133 | + have ha' : (0 : ℝ) ≤ a := by exact_mod_cast ha |
| 134 | + have hb' : 0 ≤ b := by exact_mod_cast (ha'.trans (hat.trans htb)) |
| 135 | + obtain ⟨hA, hV⟩ := cell_inequalities ha hb' hgood |
| 136 | + have hbound := variance_le hτ hκ₀ hκ' hn ht hspan ha' hat htb hnear |
| 137 | + have hm := moment ht hspan id continuous_id rfl |
| 138 | + have hI : mass a ≤ Row.integralKernel τ z := by |
| 139 | + rw [Row.integralKernel, rescale (fun _ w => w) hτ z] |
| 140 | + simp only [id_eq] at hm |
| 141 | + rw [hm, mass] |
| 142 | + exact add_le_add le_rfl (integral_prefix continuous_backward backward_nonneg ha' hat) |
| 143 | + have hI₀ : 0 ≤ mass a := add_nonneg |
| 144 | + (intervalIntegral.integral_nonneg_of_forall (by norm_num) forward_nonneg) |
| 145 | + (intervalIntegral.integral_nonneg_of_forall ha' backward_nonneg) |
| 146 | + have hmass : 99 / 100 * mass a ≤ κ * Row.integralKernel τ z := |
| 147 | + mul_le_mul hκ₀ hI hI₀ (by linarith) |
| 148 | + have hs : Real.sqrt (2001 / 1000 * Row.varianceBound τ κ z) < 99 / 100 * mass a - (cost : ℝ) := |
| 149 | + (Real.sqrt_lt' hA).mpr ((mul_le_mul_of_nonneg_left hbound (by norm_num)).trans_lt |
| 150 | + (lt_of_lt_of_le (lt_add_of_pos_right _ (by norm_num : (0 : ℝ) < 1165 / 1000)) hV)) |
| 151 | + unfold Row.lowerScore |
| 152 | + linarith only [hmass, hs, cost_eq] |
| 153 | + |
| 154 | +end ErdosSwarm.Erdos530Gap |