| | @@ -0,0 +1,69 @@ |
| 1 | +import Mathlib.Algebra.BigOperators.Ring.Finset |
| 2 | +import Mathlib.Algebra.Order.BigOperators.Group.Finset |
| 3 | +import Mathlib.Data.Finset.Max |
| 4 | +import Mathlib.Tactic.Linarith |
| 5 | +import Mathlib.Tactic.Ring |
| 6 | + |
| 7 | +/-! |
| 8 | +# Pairs of rows for Erdős problem 530 |
| 9 | + |
| 10 | +The last step of the proof of (3) in Theorem 2 of |
| 11 | +`experiments/erdos530/lower-middle-energy/NOTES.md`, §2, reads |
| 12 | +"Now `Σ_{x<y} min(n_x, n_y) ≤ (k − 1)N/2`, proving (3)", where the `k` rows `x` have sizes |
| 13 | +`n_x` and `N = Σ_x n_x`. That pair count is Lean-checked here, cleared of the division: |
| 14 | +`two_mul_sum_min_le`. |
| 15 | + |
| 16 | +Status. Only this count over pairs of rows is Lean-checked in this file. The estimates |
| 17 | +(2)–(4) of Theorem 2 (the random dilation, the collision count and the choice of the prime) |
| 18 | +remain paper proofs. |
| 19 | +-/ |
| 20 | + |
| 21 | +namespace ErdosSwarm.Erdos530RowPairs |
| 22 | + |
| 23 | +/-- **Pairs of rows.** For row sizes `n x`, `x ∈ s`, twice the sum of `min (n x) (n y)` over |
| 24 | +the pairs `x < y` of rows is at most `(k − 1) · N`, where `k = s.card` and `N = Σ_x n x`. |
| 25 | +(`s.card - 1` is truncated; both sides are `0` for empty `s`.) |
| 26 | + |
| 27 | +Proof: `2 · min a b ≤ a + b`, and each row lies in `k − 1` pairs. The induction adds a largest |
| 28 | +row `a`: the new pairs are `(x, a)` for `x ∈ s`, and |
| 29 | +`2 · Σ_{x ∈ s} min (n x) (n a) ≤ Σ_{x ∈ s} n x + |s| · n a`. |
| 30 | + |
| 31 | +This is the last step of (3) in Theorem 2 of `experiments/erdos530/lower-middle-energy/NOTES.md`; |
| 32 | +the estimates (2)–(4) themselves remain paper proofs. -/ |
| 33 | +theorem two_mul_sum_min_le {ι : Type*} [LinearOrder ι] (s : Finset ι) (n : ι → ℕ) : |
| 34 | + 2 * ∑ x ∈ s, ∑ y ∈ s.filter (fun y => x < y), min (n x) (n y) ≤ |
| 35 | + (s.card - 1) * ∑ x ∈ s, n x := by |
| 36 | + induction s using Finset.induction_on_max with |
| 37 | + | empty => simp |
| 38 | + | insert a s ha ih => |
| 39 | + have has : a ∉ s := fun h => lt_irrefl a (ha a h) |
| 40 | + -- no row of `insert a s` lies above `a` |
| 41 | + have htop : (insert a s).filter (fun y => a < y) = ∅ := by |
| 42 | + refine Finset.filter_eq_empty_iff.mpr fun y hy => ?_ |
| 43 | + rcases Finset.mem_insert.mp hy with rfl | hy |
| 44 | + · exact lt_irrefl _ |
| 45 | + · exact lt_asymm (ha y hy) |
| 46 | + -- an old row `x` gains exactly the pair `(x, a)` |
| 47 | + have hrow : ∀ x ∈ s, ∑ y ∈ (insert a s).filter (fun y => x < y), min (n x) (n y) = |
| 48 | + min (n x) (n a) + ∑ y ∈ s.filter (fun y => x < y), min (n x) (n y) := by |
| 49 | + intro x hx |
| 50 | + rw [Finset.filter_insert, if_pos (ha x hx), Finset.sum_insert] |
| 51 | + exact fun h => has (Finset.mem_of_mem_filter a h) |
| 52 | + have hmin : 2 * ∑ x ∈ s, min (n x) (n a) ≤ ∑ x ∈ s, n x + s.card * n a := by |
| 53 | + calc 2 * ∑ x ∈ s, min (n x) (n a) = ∑ x ∈ s, 2 * min (n x) (n a) := Finset.mul_sum _ _ _ |
| 54 | + _ ≤ ∑ x ∈ s, (n x + n a) := Finset.sum_le_sum fun x _ => by omega |
| 55 | + _ = ∑ x ∈ s, n x + s.card * n a := by |
| 56 | + rw [Finset.sum_add_distrib, Finset.sum_const, nsmul_eq_mul, Nat.cast_id] |
| 57 | + rw [Finset.sum_insert has, htop, Finset.sum_empty, zero_add, Finset.sum_congr rfl hrow, |
| 58 | + Finset.sum_add_distrib, Finset.card_insert_of_notMem has, Finset.sum_insert has, |
| 59 | + Nat.add_sub_cancel] |
| 60 | + rcases Nat.eq_zero_or_pos s.card with h0 | hpos |
| 61 | + · rw [Finset.card_eq_zero] at h0 |
| 62 | + subst h0 |
| 63 | + simp |
| 64 | + · obtain ⟨c, hc⟩ := Nat.exists_eq_succ_of_ne_zero hpos.ne' |
| 65 | + rw [hc] at hmin ⊢ |
| 66 | + rw [hc, Nat.succ_sub_one] at ih |
| 67 | + nlinarith [ih, hmin] |
| 68 | + |
| 69 | +end ErdosSwarm.Erdos530RowPairs |