| | @@ -0,0 +1,57 @@ |
| 1 | +import Mathlib.Data.Nat.Choose.Basic |
| 2 | +import Mathlib.Tactic.Linarith |
| 3 | + |
| 4 | +/-! |
| 5 | +# Window occupancy in the full-rows argument for Erdős problem 530 |
| 6 | + |
| 7 | +These lemmas formalize the finite arithmetic in “Counting the surplus” in |
| 8 | +`experiments/erdos530/lower-middle-energy2/full-rows/NOTES.md`. |
| 9 | +Theorems 1 and 2 of that note remain paper proofs. The occupancy identity also appears in the |
| 10 | +proof of “Progression-sensitive compression” in the October 2026 sidon-palomar report. |
| 11 | +-/ |
| 12 | + |
| 13 | +namespace ErdosSwarm.Erdos530Occupancy |
| 14 | + |
| 15 | +/-- The surplus of a window with `v` hits is `C(v - 1, 2)`, including zero for an empty window. -/ |
| 16 | +def surplus (v : ℕ) : ℕ := (v - 1).choose 2 |
| 17 | + |
| 18 | +/-- Subtracting pairs from hits and adding the surplus counts an occupied window exactly once. -/ |
| 19 | +theorem occupancy_identity (v : ℕ) : |
| 20 | + (if 0 < v then 1 else 0 : ℤ) = v - v.choose 2 + surplus v := by |
| 21 | + cases v with |
| 22 | + | zero => decide |
| 23 | + | succ n => |
| 24 | + simp only [Nat.zero_lt_succ, if_true, Nat.choose_succ_succ n 1, Nat.choose_one_right, |
| 25 | + Nat.reduceSucc, surplus, Nat.succ_sub_one, Nat.cast_succ, Nat.cast_add] |
| 26 | + omega |
| 27 | + |
| 28 | +/-- Count triples of hits with one of their three members marked. -/ |
| 29 | +theorem three_mul_choose_three (s : ℕ) : 3 * s.choose 3 = s * surplus s := by |
| 30 | + cases s with |
| 31 | + | zero => rfl |
| 32 | + | succ n => |
| 33 | + rw [Nat.mul_comm 3] |
| 34 | + exact (Nat.add_one_mul_choose_eq n 2).symm |
| 35 | + |
| 36 | +/-- For `s` hits among `k` candidates, `k` times the surplus bounds the marked triples. -/ |
| 37 | +theorem three_mul_choose_three_le {s k : ℕ} (h : s ≤ k) : 3 * s.choose 3 ≤ k * surplus s := by |
| 38 | + rw [three_mul_choose_three] |
| 39 | + exact Nat.mul_le_mul_right (surplus s) h |
| 40 | + |
| 41 | +/-- The pair-count bound in inequality (6) of the note, with denominators cleared. -/ |
| 42 | +theorem pair_count_le (K : ℕ) : 2 * K * K.choose 2 ≤ 9 * K.choose 3 + K ^ 2 := by |
| 43 | + cases K with |
| 44 | + | zero => decide |
| 45 | + | succ n => |
| 46 | + have hn : n ≤ n.choose 2 + 1 := by |
| 47 | + cases n with |
| 48 | + | zero => decide |
| 49 | + | succ m => |
| 50 | + rw [Nat.choose_succ_succ m 1, Nat.choose_one_right] |
| 51 | + omega |
| 52 | + have htriple : 3 * (n + 1).choose 3 = (n + 1) * n.choose 2 := |
| 53 | + three_mul_choose_three (n + 1) |
| 54 | + rw [Nat.choose_succ_succ n 1, Nat.choose_one_right] |
| 55 | + nlinarith only [htriple, Nat.mul_le_mul_left (n + 1) hn] |
| 56 | + |
| 57 | +end ErdosSwarm.Erdos530Occupancy |