| | @@ -0,0 +1,131 @@ |
| 1 | +import FormalConjectures.ErdosProblems.«20» |
| 2 | + |
| 3 | +/-! |
| 4 | +# The Erdős–Rado sunflower lemma |
| 5 | + |
| 6 | +`exists_sunflower_of_pow_mul_factorial_lt` is the classical bound of Erdős and Rado: a family of |
| 7 | +more than `k ^ n * n!` sets of size `n` contains `k + 1` members whose pairwise intersections |
| 8 | +are all equal. The proof is the textbook induction on `n` through a largest pairwise disjoint |
| 9 | +subfamily. It is the finite input for the solved Formal Conjectures variant |
| 10 | +`Erdos20.erdos_20.variants.erdos_rado_bound`, and its conclusion has the shape of the hypothesis of |
| 11 | +`ErdosSwarm.Erdos20.erdos_20_of_finite_bound`. It is not the open problem #20, which asks for a |
| 12 | +bound `c_k ^ n`. |
| 13 | +-/ |
| 14 | + |
| 15 | +namespace ErdosSwarm.Erdos20 |
| 16 | + |
| 17 | +open Finset |
| 18 | + |
| 19 | +/-- **Erdős–Rado.** A family of more than `k ^ n * n!` sets of size `n` contains `k + 1` members |
| 20 | +with a common pairwise intersection `K`. -/ |
| 21 | +theorem exists_sunflower_of_pow_mul_factorial_lt {α : Type*} [DecidableEq α] (k n : ℕ) |
| 22 | + (F : Finset (Finset α)) (hF : ∀ A ∈ F, A.card = n) |
| 23 | + (hcard : k ^ n * n.factorial < F.card) : |
| 24 | + ∃ G ⊆ F, G.card = k + 1 ∧ ∃ K : Finset α, ∀ A ∈ G, ∀ B ∈ G, A ≠ B → A ∩ B = K := by |
| 25 | + induction n generalizing F with |
| 26 | + | zero => |
| 27 | + exfalso |
| 28 | + have hsub : F ⊆ {∅} := by |
| 29 | + intro A hA |
| 30 | + rw [mem_singleton, ← card_eq_zero] |
| 31 | + exact hF A hA |
| 32 | + have hle := card_le_card hsub |
| 33 | + simp only [pow_zero, Nat.factorial_zero, mul_one, card_singleton] at hcard hle |
| 34 | + omega |
| 35 | + | succ n ih => |
| 36 | + classical |
| 37 | + -- A largest pairwise disjoint subfamily `D`. |
| 38 | + obtain ⟨D, hD, hmax⟩ := exists_max_image |
| 39 | + (F.powerset.filter fun D : Finset (Finset α) => (D : Set (Finset α)).PairwiseDisjoint id) card |
| 40 | + ⟨∅, by simp⟩ |
| 41 | + rw [mem_filter, mem_powerset] at hD |
| 42 | + obtain ⟨hDF, hDdisj⟩ := hD |
| 43 | + by_cases hk : k + 1 ≤ D.card |
| 44 | + · -- `k + 1` disjoint members form a sunflower with empty kernel. |
| 45 | + obtain ⟨G, hGD, hG⟩ := exists_subset_card_eq hk |
| 46 | + refine ⟨G, hGD.trans hDF, hG, ∅, fun A hA B hB hne => ?_⟩ |
| 47 | + exact disjoint_iff_inter_eq_empty.mp (hDdisj (hGD hA) (hGD hB) hne) |
| 48 | + · push Not at hk |
| 49 | + -- The union `U` of `D` is small and meets every member of `F`. |
| 50 | + have hUcard : (D.biUnion id).card ≤ k * (n + 1) := |
| 51 | + calc (D.biUnion id).card ≤ ∑ A ∈ D, (id A).card := card_biUnion_le |
| 52 | + _ = ∑ A ∈ D, (n + 1) := sum_congr rfl fun A hA => hF A (hDF hA) |
| 53 | + _ = D.card * (n + 1) := by simp |
| 54 | + _ ≤ k * (n + 1) := Nat.mul_le_mul_right _ (by omega) |
| 55 | + have hmeet : ∀ A ∈ F, ∃ x ∈ D.biUnion id, x ∈ A := by |
| 56 | + intro A hA |
| 57 | + by_cases hAD : A ∈ D |
| 58 | + · have hne : A.Nonempty := by |
| 59 | + rw [← card_pos, hF A hA] |
| 60 | + omega |
| 61 | + obtain ⟨x, hx⟩ := hne |
| 62 | + exact ⟨x, mem_biUnion.mpr ⟨A, hAD, hx⟩, hx⟩ |
| 63 | + · by_contra hcon |
| 64 | + push Not at hcon |
| 65 | + have hins : insert A D ∈ |
| 66 | + F.powerset.filter fun D : Finset (Finset α) => (D : Set (Finset α)).PairwiseDisjoint id := by |
| 67 | + rw [mem_filter, mem_powerset] |
| 68 | + refine ⟨insert_subset hA hDF, ?_⟩ |
| 69 | + rw [coe_insert] |
| 70 | + refine hDdisj.insert fun B hB _ => ?_ |
| 71 | + refine disjoint_left.mpr fun x hxA hxB => ?_ |
| 72 | + exact hcon x (mem_biUnion.mpr ⟨B, hB, hxB⟩) hxA |
| 73 | + have hle := hmax _ hins |
| 74 | + rw [card_insert_of_notMem hAD] at hle |
| 75 | + omega |
| 76 | + -- Some point of `U` lies in many members of `F`. |
| 77 | + have hx : ∃ x, k ^ n * n.factorial < (F.filter fun A => x ∈ A).card := by |
| 78 | + by_contra hcon |
| 79 | + push Not at hcon |
| 80 | + have hcover : F ⊆ (D.biUnion id).biUnion fun x => F.filter fun A => x ∈ A := by |
| 81 | + intro A hA |
| 82 | + obtain ⟨x, hxU, hxA⟩ := hmeet A hA |
| 83 | + exact mem_biUnion.mpr ⟨x, hxU, mem_filter.mpr ⟨hA, hxA⟩⟩ |
| 84 | + have hle : F.card ≤ k ^ (n + 1) * (n + 1).factorial := |
| 85 | + calc F.card ≤ ((D.biUnion id).biUnion fun x => F.filter fun A => x ∈ A).card := |
| 86 | + card_le_card hcover |
| 87 | + _ ≤ ∑ x ∈ D.biUnion id, (F.filter fun A => x ∈ A).card := card_biUnion_le |
| 88 | + _ ≤ ∑ _x ∈ D.biUnion id, k ^ n * n.factorial := sum_le_sum fun x _ => hcon x |
| 89 | + _ = (D.biUnion id).card * (k ^ n * n.factorial) := by simp |
| 90 | + _ ≤ k * (n + 1) * (k ^ n * n.factorial) := Nat.mul_le_mul_right _ hUcard |
| 91 | + _ = k ^ (n + 1) * (n + 1).factorial := by |
| 92 | + rw [Nat.factorial_succ, pow_succ] |
| 93 | + ring |
| 94 | + omega |
| 95 | + obtain ⟨x, hx⟩ := hx |
| 96 | + -- Erase `x` from the members containing it and apply the induction hypothesis. |
| 97 | + have hmemx : ∀ A ∈ F.filter fun A => x ∈ A, x ∈ A := fun A hA => (mem_filter.mp hA).2 |
| 98 | + have hinj : Set.InjOn (fun A : Finset α => A.erase x) |
| 99 | + ((F.filter fun A => x ∈ A : Finset (Finset α)) : Set (Finset α)) := by |
| 100 | + intro A hA B hB hAB |
| 101 | + have hAB' : A.erase x = B.erase x := hAB |
| 102 | + rw [← insert_erase (hmemx A hA), ← insert_erase (hmemx B hB), hAB'] |
| 103 | + obtain ⟨G', hG'sub, hG'card, K', hK'⟩ := |
| 104 | + ih ((F.filter fun A => x ∈ A).image fun A => A.erase x) |
| 105 | + (by |
| 106 | + intro B hB |
| 107 | + obtain ⟨A, hA, rfl⟩ := mem_image.mp hB |
| 108 | + rw [card_erase_of_mem (hmemx A hA), hF A (mem_filter.mp hA).1] |
| 109 | + rfl) |
| 110 | + (by rwa [card_image_of_injOn hinj]) |
| 111 | + have hG'x : ∀ B ∈ G', x ∉ B := by |
| 112 | + intro B hB |
| 113 | + obtain ⟨A, -, rfl⟩ := mem_image.mp (hG'sub hB) |
| 114 | + exact notMem_erase x A |
| 115 | + have hinj' : Set.InjOn (insert x) (G' : Set (Finset α)) := by |
| 116 | + intro A hA B hB hAB |
| 117 | + rw [← erase_insert (hG'x A hA), ← erase_insert (hG'x B hB), hAB] |
| 118 | + -- Put `x` back into the petals and the kernel. |
| 119 | + refine ⟨G'.image (insert x), ?_, ?_, insert x K', ?_⟩ |
| 120 | + · intro B hB |
| 121 | + obtain ⟨B', hB', rfl⟩ := mem_image.mp hB |
| 122 | + obtain ⟨A, hA, rfl⟩ := mem_image.mp (hG'sub hB') |
| 123 | + rw [insert_erase (hmemx A hA)] |
| 124 | + exact (mem_filter.mp hA).1 |
| 125 | + · rw [card_image_of_injOn hinj', hG'card] |
| 126 | + · intro A hA B hB hne |
| 127 | + obtain ⟨A', hA', rfl⟩ := mem_image.mp hA |
| 128 | + obtain ⟨B', hB', rfl⟩ := mem_image.mp hB |
| 129 | + rw [← insert_inter_distrib, hK' A' hA' B' hB' fun h => hne (by rw [h])] |
| 130 | + |
| 131 | +end ErdosSwarm.Erdos20 |