import Mathlib namespace ResearchErdos643 /-- Each union of two disjoint hyperedges determines their unordered pair. -/ def UniqueDisjointUnions {n : ℕ} (edges : Finset (Finset (Fin n))) : Prop := ∀ A ∈ edges, ∀ B ∈ edges, ∀ C ∈ edges, ∀ D ∈ edges, Disjoint A B → Disjoint C D → A ∪ B = C ∪ D → (A = C ∧ B = D) ∨ (A = D ∧ B = C) /-- A Steiner system with blocks of size five in which every pair lies in exactly one block. -/ def SteinerFive {n : ℕ} (blocks : Finset (Finset (Fin n))) : Prop := (∀ block ∈ blocks, block.card = 5) ∧ ∀ pair : Finset (Fin n), pair.card = 2 → ∃! block : Finset (Fin n), block ∈ blocks ∧ pair ⊆ block /-- The hyperedges are exactly the triples contained in the blocks. -/ def IsExpansion {n : ℕ} (edges blocks : Finset (Finset (Fin n))) : Prop := ∀ triple : Finset (Fin n), triple ∈ edges ↔ triple.card = 3 ∧ ∃ block ∈ blocks, triple ⊆ block /-- Two disjoint pairs share at most one extension to an edge. -/ theorem disjoint_pair_common_extensions_card_le_one {n : ℕ} {edges : Finset (Finset (Fin n))} (hUnique : UniqueDisjointUnions edges) {p q : Finset (Fin n)} (hp : p.Nonempty) (hpq : Disjoint p q) : ((Finset.univ.filter (fun x => x ∉ p ∧ insert x p ∈ edges)) ∩ (Finset.univ.filter (fun x => x ∉ q ∧ insert x q ∈ edges))).card ≤ 1 := by classical apply Finset.card_le_one.mpr intro a ha b hb simp only [Finset.mem_inter, Finset.mem_filter, Finset.mem_univ, true_and] at ha hb by_contra hab have hdisj {x y : Fin n} (hxy : x ≠ y) (hx : x ∉ q) (hy : y ∉ p) : Disjoint (insert x p) (insert y q) := by rw [Finset.disjoint_insert_left, Finset.disjoint_insert_right] exact ⟨by simp [hxy, hx], hy, hpq⟩ have hu : insert a p ∪ insert b q = insert b p ∪ insert a q := by ext x simp only [Finset.mem_union, Finset.mem_insert] tauto rcases hUnique _ ha.1.2 _ hb.2.2 _ hb.1.2 _ ha.2.2 (hdisj hab ha.2.1 hb.1.1) (hdisj (fun h => hab h.symm) hb.2.1 ha.1.1) hu with h | h · have hm : a ∈ insert b p := h.1 ▸ Finset.mem_insert_self a p exact ha.1.1 ((Finset.mem_insert.mp hm).resolve_left hab) · obtain ⟨x, hx⟩ := hp have hm : x ∈ insert a q := h.1 ▸ Finset.mem_insert_of_mem hx rcases Finset.mem_insert.mp hm with rfl | hq · exact ha.1.1 hx · exact Finset.disjoint_left.mp hpq hx hq /-- The common-extension condition on disjoint pairs implies uniqueness of disjoint unions. -/ theorem unique_disjoint_unions_of_disjoint_pair_extensions {n : ℕ} {edges : Finset (Finset (Fin n))} (hUniform : ∀ e ∈ edges, e.card = 3) (hExt : ∀ p q : Finset (Fin n), p.card = 2 → q.card = 2 → Disjoint p q → ((Finset.univ.filter (fun x => x ∉ p ∧ insert x p ∈ edges)) ∩ (Finset.univ.filter (fun x => x ∉ q ∧ insert x q ∈ edges))).card ≤ 1) : UniqueDisjointUnions edges := by classical have partition (X Y Z : Finset (Fin n)) (hX : X ⊆ Y ∪ Z) (hYZ : Disjoint Y Z) : (X ∩ Y).card + (X ∩ Z).card = X.card := by have heq : X ∩ Y ∪ (X ∩ Z) = X := by rw [← Finset.inter_union_distrib_left, Finset.inter_eq_left.mpr hX] calc _ = (X ∩ Y ∪ (X ∩ Z)).card := (Finset.card_union_of_disjoint (hYZ.mono Finset.inter_subset_right Finset.inter_subset_right)).symm _ = X.card := congrArg Finset.card heq have cross (A B C D : Finset (Fin n)) (hA : A ∈ edges) (hB : B ∈ edges) (hC : C ∈ edges) (hD : D ∈ edges) (hAB : Disjoint A B) (hCD : Disjoint C D) (hu : A ∪ B = C ∪ D) (hp : (A ∩ C).card = 2) : False := by let p := A ∩ C let q := B ∩ D have hACD : A ⊆ C ∪ D := hu ▸ Finset.subset_union_left have hCAB : C ⊆ A ∪ B := hu.symm ▸ Finset.subset_union_left have hBCD : B ⊆ C ∪ D := hu ▸ Finset.subset_union_right have hCABcards := partition C A B hCAB hAB have hBCDcards := partition B C D hBCD hCD rw [Finset.inter_comm C A, hp, Finset.inter_comm C B, hUniform _ hC] at hCABcards have hq : q.card = 2 := by change (B ∩ D).card = 2 have := hUniform _ hB omega obtain ⟨a, ha⟩ := Finset.card_pos.mp (show 0 < (A \ p).card by rw [Finset.card_sdiff_of_subset Finset.inter_subset_left, hUniform _ hA, hp]; decide) obtain ⟨c, hc⟩ := Finset.card_pos.mp (show 0 < (C \ p).card by rw [Finset.card_sdiff_of_subset Finset.inter_subset_right, hUniform _ hC, hp]; decide) obtain ⟨haA, hap⟩ := Finset.mem_sdiff.mp ha obtain ⟨hcC, hcp⟩ := Finset.mem_sdiff.mp hc have haC : a ∉ C := fun h => hap (Finset.mem_inter.mpr ⟨haA, h⟩) have hcA : c ∉ A := fun h => hcp (Finset.mem_inter.mpr ⟨h, hcC⟩) have haD := (Finset.mem_union.mp (hACD haA)).resolve_left haC have hcB := (Finset.mem_union.mp (hCAB hcC)).resolve_left hcA have haq : a ∉ q := fun h => Finset.disjoint_left.mp hAB haA (Finset.mem_inter.mp h).1 have hcq : c ∉ q := fun h => Finset.disjoint_left.mp hCD hcC (Finset.mem_inter.mp h).2 have build {x : Fin n} {r T : Finset (Fin n)} (hr : r.card = 2) (hT : T ∈ edges) (hxT : x ∈ T) (hrT : r ⊆ T) (hxr : x ∉ r) : insert x r ∈ edges := by rw [Finset.eq_of_subset_of_card_le (Finset.insert_subset hxT hrT) (by rw [Finset.card_insert_of_notMem hxr, hr, hUniform _ hT])] exact hT have hdpq : Disjoint p q := hAB.mono Finset.inter_subset_left Finset.inter_subset_left have hCommon := Finset.card_le_one.mp (hExt p q hp hq hdpq) have hac := hCommon a (Finset.mem_inter.mpr ⟨Finset.mem_filter.mpr ⟨Finset.mem_univ _, hap, build hp hA haA Finset.inter_subset_left hap⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, haq, build hq hD haD Finset.inter_subset_right haq⟩⟩) c (Finset.mem_inter.mpr ⟨Finset.mem_filter.mpr ⟨Finset.mem_univ _, hcp, build hp hC hcC Finset.inter_subset_right hcp⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hcq, build hq hB hcB Finset.inter_subset_left hcq⟩⟩) exact hcA (hac ▸ haA) intro A hA B hB C hC D hD hAB hCD hu have cancel (X Y Z : Finset (Fin n)) (hXY : Disjoint X Y) (hXZ : Disjoint X Z) (h : X ∪ Y = X ∪ Z) : Y = Z := by ext a constructor · intro ha have haX : a ∉ X := fun hx => Finset.disjoint_left.mp hXY hx ha exact (Finset.mem_union.mp (h ▸ Finset.mem_union_right X ha)).resolve_left haX · intro ha have haX : a ∉ X := fun hx => Finset.disjoint_left.mp hXZ hx ha exact (Finset.mem_union.mp (h.symm ▸ Finset.mem_union_right X ha)).resolve_left haX by_cases hAC : A = C · subst C exact Or.inl ⟨rfl, cancel A B D hAB hCD hu⟩ by_cases hAD : A = D · subst D exact Or.inr ⟨rfl, cancel A B C hAB hCD.symm (hu.trans (Finset.union_comm C A))⟩ have hlt (X : Finset (Fin n)) (hX : X ∈ edges) (hAX : A ≠ X) : (A ∩ X).card < 3 := by by_contra! h have heq := Finset.eq_of_subset_of_card_le (Finset.inter_subset_left : A ∩ X ⊆ A) (by rwa [hUniform _ hA]) exact hAX (Finset.eq_of_subset_of_card_le (heq ▸ Finset.inter_subset_right) (by rw [hUniform _ hA, hUniform _ hX])) have hsum := partition A C D (hu ▸ Finset.subset_union_left) hCD have h₁ := hlt C hC hAC have h₂ := hlt D hD hAD have h₃ := hUniform _ hA by_cases hp : (A ∩ C).card = 2 · exact False.elim (cross A B C D hA hB hC hD hAB hCD hu hp) · exact False.elim (cross A B D C hA hB hD hC hAB hCD.symm (hu.trans (Finset.union_comm C D)) (by omega)) /-- Distinct complete five-sets cannot share a vertex pair. -/ theorem full_five_eq_of_common_pair {n : ℕ} {edges : Finset (Finset (Fin n))} (hUnique : UniqueDisjointUnions edges) {B C p : Finset (Fin n)} (hB : B.card = 5) (hC : C.card = 5) (hp : p.card = 2) (hpB : p ⊆ B) (hpC : p ⊆ C) (hFullB : ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hFullC : ∀ t, t.card = 3 → t ⊆ C → t ∈ edges) : B = C := by classical by_contra hne have hout : ∃ x ∈ B, x ∉ C := by by_contra! hsub exact hne (Finset.eq_of_subset_of_card_le hsub (by omega)) obtain ⟨x, hxB, hxC⟩ := hout have hpXB : (insert x p).card = 3 := by rw [Finset.card_insert_of_notMem (fun h => hxC (hpC h)), hp] have hout' : ∃ y ∈ B, y ∉ insert x p := by by_contra! hsub have := Finset.card_le_card hsub omega obtain ⟨y, hyB, hyP⟩ := hout' let a : Finset (Fin n) := {x,y} have hya : y ≠ x := by intro he; exact hyP (he ▸ Finset.mem_insert_self x p) have haCard : a.card = 2 := by simp [a, hya.symm] have haB : a ⊆ B := Finset.insert_subset hxB (Finset.singleton_subset_iff.mpr hyB) have hap : Disjoint p a := by rw [Finset.disjoint_insert_right, Finset.disjoint_singleton_right] exact ⟨fun h => hxC (hpC h), fun h => hyP (Finset.mem_insert_of_mem h)⟩ have hcardC : (C \ p).card = 3 := by rw [Finset.card_sdiff_of_subset hpC, hC, hp] obtain ⟨b, hb, hbCard⟩ := Finset.exists_subset_card_eq (s := (C \ p).erase y) (by rw [Finset.card_erase_eq_ite, hcardC]; split <;> decide : 2 ≤ ((C \ p).erase y).card) have hbC : b ⊆ C := fun z hz => (Finset.mem_sdiff.mp (Finset.mem_erase.mp (hb hz)).2).1 have hbp : Disjoint p b := Finset.disjoint_left.mpr fun z hzp hzb => (Finset.mem_sdiff.mp (Finset.mem_erase.mp (hb hzb)).2).2 hzp have hab : Disjoint a b := by rw [Finset.disjoint_insert_left, Finset.disjoint_singleton_left] exact ⟨fun h => hxC (hbC h), fun h => Finset.notMem_erase y _ (hb h)⟩ have hpSub : p ⊆ (Finset.univ.filter (fun z => z ∉ a ∧ insert z a ∈ edges)) ∩ (Finset.univ.filter (fun z => z ∉ b ∧ insert z b ∈ edges)) := by intro z hz have hza : z ∉ a := fun h => Finset.disjoint_left.mp hap hz h have hzb : z ∉ b := fun h => Finset.disjoint_left.mp hbp hz h simp only [Finset.mem_inter, Finset.mem_filter, Finset.mem_univ, true_and] exact ⟨⟨hza, hFullB _ (by rw [Finset.card_insert_of_notMem hza, haCard]) (Finset.insert_subset (hpB hz) haB)⟩, hzb, hFullC _ (by rw [Finset.card_insert_of_notMem hzb, hbCard]) (Finset.insert_subset (hpC hz) hbC)⟩ have haNonempty : a.Nonempty := ⟨x, Finset.mem_insert_self _ _⟩ have := (Finset.card_le_card hpSub).trans (disjoint_pair_common_extensions_card_le_one hUnique haNonempty hab) omega /-- An extra extension of a block pair prevents another block through the extra vertex and an old tip. -/ theorem five_blocks_exclude_a_cross_pair {n : ℕ} {edges : Finset (Finset (Fin n))} (hUnique : UniqueDisjointUnions edges) {B C p : Finset (Fin n)} {x z : Fin n} (hB : B.card = 5) (hC : C.card = 5) (hp : p.card = 2) (hpB : p ⊆ B) (hFullB : ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hFullC : ∀ t, t.card = 3 → t ⊆ C → t ∈ edges) (hxB : x ∉ B) (hzB : z ∈ B) (hzp : z ∉ p) (hExtra : insert x p ∈ edges) (hxC : x ∈ C) (hzC : z ∈ C) : False := by classical have hBC : B ≠ C := fun h => hxB (h ▸ hxC) have hpC : Disjoint p C := by apply Finset.disjoint_left.mpr intro a ha hCa have hne : a ≠ z := fun h => hzp (h ▸ ha) exact hBC (full_five_eq_of_common_pair hUnique hB hC (p := {a,z}) (by simp [hne]) (Finset.insert_subset (hpB ha) (Finset.singleton_subset_iff.mpr hzB)) (Finset.insert_subset hCa (Finset.singleton_subset_iff.mpr hzC)) hFullB hFullC) let tips : Finset (Fin n) := {x,z} have hxz : x ≠ z := fun h => hxB (h ▸ hzB) have ht : tips.card = 2 := by simp [tips, hxz] have htC : tips ⊆ C := Finset.insert_subset hxC (Finset.singleton_subset_iff.mpr hzC) obtain ⟨q, hq, hqcard⟩ := Finset.exists_subset_card_eq (s := C \ tips) (by rw [Finset.card_sdiff_of_subset htC, hC, ht]; decide : 2 ≤ (C \ tips).card) have hqC : q ⊆ C := hq.trans Finset.sdiff_subset have hqTips (v : Fin n) (hv : v ∈ tips) : v ∉ q := fun h => (Finset.mem_sdiff.mp (hq h)).2 hv have hcommon : tips ⊆ (Finset.univ.filter (fun v => v ∉ p ∧ insert v p ∈ edges)) ∩ (Finset.univ.filter (fun v => v ∉ q ∧ insert v q ∈ edges)) := by intro v hv have hvC := htC hv have hvq := hqTips v hv have ⟨hvp, hvEdge⟩ : v ∉ p ∧ insert v p ∈ edges := by rcases Finset.mem_insert.mp hv with h | h · subst v exact ⟨fun h => hxB (hpB h), hExtra⟩ · have hvz := Finset.mem_singleton.mp h subst v exact ⟨hzp, hFullB _ (by rw [Finset.card_insert_of_notMem hzp, hp]) (Finset.insert_subset hzB hpB)⟩ exact Finset.mem_inter.mpr ⟨Finset.mem_filter.mpr ⟨Finset.mem_univ _, hvp, hvEdge⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hvq, hFullC _ (by rw [Finset.card_insert_of_notMem hvq, hqcard]) (Finset.insert_subset hvC hqC)⟩⟩ have hpnon : p.Nonempty := Finset.card_pos.mp (by omega) have := (Finset.card_le_card hcommon).trans (disjoint_pair_common_extensions_card_le_one hUnique hpnon (hpC.mono_right hqC)) omega /-- A complete five-set containing a pair uses all three edges through that pair. -/ theorem triple_subset_of_pair_in_full_five {n : ℕ} {edges : Finset (Finset (Fin n))} {pair block triple : Finset (Fin n)} (hp : pair.card = 2) (hb : block.card = 5) (hpb : pair ⊆ block) (hFull : ∀ t, t.card = 3 → t ⊆ block → t ∈ edges) (hDegree : (edges.filter (fun e => pair ⊆ e)).card ≤ 3) (hEdge : triple ∈ edges) (hpt : pair ⊆ triple) : triple ⊆ block := by classical let candidates := (block \ pair).image (fun x => insert x pair) have hc : candidates ⊆ edges.filter (fun e => pair ⊆ e) := by intro t ht obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp ht obtain ⟨hxB, hxP⟩ := Finset.mem_sdiff.mp hx exact Finset.mem_filter.mpr ⟨ hFull _ (by rw [Finset.card_insert_of_notMem hxP, hp]) (Finset.insert_subset hxB hpb), Finset.subset_insert _ _⟩ have hcard : candidates.card = 3 := by dsimp [candidates] rw [Finset.card_image_of_injOn, Finset.card_sdiff_of_subset hpb, hb, hp] intro x hx y hy hxy change insert x pair = insert y pair at hxy have hmem : x ∈ insert y pair := hxy ▸ Finset.mem_insert_self x pair exact (Finset.mem_insert.mp hmem).resolve_right (Finset.mem_sdiff.mp hx).2 have heq := Finset.eq_of_subset_of_card_le hc (hcard ▸ hDegree) have hmem : triple ∈ candidates := heq.symm ▸ Finset.mem_filter.mpr ⟨hEdge, hpt⟩ obtain ⟨x, hx, rfl⟩ := Finset.mem_image.mp hmem exact Finset.insert_subset (Finset.mem_sdiff.mp hx).1 hpb /-- Complete five-sets covering every pair assemble into a Steiner system at codegree at most three. -/ theorem expansion_of_full_five_cover {n : ℕ} (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hDegree : ∀ pair : Finset (Fin n), pair.card = 2 → (edges.filter (fun e => pair ⊆ e)).card ≤ 3) (hCover : ∀ pair : Finset (Fin n), pair.card = 2 → ∃ b : Finset (Fin n), b.card = 5 ∧ pair ⊆ b ∧ ∀ t, t.card = 3 → t ⊆ b → t ∈ edges) : ∃ blocks : Finset (Finset (Fin n)), SteinerFive blocks ∧ IsExpansion edges blocks := by classical let blocks := (Finset.univ.powersetCard 5 : Finset (Finset (Fin n))).filter (fun b => ∀ t, t.card = 3 → t ⊆ b → t ∈ edges) have hb (b : Finset (Fin n)) : b ∈ blocks ↔ b.card = 5 ∧ ∀ t, t.card = 3 → t ⊆ b → t ∈ edges := by simp [blocks, Finset.mem_powersetCard] have hpair (t : Finset (Fin n)) (ht : 3 ≤ t.card) : ∃ p ⊆ t, p.card = 2 := Finset.exists_subset_card_eq (by omega) refine ⟨blocks, ⟨fun b hb' => (hb b).mp hb' |>.1, ?_⟩, ?_⟩ · intro pair hp obtain ⟨b, hbcard, hpb, hbfull⟩ := hCover pair hp refine ⟨b, ⟨(hb b).mpr ⟨hbcard, hbfull⟩, hpb⟩, ?_⟩ intro c hc obtain ⟨hccard, hcfull⟩ := (hb c).mp hc.1 apply Finset.eq_of_subset_of_card_le _ (by omega : b.card ≤ c.card) intro x hx by_cases hxp : x ∈ pair · exact hpb hxp · have ht : (insert x pair).card = 3 := by rw [Finset.card_insert_of_notMem hxp, hp] have htc := hcfull _ ht (Finset.insert_subset hx hc.2) exact triple_subset_of_pair_in_full_five hp hbcard hpb hbfull (hDegree pair hp) htc (Finset.subset_insert _ _) (Finset.mem_insert_self _ _) · intro t constructor · intro ht obtain ⟨pair, hpt, hp⟩ := hpair t (by rw [hUniform t ht]) obtain ⟨b, hbcard, hpb, hbfull⟩ := hCover pair hp exact ⟨hUniform t ht, b, (hb b).mpr ⟨hbcard, hbfull⟩, triple_subset_of_pair_in_full_five hp hbcard hpb hbfull (hDegree pair hp) ht hpt⟩ · rintro ⟨ht, b, hb', htb⟩ exact ((hb b).mp hb').2 t ht htb theorem extension_card_eq_pair_filter_card {n : ℕ} (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) {a b : Fin n} (hab : a ≠ b) : (Finset.univ.filter (fun c => c ∉ ({a,b} : Finset (Fin n)) ∧ ({a,b,c} : Finset (Fin n)) ∈ edges)).card = (edges.filter (fun e => ({a,b} : Finset (Fin n)) ⊆ e)).card := by classical let p : Finset (Fin n) := {a,b} let es := Finset.univ.filter (fun c => c ∉ p ∧ insert c p ∈ edges) have ht (c : Fin n) : insert c p = ({a,b,c} : Finset (Fin n)) := by ext x simp [p, or_left_comm, or_comm] simp only [← ht] change es.card = (edges.filter (fun e => p ⊆ e)).card calc es.card = (es.image (fun c => insert c p)).card := by symm apply Finset.card_image_of_injOn intro c hc d hd hcd change insert c p = insert d p at hcd have hmem : c ∈ insert d p := by rw [← hcd] exact Finset.mem_insert_self _ _ exact (Finset.mem_insert.mp hmem).resolve_right (Finset.mem_filter.mp hc).2.1 _ = (edges.filter (fun e => p ⊆ e)).card := by congr 1 ext e constructor · rintro he obtain ⟨c, hc, rfl⟩ := Finset.mem_image.mp he exact Finset.mem_filter.mpr ⟨(Finset.mem_filter.mp hc).2.2, Finset.subset_insert _ _⟩ · intro he obtain ⟨he, hpe⟩ := Finset.mem_filter.mp he have hp : p.card = 2 := by simp [p, hab] have hout : ∃ c ∈ e, c ∉ p := by by_contra! h have hle := Finset.card_le_card h rw [hp, hUniform e he] at hle omega obtain ⟨c, hce, hcp⟩ := hout have heq : insert c p = e := Finset.eq_of_subset_of_card_le (Finset.insert_subset hce hpe) (by rw [Finset.card_insert_of_notMem hcp, hp, hUniform e he]) exact Finset.mem_image.mpr ⟨c, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hcp, heq ▸ he⟩, heq⟩ theorem pair_codegrees_eq_three {n : ℕ} (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hExtremal : edges.card = n.choose 2) (hMax : ∀ pair : Finset (Fin n), pair.card = 2 → (edges.filter (fun e => pair ⊆ e)).card ≤ 3) : ∀ pair : Finset (Fin n), pair.card = 2 → (edges.filter (fun e => pair ⊆ e)).card = 3 := by let pairs := (Finset.univ : Finset (Fin n)).powersetCard 2 have hcard : pairs.card = n.choose 2 := by simp [pairs] let codegree (p : Finset (Fin n)) := (edges.filter (fun e => p ⊆ e)).card have htotal : ∑ p ∈ pairs, codegree p = ∑ _p ∈ pairs, (3 : ℕ) := calc ∑ p ∈ pairs, codegree p = ∑ p ∈ pairs, ∑ e ∈ edges, if p ⊆ e then (1 : ℕ) else 0 := by apply Finset.sum_congr rfl intro p _ simpa [codegree] using (Finset.sum_filter (s := edges) (fun e => p ⊆ e) (fun _ => (1 : ℕ))) _ = ∑ e ∈ edges, ∑ p ∈ pairs, if p ⊆ e then (1 : ℕ) else 0 := Finset.sum_comm _ = ∑ e ∈ edges, (3 : ℕ) := by apply Finset.sum_congr rfl intro e he have hpair_filter : pairs.filter (fun p => p ⊆ e) = e.powersetCard 2 := by ext p simp only [pairs, Finset.mem_filter, Finset.mem_powersetCard, Finset.subset_univ, true_and] exact and_comm rw [← Finset.sum_filter (s := pairs) (fun p => p ⊆ e) (fun _ => (1 : ℕ))] simp [hpair_filter, hUniform e he] _ = ∑ _p ∈ pairs, (3 : ℕ) := by simp [hcard, hExtremal] intro p hp change codegree p = 3 have hle : ∀ q ∈ pairs, codegree q ≤ 3 := by intro q hq exact hMax q (Finset.mem_powersetCard.mp hq).2 have hp' : p ∈ pairs := Finset.mem_powersetCard.mpr ⟨Finset.subset_univ p, hp⟩ by_contra hne have hlt : codegree p < 3 := lt_of_le_of_ne (hle p hp') hne have : (∑ q ∈ pairs, codegree q) < ∑ _q ∈ pairs, (3 : ℕ) := Finset.sum_lt_sum hle ⟨p, hp', hlt⟩ exact (ne_of_lt this) htotal theorem card_edges_on_six_le_eleven {n : ℕ} (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hUnique : UniqueDisjointUnions edges) (s : Finset (Fin n)) (hs : s.card = 6) : (edges.filter (· ⊆ s)).card ≤ 11 := by classical let F := edges.filter (· ⊆ s) let G := F.image (fun a => s \ a) have hF {a : Finset (Fin n)} (ha : a ∈ F) : a ∈ edges ∧ a ⊆ s := Finset.mem_filter.mp ha have hinv {a : Finset (Fin n)} (ha : a ∈ F) : s \ (s \ a) = a := Finset.sdiff_sdiff_eq_self (hF ha).2 have hcardG : G.card = F.card := Finset.card_image_of_injOn (by intro a ha b hb hab change a ∈ F at ha change b ∈ F at hb have heq := congrArg (fun c => s \ c) hab simpa only [hinv ha, hinv hb] using heq) have hsub : F ∪ G ⊆ s.powersetCard 3 := by intro a ha rcases Finset.mem_union.mp ha with h | h · exact Finset.mem_powersetCard.mpr ⟨(hF h).2, hUniform a (hF h).1⟩ · obtain ⟨b, hb, rfl⟩ := Finset.mem_image.mp h exact Finset.mem_powersetCard.mpr ⟨Finset.sdiff_subset, by rw [Finset.card_sdiff_of_subset (hF hb).2, hs, hUniform b (hF hb).1]⟩ have hUb := Finset.card_le_card hsub rw [Finset.card_powersetCard, hs, show (6 : ℕ).choose 3 = 20 by decide] at hUb have hinter {a : Finset (Fin n)} (ha : a ∈ F ∩ G) : a ∈ edges ∧ s \ a ∈ edges ∧ a ⊆ s := by obtain ⟨haF, haG⟩ := Finset.mem_inter.mp ha obtain ⟨b, hb, hba⟩ := Finset.mem_image.mp haG refine ⟨(hF haF).1, ?_, (hF haF).2⟩ rw [← hba, hinv hb] exact (hF hb).1 have hdisj (a : Finset (Fin n)) : Disjoint a (s \ a) := by exact Finset.disjoint_left.mpr fun _ hx hy => (Finset.mem_sdiff.mp hy).2 hx have hIb : (F ∩ G).card ≤ 2 := by rcases (F ∩ G).eq_empty_or_nonempty with h | ⟨b, hb⟩ · simp [h] · refine (Finset.card_le_card (t := {b, s \ b}) ?_).trans Finset.card_le_two intro a ha obtain ⟨ha₁, ha₂, ha₃⟩ := hinter ha obtain ⟨hb₁, hb₂, hb₃⟩ := hinter hb have h := hUnique a ha₁ (s \ a) ha₂ b hb₁ (s \ b) hb₂ (hdisj a) (hdisj b) ((Finset.union_sdiff_of_subset ha₃).trans (Finset.union_sdiff_of_subset hb₃).symm) simpa only [Finset.mem_insert, Finset.mem_singleton] using h.imp And.left And.left have hsum := Finset.card_union_add_card_inter F G change F.card ≤ 11 omega /-- The constant-extension structural lemma suffices for the bounded-codegree case. -/ theorem expansion_at_equality_of_three_extension_cover {n : ℕ} (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hExtremal : edges.card = n.choose 2) (hMax : ∀ pair : Finset (Fin n), pair.card = 2 → (edges.filter (fun e => pair ⊆ e)).card ≤ 3) (hStructural : (∀ a b : Fin n, a ≠ b → (Finset.univ.filter (fun c => c ∉ ({a,b} : Finset (Fin n)) ∧ ({a,b,c} : Finset (Fin n)) ∈ edges)).card = 3) → ∀ pair : Finset (Fin n), pair.card = 2 → ∃ b : Finset (Fin n), b.card = 5 ∧ pair ⊆ b ∧ ∀ t : Finset (Fin n), t.card = 3 → t ⊆ b → t ∈ edges) : ∃ blocks : Finset (Finset (Fin n)), SteinerFive blocks ∧ IsExpansion edges blocks := by apply expansion_of_full_five_cover edges hUniform hMax apply hStructural intro a b hab rw [extension_card_eq_pair_filter_card edges hUniform hab] exact pair_codegrees_eq_three edges hUniform hExtremal hMax _ (by simp [hab]) theorem no_extremal_family_on_six_or_seven {n : ℕ} (hn : n = 6 ∨ n = 7) (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hUnique : UniqueDisjointUnions edges) (hExtremal : edges.card = n.choose 2) : False := by rcases hn with h | h <;> subst n · have hbound := card_edges_on_six_le_eleven edges hUniform hUnique Finset.univ (by simp) simpa [hExtremal, Finset.subset_univ, show (6 : ℕ).choose 2 = 15 by decide] using hbound · classical let outside (v : Fin 7) := (Finset.univ : Finset (Fin 7)).erase v have hout (v : Fin 7) : (outside v).card = 6 := by simp [outside, Finset.card_erase_of_mem] have hbound : ∑ v : Fin 7, (edges.filter (· ⊆ outside v)).card ≤ 77 := by calc _ ≤ ∑ _v : Fin 7, (11 : ℕ) := Finset.sum_le_sum fun v _ => card_edges_on_six_le_eleven edges hUniform hUnique (outside v) (hout v) _ = 77 := by simp have hsum : ∑ v : Fin 7, (edges.filter (· ⊆ outside v)).card = 84 := by calc _ = ∑ v : Fin 7, ∑ e ∈ edges, if e ⊆ outside v then (1 : ℕ) else 0 := by apply Finset.sum_congr rfl intro v _ simpa using (Finset.sum_filter (s := edges) (· ⊆ outside v) (fun _ => (1 : ℕ))) _ = ∑ e ∈ edges, ∑ v : Fin 7, if e ⊆ outside v then (1 : ℕ) else 0 := Finset.sum_comm _ = ∑ e ∈ edges, (4 : ℕ) := by apply Finset.sum_congr rfl intro e he have heq : (Finset.univ.filter fun v => e ⊆ outside v) = Finset.univ \ e := by ext v simp only [Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_sdiff, outside] constructor · intro h hv exact Finset.notMem_erase v _ (h hv) · intro hv x hx exact Finset.mem_erase.mpr ⟨fun heq => hv (heq ▸ hx), Finset.mem_univ _⟩ rw [← Finset.sum_filter, heq] simp [Finset.card_sdiff_of_subset (Finset.subset_univ e), hUniform e he] _ = 84 := by simp [hExtremal]; decide omega def localExtensions {n : ℕ} (edges : Finset (Finset (Fin n))) (pair : Finset (Fin n)) : Finset (Fin n) := Finset.univ.filter (fun v => v ∉ pair ∧ insert v pair ∈ edges) def localCoExtensions {n : ℕ} (edges : Finset (Finset (Fin n))) (pair : Finset (Fin n)) : Finset (Finset (Fin n)) := ((Finset.univ : Finset (Fin n)).powersetCard 2).filter (fun q => pair ⊆ localExtensions edges q) theorem local_neighbors_symm {n : ℕ} {edges : Finset (Finset (Fin n))} {a b c : Fin n} (hab : a ≠ b) (h : c ∈ localExtensions edges {a,b}) : b ∈ localExtensions edges {a,c} := by simp only [localExtensions, Finset.mem_filter, Finset.mem_univ, true_and, Finset.mem_insert, Finset.mem_singleton, not_or] at h ⊢ exact ⟨⟨hab.symm,Ne.symm h.1.2⟩, by simpa [Finset.insert_comm, Finset.pair_comm] using h.2⟩ theorem local_extension_edges_cross {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {p q : Finset (Fin n)} (hp : p.card = 2) (_hq : q.card = 2) {c d : Fin n} (hcd : c ≠ d) (hcp : c ∈ localExtensions edges p) (hdp : d ∈ localExtensions edges p) (hcq : c ∈ localExtensions edges q) (hdq : d ∈ localExtensions edges q) : ¬ Disjoint p q := by simp only [localExtensions, Finset.mem_filter, Finset.mem_univ, true_and] at hcp hdp hcq hdq intro hd have h₁ : Disjoint (insert c p) (insert d q) := by simp [Finset.disjoint_insert_left, Finset.disjoint_insert_right, Ne.symm hcd, hcq.1, hdp.1, hd] have h₂ : Disjoint (insert d p) (insert c q) := by simp [Finset.disjoint_insert_left, Finset.disjoint_insert_right, hcd, hdq.1, hcp.1, hd] have h₃ : insert c p ∪ insert d q = insert d p ∪ insert c q := by ext v simp only [Finset.mem_union, Finset.mem_insert] tauto rcases hu _ hcp.2 _ hdq.2 _ hdp.2 _ hcq.2 h₁ h₂ h₃ with h | h · have : c ∈ insert d p := h.1 ▸ Finset.mem_insert_self c p simp [hcd, hcp.1] at this · obtain ⟨x, hx⟩ := Finset.card_pos.mp (show 0 < p.card by omega) have hx' : x ∈ insert c q := h.1 ▸ Finset.mem_insert_of_mem hx rcases Finset.mem_insert.mp hx' with rfl | hq' · exact hcp.1 hx · exact (Finset.disjoint_left.mp hd) hx hq' theorem local_coextension_pairwise {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {p q r : Finset (Fin n)} (hp : p.card = 2) (hq : q ∈ localCoExtensions edges p) (hr : r ∈ localCoExtensions edges p) : ¬ Disjoint q r := by obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp simp only [localCoExtensions, Finset.mem_filter, Finset.mem_powersetCard, Finset.subset_univ, true_and, Finset.insert_subset_iff, Finset.singleton_subset_iff] at hq hr exact local_extension_edges_cross hu hq.1 hr.1 hab hq.2.1 hq.2.2 hr.2.1 hr.2.2 theorem local_intersecting_pair_family {α : Type*} [DecidableEq α] (F : Finset (Finset α)) (hsize : ∀ p ∈ F, p.card = 2) (hmeet : ∀ p ∈ F, ∀ q ∈ F, ¬ Disjoint p q) : F.card ≤ 1 ∨ (∃ x, ∀ p ∈ F, x ∈ p) ∨ ∃ a b c, a ≠ b ∧ a ≠ c ∧ b ≠ c ∧ F = {{a,b},{a,c},{b,c}} := by classical by_cases hl : F.card ≤ 1 · exact Or.inl hl right obtain ⟨p,hp,q,hq,hpq⟩ := Finset.one_lt_card.mp (by omega : 1 < F.card) obtain ⟨x,hxp,hxq⟩ := Finset.not_disjoint_iff.mp (hmeet p hp q hq) have pair_of_mem : ∀ {r : Finset α}, r.card = 2 → x ∈ r → ∃ a, a ≠ x ∧ r = {x,a} := by intro r hcard hxr obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.1 hcard rcases Finset.mem_insert.1 hxr with rfl | h · exact ⟨b,hab.symm,rfl⟩ · rw [Finset.mem_singleton] at h subst x exact ⟨a,hab,Finset.pair_comm _ _⟩ obtain ⟨a,ha,rfl⟩ := pair_of_mem (hsize p hp) hxp obtain ⟨b,hb,rfl⟩ := pair_of_mem (hsize q hq) hxq have hab : a ≠ b := by rintro rfl; exact hpq rfl by_cases hx : ∀ p ∈ F, x ∈ p · exact Or.inl ⟨x,hx⟩ right push Not at hx obtain ⟨r,hr,hxr⟩ := hx have hrab : r = {a,b} := by have har : a ∈ r := by obtain ⟨v,hv,hvr⟩ := Finset.not_disjoint_iff.mp (hmeet _ hp _ hr) simp only [Finset.mem_insert, Finset.mem_singleton] at hv rcases hv with rfl | rfl · contradiction · exact hvr have hbr : b ∈ r := by obtain ⟨v,hv,hvr⟩ := Finset.not_disjoint_iff.mp (hmeet _ hq _ hr) simp only [Finset.mem_insert, Finset.mem_singleton] at hv rcases hv with rfl | rfl · contradiction · exact hvr exact (Finset.eq_of_subset_of_card_le (by simpa [Finset.insert_subset_iff] using And.intro har hbr) (by rw [hsize r hr]; simp [hab])).symm subst r refine ⟨x,a,b,ha.symm,hb.symm,hab,Finset.Subset.antisymm ?_ ?_⟩ · intro r hr' by_cases hx : x ∈ r · obtain ⟨v,hv,rfl⟩ := pair_of_mem (hsize r hr') hx obtain ⟨w,hw,hw'⟩ := Finset.not_disjoint_iff.mp (hmeet _ hr' _ hr) simp only [Finset.mem_insert, Finset.mem_singleton] at hw hw' rcases hw with rfl | rfl · exact (hw'.elim ha.symm hb.symm).elim · rcases hw' with rfl | rfl <;> simp · have har : a ∈ r := by obtain ⟨v,hv,hvr⟩ := Finset.not_disjoint_iff.mp (hmeet _ hp _ hr') simp only [Finset.mem_insert, Finset.mem_singleton] at hv rcases hv with rfl | rfl · contradiction · exact hvr have hbr : b ∈ r := by obtain ⟨v,hv,hvr⟩ := Finset.not_disjoint_iff.mp (hmeet _ hq _ hr') simp only [Finset.mem_insert, Finset.mem_singleton] at hv rcases hv with rfl | rfl · contradiction · exact hvr have heq : r = {a,b} := (Finset.eq_of_subset_of_card_le (by simpa [Finset.insert_subset_iff] using And.intro har hbr) (by rw [hsize r hr']; simp [hab])).symm simp [heq] · intro r hr' simp only [Finset.mem_insert, Finset.mem_singleton] at hr' rcases hr' with rfl | rfl | rfl <;> assumption theorem local_mem_coextensions {n : ℕ} {edges : Finset (Finset (Fin n))} {p q : Finset (Fin n)} : q ∈ localCoExtensions edges p ↔ q.card = 2 ∧ p ⊆ localExtensions edges q := by simp [localCoExtensions] theorem local_pair_mem_coextensions {n : ℕ} {edges : Finset (Finset (Fin n))} {a b c d : Fin n} : {c,d} ∈ localCoExtensions edges {a,b} ↔ c ≠ d ∧ a ∈ localExtensions edges {c,d} ∧ b ∈ localExtensions edges {c,d} := by rw [local_mem_coextensions] by_cases h : c = d · simp [h] · simp [h, Finset.insert_subset_iff] theorem local_neighbors_comm {n : ℕ} {edges : Finset (Finset (Fin n))} {a b : Fin n} : localExtensions edges {a,b} = localExtensions edges {b,a} := by rw [Finset.pair_comm a b] theorem local_neighbors_ne {n : ℕ} {edges : Finset (Finset (Fin n))} {a b c : Fin n} (h : c ∈ localExtensions edges {a,b}) : c ≠ a ∧ c ≠ b := by simpa [localExtensions] using (Finset.mem_filter.mp h).2.1 theorem local_pair_with_center {α : Type*} [DecidableEq α] {p : Finset α} {x : α} (hp : p.card = 2) (hx : x ∈ p) : ∃ y, y ≠ x ∧ p = {x,y} := by obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp simp only [Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl · exact ⟨b,hab.symm,rfl⟩ · exact ⟨a,hab,Finset.pair_comm _ _⟩ theorem local_coextensions_card_le_three {n : ℕ} (edges : Finset (Finset (Fin n))) (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3) {p : Finset (Fin n)} (hp : p.card = 2) : (localCoExtensions edges p).card ≤ 3 := by obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp let F := localCoExtensions edges {a,b} have hF : ∀ q ∈ F, q.card = 2 := fun _ h => (local_mem_coextensions.mp h).1 rcases local_intersecting_pair_family F hF (fun _ hq _ hr => local_coextension_pairwise hu (by simp [hab]) hq hr) with h | ⟨x,hx⟩ | ⟨u,v,w,_,_,_,heq⟩ · change F.card ≤ 3 omega · by_cases hxa : x = a · subst x have hempty : F = ∅ := by apply Finset.eq_empty_iff_forall_notMem.2 intro q hq have hN := (local_mem_coextensions.mp hq).2 (Finset.mem_insert_self a ({b} : Finset _)) exact (Finset.mem_filter.mp hN).2.1 (hx q hq) change F.card ≤ 3 simp [hempty] · have hsub : F ⊆ (localExtensions edges {x,a}).image (fun y => ({x,y} : Finset (Fin n))) := by intro q hq obtain ⟨y,hy,rfl⟩ := local_pair_with_center (hF q hq) (hx q hq) apply Finset.mem_image.mpr exact ⟨y,local_neighbors_symm hy.symm (local_pair_mem_coextensions.mp hq).2.1,rfl⟩ calc F.card ≤ ((localExtensions edges {x,a}).image (fun y => ({x,y} : Finset (Fin n)))).card := Finset.card_le_card hsub _ ≤ (localExtensions edges {x,a}).card := Finset.card_image_le _ = 3 := hd _ _ hxa · change F.card ≤ 3 rw [heq] exact (Finset.card_insert_le _ _).trans (by exact Nat.add_le_add_right ((Finset.card_insert_le _ _).trans (by simp)) 1) theorem local_coextensions_card_three {n : ℕ} (edges : Finset (Finset (Fin n))) (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3) {p : Finset (Fin n)} (hp : p.card = 2) : (localCoExtensions edges p).card = 3 := by classical let pairs := (Finset.univ : Finset (Fin n)).powersetCard 2 have he : ∀ q ∈ pairs, (localExtensions edges q).card = 3 := by intro q hq obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp (Finset.mem_powersetCard.mp hq).2 exact hd a b hab have hq : ∀ q ∈ pairs, ({r ∈ pairs | r ⊆ localExtensions edges q}).card = 3 := by intro q hq have hh : {r ∈ pairs | r ⊆ localExtensions edges q} = (localExtensions edges q).powersetCard 2 := by ext r simp [pairs, and_comm] rw [hh, Finset.card_powersetCard, he q hq] decide have hs : ∑ q ∈ pairs, (localCoExtensions edges q).card = ∑ q ∈ pairs, ({r ∈ pairs | r ⊆ localExtensions edges q}).card := by simp only [localCoExtensions, ← show pairs = (Finset.univ : Finset (Fin n)).powersetCard 2 from rfl, Finset.card_filter] exact Finset.sum_comm have hbound : ∀ p ∈ pairs, (localCoExtensions edges p).card ≤ (fun (_ : Finset (Fin n)) => 3) p := fun p hp => local_coextensions_card_le_three edges hu hd (Finset.mem_powersetCard.mp hp).2 have hs' : ∑ q ∈ pairs, (localCoExtensions edges q).card = ∑ _q ∈ pairs, (3 : ℕ) := by rw [hs, Finset.sum_const_nat hq, Finset.sum_const_nat (fun _ _ => rfl)] exact (Finset.sum_eq_sum_iff_of_le hbound).mp hs' p (by simp [pairs, hp]) theorem local_neighbors_three_eq {n : ℕ} {edges : Finset (Finset (Fin n))} {p : Finset (Fin n)} (hp : (localExtensions edges p).card = 3) {x y z : Fin n} (hxy : x ≠ y) (hxz : x ≠ z) (hyz : y ≠ z) (hx : x ∈ localExtensions edges p) (hy : y ∈ localExtensions edges p) (hz : z ∈ localExtensions edges p) : localExtensions edges p = {x,y,z} := (Finset.eq_of_subset_of_card_le (by simp [Finset.insert_subset_iff, hx, hy, hz]) (by rw [hp]; simp [hxy,hxz,hyz])).symm theorem local_neighbors_extra {n : ℕ} {edges : Finset (Finset (Fin n))} {p : Finset (Fin n)} (hp : (localExtensions edges p).card = 3) {x y : Fin n} (hxy : x ≠ y) (hx : x ∈ localExtensions edges p) (hy : y ∈ localExtensions edges p) : ∃ z, z ≠ x ∧ z ≠ y ∧ localExtensions edges p = {x,y,z} := by have h : ¬ localExtensions edges p ⊆ {x,y} := by intro h have := Finset.card_le_card h rw [hp] at this simp [hxy] at this obtain ⟨z,hz,hzn⟩ := Finset.not_subset.mp h simp only [Finset.mem_insert, Finset.mem_singleton, not_or] at hzn exact ⟨z,hzn.1,hzn.2,local_neighbors_three_eq hp hxy (Ne.symm hzn.1) (Ne.symm hzn.2) hx hy hz⟩ theorem local_coextensions_third_of_not_center {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {p : Finset (Fin n)} (hp : p.card = 2) {x a b : Fin n} (hab : a ≠ b) (ha : {x,a} ∈ localCoExtensions edges p) (hb : {x,b} ∈ localCoExtensions edges p) (hn : ¬ ∀ q ∈ localCoExtensions edges p, x ∈ q) : {a,b} ∈ localCoExtensions edges p := by push Not at hn obtain ⟨r,hr,hxr⟩ := hn have get : ∀ {u : Fin n}, {x,u} ∈ localCoExtensions edges p → u ∈ r := by intro u hu' obtain ⟨v,hv,hvr⟩ := Finset.not_disjoint_iff.mp (local_coextension_pairwise hu hp hu' hr) simp only [Finset.mem_insert, Finset.mem_singleton] at hv rcases hv with rfl | rfl · contradiction · assumption have heq : {a,b} = r := Finset.eq_of_subset_of_card_le (by simp [Finset.insert_subset_iff, get ha, get hb]) (by rw [(local_mem_coextensions.mp hr).1]; simp [hab]) rwa [heq] theorem local_center_gives_twins {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3) {a b x : Fin n} (hax : x ≠ a) (hbx : x ≠ b) (hc : (localCoExtensions edges {a,b}).card = 3) (hx : ∀ q ∈ localCoExtensions edges {a,b}, x ∈ q) : localExtensions edges {x,a} = localExtensions edges {x,b} := by let C := localExtensions edges {x,a} ∩ localExtensions edges {x,b} have hs : localCoExtensions edges {a,b} ⊆ C.image (fun y => ({x,y} : Finset (Fin n))) := by intro q hq obtain ⟨y,hy,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hq).1 (hx q hq) obtain ⟨_,ha,hb⟩ := local_pair_mem_coextensions.mp hq apply Finset.mem_image.mpr exact ⟨y,Finset.mem_inter.mpr ⟨local_neighbors_symm hy.symm ha,local_neighbors_symm hy.symm hb⟩,rfl⟩ have hc' : 3 ≤ C.card := by calc 3 = (localCoExtensions edges {a,b}).card := hc.symm _ ≤ (C.image (fun y => ({x,y} : Finset (Fin n)))).card := Finset.card_le_card hs _ ≤ C.card := Finset.card_image_le have ha : C = localExtensions edges {x,a} := Finset.eq_of_subset_of_card_le Finset.inter_subset_left (by rwa [hd _ _ hax]) have hb : C = localExtensions edges {x,b} := Finset.eq_of_subset_of_card_le Finset.inter_subset_right (by rwa [hd _ _ hbx]) exact ha.symm.trans hb theorem local_twins_give_center {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {a b x : Fin n} (hab : a ≠ b) (hxa : x ≠ a) (hxb : x ≠ b) (hc : (localExtensions edges {x,a}).card = 3) (hh : localExtensions edges {x,a} = localExtensions edges {x,b}) : ∀ q ∈ localCoExtensions edges {a,b}, x ∈ q := by intro q hq by_contra hn have hsub : localExtensions edges {x,a} ⊆ q := by intro y hy have hy' : y ∈ localExtensions edges {x,b} := hh ▸ hy have hm : {x,y} ∈ localCoExtensions edges {a,b} := local_pair_mem_coextensions.mpr ⟨(local_neighbors_ne hy).1.symm, local_neighbors_symm hxa hy,local_neighbors_symm hxb hy'⟩ obtain ⟨v,hv,hvq⟩ := Finset.not_disjoint_iff.mp (local_coextension_pairwise hu (by simp [hab]) hm hq) simp only [Finset.mem_insert, Finset.mem_singleton] at hv rcases hv with rfl | rfl · contradiction · assumption have hh' := Finset.card_le_card hsub rw [hc, (local_mem_coextensions.mp hq).1] at hh' omega theorem local_bipartite_no_row {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3) {A B : Finset (Fin n)} (hA : A.card = 3) (hB : B.card = 3) (hAB : Disjoint A B) {x y a b b' : Fin n} (hxy : x ≠ y) (hxA : x ∉ A) (hxB : x ∉ B) (hlA : ∀ a ∈ A, localExtensions edges {x,a} = B) (hlB : ∀ b ∈ B, localExtensions edges {x,b} = A) (ha : a ∈ A) (hb : b ∈ B) (hb' : b' ∈ B) (hbb' : b ≠ b') (hrow : {a,b} ∈ localCoExtensions edges {x,y}) (hrow' : {a,b'} ∈ localCoExtensions edges {x,y}) : False := by have hctr : ∀ q ∈ localCoExtensions edges {x,y}, a ∈ q := by by_contra h have hh := local_coextensions_third_of_not_center hu (by simp [hxy]) hbb' hrow hrow' h have hc := local_neighbors_symm hbb' (local_pair_mem_coextensions.mp hh).2.1 rw [local_neighbors_comm (a := b) (b := x),hlB b hb] at hc exact (Finset.disjoint_left.mp hAB) hc hb' have hax : a ≠ x := fun h => hxA (h ▸ ha) have hay : a ≠ y := fun h => ((local_neighbors_ne (local_pair_mem_coextensions.mp hrow).2.2).1) h.symm have hnc := local_center_gives_twins hd hax hay (local_coextensions_card_three edges hu hd (by simp [hxy])) hctr rw [local_neighbors_comm (a := a) (b := x), hlA a ha] at hnc have hthird : ¬ A ⊆ {a,y} := by intro h have hh := Finset.card_le_card h rw [hA] at hh simp [hay] at hh obtain ⟨u,huA,huay⟩ := Finset.not_subset.mp hthird simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at huay have hdis : Disjoint ({a,y} : Finset (Fin n)) {x,u} := by have hxu : x ≠ u := fun h => hxA (h.symm ▸ huA) rw [Finset.disjoint_left] intro v hv hw simp only [Finset.mem_insert,Finset.mem_singleton] at hv hw aesop apply local_extension_edges_cross hu (by simp [hay]) (by simp [show x ≠ u by exact fun h => hxA (h.symm ▸ huA)]) hbb' _ _ _ _ hdis all_goals first | rwa [← hnc] | rwa [hlA u huA] theorem local_bipartite_link_forbidden {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3) {A B : Finset (Fin n)} (hA : A.card = 3) (hB : B.card = 3) (hAB : Disjoint A B) {x : Fin n} (hxA : x ∉ A) (hxB : x ∉ B) (hlA : ∀ a ∈ A, localExtensions edges {x,a} = B) (hlB : ∀ b ∈ B, localExtensions edges {x,b} = A) : False := by obtain ⟨a,ha⟩ := Finset.card_pos.mp (show 0 < A.card by omega) obtain ⟨b,hb⟩ := Finset.card_pos.mp (show 0 < B.card by omega) have hab : a ≠ b := fun h => (Finset.disjoint_left.mp hAB) (h ▸ ha) hb have hxa : x ≠ a := fun h => hxA (h.symm ▸ ha) have hxb : x ≠ b := fun h => hxB (h.symm ▸ hb) have hxab : x ∈ localExtensions edges {a,b} := by apply local_neighbors_symm hxa.symm rw [local_neighbors_comm (a := a) (b := x),hlA a ha] exact hb have hex : ¬ localExtensions edges {a,b} ⊆ {x} := by intro h have h := Finset.card_le_card h rw [hd a b hab,Finset.card_singleton] at h omega obtain ⟨y,hy,hyx⟩ := Finset.not_subset.mp hex rw [Finset.mem_singleton] at hyx have hq : {a,b} ∈ localCoExtensions edges {x,y} := local_pair_mem_coextensions.mpr ⟨hab,hxab,hy⟩ have hco : (localCoExtensions edges {x,y}).card = 3 := local_coextensions_card_three edges hu hd (by simp [Ne.symm hyx]) have hsub : ¬ localCoExtensions edges {x,y} ⊆ {{a,b}} := by intro h have h := Finset.card_le_card h rw [hco,Finset.card_singleton] at h omega obtain ⟨q,hqq,hqn⟩ := Finset.not_subset.mp hsub rw [Finset.mem_singleton] at hqn obtain ⟨v,hv,hvq⟩ := Finset.not_disjoint_iff.mp (local_coextension_pairwise hu (by simp [Ne.symm hyx]) hq hqq) simp only [Finset.mem_insert,Finset.mem_singleton] at hv rcases hv with h | h · subst v obtain ⟨b',hb'a,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hqq).1 hvq have hb' := local_neighbors_symm hb'a.symm (local_pair_mem_coextensions.mp hqq).2.1 rw [local_neighbors_comm (a := a) (b := x),hlA a ha] at hb' have hbb' : b ≠ b' := fun h => hqn (h ▸ rfl) exact local_bipartite_no_row hu hd hA hB hAB (Ne.symm hyx) hxA hxB hlA hlB ha hb hb' hbb' hq hqq · subst v obtain ⟨a',ha'b,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hqq).1 hvq rw [Finset.pair_comm a b] at hq hqn have ha' := local_neighbors_symm ha'b.symm (local_pair_mem_coextensions.mp hqq).2.1 rw [local_neighbors_comm (a := b) (b := x),hlB b hb] at ha' have haa' : a ≠ a' := fun h => hqn (h ▸ rfl) exact local_bipartite_no_row hu hd hB hA hAB.symm (Ne.symm hyx) hxB hxA hlB hlA hb ha ha' haa' hq hqq theorem local_three_twins_forbidden {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3) {A B : Finset (Fin n)} (hA : A.card = 3) {x : Fin n} (hxA : x ∉ A) (hlA : ∀ a ∈ A, localExtensions edges {x,a} = B) : False := by obtain ⟨a,ha⟩ := Finset.card_pos.mp (show 0 < A.card by omega) have hB : B.card = 3 := by rw [← hlA a ha,hd]; exact fun h => hxA (h.symm ▸ ha) have hxB : x ∉ B := by intro hx have hx' : x ∈ localExtensions edges {x,a} := (hlA a ha).symm ▸ hx exact (local_neighbors_ne hx').1 rfl have hAB : Disjoint A B := by rw [Finset.disjoint_left] intro a ha hb have hb' : a ∈ localExtensions edges {x,a} := (hlA a ha).symm ▸ hb exact (local_neighbors_ne hb').2 rfl have hlB : ∀ b ∈ B, localExtensions edges {x,b} = A := by intro b hb apply Finset.eq_of_subset_of_card_le _ _ |>.symm · intro a ha have hb' : b ∈ localExtensions edges {x,a} := (hlA a ha).symm ▸ hb exact local_neighbors_symm (fun h => hxA (h.symm ▸ ha)) hb' · rw [hA, hd] exact fun h => hxB (h.symm ▸ hb) exact local_bipartite_link_forbidden hu hd hA hB hAB hxA hxB hlA hlB theorem local_twins_close_triangle {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3) {x a b : Fin n} (hxa : x ≠ a) (hxb : x ≠ b) (hab : a ≠ b) (htw : localExtensions edges {x,a} = localExtensions edges {x,b}) : localExtensions edges {a,b} = localExtensions edges {x,a} := by let T := localExtensions edges {x,a} apply Finset.eq_of_subset_of_card_le _ _ |>.symm · intro t ht by_contra hn have ht' : t ∈ localExtensions edges {x,b} := htw ▸ ht have hxt := (local_neighbors_ne ht).1.symm have hta := (local_neighbors_ne ht).2 have htb := (local_neighbors_ne ht').2 have hall : ∀ u ∈ T, localExtensions edges {x,u} = localExtensions edges {x,t} := by intro u hu' by_cases hut : u = t · subst u rfl have hu'' : u ∈ localExtensions edges {x,b} := htw ▸ hu' have hctr : ∀ q ∈ localCoExtensions edges {u,t}, x ∈ q := by by_contra h have ha : {x,a} ∈ localCoExtensions edges {u,t} := local_pair_mem_coextensions.mpr ⟨hxa,hu',ht⟩ have hb : {x,b} ∈ localCoExtensions edges {u,t} := local_pair_mem_coextensions.mpr ⟨hxb,hu'',ht'⟩ have hh := local_coextensions_third_of_not_center hu (by simp [hut]) hab ha hb h exact hn (local_pair_mem_coextensions.mp hh).2.2 exact (local_center_gives_twins hd (local_neighbors_ne hu').1.symm hxt (local_coextensions_card_three edges hu hd (by simp [hut])) hctr) exact local_three_twins_forbidden hu hd (hd _ _ hxa) (fun h => (local_neighbors_ne h).1 rfl) hall · rw [hd _ _ hab,hd _ _ hxa] theorem local_triangle_link_no_residual {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3) {T : Finset (Fin n)} {a b c t u v : Fin n} (hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) (eab : localExtensions edges {a,b} = T) (eac : localExtensions edges {a,c} = T) (ebc : localExtensions edges {b,c} = T) (ht : t ∈ T) (eau : localExtensions edges {t,a} = {b,c,u}) (ebv : localExtensions edges {t,b} = {a,c,v}) (hua : u ≠ a) (hub : u ≠ b) (huc : u ≠ c) (hut : u ≠ t) (_hvt : v ≠ t) (hvT : v ∉ T) : False := by have htAB : t ∈ localExtensions edges {a,b} := eab.symm ▸ ht have hta := (local_neighbors_ne htAB).1 have htb := (local_neighbors_ne htAB).2 have htc := (local_neighbors_ne (show t ∈ localExtensions edges {a,c} from eac.symm ▸ ht)).2 have huA : a ∈ localExtensions edges {t,u} := local_neighbors_symm hta (by rw [eau]; simp) have hnotC : c ∉ localExtensions edges {t,u} := by intro hc have htwin : localExtensions edges {b,a} = localExtensions edges {b,c} := by rw [local_neighbors_comm (a := b) (b := a),eab,ebc] have hstar := local_twins_give_center hu hac hab.symm hbc (hd _ _ hab.symm) htwin have hh := hstar {t,u} (local_pair_mem_coextensions.mpr ⟨hut.symm,huA,hc⟩) simp [htb.symm,hub.symm] at hh have htaG : {t,a} ∈ localCoExtensions edges {b,u} := local_pair_mem_coextensions.mpr ⟨hta,by rw [eau]; simp,by rw [eau]; simp⟩ have hnotT : ¬ ∀ q ∈ localCoExtensions edges {b,u}, t ∈ q := by intro h have hh := local_center_gives_twins hd htb hut.symm (local_coextensions_card_three edges hu hd (by simp [hub.symm])) h exact hnotC (hh ▸ (show c ∈ localExtensions edges {t,b} by rw [ebv]; simp)) have hstar : ∀ q ∈ localCoExtensions edges {b,u}, a ∈ q := by by_contra hn push Not at hn obtain ⟨q,hq,hqa⟩ := hn obtain ⟨z,hz,hzq⟩ := Finset.not_disjoint_iff.mp (local_coextension_pairwise hu (by simp [hub.symm]) htaG hq) have hqt : t ∈ q := by simp only [Finset.mem_insert,Finset.mem_singleton] at hz rcases hz with h | h · rwa [← h] · exact (hqa (h ▸ hzq)).elim obtain ⟨w,hwt,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hq).1 hqt obtain ⟨_,hwb,hwu⟩ := local_pair_mem_coextensions.mp hq have hW := local_neighbors_symm hwt.symm hwb rw [ebv] at hW simp only [Finset.mem_insert,Finset.mem_singleton] at hW rcases hW with h | h | h · exact hqa (by simp [h]) · exact hnotC (h ▸ local_neighbors_symm hwt.symm hwu) · subst w have hav : a ≠ v := fun h => hqa (by simp [h]) have havG := local_coextensions_third_of_not_center hu (by simp [hub.symm]) hav htaG hq hnotT have hvB := local_neighbors_symm hav (local_pair_mem_coextensions.mp havG).2.1 rw [eab] at hvB exact hvT hvB have hh := local_center_gives_twins hd hab hua.symm (local_coextensions_card_three edges hu hd (by simp [hub.symm])) hstar have hthird : ∀ w ∈ ({b,c,u} : Finset (Fin n)), localExtensions edges {a,w} = T := by intro w hw simp only [Finset.mem_insert,Finset.mem_singleton] at hw rcases hw with rfl | rfl | rfl · exact eab · exact eac · exact hh.symm.trans eab exact local_three_twins_forbidden hu hd (by simp [hbc,hub.symm,huc.symm]) (by simp [hab,hac,hua.symm]) hthird theorem local_adjacent_link_twins_forbidden {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3) {T : Finset (Fin n)} {a b c : Fin n} (hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) (eab : localExtensions edges {a,b} = T) (eac : localExtensions edges {a,c} = T) (ebc : localExtensions edges {b,c} = T) : False := by have hTcard : T.card = 3 := eab ▸ hd _ _ hab obtain ⟨t,ht⟩ := Finset.card_pos.mp (show 0 < T.card by omega) have htAB : t ∈ localExtensions edges {a,b} := eab.symm ▸ ht have htAC : t ∈ localExtensions edges {a,c} := eac.symm ▸ ht have htBC : t ∈ localExtensions edges {b,c} := ebc.symm ▸ ht have ⟨hta,htb⟩ := local_neighbors_ne htAB have htc := (local_neighbors_ne htAC).2 have tb : b ∈ localExtensions edges {t,a} := by rw [local_neighbors_comm (a := t) (b := a)] exact local_neighbors_symm hab htAB have tc : c ∈ localExtensions edges {t,a} := by rw [local_neighbors_comm (a := t) (b := a)] exact local_neighbors_symm hac htAC have ta : a ∈ localExtensions edges {t,b} := by rw [local_neighbors_comm (a := t) (b := b)] apply local_neighbors_symm hab.symm rwa [local_neighbors_comm (a := b) (b := a)] have tc' : c ∈ localExtensions edges {t,b} := by rw [local_neighbors_comm (a := t) (b := b)] exact local_neighbors_symm hbc htBC obtain ⟨u,hub,huc,heu⟩ := local_neighbors_extra (hd _ _ hta) hbc tb tc obtain ⟨v,hva,hvc,hev⟩ := local_neighbors_extra (hd _ _ htb) hac ta tc' have hu : u ∈ localExtensions edges {t,a} := by rw [heu]; simp have hv : v ∈ localExtensions edges {t,b} := by rw [hev]; simp have ⟨hut,hua⟩ := local_neighbors_ne hu have ⟨hvt,hvb⟩ := local_neighbors_ne hv have huv : u ≠ v := by intro h subst v have htw : localExtensions edges {c,a} = localExtensions edges {c,b} := by rw [local_neighbors_comm (a := c) (b := a),local_neighbors_comm (a := c) (b := b),eac,ebc] have hstar := local_twins_give_center ‹UniqueDisjointUnions edges› hab hac.symm hbc.symm (hd _ _ hac.symm) htw have hG : {t,u} ∈ localCoExtensions edges {a,b} := local_pair_mem_coextensions.mpr ⟨hut.symm,local_neighbors_symm hta hu, local_neighbors_symm htb hv⟩ have hc := hstar {t,u} hG simp [htc.symm,huc.symm] at hc by_cases hvT : v ∈ T · by_cases huT : u ∈ T · have hP : Disjoint ({a,u} : Finset (Fin n)) {b,v} := by rw [Finset.disjoint_left] intro w hw hw' simp only [Finset.mem_insert,Finset.mem_singleton] at hw hw' aesop have hut' : t ∈ localExtensions edges {a,u} := by apply local_neighbors_symm hta.symm rwa [local_neighbors_comm (a := a) (b := t)] have hvt' : t ∈ localExtensions edges {b,v} := by apply local_neighbors_symm htb.symm rwa [local_neighbors_comm (a := b) (b := t)] have huc' : c ∈ localExtensions edges {a,u} := local_neighbors_symm hac (eac.symm ▸ huT) have hvc' : c ∈ localExtensions edges {b,v} := local_neighbors_symm hbc (ebc.symm ▸ hvT) exact local_extension_edges_cross ‹UniqueDisjointUnions edges› (by simp [hua.symm]) (by simp [hvb.symm]) htc hut' huc' hvt' hvc' hP · rw [Finset.pair_comm a b] at eab exact local_triangle_link_no_residual ‹UniqueDisjointUnions edges› hd hab.symm hbc hac eab ebc eac ht hev heu hvb hva hvc hvt hut huT · exact local_triangle_link_no_residual ‹UniqueDisjointUnions edges› hd hab hac hbc eab eac ebc ht heu hev hua hub huc hut hvt hvT theorem local_no_coextension_center {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3) {a b x : Fin n} (hab : a ≠ b) : ¬ ∀ q ∈ localCoExtensions edges {a,b}, x ∈ q := by intro hctr have hc := local_coextensions_card_three edges hu hd (by simp [hab] : ({a,b} : Finset (Fin n)).card = 2) obtain ⟨p,hp⟩ := Finset.card_pos.mp (show 0 < (localCoExtensions edges {a,b}).card by omega) have hpa := (local_mem_coextensions.mp hp).2 (show a ∈ ({a,b} : Finset (Fin n)) by simp) have hpb := (local_mem_coextensions.mp hp).2 (show b ∈ ({a,b} : Finset (Fin n)) by simp) have ha : x ≠ a := fun h => (Finset.mem_filter.mp hpa).2.1 (h ▸ hctr p hp) have hb : x ≠ b := fun h => (Finset.mem_filter.mp hpb).2.1 (h ▸ hctr p hp) have htw := local_center_gives_twins hd ha hb hc hctr have hclose := local_twins_close_triangle hu hd ha hb hab htw exact local_adjacent_link_twins_forbidden hu hd hab ha.symm hb.symm hclose ((local_neighbors_comm (a := a) (b := x))) ((local_neighbors_comm (a := b) (b := x)).trans htw.symm) theorem local_second_common_neighbor {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3) {x a b c : Fin n} (hxa : x ≠ a) (hbc : b ≠ c) (hb : b ∈ localExtensions edges {x,a}) (hc : c ∈ localExtensions edges {x,a}) : ∃ u, x ≠ u ∧ a ≠ u ∧ b ∈ localExtensions edges {x,u} ∧ c ∈ localExtensions edges {x,u} := by have hP : {x,a} ∈ localCoExtensions edges {b,c} := local_pair_mem_coextensions.mpr ⟨hxa,hb,hc⟩ have h := local_no_coextension_center hu hd (x := a) hbc push Not at h obtain ⟨q,hq,hqa⟩ := h obtain ⟨y,hy,hyq⟩ := Finset.not_disjoint_iff.mp (local_coextension_pairwise hu (by simp [hbc]) hP hq) have hxq : x ∈ q := by simp only [Finset.mem_insert,Finset.mem_singleton] at hy rcases hy with h | h · rwa [← h] · exact (hqa (h ▸ hyq)).elim obtain ⟨u,hux,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hq).1 hxq obtain ⟨_,hbu,hcu⟩ := local_pair_mem_coextensions.mp hq exact ⟨u,hux.symm,fun h => hqa (by simp [h]),hbu,hcu⟩ theorem local_four_cycle_closes {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3) {x a b c u : Fin n} (hxa : x ≠ a) (hxu : x ≠ u) (hbc : b ≠ c) (hau : a ≠ u) (hb : b ∈ localExtensions edges {x,a}) (hc : c ∈ localExtensions edges {x,a}) (hbu : b ∈ localExtensions edges {x,u}) (hcu : c ∈ localExtensions edges {x,u}) : b ∈ localExtensions edges {a,u} ∧ c ∈ localExtensions edges {a,u} ∧ a ∈ localExtensions edges {b,c} ∧ u ∈ localExtensions edges {b,c} := by have h₁ : {x,a} ∈ localCoExtensions edges {b,c} := local_pair_mem_coextensions.mpr ⟨hxa,hb,hc⟩ have h₂ : {x,u} ∈ localCoExtensions edges {b,c} := local_pair_mem_coextensions.mpr ⟨hxu,hbu,hcu⟩ have he := local_coextensions_third_of_not_center hu (by simp [hbc]) hau h₁ h₂ (local_no_coextension_center hu hd hbc) have hxB : x ≠ b := (local_neighbors_ne hb).1.symm have hxC : x ≠ c := (local_neighbors_ne hc).1.symm have h₁' : {x,b} ∈ localCoExtensions edges {a,u} := local_pair_mem_coextensions.mpr ⟨hxB,local_neighbors_symm hxa hb,local_neighbors_symm hxu hbu⟩ have h₂' : {x,c} ∈ localCoExtensions edges {a,u} := local_pair_mem_coextensions.mpr ⟨hxC,local_neighbors_symm hxa hc,local_neighbors_symm hxu hcu⟩ have he' := local_coextensions_third_of_not_center hu (by simp [hau]) hbc h₁' h₂' (local_no_coextension_center hu hd hau) exact ⟨(local_pair_mem_coextensions.mp he).2.1,(local_pair_mem_coextensions.mp he).2.2, (local_pair_mem_coextensions.mp he').2.1,(local_pair_mem_coextensions.mp he').2.2⟩ theorem local_neighbors_mem_edges {n : ℕ} {edges : Finset (Finset (Fin n))} {a b c : Fin n} (h : c ∈ localExtensions edges {a,b}) : {a,b,c} ∈ edges := by have heq : insert c ({a,b} : Finset (Fin n)) = {a,b,c} := by ext z simp only [Finset.mem_insert,Finset.mem_singleton] tauto exact heq ▸ (Finset.mem_filter.mp h).2.2 theorem local_five_edges {n : ℕ} {edges : Finset (Finset (Fin n))} {x a b c d : Fin n} (hxa : x ≠ a) (hxb : x ≠ b) (hxc : x ≠ c) (hxd : x ≠ d) (hab : a ≠ b) (hac : a ≠ c) (had : a ≠ d) (hbc : b ≠ c) (hbd : b ≠ d) (hcd : c ≠ d) (h₁ : {x,a,b} ∈ edges) (h₂ : {x,a,c} ∈ edges) (h₃ : {x,a,d} ∈ edges) (h₄ : {x,c,b} ∈ edges) (h₅ : {x,d,b} ∈ edges) (h₆ : {x,d,c} ∈ edges) (h₇ : {a,b,c} ∈ edges) (h₈ : {a,b,d} ∈ edges) (h₉ : {a,d,c} ∈ edges) (h₁₀ : {b,c,d} ∈ edges) : ∀ t : Finset (Fin n), t.card = 3 → t ⊆ {x,a,b,c,d} → t ∈ edges := by let f : Fin 5 → Fin n := ![x,a,b,c,d] have hf : Function.Injective f := by intro i j fin_cases i <;> fin_cases j <;> simp_all [f, hxa.symm, hxb.symm, hxc.symm, hxd.symm, hab.symm, hac.symm, had.symm, hbc.symm, hbd.symm, hcd.symm] let ff : Fin 5 ↪ Fin n := ⟨f,hf⟩ have hfmap : Finset.univ.map ff = {x,a,b,c,d} := by rw [show (Finset.univ : Finset (Fin 5)) = {0,1,2,3,4} by decide] simp [ff,f] intro t hcard hsub have ht : t ∈ (Finset.univ.map ff).powersetCard 3 := by rw [hfmap] exact Finset.mem_powersetCard.mpr ⟨hsub,hcard⟩ rw [Finset.powersetCard_map] at ht obtain ⟨u,hu,huEq⟩ := Finset.mem_map.mp ht rw [← huEq] change u.map ff ∈ edges have hfin : (Finset.univ : Finset (Fin 5)).powersetCard 3 = {{0,1,2},{0,1,3},{0,1,4},{0,3,2},{0,4,2},{0,4,3}, {1,2,3},{1,2,4},{1,4,3},{2,3,4}} := by decide rw [hfin] at hu simp only [Finset.mem_insert,Finset.mem_singleton] at hu rcases hu with rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl | rfl <;> simp [ff,f,h₁,h₂,h₃,h₄,h₅,h₆,h₇,h₈,h₉,h₁₀] theorem full_five_cover_of_three_extensions {n : ℕ} (edges : Finset (Finset (Fin n))) (_hUniform : ∀ e ∈ edges, e.card = 3) (hUnique : UniqueDisjointUnions edges) (hDegree : ∀ a b : Fin n, a ≠ b → ((Finset.univ.filter fun c => c ∉ ({a,b} : Finset (Fin n)) ∧ ({a,b,c} : Finset (Fin n)) ∈ edges)).card = 3) : ∀ pair : Finset (Fin n), pair.card = 2 → ∃ block : Finset (Fin n), block.card = 5 ∧ pair ⊆ block ∧ ∀ t : Finset (Fin n), t.card = 3 → t ⊆ block → t ∈ edges := by have hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3 := by intro a b h have heq : ∀ c : Fin n, insert c ({a,b} : Finset (Fin n)) = {a,b,c} := by intro c ext z simp only [Finset.mem_insert,Finset.mem_singleton] tauto simpa only [localExtensions,heq] using hDegree a b h intro pair hp obtain ⟨x,a,hxa,rfl⟩ := Finset.card_eq_two.mp hp obtain ⟨b,c,d,hbc,hbd,hcd,he⟩ := Finset.card_eq_three.mp (hd _ _ hxa) have hb : b ∈ localExtensions edges {x,a} := by rw [he]; simp have hc : c ∈ localExtensions edges {x,a} := by rw [he]; simp have hh : d ∈ localExtensions edges {x,a} := by rw [he]; simp have ⟨hbx,hba⟩ := local_neighbors_ne hb have ⟨hcx,hca⟩ := local_neighbors_ne hc have ⟨hdx,hda⟩ := local_neighbors_ne hh obtain ⟨u,hxu,hau,hbu,hcu⟩ := local_second_common_neighbor hUnique hd hxa hbc hb hc obtain ⟨v,hxv,hav,hbv,hdv⟩ := local_second_common_neighbor hUnique hd hxa hbd hb hh have hu := local_four_cycle_closes hUnique hd hxa hxu hbc hau hb hc hbu hcu have hv := local_four_cycle_closes hUnique hd hxa hxv hbd hav hb hh hbv hdv have hxab : x ∈ localExtensions edges {a,b} := by apply local_neighbors_symm hxa.symm rwa [local_neighbors_comm (a := a) (b := x)] have hcab : c ∈ localExtensions edges {a,b} := by have h := local_neighbors_symm hbc hu.2.2.1 rwa [local_neighbors_comm (a := b) (b := a)] at h have hUab : u ∈ localExtensions edges {a,b} := local_neighbors_symm hau hu.1 have hdab : d ∈ localExtensions edges {a,b} := by have h := local_neighbors_symm hbd hv.2.2.1 rwa [local_neighbors_comm (a := b) (b := a)] at h have hVab : v ∈ localExtensions edges {a,b} := local_neighbors_symm hav hv.1 have hAB := local_neighbors_three_eq (hd _ _ hba.symm) hcx.symm hdx.symm hcd hxab hcab hdab rw [hAB] at hUab hVab have hud : u = d := by simpa [hxu.symm,(local_neighbors_ne hcu).2.symm] using hUab have hvc : v = c := by simpa [hxv.symm,(local_neighbors_ne hdv).2.symm] using hVab subst u subst v have ht1 := local_neighbors_mem_edges hb have ht2 := local_neighbors_mem_edges hc have ht3 := local_neighbors_mem_edges hh have ht4 := local_neighbors_mem_edges hbv have ht5 := local_neighbors_mem_edges hbu have ht6 := local_neighbors_mem_edges hcu have ht7 := local_neighbors_mem_edges hcab have ht8 := local_neighbors_mem_edges hdab have ht9 := local_neighbors_mem_edges hu.2.1 have ht10 := local_neighbors_mem_edges hu.2.2.2 refine ⟨{x,a,b,c,d}, by simp [hxa,hbx.symm,hcx.symm,hdx.symm,hba.symm,hca.symm,hda.symm,hbc,hbd,hcd], by simp [Finset.insert_subset_iff], ?_⟩ exact local_five_edges hxa hbx.symm hcx.symm hdx.symm hba.symm hca.symm hda.symm hbc hbd hcd ht1 ht2 ht3 ht4 ht5 ht6 ht7 ht8 ht9 ht10 /-- Equality families with pair codegree bounded by three are Steiner expansions. -/ theorem classify_extremal_triple_families_of_pair_codegree_le_three {n : ℕ} (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hUnique : UniqueDisjointUnions edges) (hExtremal : edges.card = n.choose 2) (hMax : ∀ pair : Finset (Fin n), pair.card = 2 → (edges.filter (fun e => pair ⊆ e)).card ≤ 3) : ∃ blocks : Finset (Finset (Fin n)), SteinerFive blocks ∧ IsExpansion edges blocks := by exact expansion_at_equality_of_three_extension_cover edges hUniform hExtremal hMax (full_five_cover_of_three_extensions edges hUniform hUnique) theorem pair_codegree_le_three_of_steiner_expansion {n : ℕ} {edges blocks : Finset (Finset (Fin n))} (hSteiner : SteinerFive blocks) (hExpansion : IsExpansion edges blocks) : ∀ pair : Finset (Fin n), pair.card = 2 → (edges.filter (fun e => pair ⊆ e)).card ≤ 3 := by intro pair hp obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp rw [← extension_card_eq_pair_filter_card edges (fun e he => ((hExpansion e).mp he).1) hab] obtain ⟨block, ⟨hb, hpB⟩, hu⟩ := hSteiner.2 {a,b} hp have hs : (Finset.univ.filter (fun c => c ∉ ({a,b} : Finset (Fin n)) ∧ ({a,b,c} : Finset (Fin n)) ∈ edges)) ⊆ block \ {a,b} := by intro c hc obtain ⟨hnp, he⟩ := (Finset.mem_filter.mp hc).2 obtain ⟨_, B, hB, htB⟩ := (hExpansion _).mp he have hpT : ({a,b} : Finset (Fin n)) ⊆ {a,b,c} := by simp [Finset.insert_subset_iff] have hEq := hu B ⟨hB, hpT.trans htB⟩ subst B exact Finset.mem_sdiff.mpr ⟨htB (by simp), hnp⟩ exact (Finset.card_le_card hs).trans (by rw [Finset.card_sdiff_of_subset hpB, hSteiner.1 block hb, hp]) theorem pair_extension_sizes_eq_three_of_common_link_card_le_three {n : ℕ} (extensions : Finset (Fin n) → Finset (Fin n)) (hTotal : ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, (extensions p).card = 3 * n.choose 2) (hCommon : ∀ q : Finset (Fin n), q.card = 2 → (((Finset.univ : Finset (Fin n)).powersetCard 2).filter (fun p => q ⊆ extensions p)).card ≤ 3) : ∀ p : Finset (Fin n), p.card = 2 → (extensions p).card = 3 := by let pairs := (Finset.univ : Finset (Fin n)).powersetCard 2 have hmem (p : Finset (Fin n)) : p ∈ pairs ↔ p.card = 2 := by simp [pairs] have hcard : pairs.card = n.choose 2 := by simp [pairs] have hCount : ∑ p ∈ pairs, (extensions p).card.choose 2 ≤ 3 * n.choose 2 := calc ∑ p ∈ pairs, (extensions p).card.choose 2 = ∑ p ∈ pairs, ∑ q ∈ pairs, if q ⊆ extensions p then (1 : ℕ) else 0 := by apply Finset.sum_congr rfl intro p _ rw [← Finset.sum_filter (s := pairs) (fun q => q ⊆ extensions p) (fun _ => (1 : ℕ))] have hfilter : pairs.filter (fun q => q ⊆ extensions p) = (extensions p).powersetCard 2 := by ext q simp only [Finset.mem_filter, Finset.mem_powersetCard, hmem] exact and_comm simp [hfilter] _ = ∑ q ∈ pairs, ∑ p ∈ pairs, if q ⊆ extensions p then (1 : ℕ) else 0 := Finset.sum_comm _ ≤ ∑ _q ∈ pairs, (3 : ℕ) := by apply Finset.sum_le_sum intro q hq rw [← Finset.sum_filter (s := pairs) (fun p => q ⊆ extensions p) (fun _ => (1 : ℕ))] simpa using hCommon q ((hmem q).mp hq) _ = 3 * n.choose 2 := by simp [hcard, Nat.mul_comm] have hLocal (d : ℕ) : 2 * d + (if 3 < d then 1 else 0) ≤ d.choose 2 + 3 := by induction d with | zero => decide | succ d ih => by_cases hd : 3 ≤ d · have hPascal : (d + 1).choose 2 = d + d.choose 2 := by simpa only [Nat.choose_one_right] using Nat.choose_succ_succ' d 1 change 2 * (d + 1) + (if 3 < d + 1 then 1 else 0) ≤ (d + 1).choose 2 + 3 rw [hPascal] split_ifs at ih ⊢ <;> omega · interval_cases d <;> decide have hLower : ∑ p ∈ pairs, 2 * (extensions p).card = 6 * n.choose 2 := by rw [← Finset.mul_sum] change 2 * (∑ p ∈ pairs, (extensions p).card) = 6 * n.choose 2 rw [show (∑ p ∈ pairs, (extensions p).card) = 3 * n.choose 2 from hTotal] omega have hUpper : ∑ p ∈ pairs, ((extensions p).card.choose 2 + 3) ≤ 6 * n.choose 2 := by rw [Finset.sum_add_distrib] simp only [Finset.sum_const, nsmul_eq_mul] refine (Nat.add_le_add_right hCount _).trans ?_ rw [hcard] change 3 * n.choose 2 + n.choose 2 * 3 ≤ 6 * n.choose 2 omega have hle : ∀ p ∈ pairs, (extensions p).card ≤ 3 := by intro p hp by_contra! hhigh have hlt : (∑ q ∈ pairs, 2 * (extensions q).card) < ∑ q ∈ pairs, ((extensions q).card.choose 2 + 3) := by apply Finset.sum_lt_sum · intro q _ have := hLocal (extensions q).card omega · refine ⟨p, hp, ?_⟩ have H := hLocal (extensions p).card simp only [if_pos hhigh] at H omega omega intro p hp have hp' := (hmem p).mpr hp by_contra hne have hlt := Finset.sum_lt_sum hle ⟨p, hp', lt_of_le_of_ne (hle p hp') hne⟩ have hTotal' : ∑ q ∈ pairs, (extensions q).card = 3 * n.choose 2 := hTotal have hConst : ∑ _q ∈ pairs, (3 : ℕ) = 3 * n.choose 2 := by simp [hcard, Nat.mul_comm] rw [hConst, ← hTotal'] at hlt exact (lt_irrefl _) hlt theorem pair_codegrees_eq_three_of_common_link_card_le_three {n : ℕ} (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hExtremal : edges.card = n.choose 2) (hCommon : ∀ q : Finset (Fin n), q.card = 2 → (((Finset.univ : Finset (Fin n)).powersetCard 2).filter (fun p => q ⊆ Finset.univ.filter (fun x => x ∉ p ∧ insert x p ∈ edges))).card ≤ 3) : ∀ p : Finset (Fin n), p.card = 2 → (edges.filter (fun e => p ⊆ e)).card = 3 := by let extensions (p : Finset (Fin n)) := Finset.univ.filter (fun x => x ∉ p ∧ insert x p ∈ edges) let pairs := (Finset.univ : Finset (Fin n)).powersetCard 2 have card_ext (p : Finset (Fin n)) (hp : p.card = 2) : (extensions p).card = (edges.filter (fun e => p ⊆ e)).card := by refine Finset.card_bij (fun x _ => insert x p) ?_ ?_ ?_ · intro x hx exact Finset.mem_filter.mpr ⟨(Finset.mem_filter.mp hx).2.2, Finset.subset_insert _ _⟩ · intro x hx y _ h have hx' : x ∉ p := (Finset.mem_filter.mp hx).2.1 have hm : x ∈ insert y p := h ▸ Finset.mem_insert_self x p exact (Finset.mem_insert.mp hm).resolve_right hx' · intro e he obtain ⟨hee, hpe⟩ := Finset.mem_filter.mp he have hdiff : (e \ p).card = 1 := by rw [Finset.card_sdiff_of_subset hpe, hUniform e hee, hp] obtain ⟨x, hx⟩ := Finset.card_pos.mp (by omega : 0 < (e \ p).card) obtain ⟨hxe, hxp⟩ := Finset.mem_sdiff.mp hx have hxeq : insert x p = e := Finset.eq_of_subset_of_card_le (Finset.insert_subset_iff.mpr ⟨hxe, hpe⟩) (by rw [Finset.card_insert_of_notMem hxp, hp, hUniform e hee]) exact ⟨x, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hxp, hxeq ▸ hee⟩, hxeq⟩ have hTotal : ∑ p ∈ pairs, (extensions p).card = 3 * n.choose 2 := calc ∑ p ∈ pairs, (extensions p).card = ∑ p ∈ pairs, ∑ e ∈ edges, if p ⊆ e then (1 : ℕ) else 0 := by apply Finset.sum_congr rfl intro p hp rw [card_ext p (Finset.mem_powersetCard.mp hp).2, ← Finset.sum_filter (s := edges) (fun e => p ⊆ e) (fun _ => (1 : ℕ))] simp _ = ∑ e ∈ edges, ∑ p ∈ pairs, if p ⊆ e then (1 : ℕ) else 0 := Finset.sum_comm _ = ∑ e ∈ edges, (3 : ℕ) := by apply Finset.sum_congr rfl intro e he have hpair_filter : pairs.filter (fun p => p ⊆ e) = e.powersetCard 2 := by ext p simp only [pairs, Finset.mem_filter, Finset.mem_powersetCard, Finset.subset_univ, true_and] exact and_comm rw [← Finset.sum_filter (s := pairs) (fun p => p ⊆ e) (fun _ => (1 : ℕ))] simp [hpair_filter, hUniform e he] _ = 3 * n.choose 2 := by simp [hExtremal, Nat.mul_comm] intro p hp rw [← card_ext p hp] exact pair_extension_sizes_eq_three_of_common_link_card_le_three extensions hTotal hCommon p hp /-- It suffices to bound the common links, without a bound on the pair codegrees themselves. -/ theorem classify_extremal_triple_families_of_common_link_le_three {n : ℕ} (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hUnique : UniqueDisjointUnions edges) (hExtremal : edges.card = n.choose 2) (hCommon : ∀ q : Finset (Fin n), q.card = 2 → (localCoExtensions edges q).card ≤ 3) : ∃ blocks : Finset (Finset (Fin n)), SteinerFive blocks ∧ IsExpansion edges blocks := by apply classify_extremal_triple_families_of_pair_codegree_le_three edges hUniform hUnique hExtremal intro p hp exact le_of_eq (pair_codegrees_eq_three_of_common_link_card_le_three edges hUniform hExtremal hCommon p hp) /-- Any counterexample at equality has a common link that is a star of at least four edges. -/ theorem large_common_link_star_of_nonsteiner_extremal {n : ℕ} (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hUnique : UniqueDisjointUnions edges) (hExtremal : edges.card = n.choose 2) (hFailure : ¬ ∃ blocks : Finset (Finset (Fin n)), SteinerFive blocks ∧ IsExpansion edges blocks) : ∃ q : Finset (Fin n), q.card = 2 ∧ 4 ≤ (localCoExtensions edges q).card ∧ ∃ center : Fin n, ∀ p ∈ localCoExtensions edges q, center ∈ p := by classical have hlarge : ∃ q : Finset (Fin n), q.card = 2 ∧ 4 ≤ (localCoExtensions edges q).card := by by_contra! h apply hFailure exact classify_extremal_triple_families_of_common_link_le_three edges hUniform hUnique hExtremal (fun q hq => by have := h q hq; omega) obtain ⟨q, hq, hsize⟩ := hlarge refine ⟨q, hq, hsize, ?_⟩ have hpair (p : Finset (Fin n)) (hp : p ∈ localCoExtensions edges q) : p.card = 2 := (Finset.mem_powersetCard.mp (Finset.mem_filter.mp hp).1).2 rcases local_intersecting_pair_family _ hpair (fun p hp r hr => local_coextension_pairwise hUnique hq hp hr) with h | h | h · omega · exact h · obtain ⟨a,b,c,_,_,_,heq⟩ := h rw [heq] at hsize have htwo : ({{a,c},{b,c}} : Finset (Finset (Fin n))).card ≤ 2 := Finset.card_le_two have hle : ({{a,b},{a,c},{b,c}} : Finset (Finset (Fin n))).card ≤ 3 := (Finset.card_insert_le _ _).trans (by omega) omega /-- If complete five-sets cover the other vertices' pairs, the link at the remaining vertex is a matching. -/ theorem vertex_link_matching_of_full_fives_away {n : ℕ} {edges : Finset (Finset (Fin n))} {x : Fin n} (hUnique : UniqueDisjointUnions edges) (hCover : ∀ p : Finset (Fin n), p.card = 2 → x ∉ p → ∃ B : Finset (Fin n), B.card = 5 ∧ p ⊆ B ∧ x ∉ B ∧ ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) : ∀ a : Fin n, (localExtensions edges {x,a}).card ≤ 1 := by classical intro a apply Finset.card_le_one.mpr intro b hb c hc by_contra hbc have hb' := local_neighbors_ne hb have hc' := local_neighbors_ne hc let p : Finset (Fin n) := {b,c} have hp : p.card = 2 := by simp [p, hbc] obtain ⟨B, hB, hpB, hxB, hFull⟩ := hCover p hp (by simp [p, hb'.1.symm, hc'.1.symm]) have hC : (B \ p).card = 3 := by rw [Finset.card_sdiff_of_subset hpB, hB, hp] obtain ⟨q, hq, hqCard⟩ := Finset.exists_subset_card_eq (s := (B \ p).erase a) (by rw [Finset.card_erase_eq_ite, hC]; split <;> decide : 2 ≤ ((B \ p).erase a).card) have hqB : q ⊆ B := hq.trans ((Finset.erase_subset _ _).trans Finset.sdiff_subset) have hqdisj : Disjoint ({x,a} : Finset (Fin n)) q := by rw [Finset.disjoint_insert_left, Finset.disjoint_singleton_left] exact ⟨fun h => hxB (hqB h), fun h => Finset.notMem_erase a _ (hq h)⟩ have hq_ext : p ⊆ localExtensions edges q := by intro z hz have hzq : z ∉ q := fun h => (Finset.mem_sdiff.mp (Finset.mem_erase.mp (hq h)).2).2 hz exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, hzq, hFull _ (by rw [Finset.card_insert_of_notMem hzq, hqCard]) (Finset.insert_subset (hpB hz) hqB)⟩ have hsub : p ⊆ localExtensions edges {x,a} ∩ localExtensions edges q := by intro z hz exact Finset.mem_inter.mpr ⟨(Finset.insert_subset_iff.mpr ⟨hb, Finset.singleton_subset_iff.mpr hc⟩ : p ⊆ localExtensions edges {x,a}) hz, hq_ext hz⟩ have := (Finset.card_le_card hsub).trans (disjoint_pair_common_extensions_card_le_one hUnique (Finset.insert_nonempty x {a}) hqdisj) omega /-- A pair in a complete five-set has exactly the three common supporting pairs on the remaining vertices of that five-set. -/ theorem full_five_pair_common_link_eq {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {B p : Finset (Fin n)} (hB : B.card = 5) (hp : p.card = 2) (hpB : p ⊆ B) (hFull : ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) : localCoExtensions edges p = (B \ p).powersetCard 2 := by classical have hR : (B \ p).card = 3 := by rw [Finset.card_sdiff_of_subset hpB,hB,hp] have hm : (B \ p).powersetCard 2 ⊆ localCoExtensions edges p := by intro q hq obtain ⟨hqr,hq2⟩ := Finset.mem_powersetCard.mp hq apply local_mem_coextensions.mpr refine ⟨hq2,?_⟩ intro x hx have hxq : x ∉ q := fun h => (Finset.mem_sdiff.mp (hqr h)).2 hx exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hxq, hFull _ (by rw [Finset.card_insert_of_notMem hxq,hq2]) (Finset.insert_subset (hpB hx) (hqr.trans Finset.sdiff_subset))⟩ apply Finset.Subset.antisymm _ hm intro q hq have hq2 := (local_mem_coextensions.mp hq).1 apply Finset.mem_powersetCard.mpr refine ⟨?_,hq2⟩ by_contra hn obtain ⟨z,hz,hzR⟩ := Finset.not_subset.mp hn have hs : q ∩ (B \ p) ⊆ q.erase z := by intro a ha obtain ⟨haq,haR⟩ := Finset.mem_inter.mp ha exact Finset.mem_erase.mpr ⟨fun h => hzR (h ▸ haR),haq⟩ have hi := Finset.card_le_card hs rw [Finset.card_erase_of_mem hz,hq2] at hi have hS : 2 ≤ ((B \ p) \ q).card := by have he := Finset.card_sdiff_add_card_inter (B \ p) q rw [Finset.inter_comm (B \ p) q,hR] at he omega obtain ⟨r,hr,hr2⟩ := Finset.exists_subset_card_eq hS have hrR : r ∈ (B \ p).powersetCard 2 := Finset.mem_powersetCard.mpr ⟨hr.trans Finset.sdiff_subset,hr2⟩ have hdis : Disjoint q r := Finset.disjoint_left.mpr (fun x hx hx' => (Finset.mem_sdiff.mp (hr hx')).2 hx) exact local_coextension_pairwise hu hp hq (hm hrR) hdis /-- An external vertex extends at most one pair in a complete five-set. -/ theorem full_five_external_support_unique {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {B p q : Finset (Fin n)} {x : Fin n} (hB : B.card = 5) (hFull : ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hx : x ∉ B) (hp : p.card = 2) (hq : q.card = 2) (hpB : p ⊆ B) (hqB : q ⊆ B) (hxp : insert x p ∈ edges) (hxq : insert x q ∈ edges) : p = q := by classical have ext_in_block {z : Fin n} {r : Finset (Fin n)} (hr : r.card = 2) (hrB : r ⊆ B) (hzB : z ∈ B) (hzr : z ∉ r) : z ∈ localExtensions edges r := Finset.mem_filter.mpr ⟨Finset.mem_univ _, hzr, hFull _ (by rw [Finset.card_insert_of_notMem hzr, hr]) (Finset.insert_subset hzB hrB)⟩ have ext_x {r : Finset (Fin n)} (hrB : r ⊆ B) (hr : insert x r ∈ edges) : x ∈ localExtensions edges r := Finset.mem_filter.mpr ⟨Finset.mem_univ _, fun h => hx (hrB h), hr⟩ by_cases hpq : Disjoint p q · obtain ⟨z, hz⟩ := Finset.card_pos.mp (show 0 < (B \ (p ∪ q)).card by rw [Finset.card_sdiff_of_subset (Finset.union_subset hpB hqB), hB, Finset.card_union_of_disjoint hpq, hp, hq] decide) obtain ⟨hzB, hzp, hzq⟩ := (show z ∈ B ∧ z ∉ p ∧ z ∉ q by simpa using hz) exact (local_extension_edges_cross hu hp hq (c := x) (d := z) (fun h => hx (h ▸ hzB)) (ext_x hpB hxp) (ext_in_block hp hpB hzB hzp) (ext_x hqB hxq) (ext_in_block hq hqB hzB hzq) hpq).elim · obtain ⟨a,ha,ha'⟩ := Finset.not_disjoint_iff.mp hpq obtain ⟨b,hba,rfl⟩ := local_pair_with_center hp ha obtain ⟨c,hca,rfl⟩ := local_pair_with_center hq ha' by_cases hbc : b = c · subst c rfl exfalso let T : Finset (Fin n) := {a,b,c} have hT : T.card = 3 := by simp [T,hba.symm,hca.symm,hbc] have haB := hpB (Finset.mem_insert_self a {b}) have hbB := hpB (Finset.mem_insert_of_mem (Finset.mem_singleton_self b)) have hcB := hqB (Finset.mem_insert_of_mem (Finset.mem_singleton_self c)) have hTB : T ⊆ B := Finset.insert_subset haB (Finset.insert_subset hbB (Finset.singleton_subset_iff.mpr hcB)) have hR : (B \ T).card = 2 := by rw [Finset.card_sdiff_of_subset hTB,hB,hT] have hxa : x ≠ a := fun h => hx (h ▸ haB) have hb : b ∈ localExtensions edges {x,a} := by rw [local_neighbors_comm (a := x) (b := a)] exact local_neighbors_symm hba.symm (ext_x hpB hxp) have hc : c ∈ localExtensions edges {x,a} := by rw [local_neighbors_comm (a := x) (b := a)] exact local_neighbors_symm hca.symm (ext_x hqB hxq) have hdis : Disjoint ({x,a} : Finset (Fin n)) (B \ T) := by rw [Finset.disjoint_insert_left, Finset.disjoint_singleton_left] exact ⟨fun h => hx (Finset.mem_sdiff.mp h).1, by simp [T]⟩ exact local_extension_edges_cross hu (by simp [hxa]) hR hbc hb hc (ext_in_block hR Finset.sdiff_subset hbB (by simp [T])) (ext_in_block hR Finset.sdiff_subset hcB (by simp [T])) hdis /-- An oriented missing pair can arise from at most one external extension of a block pair. -/ theorem full_five_external_support_of_missing_pair_unique {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {B C p q : Finset (Fin n)} {x z : Fin n} (hB : B.card = 5) (hC : C.card = 5) (hFullB : ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hFullC : ∀ t, t.card = 3 → t ⊆ C → t ∈ edges) (hp : p.card = 2) (hq : q.card = 2) (hpB : p ⊆ B) (hqC : q ⊆ C) (hxB : x ∉ B) (hxC : x ∉ C) (hzB : z ∈ B) (hzC : z ∈ C) (hzp : z ∉ p) (hzq : z ∉ q) (hxp : insert x p ∈ edges) (hxq : insert x q ∈ edges) : B = C ∧ p = q := by classical have hBC : B = C := by by_contra hn have hdis : Disjoint p q := by apply Finset.disjoint_left.mpr intro a ha hqa have haz : a ≠ z := fun h => hzp (h ▸ ha) exact hn (full_five_eq_of_common_pair hu hB hC (p := {a,z}) (by simp [haz]) (Finset.insert_subset (hpB ha) (Finset.singleton_subset_iff.mpr hzB)) (Finset.insert_subset (hqC hqa) (Finset.singleton_subset_iff.mpr hzC)) hFullB hFullC) apply local_extension_edges_cross hu hp hq (c := x) (d := z) (fun h => hxB (h ▸ hzB)) _ _ _ _ hdis · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, fun h => hxB (hpB h), hxp⟩ · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, hzp, hFullB _ (by rw [Finset.card_insert_of_notMem hzp,hp]) (Finset.insert_subset hzB hpB)⟩ · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, fun h => hxC (hqC h), hxq⟩ · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _, hzq, hFullC _ (by rw [Finset.card_insert_of_notMem hzq,hq]) (Finset.insert_subset hzC hqC)⟩ subst C exact ⟨rfl, full_five_external_support_unique hu hB hFullB hxB hp hq hpB hqC hxp hxq⟩ /-- Opposite charges at one pair force a second block pair in each extra triple. -/ theorem full_five_opposite_charges_intersect {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {B C p q : Finset (Fin n)} {x z : Fin n} (hFullB : ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hFullC : ∀ t, t.card = 3 → t ⊆ C → t ∈ edges) (hp : p.card = 2) (hq : q.card = 2) (hpB : p ⊆ B) (hqC : q ⊆ C) (hxB : x ∉ B) (hzC : z ∉ C) (hzB : z ∈ B) (hxC : x ∈ C) (hzp : z ∉ p) (hxq : x ∉ q) (hxp : insert x p ∈ edges) (hzq : insert z q ∈ edges) : ∃ w ∈ p ∩ q, ({x,w} : Finset (Fin n)) ⊆ C ∧ ({z,w} : Finset (Fin n)) ⊆ B := by have hne : x ≠ z := fun h => hxB (h ▸ hzB) have hnot : ¬ Disjoint p q := by apply local_extension_edges_cross hu hp hq hne · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,fun h => hxB (hpB h),hxp⟩ · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hzp, hFullB _ (by rw [Finset.card_insert_of_notMem hzp,hp]) (Finset.insert_subset hzB hpB)⟩ · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hxq, hFullC _ (by rw [Finset.card_insert_of_notMem hxq,hq]) (Finset.insert_subset hxC hqC)⟩ · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,fun h => hzC (hqC h),hzq⟩ obtain ⟨w,hwp,hwq⟩ := Finset.not_disjoint_iff.mp hnot exact ⟨w,Finset.mem_inter.mpr ⟨hwp,hwq⟩, Finset.insert_subset hxC (Finset.singleton_subset_iff.mpr (hqC hwq)), Finset.insert_subset hzB (Finset.singleton_subset_iff.mpr (hpB hwp))⟩ /-- Extra triples with a block pair are sparse relative to pairs in no block. -/ theorem full_five_external_extension_count {n : ℕ} {edges blocks : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hblocks : ∀ B ∈ blocks, B.card = 5 ∧ ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) : let extra := blocks.sigma (fun B => (B.powersetCard 2).sigma (fun p => localExtensions edges p \ B)) let missing := ((Finset.univ : Finset (Fin n)).powersetCard 2).filter (fun p => ¬ ∃ B ∈ blocks, p ⊆ B) 3 * extra.card ≤ 2 * missing.card := by classical dsimp only let extra := blocks.sigma (fun B => (B.powersetCard 2).sigma (fun p => localExtensions edges p \ B)) let missing := ((Finset.univ : Finset (Fin n)).powersetCard 2).filter (fun p => ¬ ∃ B ∈ blocks, p ⊆ B) change 3 * extra.card ≤ 2 * missing.card let charged := extra.sigma (fun e => e.1 \ e.2.1) have data {e : Sigma (fun _ : Finset (Fin n) => Sigma (fun _ : Finset (Fin n) => Fin n))} (he : e ∈ extra) : e.1 ∈ blocks ∧ e.2.1 ⊆ e.1 ∧ e.2.1.card = 2 ∧ e.2.2 ∉ e.1 ∧ insert e.2.2 e.2.1 ∈ edges := by obtain ⟨hB,hm⟩ := Finset.mem_sigma.mp he obtain ⟨hp,hx⟩ := Finset.mem_sigma.mp hm obtain ⟨hpB,hp2⟩ := Finset.mem_powersetCard.mp hp obtain ⟨hxe,hxn⟩ := Finset.mem_sdiff.mp hx exact ⟨hB,hpB,hp2,hxn,(Finset.mem_filter.mp hxe).2.2⟩ have hcount : charged.card = 3 * extra.card := by rw [Finset.card_sigma] calc _ = ∑ _e ∈ extra, (3 : ℕ) := Finset.sum_congr rfl (by intro e he obtain ⟨hB,hpB,hp2,_,_⟩ := data he rw [Finset.card_sdiff_of_subset hpB,(hblocks _ hB).1,hp2]) _ = _ := by simp [Nat.mul_comm] let f := fun z : Sigma (fun _ : Sigma (fun _ : Finset (Fin n) => Sigma (fun _ : Finset (Fin n) => Fin n)) => Fin n) => ({z.1.2.2,z.2} : Finset (Fin n)) have hmap : ∀ i ∈ charged, f i ∈ missing := by intro i hi obtain ⟨he,hz⟩ := Finset.mem_sigma.mp hi obtain ⟨hB,hpB,hp2,hxn,hxp⟩ := data he obtain ⟨hzB,hzp⟩ := Finset.mem_sdiff.mp hz have hxz : i.1.2.2 ≠ i.2 := fun h => hxn (h.symm ▸ hzB) apply Finset.mem_filter.mpr refine ⟨by simp [f,hxz],?_⟩ rintro ⟨C,hC,hfC⟩ exact five_blocks_exclude_a_cross_pair hu (hblocks _ hB).1 (hblocks _ hC).1 hp2 hpB (hblocks _ hB).2 (hblocks _ hC).2 hxn hzB hzp hxp (hfC (Finset.mem_insert_self _ _)) (hfC (Finset.mem_insert_of_mem (Finset.mem_singleton_self _))) have hbound : charged.card ≤ 2 * missing.card := by apply Finset.card_le_mul_card_image_of_maps_to (f := f) hmap 2 intro p hp have hp2 := (Finset.mem_powersetCard.mp (Finset.mem_filter.mp hp).1).2 rw [← hp2] apply Finset.card_le_card_of_injOn (fun z => z.1.2.2) · intro z hz have hfz := (Finset.mem_filter.mp hz).2 exact hfz ▸ Finset.mem_insert_self _ _ · rintro ⟨⟨B,P,x⟩,z⟩ hi ⟨⟨C,Q,y⟩,w⟩ hj heq change x = y at heq subst y obtain ⟨hi,hfi⟩ := Finset.mem_filter.mp hi obtain ⟨hj,hfj⟩ := Finset.mem_filter.mp hj obtain ⟨he,hz⟩ := Finset.mem_sigma.mp hi obtain ⟨he',hw⟩ := Finset.mem_sigma.mp hj obtain ⟨hB,hPB,hP,hxB,hxp⟩ := data he obtain ⟨hC,hQC,hQ,hxC,hxq⟩ := data he' obtain ⟨hzB,hzP⟩ := Finset.mem_sdiff.mp hz obtain ⟨hwC,hwQ⟩ := Finset.mem_sdiff.mp hw have hz_ne : z ≠ x := fun h => hxB (h ▸ hzB) have hzw : z = w := by have hf : ({x,z} : Finset (Fin n)) = {x,w} := hfi.trans hfj.symm have hm : z ∈ ({x,w} : Finset (Fin n)) := hf ▸ (Finset.mem_insert_of_mem (Finset.mem_singleton_self z) : z ∈ ({x,z} : Finset (Fin n))) exact Finset.mem_singleton.mp ((Finset.mem_insert.mp hm).resolve_left hz_ne) subst w obtain ⟨rfl,rfl⟩ := full_five_external_support_of_missing_pair_unique hu (hblocks _ hB).1 (hblocks _ hC).1 (hblocks _ hB).2 (hblocks _ hC).2 hP hQ hPB hQC hxB hxC hzB hwC hzP hwQ hxp hxq rfl omega /-- A pair inside a complete five-set is absent from every common link of the family of triples avoiding its pairs. -/ theorem full_five_pair_common_link_empty_in_residual {n : ℕ} {edges residual : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hsub : residual ⊆ edges) {B p : Finset (Fin n)} (hB : B.card = 5) (hFull : ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hp : p.card = 2) (hpB : p ⊆ B) (hResidual : ∀ t ∈ residual, (t ∩ B).card ≤ 1) : localCoExtensions residual p = ∅ := by classical apply Finset.eq_empty_iff_forall_notMem.mpr intro q hq obtain ⟨hq2,hpq⟩ := local_mem_coextensions.mp hq have hex {x : Fin n} (hx : x ∈ localExtensions residual q) : x ∈ localExtensions edges q := by obtain ⟨_,hn,he⟩ := Finset.mem_filter.mp hx exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hn,hsub he⟩ have hcard : ((B \ p) \ q).card ≥ 2 := by obtain ⟨x,hx⟩ := Finset.card_pos.mp (show 0 < p.card by omega) obtain ⟨_,hxq,hxr⟩ := Finset.mem_filter.mp (hpq hx) have hqB : Disjoint q B := Finset.disjoint_left.mpr (by intro z hzq hzB have hzx : z ≠ x := fun h => hxq (h ▸ hzq) have hpair : ({z,x} : Finset (Fin n)) ⊆ insert x q ∩ B := Finset.insert_subset (Finset.mem_inter.mpr ⟨Finset.mem_insert_of_mem hzq,hzB⟩) (Finset.singleton_subset_iff.mpr (Finset.mem_inter.mpr ⟨Finset.mem_insert_self _ _,hpB hx⟩)) have hc := Finset.card_le_card hpair have hle := hResidual _ hxr simp only [Finset.card_pair hzx] at hc omega) have heq : (B \ p) \ q = B \ p := by ext z simp only [Finset.mem_sdiff] exact ⟨And.left, fun hz => ⟨hz, fun hzq => Finset.disjoint_left.mp hqB hzq hz.1⟩⟩ rw [heq,Finset.card_sdiff_of_subset hpB,hB,hp] decide obtain ⟨r,hr,hr2⟩ := Finset.exists_subset_card_eq hcard have hrB : r ⊆ B := hr.trans (Finset.sdiff_subset.trans Finset.sdiff_subset) have hpr : p ⊆ localExtensions edges r := by intro x hx have hxr : x ∉ r := fun h => (Finset.mem_sdiff.mp (Finset.mem_sdiff.mp (hr h)).1).2 hx apply Finset.mem_filter.mpr exact ⟨Finset.mem_univ _,hxr, hFull _ (by rw [Finset.card_insert_of_notMem hxr,hr2]) (Finset.insert_subset (hpB hx) hrB)⟩ have hrq : Disjoint q r := Finset.disjoint_left.mpr (by intro z hz hzr exact (Finset.mem_sdiff.mp (hr hzr)).2 hz) exact local_coextension_pairwise hu hp (local_mem_coextensions.mpr ⟨hq2,fun _ hx => hex (hpq hx)⟩) (local_mem_coextensions.mpr ⟨hr2,hpr⟩) hrq /-- An extra extension (x) of a block pair gives no residual common link between (x) and an unused vertex (z) of that block. -/ theorem full_five_external_charge_common_link_empty {n : ℕ} {edges residual : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hsub : residual ⊆ edges) {B p : Finset (Fin n)} {x z : Fin n} (hFull : ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hp : p.card = 2) (hpB : p ⊆ B) (hxB : x ∉ B) (hzB : z ∈ B) (hzp : z ∉ p) (hxp : insert x p ∈ edges) (hResidual : ∀ t ∈ residual, (t ∩ B).card ≤ 1) : localCoExtensions residual {x,z} = ∅ := by classical apply Finset.eq_empty_iff_forall_notMem.mpr intro q hq have hxz : x ≠ z := fun h => hxB (h ▸ hzB) obtain ⟨hq2,hqext⟩ := local_mem_coextensions.mp hq have hxq := hqext (Finset.mem_insert_self x ({z} : Finset (Fin n))) have hzq := hqext (Finset.mem_insert_of_mem (Finset.mem_singleton_self z)) obtain ⟨_,hzqn,hzqe⟩ := Finset.mem_filter.mp hzq have hqDis : Disjoint p q := Finset.disjoint_left.mpr (by intro a hap haq have haz : a ≠ z := fun h => hzp (h ▸ hap) have hs : ({a,z} : Finset (Fin n)) ⊆ insert z q ∩ B := Finset.insert_subset (Finset.mem_inter.mpr ⟨Finset.mem_insert_of_mem haq,hpB hap⟩) (Finset.singleton_subset_iff.mpr (Finset.mem_inter.mpr ⟨Finset.mem_insert_self _ _,hzB⟩)) have hc := Finset.card_le_card hs have hd := hResidual _ hzqe simp only [Finset.card_pair haz] at hc omega) obtain ⟨_,hxqn,hxqe⟩ := Finset.mem_filter.mp hxq apply local_extension_edges_cross hu hp hq2 hxz _ _ _ _ hqDis · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,fun h => hxB (hpB h),hxp⟩ · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hzp, hFull _ (by rw [Finset.card_insert_of_notMem hzp,hp]) (Finset.insert_subset hzB hpB)⟩ · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hxqn,hsub hxqe⟩ · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hzqn,hsub hzqe⟩ /-- Each triple outside the complete blocks that meets a block in a pair provides three distinct pairs with empty common links in the residual family. -/ theorem full_five_external_edge_count {n : ℕ} {edges blocks residual : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hsub : residual ⊆ edges) (hUniform : ∀ e ∈ edges, e.card = 3) (hblocks : ∀ B ∈ blocks, B.card = 5 ∧ ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hr : ∀ t ∈ residual, ∀ B ∈ blocks, (t ∩ B).card ≤ 1) : let extra := edges.filter (fun e => (∃ B ∈ blocks, 2 ≤ (e ∩ B).card) ∧ ∀ B ∈ blocks, ¬ e ⊆ B) let missing := ((Finset.univ : Finset (Fin n)).powersetCard 2).filter (fun p => (∀ B ∈ blocks, ¬ p ⊆ B) ∧ localCoExtensions residual p = ∅) 3 * extra.card ≤ missing.card := by classical dsimp only let extra := edges.filter (fun e => (∃ B ∈ blocks, 2 ≤ (e ∩ B).card) ∧ ∀ B ∈ blocks, ¬ e ⊆ B) let missing := ((Finset.univ : Finset (Fin n)).powersetCard 2).filter (fun p => (∀ B ∈ blocks, ¬ p ⊆ B) ∧ localCoExtensions residual p = ∅) change 3 * extra.card ≤ missing.card let rank := Fintype.equivFin (Finset (Fin n)) have hchoose (e : Finset (Fin n)) (he : e ∈ extra) : ∃ B ∈ blocks, 2 ≤ (e ∩ B).card ∧ ∀ C ∈ blocks, 2 ≤ (e ∩ C).card → rank B ≤ rank C := by obtain ⟨C,hC,hc⟩ := (Finset.mem_filter.mp he).2.1 obtain ⟨B,hB,hmin⟩ := Finset.exists_min_image (blocks.filter (fun B => 2 ≤ (e ∩ B).card)) rank ⟨C,Finset.mem_filter.mpr ⟨hC,hc⟩⟩ obtain ⟨hBb,hBc⟩ := Finset.mem_filter.mp hB exact ⟨B,hBb,hBc,fun C hC hCc => hmin C (Finset.mem_filter.mpr ⟨hC,hCc⟩)⟩ have hdata (e : Finset (Fin n)) (he : e ∈ extra) : ∃ (B p : Finset (Fin n)) (x : Fin n), B ∈ blocks ∧ p ⊆ B ∧ p.card = 2 ∧ x ∉ B ∧ insert x p = e ∧ (∀ C ∈ blocks, 2 ≤ (e ∩ C).card → rank B ≤ rank C) := by obtain ⟨B,hB,hBc,hmin⟩ := hchoose e he obtain ⟨heen,_,hn⟩ := Finset.mem_filter.mp he obtain ⟨x,hxe,hxB⟩ := Finset.not_subset.mp (hn B hB) let p := e ∩ B have hxp : x ∉ p := fun h => hxB (Finset.mem_inter.mp h).2 have hs : insert x p ⊆ e := Finset.insert_subset hxe Finset.inter_subset_left have hc := Finset.card_le_card hs rw [Finset.card_insert_of_notMem hxp,hUniform _ heen] at hc have hp : p.card = 2 := by change 2 ≤ p.card at hBc omega refine ⟨B,p,x,hB,Finset.inter_subset_right,hp,hxB,?_,hmin⟩ exact Finset.eq_of_subset_of_card_le hs (by rw [Finset.card_insert_of_notMem hxp,hp,hUniform _ heen]) choose block pair tip hs using hdata let charges := extra.attach.sigma (fun e => block e.1 e.2 \ pair e.1 e.2) let f := fun i : Sigma (fun _ : {e // e ∈ extra} => Fin n) => ({tip i.1.1 i.1.2, i.2} : Finset (Fin n)) have hc : charges.card = 3 * extra.card := by rw [Finset.card_sigma] calc _ = ∑ _ ∈ extra.attach, (3 : ℕ) := Finset.sum_congr rfl (by intro e _ obtain ⟨hB,hpB,hp,_,_,_⟩ := hs e.1 e.2 rw [Finset.card_sdiff_of_subset hpB,(hblocks _ hB).1,hp]) _ = _ := by simp [Nat.mul_comm] have hmap : ∀ i ∈ charges, f i ∈ missing := by intro i hi obtain ⟨hB,hpB,hp,hxB,he,_⟩ := hs i.1.1 i.1.2 obtain ⟨hzB,hzp⟩ := Finset.mem_sdiff.mp (Finset.mem_sigma.mp hi).2 have hxz : tip i.1.1 i.1.2 ≠ i.2 := fun h => hxB (h.symm ▸ hzB) have hedge := he ▸ (Finset.mem_filter.mp i.1.2).1 refine Finset.mem_filter.mpr ⟨by simp [f,hxz],?_,?_⟩ · intro C hC hpC exact five_blocks_exclude_a_cross_pair hu (hblocks _ hB).1 (hblocks _ hC).1 hp hpB (hblocks _ hB).2 (hblocks _ hC).2 hxB hzB hzp hedge (hpC (Finset.mem_insert_self _ _)) (hpC (Finset.mem_insert_of_mem (Finset.mem_singleton_self _))) · exact full_five_external_charge_common_link_empty hu hsub (hblocks _ hB).2 hp hpB hxB hzB hzp hedge (fun t ht => hr t ht _ hB) have hinj : Set.InjOn f (↑charges : Set (Sigma (fun _ : {e // e ∈ extra} => Fin n))) := by rintro ⟨a,z⟩ ha ⟨b,w⟩ hb hf obtain ⟨hA,hpA,hp,hxA,hea,hminA⟩ := hs a.1 a.2 obtain ⟨hB,hqB,hq,hyB,heb,hminB⟩ := hs b.1 b.2 obtain ⟨hzA,hzp⟩ := Finset.mem_sdiff.mp (Finset.mem_sigma.mp ha).2 obtain ⟨hwB,hwq⟩ := Finset.mem_sdiff.mp (Finset.mem_sigma.mp hb).2 have hxz : tip a.1 a.2 ≠ z := fun h => hxA (h.symm ▸ hzA) have hxe := Eq.mpr (congrArg (fun t => t ∈ edges) hea) (Finset.mem_filter.mp a.2).1 have hye := Eq.mpr (congrArg (fun t => t ∈ edges) heb) (Finset.mem_filter.mp b.2).1 change ({tip a.1 a.2,z} : Finset (Fin n)) = {tip b.1 b.2,w} at hf have hxm : tip a.1 a.2 ∈ ({tip b.1 b.2,w} : Finset (Fin n)) := hf ▸ Finset.mem_insert_self _ _ have hzm : z ∈ ({tip b.1 b.2,w} : Finset (Fin n)) := hf ▸ (Finset.mem_insert_of_mem (Finset.mem_singleton_self z) : z ∈ ({tip a.1 a.2,z} : Finset (Fin n))) rcases Finset.mem_insert.mp hxm with hxy | hxw · have hzw := Finset.mem_singleton.mp ((Finset.mem_insert.mp hzm).resolve_left (fun h => hxz (hxy.trans h.symm))) subst w have hyEq : tip b.1 b.2 = tip a.1 a.2 := hxy.symm rw [hyEq] at hyB heb hye have hpair := (full_five_external_support_of_missing_pair_unique hu (hblocks _ hA).1 (hblocks _ hB).1 (hblocks _ hA).2 (hblocks _ hB).2 hp hq hpA hqB hxA hyB hzA hwB hzp hwq hxe hye).2 have hab : a = b := Subtype.ext (hea.symm.trans ((congrArg (insert (tip a.1 a.2)) hpair).trans heb)) subst b rfl · have hxw := Finset.mem_singleton.mp hxw have hzy := (Finset.mem_insert.mp hzm).resolve_right (fun h => hxz (hxw.trans (Finset.mem_singleton.mp h).symm)) have hxeq : tip a.1 a.2 = w := hxw have hyeq : tip b.1 b.2 = z := hzy.symm rw [hxeq] at hxA hea hxe rw [hyeq] at hyB heb hye obtain ⟨v,hv,hvB,hvA⟩ := full_five_opposite_charges_intersect hu (hblocks _ hA).2 (hblocks _ hB).2 hp hq hpA hqB hxA hyB hzA hwB hzp hwq hxe hye obtain ⟨hvp,hvq⟩ := Finset.mem_inter.mp hv have hwa : w ≠ v := fun h => hxA (h.symm ▸ hpA hvp) have hzb : z ≠ v := fun h => hyB (h.symm ▸ hqB hvq) have hca : 2 ≤ (a.1 ∩ block b.1 b.2).card := by have hh : ({w,v} : Finset (Fin n)) ⊆ a.1 ∩ block b.1 b.2 := by rw [← hea] exact Finset.subset_inter (Finset.insert_subset (Finset.mem_insert_self _ _) (Finset.singleton_subset_iff.mpr (Finset.mem_insert_of_mem hvp))) hvB simpa [hwa] using Finset.card_le_card hh have hcb : 2 ≤ (b.1 ∩ block a.1 a.2).card := by have hh : ({z,v} : Finset (Fin n)) ⊆ b.1 ∩ block a.1 a.2 := by rw [← heb] exact Finset.subset_inter (Finset.insert_subset (Finset.mem_insert_self _ _) (Finset.singleton_subset_iff.mpr (Finset.mem_insert_of_mem hvq))) hvA simpa [hzb] using Finset.card_le_card hh have heq := rank.injective (le_antisymm (hminA _ hB hca) (hminB _ hA hcb)) exact (hxA (heq ▸ hwB)).elim rw [← hc] exact Finset.card_le_card_of_injOn f hmap hinj /-- Counting each edge from its three constituent pairs. -/ theorem sum_local_extensions_card {n : ℕ} (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) : ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, (localExtensions edges p).card = 3 * edges.card := by classical let pairs := (Finset.univ : Finset (Fin n)).powersetCard 2 have hcard (p : Finset (Fin n)) (hp : p.card = 2) : (localExtensions edges p).card = (edges.filter (fun e => p ⊆ e)).card := by obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp have hEq (c : Fin n) : insert c ({a,b} : Finset (Fin n)) = {a,b,c} := by ext x simp only [Finset.mem_insert, Finset.mem_singleton] tauto simpa only [localExtensions, hEq] using extension_card_eq_pair_filter_card edges hUniform hab calc _ = ∑ p ∈ pairs, ∑ e ∈ edges, if p ⊆ e then (1 : ℕ) else 0 := by apply Finset.sum_congr rfl intro p hp rw [hcard p (Finset.mem_powersetCard.mp hp).2, ← Finset.sum_filter] simp _ = ∑ e ∈ edges, ∑ p ∈ pairs, if p ⊆ e then (1 : ℕ) else 0 := Finset.sum_comm _ = ∑ e ∈ edges, (3 : ℕ) := by apply Finset.sum_congr rfl intro e he have hfilter : pairs.filter (fun p => p ⊆ e) = e.powersetCard 2 := by ext p simp only [pairs, Finset.mem_filter, Finset.mem_powersetCard, Finset.subset_univ, true_and] exact and_comm rw [← Finset.sum_filter, hfilter] simp [hUniform e he] _ = 3 * edges.card := by simp [Nat.mul_comm] theorem shadow_bound_counterexample : ∃ edges : Finset (Finset (Fin 12)), (∀ e ∈ edges, e.card = 3) ∧ UniqueDisjointUnions edges ∧ ((Finset.univ.powersetCard 2).filter (fun p => ∃ e ∈ edges, p ⊆ e)).card < edges.card := by let edges : Finset (Finset (Fin 12)) := {{0, 1, 3}, {0, 1, 4}, {0, 1, 5}, {0, 3, 4}, {0, 3, 5}, {0, 4, 5}, {1, 3, 4}, {1, 3, 5}, {1, 4, 5}, {3, 4, 5}, {1, 2, 6}, {1, 2, 7}, {1, 2, 8}, {1, 6, 7}, {1, 6, 8}, {1, 7, 8}, {2, 6, 7}, {2, 6, 8}, {2, 7, 8}, {6, 7, 8}, {0, 2, 9}, {0, 2, 10}, {0, 2, 11}, {0, 9, 10}, {0, 9, 11}, {0, 10, 11}, {2, 9, 10}, {2, 9, 11}, {2, 10, 11}, {9, 10, 11}, {0, 1, 2}} let covered : Finset (Finset (Fin 12)) := {{0, 1}, {0, 3}, {0, 4}, {0, 5}, {1, 3}, {1, 4}, {1, 5}, {3, 4}, {3, 5}, {4, 5}, {1, 2}, {1, 6}, {1, 7}, {1, 8}, {2, 6}, {2, 7}, {2, 8}, {6, 7}, {6, 8}, {7, 8}, {0, 2}, {0, 9}, {0, 10}, {0, 11}, {2, 9}, {2, 10}, {2, 11}, {9, 10}, {9, 11}, {10, 11}} let mask (e : Finset (Fin 12)) : BitVec 12 := (BitVec.ofBoolListLE ((List.finRange 12).map fun v => decide (v ∈ e))).cast (by simp) let masks : List (BitVec 12) := [11, 19, 35, 25, 41, 49, 26, 42, 50, 56, 70, 134, 262, 194, 322, 386, 196, 324, 388, 448, 517, 1029, 2053, 1537, 2561, 3073, 1540, 2564, 3076, 3584, 7] have hUniform : ∀ e ∈ edges, e.card = 3 := by simp only [edges, Finset.forall_mem_insert, Finset.mem_singleton, forall_eq] repeat' apply And.intro <;> decide have hCovered : ∀ e ∈ edges, e.powersetCard 2 ⊆ covered := by simp only [edges, Finset.forall_mem_insert, Finset.mem_singleton, forall_eq] repeat' apply And.intro all_goals (dsimp only [covered]; decide +kernel) have hValid : ∀ e ∈ edges, mask e ∈ masks := by simp only [edges, Finset.forall_mem_insert, Finset.mem_singleton, forall_eq] repeat' apply And.intro all_goals (dsimp only [masks, mask]; decide +kernel) have hMask (e : Finset (Fin 12)) (i : Fin 12) : (mask e).getLsbD i = decide (i ∈ e) := by unfold mask rw [BitVec.getLsbD_cast, BitVec.getLsbD_ofBoolListLE] simp [List.getD_eq_getElem?_getD, i.isLt] have hInj : Function.Injective mask := by intro e f h ext v exact decide_eq_decide.mp (by rw [← hMask, ← hMask, h]) have hUnion (e f : Finset (Fin 12)) : mask (e ∪ f) = mask e ||| mask f := by apply BitVec.eq_of_getLsbD_eq intro i hi let v : Fin 12 := ⟨i, hi⟩ change (mask (e ∪ f)).getLsbD v = (mask e ||| mask f).getLsbD v rw [BitVec.getLsbD_or, hMask, hMask, hMask] simp have hDisj {e f : Finset (Fin 12)} (h : Disjoint e f) : mask e &&& mask f = 0 := by apply BitVec.eq_of_getLsbD_eq intro i hi let v : Fin 12 := ⟨i, hi⟩ change (mask e &&& mask f).getLsbD v = (0 : BitVec 12).getLsbD v rw [BitVec.getLsbD_and, hMask, hMask] by_cases he : v ∈ e · have hf : v ∉ f := fun hf => Finset.disjoint_left.mp h he hf simp [he, hf] · simp [he] let disjointPairs := masks.flatMap fun a => (masks.filter fun b => decide (a.toNat < b.toNat) && (a &&& b == 0)).map (fun b => (a, b)) let unionMask (p : BitVec 12 × BitVec 12) := p.1 ||| p.2 have hCertificate : (disjointPairs.map unionMask).Nodup := by dsimp only [disjointPairs, masks, unionMask] decide +kernel have hPair {a b : BitVec 12} (ha : a ∈ masks) (hb : b ∈ masks) (hab : a &&& b = 0) (hlt : a.toNat < b.toNat) : (a, b) ∈ disjointPairs := by refine List.mem_flatMap.mpr ⟨a, ha, List.mem_map.mpr ⟨b, ?_, rfl⟩⟩ exact List.mem_filter.mpr ⟨hb, by simp [hlt, hab]⟩ have hNonzero : (0 : BitVec 12) ∉ masks := by dsimp only [masks] decide +kernel have hNe {a b : BitVec 12} (ha : a ∈ masks) (hab : a &&& b = 0) : a.toNat ≠ b.toNat := by intro heq have he := BitVec.eq_of_toNat_eq heq subst b have hz : a = 0 := by simpa using hab exact hNonzero (hz ▸ ha) have hCertificateEq {a b c d : BitVec 12} (hab : (a, b) ∈ disjointPairs) (hcd : (c, d) ∈ disjointPairs) (hu : a ||| b = c ||| d) : a = c ∧ b = d := by exact Prod.mk.inj (List.inj_on_of_nodup_map hCertificate hab hcd hu) have hBV (a b c d : BitVec 12) (ha : a ∈ masks) (hb : b ∈ masks) (hc : c ∈ masks) (hd : d ∈ masks) (hab : a &&& b = 0) (hcd : c &&& d = 0) (hu : a ||| b = c ||| d) : (a = c ∧ b = d) ∨ (a = d ∧ b = c) := by rcases lt_or_gt_of_ne (hNe ha hab) with habLt | habGt <;> rcases lt_or_gt_of_ne (hNe hc hcd) with hcdLt | hcdGt · exact Or.inl (hCertificateEq (hPair ha hb hab habLt) (hPair hc hd hcd hcdLt) hu) · exact Or.inr (hCertificateEq (hPair ha hb hab habLt) (hPair hd hc (by simpa only [BitVec.and_comm] using hcd) hcdGt) (by simpa only [BitVec.or_comm d c] using hu)) · have h := hCertificateEq (hPair hc hd hcd hcdLt) (hPair hb ha (by simpa only [BitVec.and_comm] using hab) habGt) (by simpa only [BitVec.or_comm b a] using hu.symm) exact Or.inr ⟨h.2.symm, h.1.symm⟩ · have h := hCertificateEq (hPair hb ha (by simpa only [BitVec.and_comm] using hab) habGt) (hPair hd hc (by simpa only [BitVec.and_comm] using hcd) hcdGt) (by simpa only [BitVec.or_comm b a, BitVec.or_comm d c] using hu) exact Or.inl ⟨h.2, h.1⟩ refine ⟨edges, hUniform, ?_, ?_⟩ · intro A hA B hB C hC D hD hAB hCD hU have hu := congrArg mask hU rw [hUnion, hUnion] at hu rcases hBV (mask A) (mask B) (mask C) (mask D) (hValid A hA) (hValid B hB) (hValid C hC) (hValid D hD) (hDisj hAB) (hDisj hCD) hu with h | h · exact Or.inl ⟨hInj h.1, hInj h.2⟩ · exact Or.inr ⟨hInj h.1, hInj h.2⟩ · have hsub : (Finset.univ.powersetCard 2).filter (fun p => ∃ e ∈ edges, p ⊆ e) ⊆ covered := by intro p hp obtain ⟨hp, e, he, hpe⟩ := Finset.mem_filter.mp hp exact hCovered e he (Finset.mem_powersetCard.mpr ⟨hpe, (Finset.mem_powersetCard.mp hp).2⟩) exact (Finset.card_le_card hsub).trans_lt (by decide +kernel) theorem local_center_card_le_inter {n : ℕ} {edges : Finset (Finset (Fin n))} {a b x : Fin n} (hx : ∀ q ∈ localCoExtensions edges {a,b}, x ∈ q) : (localCoExtensions edges {a,b}).card ≤ (localExtensions edges {x,a} ∩ localExtensions edges {x,b}).card := by let C := localExtensions edges {x,a} ∩ localExtensions edges {x,b} have hs : localCoExtensions edges {a,b} ⊆ C.image (fun y => ({x,y} : Finset (Fin n))) := by intro q hq obtain ⟨y,hy,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hq).1 (hx q hq) obtain ⟨_,ha,hb⟩ := local_pair_mem_coextensions.mp hq exact Finset.mem_image.mpr ⟨y,Finset.mem_inter.mpr ⟨local_neighbors_symm hy.symm ha,local_neighbors_symm hy.symm hb⟩,rfl⟩ exact (Finset.card_le_card hs).trans Finset.card_image_le theorem local_twins_center_of_card_ge_three {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {a b x : Fin n} (hab : a ≠ b) (hxa : x ≠ a) (hxb : x ≠ b) (hc : 3 ≤ (localExtensions edges {x,a}).card) (hh : localExtensions edges {x,a} = localExtensions edges {x,b}) : ∀ q ∈ localCoExtensions edges {a,b}, x ∈ q := by intro q hq by_contra hn have hsub : localExtensions edges {x,a} ⊆ q := by intro y hy have hy' : y ∈ localExtensions edges {x,b} := hh ▸ hy have hm : {x,y} ∈ localCoExtensions edges {a,b} := local_pair_mem_coextensions.mpr ⟨(local_neighbors_ne hy).1.symm, local_neighbors_symm hxa hy,local_neighbors_symm hxb hy'⟩ obtain ⟨v,hv,hvq⟩ := Finset.not_disjoint_iff.mp (local_coextension_pairwise hu (by simp [hab]) hm hq) simp only [Finset.mem_insert,Finset.mem_singleton] at hv rcases hv with rfl | rfl · contradiction · assumption have hh' := Finset.card_le_card hsub rw [(local_mem_coextensions.mp hq).1] at hh' omega theorem local_neighbors_cycle {n : ℕ} {edges : Finset (Finset (Fin n))} {a b c : Fin n} (hab : a ≠ b) (h : c ∈ localExtensions edges {a,b}) : a ∈ localExtensions edges {b,c} := by rw [local_neighbors_comm (a := a) (b := b)] at h exact local_neighbors_symm hab.symm h /-- A common link can use only one edge incident to a fixed vertex across this biclique. -/ theorem local_biclique_cross_same_endpoint {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {A T : Finset (Fin n)} {x y a t u : Fin n} (hA : 3 ≤ A.card) (hxA : x ∉ A) (hAT : ∀ b ∈ A, T ⊆ localExtensions edges {x,b}) (hxy : x ≠ y) (ha : a ∈ A) (ht : t ∈ T) (huT : u ∈ T) (htip : {a,t} ∈ localCoExtensions edges {x,y}) (huip : {a,u} ∈ localCoExtensions edges {x,y}) : t = u := by by_contra htu obtain ⟨hat,_,hyaT⟩ := local_pair_mem_coextensions.mp htip obtain ⟨hau,_,hyaU⟩ := local_pair_mem_coextensions.mp huip have hay : a ≠ y := (local_neighbors_ne hyaT).1.symm have hax : a ≠ x := fun h => hxA (h ▸ ha) have hsmall : ¬ A ⊆ {a,y} := by intro h have hh := Finset.card_le_card h have hc : ({a,y} : Finset (Fin n)).card = 2 := by simp [hay] omega obtain ⟨b,hb,hbne⟩ := Finset.not_subset.mp hsmall simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at hbne have hxb : x ≠ b := fun h => hxA (h.symm ▸ hb) have hdis : Disjoint ({a,y} : Finset (Fin n)) {x,b} := by simp only [Finset.disjoint_insert_left,Finset.disjoint_singleton_left, Finset.mem_insert,Finset.mem_singleton,not_or] exact ⟨⟨hax,Ne.symm hbne.1⟩,hxy.symm,Ne.symm hbne.2⟩ exact local_extension_edges_cross hu (by simp [hay]) (by simp [hxb]) htu (local_neighbors_symm hat hyaT) (local_neighbors_symm hau hyaU) (hAT b hb ht) (hAT b hb huT) hdis /-- The cross pairs in a complete bipartite subgraph contribute at most one support to each common link involving the vertex of that subgraph. -/ theorem local_biclique_cross_support_unique {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {A T : Finset (Fin n)} {x y a b t u : Fin n} (hA : 3 ≤ A.card) (hT : 3 ≤ T.card) (hxA : x ∉ A) (hAT : ∀ v ∈ A, T ⊆ localExtensions edges {x,v}) (hxy : x ≠ y) (ha : a ∈ A) (hb : b ∈ A) (ht : t ∈ T) (huT : u ∈ T) (htip : {a,t} ∈ localCoExtensions edges {x,y}) (huip : {b,u} ∈ localCoExtensions edges {x,y}) : a = b ∧ t = u := by have hdis : Disjoint A T := by apply Finset.disjoint_left.mpr intro v hvA hvT exact (local_neighbors_ne (hAT v hvA hvT)).2 rfl have hxT : x ∉ T := fun hx => (local_neighbors_ne (hAT a ha hx)).1 rfl have hTA : ∀ v ∈ T, A ⊆ localExtensions edges {x,v} := by intro v hv w hw exact local_neighbors_symm (fun h => hxA (h.symm ▸ hw)) (hAT w hw hv) have hmeet := local_coextension_pairwise hu (by simp [hxy]) htip huip obtain ⟨v,hv,hv'⟩ := Finset.not_disjoint_iff.mp hmeet rcases Finset.mem_insert.mp hv with rfl | hv · rcases Finset.mem_insert.mp hv' with rfl | hv' · exact ⟨rfl,local_biclique_cross_same_endpoint hu hA hxA hAT hxy ha ht huT htip huip⟩ · exact (Finset.disjoint_left.mp hdis ha (Finset.mem_singleton.mp hv' ▸ huT)).elim · have hvt := Finset.mem_singleton.mp hv subst v rcases Finset.mem_insert.mp hv' with h | hv' · exact (Finset.disjoint_left.mp hdis (h ▸ hb) ht).elim · have heq := Finset.mem_singleton.mp hv' subst u rw [Finset.pair_comm a t] at htip rw [Finset.pair_comm b t] at huip exact ⟨local_biclique_cross_same_endpoint hu hT hxT hTA hxy ht ha hb htip huip,rfl⟩ /-- The excess over one of the cross codegrees in this biclique is at most `n - 1`. -/ theorem local_biclique_sum_cross_extensions_erase_le {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {A T : Finset (Fin n)} {x : Fin n} (hA : 3 ≤ A.card) (hT : 3 ≤ T.card) (hxA : x ∉ A) (hAT : ∀ a ∈ A, T ⊆ localExtensions edges {x,a}) : (∑ p ∈ A ×ˢ T, ((localExtensions edges {p.1,p.2}).erase x).card) ≤ n - 1 := by let D := (A ×ˢ T).sigma (fun p => (localExtensions edges {p.1,p.2}).erase x) have hD : D.card ≤ ((Finset.univ : Finset (Fin n)).erase x).card := by apply Finset.card_le_card_of_injOn (fun z => z.2) · intro z hz refine Finset.mem_erase.mpr ⟨?_,Finset.mem_univ _⟩ exact (Finset.mem_erase.mp (Finset.mem_sigma.mp hz).2).1 · rintro ⟨⟨a,t⟩,y⟩ hz ⟨⟨b,u⟩,y'⟩ hz' hy change y = y' at hy subst y' obtain ⟨hat,hy⟩ := Finset.mem_sigma.mp hz obtain ⟨hbu,hy'⟩ := Finset.mem_sigma.mp hz' obtain ⟨ha,ht⟩ := Finset.mem_product.mp hat obtain ⟨hb,huT⟩ := Finset.mem_product.mp hbu obtain ⟨hyx,hya⟩ := Finset.mem_erase.mp hy have hyb := (Finset.mem_erase.mp hy').2 have hxa : x ≠ a := fun he => hxA (he.symm ▸ ha) have hxb : x ≠ b := fun he => hxA (he.symm ▸ hb) have hxt := hAT a ha ht have hxu := hAT b hb huT have hat' : {a,t} ∈ localCoExtensions edges {x,y} := local_pair_mem_coextensions.mpr ⟨(local_neighbors_ne hxt).2.symm, local_neighbors_cycle hxa hxt,hya⟩ have hbu' : {b,u} ∈ localCoExtensions edges {x,y} := local_pair_mem_coextensions.mpr ⟨(local_neighbors_ne hxu).2.symm, local_neighbors_cycle hxb hxu,hyb⟩ obtain ⟨rfl,rfl⟩ := local_biclique_cross_support_unique hu hA hT hxA hAT hyx.symm ha hb ht huT hat' hbu' rfl simpa [D, Finset.card_sigma] using hD theorem local_biclique_cross_no_move_at_class_member {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {A T : Finset (Fin n)} (hA : 3 ≤ A.card) {x : Fin n} (hAx : x ∉ A) (hl : ∀ a ∈ A, localExtensions edges {x,a} = T) {a t y v : Fin n} (ha : a ∈ A) (ht : t ∈ T) (hxy : x ≠ y) (htv : t ≠ v) (h₁ : {a,t} ∈ localCoExtensions edges {x,y}) (h₂ : {a,v} ∈ localCoExtensions edges {x,y}) : False := by obtain ⟨hat,_,hyaT⟩ := local_pair_mem_coextensions.mp h₁ obtain ⟨hav,hxaV,hyaV⟩ := local_pair_mem_coextensions.mp h₂ have hax : x ≠ a := fun h => hAx (h.symm ▸ ha) have hay : a ≠ y := (local_neighbors_ne hyaT).1.symm have hv : v ∈ T := by rw [← hl a ha,local_neighbors_comm (a := x) (b := a)] exact local_neighbors_symm hav hxaV have hex : ¬ A ⊆ {a,y} := by intro h have hh := Finset.card_le_card h have hcard : ({a,y} : Finset (Fin n)).card = 2 := by simp [hay] omega obtain ⟨a',ha',ha'n⟩ := Finset.not_subset.mp hex simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at ha'n have hxa' : x ≠ a' := fun h => hAx (h.symm ▸ ha') have hdis : Disjoint ({a,y} : Finset (Fin n)) {x,a'} := by rw [Finset.disjoint_left] intro z hz hz' simp only [Finset.mem_insert,Finset.mem_singleton] at hz hz' aesop exact local_extension_edges_cross hu (by simp [hay]) (by simp [hxa']) htv (local_neighbors_symm hat hyaT) (local_neighbors_symm hav hyaV) ((hl a' ha').symm ▸ ht) ((hl a' ha').symm ▸ hv) hdis theorem local_biclique_cross_coextension_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 4) {A T : Finset (Fin n)} (hA : 3 ≤ A.card) (hT : 3 ≤ T.card) {x : Fin n} (hAx : x ∉ A) (hl : ∀ a ∈ A, localExtensions edges {x,a} = T) {a t y : Fin n} (ha : a ∈ A) (ht : t ∈ T) (hxy : x ≠ y) (hat : {a,t} ∈ localCoExtensions edges {x,y}) : (localCoExtensions edges {x,y}).card + A.card ≤ 5 := by have hxt : x ≠ t := by have ht' : t ∈ localExtensions edges {x,a} := (hl a ha).symm ▸ ht exact (local_neighbors_ne ht').1.symm have hTx : x ∉ T := fun h => (local_neighbors_ne (show x ∈ localExtensions edges {x,a} from (hl a ha).symm ▸ h)).1 rfl have hrev : ∀ w ∈ T, A ⊆ localExtensions edges {x,w} := by intro w hw v hv have hxv : x ≠ v := fun h => hAx (h.symm ▸ hv) exact local_neighbors_symm hxv ((hl v hv).symm ▸ hw) have hcap : (localExtensions edges {x,t} \ A).card + A.card = (localExtensions edges {x,t}).card := Finset.card_sdiff_add_card_eq_card (hrev t ht) have hG := local_mem_coextensions.mp hat have hsub : localCoExtensions edges {x,y} ⊆ insert {t,a} ((localExtensions edges {x,t} \ A).image (fun v => ({t,v} : Finset (Fin n)))) := by intro q hq obtain ⟨u,hu,huq⟩ := Finset.not_disjoint_iff.mp (local_coextension_pairwise ‹UniqueDisjointUnions edges› (by simp [hxy]) hat hq) simp only [Finset.mem_insert,Finset.mem_singleton] at hu rcases hu with h | h · subst u obtain ⟨v,hva,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hq).1 huq by_cases htv : t = v · subst v simp [Finset.pair_comm t a] · exact (local_biclique_cross_no_move_at_class_member ‹UniqueDisjointUnions edges› hA hAx hl ha ht hxy htv hat hq).elim · subst u obtain ⟨v,hvt,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hq).1 huq by_cases hav : a = v · subst v simp apply Finset.mem_insert.mpr right apply Finset.mem_image.mpr have hp : v ∈ localExtensions edges {x,t} := by rw [local_neighbors_comm (a := x) (b := t)] exact local_neighbors_symm hvt.symm (local_pair_mem_coextensions.mp hq).2.1 refine ⟨v,Finset.mem_sdiff.mpr ⟨hp,?_⟩,rfl⟩ intro hv have hyta := (local_pair_mem_coextensions.mp hat).2.2 have hytv := (local_pair_mem_coextensions.mp hq).2.2 have hta : t ≠ a := (local_neighbors_ne ((hl a ha).symm ▸ ht)).2 have hty : t ≠ y := (local_neighbors_ne hyta).2.symm have hex : ¬ T ⊆ {t,y} := by intro h have hh := Finset.card_le_card h have hcard : ({t,y} : Finset (Fin n)).card = 2 := by simp [hty] omega obtain ⟨w,hw,hw'⟩ := Finset.not_subset.mp hex simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at hw' have hxw : x ≠ w := fun h => hTx (h.symm ▸ hw) have hdis : Disjoint ({t,y} : Finset (Fin n)) {x,w} := by rw [Finset.disjoint_left] intro z hz hz' simp only [Finset.mem_insert,Finset.mem_singleton] at hz hz' aesop exact local_extension_edges_cross ‹UniqueDisjointUnions edges› (by simp [hty]) (by simp [hxw]) hav (local_neighbors_cycle hta.symm hyta) (local_neighbors_symm hvt.symm hytv) (hrev w hw ha) (hrev w hw hv) hdis have hc : (localCoExtensions edges {x,y}).card ≤ (localExtensions edges {x,t} \ A).card + 1 := by calc _ ≤ (insert {t,a} ((localExtensions edges {x,t} \ A).image (fun v => ({t,v} : Finset (Fin n))))).card := Finset.card_le_card hsub _ ≤ _ := (Finset.card_insert_le _ _).trans (Nat.add_le_add_right Finset.card_image_le 1) have hh := hd x t hxt omega theorem local_fat_triangle_exists {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (htw : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card = 4 → ∃ b, x ≠ b ∧ a ≠ b ∧ localExtensions edges {x,b} = localExtensions edges {x,a}) {x a : Fin n} (hxa : x ≠ a) (hd : (localExtensions edges {x,a}).card = 4) : ∃ b, x ≠ b ∧ a ≠ b ∧ localExtensions edges {x,b} = localExtensions edges {x,a} ∧ localExtensions edges {a,b} = localExtensions edges {x,a} := by have local_fat_twins_same_partner {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {x a b c : Fin n} (hxa : x ≠ a) (hxb : x ≠ b) (hab : a ≠ b) (hxc : x ≠ c) (hac : a ≠ c) (hd : 2 ≤ (localExtensions edges {x,a}).card) (hb : localExtensions edges {x,b} = localExtensions edges {x,a}) (hc : localExtensions edges {a,c} = localExtensions edges {x,a}) : b = c := by by_contra hbc obtain ⟨u,huN,v,hvN,huv⟩ := Finset.one_lt_card.mp (by omega : 1 < (localExtensions edges {x,a}).card) have hdis : Disjoint ({x,b} : Finset (Fin n)) {a,c} := by rw [Finset.disjoint_left] intro z hz hz' simp only [Finset.mem_insert,Finset.mem_singleton] at hz hz' aesop exact local_extension_edges_cross hu (by simp [hxb]) (by simp [hac]) huv (hb.symm ▸ huN) (hb.symm ▸ hvN) (hc.symm ▸ huN) (hc.symm ▸ hvN) hdis obtain ⟨b,hxb,hab,hb⟩ := htw x a hxa hd rw [local_neighbors_comm (a := x) (b := a)] at hd obtain ⟨c,hac,hxc,hc⟩ := htw a x hxa.symm hd rw [local_neighbors_comm (a := a) (b := x)] at hc hd have hbc := local_fat_twins_same_partner hu hxa hxb hab hxc hac (by omega) hb hc exact ⟨b,hxb,hab,hb,hbc ▸ hc⟩ theorem local_fat_triangle_residual_mem {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hg : ∀ x a : Fin n, x ≠ a → 3 ≤ (localCoExtensions edges {x,a}).card) {T : Finset (Fin n)} {a b c t w : Fin n} (hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) (eab : localExtensions edges {a,b} = T) (eac : localExtensions edges {a,c} = T) (ebc : localExtensions edges {b,c} = T) (hT : 3 ≤ T.card) (ht : t ∈ T) (hw : w ∈ localExtensions edges {t,a}) (hwb : w ≠ b) (hwc : w ≠ c) (hct : (localExtensions edges {t,b}).card ≤ 3) : ∃ v ∈ localExtensions edges {t,b}, v ≠ a ∧ v ≠ c ∧ v ∈ T := by have local_center_residual_neighbors {n : ℕ} {edges : Finset (Finset (Fin n))} {a b x t : Fin n} (hu : UniqueDisjointUnions edges) (hbt : b ≠ t) (ha : {x,a} ∈ localCoExtensions edges {b,t}) (hc : ¬ ∀ q ∈ localCoExtensions edges {b,t}, a ∈ q) : ∃ v, v ≠ a ∧ {x,v} ∈ localCoExtensions edges {b,t} := by push Not at hc obtain ⟨r,hr,har⟩ := hc obtain ⟨i,hi,hir⟩ := Finset.not_disjoint_iff.mp (local_coextension_pairwise hu (by simp [hbt]) ha hr) have hxr : x ∈ r := by simp only [Finset.mem_insert,Finset.mem_singleton] at hi rcases hi with h | h · rwa [← h] · exact (har (h ▸ hir)).elim obtain ⟨v,_,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hr).1 hxr exact ⟨v,fun h => har (by simp [h]),hr⟩ have htAB : t ∈ localExtensions edges {a,b} := eab.symm ▸ ht have htAC : t ∈ localExtensions edges {a,c} := eac.symm ▸ ht have ⟨hta,htb⟩ := local_neighbors_ne htAB have htc := (local_neighbors_ne htAC).2 have ⟨hwt,hwa⟩ := local_neighbors_ne hw have hWta : a ∈ localExtensions edges {t,w} := local_neighbors_symm hta hw have hWtc : c ∉ localExtensions edges {t,w} := by intro hc have hBTA := (local_neighbors_comm (a := b) (b := a)).trans eab have hBC := hBTA.trans ebc.symm have hstar := local_twins_center_of_card_ge_three hu hac hab.symm hbc (hBTA.symm ▸ hT) hBC have hCo : {t,w} ∈ localCoExtensions edges {a,c} := local_pair_mem_coextensions.mpr ⟨hwt.symm,hWta,hc⟩ have hh := hstar _ hCo simp [htb.symm,hwb.symm] at hh have hATb : b ∈ localExtensions edges {t,a} := by rw [local_neighbors_comm (a := t) (b := a)] exact local_neighbors_symm hab htAB have hCTb : c ∈ localExtensions edges {t,b} := by rw [local_neighbors_comm (a := t) (b := b)] exact local_neighbors_symm hbc (ebc.symm ▸ ht) have hP : {t,a} ∈ localCoExtensions edges {b,w} := local_pair_mem_coextensions.mpr ⟨hta,hATb,hw⟩ have hCards := hg b w hwb.symm have hNotT : ¬ ∀ q ∈ localCoExtensions edges {b,w}, t ∈ q := by intro h have hc := local_center_card_le_inter h have hsub : localExtensions edges {t,b} ∩ localExtensions edges {t,w} ⊆ (localExtensions edges {t,b}).erase c := by intro u hu' obtain ⟨huB,huW⟩ := Finset.mem_inter.mp hu' apply Finset.mem_erase.mpr exact ⟨fun h => hWtc (h ▸ huW),huB⟩ have hlt := Finset.card_lt_card (Finset.erase_ssubset hCTb) have hle := Finset.card_le_card hsub omega have hNotA : ¬ ∀ q ∈ localCoExtensions edges {b,w}, a ∈ q := by intro h have hc := local_center_card_le_inter h rw [eab] at hc obtain ⟨i,hi,j,hj,hij⟩ := Finset.one_lt_card.mp (show 1 < (T ∩ localExtensions edges {a,w}).card by omega) have ⟨hiT,hiA⟩ := Finset.mem_inter.mp hi have ⟨hjT,hjA⟩ := Finset.mem_inter.mp hj have hdis : Disjoint ({a,w} : Finset (Fin n)) {b,c} := by rw [Finset.disjoint_left] intro u hu' hv' simp only [Finset.mem_insert,Finset.mem_singleton] at hu' hv' aesop exact local_extension_edges_cross hu (by simp [hwa.symm]) (by simp [hbc]) hij hiA hjA (ebc.symm ▸ hiT) (ebc.symm ▸ hjT) hdis obtain ⟨v,hva,hvP⟩ := local_center_residual_neighbors hu hwb.symm hP hNotA have hvN := local_neighbors_symm (local_pair_mem_coextensions.mp hvP).1 (local_pair_mem_coextensions.mp hvP).2.1 have hvW := local_neighbors_symm (local_pair_mem_coextensions.mp hvP).1 (local_pair_mem_coextensions.mp hvP).2.2 have hvc : v ≠ c := fun h => hWtc (h ▸ hvW) have hvG := local_coextensions_third_of_not_center hu (by simp [hwb.symm]) hva.symm hP hvP hNotT have hvA := local_neighbors_symm hva.symm (local_pair_mem_coextensions.mp hvG).2.1 exact ⟨v,hvN,hva,hvc,eab ▸ hvA⟩ theorem local_fat_triangle_cross_exact {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 4) (hg : ∀ x a : Fin n, x ≠ a → 3 ≤ (localCoExtensions edges {x,a}).card) (htw : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card = 4 → ∃ b, x ≠ b ∧ a ≠ b ∧ localExtensions edges {x,b} = localExtensions edges {x,a}) {T : Finset (Fin n)} {a b c t : Fin n} (hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) (eab : localExtensions edges {a,b} = T) (eac : localExtensions edges {a,c} = T) (ebc : localExtensions edges {b,c} = T) (hT : 3 ≤ T.card) (ht : t ∈ T) : localExtensions edges {t,a} = {b,c} := by have local_fat_triangle_cross_le_three {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 4) (htw : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card = 4 → ∃ b, x ≠ b ∧ a ≠ b ∧ localExtensions edges {x,b} = localExtensions edges {x,a}) {a b c t : Fin n} (hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) (hT : 3 ≤ (localExtensions edges {a,b}).card) (he : localExtensions edges {a,b} = localExtensions edges {a,c}) (hta : t ≠ a) (htB : b ∈ localExtensions edges {t,a}) (htC : c ∈ localExtensions edges {t,a}) : (localExtensions edges {t,a}).card ≤ 3 := by have hBound := hd _ _ hta by_contra hn have h4 : (localExtensions edges {t,a}).card = 4 := by omega obtain ⟨w,htw',haw,hweq,_⟩ := local_fat_triangle_exists hu htw hta h4 have hwBC : {t,w} ∈ localCoExtensions edges {b,c} := local_pair_mem_coextensions.mpr ⟨htw',hweq.symm ▸ htB,hweq.symm ▸ htC⟩ have hstar := local_twins_center_of_card_ge_three hu hbc hab hac hT he have hh := hstar {t,w} hwBC simp [hta.symm,haw] at hh have htAB : t ∈ localExtensions edges {a,b} := eab.symm ▸ ht have htAC : t ∈ localExtensions edges {a,c} := eac.symm ▸ ht have htBC : t ∈ localExtensions edges {b,c} := ebc.symm ▸ ht have ⟨hta,htb⟩ := local_neighbors_ne htAB have htc := (local_neighbors_ne htAC).2 have hbaT : localExtensions edges {b,a} = T := (local_neighbors_comm (a := b) (b := a)).trans eab have hcaT : localExtensions edges {c,a} = T := (local_neighbors_comm (a := c) (b := a)).trans eac have hcbT : localExtensions edges {c,b} = T := (local_neighbors_comm (a := c) (b := b)).trans ebc have hTb : b ∈ localExtensions edges {t,a} := by rw [local_neighbors_comm (a := t) (b := a)] exact local_neighbors_symm hab htAB have hTc : c ∈ localExtensions edges {t,a} := by rw [local_neighbors_comm (a := t) (b := a)] exact local_neighbors_symm hac htAC have hTa' : a ∈ localExtensions edges {t,b} := by rw [local_neighbors_comm (a := t) (b := b)] exact local_neighbors_cycle hab htAB have hTc' : c ∈ localExtensions edges {t,b} := by rw [local_neighbors_comm (a := t) (b := b)] exact local_neighbors_symm hbc htBC have hTa'' : a ∈ localExtensions edges {t,c} := by rw [local_neighbors_comm (a := t) (b := c)] apply local_neighbors_symm hac.symm exact hcaT.symm ▸ ht have hTb'' : b ∈ localExtensions edges {t,c} := by rw [local_neighbors_comm (a := t) (b := c)] apply local_neighbors_symm hbc.symm exact hcbT.symm ▸ ht have hbcap := local_fat_triangle_cross_le_three hu hd htw hab.symm hbc hac (hbaT.symm ▸ hT) (hbaT.trans ebc.symm) htb hTa' hTc' have hccap := local_fat_triangle_cross_le_three hu hd htw hac.symm hbc.symm hab (hcaT.symm ▸ hT) (hcaT.trans hcbT.symm) htc hTa'' hTb'' apply Finset.Subset.antisymm · intro w hw by_contra h simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at h obtain ⟨v,hv,hva,hvc,hvT⟩ := local_fat_triangle_residual_mem hu hg hab hac hbc eab eac ebc hT ht hw h.1 h.2 hbcap obtain ⟨z,hz,hza,hzb,hzT⟩ := local_fat_triangle_residual_mem hu hg hac hab hbc.symm eac eab hcbT hT ht hw h.2 h.1 hccap have ⟨hvt,hvb⟩ := local_neighbors_ne hv have ⟨hzt,hzc⟩ := local_neighbors_ne hz have hvz : v ≠ z := by intro he subst z have hctr := local_twins_center_of_card_ge_three hu hbc hab hac (eab.symm ▸ hT) (eab.trans eac.symm) have htV : {t,v} ∈ localCoExtensions edges {b,c} := local_pair_mem_coextensions.mpr ⟨hvt.symm,local_neighbors_symm htb hv, local_neighbors_symm htc hz⟩ have hh := hctr _ htV simp [hta.symm,hva.symm] at hh have hdis : Disjoint ({b,v} : Finset (Fin n)) {c,z} := by rw [Finset.disjoint_left] intro u hu' hv' simp only [Finset.mem_insert,Finset.mem_singleton] at hu' hv' aesop exact local_extension_edges_cross ‹UniqueDisjointUnions edges› (by simp [hvb.symm]) (by simp [hzc.symm]) hta (local_neighbors_cycle htb hv) (local_neighbors_cycle hab (eab.symm ▸ hvT)) (local_neighbors_cycle htc hz) (local_neighbors_cycle hac (eac.symm ▸ hzT)) hdis · simp [Finset.insert_subset_iff,hTb,hTc] theorem local_coextensions_card_le_four {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 4) {p : Finset (Fin n)} (hp : p.card = 2) : (localCoExtensions edges p).card ≤ 4 := by obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp let F := localCoExtensions edges {a,b} have hF : ∀ q ∈ F, q.card = 2 := fun _ h => (local_mem_coextensions.mp h).1 rcases local_intersecting_pair_family F hF (fun _ hq _ hr => local_coextension_pairwise hu (by simp [hab]) hq hr) with h | ⟨x,hx⟩ | ⟨u,v,w,_,_,_,heq⟩ · change F.card ≤ 4 omega · change F.card ≤ 4 by_cases hpos : 0 < F.card · obtain ⟨q,hq⟩ := Finset.card_pos.mp hpos have ha := (local_mem_coextensions.mp hq).2 (show a ∈ ({a,b} : Finset (Fin n)) by simp) have hxa : x ≠ a := fun h => (Finset.mem_filter.mp ha).2.1 (h ▸ hx q hq) exact (local_center_card_le_inter hx).trans ((Finset.card_le_card Finset.inter_subset_left).trans (hd _ _ hxa)) · omega · change F.card ≤ 4 rw [heq] have h : ({{u,v},{u,w},{v,w}} : Finset (Finset (Fin n))).card ≤ 3 := (Finset.card_insert_le _ _).trans (Nat.add_le_add_right ((Finset.card_insert_le _ _).trans (by simp)) 1) omega def localOrderedPairs (n : ℕ) : Finset (Fin n × Fin n) := Finset.univ.filter (fun p => p.1 ≠ p.2) def localUnderlyingPair {n : ℕ} (p : Fin n × Fin n) : Finset (Fin n) := {p.1,p.2} theorem local_mem_ordered_pairs {n : ℕ} {p : Fin n × Fin n} : p ∈ localOrderedPairs n ↔ p.1 ≠ p.2 := by simp [localOrderedPairs] theorem local_orderings_two {n : ℕ} {p : Finset (Fin n)} (hp : p.card = 2) : ((localOrderedPairs n).filter (fun q => localUnderlyingPair q = p)).card = 2 := by obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp have heq : (localOrderedPairs n).filter (fun q => localUnderlyingPair q = {a,b}) = {(a,b),(b,a)} := by ext q obtain ⟨u,v⟩ := q change ((u,v) ∈ (localOrderedPairs n).filter (fun q => localUnderlyingPair q = {a,b})) ↔ (u,v) ∈ ({(a,b),(b,a)} : Finset (Fin n × Fin n)) rw [Finset.mem_filter, local_mem_ordered_pairs] simp only [localUnderlyingPair, Finset.mem_insert, Finset.mem_singleton,Prod.mk.injEq] constructor · rintro ⟨huv,h⟩ have hu : u ∈ ({a,b} : Finset (Fin n)) := h ▸ Finset.mem_insert_self u {v} have hv : v ∈ ({a,b} : Finset (Fin n)) := h ▸ Finset.mem_insert_of_mem (Finset.mem_singleton_self v) simp only [Finset.mem_insert, Finset.mem_singleton] at hu hv rcases hu with h | h <;> rcases hv with hh | hh <;> aesop · rintro (⟨rfl,rfl⟩ | ⟨rfl,rfl⟩) · exact ⟨hab,rfl⟩ · exact ⟨hab.symm,Finset.pair_comm _ _⟩ rw [heq] simp [hab] def localFourTwinClass {n : ℕ} (edges : Finset (Finset (Fin n))) (x a : Fin n) : Finset (Fin n) := Finset.univ.filter (fun b => x ≠ b ∧ localExtensions edges {x,b} = localExtensions edges {x,a}) theorem local_mem_four_twin_class {n : ℕ} {edges : Finset (Finset (Fin n))} {x a b : Fin n} : b ∈ localFourTwinClass edges x a ↔ x ≠ b ∧ localExtensions edges {x,b} = localExtensions edges {x,a} := by simp [localFourTwinClass] theorem local_four_twin_class_card_le {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 4) {x a : Fin n} (h4 : (localExtensions edges {x,a}).card = 4) : (localFourTwinClass edges x a).card ≤ 4 := by obtain ⟨t,ht⟩ := Finset.card_pos.mp (show 0 < (localExtensions edges {x,a}).card by omega) have hx : x ≠ t := (local_neighbors_ne ht).1.symm have hsub : localFourTwinClass edges x a ⊆ localExtensions edges {x,t} := by intro b hb obtain ⟨hxb,hb⟩ := local_mem_four_twin_class.mp hb exact local_neighbors_symm hxb (hb.symm ▸ ht) exact (Finset.card_le_card hsub).trans (hd _ _ hx) theorem local_coextension_double_count {n : ℕ} (edges : Finset (Finset (Fin n))) : ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, (localCoExtensions edges p).card = ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, (localExtensions edges p).card.choose 2 := by classical let pairs := (Finset.univ : Finset (Fin n)).powersetCard 2 have hv : ∀ q ∈ pairs, ({r ∈ pairs | r ⊆ localExtensions edges q}).card = (localExtensions edges q).card.choose 2 := by intro q hq have heq : {r ∈ pairs | r ⊆ localExtensions edges q} = (localExtensions edges q).powersetCard 2 := by ext r simp [pairs,and_comm] rw [heq,Finset.card_powersetCard] calc ∑ p ∈ pairs, (localCoExtensions edges p).card = ∑ q ∈ pairs, ({r ∈ pairs | r ⊆ localExtensions edges q}).card := by simp only [localCoExtensions, ← show pairs = (Finset.univ : Finset (Fin n)).powersetCard 2 from rfl, Finset.card_filter] exact Finset.sum_comm _ = _ := Finset.sum_congr rfl hv theorem local_ordered_filter_count {n : ℕ} (f : Finset (Fin n) → Prop) [DecidablePred f] : ((localOrderedPairs n).filter (fun p => f (localUnderlyingPair p))).card = 2 * (((Finset.univ : Finset (Fin n)).powersetCard 2).filter f).card := by have local_ordered_pair_sum {n : ℕ} (f : Finset (Fin n) → ℕ) : ∑ p ∈ localOrderedPairs n, f (localUnderlyingPair p) = 2 * ∑ p ∈ ((Finset.univ : Finset (Fin n)).powersetCard 2), f p := by classical let pairs := (Finset.univ : Finset (Fin n)).powersetCard 2 have hmap : ∀ p ∈ localOrderedPairs n, localUnderlyingPair p ∈ pairs := by intro p hp simp [pairs,localUnderlyingPair,local_mem_ordered_pairs.mp hp] rw [← Finset.sum_fiberwise_of_maps_to' hmap f, Finset.mul_sum] apply Finset.sum_congr rfl intro p hp rw [Finset.sum_const_nat (fun _ _ => rfl)] rw [local_orderings_two (Finset.mem_powersetCard.mp hp).2] simp only [Finset.card_filter] exact local_ordered_pair_sum (fun p => if f p then 1 else 0) theorem local_four_star_le_twin_choices {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 4) : let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let F := (localOrderedPairs n).filter (fun p => (localExtensions edges (localUnderlyingPair p)).card = 4) 2 * ({p ∈ P | (localCoExtensions edges p).card = 4}).card ≤ ∑ p ∈ F, ((localFourTwinClass edges p.1 p.2).card - 1) := by have local_size_four_coextension_twins {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 4) {a b : Fin n} (hab : a ≠ b) (hF : (localCoExtensions edges {a,b}).card = 4) : ∃ x, x ≠ a ∧ x ≠ b ∧ (localExtensions edges {x,a}).card = 4 ∧ localExtensions edges {x,a} = localExtensions edges {x,b} := by let F := localCoExtensions edges {a,b} have hsize : ∀ q ∈ F, q.card = 2 := fun _ h => (local_mem_coextensions.mp h).1 rcases local_intersecting_pair_family F hsize (fun _ hq _ hr => local_coextension_pairwise hu (by simp [hab]) hq hr) with h | ⟨x,hx⟩ | ⟨u,v,w,_,_,_,heq⟩ · change F.card ≤ 1 at h change F.card = 4 at hF omega · obtain ⟨q,hq⟩ := Finset.card_pos.mp (show 0 < F.card by change 0 < (localCoExtensions edges {a,b}).card; omega) have ha := (local_mem_coextensions.mp hq).2 (show a ∈ ({a,b} : Finset (Fin n)) by simp) have hb := (local_mem_coextensions.mp hq).2 (show b ∈ ({a,b} : Finset (Fin n)) by simp) have hxa : x ≠ a := fun h => (Finset.mem_filter.mp ha).2.1 (h ▸ hx q hq) have hxb : x ≠ b := fun h => (Finset.mem_filter.mp hb).2.1 (h ▸ hx q hq) have hG := local_center_card_le_inter hx rw [hF] at hG have hL := Finset.card_le_card (Finset.inter_subset_left (s₁ := localExtensions edges {x,a}) (s₂ := localExtensions edges {x,b})) have hR := Finset.card_le_card (Finset.inter_subset_right (s₁ := localExtensions edges {x,a}) (s₂ := localExtensions edges {x,b})) have hA := hd x a hxa have hB := hd x b hxb have e₁ := Finset.eq_of_subset_of_card_le (Finset.inter_subset_left (s₁ := localExtensions edges {x,a}) (s₂ := localExtensions edges {x,b})) (by omega) have e₂ := Finset.eq_of_subset_of_card_le (Finset.inter_subset_right (s₁ := localExtensions edges {x,a}) (s₂ := localExtensions edges {x,b})) (by omega) exact ⟨x,hxa,hxb,by omega,e₁.symm.trans e₂⟩ · change F.card = 4 at hF rw [heq] at hF have h : ({{u,v},{u,w},{v,w}} : Finset (Finset (Fin n))).card ≤ 3 := (Finset.card_insert_le _ _).trans (Nat.add_le_add_right ((Finset.card_insert_le _ _).trans (by simp)) 1) omega classical dsimp only let F := (localOrderedPairs n).filter (fun p => (localExtensions edges (localUnderlyingPair p)).card = 4) let J := F.sigma (fun p => (localFourTwinClass edges p.1 p.2).erase p.2) let G := (localOrderedPairs n).filter (fun p => (localCoExtensions edges (localUnderlyingPair p)).card = 4) have hcard : J.card = ∑ p ∈ F, ((localFourTwinClass edges p.1 p.2).card - 1) := by rw [Finset.card_sigma] apply Finset.sum_congr rfl intro p hp exact Finset.card_erase_of_mem (local_mem_four_twin_class.mpr ⟨local_mem_ordered_pairs.mp (Finset.mem_filter.mp hp).1,rfl⟩) have hex : ∀ p ∈ G, ∃ x, (⟨(x,p.1),p.2⟩ : Sigma (fun _ : Fin n × Fin n => Fin n)) ∈ J := by intro p hp obtain ⟨hord,hg⟩ := Finset.mem_filter.mp hp obtain ⟨x,hxa,hxb,h4,hTw⟩ := local_size_four_coextension_twins hu hd (local_mem_ordered_pairs.mp hord) hg refine ⟨x, ?_⟩ apply Finset.mem_sigma.mpr exact ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hxa,h4⟩, Finset.mem_erase.mpr ⟨(local_mem_ordered_pairs.mp hord).symm, local_mem_four_twin_class.mpr ⟨hxb,hTw.symm⟩⟩⟩ have hG : G.card ≤ J.card := by let lift : (p : Fin n × Fin n) → p ∈ G → Sigma (fun _ : Fin n × Fin n => Fin n) := fun p hp => ⟨(Classical.choose (hex p hp),p.1),p.2⟩ apply Finset.card_le_card_of_injOn (fun p => if hp : p ∈ G then lift p hp else ⟨p,p.2⟩) · intro p hp change p ∈ G at hp simp only [dif_pos hp] exact Classical.choose_spec (hex p hp) · intro p hp q hq heq change p ∈ G at hp change q ∈ G at hq simp only [dif_pos hp,dif_pos hq] at heq have hfst := congrArg (fun w : Sigma (fun _ : Fin n × Fin n => Fin n) => w.1.2) heq have hsnd := congrArg (fun w : Sigma (fun _ : Fin n × Fin n => Fin n) => w.2) heq exact Prod.ext hfst hsnd have hGcard := local_ordered_filter_count (fun (p : Finset (Fin n)) => (localCoExtensions edges p).card = 4) change G.card = _ at hGcard rw [← hGcard] exact hG.trans_eq hcard def localFourFatPairs {n : ℕ} (edges : Finset (Finset (Fin n))) : Finset (Fin n × Fin n) := (localOrderedPairs n).filter (fun p => (localExtensions edges (localUnderlyingPair p)).card = 4) def localFourSlots (k : ℕ) : Finset (Fin 2) := if k = 4 then Finset.univ else {0} def localFourTokens {n : ℕ} (edges : Finset (Finset (Fin n))) : Finset ((Fin n × Fin n) × (Fin n × Fin 2)) := (((localFourFatPairs edges).filter (fun p => 3 ≤ (localFourTwinClass edges p.1 p.2).card)).sigma (fun p => (localExtensions edges (localUnderlyingPair p)) ×ˢ (localFourSlots (localFourTwinClass edges p.1 p.2).card))).map ⟨fun p => (p.1,p.2),fun p q h => by cases p; cases q; cases h; rfl⟩ theorem local_four_token_mem {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} {b : Fin 2} : ((x,a),(t,b)) ∈ localFourTokens edges ↔ x ≠ a ∧ (localExtensions edges {x,a}).card = 4 ∧ 3 ≤ (localFourTwinClass edges x a).card ∧ t ∈ localExtensions edges {x,a} ∧ b ∈ localFourSlots (localFourTwinClass edges x a).card := by unfold localFourTokens constructor · intro h obtain ⟨q,hq,hqeq⟩ := Finset.mem_map.mp h change (q.1,q.2) = ((x,a),(t,b)) at hqeq have hf := (Prod.mk.inj hqeq).1 have hs := (Prod.mk.inj hqeq).2 have hq' := Finset.mem_sigma.mp hq simp only [hf,hs,Finset.mem_filter,Finset.mem_product] at hq' exact ⟨local_mem_ordered_pairs.mp (Finset.mem_filter.mp hq'.1.1).1, (Finset.mem_filter.mp hq'.1.1).2,hq'.1.2,hq'.2.1,hq'.2.2⟩ · rintro ⟨hxa,h4,hk,ht,hb⟩ apply Finset.mem_map.mpr refine ⟨⟨(x,a),(t,b)⟩,Finset.mem_sigma.mpr ?_,rfl⟩ exact ⟨Finset.mem_filter.mpr ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hxa,h4⟩,hk⟩,Finset.mem_product.mpr ⟨ht,hb⟩⟩ theorem local_four_token_pair_data {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} {b : Fin 2} (h : ((x,a),(t,b)) ∈ localFourTokens edges) : a ≠ t ∧ x ≠ t ∧ x ∈ localExtensions edges {a,t} := by obtain ⟨hxa,_,_,ht,_⟩ := local_four_token_mem.mp h obtain ⟨htx,hta⟩ := local_neighbors_ne ht exact ⟨hta.symm,htx.symm,local_neighbors_cycle hxa ht⟩ noncomputable def localFourNext {n : ℕ} (edges : Finset (Finset (Fin n))) (x a t : Fin n) : Fin n := if h : ∃ y ∈ localExtensions edges {a,t}, x ≠ y then Classical.choose h else x noncomputable def localFourCharge {n : ℕ} (edges : Finset (Finset (Fin n))) (p : (Fin n × Fin n) × (Fin n × Fin 2)) : Bool × Finset (Fin n) := if (localExtensions edges {p.1.2,p.2.1}).card = 1 then (false,{p.1.2,p.2.1}) else (true,{p.1.1,localFourNext edges p.1.1 p.1.2 p.2.1}) theorem local_four_charge_true_spec {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} {b : Fin 2} {p : Finset (Fin n)} (htok : ((x,a),(t,b)) ∈ localFourTokens edges) (h : localFourCharge edges ((x,a),(t,b)) = (true,p)) : let y := localFourNext edges x a t x ≠ y ∧ {x,y} = p ∧ {a,t} ∈ localCoExtensions edges p := by have local_four_next_spec {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} (hx : x ∈ localExtensions edges {a,t}) (h : (localExtensions edges {a,t}).card ≠ 1) : localFourNext edges x a t ∈ localExtensions edges {a,t} ∧ x ≠ localFourNext edges x a t := by classical have hex : ∃ y ∈ localExtensions edges {a,t}, x ≠ y := by by_contra hn push Not at hn have heq : localExtensions edges {a,t} = {x} := by ext z rw [Finset.mem_singleton] exact ⟨fun hz => (hn z hz).symm,fun hz => hz ▸ hx⟩ simp [heq] at h simpa only [localFourNext,dif_pos hex] using Classical.choose_spec hex obtain ⟨hat,_,hX⟩ := local_four_token_pair_data htok unfold localFourCharge at h split at h · exact Bool.noConfusion (Prod.mk.inj h).1 · have hcard : (localExtensions edges {a,t}).card ≠ 1 := by assumption have hNext := local_four_next_spec hX hcard have hP := (Prod.mk.inj h).2 dsimp only at hP ⊢ exact ⟨hNext.2,hP,hP ▸ local_pair_mem_coextensions.mpr ⟨hat,hX,hNext.1⟩⟩ theorem local_four_charge_false_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (p : Finset (Fin n)) (hp : p.card = 2) : ((localFourTokens edges).filter (fun q => localFourCharge edges q = (false,p))).card ≤ 4 * (if (localExtensions edges p).card = 1 then 1 else 0) := by have local_four_charge_false_spec {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} {b : Fin 2} {p : Finset (Fin n)} (h : localFourCharge edges ((x,a),(t,b)) = (false,p)) : (localExtensions edges {a,t}).card = 1 ∧ {a,t} = p := by unfold localFourCharge at h split at h · exact ⟨by assumption,(Prod.mk.inj h).2⟩ · exact Bool.noConfusion (Prod.mk.inj h).1 classical let S := (localFourTokens edges).filter (fun q => localFourCharge edges q = (false,p)) by_cases hd : (localExtensions edges p).card = 1 · simp only [hd,if_true,mul_one] let O := (localOrderedPairs n).filter (fun q => localUnderlyingPair q = p) have hc : (O ×ˢ (Finset.univ : Finset (Fin 2))).card = 4 := by rw [Finset.card_product,local_orderings_two hp] decide rw [← hc] apply Finset.card_le_card_of_injOn (fun q => ((q.1.2,q.2.1),q.2.2)) · rintro ⟨⟨x,a⟩,⟨t,b⟩⟩ h change ((x,a),(t,b)) ∈ S at h obtain ⟨htok,hch⟩ := Finset.mem_filter.mp h have hh := local_four_charge_false_spec hch have hp' := local_four_token_pair_data htok apply Finset.mem_product.mpr exact ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hp'.1, hh.2⟩, Finset.mem_univ _⟩ · rintro ⟨⟨x,a⟩,⟨t,b⟩⟩ h ⟨⟨y,c⟩,⟨u,d⟩⟩ h' heq change ((x,a),(t,b)) ∈ S at h change ((y,c),(u,d)) ∈ S at h' simp only [Prod.mk.injEq] at heq rcases heq with ⟨⟨rfl,rfl⟩,rfl⟩ obtain ⟨htok,hch⟩ := Finset.mem_filter.mp h obtain ⟨htok',hch'⟩ := Finset.mem_filter.mp h' have ⟨h1,_⟩ := local_four_charge_false_spec hch have hx := (local_four_token_pair_data htok).2.2 have hy := (local_four_token_pair_data htok').2.2 have hxy := Finset.card_le_one.mp (by omega : (localExtensions edges {a,t}).card ≤ 1) _ hx _ hy cases hxy rfl · simp only [hd,if_false,Nat.mul_zero] apply Nat.le_of_eq apply Finset.card_eq_zero.mpr apply Finset.eq_empty_iff_forall_notMem.mpr intro q h obtain ⟨⟨x,a⟩,⟨t,b⟩⟩ := q have hh := local_four_charge_false_spec (Finset.mem_filter.mp h).2 exact hd (hh.2 ▸ hh.1) theorem local_four_charge_true_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 4) (p : Finset (Fin n)) (hp : p.card = 2) : ((localFourTokens edges).filter (fun q => localFourCharge edges q = (true,p))).card ≤ 4 * (3 - (localCoExtensions edges p).card) := by have local_four_charge_true_size_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 4) {x a t : Fin n} {b : Fin 2} {p : Finset (Fin n)} (htok : ((x,a),(t,b)) ∈ localFourTokens edges) (h : localFourCharge edges ((x,a),(t,b)) = (true,p)) : (localCoExtensions edges p).card + (localFourTwinClass edges x a).card ≤ 5 := by obtain ⟨hxa,h4,hk,ht,hb⟩ := local_four_token_mem.mp htok obtain ⟨hxy,heq,hG⟩ := local_four_charge_true_spec htok h rw [← heq] at hG ⊢ have ha : a ∈ localFourTwinClass edges x a := local_mem_four_twin_class.mpr ⟨hxa,rfl⟩ exact local_biclique_cross_coextension_bound hu hd hk (by omega : 3 ≤ (localExtensions edges {x,a}).card) (fun h => (local_mem_four_twin_class.mp h).1 rfl) (fun _ h => (local_mem_four_twin_class.mp h).2) ha ht hxy hG classical let S := (localFourTokens edges).filter (fun q => localFourCharge edges q = (true,p)) let G := localCoExtensions edges p let O := (localOrderedPairs n).filter (fun q => localUnderlyingPair q = p) have hoc : O.card = 2 := local_orderings_two hp by_cases he : S = ∅ · simp [show {q ∈ localFourTokens edges | localFourCharge edges q = (true,p)} = S from rfl,he] obtain ⟨q,hq⟩ := Finset.nonempty_iff_ne_empty.mpr he obtain ⟨⟨x,a⟩,⟨t,b⟩⟩ := q obtain ⟨htok,hch⟩ := Finset.mem_filter.mp hq have ⟨_,_,hG⟩ := local_four_charge_true_spec htok hch have hs := local_four_charge_true_size_bound hu hd htok hch have hk := (local_four_token_mem.mp htok).2.2.1 have hpos : 0 < G.card := Finset.card_pos.mpr ⟨_,hG⟩ have hcap : G.card ≤ 2 := by change (localCoExtensions edges p).card ≤ 2; omega by_cases hG1 : G.card = 1 · have hG_eq : G = {({a,t} : Finset (Fin n))} := by apply (Finset.eq_of_subset_of_card_le (show ({({a,t} : Finset (Fin n))} : Finset _) ⊆ G by simpa only [Finset.singleton_subset_iff] using hG) ?_).symm rw [hG1,Finset.card_singleton] let R := (localOrderedPairs n).filter (fun q => localUnderlyingPair q = {a,t}) have hR : R.card = 2 := local_orderings_two (local_mem_coextensions.mp hG).1 have hprod : (O ×ˢ (R ×ˢ (Finset.univ : Finset (Fin 2)))).card = 8 := by simp [Finset.card_product,hoc,hR] have hlim : 4 * (3 - (localCoExtensions edges p).card) = 8 := by change 4 * (3 - G.card) = 8 rw [hG1] rw [hlim, ← hprod] apply Finset.card_le_card_of_injOn (fun q => ((q.1.1,localFourNext edges q.1.1 q.1.2 q.2.1),((q.1.2,q.2.1),q.2.2))) · rintro ⟨⟨u,c⟩,⟨v,d⟩⟩ h change ((u,c),(v,d)) ∈ S at h obtain ⟨htok',hch'⟩ := Finset.mem_filter.mp h obtain ⟨hUN,heq,hP⟩ := local_four_charge_true_spec htok' hch' have hv : c ≠ v := (local_four_token_pair_data htok').1 have heq' : {c,v} = ({a,t} : Finset (Fin n)) := by change ({c,v} : Finset (Fin n)) ∈ G at hP rwa [hG_eq,Finset.mem_singleton] at hP exact Finset.mem_product.mpr ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hUN,heq⟩,Finset.mem_product.mpr ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hv,heq'⟩,Finset.mem_univ _⟩⟩ · intro u hu' v hv' he' apply Prod.ext · apply Prod.ext · exact congrArg (fun z : (Fin n × Fin n) × ((Fin n × Fin n) × Fin 2) => z.1.1) he' · exact congrArg (fun z : (Fin n × Fin n) × ((Fin n × Fin n) × Fin 2) => z.2.1.1) he' · exact congrArg (fun z : (Fin n × Fin n) × ((Fin n × Fin n) × Fin 2) => (z.2.1.2,z.2.2)) he' · have hG2 : G.card = 2 := by omega have hprod : (O ×ˢ G).card = 4 := by simp [Finset.card_product,hoc,hG2] have hlim : 4 * (3 - (localCoExtensions edges p).card) = 4 := by change 4 * (3 - G.card) = 4 rw [hG2] rw [hlim,← hprod] apply Finset.card_le_card_of_injOn (fun q => ((q.1.1,localFourNext edges q.1.1 q.1.2 q.2.1),localUnderlyingPair (q.1.2,q.2.1))) · rintro ⟨⟨u,c⟩,⟨v,d⟩⟩ h change ((u,c),(v,d)) ∈ S at h obtain ⟨htok',hch'⟩ := Finset.mem_filter.mp h obtain ⟨hUN,heq,hP⟩ := local_four_charge_true_spec htok' hch' exact Finset.mem_product.mpr ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hUN,heq⟩,hP⟩ · rintro ⟨⟨u,c⟩,⟨v,d⟩⟩ h ⟨⟨u',c'⟩,⟨v',d'⟩⟩ h' he' change ((u,c),(v,d)) ∈ S at h change ((u',c'),(v',d')) ∈ S at h' simp only [Prod.mk.injEq] at he' obtain ⟨⟨huu',hNext⟩,hpairs⟩ := he' subst u' change ({c,v} : Finset (Fin n)) = {c',v'} at hpairs obtain ⟨htok',hch'⟩ := Finset.mem_filter.mp h obtain ⟨htok'',hch''⟩ := Finset.mem_filter.mp h' have hs1 := local_four_charge_true_size_bound hu hd htok' hch' have hs2 := local_four_charge_true_size_bound hu hd htok'' hch'' have hG2' : (localCoExtensions edges p).card = 2 := hG2 obtain ⟨huc,h4',hk',hvN,hd'⟩ := local_four_token_mem.mp htok' obtain ⟨huc',h4'',hk'',hvN',hd''⟩ := local_four_token_mem.mp htok'' have hd0 : d = 0 := by simpa [localFourSlots,show (localFourTwinClass edges u c).card ≠ 4 by omega] using hd' have hd0' : d' = 0 := by simpa [localFourSlots,show (localFourTwinClass edges u c').card ≠ 4 by omega] using hd'' subst d subst d' have hcv := (local_four_token_pair_data htok').1 have hcv' := (local_four_token_pair_data htok'').1 have hcMem : c ∈ ({c',v'} : Finset (Fin n)) := hpairs ▸ Finset.mem_insert_self c {v} have hvMem : v ∈ ({c',v'} : Finset (Fin n)) := hpairs ▸ Finset.mem_insert_of_mem (Finset.mem_singleton_self v) simp only [Finset.mem_insert,Finset.mem_singleton] at hcMem hvMem rcases hcMem with e | e <;> rcases hvMem with e' | e' · exact (hcv (e.trans e'.symm)).elim · cases e cases e' rfl · subst v' subst c' obtain ⟨huNext,hEq,hP⟩ := local_four_charge_true_spec htok' hch' let y := localFourNext edges u c v change u ≠ y at huNext have hP' : ({c,v} : Finset (Fin n)) ∈ G := hP have hmore : ¬ G ⊆ {({c,v} : Finset (Fin n))} := by intro h have hh := Finset.card_le_card h rw [hG2,Finset.card_singleton] at hh omega obtain ⟨q₀,hq₀,hne⟩ := Finset.not_subset.mp hmore rw [Finset.mem_singleton] at hne have hPxy : {c,v} ∈ localCoExtensions edges {u,y} := hEq.symm ▸ hP have hqxy : q₀ ∈ localCoExtensions edges {u,y} := hEq.symm ▸ hq₀ obtain ⟨w,hw,hqw⟩ := Finset.not_disjoint_iff.mp (local_coextension_pairwise hu (by simp [huNext]) hPxy hqxy) simp only [Finset.mem_insert,Finset.mem_singleton] at hw exfalso rcases hw with e | e · subst w obtain ⟨z,hzc,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hqxy).1 hqw have hvz : v ≠ z := fun h => hne (h ▸ rfl) exact local_biclique_cross_no_move_at_class_member hu hk' (fun h => (local_mem_four_twin_class.mp h).1 rfl) (fun _ h => (local_mem_four_twin_class.mp h).2) (local_mem_four_twin_class.mpr ⟨huc,rfl⟩) hvN huNext hvz hPxy hqxy · subst w obtain ⟨z,hzv,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hqxy).1 hqw have hcz : c ≠ z := fun h => hne (h ▸ Finset.pair_comm _ _) rw [Finset.pair_comm c v] at hPxy exact local_biclique_cross_no_move_at_class_member hu hk'' (fun h => (local_mem_four_twin_class.mp h).1 rfl) (fun _ h => (local_mem_four_twin_class.mp h).2) (local_mem_four_twin_class.mpr ⟨huc',rfl⟩) hvN' huNext hcz hPxy hqxy · exact (hcv (e.trans e'.symm)).elim theorem local_four_tokens_le_deficits {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 4) : let P := (Finset.univ : Finset (Fin n)).powersetCard 2 (localFourTokens edges).card ≤ 4 * (({p ∈ P | (localExtensions edges p).card = 1}).card + ∑ p ∈ P, (3 - (localCoExtensions edges p).card)) := by have local_four_next_spec {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} (hx : x ∈ localExtensions edges {a,t}) (h : (localExtensions edges {a,t}).card ≠ 1) : localFourNext edges x a t ∈ localExtensions edges {a,t} ∧ x ≠ localFourNext edges x a t := by classical have hex : ∃ y ∈ localExtensions edges {a,t}, x ≠ y := by by_contra hn push Not at hn have heq : localExtensions edges {a,t} = {x} := by ext z rw [Finset.mem_singleton] exact ⟨fun hz => (hn z hz).symm,fun hz => hz ▸ hx⟩ simp [heq] at h simpa only [localFourNext,dif_pos hex] using Classical.choose_spec hex classical dsimp only let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let Q := (Finset.univ : Finset Bool) ×ˢ P let cap := fun q : Bool × Finset (Fin n) => if q.1 then 4 * (3 - (localCoExtensions edges q.2).card) else 4 * (if (localExtensions edges q.2).card = 1 then 1 else 0) let S := localFourTokens edges have hmap : ∀ tok ∈ S, localFourCharge edges tok ∈ Q := by rintro ⟨⟨x,a⟩,⟨t,b⟩⟩ htok obtain ⟨hat,_,hx⟩ := local_four_token_pair_data htok apply Finset.mem_product.mpr refine ⟨Finset.mem_univ _,?_⟩ unfold localFourCharge split · simp [P,hat] · rename_i hne have hy := (local_four_next_spec hx hne).2 simp [P,hy] have hsum : S.card = ∑ q ∈ Q, ((S.filter (fun tok => localFourCharge edges tok = q)).card) := by simpa only [Finset.sum_const, nsmul_eq_mul, Nat.cast_id, mul_one] using (Finset.sum_fiberwise_of_maps_to hmap (fun _ => (1 : ℕ))).symm have hle : S.card ≤ ∑ q ∈ Q, cap q := by rw [hsum] apply Finset.sum_le_sum rintro ⟨flag,p⟩ hp obtain ⟨_,hpa⟩ := Finset.mem_product.mp hp have hpc := (Finset.mem_powersetCard.mp hpa).2 cases flag · exact local_four_charge_false_bound p hpc · exact local_four_charge_true_bound hu hd p hpc refine hle.trans_eq ?_ rw [Finset.sum_product] simp only [show (Finset.univ : Finset Bool) = {false,true} by decide, Finset.sum_insert (by decide : false ∉ ({true} : Finset Bool)), Finset.sum_singleton, cap, Bool.false_eq_true, if_false, if_true, ← Finset.mul_sum, ← Finset.card_filter, ← Nat.mul_add] rfl theorem local_four_saturation {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 4) (havg : ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, (localExtensions edges p).card = 3 * n.choose 2) : (∀ a b : Fin n, a ≠ b → 2 ≤ (localExtensions edges {a,b}).card) ∧ (∀ a b : Fin n, a ≠ b → 3 ≤ (localCoExtensions edges {a,b}).card) ∧ (∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 4 → (localFourTwinClass edges a b).card = 2) := by have local_four_surplus_identity {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 4) (havg : ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, (localExtensions edges p).card = 3 * n.choose 2) : let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let d := fun p => (localExtensions edges p).card let g := fun p => (localCoExtensions edges p).card ({p ∈ P | g p = 4}).card = ({p ∈ P | d p = 4}).card + 3 * ({p ∈ P | d p = 0}).card + ({p ∈ P | d p = 1}).card + ∑ p ∈ P, (3 - g p) := by classical dsimp only let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let d := fun p => (localExtensions edges p).card let g := fun p => (localCoExtensions edges p).card have hsize : P.card = n.choose 2 := by simp [P,Finset.card_powersetCard] have hd' : ∀ p ∈ P, d p ≤ 4 := by intro p hp obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp (Finset.mem_powersetCard.mp hp).2 exact hd a b hab have hg' : ∀ p ∈ P, g p ≤ 4 := by intro p hp exact local_coextensions_card_le_four hu hd (Finset.mem_powersetCard.mp hp).2 have h1 : ∑ p ∈ P, (g p + (3 - g p)) = ∑ p ∈ P, (3 + if g p = 4 then 1 else 0) := by apply Finset.sum_congr rfl intro p hp have hg := hg' p hp interval_cases h : g p <;> decide have h2 : ∑ p ∈ P, ((d p).choose 2 + 3) = ∑ p ∈ P, (2 * d p + 3 * (if d p = 0 then 1 else 0) + (if d p = 1 then 1 else 0) + (if d p = 4 then 1 else 0)) := by apply Finset.sum_congr rfl intro p hp have hdp := hd' p hp interval_cases h : d p <;> decide simp only [Finset.sum_add_distrib, ← Finset.mul_sum, ← Finset.card_filter, Finset.sum_const, nsmul_eq_mul] at h1 h2 have hsum : ∑ p ∈ P, g p = ∑ p ∈ P, (d p).choose 2 := local_coextension_double_count edges change ∑ p ∈ P, d p = 3 * n.choose 2 at havg simp only [hsize,Nat.cast_id] at h1 h2 change ({p ∈ P | g p = 4}).card = ({p ∈ P | d p = 4}).card + 3 * ({p ∈ P | d p = 0}).card + ({p ∈ P | d p = 1}).card + ∑ p ∈ P, (3 - g p) omega have local_four_token_count {n : ℕ} (edges : Finset (Finset (Fin n))) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 4) : let F := localFourFatPairs edges let k := fun (p : Fin n × Fin n) => (localFourTwinClass edges p.1 p.2).card (localFourTokens edges).card = 4 * ((F.filter (fun p => k p = 3)).card + 2 * (F.filter (fun p => k p = 4)).card) := by dsimp only let F := localFourFatPairs edges let k := fun (p : Fin n × Fin n) => (localFourTwinClass edges p.1 p.2).card have hcalc : (localFourTokens edges).card = ∑ p ∈ F with 3 ≤ k p, 4 * (localFourSlots (k p)).card := by simp only [localFourTokens,Finset.card_map,Finset.card_sigma,Finset.card_product] apply Finset.sum_congr rfl intro p hp rw [(Finset.mem_filter.mp (Finset.mem_filter.mp hp).1).2] rw [hcalc, Finset.sum_filter, Finset.card_filter, Finset.card_filter, Finset.mul_sum, ← Finset.sum_add_distrib, Finset.mul_sum] apply Finset.sum_congr rfl intro p hp have hk : k p ≤ 4 := local_four_twin_class_card_le hd (Finset.mem_filter.mp hp).2 change (if 3 ≤ k p then 4 * (localFourSlots (k p)).card else 0) = 4 * ((if k p = 3 then 1 else 0) + 2 * (if k p = 4 then 1 else 0)) interval_cases h : k p <;> simp [h,localFourSlots] classical let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let F := localFourFatPairs edges let k := fun (p : Fin n × Fin n) => (localFourTwinClass edges p.1 p.2).card let d := fun p => (localExtensions edges p).card let g := fun p => (localCoExtensions edges p).card let A₀ := ({p ∈ P | d p = 0}).card let A₁ := ({p ∈ P | d p = 1}).card let A₄ := ({p ∈ P | d p = 4}).card let D := ∑ p ∈ P, (3 - g p) let X := (F.filter (fun p => k p = 3)).card + 2 * (F.filter (fun p => k p = 4)).card let S := ({p ∈ P | g p = 4}).card have hcF : F.card = 2 * A₄ := local_ordered_filter_count (fun p => d p = 4) have hid : S = A₄ + 3 * A₀ + A₁ + D := local_four_surplus_identity hu hd havg have htok : (localFourTokens edges).card = 4 * X := local_four_token_count edges hd have hcap : (localFourTokens edges).card ≤ 4 * (A₁ + D) := local_four_tokens_le_deficits hu hd have hstar : 2 * S ≤ ∑ p ∈ F, (k p - 1) := local_four_star_le_twin_choices hu hd have hK : ∀ p ∈ F, k p ≤ 4 := fun p hp => local_four_twin_class_card_le hd (Finset.mem_filter.mp hp).2 have hKsum : (∑ p ∈ F, (k p - 1)) ≤ F.card + X := by change (∑ p ∈ F, (k p - 1)) ≤ F.card + ((F.filter (fun p => k p = 3)).card + 2 * (F.filter (fun p => k p = 4)).card) rw [show F.card = ∑ p ∈ F, (1 : ℕ) by simp, Finset.card_filter,Finset.card_filter, Finset.mul_sum, ← Finset.sum_add_distrib, ← Finset.sum_add_distrib] apply Finset.sum_le_sum intro p hp have hh := hK p hp interval_cases h : k p <;> decide have hzero : A₀ = 0 ∧ A₁ = 0 ∧ D = 0 ∧ X = 0 := by omega obtain ⟨ha₀,ha₁,hD,hX⟩ := hzero have hKle : ∀ p ∈ F, k p - 1 ≤ 1 := by intro p hp have hk3 : k p ≠ 3 := by intro h have hpos : 0 < (F.filter (fun p => k p = 3)).card := Finset.card_pos.mpr ⟨p,Finset.mem_filter.mpr ⟨hp,h⟩⟩ change (F.filter (fun p => k p = 3)).card + 2 * (F.filter (fun p => k p = 4)).card = 0 at hX omega have hk4 : k p ≠ 4 := by intro h have hpos : 0 < (F.filter (fun p => k p = 4)).card := Finset.card_pos.mpr ⟨p,Finset.mem_filter.mpr ⟨hp,h⟩⟩ change (F.filter (fun p => k p = 3)).card + 2 * (F.filter (fun p => k p = 4)).card = 0 at hX omega have := hK p hp omega have hEqsum : (∑ p ∈ F, (k p - 1)) = ∑ _p ∈ F, (1 : ℕ) := by simp only [Finset.sum_const, nsmul_eq_mul, Nat.cast_id,mul_one] omega have hall := (Finset.sum_eq_sum_iff_of_le hKle).mp hEqsum refine ⟨?_,?_,?_⟩ · intro a b hab have hp : ({a,b} : Finset (Fin n)) ∈ P := by simp [P,hab] by_contra hn have hp' : d ({a,b} : Finset (Fin n)) = 0 ∨ d ({a,b} : Finset (Fin n)) = 1 := by change ¬ 2 ≤ d ({a,b} : Finset (Fin n)) at hn omega rcases hp' with hh | hh · have hpos : 0 < A₀ := Finset.card_pos.mpr ⟨_,Finset.mem_filter.mpr ⟨hp,hh⟩⟩ omega · have hpos : 0 < A₁ := Finset.card_pos.mpr ⟨_,Finset.mem_filter.mpr ⟨hp,hh⟩⟩ omega · intro a b hab have hp : ({a,b} : Finset (Fin n)) ∈ P := by simp [P,hab] have hterm : 3 - g ({a,b} : Finset (Fin n)) ≤ D := Finset.single_le_sum (fun q hq => Nat.zero_le (3 - g q)) hp change 3 ≤ g ({a,b} : Finset (Fin n)) omega · intro a b hab h4 have hmem : (a,b) ∈ F := Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hab,h4⟩ have h := hall (a,b) hmem change (localFourTwinClass edges a b).card - 1 = 1 at h omega theorem local_four_impossible_at_average_three {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 4) (havg : ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, (localExtensions edges p).card = 3 * n.choose 2) : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3 := by classical obtain ⟨h2,hg,hk⟩ := local_four_saturation hu hd havg have htw : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card = 4 → ∃ b, x ≠ b ∧ a ≠ b ∧ localExtensions edges {x,b} = localExtensions edges {x,a} := by intro x a hxa h4 obtain ⟨b,c,hbc,heq⟩ := Finset.card_eq_two.mp (hk x a hxa h4) have ha : a ∈ localFourTwinClass edges x a := local_mem_four_twin_class.mpr ⟨hxa,rfl⟩ rw [heq] at ha simp only [Finset.mem_insert,Finset.mem_singleton] at ha rcases ha with h | h · subst b have hc : c ∈ localFourTwinClass edges x a := by rw [heq]; simp exact ⟨c,(local_mem_four_twin_class.mp hc).1,hbc,(local_mem_four_twin_class.mp hc).2⟩ · subst c have hb : b ∈ localFourTwinClass edges x a := by rw [heq]; simp exact ⟨b,(local_mem_four_twin_class.mp hb).1,hbc.symm,(local_mem_four_twin_class.mp hb).2⟩ let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let d := fun p => (localExtensions edges p).card let F := localFourFatPairs edges let R := (localOrderedPairs n).filter (fun p => d (localUnderlyingPair p) = 2) let J := F.sigma (fun p => localExtensions edges (localUnderlyingPair p)) have hF : F.card = R.card := by have hF := local_ordered_filter_count (fun p => d p = 4) have hR := local_ordered_filter_count (fun p => d p = 2) change F.card = 2 * (P.filter (fun p => d p = 4)).card at hF change R.card = 2 * (P.filter (fun p => d p = 2)).card at hR have hh : ∑ p ∈ P, (d p + (if d p = 2 then 1 else 0)) = ∑ p ∈ P, (3 + (if d p = 4 then 1 else 0)) := by apply Finset.sum_congr rfl intro p hp obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp (Finset.mem_powersetCard.mp hp).2 have ha : 2 ≤ d ({a,b} : Finset (Fin n)) := h2 a b hab have hb : d ({a,b} : Finset (Fin n)) ≤ 4 := hd a b hab interval_cases he : d ({a,b} : Finset (Fin n)) <;> decide simp only [Finset.sum_add_distrib, ← Finset.card_filter, Finset.sum_const, nsmul_eq_mul,Nat.cast_id] at hh have hP : P.card = n.choose 2 := by simp [P,Finset.card_powersetCard] rw [hP] at hh change ∑ p ∈ P, d p = 3 * n.choose 2 at havg omega have hJ : J.card = 4 * F.card := by rw [Finset.card_sigma,Nat.mul_comm 4] apply Finset.sum_const_nat intro p hp exact (Finset.mem_filter.mp hp).2 let f := fun (j : Sigma (fun _ : Fin n × Fin n => Fin n)) => (j.1.1,j.2) have hcross : ∀ j ∈ J, j.1.2 ∈ localExtensions edges (localUnderlyingPair (f j)) ∧ f j ∈ R := by rintro ⟨⟨a,b⟩,t⟩ h obtain ⟨hfab,ht⟩ := Finset.mem_sigma.mp h obtain ⟨hab,h4⟩ := Finset.mem_filter.mp hfab have hab := local_mem_ordered_pairs.mp hab obtain ⟨c,hac,hbc,hacN,hbcN⟩ := local_fat_triangle_exists hu htw hab h4 have hta := (local_neighbors_ne ht).1 have ht' : 3 ≤ (localExtensions edges {a,b}).card := by change (localExtensions edges {a,b}).card = 4 at h4 omega have hN := local_fat_triangle_cross_exact hu hd hg htw hab hac hbc rfl hacN hbcN ht' ht have hN' : localExtensions edges {a,t} = {b,c} := (local_neighbors_comm (a := a) (b := t)).trans hN refine ⟨?_,Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hta.symm,?_⟩⟩ · change b ∈ localExtensions edges {a,t} simp [hN'] · change (localExtensions edges {a,t}).card = 2 simp [hN',hbc] have hbound : J.card ≤ 2 * R.card := by apply Finset.card_le_mul_card_image_of_maps_to (f := f) (fun j hj => (hcross j hj).2) 2 intro p hp have hp2 : (localExtensions edges (localUnderlyingPair p)).card = 2 := (Finset.mem_filter.mp hp).2 rw [← hp2] apply Finset.card_le_card_of_injOn (fun j => j.1.2) · intro j hj obtain ⟨hj,hf⟩ := Finset.mem_filter.mp hj exact hf ▸ (hcross j hj).1 · rintro ⟨⟨a,b⟩,t⟩ hj ⟨⟨a',b'⟩,t'⟩ hj' he have hf := (Finset.mem_filter.mp hj).2.trans (Finset.mem_filter.mp hj').2.symm change (a,t) = (a',t') at hf rcases Prod.mk.inj hf with ⟨rfl,rfl⟩ change b = b' at he cases he rfl have hF0 : F.card = 0 := by omega have h3le : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 3 := by intro a b hab have hmax := hd a b hab by_contra hn have h4 : (localExtensions edges {a,b}).card = 4 := by omega have hpos : 0 < F.card := Finset.card_pos.mpr ⟨(a,b),Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hab,h4⟩⟩ omega have hle : ∀ p ∈ P, d p ≤ (fun (_ : Finset (Fin n)) => 3) p := by intro p hp obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp (Finset.mem_powersetCard.mp hp).2 exact h3le a b hab have hsum : ∑ p ∈ P, d p = ∑ _p ∈ P, (3 : ℕ) := by have hp : P.card = n.choose 2 := by simp [P,Finset.card_powersetCard] rw [Finset.sum_const_nat (fun _ _ => rfl),hp,Nat.mul_comm] exact havg intro a b hab exact (Finset.sum_eq_sum_iff_of_le hle).mp hsum {a,b} (by simp [P,hab]) /-- Equality families with pair codegree bounded by four are Steiner expansions. -/ theorem classify_extremal_triple_families_of_pair_codegree_le_four {n : ℕ} (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hUnique : UniqueDisjointUnions edges) (hExtremal : edges.card = n.choose 2) (hMax : ∀ pair : Finset (Fin n), pair.card = 2 → (edges.filter (fun e => pair ⊆ e)).card ≤ 4) : ∃ blocks : Finset (Finset (Fin n)), SteinerFive blocks ∧ IsExpansion edges blocks := by have hcard (a b : Fin n) (hab : a ≠ b) : (localExtensions edges {a,b}).card = (edges.filter (fun e => ({a,b} : Finset (Fin n)) ⊆ e)).card := by have hEq (c : Fin n) : insert c ({a,b} : Finset (Fin n)) = {a,b,c} := by ext x simp only [Finset.mem_insert, Finset.mem_singleton] tauto simpa only [localExtensions, hEq] using extension_card_eq_pair_filter_card edges hUniform hab have hDeg4 (a b : Fin n) (hab : a ≠ b) : (localExtensions edges {a,b}).card ≤ 4 := by rw [hcard a b hab] exact hMax _ (by simp [hab]) have hAvg := sum_local_extensions_card edges hUniform rw [hExtremal] at hAvg have hDeg3 := local_four_impossible_at_average_three hUnique hDeg4 hAvg apply classify_extremal_triple_families_of_pair_codegree_le_three edges hUniform hUnique hExtremal intro p hp obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp rw [← hcard a b hab, hDeg3 a b hab] theorem local_containment_biclique_cross_no_move {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {A T : Finset (Fin n)} (hA : 3 ≤ A.card) {x : Fin n} (hAx : x ∉ A) (hl : ∀ a ∈ A, T ⊆ localExtensions edges {x,a}) {a t y v : Fin n} (ha : a ∈ A) (he : localExtensions edges {x,a} = T) (ht : t ∈ T) (hxy : x ≠ y) (htv : t ≠ v) (h₁ : {a,t} ∈ localCoExtensions edges {x,y}) (h₂ : {a,v} ∈ localCoExtensions edges {x,y}) : False := by obtain ⟨hat,_,hyaT⟩ := local_pair_mem_coextensions.mp h₁ obtain ⟨hav,hxaV,hyaV⟩ := local_pair_mem_coextensions.mp h₂ have hax : x ≠ a := fun h => hAx (h.symm ▸ ha) have hay : a ≠ y := (local_neighbors_ne hyaT).1.symm have hv : v ∈ T := by rw [← he,local_neighbors_comm (a := x) (b := a)] exact local_neighbors_symm hav hxaV have hex : ¬ A ⊆ {a,y} := by intro h have hh := Finset.card_le_card h have hcard : ({a,y} : Finset (Fin n)).card = 2 := by simp [hay] omega obtain ⟨a',ha',ha'n⟩ := Finset.not_subset.mp hex simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at ha'n have hxa' : x ≠ a' := fun h => hAx (h.symm ▸ ha') have hdis : Disjoint ({a,y} : Finset (Fin n)) {x,a'} := by rw [Finset.disjoint_left] intro z hz hz' simp only [Finset.mem_insert,Finset.mem_singleton] at hz hz' aesop exact local_extension_edges_cross hu (by simp [hay]) (by simp [hxa']) htv (local_neighbors_symm hat hyaT) (local_neighbors_symm hav hyaV) (hl a' ha' ht) (hl a' ha' hv) hdis theorem local_containment_biclique_cross_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {A T : Finset (Fin n)} (hA : 3 ≤ A.card) (hT : 3 ≤ T.card) {x : Fin n} (hAx : x ∉ A) (hl : ∀ a ∈ A, T ⊆ localExtensions edges {x,a}) {a t y : Fin n} (ha : a ∈ A) (he : localExtensions edges {x,a} = T) (ht : t ∈ T) (hxy : x ≠ y) (hat : {a,t} ∈ localCoExtensions edges {x,y}) : (localCoExtensions edges {x,y}).card + A.card ≤ (localExtensions edges {x,t}).card + 1 := by have hxt : x ≠ t := by have ht' : t ∈ localExtensions edges {x,a} := he.symm ▸ ht exact (local_neighbors_ne ht').1.symm have hTx : x ∉ T := fun h => (local_neighbors_ne (show x ∈ localExtensions edges {x,a} from he.symm ▸ h)).1 rfl have hrev : ∀ w ∈ T, A ⊆ localExtensions edges {x,w} := by intro w hw v hv have hxv : x ≠ v := fun h => hAx (h.symm ▸ hv) exact local_neighbors_symm hxv (hl v hv hw) have hcap : (localExtensions edges {x,t} \ A).card + A.card = (localExtensions edges {x,t}).card := Finset.card_sdiff_add_card_eq_card (hrev t ht) have hG := local_mem_coextensions.mp hat have hsub : localCoExtensions edges {x,y} ⊆ insert {t,a} ((localExtensions edges {x,t} \ A).image (fun v => ({t,v} : Finset (Fin n)))) := by intro q hq obtain ⟨u,hu,huq⟩ := Finset.not_disjoint_iff.mp (local_coextension_pairwise ‹UniqueDisjointUnions edges› (by simp [hxy]) hat hq) simp only [Finset.mem_insert,Finset.mem_singleton] at hu rcases hu with h | h · subst u obtain ⟨v,hva,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hq).1 huq by_cases htv : t = v · subst v simp [Finset.pair_comm t a] · exact (local_containment_biclique_cross_no_move ‹UniqueDisjointUnions edges› hA hAx hl ha he ht hxy htv hat hq).elim · subst u obtain ⟨v,hvt,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hq).1 huq by_cases hav : a = v · subst v simp apply Finset.mem_insert.mpr right apply Finset.mem_image.mpr have hp : v ∈ localExtensions edges {x,t} := by rw [local_neighbors_comm (a := x) (b := t)] exact local_neighbors_symm hvt.symm (local_pair_mem_coextensions.mp hq).2.1 refine ⟨v,Finset.mem_sdiff.mpr ⟨hp,?_⟩,rfl⟩ intro hv have hyta := (local_pair_mem_coextensions.mp hat).2.2 have hytv := (local_pair_mem_coextensions.mp hq).2.2 have hta : t ≠ a := (local_neighbors_ne (he.symm ▸ ht)).2 have hty : t ≠ y := (local_neighbors_ne hyta).2.symm have hex : ¬ T ⊆ {t,y} := by intro h have hh := Finset.card_le_card h have hcard : ({t,y} : Finset (Fin n)).card = 2 := by simp [hty] omega obtain ⟨w,hw,hw'⟩ := Finset.not_subset.mp hex simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at hw' have hxw : x ≠ w := fun h => hTx (h.symm ▸ hw) have hdis : Disjoint ({t,y} : Finset (Fin n)) {x,w} := by rw [Finset.disjoint_left] intro z hz hz' simp only [Finset.mem_insert,Finset.mem_singleton] at hz hz' aesop exact local_extension_edges_cross ‹UniqueDisjointUnions edges› (by simp [hty]) (by simp [hxw]) hav (local_neighbors_cycle hta.symm hyta) (local_neighbors_symm hvt.symm hytv) (hrev w hw ha) (hrev w hw hv) hdis have hc : (localCoExtensions edges {x,y}).card ≤ (localExtensions edges {x,t} \ A).card + 1 := by calc _ ≤ (insert {t,a} ((localExtensions edges {x,t} \ A).image (fun v => ({t,v} : Finset (Fin n))))).card := Finset.card_le_card hsub _ ≤ _ := (Finset.card_insert_le _ _).trans (Nat.add_le_add_right Finset.card_image_le 1) omega def localFiveContainmentClass {n : ℕ} (edges : Finset (Finset (Fin n))) (x a : Fin n) : Finset (Fin n) := Finset.univ.filter (fun b => x ≠ b ∧ localExtensions edges {x,a} ⊆ localExtensions edges {x,b}) theorem local_mem_five_twin_class {n : ℕ} {edges : Finset (Finset (Fin n))} {x a b : Fin n} : b ∈ localFiveContainmentClass edges x a ↔ x ≠ b ∧ localExtensions edges {x,a} ⊆ localExtensions edges {x,b} := by simp [localFiveContainmentClass] def localFiveFatPairs {n : ℕ} (edges : Finset (Finset (Fin n))) : Finset (Fin n × Fin n) := (localOrderedPairs n).filter (fun p => (localExtensions edges (localUnderlyingPair p)).card ≥ 4) def localFiveSlots (k : ℕ) : Finset (Fin 2) := if k = 5 then Finset.univ else {0} def localFiveTokens {n : ℕ} (edges : Finset (Finset (Fin n))) : Finset ((Fin n × Fin n) × (Fin n × Fin 2)) := (((localFiveFatPairs edges).filter (fun p => 4 ≤ (localFiveContainmentClass edges p.1 p.2).card)).sigma (fun p => (localExtensions edges (localUnderlyingPair p)) ×ˢ (localFiveSlots (localFiveContainmentClass edges p.1 p.2).card))).map ⟨fun p => (p.1,p.2),fun p q h => by cases p; cases q; cases h; rfl⟩ theorem local_five_token_mem {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} {b : Fin 2} : ((x,a),(t,b)) ∈ localFiveTokens edges ↔ x ≠ a ∧ (localExtensions edges {x,a}).card ≥ 4 ∧ 4 ≤ (localFiveContainmentClass edges x a).card ∧ t ∈ localExtensions edges {x,a} ∧ b ∈ localFiveSlots (localFiveContainmentClass edges x a).card := by unfold localFiveTokens constructor · intro h obtain ⟨q,hq,hqeq⟩ := Finset.mem_map.mp h change (q.1,q.2) = ((x,a),(t,b)) at hqeq have hf := (Prod.mk.inj hqeq).1 have hs := (Prod.mk.inj hqeq).2 have hq' := Finset.mem_sigma.mp hq simp only [hf,hs,Finset.mem_filter,Finset.mem_product] at hq' exact ⟨local_mem_ordered_pairs.mp (Finset.mem_filter.mp hq'.1.1).1, (Finset.mem_filter.mp hq'.1.1).2,hq'.1.2,hq'.2.1,hq'.2.2⟩ · rintro ⟨hxa,h4,hk,ht,hb⟩ apply Finset.mem_map.mpr refine ⟨⟨(x,a),(t,b)⟩,Finset.mem_sigma.mpr ?_,rfl⟩ exact ⟨Finset.mem_filter.mpr ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hxa,h4⟩,hk⟩,Finset.mem_product.mpr ⟨ht,hb⟩⟩ theorem local_five_token_pair_data {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} {b : Fin 2} (h : ((x,a),(t,b)) ∈ localFiveTokens edges) : a ≠ t ∧ x ≠ t ∧ x ∈ localExtensions edges {a,t} := by obtain ⟨hxa,_,_,ht,_⟩ := local_five_token_mem.mp h obtain ⟨htx,hta⟩ := local_neighbors_ne ht exact ⟨hta.symm,htx.symm,local_neighbors_cycle hxa ht⟩ theorem local_five_charge_true_spec {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} {b : Fin 2} {p : Finset (Fin n)} (htok : ((x,a),(t,b)) ∈ localFiveTokens edges) (h : localFourCharge edges ((x,a),(t,b)) = (true,p)) : let y := localFourNext edges x a t x ≠ y ∧ {x,y} = p ∧ {a,t} ∈ localCoExtensions edges p := by have local_four_next_spec {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} (hx : x ∈ localExtensions edges {a,t}) (h : (localExtensions edges {a,t}).card ≠ 1) : localFourNext edges x a t ∈ localExtensions edges {a,t} ∧ x ≠ localFourNext edges x a t := by classical have hex : ∃ y ∈ localExtensions edges {a,t}, x ≠ y := by by_contra hn push Not at hn have heq : localExtensions edges {a,t} = {x} := by ext z rw [Finset.mem_singleton] exact ⟨fun hz => (hn z hz).symm,fun hz => hz ▸ hx⟩ simp [heq] at h simpa only [localFourNext,dif_pos hex] using Classical.choose_spec hex obtain ⟨hat,_,hX⟩ := local_five_token_pair_data htok unfold localFourCharge at h split at h · exact Bool.noConfusion (Prod.mk.inj h).1 · have hcard : (localExtensions edges {a,t}).card ≠ 1 := by assumption have hNext := local_four_next_spec hX hcard have hP := (Prod.mk.inj h).2 dsimp only at hP ⊢ exact ⟨hNext.2,hP,hP ▸ local_pair_mem_coextensions.mpr ⟨hat,hX,hNext.1⟩⟩ theorem local_five_tokens_le_deficits {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 5) : let P := (Finset.univ : Finset (Fin n)).powersetCard 2 (localFiveTokens edges).card ≤ 4 * (({p ∈ P | (localExtensions edges p).card = 1}).card + ∑ p ∈ P, (3 - (localCoExtensions edges p).card)) := by have local_five_charge_true_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 5) (p : Finset (Fin n)) (hp : p.card = 2) : ((localFiveTokens edges).filter (fun q => localFourCharge edges q = (true,p))).card ≤ 4 * (3 - (localCoExtensions edges p).card) := by have local_five_charge_true_size_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 5) {x a t : Fin n} {b : Fin 2} {p : Finset (Fin n)} (htok : ((x,a),(t,b)) ∈ localFiveTokens edges) (h : localFourCharge edges ((x,a),(t,b)) = (true,p)) : (localCoExtensions edges p).card + (localFiveContainmentClass edges x a).card ≤ 6 := by obtain ⟨hxa,h4,hk,ht,hb⟩ := local_five_token_mem.mp htok obtain ⟨hxy,heq,hG⟩ := local_five_charge_true_spec htok h rw [← heq] at hG ⊢ have ha : a ∈ localFiveContainmentClass edges x a := local_mem_five_twin_class.mpr ⟨hxa,Finset.Subset.rfl⟩ have hB := local_containment_biclique_cross_bound hu (A := localFiveContainmentClass edges x a) (by omega) (by omega : 3 ≤ (localExtensions edges {x,a}).card) (fun h => (local_mem_five_twin_class.mp h).1 rfl) (fun _ h => (local_mem_five_twin_class.mp h).2) ha rfl ht hxy hG have hD := hd x t (local_five_token_pair_data htok).2.1 omega classical let S := (localFiveTokens edges).filter (fun q => localFourCharge edges q = (true,p)) let G := localCoExtensions edges p let O := (localOrderedPairs n).filter (fun q => localUnderlyingPair q = p) have hoc : O.card = 2 := local_orderings_two hp by_cases he : S = ∅ · simp [show {q ∈ localFiveTokens edges | localFourCharge edges q = (true,p)} = S from rfl,he] obtain ⟨q,hq⟩ := Finset.nonempty_iff_ne_empty.mpr he obtain ⟨⟨x,a⟩,⟨t,b⟩⟩ := q obtain ⟨htok,hch⟩ := Finset.mem_filter.mp hq have ⟨_,_,hG⟩ := local_five_charge_true_spec htok hch have hs := local_five_charge_true_size_bound hu hd htok hch have hk := (local_five_token_mem.mp htok).2.2.1 have hpos : 0 < G.card := Finset.card_pos.mpr ⟨_,hG⟩ have hcap : G.card ≤ 2 := by change (localCoExtensions edges p).card ≤ 2; omega by_cases hG1 : G.card = 1 · have hG_eq : G = {({a,t} : Finset (Fin n))} := by apply (Finset.eq_of_subset_of_card_le (show ({({a,t} : Finset (Fin n))} : Finset _) ⊆ G by simpa only [Finset.singleton_subset_iff] using hG) ?_).symm rw [hG1,Finset.card_singleton] let R := (localOrderedPairs n).filter (fun q => localUnderlyingPair q = {a,t}) have hR : R.card = 2 := local_orderings_two (local_mem_coextensions.mp hG).1 have hprod : (O ×ˢ (R ×ˢ (Finset.univ : Finset (Fin 2)))).card = 8 := by simp [Finset.card_product,hoc,hR] have hlim : 4 * (3 - (localCoExtensions edges p).card) = 8 := by change 4 * (3 - G.card) = 8 rw [hG1] rw [hlim, ← hprod] apply Finset.card_le_card_of_injOn (fun q => ((q.1.1,localFourNext edges q.1.1 q.1.2 q.2.1),((q.1.2,q.2.1),q.2.2))) · rintro ⟨⟨u,c⟩,⟨v,d⟩⟩ h change ((u,c),(v,d)) ∈ S at h obtain ⟨htok',hch'⟩ := Finset.mem_filter.mp h obtain ⟨hUN,heq,hP⟩ := local_five_charge_true_spec htok' hch' have hv : c ≠ v := (local_five_token_pair_data htok').1 have heq' : {c,v} = ({a,t} : Finset (Fin n)) := by change ({c,v} : Finset (Fin n)) ∈ G at hP rwa [hG_eq,Finset.mem_singleton] at hP exact Finset.mem_product.mpr ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hUN,heq⟩,Finset.mem_product.mpr ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hv,heq'⟩,Finset.mem_univ _⟩⟩ · intro u hu' v hv' he' apply Prod.ext · apply Prod.ext · exact congrArg (fun z : (Fin n × Fin n) × ((Fin n × Fin n) × Fin 2) => z.1.1) he' · exact congrArg (fun z : (Fin n × Fin n) × ((Fin n × Fin n) × Fin 2) => z.2.1.1) he' · exact congrArg (fun z : (Fin n × Fin n) × ((Fin n × Fin n) × Fin 2) => (z.2.1.2,z.2.2)) he' · have hG2 : G.card = 2 := by omega have hprod : (O ×ˢ G).card = 4 := by simp [Finset.card_product,hoc,hG2] have hlim : 4 * (3 - (localCoExtensions edges p).card) = 4 := by change 4 * (3 - G.card) = 4 rw [hG2] rw [hlim,← hprod] apply Finset.card_le_card_of_injOn (fun q => ((q.1.1,localFourNext edges q.1.1 q.1.2 q.2.1),localUnderlyingPair (q.1.2,q.2.1))) · rintro ⟨⟨u,c⟩,⟨v,d⟩⟩ h change ((u,c),(v,d)) ∈ S at h obtain ⟨htok',hch'⟩ := Finset.mem_filter.mp h obtain ⟨hUN,heq,hP⟩ := local_five_charge_true_spec htok' hch' exact Finset.mem_product.mpr ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hUN,heq⟩,hP⟩ · rintro ⟨⟨u,c⟩,⟨v,d⟩⟩ h ⟨⟨u',c'⟩,⟨v',d'⟩⟩ h' he' change ((u,c),(v,d)) ∈ S at h change ((u',c'),(v',d')) ∈ S at h' simp only [Prod.mk.injEq] at he' obtain ⟨⟨huu',hNext⟩,hpairs⟩ := he' subst u' change ({c,v} : Finset (Fin n)) = {c',v'} at hpairs obtain ⟨htok',hch'⟩ := Finset.mem_filter.mp h obtain ⟨htok'',hch''⟩ := Finset.mem_filter.mp h' have hs1 := local_five_charge_true_size_bound hu hd htok' hch' have hs2 := local_five_charge_true_size_bound hu hd htok'' hch'' have hG2' : (localCoExtensions edges p).card = 2 := hG2 obtain ⟨huc,h4',hk',hvN,hd'⟩ := local_five_token_mem.mp htok' obtain ⟨huc',h4'',hk'',hvN',hd''⟩ := local_five_token_mem.mp htok'' have hd0 : d = 0 := by simpa [localFiveSlots,show (localFiveContainmentClass edges u c).card ≠ 5 by omega] using hd' have hd0' : d' = 0 := by simpa [localFiveSlots,show (localFiveContainmentClass edges u c').card ≠ 5 by omega] using hd'' subst d subst d' have hcv := (local_five_token_pair_data htok').1 have hcv' := (local_five_token_pair_data htok'').1 have hcMem : c ∈ ({c',v'} : Finset (Fin n)) := hpairs ▸ Finset.mem_insert_self c {v} have hvMem : v ∈ ({c',v'} : Finset (Fin n)) := hpairs ▸ Finset.mem_insert_of_mem (Finset.mem_singleton_self v) simp only [Finset.mem_insert,Finset.mem_singleton] at hcMem hvMem rcases hcMem with e | e <;> rcases hvMem with e' | e' · exact (hcv (e.trans e'.symm)).elim · cases e cases e' rfl · subst v' subst c' obtain ⟨huNext,hEq,hP⟩ := local_five_charge_true_spec htok' hch' let y := localFourNext edges u c v change u ≠ y at huNext have hP' : ({c,v} : Finset (Fin n)) ∈ G := hP have hmore : ¬ G ⊆ {({c,v} : Finset (Fin n))} := by intro h have hh := Finset.card_le_card h rw [hG2,Finset.card_singleton] at hh omega obtain ⟨q₀,hq₀,hne⟩ := Finset.not_subset.mp hmore rw [Finset.mem_singleton] at hne have hPxy : {c,v} ∈ localCoExtensions edges {u,y} := hEq.symm ▸ hP have hqxy : q₀ ∈ localCoExtensions edges {u,y} := hEq.symm ▸ hq₀ obtain ⟨w,hw,hqw⟩ := Finset.not_disjoint_iff.mp (local_coextension_pairwise hu (by simp [huNext]) hPxy hqxy) simp only [Finset.mem_insert,Finset.mem_singleton] at hw exfalso rcases hw with e | e · subst w obtain ⟨z,hzc,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hqxy).1 hqw have hvz : v ≠ z := fun h => hne (h ▸ rfl) exact local_containment_biclique_cross_no_move hu (A := localFiveContainmentClass edges u c) (by omega) (fun h => (local_mem_five_twin_class.mp h).1 rfl) (fun _ h => (local_mem_five_twin_class.mp h).2) (local_mem_five_twin_class.mpr ⟨huc,Finset.Subset.rfl⟩) rfl hvN huNext hvz hPxy hqxy · subst w obtain ⟨z,hzv,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hqxy).1 hqw have hcz : c ≠ z := fun h => hne (h ▸ Finset.pair_comm _ _) rw [Finset.pair_comm c v] at hPxy exact local_containment_biclique_cross_no_move hu (A := localFiveContainmentClass edges u v) (by omega) (fun h => (local_mem_five_twin_class.mp h).1 rfl) (fun _ h => (local_mem_five_twin_class.mp h).2) (local_mem_five_twin_class.mpr ⟨huc',Finset.Subset.rfl⟩) rfl hvN' huNext hcz hPxy hqxy · exact (hcv (e.trans e'.symm)).elim have local_five_charge_false_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (p : Finset (Fin n)) (hp : p.card = 2) : ((localFiveTokens edges).filter (fun q => localFourCharge edges q = (false,p))).card ≤ 4 * (if (localExtensions edges p).card = 1 then 1 else 0) := by have local_five_charge_false_spec {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} {b : Fin 2} {p : Finset (Fin n)} (h : localFourCharge edges ((x,a),(t,b)) = (false,p)) : (localExtensions edges {a,t}).card = 1 ∧ {a,t} = p := by unfold localFourCharge at h split at h · exact ⟨by assumption,(Prod.mk.inj h).2⟩ · exact Bool.noConfusion (Prod.mk.inj h).1 classical let S := (localFiveTokens edges).filter (fun q => localFourCharge edges q = (false,p)) by_cases hd : (localExtensions edges p).card = 1 · simp only [hd,if_true,mul_one] let O := (localOrderedPairs n).filter (fun q => localUnderlyingPair q = p) have hc : (O ×ˢ (Finset.univ : Finset (Fin 2))).card = 4 := by rw [Finset.card_product,local_orderings_two hp] decide rw [← hc] apply Finset.card_le_card_of_injOn (fun q => ((q.1.2,q.2.1),q.2.2)) · rintro ⟨⟨x,a⟩,⟨t,b⟩⟩ h change ((x,a),(t,b)) ∈ S at h obtain ⟨htok,hch⟩ := Finset.mem_filter.mp h have hh := local_five_charge_false_spec hch have hp' := local_five_token_pair_data htok apply Finset.mem_product.mpr exact ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hp'.1, hh.2⟩, Finset.mem_univ _⟩ · rintro ⟨⟨x,a⟩,⟨t,b⟩⟩ h ⟨⟨y,c⟩,⟨u,d⟩⟩ h' heq change ((x,a),(t,b)) ∈ S at h change ((y,c),(u,d)) ∈ S at h' simp only [Prod.mk.injEq] at heq rcases heq with ⟨⟨rfl,rfl⟩,rfl⟩ obtain ⟨htok,hch⟩ := Finset.mem_filter.mp h obtain ⟨htok',hch'⟩ := Finset.mem_filter.mp h' have ⟨h1,_⟩ := local_five_charge_false_spec hch have hx := (local_five_token_pair_data htok).2.2 have hy := (local_five_token_pair_data htok').2.2 have hxy := Finset.card_le_one.mp (by omega : (localExtensions edges {a,t}).card ≤ 1) _ hx _ hy cases hxy rfl · simp only [hd,if_false,Nat.mul_zero] apply Nat.le_of_eq apply Finset.card_eq_zero.mpr apply Finset.eq_empty_iff_forall_notMem.mpr intro q h obtain ⟨⟨x,a⟩,⟨t,b⟩⟩ := q have hh := local_five_charge_false_spec (Finset.mem_filter.mp h).2 exact hd (hh.2 ▸ hh.1) have local_four_next_spec {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} (hx : x ∈ localExtensions edges {a,t}) (h : (localExtensions edges {a,t}).card ≠ 1) : localFourNext edges x a t ∈ localExtensions edges {a,t} ∧ x ≠ localFourNext edges x a t := by classical have hex : ∃ y ∈ localExtensions edges {a,t}, x ≠ y := by by_contra hn push Not at hn have heq : localExtensions edges {a,t} = {x} := by ext z rw [Finset.mem_singleton] exact ⟨fun hz => (hn z hz).symm,fun hz => hz ▸ hx⟩ simp [heq] at h simpa only [localFourNext,dif_pos hex] using Classical.choose_spec hex classical dsimp only let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let Q := (Finset.univ : Finset Bool) ×ˢ P let cap := fun q : Bool × Finset (Fin n) => if q.1 then 4 * (3 - (localCoExtensions edges q.2).card) else 4 * (if (localExtensions edges q.2).card = 1 then 1 else 0) let S := localFiveTokens edges have hmap : ∀ tok ∈ S, localFourCharge edges tok ∈ Q := by rintro ⟨⟨x,a⟩,⟨t,b⟩⟩ htok obtain ⟨hat,_,hx⟩ := local_five_token_pair_data htok apply Finset.mem_product.mpr refine ⟨Finset.mem_univ _,?_⟩ unfold localFourCharge split · simp [P,hat] · rename_i hne have hy := (local_four_next_spec hx hne).2 simp [P,hy] have hsum : S.card = ∑ q ∈ Q, ((S.filter (fun tok => localFourCharge edges tok = q)).card) := by simpa only [Finset.sum_const, nsmul_eq_mul, Nat.cast_id, mul_one] using (Finset.sum_fiberwise_of_maps_to hmap (fun _ => (1 : ℕ))).symm have hle : S.card ≤ ∑ q ∈ Q, cap q := by rw [hsum] apply Finset.sum_le_sum rintro ⟨flag,p⟩ hp obtain ⟨_,hpa⟩ := Finset.mem_product.mp hp have hpc := (Finset.mem_powersetCard.mp hpa).2 cases flag · exact local_five_charge_false_bound p hpc · exact local_five_charge_true_bound hu hd p hpc refine hle.trans_eq ?_ rw [Finset.sum_product] simp only [show (Finset.univ : Finset Bool) = {false,true} by decide, Finset.sum_insert (by decide : false ∉ ({true} : Finset Bool)), Finset.sum_singleton, cap, Bool.false_eq_true, if_false, if_true, ← Finset.mul_sum, ← Finset.card_filter, ← Nat.mul_add] rfl def localFiveCompanions {n : ℕ} (x a : Fin n) : Finset (Fin n) := (Finset.univ.erase x).erase a def localFiveOverlap {n : ℕ} (edges : Finset (Finset (Fin n))) (x a b : Fin n) : Finset (Fin n) := localExtensions edges {x,a} ∩ localExtensions edges {x,b} def localFiveScore {n : ℕ} (edges : Finset (Finset (Fin n))) (x a : Fin n) : ℕ := ∑ b ∈ localFiveCompanions x a, ((localFiveOverlap edges x a b).card - 3) def localFiveBonus {n : ℕ} (edges : Finset (Finset (Fin n))) (x a : Fin n) : ℕ := if 4 ≤ (localExtensions edges {x,a}).card then (localFiveContainmentClass edges x a).card - 3 else 0 def localFivePotential (d : ℕ) : ℕ := if d = 4 then 1 else if d = 5 then 3 else 0 theorem local_mem_five_companions {n : ℕ} {x a b : Fin n} : b ∈ localFiveCompanions x a ↔ b ≠ a ∧ b ≠ x := by simp [localFiveCompanions] theorem local_five_score_at_five {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 5) {x a : Fin n} (hxa : x ≠ a) (h5 : (localExtensions edges {x,a}).card = 5) : let e := (localFiveContainmentClass edges x a).card - 1 let q := ({b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 4}).card localFiveScore edges x a = 2 * e + q ∧ 5 * e + 4 * q ≤ 20 := by have local_five_overlap_capacity {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 5) {x a : Fin n} (hxa : x ≠ a) : ∑ b ∈ localFiveCompanions x a, (localFiveOverlap edges x a b).card ≤ 4 * (localExtensions edges {x,a}).card := by classical let T := localExtensions edges {x,a} let C := localFiveCompanions x a have h : ∀ b ∈ C, (localFiveOverlap edges x a b).card = ({t ∈ T | t ∈ localExtensions edges {x,b}}).card := by intro b hb rfl have hSwap : ∑ b ∈ C, ({t ∈ T | t ∈ localExtensions edges {x,b}}).card = ∑ t ∈ T, ({b ∈ C | t ∈ localExtensions edges {x,b}}).card := by simp only [Finset.card_filter] exact Finset.sum_comm calc _ = ∑ b ∈ C, ({t ∈ T | t ∈ localExtensions edges {x,b}}).card := Finset.sum_congr rfl h _ = ∑ t ∈ T, ({b ∈ C | t ∈ localExtensions edges {x,b}}).card := hSwap _ ≤ ∑ _t ∈ T, (4 : ℕ) := by apply Finset.sum_le_sum intro t ht have hxt := (local_neighbors_ne ht).1.symm have ha : a ∈ localExtensions edges {x,t} := local_neighbors_symm hxa ht have hsub : {b ∈ C | t ∈ localExtensions edges {x,b}} ⊆ (localExtensions edges {x,t}).erase a := by intro b hb obtain ⟨hb,hbt⟩ := Finset.mem_filter.mp hb obtain ⟨hba,hbx⟩ := local_mem_five_companions.mp hb exact Finset.mem_erase.mpr ⟨hba,local_neighbors_symm hbx.symm hbt⟩ have hc := Finset.card_le_card hsub rw [Finset.card_erase_of_mem ha] at hc have := hd x t hxt omega _ = _ := by simp [T,Nat.mul_comm] dsimp only let T := localExtensions edges {x,a} let A := localFiveContainmentClass edges x a let C := localFiveCompanions x a have haa : a ∈ A := local_mem_five_twin_class.mpr ⟨hxa,Finset.Subset.rfl⟩ have hclass : A.erase a = C.filter (fun b => (localFiveOverlap edges x a b).card = 5) := by ext b rw [Finset.mem_erase,Finset.mem_filter,local_mem_five_companions,local_mem_five_twin_class] simp only [and_assoc,ne_comm (a := x) (b := b)] refine and_congr_right fun _ => and_congr_right fun _ => ?_ change T ⊆ localExtensions edges {x,b} ↔ (T ∩ localExtensions edges {x,b}).card = 5 constructor · intro h rw [Finset.inter_eq_left.mpr h] exact h5 · intro h have hh : T ∩ localExtensions edges {x,b} = T := Finset.eq_of_subset_of_card_le Finset.inter_subset_left (by rw [h5,h]) exact Finset.inter_eq_left.mp hh have heq : (localFiveContainmentClass edges x a).card - 1 = (C.filter (fun b => (localFiveOverlap edges x a b).card = 5)).card := by rw [← Finset.card_erase_of_mem haa,hclass] have hc : ∀ b : Fin n, (localFiveOverlap edges x a b).card ≤ 5 := fun b => (Finset.card_le_card (show localFiveOverlap edges x a b ⊆ T from Finset.inter_subset_left)).trans_eq h5 rw [heq] constructor · unfold localFiveScore rw [Finset.card_filter,Finset.card_filter,Finset.mul_sum,← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro b hb have h := hc b interval_cases he : (localFiveOverlap edges x a b).card <;> decide · have hcap := local_five_overlap_capacity hd hxa rw [h5] at hcap refine le_trans ?_ hcap rw [Finset.card_filter,Finset.card_filter,Finset.mul_sum,Finset.mul_sum,← Finset.sum_add_distrib] apply Finset.sum_le_sum intro b hb have h := hc b interval_cases he : (localFiveOverlap edges x a b).card <;> decide theorem local_five_both_companions_same {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {x a b c : Fin n} (hxa : x ≠ a) (hmax : (localExtensions edges {x,a}).card ≤ 5) (hb : b ∈ localFiveCompanions x a) (hc : c ∈ localFiveCompanions a x) (hB : 4 ≤ (localFiveOverlap edges x a b).card) (hC : 4 ≤ (localFiveOverlap edges a x c).card) : b = c := by let B := localFiveOverlap edges x a b let C := localFiveOverlap edges a x c let T := localExtensions edges {x,a} have hBT : B ⊆ T := Finset.inter_subset_left have hCT : C ⊆ T := by rw [show T = localExtensions edges {a,x} from local_neighbors_comm] exact Finset.inter_subset_left have hcap := Finset.card_le_card (Finset.union_subset hBT hCT) have hc' := Finset.card_union_add_card_inter B C change B.card ≥ 4 at hB change C.card ≥ 4 at hC change T.card ≤ 5 at hmax have ⟨u,hu',v,hv',huv⟩ := Finset.one_lt_card.mp (by omega : 1 < (B ∩ C).card) obtain ⟨huB,huC⟩ := Finset.mem_inter.mp hu' obtain ⟨hvB,hvC⟩ := Finset.mem_inter.mp hv' have huBN : u ∈ localExtensions edges {x,b} := (Finset.mem_inter.mp huB).2 have huCN : u ∈ localExtensions edges {a,c} := (Finset.mem_inter.mp huC).2 have hvBN : v ∈ localExtensions edges {x,b} := (Finset.mem_inter.mp hvB).2 have hvCN : v ∈ localExtensions edges {a,c} := (Finset.mem_inter.mp hvC).2 have ⟨hba,hbx⟩ := local_mem_five_companions.mp hb have ⟨hcx,hca⟩ := local_mem_five_companions.mp hc by_contra hbc have hdis : Disjoint ({x,b} : Finset (Fin n)) {a,c} := by rw [Finset.disjoint_left] intro z hz hz' simp only [Finset.mem_insert,Finset.mem_singleton] at hz hz' aesop exact local_extension_edges_cross hu (by simp [hbx.symm]) (by simp [hca.symm]) huv huBN hvBN huCN hvCN hdis theorem local_five_pointwise_score_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 5) {x a : Fin n} (hxa : x ≠ a) : localFiveScore edges x a + localFiveScore edges a x ≤ 2 * localFivePotential (localExtensions edges {x,a}).card + localFiveBonus edges x a + localFiveBonus edges a x := by have local_five_score_at_four {n : ℕ} {edges : Finset (Finset (Fin n))} {x a : Fin n} (hxa : x ≠ a) (h4 : (localExtensions edges {x,a}).card = 4) : localFiveScore edges x a = (localFiveContainmentClass edges x a).card - 1 := by let T := localExtensions edges {x,a} let A := localFiveContainmentClass edges x a let C := localFiveCompanions x a have haa : a ∈ A := local_mem_five_twin_class.mpr ⟨hxa,Finset.Subset.rfl⟩ have hclass : A.erase a = C.filter (fun b => (localFiveOverlap edges x a b).card = 4) := by ext b rw [Finset.mem_erase,Finset.mem_filter,local_mem_five_companions,local_mem_five_twin_class] simp only [and_assoc,ne_comm (a := x) (b := b)] refine and_congr_right fun _ => and_congr_right fun _ => ?_ change T ⊆ localExtensions edges {x,b} ↔ (T ∩ localExtensions edges {x,b}).card = 4 constructor · intro h rw [Finset.inter_eq_left.mpr h] exact h4 · intro h have hh : T ∩ localExtensions edges {x,b} = T := Finset.eq_of_subset_of_card_le Finset.inter_subset_left (by rw [h4,h]) exact Finset.inter_eq_left.mp hh rw [← Finset.card_erase_of_mem haa,hclass,Finset.card_filter] apply Finset.sum_congr rfl intro b hb have hc : (localFiveOverlap edges x a b).card ≤ 4 := (Finset.card_le_card (show localFiveOverlap edges x a b ⊆ T from Finset.inter_subset_left)).trans_eq h4 interval_cases h : (localFiveOverlap edges x a b).card <;> decide have local_five_score_at_small_degree {n : ℕ} {edges : Finset (Finset (Fin n))} {x a : Fin n} (h : (localExtensions edges {x,a}).card ≤ 3) : localFiveScore edges x a = 0 := by unfold localFiveScore apply Finset.sum_eq_zero intro b hb have hc : (localFiveOverlap edges x a b).card ≤ (localExtensions edges {x,a}).card := Finset.card_le_card Finset.inter_subset_left omega classical have hn := hd x a hxa have hcomm : (localExtensions edges {a,x}).card = (localExtensions edges {x,a}).card := congrArg Finset.card local_neighbors_comm by_cases hsmall : (localExtensions edges {x,a}).card ≤ 3 · have hsmall' : (localExtensions edges {a,x}).card ≤ 3 := by omega rw [local_five_score_at_small_degree hsmall,local_five_score_at_small_degree hsmall'] omega have hsingle : ∀ (u v : Fin n), u ≠ v → 2 ≤ (localExtensions edges {u,v}).card → localFiveScore edges u v ≤ 2 * localFivePotential (localExtensions edges {u,v}).card + localFiveBonus edges u v := by intro u v huv hmin have hmax := hd u v huv by_cases hh : (localExtensions edges {u,v}).card ≤ 3 · simp [local_five_score_at_small_degree hh] by_cases hh4 : (localExtensions edges {u,v}).card = 4 · rw [local_five_score_at_four huv hh4] simp [localFivePotential,localFiveBonus,hh4] omega have hh5 : (localExtensions edges {u,v}).card = 5 := by omega obtain ⟨hs,hc⟩ := local_five_score_at_five hd huv hh5 simp [localFivePotential,localFiveBonus,hh5] omega by_cases h1 : localFiveScore edges x a = 0 · have hle := hsingle a x hxa.symm (by omega) rw [hcomm] at hle omega by_cases h2 : localFiveScore edges a x = 0 · have hle := hsingle x a hxa (by omega) omega have hpos : ∀ (u v : Fin n), localFiveScore edges u v ≠ 0 → ∃ b ∈ localFiveCompanions u v, 4 ≤ (localFiveOverlap edges u v b).card := by intro u v hv by_contra hn push Not at hn apply hv unfold localFiveScore apply Finset.sum_eq_zero intro b hb have := hn b hb omega obtain ⟨b,hb,hB⟩ := hpos x a h1 obtain ⟨c,hc,hC⟩ := hpos a x h2 have heq := local_five_both_companions_same hu hxa hn hb hc hB hC subst c have hW₁ : localFiveScore edges x a = (localFiveOverlap edges x a b).card - 3 := by unfold localFiveScore apply Finset.sum_eq_single b · intro u hu' hub by_contra hneg have hu₄ : 4 ≤ (localFiveOverlap edges x a u).card := by omega exact hub (local_five_both_companions_same hu hxa hn hu' hc hu₄ hC) · exact fun h => (h hb).elim have hW₂ : localFiveScore edges a x = (localFiveOverlap edges a x b).card - 3 := by unfold localFiveScore apply Finset.sum_eq_single b · intro u hu' hub by_contra hneg have hu₄ : 4 ≤ (localFiveOverlap edges a x u).card := by omega exact hub (local_five_both_companions_same hu hxa hn hb hu' hB hu₄).symm · exact fun h => (h hc).elim have hcb : (localFiveOverlap edges x a b).card ≤ (localExtensions edges {x,a}).card := Finset.card_le_card Finset.inter_subset_left have hcb' : (localFiveOverlap edges a x b).card ≤ (localExtensions edges {a,x}).card := Finset.card_le_card Finset.inter_subset_left by_cases h4 : (localExtensions edges {x,a}).card = 4 · simp [localFivePotential,h4] omega have h5 : (localExtensions edges {x,a}).card = 5 := by omega simp [localFivePotential,h5] omega theorem local_five_star_data {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {a b : Fin n} (hab : a ≠ b) (hg : 4 ≤ (localCoExtensions edges {a,b}).card) : ∃ x, x ≠ a ∧ x ≠ b ∧ (localCoExtensions edges {a,b}).card ≤ (localFiveOverlap edges x a b).card := by let G := localCoExtensions edges {a,b} have hG : ∀ q ∈ G, q.card = 2 := fun q hq => (local_mem_coextensions.mp hq).1 change 4 ≤ G.card at hg rcases local_intersecting_pair_family G hG (fun _ hq _ hr => local_coextension_pairwise hu (by simp [hab]) hq hr) with h | ⟨x,hx⟩ | ⟨u,v,w,_,_,_,heq⟩ · omega · obtain ⟨q,hq⟩ := Finset.card_pos.mp (show 0 < G.card by omega) have ha := (local_mem_coextensions.mp hq).2 (show a ∈ ({a,b} : Finset (Fin n)) by simp) have hb := (local_mem_coextensions.mp hq).2 (show b ∈ ({a,b} : Finset (Fin n)) by simp) exact ⟨x,fun h => (Finset.mem_filter.mp ha).2.1 (h ▸ hx q hq), fun h => (Finset.mem_filter.mp hb).2.1 (h ▸ hx q hq),local_center_card_le_inter hx⟩ · have h : ({{u,v},{u,w},{v,w}} : Finset (Finset (Fin n))).card ≤ 3 := (Finset.card_insert_le _ _).trans (Nat.add_le_add_right ((Finset.card_insert_le _ _).trans (by simp)) 1) rw [heq] at hg omega theorem local_five_ordered_pair_sum {n : ℕ} (f : Finset (Fin n) → ℕ) : ∑ p ∈ localOrderedPairs n, f (localUnderlyingPair p) = 2 * ∑ p ∈ ((Finset.univ : Finset (Fin n)).powersetCard 2), f p := by classical let pairs := (Finset.univ : Finset (Fin n)).powersetCard 2 have hmap : ∀ p ∈ localOrderedPairs n, localUnderlyingPair p ∈ pairs := by intro p hp simp [pairs,localUnderlyingPair,local_mem_ordered_pairs.mp hp] rw [← Finset.sum_fiberwise_of_maps_to' hmap f, Finset.mul_sum] apply Finset.sum_congr rfl intro p hp rw [Finset.sum_const_nat (fun _ _ => rfl)] rw [local_orderings_two (Finset.mem_powersetCard.mp hp).2] theorem local_five_score_sum_lower {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) : 2 * (∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, ((localCoExtensions edges p).card - 3)) ≤ ∑ p ∈ localOrderedPairs n, localFiveScore edges p.1 p.2 := by classical let O := localOrderedPairs n let C := fun (p : Fin n × Fin n) => localFiveCompanions p.1 p.2 let J := O.sigma C let trans := fun (p : Sigma (fun _ : Fin n × Fin n => Fin n)) => (p.1.2,p.2) let wt := fun (p : Sigma (fun _ : Fin n × Fin n => Fin n)) => (localFiveOverlap edges p.1.1 p.1.2 p.2).card - 3 have ht : ∀ p ∈ J, trans p ∈ O := by intro p hp exact local_mem_ordered_pairs.mpr (local_mem_five_companions.mp (Finset.mem_sigma.mp hp).2).1.symm have hbound : ∑ q ∈ O, ((localCoExtensions edges (localUnderlyingPair q)).card - 3) ≤ ∑ p ∈ J, wt p := by rw [← Finset.sum_fiberwise_of_maps_to ht wt] apply Finset.sum_le_sum rintro ⟨a,b⟩ hp have hab := local_mem_ordered_pairs.mp hp change (localCoExtensions edges {a,b}).card - 3 ≤ ∑ p ∈ J with trans p = (a,b), wt p by_cases hh : 4 ≤ (localCoExtensions edges {a,b}).card · obtain ⟨x,hxa,hxb,hg⟩ := local_five_star_data hu hab hh let j : Sigma (fun _ : Fin n × Fin n => Fin n) := ⟨(x,a),b⟩ have hj : j ∈ J := Finset.mem_sigma.mpr ⟨local_mem_ordered_pairs.mpr hxa, local_mem_five_companions.mpr ⟨hab.symm,hxb.symm⟩⟩ have hf : j ∈ J.filter (fun p => trans p = (a,b)) := Finset.mem_filter.mpr ⟨hj,rfl⟩ refine le_trans ?_ (Finset.single_le_sum (fun _ _ => Nat.zero_le _) hf) change (localCoExtensions edges {a,b}).card ≤ (localFiveOverlap edges x a b).card at hg exact Nat.sub_le_sub_right hg 3 · have h0 : (localCoExtensions edges {a,b}).card - 3 = 0 := by omega simp [h0] have hid := local_five_ordered_pair_sum (fun p : Finset (Fin n) => (localCoExtensions edges p).card - 3) rw [← hid] refine hbound.trans_eq ?_ exact Finset.sum_sigma _ _ _ theorem local_five_excess_identity {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 5) (havg : ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, (localExtensions edges p).card = 3 * n.choose 2) : let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let d := fun p => (localExtensions edges p).card ∑ p ∈ P, ((localCoExtensions edges p).card - 3) = (∑ p ∈ P, localFivePotential (d p)) + 3 * (P.filter (fun p => d p = 0)).card + (P.filter (fun p => d p = 1)).card + ∑ p ∈ P, (3 - (localCoExtensions edges p).card) := by classical dsimp only let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let d := fun p => (localExtensions edges p).card let g := fun p => (localCoExtensions edges p).card have hsize : P.card = n.choose 2 := by simp [P,Finset.card_powersetCard] have hsum : ∑ p ∈ P, g p = ∑ p ∈ P, (d p).choose 2 := local_coextension_double_count edges have hg : ∑ p ∈ P, (g p + (3 - g p)) = ∑ p ∈ P, (3 + (g p - 3)) := by apply Finset.sum_congr rfl intro p hp omega have hcalc : ∑ p ∈ P, ((d p).choose 2 + 3) = ∑ p ∈ P, (2 * d p + localFivePotential (d p) + 3 * (if d p = 0 then 1 else 0) + (if d p = 1 then 1 else 0)) := by apply Finset.sum_congr rfl intro p hp obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp (Finset.mem_powersetCard.mp hp).2 have hl : d ({a,b} : Finset (Fin n)) ≤ 5 := hd a b hab interval_cases h : d ({a,b} : Finset (Fin n)) <;> decide simp only [Finset.sum_add_distrib,← Finset.mul_sum,← Finset.card_filter, Finset.sum_const,nsmul_eq_mul,Nat.cast_id,hsize] at hg hcalc change ∑ p ∈ P, d p = 3 * n.choose 2 at havg change ∑ p ∈ P, (g p - 3) = (∑ p ∈ P, localFivePotential (d p)) + 3 * (P.filter (fun p => d p = 0)).card + (P.filter (fun p => d p = 1)).card + ∑ p ∈ P, (3 - g p) omega theorem local_five_bonus_sum {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 5) : ∑ p ∈ localOrderedPairs n, localFiveBonus edges p.1 p.2 ≤ ({p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2 | (localExtensions edges p).card = 1}).card + ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, (3 - (localCoExtensions edges p).card) := by have local_five_twin_class_card_le {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 5) {x a : Fin n} (h4 : 0 < (localExtensions edges {x,a}).card) : (localFiveContainmentClass edges x a).card ≤ 5 := by obtain ⟨t,ht⟩ := Finset.card_pos.mp (show 0 < (localExtensions edges {x,a}).card by omega) have hx : x ≠ t := (local_neighbors_ne ht).1.symm have hsub : localFiveContainmentClass edges x a ⊆ localExtensions edges {x,t} := by intro b hb obtain ⟨hxb,hb⟩ := local_mem_five_twin_class.mp hb exact local_neighbors_symm hxb (hb ht) exact (Finset.card_le_card hsub).trans (hd _ _ hx) classical let O := localOrderedPairs n let F := localFiveFatPairs edges let K := F.filter (fun p => 4 ≤ (localFiveContainmentClass edges p.1 p.2).card) let f := fun (p : Fin n × Fin n) => (localExtensions edges (localUnderlyingPair p)).card * (localFiveSlots (localFiveContainmentClass edges p.1 p.2).card).card have htok : (localFiveTokens edges).card = ∑ p ∈ K, f p := by simp only [localFiveTokens,Finset.card_map,Finset.card_sigma,Finset.card_product] rfl have h : 4 * (∑ p ∈ O, localFiveBonus edges p.1 p.2) ≤ (localFiveTokens edges).card := by rw [htok,Finset.mul_sum] have hs : ∑ p ∈ K, f p = ∑ p ∈ O, if 4 ≤ (localExtensions edges (localUnderlyingPair p)).card ∧ 4 ≤ (localFiveContainmentClass edges p.1 p.2).card then f p else 0 := by simpa only [K,F,localFiveFatPairs,Finset.filter_filter,Finset.sum_filter,and_comm,O] rw [hs] apply Finset.sum_le_sum intro p hp obtain ⟨x,a⟩ := p have hxa := local_mem_ordered_pairs.mp hp let d := (localExtensions edges {x,a}).card let k := (localFiveContainmentClass edges x a).card change 4 * localFiveBonus edges x a ≤ if 4 ≤ d ∧ 4 ≤ k then d * (localFiveSlots k).card else 0 by_cases hD : 4 ≤ d · have hK : k ≤ 5 := local_five_twin_class_card_le hd (by omega : 0 < d) change 4 * (if 4 ≤ d then k - 3 else 0) ≤ _ rw [if_pos hD] by_cases hk4 : 4 ≤ k · rw [if_pos (And.intro hD hk4)] by_cases hk5 : k = 5 · rw [hk5] simp [localFiveSlots] omega · have hk : k = 4 := by omega rw [hk] simp [localFiveSlots] omega · rw [if_neg (fun h => hk4 h.2)] omega · simp [localFiveBonus,show ¬4 ≤ (localExtensions edges {x,a}).card from hD,hD] have hc := local_five_tokens_le_deficits hu hd dsimp only at hc change ∑ p ∈ O, localFiveBonus edges p.1 p.2 ≤ _ omega theorem local_five_saturation {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 5) (havg : ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, (localExtensions edges p).card = 3 * n.choose 2) : (∀ x a : Fin n, x ≠ a → 2 ≤ (localExtensions edges {x,a}).card) ∧ (∀ x a : Fin n, x ≠ a → 3 ≤ (localCoExtensions edges {x,a}).card) ∧ (∀ x a : Fin n, x ≠ a → localFiveScore edges x a + localFiveScore edges a x = 2 * localFivePotential (localExtensions edges {x,a}).card) := by classical let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let O := localOrderedPairs n let d := fun p => (localExtensions edges p).card let g := fun p => (localCoExtensions edges p).card let f := fun (p : Fin n × Fin n) => localFiveScore edges p.1 p.2 let b := fun (p : Fin n × Fin n) => localFiveBonus edges p.1 p.2 let U := ∑ p ∈ P, localFivePotential (d p) let A₀ := (P.filter (fun p => d p = 0)).card let A₁ := (P.filter (fun p => d p = 1)).card let D := ∑ p ∈ P, (3 - g p) have hG : ∑ p ∈ P, (g p - 3) = U + 3 * A₀ + A₁ + D := local_five_excess_identity hd havg have hL : 2 * (∑ p ∈ P, (g p - 3)) ≤ ∑ p ∈ O, f p := local_five_score_sum_lower hu have hB : ∑ p ∈ O, b p ≤ A₁ + D := local_five_bonus_sum hu hd have sum_swap (v : (Fin n × Fin n) → ℕ) : ∑ p ∈ O, v p.swap = ∑ p ∈ O, v p := by refine Finset.sum_nbij Prod.swap ?_ ?_ ?_ (fun _ _ => rfl) · intro p hp exact local_mem_ordered_pairs.mpr (local_mem_ordered_pairs.mp hp).symm · intro p hp q hq hpq exact congrArg Prod.swap hpq · intro p hp exact ⟨p.swap,local_mem_ordered_pairs.mpr (local_mem_ordered_pairs.mp hp).symm,rfl⟩ have hpoint : ∀ p ∈ O, f p + f p.swap ≤ 2 * localFivePotential (d (localUnderlyingPair p)) + b p + b p.swap := by intro p hp exact local_five_pointwise_score_bound hu hd (local_mem_ordered_pairs.mp hp) have hsum := Finset.sum_le_sum hpoint simp only [Finset.sum_add_distrib, ← Finset.mul_sum, sum_swap] at hsum have hU : ∑ p ∈ O, localFivePotential (d (localUnderlyingPair p)) = 2 * U := local_five_ordered_pair_sum (fun p => localFivePotential (d p)) rw [hU] at hsum have hD : A₀ = 0 ∧ A₁ = 0 ∧ D = 0 ∧ ∑ p ∈ O, b p = 0 := by omega obtain ⟨ha₀,ha₁,hdef,hB0⟩ := hD have hpointEq : ∀ p ∈ O, f p + f p.swap = 2 * localFivePotential (d (localUnderlyingPair p)) + b p + b p.swap := by apply (Finset.sum_eq_sum_iff_of_le hpoint).mp simp only [Finset.sum_add_distrib, ← Finset.mul_sum,sum_swap,hU] omega refine ⟨?_,?_,?_⟩ · intro x a hxa have hp : ({x,a} : Finset (Fin n)) ∈ P := by simp [P,hxa] change 2 ≤ d ({x,a} : Finset (Fin n)) by_contra hn have h : d ({x,a} : Finset (Fin n)) = 0 ∨ d ({x,a} : Finset (Fin n)) = 1 := by omega rcases h with h0 | h1 · have hpos : 0 < A₀ := Finset.card_pos.mpr ⟨_,Finset.mem_filter.mpr ⟨hp,h0⟩⟩ omega · have hpos : 0 < A₁ := Finset.card_pos.mpr ⟨_,Finset.mem_filter.mpr ⟨hp,h1⟩⟩ omega · intro x a hxa have hp : ({x,a} : Finset (Fin n)) ∈ P := by simp [P,hxa] have hh : 3 - g ({x,a} : Finset (Fin n)) ≤ D := Finset.single_le_sum (fun q hq => Nat.zero_le (3 - g q)) hp change 3 ≤ g ({x,a} : Finset (Fin n)) omega · intro x a hxa have hp : (x,a) ∈ O := local_mem_ordered_pairs.mpr hxa have hp' : (a,x) ∈ O := local_mem_ordered_pairs.mpr hxa.symm have h₁ : b (x,a) ≤ ∑ p ∈ O, b p := Finset.single_le_sum (fun p hp => Nat.zero_le (b p)) hp have h₂ : b (a,x) ≤ ∑ p ∈ O, b p := Finset.single_le_sum (fun p hp => Nat.zero_le (b p)) hp' have he := hpointEq (x,a) hp change f (x,a) + f (a,x) = 2 * localFivePotential (d (localUnderlyingPair (x,a))) + b (x,a) + b (a,x) at he change f (x,a) + f (a,x) = 2 * localFivePotential (d (localUnderlyingPair (x,a))) omega theorem local_five_next_spec {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} (hx : x ∈ localExtensions edges {a,t}) (h : (localExtensions edges {a,t}).card ≠ 1) : localFourNext edges x a t ∈ localExtensions edges {a,t} ∧ x ≠ localFourNext edges x a t := by classical have hex : ∃ y ∈ localExtensions edges {a,t}, x ≠ y := by by_contra hn push Not at hn have heq : localExtensions edges {a,t} = {x} := by ext z rw [Finset.mem_singleton] exact ⟨fun hz => (hn z hz).symm,fun hz => hz ▸ hx⟩ simp [heq] at h simpa only [localFourNext,dif_pos hex] using Classical.choose_spec hex theorem local_five_active_endpoint {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 5) {x a : Fin n} (hxa : x ≠ a) (hd5 : (localExtensions edges {x,a}).card = 5) (hS : localFiveScore edges x a + localFiveScore edges a x = 6) (hpos : 0 < localFiveScore edges x a) : localFiveScore edges x a = 6 := by by_contra hn have hA : 0 < localFiveScore edges a x := by omega have ex : ∀ (u v : Fin n), 0 < localFiveScore edges u v → ∃ b ∈ localFiveCompanions u v, 4 ≤ (localFiveOverlap edges u v b).card := by intro u v hv by_contra hn push Not at hn have hh : localFiveScore edges u v = 0 := by unfold localFiveScore apply Finset.sum_eq_zero intro b hb have := hn b hb omega omega obtain ⟨b,hb,hB⟩ := ex x a hpos obtain ⟨c,hc,hC⟩ := ex a x hA have hmax := hd x a hxa have he := local_five_both_companions_same hu hxa hmax hb hc hB hC subst c have hW : localFiveScore edges x a = (localFiveOverlap edges x a b).card - 3 := by unfold localFiveScore apply Finset.sum_eq_single b · intro z hz hzb by_contra hh exact hzb (local_five_both_companions_same hu hxa hmax hz hc (by omega) hC) · exact fun h => (h hb).elim have hW' : localFiveScore edges a x = (localFiveOverlap edges a x b).card - 3 := by unfold localFiveScore apply Finset.sum_eq_single b · intro z hz hzb by_contra hh exact hzb (local_five_both_companions_same hu hxa hmax hb hz hB (by omega)).symm · exact fun h => (h hc).elim have h₁ : (localFiveOverlap edges x a b).card ≤ (localExtensions edges {x,a}).card := Finset.card_le_card Finset.inter_subset_left have h₂ : (localFiveOverlap edges a x b).card ≤ (localExtensions edges {a,x}).card := Finset.card_le_card Finset.inter_subset_left rw [local_neighbors_comm (a := a) (b := x)] at h₂ omega theorem local_five_containment_cross_saturation {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hD : ∀ x a : Fin n, x ≠ a → 2 ≤ (localExtensions edges {x,a}).card) (hG : ∀ x a : Fin n, x ≠ a → 3 ≤ (localCoExtensions edges {x,a}).card) {x a : Fin n} (hxa : x ≠ a) (hC : 3 ≤ (localFiveContainmentClass edges x a).card) (hT : 3 ≤ (localExtensions edges {x,a}).card) {t : Fin n} (ht : t ∈ localExtensions edges {x,a}) : (localFiveContainmentClass edges x a).card + 2 ≤ (localExtensions edges {x,t}).card := by have hat : a ≠ t := (local_neighbors_ne ht).2.symm have hx : x ∈ localExtensions edges {a,t} := local_neighbors_cycle hxa ht have hy' := local_five_next_spec (edges := edges) hx (by have := hD a t hat; omega) obtain ⟨hyN,hxy⟩ := hy' have hb : {a,t} ∈ localCoExtensions edges {x,localFourNext edges x a t} := local_pair_mem_coextensions.mpr ⟨hat,hx,hyN⟩ have hcap := local_containment_biclique_cross_bound hu hC hT (fun h => (local_mem_five_twin_class.mp h).1 rfl) (fun _ h => (local_mem_five_twin_class.mp h).2) (local_mem_five_twin_class.mpr ⟨hxa,Finset.Subset.rfl⟩) rfl ht hxy hb have hh := hG _ _ hxy omega theorem local_five_active_class_three {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 5) (hD : ∀ x a : Fin n, x ≠ a → 2 ≤ (localExtensions edges {x,a}).card) (hG : ∀ x a : Fin n, x ≠ a → 3 ≤ (localCoExtensions edges {x,a}).card) {x a : Fin n} (hxa : x ≠ a) (hd5 : (localExtensions edges {x,a}).card = 5) (hS : localFiveScore edges x a = 6) : (localFiveContainmentClass edges x a).card = 3 ∧ ({b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 4}).card = 2 := by obtain ⟨hs,hc⟩ := local_five_score_at_five hd hxa hd5 obtain ⟨t,ht⟩ := Finset.card_pos.mp (show 0 < (localExtensions edges {x,a}).card by omega) have hxT : x ≠ t := (local_neighbors_ne ht).1.symm have hclass : (localFiveContainmentClass edges x a).card ≤ 3 := by by_contra hh have h := local_five_containment_cross_saturation hu hD hG hxa (by omega) (by omega) ht have := hd x t hxT omega omega theorem local_five_no_active_five {n : ℕ} {edges : Finset (Finset (Fin n))} (hUnique : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 5) (hD : ∀ x a : Fin n, x ≠ a → 2 ≤ (localExtensions edges {x,a}).card) (hG : ∀ x a : Fin n, x ≠ a → 3 ≤ (localCoExtensions edges {x,a}).card) (hS : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card = 5 → localFiveScore edges x a + localFiveScore edges a x = 6) {x a : Fin n} (hxa : x ≠ a) (h5 : (localExtensions edges {x,a}).card = 5) (hpos : 0 < localFiveScore edges x a) : False := by have local_five_pos_overlap {n : ℕ} {edges : Finset (Finset (Fin n))} {x a b : Fin n} (hb : b ∈ localFiveCompanions x a) (h : 4 ≤ (localFiveOverlap edges x a b).card) : 0 < localFiveScore edges x a := by have hh : (localFiveOverlap edges x a b).card - 3 ≤ localFiveScore edges x a := Finset.single_le_sum (f := fun b => (localFiveOverlap edges x a b).card - 3) (fun _ _ => Nat.zero_le _) hb omega classical let N := fun u => localExtensions edges {x,u} let T := N a let A := localFiveContainmentClass edges x a let B := {b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 4} have hT : T.card = 5 := h5 have hbnd := local_five_active_endpoint hUnique hd hxa h5 (hS x a hxa h5) hpos obtain ⟨hA,hB⟩ := local_five_active_class_three hUnique hd hD hG hxa h5 hbnd change A.card = 3 at hA change B.card = 2 at hB obtain ⟨b,c,hbc,hBC⟩ := Finset.card_eq_two.mp hB have hb : b ∈ B := hBC.symm ▸ Finset.mem_insert_self b {c} have hc : c ∈ B := hBC.symm ▸ Finset.mem_insert_of_mem (Finset.mem_singleton_self c) have ⟨hCb,hTb⟩ := Finset.mem_filter.mp hb have ⟨hCc,hTc⟩ := Finset.mem_filter.mp hc change (T ∩ N b).card = 4 at hTb change (T ∩ N c).card = 4 at hTc have hxb : x ≠ b := (local_mem_five_companions.mp hCb).2.symm have hxc : x ≠ c := (local_mem_five_companions.mp hCc).2.symm have hbA : b ∉ A := by intro h have hs : T ⊆ N b := (local_mem_five_twin_class.mp h).2 rw [Finset.inter_eq_left.mpr hs,hT] at hTb contradiction have hcA : c ∉ A := by intro h have hs : T ⊆ N c := (local_mem_five_twin_class.mp h).2 rw [Finset.inter_eq_left.mpr hs,hT] at hTc contradiction have all₅ : ∀ t ∈ T, x ≠ t ∧ (N t).card = 5 := by intro t ht have hxt := (local_neighbors_ne ht).1.symm have hlo := local_five_containment_cross_saturation hUnique hD hG hxa (by omega : 3 ≤ A.card) (by omega : 3 ≤ T.card) ht have hhi : (N t).card ≤ 5 := hd x t hxt change A.card + 2 ≤ (N t).card at hlo exact ⟨hxt,by omega⟩ have forall_A : ∀ t ∈ T, A ⊆ N t := by intro t ht z hz have ⟨hxz,hzN⟩ := local_mem_five_twin_class.mp hz exact local_neighbors_symm hxz (hzN ht) let K := (T ∩ N b) ∩ (T ∩ N c) have hKT : K ⊆ T := Finset.inter_subset_left.trans Finset.inter_subset_left have hKl : 3 ≤ K.card := by have hu := Finset.card_le_card (Finset.union_subset (Finset.inter_subset_left : T ∩ N b ⊆ T) (Finset.inter_subset_left : T ∩ N c ⊆ T)) have hcard := Finset.card_union_add_card_inter (T ∩ N b) (T ∩ N c) change (T ∩ N b ∪ T ∩ N c).card + K.card = (T ∩ N b).card + (T ∩ N c).card at hcard omega have hKne : ∃ u ∈ K, ∀ v ∈ K, N v = N u := by obtain ⟨u,hu⟩ := Finset.card_pos.mp (show 0 < K.card by omega) have hsub : ∀ t ∈ K, insert b (insert c A) ⊆ N t := by intro t ht have ⟨htb,htc⟩ := Finset.mem_inter.mp ht have ⟨_,htbN⟩ := Finset.mem_inter.mp htb have ⟨_,htcN⟩ := Finset.mem_inter.mp htc have hbN : b ∈ N t := local_neighbors_symm hxb htbN have hcN : c ∈ N t := local_neighbors_symm hxc htcN simp only [Finset.insert_subset_iff,hbN,hcN,true_and] exact forall_A t (hKT ht) have hca : (insert b (insert c A)).card = 5 := by rw [Finset.card_insert_of_notMem (by simp [hbc,hbA]),Finset.card_insert_of_notMem hcA,hA] have he : ∀ t ∈ K, insert b (insert c A) = N t := fun t ht => Finset.eq_of_subset_of_card_le (hsub t ht) (by rw [(all₅ t (hKT ht)).2,hca]) exact ⟨u,hu,fun v hv => (he v hv).symm.trans (he u hu)⟩ obtain ⟨u,hu,hK⟩ := hKne have hKu : K ⊆ localFiveContainmentClass edges x u := by intro v hv exact local_mem_five_twin_class.mpr ⟨(all₅ v (hKT hv)).1, by change N u ⊆ N v; rw [← hK v hv]⟩ have hku : (localFiveContainmentClass edges x u).card ≤ 3 := by by_contra hn obtain ⟨t,ht⟩ := Finset.card_pos.mp (show 0 < (N u).card by rw [(all₅ u (hKT hu)).2]; decide) have h := local_five_containment_cross_saturation hUnique hD hG (all₅ u (hKT hu)).1 (by omega) (by rw [(all₅ u (hKT hu)).2]; decide) ht have hh := hd x t (local_neighbors_ne ht).1.symm omega have hKcard : K.card = 3 := by have := Finset.card_le_card hKu; omega have hsplit : ¬ T ∩ N b ⊆ K := by intro h have := Finset.card_le_card h omega obtain ⟨t,htb,htK⟩ := Finset.not_subset.mp hsplit obtain ⟨ht,htbN⟩ := Finset.mem_inter.mp htb have htcN : t ∉ N c := fun hh => htK (Finset.mem_inter.mpr ⟨htb,Finset.mem_inter.mpr ⟨ht,hh⟩⟩) have htu : t ≠ u := fun he => htK (he.symm ▸ hu) have hOV : 4 ≤ (localFiveOverlap edges x t u).card := by have hb_t : b ∈ N t := local_neighbors_symm hxb htbN have hb_u : b ∈ N u := local_neighbors_symm hxb (Finset.mem_inter.mp (Finset.mem_inter.mp hu).1).2 have hsub : insert b A ⊆ localFiveOverlap edges x t u := by rw [Finset.insert_subset_iff] exact ⟨Finset.mem_inter.mpr ⟨hb_t,hb_u⟩, fun z hz => Finset.mem_inter.mpr ⟨forall_A t ht hz,forall_A u (hKT hu) hz⟩⟩ have hh := Finset.card_le_card hsub rwa [Finset.card_insert_of_notMem hbA,hA] at hh have hScore := local_five_pos_overlap (local_mem_five_companions.mpr ⟨htu.symm,(all₅ u (hKT hu)).1.symm⟩) hOV obtain ⟨hxt,ht5⟩ := all₅ t ht have hS6 := local_five_active_endpoint hUnique hd hxt ht5 (hS x t hxt ht5) hScore obtain ⟨hCt,_⟩ := local_five_active_class_three hUnique hd hD hG hxt ht5 hS6 have hsub : localFiveContainmentClass edges x t ⊆ insert t K := by intro v hv have ⟨hxv,hNt⟩ := local_mem_five_twin_class.mp hv have hNeq : N v = N t := (Finset.eq_of_subset_of_card_le hNt (by rw [ht5]; exact hd x v hxv)).symm have hava : a ∈ A := local_mem_five_twin_class.mpr ⟨hxa,Finset.Subset.rfl⟩ have hav : a ∈ N v := hNeq.symm ▸ forall_A t ht hava have hvT : v ∈ T := local_neighbors_symm hxv hav have hvb : b ∈ N v := hNeq.symm ▸ local_neighbors_symm hxb htbN have hvb' : v ∈ N b := local_neighbors_symm hxv hvb have hvc : v ∉ N c := by intro h have hh : c ∈ N t := hNeq ▸ local_neighbors_symm hxc h exact htcN (local_neighbors_symm hxt hh) have hvB : v ∈ T ∩ N b := Finset.mem_inter.mpr ⟨hvT,hvb'⟩ by_cases h : v = t · exact Finset.mem_insert.mpr (Or.inl h) have htB : t ∈ T ∩ N b := htb have hbig : insert v (insert t K) ⊆ T ∩ N b := by rw [Finset.insert_subset_iff,Finset.insert_subset_iff] exact ⟨hvB,htB,Finset.inter_subset_left⟩ have hvK : v ∉ K := fun hh => hvc (Finset.mem_inter.mp (Finset.mem_inter.mp hh).2).2 have hcapa := Finset.card_le_card hbig rw [Finset.card_insert_of_notMem (by simp [h,hvK]),Finset.card_insert_of_notMem htK,hKcard,hTb] at hcapa omega have hsingleton : localFiveContainmentClass edges x t ⊆ {t} := by intro v hv have hs := Finset.mem_insert.mp (hsub hv) rcases hs with h | h · simpa [h] · have ⟨hxv,hNt⟩ := local_mem_five_twin_class.mp hv have hNeq : N v = N t := (Finset.eq_of_subset_of_card_le hNt (by rw [ht5]; exact hd x v hxv)).symm have hcN : c ∈ N v := local_neighbors_symm hxc (Finset.mem_inter.mp (Finset.mem_inter.mp h).2).2 have hct : c ∈ N t := hNeq ▸ hcN exact (htcN (local_neighbors_symm hxt hct)).elim have hbad := Finset.card_le_card hsingleton rw [hCt,Finset.card_singleton] at hbad omega theorem local_five_impossible_at_average_three {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 5) (havg : ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, (localExtensions edges p).card = 3 * n.choose 2) : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3 := by obtain ⟨hD,hG,hS⟩ := local_five_saturation hu hd havg have hS' : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card = 5 → localFiveScore edges x a + localFiveScore edges a x = 6 := by intro x a hxa h5 simpa [localFivePotential,h5] using hS x a hxa have h4 : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 4 := by intro x a hxa have h := hd x a hxa by_contra hn have h5 : (localExtensions edges {x,a}).card = 5 := by omega have hsum := hS' x a hxa h5 by_cases hx : 0 < localFiveScore edges x a · exact local_five_no_active_five hu hd hD hG hS' hxa h5 hx · have h5' := congrArg Finset.card (local_neighbors_comm (edges := edges) (a := a) (b := x)) exact local_five_no_active_five hu hd hD hG hS' hxa.symm (h5'.trans h5) (by omega) exact local_four_impossible_at_average_three hu h4 havg /-- Equality families with pair codegree bounded by five are Steiner expansions. -/ theorem classify_extremal_triple_families_of_pair_codegree_le_five {n : ℕ} (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hUnique : UniqueDisjointUnions edges) (hExtremal : edges.card = n.choose 2) (hMax : ∀ pair : Finset (Fin n), pair.card = 2 → (edges.filter (fun e => pair ⊆ e)).card ≤ 5) : ∃ blocks : Finset (Finset (Fin n)), SteinerFive blocks ∧ IsExpansion edges blocks := by have hcard (a b : Fin n) (hab : a ≠ b) : (localExtensions edges {a,b}).card = (edges.filter (fun e => ({a,b} : Finset (Fin n)) ⊆ e)).card := by have hEq (c : Fin n) : insert c ({a,b} : Finset (Fin n)) = {a,b,c} := by ext x simp only [Finset.mem_insert, Finset.mem_singleton] tauto simpa only [localExtensions, hEq] using extension_card_eq_pair_filter_card edges hUniform hab have hDeg5 (a b : Fin n) (hab : a ≠ b) : (localExtensions edges {a,b}).card ≤ 5 := by rw [hcard a b hab] exact hMax _ (by simp [hab]) have hAvg := sum_local_extensions_card edges hUniform rw [hExtremal] at hAvg have hDeg3 := local_five_impossible_at_average_three hUnique hDeg5 hAvg apply classify_extremal_triple_families_of_pair_codegree_le_three edges hUniform hUnique hExtremal intro p hp obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp rw [← hcard a b hab, hDeg3 a b hab] /-- An equality family is an expansion whenever the triples avoiding block pairs have pair codegree at most two. -/ theorem classify_extremal_of_residual_pair_codegree_le_two {n : ℕ} {edges blocks : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hU : ∀ e ∈ edges, e.card = 3) (hE : edges.card = n.choose 2) (hB : ∀ B ∈ blocks, B.card = 5 ∧ ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hD : let residual := edges.filter (fun e => ∀ B ∈ blocks, (e ∩ B).card ≤ 1) ∀ p : Finset (Fin n), p.card = 2 → (localExtensions residual p).card ≤ 2) : SteinerFive blocks ∧ IsExpansion edges blocks := by classical let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let covered := blocks.biUnion (fun B => B.powersetCard 2) let internal := blocks.biUnion (fun B => B.powersetCard 3) let residual := edges.filter (fun e => ∀ B ∈ blocks, (e ∩ B).card ≤ 1) let extra := edges.filter (fun e => (∃ B ∈ blocks, 2 ≤ (e ∩ B).card) ∧ ∀ B ∈ blocks, ¬ e ⊆ B) let missing := P.filter (fun p => ∀ B ∈ blocks, ¬ p ⊆ B) let zero := missing.filter (fun p => localCoExtensions residual p = ∅) have hpc : ∀ p, p ∈ covered ↔ p.card = 2 ∧ ∃ B ∈ blocks, p ⊆ B := by intro p simp only [covered, Finset.mem_biUnion, Finset.mem_powersetCard] aesop have hti : ∀ t, t ∈ internal ↔ t.card = 3 ∧ ∃ B ∈ blocks, t ⊆ B := by intro t simp only [internal, Finset.mem_biUnion, Finset.mem_powersetCard] aesop have hdj (k : ℕ) (hk : 2 ≤ k) : (↑blocks : Set (Finset (Fin n))).PairwiseDisjoint (fun B => B.powersetCard k) := by intro B hBm C hCm hne apply Finset.disjoint_left.mpr intro t htB htC obtain ⟨htB,ht⟩ := Finset.mem_powersetCard.mp htB obtain ⟨htC,_⟩ := Finset.mem_powersetCard.mp htC obtain ⟨p,hpt,hp⟩ := Finset.exists_subset_card_eq (s := t) (by omega : 2 ≤ t.card) exact hne (full_five_eq_of_common_pair hu (hB _ hBm).1 (hB _ hCm).1 hp (hpt.trans htB) (hpt.trans htC) (hB _ hBm).2 (hB _ hCm).2) have hIC : internal.card = covered.card := by rw [Finset.card_biUnion (hdj 3 (by decide)), Finset.card_biUnion (hdj 2 (by decide))] apply Finset.sum_congr rfl intro B hBm simp only [Finset.card_powersetCard,(hB _ hBm).1] decide have hIE : internal ⊆ edges := by intro t ht obtain ⟨ht3,B,hBm,htB⟩ := (hti t).mp ht exact (hB _ hBm).2 t ht3 htB have hMP : missing = P \ covered := by ext p simp only [missing, Finset.mem_filter, Finset.mem_sdiff, hpc] constructor · rintro ⟨hp,hn⟩ exact ⟨hp,fun ⟨_,B,hBm,hpB⟩ => hn B hBm hpB⟩ · rintro ⟨hp,hn⟩ exact ⟨hp,fun B hBm hpB => hn ⟨(Finset.mem_powersetCard.mp hp).2,B,hBm,hpB⟩⟩ have hCP : covered ⊆ P := by intro p hp simp [P,(hpc p).mp hp |>.1] have hM : missing.card + internal.card = n.choose 2 := by rw [hMP,hIC,Finset.card_sdiff_add_card_eq_card hCP] simp [P] have hres : residual ⊆ edges := Finset.filter_subset _ _ have hR (t : Finset (Fin n)) (ht : t ∈ residual) (B : Finset (Fin n)) (hBm : B ∈ blocks) : (t ∩ B).card ≤ 1 := (Finset.mem_filter.mp ht).2 B hBm have hcoverEdges : edges ⊆ internal ∪ extra ∪ residual := by intro t ht by_cases hi : t ∈ internal · exact Finset.mem_union_left _ (Finset.mem_union_left _ hi) have hn : ∀ B ∈ blocks, ¬ t ⊆ B := by intro B hm hs exact hi ((hti t).mpr ⟨hU t ht,B,hm,hs⟩) by_cases he : ∃ B ∈ blocks, 2 ≤ (t ∩ B).card · exact Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨ht,he,hn⟩)) · exact Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨ht,fun B hBm => by have hw : ¬ 2 ≤ (t ∩ B).card := fun h => he ⟨B,hBm,h⟩ omega⟩) have hsplit : edges.card ≤ internal.card + extra.card + residual.card := by have hs := Finset.card_le_card hcoverEdges have h₁ := Finset.card_union_le (internal ∪ extra) residual have h₂ := Finset.card_union_le internal extra omega have hX : 3 * extra.card ≤ zero.card := by simpa only [extra,zero,missing,P,Finset.filter_filter] using full_five_external_edge_count hu hres hU hB hR have hzM : zero.card ≤ missing.card := Finset.card_le_card (Finset.filter_subset _ _) have hzero (p : Finset (Fin n)) (hp : p ∈ covered) : localExtensions residual p = ∅ := by obtain ⟨hp2,B,hBm,hpB⟩ := (hpc p).mp hp apply Finset.eq_empty_iff_forall_notMem.mpr intro x hx have hh := hR _ (Finset.mem_filter.mp hx).2.2 B hBm have hc := Finset.card_le_card (show p ⊆ insert x p ∩ B from Finset.subset_inter (Finset.subset_insert _ _) hpB) omega have hcSum : (∑ p ∈ P, (localExtensions residual p).card) = ∑ p ∈ missing, (localExtensions residual p).card := by rw [hMP] have hdiff := Finset.sum_sdiff hCP (f := fun p => (localExtensions residual p).card) have hz : ∑ p ∈ covered, (localExtensions residual p).card = 0 := by apply Finset.sum_eq_zero intro p hp simp [hzero p hp] rw [hz,add_zero] at hdiff exact hdiff.symm have hsum := sum_local_extensions_card residual (fun t ht => hU t (hres ht)) change (∑ p ∈ P, (localExtensions residual p).card) = 3 * residual.card at hsum rw [hcSum] at hsum have hpoint : ∀ p ∈ missing, (localExtensions residual p).card ≤ (fun _ => (2 : ℕ)) p := fun p hp => hD p (Finset.mem_powersetCard.mp (Finset.mem_filter.mp hp).1).2 have hupper := Finset.sum_le_sum hpoint simp only [Finset.sum_const,nsmul_eq_mul,Nat.cast_id] at hupper have hEq : ∑ p ∈ missing, (localExtensions residual p).card = ∑ _ ∈ missing, (2 : ℕ) := by simp only [Finset.sum_const,nsmul_eq_mul,Nat.cast_id] omega have hzm : zero = missing := Finset.eq_of_subset_of_card_le (Finset.filter_subset _ _) (by omega) have hNo : ∀ p ∈ P, localCoExtensions residual p = ∅ := by intro p hp by_cases hh : p ∈ covered · obtain ⟨hp2,B,hBm,hpB⟩ := (hpc p).mp hh exact full_five_pair_common_link_empty_in_residual hu hres (hB _ hBm).1 (hB _ hBm).2 hp2 hpB (fun t ht => hR t ht B hBm) · have hm : p ∈ missing := by rw [hMP]; exact Finset.mem_sdiff.mpr ⟨hp,hh⟩ exact (Finset.mem_filter.mp (hzm.symm ▸ hm : p ∈ zero)).2 have hMissing : missing = ∅ := by apply Finset.eq_empty_iff_forall_notMem.mpr intro p hp have ht := (Finset.sum_eq_sum_iff_of_le hpoint).mp hEq p hp change (localExtensions residual p).card = 2 at ht obtain ⟨q,hq,hq2⟩ := Finset.exists_subset_card_eq (s := localExtensions residual p) (n := 2) (by omega) have hqP : q ∈ P := by simp [P,hq2] have hpm : p ∈ localCoExtensions residual q := local_mem_coextensions.mpr ⟨(Finset.mem_powersetCard.mp (Finset.mem_filter.mp hp).1).2,hq⟩ rw [hNo q hqP] at hpm exact Finset.notMem_empty _ hpm have hEqInt : internal = edges := Finset.eq_of_subset_of_card_le hIE (by have hm : missing.card = 0 := by simp [hMissing] omega) refine ⟨⟨fun B hBm => (hB _ hBm).1,?_⟩,?_⟩ · intro p hp have hpp : p ∈ P := by simp [P,hp] have hCov : p ∈ covered := by by_contra hn have hm : p ∈ missing := by rw [hMP]; exact Finset.mem_sdiff.mpr ⟨hpp,hn⟩ simp [hMissing] at hm obtain ⟨_,B,hBm,hpB⟩ := (hpc p).mp hCov refine ⟨B,⟨hBm,hpB⟩,?_⟩ rintro C ⟨hCm,hpC⟩ exact full_five_eq_of_common_pair hu (hB _ hCm).1 (hB _ hBm).1 hp hpC hpB (hB _ hCm).2 (hB _ hBm).2 · intro t rw [← hEqInt] exact hti t def oneSixthDonorEdges : Finset (Finset (Fin 21)) := {{0, 1, 2}, {0, 1, 3}, {0, 1, 4}, {0, 2, 3}, {0, 2, 4}, {0, 3, 4}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}, {0, 5, 6}, {0, 5, 7}, {0, 5, 8}, {0, 6, 7}, {0, 6, 8}, {0, 7, 8}, {5, 6, 7}, {5, 6, 8}, {5, 7, 8}, {6, 7, 8}, {1, 5, 9}, {1, 5, 10}, {1, 5, 11}, {1, 9, 10}, {1, 9, 11}, {1, 10, 11}, {5, 9, 10}, {5, 9, 11}, {5, 10, 11}, {9, 10, 11}, {2, 6, 12}, {2, 6, 13}, {2, 6, 14}, {2, 12, 13}, {2, 12, 14}, {2, 13, 14}, {6, 12, 13}, {6, 12, 14}, {6, 13, 14}, {12, 13, 14}, {3, 7, 15}, {3, 7, 16}, {3, 7, 17}, {3, 15, 16}, {3, 15, 17}, {3, 16, 17}, {7, 15, 16}, {7, 15, 17}, {7, 16, 17}, {15, 16, 17}, {4, 8, 18}, {4, 8, 19}, {4, 8, 20}, {4, 18, 19}, {4, 18, 20}, {4, 19, 20}, {8, 18, 19}, {8, 18, 20}, {8, 19, 20}, {18, 19, 20}, {0, 1, 5}, {0, 2, 6}, {0, 3, 7}, {0, 4, 8}} def oneSixthDonorShadow : Finset (Finset (Fin 21)) := oneSixthDonorEdges.biUnion fun e => e.powersetCard 2 def oneSixthDonorAugmented : Finset (Finset (Fin 21)) := oneSixthDonorShadow ∪ oneSixthDonorEdges.biUnion (fun e => (oneSixthDonorEdges.filter fun f => (e ∩ f).card = 2).image fun f => (e \ f) ∪ (f \ e)) theorem one_sixth_donor_uniform : ∀ e ∈ oneSixthDonorEdges, e.card = 3 := by simp only [oneSixthDonorEdges, Finset.forall_mem_insert, Finset.mem_singleton, forall_eq] repeat' apply And.intro <;> decide theorem one_sixth_donor_edge_card : oneSixthDonorEdges.card = 64 := by decide +kernel theorem one_sixth_donor_shadow_card : oneSixthDonorShadow.card = 60 := by set_option maxHeartbeats 0 in decide +kernel theorem one_sixth_donor_augmented_card : oneSixthDonorAugmented.card = 84 := by set_option maxHeartbeats 0 in decide +kernel theorem one_sixth_donor_unique : UniqueDisjointUnions oneSixthDonorEdges := by let edges := oneSixthDonorEdges let mask (e : Finset (Fin 21)) : BitVec 21 := (BitVec.ofBoolListLE ((List.finRange 21).map fun v => decide (v ∈ e))).cast (by simp) let masks : List (BitVec 21) := [7, 11, 19, 13, 21, 25, 14, 22, 26, 28, 97, 161, 289, 193, 321, 385, 224, 352, 416, 448, 546, 1058, 2082, 1538, 2562, 3074, 1568, 2592, 3104, 3584, 4164, 8260, 16452, 12292, 20484, 24580, 12352, 20544, 24640, 28672, 32904, 65672, 131208, 98312, 163848, 196616, 98432, 163968, 196736, 229376, 262416, 524560, 1048848, 786448, 1310736, 1572880, 786688, 1310976, 1573120, 1835008, 35, 69, 137, 273] have hValid : ∀ e ∈ edges, mask e ∈ masks := by simp only [edges, oneSixthDonorEdges, Finset.forall_mem_insert, Finset.mem_singleton, forall_eq] repeat' apply And.intro all_goals (dsimp only [masks, mask]; decide +kernel) have hMask (e : Finset (Fin 21)) (i : Fin 21) : (mask e).getLsbD i = decide (i ∈ e) := by unfold mask rw [BitVec.getLsbD_cast, BitVec.getLsbD_ofBoolListLE] simp [List.getD_eq_getElem?_getD, i.isLt] have hInj : Function.Injective mask := by intro e f h ext v exact decide_eq_decide.mp (by rw [← hMask, ← hMask, h]) have hUnion (e f : Finset (Fin 21)) : mask (e ∪ f) = mask e ||| mask f := by apply BitVec.eq_of_getLsbD_eq intro i hi let v : Fin 21 := ⟨i, hi⟩ change (mask (e ∪ f)).getLsbD v = (mask e ||| mask f).getLsbD v rw [BitVec.getLsbD_or, hMask, hMask, hMask] simp have hDisj {e f : Finset (Fin 21)} (h : Disjoint e f) : mask e &&& mask f = 0 := by apply BitVec.eq_of_getLsbD_eq intro i hi let v : Fin 21 := ⟨i, hi⟩ change (mask e &&& mask f).getLsbD v = (0 : BitVec 21).getLsbD v rw [BitVec.getLsbD_and, hMask, hMask] by_cases he : v ∈ e · have hf : v ∉ f := fun hf => Finset.disjoint_left.mp h he hf simp [he, hf] · simp [he] let disjointPairs := masks.flatMap fun a => (masks.filter fun b => decide (a.toNat < b.toNat) && (a &&& b == 0)).map (fun b => (a, b)) let unionMask (p : BitVec 21 × BitVec 21) := p.1 ||| p.2 let bucket (i : Fin 23) := disjointPairs.filter (fun p => decide ((unionMask p).toNat % 23 = i.val)) have hBucket (i : Fin 23) : ((bucket i).map unionMask).Nodup := by set_option maxHeartbeats 0 in fin_cases i all_goals (dsimp only [bucket, disjointPairs, masks, unionMask]; decide +kernel) have hPair {a b : BitVec 21} (ha : a ∈ masks) (hb : b ∈ masks) (hab : a &&& b = 0) (hlt : a.toNat < b.toNat) : (a, b) ∈ disjointPairs := by refine List.mem_flatMap.mpr ⟨a, ha, List.mem_map.mpr ⟨b, ?_, rfl⟩⟩ exact List.mem_filter.mpr ⟨hb, by simp [hlt, hab]⟩ have hNonzero : (0 : BitVec 21) ∉ masks := by dsimp only [masks] decide +kernel have hNe {a b : BitVec 21} (ha : a ∈ masks) (hab : a &&& b = 0) : a.toNat ≠ b.toNat := by intro heq have he := BitVec.eq_of_toNat_eq heq subst b have hz : a = 0 := by simpa using hab exact hNonzero (hz ▸ ha) have hCertificateEq {a b c d : BitVec 21} (hab : (a, b) ∈ disjointPairs) (hcd : (c, d) ∈ disjointPairs) (hu : a ||| b = c ||| d) : a = c ∧ b = d := by let i : Fin 23 := ⟨(a ||| b).toNat % 23, Nat.mod_lt _ (by decide)⟩ have hb₁ : (a,b) ∈ bucket i := List.mem_filter.mpr ⟨hab, by simp [unionMask, i]⟩ have hb₂ : (c,d) ∈ bucket i := List.mem_filter.mpr ⟨hcd, by simp [unionMask, i, hu]⟩ exact Prod.mk.inj (List.inj_on_of_nodup_map (hBucket i) hb₁ hb₂ hu) have hBV (a b c d : BitVec 21) (ha : a ∈ masks) (hb : b ∈ masks) (hc : c ∈ masks) (hd : d ∈ masks) (hab : a &&& b = 0) (hcd : c &&& d = 0) (hu : a ||| b = c ||| d) : (a = c ∧ b = d) ∨ (a = d ∧ b = c) := by rcases lt_or_gt_of_ne (hNe ha hab) with habLt | habGt <;> rcases lt_or_gt_of_ne (hNe hc hcd) with hcdLt | hcdGt · exact Or.inl (hCertificateEq (hPair ha hb hab habLt) (hPair hc hd hcd hcdLt) hu) · exact Or.inr (hCertificateEq (hPair ha hb hab habLt) (hPair hd hc (by simpa only [BitVec.and_comm] using hcd) hcdGt) (by simpa only [BitVec.or_comm d c] using hu)) · have h := hCertificateEq (hPair hc hd hcd hcdLt) (hPair hb ha (by simpa only [BitVec.and_comm] using hab) habGt) (by simpa only [BitVec.or_comm b a] using hu.symm) exact Or.inr ⟨h.2.symm, h.1.symm⟩ · have h := hCertificateEq (hPair hb ha (by simpa only [BitVec.and_comm] using hab) habGt) (hPair hd hc (by simpa only [BitVec.and_comm] using hcd) hcdGt) (by simpa only [BitVec.or_comm b a, BitVec.or_comm d c] using hu) exact Or.inl ⟨h.2, h.1⟩ intro A hA B hB C hC D hD hAB hCD hU have hu := congrArg mask hU rw [hUnion, hUnion] at hu rcases hBV (mask A) (mask B) (mask C) (mask D) (hValid A hA) (hValid B hB) (hValid C hC) (hValid D hD) (hDisj hAB) (hDisj hCD) hu with h | h · exact Or.inl ⟨hInj h.1, hInj h.2⟩ · exact Or.inr ⟨hInj h.1, hInj h.2⟩ theorem donor_augmented_shadow_one_sixth : ∃ edges : Finset (Finset (Fin 21)), (∀ e ∈ edges, e.card = 3) ∧ UniqueDisjointUnions edges ∧ let shadow := edges.biUnion fun e => e.powersetCard 2 let augmented := shadow ∪ edges.biUnion (fun e => (edges.filter fun f => (e ∩ f).card = 2).image fun f => (e \ f) ∪ (f \ e)) edges.card = 64 ∧ shadow.card = 60 ∧ augmented.card = 84 := by exact ⟨oneSixthDonorEdges, one_sixth_donor_uniform, one_sixth_donor_unique, one_sixth_donor_edge_card, one_sixth_donor_shadow_card, one_sixth_donor_augmented_card⟩ /-- Pairs that are not contained in any chosen block. -/ def fullFiveMissingPairs {n : ℕ} (blocks : Finset (Finset (Fin n))) : Finset (Finset (Fin n)) := ((Finset.univ : Finset (Fin n)).powersetCard 2).filter (fun p => ∀ B ∈ blocks, ¬ p ⊆ B) /-- Triples that meet each chosen block in at most one vertex. -/ def fullFiveResidual {n : ℕ} (edges blocks : Finset (Finset (Fin n))) : Finset (Finset (Fin n)) := edges.filter (fun e => ∀ B ∈ blocks, (e ∩ B).card ≤ 1) /-- Available pairs with no common support in the residual family. -/ def fullFiveEmptyLabels {n : ℕ} (residual available : Finset (Finset (Fin n))) : Finset (Finset (Fin n)) := available.filter (fun p => localCoExtensions residual p = ∅) /-- The pairs supporting residual edges or occurring together as their extensions are outside the complete blocks. -/ theorem full_five_residual_shadows_subset_missing {n : ℕ} {edges blocks residual : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hsub : residual ⊆ edges) (hB : ∀ B ∈ blocks, B.card = 5 ∧ ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hR : ∀ t ∈ residual, ∀ B ∈ blocks, (t ∩ B).card ≤ 1) : let missing := fullFiveMissingPairs blocks (∀ p : Finset (Fin n), p.card = 2 → (localExtensions residual p).Nonempty → p ∈ missing) ∧ (∀ p : Finset (Fin n), p.card = 2 → (localExtensions residual p).powersetCard 2 ⊆ missing) := by classical dsimp only [fullFiveMissingPairs] constructor · rintro p hp ⟨x,hx⟩ apply Finset.mem_filter.mpr refine ⟨by simp [hp], ?_⟩ intro B hBm hpB have hle := hR _ (Finset.mem_filter.mp hx).2.2 B hBm have hc := Finset.card_le_card (Finset.subset_inter (Finset.subset_insert x p) hpB) omega · intro p hp q hq obtain ⟨hqN,hq2⟩ := Finset.mem_powersetCard.mp hq apply Finset.mem_filter.mpr refine ⟨by simp [hq2], ?_⟩ intro B hBm hqB have hEmpty := full_five_pair_common_link_empty_in_residual hu hsub (hB _ hBm).1 (hB _ hBm).2 hq2 hqB (fun t ht => hR t ht B hBm) have hm := local_mem_coextensions.mpr ⟨hp,hqN⟩ rw [hEmpty] at hm exact Finset.notMem_empty _ hm /-- Once every edge lies in a block or in the residual, the only pair codegrees that need a bound are those of the residual. -/ theorem full_five_pair_bound_of_no_extra {n k : ℕ} {edges blocks residual : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hB : ∀ B ∈ blocks, B.card = 5 ∧ ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hR : ∀ t ∈ residual, ∀ B ∈ blocks, (t ∩ B).card ≤ 1) (hCover : edges ⊆ blocks.biUnion (fun B => B.powersetCard 3) ∪ residual) (hk : 3 ≤ k) {p : Finset (Fin n)} (hp : p.card = 2) (hD : (∀ B ∈ blocks, ¬ p ⊆ B) → (localExtensions residual p).card ≤ k) : (localExtensions edges p).card ≤ k := by classical by_cases hc : ∃ B ∈ blocks, p ⊆ B · obtain ⟨B,hBm,hpB⟩ := hc have hsub : localExtensions edges p ⊆ B \ p := by intro x hx obtain ⟨_,hxp,hxe⟩ := Finset.mem_filter.mp hx apply Finset.mem_sdiff.mpr refine ⟨?_,hxp⟩ rcases Finset.mem_union.mp (hCover hxe) with hi | hr · obtain ⟨C,hCm,htC⟩ := Finset.mem_biUnion.mp hi have htC := (Finset.mem_powersetCard.mp htC).1 have hBC := full_five_eq_of_common_pair hu (hB _ hBm).1 (hB _ hCm).1 hp hpB ((Finset.subset_insert x p).trans htC) (hB _ hBm).2 (hB _ hCm).2 exact hBC.symm ▸ htC (Finset.mem_insert_self x p) · have hs : p ⊆ insert x p ∩ B := Finset.subset_inter (Finset.subset_insert x p) hpB have h2 := Finset.card_le_card hs have h1 := hR _ hr B hBm omega exact (Finset.card_le_card hsub).trans (by rw [Finset.card_sdiff_of_subset hpB,(hB _ hBm).1,hp] exact hk) · have hM : ∀ B ∈ blocks, ¬ p ⊆ B := fun B hBm hpB => hc ⟨B,hBm,hpB⟩ have hsub : localExtensions edges p ⊆ localExtensions residual p := by intro x hx obtain ⟨_,hxp,hxe⟩ := Finset.mem_filter.mp hx apply Finset.mem_filter.mpr refine ⟨Finset.mem_univ _,hxp,?_⟩ rcases Finset.mem_union.mp (hCover hxe) with hi | hr · obtain ⟨C,hCm,htC⟩ := Finset.mem_biUnion.mp hi exact (hM C hCm ((Finset.subset_insert x p).trans (Finset.mem_powersetCard.mp htC).1)).elim · exact hr exact (Finset.card_le_card hsub).trans (hD hM) /-- The weighted residual estimate and its equality case suffice for classification. The hypothesis involves only triples avoiding the pairs of all chosen blocks. -/ theorem classify_extremal_of_residual_weighted_bound {n : ℕ} {edges blocks : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hU : ∀ e ∈ edges, e.card = 3) (hE : edges.card = n.choose 2) (hB : ∀ B ∈ blocks, B.card = 5 ∧ ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hWeighted : let residual := fullFiveResidual edges blocks let missing := fullFiveMissingPairs blocks let zero := fullFiveEmptyLabels residual missing 3 * residual.card + zero.card ≤ 3 * missing.card ∧ (3 * residual.card + zero.card = 3 * missing.card → zero = ∅ ∧ ∀ p ∈ missing, (localExtensions residual p).card ≤ 5)) : ∃ result : Finset (Finset (Fin n)), SteinerFive result ∧ IsExpansion edges result := by classical let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let covered := blocks.biUnion (fun B => B.powersetCard 2) let internal := blocks.biUnion (fun B => B.powersetCard 3) let residual := fullFiveResidual edges blocks let extra := edges.filter (fun e => (∃ B ∈ blocks, 2 ≤ (e ∩ B).card) ∧ ∀ B ∈ blocks, ¬ e ⊆ B) let missing := P.filter (fun p => ∀ B ∈ blocks, ¬ p ⊆ B) let zero := fullFiveEmptyLabels residual missing have hpc : ∀ p, p ∈ covered ↔ p.card = 2 ∧ ∃ B ∈ blocks, p ⊆ B := by intro p constructor · intro h obtain ⟨B,hBm,hpB⟩ := Finset.mem_biUnion.mp h obtain ⟨hsub,h2⟩ := Finset.mem_powersetCard.mp hpB exact ⟨h2,B,hBm,hsub⟩ · rintro ⟨h2,B,hBm,hsub⟩ exact Finset.mem_biUnion.mpr ⟨B,hBm,Finset.mem_powersetCard.mpr ⟨hsub,h2⟩⟩ have hti : ∀ t, t ∈ internal ↔ t.card = 3 ∧ ∃ B ∈ blocks, t ⊆ B := by intro t constructor · intro h obtain ⟨B,hBm,htB⟩ := Finset.mem_biUnion.mp h obtain ⟨hsub,h3⟩ := Finset.mem_powersetCard.mp htB exact ⟨h3,B,hBm,hsub⟩ · rintro ⟨h3,B,hBm,hsub⟩ exact Finset.mem_biUnion.mpr ⟨B,hBm,Finset.mem_powersetCard.mpr ⟨hsub,h3⟩⟩ have hdj (k : ℕ) (hk : 2 ≤ k) : (↑blocks : Set (Finset (Fin n))).PairwiseDisjoint (fun B => B.powersetCard k) := by intro B hBm C hCm hne apply Finset.disjoint_left.mpr intro t htB htC obtain ⟨htB,ht⟩ := Finset.mem_powersetCard.mp htB obtain ⟨htC,_⟩ := Finset.mem_powersetCard.mp htC obtain ⟨p,hpt,hp⟩ := Finset.exists_subset_card_eq (s := t) (by omega : 2 ≤ t.card) exact hne (full_five_eq_of_common_pair hu (hB _ hBm).1 (hB _ hCm).1 hp (hpt.trans htB) (hpt.trans htC) (hB _ hBm).2 (hB _ hCm).2) have hIC : internal.card = covered.card := by rw [Finset.card_biUnion (hdj 3 (by decide)), Finset.card_biUnion (hdj 2 (by decide))] apply Finset.sum_congr rfl intro B hBm simp only [Finset.card_powersetCard,(hB _ hBm).1] decide have hMP : missing = P \ covered := by ext p simp only [missing, fullFiveMissingPairs, P, Finset.mem_filter, Finset.mem_sdiff, hpc] constructor · rintro ⟨hp,hn⟩ exact ⟨hp,fun ⟨_,B,hBm,hpB⟩ => hn B hBm hpB⟩ · rintro ⟨hp,hn⟩ exact ⟨hp,fun B hBm hpB => hn ⟨(Finset.mem_powersetCard.mp hp).2,B,hBm,hpB⟩⟩ have hCP : covered ⊆ P := by intro p hp simp [P,(hpc p).mp hp |>.1] have hM : missing.card + internal.card = n.choose 2 := by rw [hMP,hIC,Finset.card_sdiff_add_card_eq_card hCP] simp [P] have hres : residual ⊆ edges := Finset.filter_subset _ _ have hR (t : Finset (Fin n)) (ht : t ∈ residual) (B : Finset (Fin n)) (hBm : B ∈ blocks) : (t ∩ B).card ≤ 1 := (Finset.mem_filter.mp ht).2 B hBm have hcoverEdges : edges ⊆ internal ∪ extra ∪ residual := by intro t ht by_cases hi : t ∈ internal · exact Finset.mem_union_left _ (Finset.mem_union_left _ hi) have hn : ∀ B ∈ blocks, ¬ t ⊆ B := by intro B hm hs exact hi ((hti t).mpr ⟨hU t ht,B,hm,hs⟩) by_cases he : ∃ B ∈ blocks, 2 ≤ (t ∩ B).card · exact Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨ht,he,hn⟩)) · exact Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨ht,fun B hBm => by have hw : ¬ 2 ≤ (t ∩ B).card := fun h => he ⟨B,hBm,h⟩ omega⟩) have hsplit : edges.card ≤ internal.card + extra.card + residual.card := by have hs := Finset.card_le_card hcoverEdges have h₁ := Finset.card_union_le (internal ∪ extra) residual have h₂ := Finset.card_union_le internal extra omega have hX : 3 * extra.card ≤ zero.card := by simpa only [extra,zero,fullFiveEmptyLabels,missing,P,Finset.filter_filter] using full_five_external_edge_count hu hres hU hB hR change 3 * residual.card + zero.card ≤ 3 * missing.card ∧ (3 * residual.card + zero.card = 3 * missing.card → zero = ∅ ∧ ∀ p ∈ missing, (localExtensions residual p).card ≤ 5) at hWeighted have hEq : 3 * residual.card + zero.card = 3 * missing.card := by omega obtain ⟨hz,hDeg⟩ := hWeighted.2 hEq have hNoExtra : extra = ∅ := by have hz0 : zero.card = 0 := by simp [hz] exact Finset.card_eq_zero.mp (by omega) have hCover : edges ⊆ internal ∪ residual := by simpa only [hNoExtra, Finset.union_empty] using hcoverEdges apply classify_extremal_triple_families_of_pair_codegree_le_five edges hU hu hE intro p hp obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp rw [← extension_card_eq_pair_filter_card edges hU hab] have hconv (edges' : Finset (Finset (Fin n))) : (Finset.univ.filter (fun c => c ∉ ({a,b} : Finset (Fin n)) ∧ ({a,b,c} : Finset (Fin n)) ∈ edges')) = localExtensions edges' {a,b} := by ext c have heq : insert c ({a,b} : Finset (Fin n)) = {a,b,c} := by ext v simp only [Finset.mem_insert,Finset.mem_singleton] tauto simp only [localExtensions,Finset.mem_filter,heq] rw [hconv] exact full_five_pair_bound_of_no_extra hu hB hR hCover (by decide : 3 ≤ 5) hp (fun h => hDeg _ (Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _,hp⟩,h⟩)) theorem residual_weighted_bound_of_common_links_le_three {n : ℕ} (available : Finset (Finset (Fin n))) (extensions : Finset (Fin n) → Finset (Fin n)) (hPairs : ∀ p ∈ available, p.card = 2) (hLabels : ∀ p ∈ available, (extensions p).powersetCard 2 ⊆ available) (hCommon : ∀ q ∈ available, (available.filter (fun p => q ⊆ extensions p)).card ≤ 3) : let emptyLabels := available.filter (fun q => ¬ ∃ p ∈ available, q ⊆ extensions p) (∑ p ∈ available, (extensions p).card) + emptyLabels.card ≤ 3 * available.card ∧ ((∑ p ∈ available, (extensions p).card) + emptyLabels.card = 3 * available.card → emptyLabels = ∅ ∧ ∀ p ∈ available, (extensions p).card = 3) := by classical let d (p : Finset (Fin n)) := (extensions p).card let k (q : Finset (Fin n)) := (available.filter (fun p => q ⊆ extensions p)).card let filled := available.filter (fun q => ∃ p ∈ available, q ⊆ extensions p) let emptyLabels := available.filter (fun q => ¬ ∃ p ∈ available, q ⊆ extensions p) change (∑ p ∈ available, d p) + emptyLabels.card ≤ 3 * available.card ∧ ((∑ p ∈ available, d p) + emptyLabels.card = 3 * available.card → emptyLabels = ∅ ∧ ∀ p ∈ available, d p = 3) have hPartition : filled.card + emptyLabels.card = available.card := Finset.card_filter_add_card_filter_not (s := available) _ have hCount : (∑ p ∈ available, (d p).choose 2) = ∑ q ∈ available, k q := calc (∑ p ∈ available, (d p).choose 2) = ∑ p ∈ available, ∑ q ∈ available, if q ⊆ extensions p then 1 else 0 := by apply Finset.sum_congr rfl intro p hp rw [← Finset.sum_filter (s := available) (fun q => q ⊆ extensions p) (fun _ => (1 : ℕ))] have hfilter : available.filter (fun q => q ⊆ extensions p) = (extensions p).powersetCard 2 := by ext q exact ⟨fun h => Finset.mem_powersetCard.mpr ⟨(Finset.mem_filter.mp h).2, hPairs q (Finset.mem_filter.mp h).1⟩, fun h => Finset.mem_filter.mpr ⟨hLabels p hp h, (Finset.mem_powersetCard.mp h).1⟩⟩ simp [hfilter, d] _ = ∑ q ∈ available, ∑ p ∈ available, if q ⊆ extensions p then 1 else 0 := Finset.sum_comm _ = ∑ q ∈ available, k q := by apply Finset.sum_congr rfl intro q _ rw [← Finset.sum_filter (s := available) (fun p => q ⊆ extensions p) (fun _ => (1 : ℕ))] simp [k] have hBound : (∑ p ∈ available, (d p).choose 2) ≤ 3 * filled.card := by rw [hCount] have hsum : (∑ q ∈ filled, k q) = ∑ q ∈ available, k q := by rw [Finset.sum_filter] apply Finset.sum_congr rfl intro q _ split_ifs with h · rfl · symm apply Finset.card_eq_zero.mpr exact Finset.eq_empty_iff_forall_notMem.mpr (fun p hp => h ⟨p, (Finset.mem_filter.mp hp).1, (Finset.mem_filter.mp hp).2⟩) rw [← hsum] calc (∑ q ∈ filled, k q) ≤ ∑ _q ∈ filled, (3 : ℕ) := Finset.sum_le_sum (fun q hq => hCommon q (Finset.mem_filter.mp hq).1) _ = 3 * filled.card := by simp [Nat.mul_comm] have hLocal (a : ℕ) : 3 * a ≤ 6 + a.choose 2 := by induction a with | zero => decide | succ a ih => by_cases ha : 3 ≤ a · have hp : (a + 1).choose 2 = a + a.choose 2 := by simpa only [Nat.choose_one_right] using Nat.choose_succ_succ' a 1 change 3 * (a + 1) ≤ 6 + (a + 1).choose 2 rw [hp] omega · interval_cases a <;> decide have hTotal : (∑ p ∈ available, (6 + (d p).choose 2)) = 6 * available.card + ∑ p ∈ available, (d p).choose 2 := by simp [Finset.sum_add_distrib, Nat.mul_comm] have hCompare : 3 * (∑ p ∈ available, d p) ≤ 6 * available.card + ∑ p ∈ available, (d p).choose 2 := by rw [← hTotal, Finset.mul_sum] exact Finset.sum_le_sum (fun p _ => hLocal (d p)) constructor · omega · intro hEq have hTight : 3 * (∑ p ∈ available, d p) = 6 * available.card + ∑ p ∈ available, (d p).choose 2 := by omega have hLower (p : Finset (Fin n)) (hp : p ∈ available) : 3 ≤ d p := by by_contra! hlt have hStrict : 3 * d p < 6 + (d p).choose 2 := by generalize d p = a at hlt ⊢ interval_cases a <;> decide have hSumStrict := Finset.sum_lt_sum (s := available) (fun q _ => hLocal (d q)) ⟨p, hp, hStrict⟩ rw [← Finset.mul_sum, hTotal] at hSumStrict omega have hMinChoose : 3 * available.card ≤ ∑ p ∈ available, (d p).choose 2 := calc 3 * available.card = ∑ _p ∈ available, (3 : ℕ) := by simp [Nat.mul_comm] _ ≤ _ := Finset.sum_le_sum (fun p hp => Nat.choose_le_choose 2 (hLower p hp)) have hEmpty : emptyLabels.card = 0 := by omega refine ⟨Finset.card_eq_zero.mp hEmpty, fun p hp => le_antisymm ?_ (hLower p hp)⟩ by_contra! hlt have hStrict : 3 < (d p).choose 2 := lt_of_lt_of_le (by decide : 3 < (4 : ℕ).choose 2) (Nat.choose_le_choose 2 hlt) have hsum : (∑ _q ∈ available, (3 : ℕ)) < ∑ q ∈ available, (d q).choose 2 := Finset.sum_lt_sum (s := available) (fun q hq => show 3 ≤ (d q).choose 2 from Nat.choose_le_choose 2 (hLower q hq)) ⟨p, hp, hStrict⟩ have hThreeSum : (∑ _q ∈ available, (3 : ℕ)) = 3 * available.card := by simp [Nat.mul_comm] rw [hThreeSum] at hsum omega theorem residual_triple_bound_of_common_links_le_three {n : ℕ} (edges available : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hPairs : ∀ p ∈ available, p.card = 2) (hCovered : ∀ e ∈ edges, e.powersetCard 2 ⊆ available) (hLabels : ∀ p ∈ available, ((Finset.univ.filter (fun x => x ∉ p ∧ insert x p ∈ edges)).powersetCard 2) ⊆ available) (hCommon : ∀ q ∈ available, (available.filter (fun p => q ⊆ Finset.univ.filter (fun x => x ∉ p ∧ insert x p ∈ edges))).card ≤ 3) : let emptyLabels := available.filter (fun q => ¬ ∃ p ∈ available, q ⊆ Finset.univ.filter (fun x => x ∉ p ∧ insert x p ∈ edges)) 3 * edges.card + emptyLabels.card ≤ 3 * available.card ∧ (3 * edges.card + emptyLabels.card = 3 * available.card → emptyLabels = ∅ ∧ ∀ p ∈ available, (edges.filter (fun e => p ⊆ e)).card = 3) := by let extensions (p : Finset (Fin n)) := Finset.univ.filter (fun x => x ∉ p ∧ insert x p ∈ edges) have hCodegree (p : Finset (Fin n)) (hp : p ∈ available) : (extensions p).card = (edges.filter (fun e => p ⊆ e)).card := by refine Finset.card_bij (fun x _ => insert x p) ?_ ?_ ?_ · intro x hx exact Finset.mem_filter.mpr ⟨(Finset.mem_filter.mp hx).2.2, Finset.subset_insert _ _⟩ · intro x hx y _ h exact (Finset.mem_insert.mp (h ▸ Finset.mem_insert_self x p)).resolve_right (Finset.mem_filter.mp hx).2.1 · intro e he obtain ⟨hee, hpe⟩ := Finset.mem_filter.mp he have hdiff : (e \ p).card = 1 := by rw [Finset.card_sdiff_of_subset hpe, hUniform e hee, hPairs p hp] obtain ⟨x, hx⟩ := Finset.card_pos.mp (by omega : 0 < (e \ p).card) obtain ⟨hxe, hxp⟩ := Finset.mem_sdiff.mp hx have hxeq : insert x p = e := Finset.eq_of_subset_of_card_le (Finset.insert_subset_iff.mpr ⟨hxe, hpe⟩) (by rw [Finset.card_insert_of_notMem hxp, hPairs p hp, hUniform e hee]) exact ⟨x, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hxp, hxeq ▸ hee⟩, hxeq⟩ have hTotal : ∑ p ∈ available, (extensions p).card = 3 * edges.card := calc ∑ p ∈ available, (extensions p).card = ∑ p ∈ available, ∑ e ∈ edges, if p ⊆ e then (1 : ℕ) else 0 := by apply Finset.sum_congr rfl intro p hp rw [hCodegree p hp, ← Finset.sum_filter (s := edges) (fun e => p ⊆ e) (fun _ => (1 : ℕ))] simp _ = ∑ e ∈ edges, ∑ p ∈ available, if p ⊆ e then (1 : ℕ) else 0 := Finset.sum_comm _ = ∑ _e ∈ edges, (3 : ℕ) := by apply Finset.sum_congr rfl intro e he have hfilter : available.filter (fun p => p ⊆ e) = e.powersetCard 2 := by ext p exact ⟨fun h => Finset.mem_powersetCard.mpr ⟨(Finset.mem_filter.mp h).2, hPairs p (Finset.mem_filter.mp h).1⟩, fun h => Finset.mem_filter.mpr ⟨hCovered e he h, (Finset.mem_powersetCard.mp h).1⟩⟩ rw [← Finset.sum_filter (s := available) (fun p => p ⊆ e) (fun _ => (1 : ℕ))] simp [hfilter, hUniform e he] _ = 3 * edges.card := by simp [Nat.mul_comm] have h := residual_weighted_bound_of_common_links_le_three available extensions hPairs hLabels hCommon dsimp only at h ⊢ rw [hTotal] at h refine ⟨h.1, fun hEq => ?_⟩ obtain ⟨hEmpty, hAll⟩ := h.2 hEq exact ⟨hEmpty, fun p hp => (hCodegree p hp).symm.trans (hAll p hp)⟩ /-- At equality it is enough to bound the common links in the residual. -/ theorem classify_extremal_of_residual_common_links_le_three {n : ℕ} {edges blocks : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hU : ∀ e ∈ edges, e.card = 3) (hE : edges.card = n.choose 2) (hB : ∀ B ∈ blocks, B.card = 5 ∧ ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hG : let residual := fullFiveResidual edges blocks ∀ p : Finset (Fin n), p.card = 2 → (localCoExtensions residual p).card ≤ 3) : ∃ result : Finset (Finset (Fin n)), SteinerFive result ∧ IsExpansion edges result := by classical apply classify_extremal_of_residual_weighted_bound hu hU hE hB let residual := fullFiveResidual edges blocks let missing := fullFiveMissingPairs blocks have hsub : residual ⊆ edges := Finset.filter_subset _ _ have hR : ∀ t ∈ residual, ∀ B ∈ blocks, (t ∩ B).card ≤ 1 := fun _ ht => (Finset.mem_filter.mp ht).2 obtain ⟨hSupport,hLabels⟩ := full_five_residual_shadows_subset_missing hu hsub hB hR have hPair : ∀ p ∈ missing, p.card = 2 := fun _ hp => (Finset.mem_powersetCard.mp (Finset.mem_filter.mp hp).1).2 have hCover : ∀ e ∈ residual, e.powersetCard 2 ⊆ missing := by intro e he p hp obtain ⟨hpe,hp2⟩ := Finset.mem_powersetCard.mp hp apply Finset.mem_filter.mpr refine ⟨Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _,hp2⟩, ?_⟩ intro B hBm hpB have h1 := hR e he B hBm have h2 := Finset.card_le_card (Finset.subset_inter hpe hpB) omega have hFilter (q : Finset (Fin n)) (hq : q.card = 2) : missing.filter (fun p => q ⊆ localExtensions residual p) = localCoExtensions residual q := by ext p rw [Finset.mem_filter, local_mem_coextensions] constructor · exact fun ⟨hp,hqp⟩ => ⟨hPair p hp,hqp⟩ · rintro ⟨hp,hqp⟩ obtain ⟨x,hx⟩ := Finset.card_pos.mp (show 0 < q.card by omega) exact ⟨hSupport p hp ⟨x,hqp hx⟩,hqp⟩ have hZero : missing.filter (fun q => ¬ ∃ p ∈ missing, q ⊆ localExtensions residual p) = missing.filter (fun q => localCoExtensions residual q = ∅) := by ext q simp only [Finset.mem_filter] constructor · rintro ⟨hq,hn⟩ refine ⟨hq, Finset.eq_empty_iff_forall_notMem.mpr ?_⟩ intro p hp rw [← hFilter q (hPair q hq)] at hp exact hn ⟨p,(Finset.mem_filter.mp hp).1,(Finset.mem_filter.mp hp).2⟩ · rintro ⟨hq,hEmp⟩ refine ⟨hq,?_⟩ rintro ⟨p,hpm,hpq⟩ have hm : p ∈ missing.filter (fun p => q ⊆ localExtensions residual p) := Finset.mem_filter.mpr ⟨hpm,hpq⟩ rw [hFilter q (hPair q hq),hEmp] at hm exact Finset.notMem_empty _ hm have hBnd := residual_triple_bound_of_common_links_le_three residual missing (fun e he => hU e (hsub he)) hPair hCover (fun p hp => hLabels p (hPair p hp)) (fun q hq => by change (missing.filter fun p => q ⊆ localExtensions residual p).card ≤ 3 rw [hFilter q (hPair q hq)] exact hG q (hPair q hq)) dsimp only at hBnd let emptyLabels := missing.filter (fun q => ¬ ∃ p ∈ missing, q ⊆ localExtensions residual p) change (3 * residual.card + emptyLabels.card ≤ 3 * missing.card ∧ (3 * residual.card + emptyLabels.card = 3 * missing.card → emptyLabels = ∅ ∧ ∀ p ∈ missing, (residual.filter (fun e => p ⊆ e)).card = 3)) at hBnd have hZero' : emptyLabels = missing.filter (fun q => localCoExtensions residual q = ∅) := hZero refine ⟨by simpa only [hZero',fullFiveEmptyLabels] using hBnd.1,?_⟩ intro heq have heq' : 3 * residual.card + emptyLabels.card = 3 * missing.card := by rw [hZero'] exact heq obtain ⟨hz,hd⟩ := hBnd.2 heq' refine ⟨by simpa only [hZero',fullFiveEmptyLabels] using hz,fun p hp => ?_⟩ obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp (hPair p hp) have hi (c : Fin n) : insert c ({a,b} : Finset (Fin n)) = {a,b,c} := by ext x simp only [Finset.mem_insert,Finset.mem_singleton] tauto have he := extension_card_eq_pair_filter_card residual (fun e he => hU e (hsub he)) hab have he' : (localExtensions residual {a,b}).card = (residual.filter (fun e => ({a,b} : Finset (Fin n)) ⊆ e)).card := by simpa only [localExtensions,hi] using he rw [he',hd _ hp] decide /-- The stronger weighted estimate requires only a codegree cap in the residual. -/ theorem classify_extremal_of_residual_strong_bound {n : ℕ} {edges blocks : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hU : ∀ e ∈ edges, e.card = 3) (hE : edges.card = n.choose 2) (hB : ∀ B ∈ blocks, B.card = 5 ∧ ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hD : let residual := fullFiveResidual edges blocks ∀ p : Finset (Fin n), p.card = 2 → (localExtensions residual p).card ≤ 5) (hStrong : let residual := fullFiveResidual edges blocks let missing := fullFiveMissingPairs blocks let zero := fullFiveEmptyLabels residual missing 2 * residual.card + zero.card ≤ 2 * missing.card) : ∃ result : Finset (Finset (Fin n)), SteinerFive result ∧ IsExpansion edges result := by classical apply classify_extremal_of_residual_weighted_bound hu hU hE hB let residual := fullFiveResidual edges blocks let missing := fullFiveMissingPairs blocks let zero := fullFiveEmptyLabels residual missing change 2 * residual.card + zero.card ≤ 2 * missing.card at hStrong change 3 * residual.card + zero.card ≤ 3 * missing.card ∧ (3 * residual.card + zero.card = 3 * missing.card → zero = ∅ ∧ ∀ p ∈ missing, (localExtensions residual p).card ≤ 5) refine ⟨by omega, fun heq => ⟨Finset.card_eq_zero.mp (by omega),?_⟩⟩ intro p hp exact hD p (Finset.mem_powersetCard.mp (Finset.mem_filter.mp hp).1).2 def sharpResidualEdges : Finset (Finset (Fin 18)) := {{2, 5, 6}, {2, 5, 7}, {2, 6, 7}, {5, 6, 8}, {5, 6, 9}, {5, 7, 8}, {5, 7, 9}, {6, 7, 8}, {6, 7, 9}, {3, 5, 10}, {3, 5, 11}, {3, 10, 11}, {5, 10, 12}, {5, 10, 13}, {5, 11, 12}, {5, 11, 13}, {10, 11, 12}, {10, 11, 13}, {4, 5, 14}, {4, 5, 15}, {4, 14, 15}, {5, 14, 16}, {5, 14, 17}, {5, 15, 16}, {5, 15, 17}, {14, 15, 16}, {14, 15, 17}} def sharpResidualCompletion : Finset (Finset (Fin 18)) := (({0, 1, 2, 3, 4} : Finset (Fin 18)).powersetCard 3) ∪ insert {0, 1, 5} sharpResidualEdges def sharpResidualShadow : Finset (Finset (Fin 18)) := sharpResidualEdges.biUnion fun e => e.powersetCard 2 def sharpResidualLabels : Finset (Finset (Fin 18)) := sharpResidualEdges.biUnion fun e => (sharpResidualEdges.filter fun f => (e ∩ f).card = 2).image fun f => (e \ f) ∪ (f \ e) theorem sharp_residual_uniform : ∀ e ∈ sharpResidualEdges, e.card = 3 := by simp only [sharpResidualEdges, Finset.forall_mem_insert, Finset.mem_singleton, forall_eq] repeat' apply And.intro <;> decide theorem sharp_residual_counts : sharpResidualEdges.card = 27 ∧ sharpResidualShadow.card = 36 ∧ sharpResidualLabels.card = 18 := by refine ⟨by decide, by decide, ?_⟩ set_option maxHeartbeats 0 in decide +kernel theorem sharp_residual_charged_pairs : ({{2, 5}, {3, 5}, {4, 5}} : Finset (Finset (Fin 18))) ⊆ sharpResidualShadow \ sharpResidualLabels := by set_option maxHeartbeats 0 in decide +kernel theorem sharp_residual_meets_block_at_most_one : ∀ e ∈ sharpResidualEdges, (e ∩ ({0, 1, 2, 3, 4} : Finset (Fin 18))).card ≤ 1 := by simp only [sharpResidualEdges, Finset.forall_mem_insert, Finset.mem_singleton, forall_eq] repeat' apply And.intro <;> decide theorem sharp_residual_completion_unique : UniqueDisjointUnions sharpResidualCompletion := by let edges := sharpResidualCompletion let mask (e : Finset (Fin 18)) : BitVec 18 := (BitVec.ofBoolListLE ((List.finRange 18).map fun v => decide (v ∈ e))).cast (by simp) let masks : List (BitVec 18) := [7, 11, 19, 35, 13, 21, 25, 14, 22, 26, 28, 100, 164, 196, 1064, 2088, 3080, 16432, 32816, 49168, 352, 608, 416, 672, 5152, 9248, 6176, 10272, 81952, 147488, 98336, 163872, 448, 704, 7168, 11264, 114688, 180224] have hValid : ∀ e ∈ edges, mask e ∈ masks := by have hBlock : (({0,1,2,3,4} : Finset (Fin 18)).powersetCard 3) = {{0, 1, 2}, {0, 1, 3}, {0, 1, 4}, {0, 2, 3}, {0, 2, 4}, {0, 3, 4}, {1, 2, 3}, {1, 2, 4}, {1, 3, 4}, {2, 3, 4}} := by decide +kernel change ∀ e ∈ sharpResidualCompletion, mask e ∈ masks rw [sharpResidualCompletion, hBlock] rw [Finset.forall_mem_union] simp only [sharpResidualEdges, Finset.forall_mem_insert, Finset.mem_singleton, forall_eq] repeat' apply And.intro all_goals (dsimp only [masks, mask]; decide +kernel) have hMask (e : Finset (Fin 18)) (i : Fin 18) : (mask e).getLsbD i = decide (i ∈ e) := by unfold mask rw [BitVec.getLsbD_cast, BitVec.getLsbD_ofBoolListLE] simp [List.getD_eq_getElem?_getD, i.isLt] have hInj : Function.Injective mask := by intro e f h ext v exact decide_eq_decide.mp (by rw [← hMask, ← hMask, h]) have hUnion (e f : Finset (Fin 18)) : mask (e ∪ f) = mask e ||| mask f := by apply BitVec.eq_of_getLsbD_eq intro i hi let v : Fin 18 := ⟨i, hi⟩ change (mask (e ∪ f)).getLsbD v = (mask e ||| mask f).getLsbD v rw [BitVec.getLsbD_or, hMask, hMask, hMask] simp have hDisj {e f : Finset (Fin 18)} (h : Disjoint e f) : mask e &&& mask f = 0 := by apply BitVec.eq_of_getLsbD_eq intro i hi let v : Fin 18 := ⟨i, hi⟩ change (mask e &&& mask f).getLsbD v = (0 : BitVec 18).getLsbD v rw [BitVec.getLsbD_and, hMask, hMask] by_cases he : v ∈ e · have hf : v ∉ f := fun hf => Finset.disjoint_left.mp h he hf simp [he, hf] · simp [he] let disjointPairs := masks.flatMap fun a => (masks.filter fun b => decide (a.toNat < b.toNat) && (a &&& b == 0)).map (fun b => (a, b)) let unionMask (p : BitVec 18 × BitVec 18) := p.1 ||| p.2 let bucket (i : Fin 11) := disjointPairs.filter (fun p => decide ((unionMask p).toNat % 11 = i.val)) have hBucket (i : Fin 11) : ((bucket i).map unionMask).Nodup := by set_option maxHeartbeats 0 in fin_cases i all_goals (dsimp only [bucket, disjointPairs, masks, unionMask]; decide +kernel) have hPair {a b : BitVec 18} (ha : a ∈ masks) (hb : b ∈ masks) (hab : a &&& b = 0) (hlt : a.toNat < b.toNat) : (a, b) ∈ disjointPairs := by refine List.mem_flatMap.mpr ⟨a, ha, List.mem_map.mpr ⟨b, ?_, rfl⟩⟩ exact List.mem_filter.mpr ⟨hb, by simp [hlt, hab]⟩ have hNonzero : (0 : BitVec 18) ∉ masks := by dsimp only [masks] decide +kernel have hNe {a b : BitVec 18} (ha : a ∈ masks) (hab : a &&& b = 0) : a.toNat ≠ b.toNat := by intro heq have he := BitVec.eq_of_toNat_eq heq subst b have hz : a = 0 := by simpa using hab exact hNonzero (hz ▸ ha) have hCertificateEq {a b c d : BitVec 18} (hab : (a, b) ∈ disjointPairs) (hcd : (c, d) ∈ disjointPairs) (hu : a ||| b = c ||| d) : a = c ∧ b = d := by let i : Fin 11 := ⟨(a ||| b).toNat % 11, Nat.mod_lt _ (by decide)⟩ have hb₁ : (a,b) ∈ bucket i := List.mem_filter.mpr ⟨hab, by simp [unionMask, i]⟩ have hb₂ : (c,d) ∈ bucket i := List.mem_filter.mpr ⟨hcd, by simp [unionMask, i, hu]⟩ exact Prod.mk.inj (List.inj_on_of_nodup_map (hBucket i) hb₁ hb₂ hu) have hBV (a b c d : BitVec 18) (ha : a ∈ masks) (hb : b ∈ masks) (hc : c ∈ masks) (hd : d ∈ masks) (hab : a &&& b = 0) (hcd : c &&& d = 0) (hu : a ||| b = c ||| d) : (a = c ∧ b = d) ∨ (a = d ∧ b = c) := by rcases lt_or_gt_of_ne (hNe ha hab) with habLt | habGt <;> rcases lt_or_gt_of_ne (hNe hc hcd) with hcdLt | hcdGt · exact Or.inl (hCertificateEq (hPair ha hb hab habLt) (hPair hc hd hcd hcdLt) hu) · exact Or.inr (hCertificateEq (hPair ha hb hab habLt) (hPair hd hc (by simpa only [BitVec.and_comm] using hcd) hcdGt) (by simpa only [BitVec.or_comm d c] using hu)) · have h := hCertificateEq (hPair hc hd hcd hcdLt) (hPair hb ha (by simpa only [BitVec.and_comm] using hab) habGt) (by simpa only [BitVec.or_comm b a] using hu.symm) exact Or.inr ⟨h.2.symm, h.1.symm⟩ · have h := hCertificateEq (hPair hb ha (by simpa only [BitVec.and_comm] using hab) habGt) (hPair hd hc (by simpa only [BitVec.and_comm] using hcd) hcdGt) (by simpa only [BitVec.or_comm b a, BitVec.or_comm d c] using hu) exact Or.inl ⟨h.2, h.1⟩ intro A hA B hB C hC D hD hAB hCD hU have hu := congrArg mask hU rw [hUnion, hUnion] at hu rcases hBV (mask A) (mask B) (mask C) (mask D) (hValid A hA) (hValid B hB) (hValid C hC) (hValid D hD) (hDisj hAB) (hDisj hCD) hu with h | h · exact Or.inl ⟨hInj h.1, hInj h.2⟩ · exact Or.inr ⟨hInj h.1, hInj h.2⟩ /-- The ordinary pair shadow of a triple family. -/ def ordinaryPairShadow {n : ℕ} (edges : Finset (Finset (Fin n))) : Finset (Finset (Fin n)) := edges.biUnion (fun e => e.powersetCard 2) /-- Pairs that are both extensions of some supporting pair. -/ def commonPairLabelShadow {n : ℕ} (edges : Finset (Finset (Fin n))) : Finset (Finset (Fin n)) := ((Finset.univ : Finset (Fin n)).powersetCard 2).filter (fun p => (localCoExtensions edges p).Nonempty) theorem mem_ordinaryPairShadow {n : ℕ} {edges : Finset (Finset (Fin n))} {p : Finset (Fin n)} : p ∈ ordinaryPairShadow edges ↔ p.card = 2 ∧ ∃ e ∈ edges, p ⊆ e := by constructor · intro h obtain ⟨e, he, hpe⟩ := Finset.mem_biUnion.mp h exact ⟨(Finset.mem_powersetCard.mp hpe).2, e, he, (Finset.mem_powersetCard.mp hpe).1⟩ · rintro ⟨hp, e, he, hpe⟩ exact Finset.mem_biUnion.mpr ⟨e, he, Finset.mem_powersetCard.mpr ⟨hpe, hp⟩⟩ /-- If the ordinary shadows are disjoint, both supporting triples of a label come from the same family. Two different families cannot support the same label. -/ theorem disjoint_commonPairLabelShadow_union {n : ℕ} {left right : Finset (Finset (Fin n))} (hshadow : Disjoint (ordinaryPairShadow left) (ordinaryPairShadow right)) (hu : UniqueDisjointUnions (left ∪ right)) : Disjoint (commonPairLabelShadow left) (commonPairLabelShadow right) ∧ commonPairLabelShadow (left ∪ right) = commonPairLabelShadow left ∪ commonPairLabelShadow right := by classical have extension_subset {A B : Finset (Finset (Fin n))} (hAB : A ⊆ B) (p : Finset (Fin n)) : localExtensions A p ⊆ localExtensions B p := by intro z hz obtain ⟨_,hn,he⟩ := Finset.mem_filter.mp hz exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hn,hAB he⟩ have label_subset {A B : Finset (Finset (Fin n))} (hAB : A ⊆ B) : commonPairLabelShadow A ⊆ commonPairLabelShadow B := by intro q hq obtain ⟨hq2,⟨p,hp⟩⟩ := Finset.mem_filter.mp hq obtain ⟨hp2,hqp⟩ := local_mem_coextensions.mp hp exact Finset.mem_filter.mpr ⟨hq2,⟨p,local_mem_coextensions.mpr ⟨hp2,hqp.trans (extension_subset hAB p)⟩⟩⟩ constructor · apply Finset.disjoint_left.mpr intro q hl hr obtain ⟨hq,⟨p,hp⟩⟩ := Finset.mem_filter.mp hl obtain ⟨_,⟨r,hr'⟩⟩ := Finset.mem_filter.mp hr have hq2 := (Finset.mem_powersetCard.mp hq).2 obtain ⟨hp2,hqp⟩ := local_mem_coextensions.mp hp obtain ⟨hr2,hqr⟩ := local_mem_coextensions.mp hr' have hpr : ¬ Disjoint p r := by intro hd exact local_coextension_pairwise hu hq2 (local_mem_coextensions.mpr ⟨hp2,hqp.trans (extension_subset Finset.subset_union_left p)⟩) (local_mem_coextensions.mpr ⟨hr2,hqr.trans (extension_subset Finset.subset_union_right r)⟩) hd have hcap : (p ∩ r).Nonempty := by by_contra h exact hpr (Finset.disjoint_iff_inter_eq_empty.mpr (Finset.not_nonempty_iff_eq_empty.mp h)) obtain ⟨z,hz⟩ := hcap obtain ⟨hzp,hzr⟩ := Finset.mem_inter.mp hz obtain ⟨x,hx⟩ := Finset.card_pos.mp (show 0 < q.card by omega) obtain ⟨_,hxp,hxe⟩ := Finset.mem_filter.mp (hqp hx) obtain ⟨_,_,hxf⟩ := Finset.mem_filter.mp (hqr hx) have hxz : x ≠ z := fun h => hxp (h ▸ hzp) have lm : ({x,z} : Finset (Fin n)) ∈ ordinaryPairShadow left := mem_ordinaryPairShadow.mpr ⟨by simp [hxz],insert x p,hxe,by simp [Finset.insert_subset_iff,hzp]⟩ have rm : ({x,z} : Finset (Fin n)) ∈ ordinaryPairShadow right := mem_ordinaryPairShadow.mpr ⟨by simp [hxz],insert x r,hxf,by simp [Finset.insert_subset_iff,hzr]⟩ exact Finset.disjoint_left.mp hshadow lm rm · apply Finset.Subset.antisymm · intro q hq obtain ⟨hq2,⟨p,hp⟩⟩ := Finset.mem_filter.mp hq obtain ⟨hp2,hqp⟩ := local_mem_coextensions.mp hp obtain ⟨x,hx⟩ := Finset.card_pos.mp (show 0 < q.card by have := (Finset.mem_powersetCard.mp hq2).2; omega) have ex (z : Fin n) (hz : z ∈ q) : z ∉ p ∧ (insert z p ∈ left ∨ insert z p ∈ right) := by obtain ⟨_,hn,he⟩ := Finset.mem_filter.mp (hqp hz) exact ⟨hn,Finset.mem_union.mp he⟩ rcases (ex x hx).2 with hl | hr · have hpL := mem_ordinaryPairShadow.mpr ⟨hp2,insert x p,hl,Finset.subset_insert x p⟩ refine Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨hq2,⟨p,?_⟩⟩) apply local_mem_coextensions.mpr refine ⟨hp2,?_⟩ intro z hz obtain ⟨hn,hzL | hzR⟩ := ex z hz · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hn,hzL⟩ · exact (Finset.disjoint_left.mp hshadow hpL (mem_ordinaryPairShadow.mpr ⟨hp2,insert z p,hzR,Finset.subset_insert z p⟩)).elim · have hpR := mem_ordinaryPairShadow.mpr ⟨hp2,insert x p,hr,Finset.subset_insert x p⟩ refine Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨hq2,⟨p,?_⟩⟩) apply local_mem_coextensions.mpr refine ⟨hp2,?_⟩ intro z hz obtain ⟨hn,hzL | hzR⟩ := ex z hz · exact (Finset.disjoint_left.mp hshadow (mem_ordinaryPairShadow.mpr ⟨hp2,insert z p,hzL,Finset.subset_insert z p⟩) hpR).elim · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hn,hzR⟩ · exact Finset.union_subset (label_subset Finset.subset_union_left) (label_subset Finset.subset_union_right) theorem ordinaryPairShadow_union {n : ℕ} (left right : Finset (Finset (Fin n))) : ordinaryPairShadow (left ∪ right) = ordinaryPairShadow left ∪ ordinaryPairShadow right := by ext p simp only [mem_ordinaryPairShadow, Finset.mem_union] constructor · rintro ⟨hp, e, he | he, hpe⟩ · exact Or.inl ⟨hp,e,he,hpe⟩ · exact Or.inr ⟨hp,e,he,hpe⟩ · rintro (⟨hp,e,he,hpe⟩ | ⟨hp,e,he,hpe⟩) · exact ⟨hp,e,Or.inl he,hpe⟩ · exact ⟨hp,e,Or.inr he,hpe⟩ /-- The two-shadow bound splits over families that share no supporting pair. If both subfamilies satisfy it and the union attains equality, both attain equality. -/ theorem shadow_sum_bound_and_equality_of_disjoint_shadows {n : ℕ} {left right : Finset (Finset (Fin n))} (hshadow : Disjoint (ordinaryPairShadow left) (ordinaryPairShadow right)) (hu : UniqueDisjointUnions (left ∪ right)) (hUniform : ∀ e ∈ left ∪ right, e.card = 3) (hl : 2 * left.card ≤ (ordinaryPairShadow left).card + (commonPairLabelShadow left).card) (hr : 2 * right.card ≤ (ordinaryPairShadow right).card + (commonPairLabelShadow right).card) : let both := left ∪ right 2 * both.card ≤ (ordinaryPairShadow both).card + (commonPairLabelShadow both).card ∧ (2 * both.card = (ordinaryPairShadow both).card + (commonPairLabelShadow both).card → 2 * left.card = (ordinaryPairShadow left).card + (commonPairLabelShadow left).card ∧ 2 * right.card = (ordinaryPairShadow right).card + (commonPairLabelShadow right).card) := by classical have hDisjoint : Disjoint left right := by apply Finset.disjoint_left.mpr intro e he hf have h3 := hUniform e (Finset.mem_union_left _ he) obtain ⟨p,hpe,hp⟩ := Finset.exists_subset_card_eq (s := e) (n := 2) (by omega) exact Finset.disjoint_left.mp hshadow (mem_ordinaryPairShadow.mpr ⟨hp,e,he,hpe⟩) (mem_ordinaryPairShadow.mpr ⟨hp,e,hf,hpe⟩) obtain ⟨hLabel,hEq⟩ := disjoint_commonPairLabelShadow_union hshadow hu dsimp only rw [ordinaryPairShadow_union, hEq, Finset.card_union_of_disjoint hDisjoint, Finset.card_union_of_disjoint hshadow, Finset.card_union_of_disjoint hLabel] omega /-- Summing the reciprocal weights of the supporting pairs counts the nonempty labels. -/ theorem common_pair_label_reciprocal_sum {n : ℕ} (edges : Finset (Finset (Fin n))) : ((commonPairLabelShadow edges).card : ℚ) = ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, ∑ q ∈ (localExtensions edges p).powersetCard 2, ((localCoExtensions edges q).card : ℚ)⁻¹ := by classical let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let w (q : Finset (Fin n)) := ((localCoExtensions edges q).card : ℚ)⁻¹ change ((commonPairLabelShadow edges).card : ℚ) = ∑ p ∈ P, ∑ q ∈ (localExtensions edges p).powersetCard 2, w q symm calc _ = ∑ p ∈ P, ∑ q ∈ P, if q ⊆ localExtensions edges p then w q else 0 := by apply Finset.sum_congr rfl intro p _ have hf : P.filter (fun q => q ⊆ localExtensions edges p) = (localExtensions edges p).powersetCard 2 := by ext q simp [P, and_comm] rw [← Finset.sum_filter, hf] _ = ∑ q ∈ P, ∑ p ∈ P, if q ⊆ localExtensions edges p then w q else 0 := Finset.sum_comm _ = ∑ q ∈ P, if (localCoExtensions edges q).Nonempty then (1 : ℚ) else 0 := by apply Finset.sum_congr rfl intro q _ rw [← Finset.sum_filter] change (∑ _ ∈ localCoExtensions edges q, w q) = if (localCoExtensions edges q).Nonempty then 1 else 0 by_cases h : (localCoExtensions edges q).Nonempty · rw [if_pos h, Finset.sum_const, nsmul_eq_mul] have hn : ((localCoExtensions edges q).card : ℚ) ≠ 0 := by exact_mod_cast (Finset.card_pos.mpr h).ne' exact mul_inv_cancel₀ hn · rw [if_neg h,Finset.not_nonempty_iff_eq_empty.mp h,Finset.sum_empty] _ = _ := by rw [← Finset.sum_filter] simp [P,commonPairLabelShadow] def tightSevenEdges : Finset (Finset (Fin 7)) := {{0, 1, 3}, {0, 1, 4}, {0, 1, 5}, {0, 1, 6}, {0, 2, 3}, {0, 2, 4}, {0, 2, 5}, {0, 2, 6}, {1, 2, 3}, {1, 2, 4}, {1, 2, 5}, {1, 2, 6}} theorem tight_seven_uniform : ∀ e ∈ tightSevenEdges, e.card = 3 := by simp only [tightSevenEdges, Finset.forall_mem_insert, Finset.mem_singleton, forall_eq] repeat' apply And.intro <;> decide theorem tight_seven_counts : tightSevenEdges.card = 12 ∧ (tightSevenEdges.biUnion fun e => e.powersetCard 2).card = 15 ∧ (tightSevenEdges.biUnion fun e => (tightSevenEdges.filter fun f => (e ∩ f).card = 2).image fun f => (e \ f) ∪ (f \ e)).card = 9 ∧ (tightSevenEdges.filter fun e => ({0, 1} : Finset (Fin 7)) ⊆ e).card = 4 := by refine ⟨by decide, by decide, ?_, by decide⟩ decide +kernel theorem tight_seven_pair_connected : ∀ e ∈ tightSevenEdges, ∀ f ∈ tightSevenEdges, (tightSevenEdges.filter fun g => (e ∩ g).card = 2 ∧ (f ∩ g).card = 2).Nonempty := by simp only [tightSevenEdges, Finset.forall_mem_insert, Finset.mem_singleton, forall_eq] repeat' apply And.intro all_goals decide +kernel theorem tight_seven_unique : UniqueDisjointUnions tightSevenEdges := by let edges := tightSevenEdges let mask (e : Finset (Fin 7)) : BitVec 7 := (BitVec.ofBoolListLE ((List.finRange 7).map fun v => decide (v ∈ e))).cast (by simp) let masks : List (BitVec 7) := [11, 19, 35, 67, 13, 21, 37, 69, 14, 22, 38, 70] have hValid : ∀ e ∈ edges, mask e ∈ masks := by simp only [edges, tightSevenEdges, Finset.forall_mem_insert, Finset.mem_singleton, forall_eq] repeat' apply And.intro all_goals (dsimp only [masks, mask]; decide +kernel) have hMask (e : Finset (Fin 7)) (i : Fin 7) : (mask e).getLsbD i = decide (i ∈ e) := by unfold mask rw [BitVec.getLsbD_cast, BitVec.getLsbD_ofBoolListLE] simp [List.getD_eq_getElem?_getD, i.isLt] have hInj : Function.Injective mask := by intro e f h ext v exact decide_eq_decide.mp (by rw [← hMask, ← hMask, h]) have hUnion (e f : Finset (Fin 7)) : mask (e ∪ f) = mask e ||| mask f := by apply BitVec.eq_of_getLsbD_eq intro i hi let v : Fin 7 := ⟨i, hi⟩ change (mask (e ∪ f)).getLsbD v = (mask e ||| mask f).getLsbD v rw [BitVec.getLsbD_or, hMask, hMask, hMask] simp have hDisj {e f : Finset (Fin 7)} (h : Disjoint e f) : mask e &&& mask f = 0 := by apply BitVec.eq_of_getLsbD_eq intro i hi let v : Fin 7 := ⟨i, hi⟩ change (mask e &&& mask f).getLsbD v = (0 : BitVec 7).getLsbD v rw [BitVec.getLsbD_and, hMask, hMask] by_cases he : v ∈ e · have hf : v ∉ f := fun hf => Finset.disjoint_left.mp h he hf simp [he, hf] · simp [he] let disjointPairs := masks.flatMap fun a => (masks.filter fun b => decide (a.toNat < b.toNat) && (a &&& b == 0)).map (fun b => (a, b)) let unionMask (p : BitVec 7 × BitVec 7) := p.1 ||| p.2 have hCertificate : (disjointPairs.map unionMask).Nodup := by dsimp only [disjointPairs, masks, unionMask] decide +kernel have hPair {a b : BitVec 7} (ha : a ∈ masks) (hb : b ∈ masks) (hab : a &&& b = 0) (hlt : a.toNat < b.toNat) : (a, b) ∈ disjointPairs := by refine List.mem_flatMap.mpr ⟨a, ha, List.mem_map.mpr ⟨b, ?_, rfl⟩⟩ exact List.mem_filter.mpr ⟨hb, by simp [hlt, hab]⟩ have hNonzero : (0 : BitVec 7) ∉ masks := by dsimp only [masks] decide +kernel have hNe {a b : BitVec 7} (ha : a ∈ masks) (hab : a &&& b = 0) : a.toNat ≠ b.toNat := by intro heq have he := BitVec.eq_of_toNat_eq heq subst b have hz : a = 0 := by simpa using hab exact hNonzero (hz ▸ ha) have hCertificateEq {a b c d : BitVec 7} (hab : (a, b) ∈ disjointPairs) (hcd : (c, d) ∈ disjointPairs) (hu : a ||| b = c ||| d) : a = c ∧ b = d := by exact Prod.mk.inj (List.inj_on_of_nodup_map hCertificate hab hcd hu) have hBV (a b c d : BitVec 7) (ha : a ∈ masks) (hb : b ∈ masks) (hc : c ∈ masks) (hd : d ∈ masks) (hab : a &&& b = 0) (hcd : c &&& d = 0) (hu : a ||| b = c ||| d) : (a = c ∧ b = d) ∨ (a = d ∧ b = c) := by rcases lt_or_gt_of_ne (hNe ha hab) with habLt | habGt <;> rcases lt_or_gt_of_ne (hNe hc hcd) with hcdLt | hcdGt · exact Or.inl (hCertificateEq (hPair ha hb hab habLt) (hPair hc hd hcd hcdLt) hu) · exact Or.inr (hCertificateEq (hPair ha hb hab habLt) (hPair hd hc (by simpa only [BitVec.and_comm] using hcd) hcdGt) (by simpa only [BitVec.or_comm d c] using hu)) · have h := hCertificateEq (hPair hc hd hcd hcdLt) (hPair hb ha (by simpa only [BitVec.and_comm] using hab) habGt) (by simpa only [BitVec.or_comm b a] using hu.symm) exact Or.inr ⟨h.2.symm, h.1.symm⟩ · have h := hCertificateEq (hPair hb ha (by simpa only [BitVec.and_comm] using hab) habGt) (hPair hd hc (by simpa only [BitVec.and_comm] using hcd) hcdGt) (by simpa only [BitVec.or_comm b a, BitVec.or_comm d c] using hu) exact Or.inl ⟨h.2, h.1⟩ intro A hA B hB C hC D hD hAB hCD hU have hu := congrArg mask hU rw [hUnion, hUnion] at hu rcases hBV (mask A) (mask B) (mask C) (mask D) (hValid A hA) (hValid B hB) (hValid C hC) (hValid D hD) (hDisj hAB) (hDisj hCD) hu with h | h · exact Or.inl ⟨hInj h.1, hInj h.2⟩ · exact Or.inr ⟨hInj h.1, hInj h.2⟩ theorem residual_pair_counts_identity {α : Type} [DecidableEq α] (pairs : Finset α) (d g : α → ℕ) (edgeCount : ℕ) (hDegrees : ∑ p ∈ pairs, d p = 3 * edgeCount) (hCommon : ∑ p ∈ pairs, (d p).choose 2 = ∑ p ∈ pairs, g p) : let covered := pairs.filter (fun p => 0 < d p) let labels := pairs.filter (fun p => 0 < g p) let potential := ∑ p ∈ pairs, (d p - 2).choose 2 let deficit := (pairs.filter (fun p => d p = 1)).card + ∑ p ∈ labels, (3 - g p) let excess := ∑ p ∈ pairs, (g p - 3) 3 * (covered.card + labels.card) + excess = 6 * edgeCount + potential + deficit := by dsimp only have hId (m : ℕ) : m.choose 2 + (if 0 < m then 3 else 0) = 2 * m + (m - 2).choose 2 + (if m = 1 then 1 else 0) := by by_cases h : 2 ≤ m · obtain ⟨k, hk⟩ := Nat.exists_eq_add_of_le h have hk' : m = k + 2 := by omega have hPascal (k : ℕ) : (k + 1).choose 2 = k + k.choose 2 := by simpa only [Nat.choose_one_right] using Nat.choose_succ_succ' k 1 rw [hk', hPascal (k + 1), hPascal k] simp omega · interval_cases m <;> decide have hSupport := Finset.sum_congr (s₁ := pairs) rfl (fun p _ => hId (d p)) simp only [Finset.sum_add_distrib, ← Finset.mul_sum] at hSupport rw [← Finset.sum_filter, ← Finset.sum_filter, hCommon, hDegrees] at hSupport have hSupport' : (∑ p ∈ pairs, g p) + 3 * (pairs.filter (fun p => 0 < d p)).card = 2 * (3 * edgeCount) + (∑ p ∈ pairs, (d p - 2).choose 2) + (pairs.filter (fun p => d p = 1)).card := by simpa [Nat.mul_comm] using hSupport have hLabel (m : ℕ) : m + (if 0 < m then 3 - m else 0) = (if 0 < m then 3 else 0) + (m - 3) := by split_ifs <;> omega have hLabelSum := Finset.sum_congr (s₁ := pairs) rfl (fun p _ => hLabel (g p)) simp only [Finset.sum_add_distrib] at hLabelSum rw [← Finset.sum_filter, ← Finset.sum_filter] at hLabelSum have hLabelSum' : (∑ p ∈ pairs, g p) + (∑ p ∈ pairs.filter (fun p => 0 < g p), (3 - g p)) = 3 * (pairs.filter (fun p => 0 < g p)).card + ∑ p ∈ pairs, (g p - 3) := by simpa [Nat.mul_comm] using hLabelSum omega theorem residual_weighted_bound_of_excess_le {α : Type} [DecidableEq α] (pairs : Finset α) (d g : α → ℕ) (edgeCount : ℕ) (hDegrees : ∑ p ∈ pairs, d p = 3 * edgeCount) (hCommon : ∑ p ∈ pairs, (d p).choose 2 = ∑ p ∈ pairs, g p) (hExcess : 2 * (∑ p ∈ pairs, (g p - 3)) ≤ 2 * (∑ p ∈ pairs, (d p - 2).choose 2) + (pairs.filter (fun p => d p = 1)).card + ∑ p ∈ pairs.filter (fun p => 0 < g p), (3 - g p)) : let covered := pairs.filter (fun p => 0 < d p) let labels := pairs.filter (fun p => 0 < g p) let potential := ∑ p ∈ pairs, (d p - 2).choose 2 let deficit := (pairs.filter (fun p => d p = 1)).card + ∑ p ∈ labels, (3 - g p) let excess := ∑ p ∈ pairs, (g p - 3) 2 * edgeCount ≤ covered.card + labels.card ∧ 2 * edgeCount + (pairs \ labels).card ≤ 2 * pairs.card ∧ (2 * edgeCount = covered.card + labels.card → deficit = 0 ∧ excess = potential) := by dsimp only have hId := residual_pair_counts_identity pairs d g edgeCount hDegrees hCommon dsimp only at hId have hCovered : (pairs.filter (fun p => 0 < d p)).card ≤ pairs.card := Finset.card_filter_le _ _ have hLabels : (pairs \ pairs.filter (fun p => 0 < g p)).card = pairs.card - (pairs.filter (fun p => 0 < g p)).card := Finset.card_sdiff_of_subset (Finset.filter_subset _ _) have hLabelSub : (pairs.filter (fun p => 0 < g p)).card ≤ pairs.card := Finset.card_filter_le _ _ refine ⟨?_, ?_, fun hEq => ⟨?_, ?_⟩⟩ <;> omega def twoShadowPairDegree {n : ℕ} (edges : Finset (Finset (Fin n))) (p : Finset (Fin n)) : ℕ := (edges.filter (p ⊆ ·)).card def twoShadowCommonDegree {n : ℕ} (edges : Finset (Finset (Fin n))) (a b : Fin n) : ℕ := (edges.filter fun e => a ∈ e ∧ b ∉ e ∧ insert b (e.erase a) ∈ edges).card def twoShadowTripleWeight {n : ℕ} (edges : Finset (Finset (Fin n))) (e : Finset (Fin n)) : ℚ := ∑ a ∈ e, ((twoShadowPairDegree edges (e.erase a) : ℚ)⁻¹ + (1 / 2) * ∑ b ∈ Finset.univ \ e, if insert b (e.erase a) ∈ edges then (twoShadowCommonDegree edges a b : ℚ)⁻¹ else 0) def lowWeightEdges : Finset (Finset (Fin 24)) := {{0, 1, 2}, {0, 1, 3}, {0, 2, 13}, {0, 2, 14}, {0, 2, 15}, {0, 2, 16}, {0, 2, 17}, {0, 2, 18}, {0, 2, 19}, {0, 2, 20}, {0, 2, 21}, {0, 2, 22}, {0, 2, 23}, {0, 3, 23}, {1, 2, 3}, {1, 2, 4}, {1, 2, 5}, {1, 2, 6}, {1, 2, 7}, {1, 2, 8}, {1, 2, 9}, {1, 2, 10}, {1, 2, 11}, {1, 2, 12}, {2, 3, 13}, {2, 3, 14}, {2, 3, 15}, {2, 3, 16}, {2, 3, 17}, {2, 3, 18}, {2, 3, 19}, {2, 3, 20}, {2, 3, 21}, {2, 3, 22}, {2, 3, 23}, {2, 4, 13}, {2, 4, 14}, {2, 4, 15}, {2, 4, 16}, {2, 4, 17}, {2, 4, 18}, {2, 4, 19}, {2, 4, 20}, {2, 4, 21}, {2, 4, 22}, {2, 5, 13}, {2, 5, 14}, {2, 5, 15}, {2, 5, 16}, {2, 5, 17}, {2, 5, 18}, {2, 5, 19}, {2, 5, 20}, {2, 5, 21}, {2, 5, 22}, {2, 6, 13}, {2, 6, 14}, {2, 6, 15}, {2, 6, 16}, {2, 6, 17}, {2, 6, 18}, {2, 6, 19}, {2, 6, 20}, {2, 6, 21}, {2, 6, 22}, {2, 7, 13}, {2, 7, 14}, {2, 7, 15}, {2, 7, 16}, {2, 7, 17}, {2, 7, 18}, {2, 7, 19}, {2, 7, 20}, {2, 7, 21}, {2, 7, 22}, {2, 8, 13}, {2, 8, 14}, {2, 8, 15}, {2, 8, 16}, {2, 8, 17}, {2, 8, 18}, {2, 8, 19}, {2, 8, 20}, {2, 8, 21}, {2, 8, 22}, {2, 9, 13}, {2, 9, 14}, {2, 9, 15}, {2, 9, 16}, {2, 9, 17}, {2, 9, 18}, {2, 9, 19}, {2, 9, 20}, {2, 9, 21}, {2, 9, 22}, {2, 10, 13}, {2, 10, 14}, {2, 10, 15}, {2, 10, 16}, {2, 10, 17}, {2, 10, 18}, {2, 10, 19}, {2, 10, 20}, {2, 10, 21}, {2, 10, 22}, {2, 11, 13}, {2, 11, 14}, {2, 11, 15}, {2, 11, 16}, {2, 11, 17}, {2, 11, 18}, {2, 11, 19}, {2, 11, 20}, {2, 11, 21}, {2, 11, 22}, {2, 12, 13}, {2, 12, 14}, {2, 12, 15}, {2, 12, 16}, {2, 12, 17}, {2, 12, 18}, {2, 12, 19}, {2, 12, 20}, {2, 12, 21}, {2, 12, 22}} theorem low_weight_edge_uniform : ∀ e ∈ lowWeightEdges, e.card = 3 := by set_option maxRecDepth 4096 in set_option maxHeartbeats 0 in first | simp only [lowWeightEdges, Finset.forall_mem_insert, Finset.mem_singleton, forall_eq] repeat' apply And.intro all_goals decide +kernel theorem low_weight_edge_weight : twoShadowTripleWeight lowWeightEdges ({0, 1, 2} : Finset (Fin 24)) = 527 / 264 := by set_option maxRecDepth 4096 in set_option maxHeartbeats 0 in first | set_option maxHeartbeats 0 in decide +kernel theorem low_weight_edge_mem : ({0, 1, 2} : Finset (Fin 24)) ∈ lowWeightEdges := by set_option maxRecDepth 4096 in set_option maxHeartbeats 0 in first | decide +kernel def weightVertexMask {n : ℕ} (e : Finset (Fin n)) : BitVec n := (BitVec.ofBoolListLE ((List.finRange n).map fun v => decide (v ∈ e))).cast (by simp) def weightDisjointMaskPairs {n : ℕ} (masks : List (BitVec n)) : List (BitVec n × BitVec n) := masks.flatMap fun a => (masks.filter fun b => decide (a.toNat < b.toNat) && (a &&& b == 0)).map (fun b => (a, b)) def weightUnionMask {n : ℕ} (p : BitVec n × BitVec n) : BitVec n := p.1 ||| p.2 def weightDisjointPairsBucket {n : ℕ} (masks : List (BitVec n)) (i : Fin 7) : List (BitVec n × BitVec n) := (weightDisjointMaskPairs masks).filter (fun p => decide ((weightUnionMask p).toNat % 7 = i.val)) theorem unique_disjoint_unions_of_weight_mask_certificate {n : ℕ} {edges : Finset (Finset (Fin n))} {masks : List (BitVec n)} (hValid : ∀ e ∈ edges, weightVertexMask e ∈ masks) (hNonzero : (0 : BitVec n) ∉ masks) (hBucket : ∀ i : Fin 7, ((weightDisjointPairsBucket masks i).map weightUnionMask).Nodup) : UniqueDisjointUnions edges := by have hMask (e : Finset (Fin n)) (i : Fin n) : (weightVertexMask e).getLsbD i = decide (i ∈ e) := by unfold weightVertexMask rw [BitVec.getLsbD_cast, BitVec.getLsbD_ofBoolListLE] simp [List.getD_eq_getElem?_getD, i.isLt] have hInj : Function.Injective (weightVertexMask (n := n)) := by intro e f h ext v exact decide_eq_decide.mp (by rw [← hMask, ← hMask, h]) have hUnion (e f : Finset (Fin n)) : weightVertexMask (e ∪ f) = weightVertexMask e ||| weightVertexMask f := by apply BitVec.eq_of_getLsbD_eq intro i hi let v : Fin n := ⟨i, hi⟩ change (weightVertexMask (e ∪ f)).getLsbD v = (weightVertexMask e ||| weightVertexMask f).getLsbD v rw [BitVec.getLsbD_or, hMask, hMask, hMask] simp have hDisj {e f : Finset (Fin n)} (h : Disjoint e f) : weightVertexMask e &&& weightVertexMask f = 0 := by apply BitVec.eq_of_getLsbD_eq intro i hi let v : Fin n := ⟨i, hi⟩ change (weightVertexMask e &&& weightVertexMask f).getLsbD v = (0 : BitVec n).getLsbD v rw [BitVec.getLsbD_and, hMask, hMask] by_cases he : v ∈ e · have hf : v ∉ f := fun hf => Finset.disjoint_left.mp h he hf simp [he, hf] · simp [he] have hPair {a b : BitVec n} (ha : a ∈ masks) (hb : b ∈ masks) (hab : a &&& b = 0) (hlt : a.toNat < b.toNat) : (a, b) ∈ weightDisjointMaskPairs masks := by unfold weightDisjointMaskPairs refine List.mem_flatMap.mpr ⟨a, ha, List.mem_map.mpr ⟨b, ?_, rfl⟩⟩ exact List.mem_filter.mpr ⟨hb, by simp [hlt, hab]⟩ have hNe {a b : BitVec n} (ha : a ∈ masks) (hab : a &&& b = 0) : a.toNat ≠ b.toNat := by intro heq have he := BitVec.eq_of_toNat_eq heq subst b have hz : a = 0 := by simpa using hab exact hNonzero (hz ▸ ha) have hCertificateEq {a b c d : BitVec n} (hab : (a, b) ∈ weightDisjointMaskPairs masks) (hcd : (c, d) ∈ weightDisjointMaskPairs masks) (hu : a ||| b = c ||| d) : a = c ∧ b = d := by let i : Fin 7 := ⟨(a ||| b).toNat % 7, Nat.mod_lt _ (by decide)⟩ have hb₁ : (a,b) ∈ weightDisjointPairsBucket masks i := List.mem_filter.mpr ⟨hab, by simp [weightUnionMask, i]⟩ have hb₂ : (c,d) ∈ weightDisjointPairsBucket masks i := List.mem_filter.mpr ⟨hcd, by simp [weightUnionMask, i, hu]⟩ exact Prod.mk.inj (List.inj_on_of_nodup_map (hBucket i) hb₁ hb₂ hu) have hBV (a b c d : BitVec n) (ha : a ∈ masks) (hb : b ∈ masks) (hc : c ∈ masks) (hd : d ∈ masks) (hab : a &&& b = 0) (hcd : c &&& d = 0) (hu : a ||| b = c ||| d) : (a = c ∧ b = d) ∨ (a = d ∧ b = c) := by rcases lt_or_gt_of_ne (hNe ha hab) with habLt | habGt <;> rcases lt_or_gt_of_ne (hNe hc hcd) with hcdLt | hcdGt · exact Or.inl (hCertificateEq (hPair ha hb hab habLt) (hPair hc hd hcd hcdLt) hu) · exact Or.inr (hCertificateEq (hPair ha hb hab habLt) (hPair hd hc (by simpa only [BitVec.and_comm] using hcd) hcdGt) (by simpa only [BitVec.or_comm d c] using hu)) · have h := hCertificateEq (hPair hc hd hcd hcdLt) (hPair hb ha (by simpa only [BitVec.and_comm] using hab) habGt) (by simpa only [BitVec.or_comm b a] using hu.symm) exact Or.inr ⟨h.2.symm, h.1.symm⟩ · have h := hCertificateEq (hPair hb ha (by simpa only [BitVec.and_comm] using hab) habGt) (hPair hd hc (by simpa only [BitVec.and_comm] using hcd) hcdGt) (by simpa only [BitVec.or_comm b a, BitVec.or_comm d c] using hu) exact Or.inl ⟨h.2, h.1⟩ intro A hA B hB C hC D hD hAB hCD hU have hu := congrArg weightVertexMask hU rw [hUnion, hUnion] at hu rcases hBV (weightVertexMask A) (weightVertexMask B) (weightVertexMask C) (weightVertexMask D) (hValid A hA) (hValid B hB) (hValid C hC) (hValid D hD) (hDisj hAB) (hDisj hCD) hu with h | h · exact Or.inl ⟨hInj h.1, hInj h.2⟩ · exact Or.inr ⟨hInj h.1, hInj h.2⟩ def lowWeightMasks : List (BitVec 24) := [7, 11, 8197, 16389, 32773, 65541, 131077, 262149, 524293, 1048581, 2097157, 4194309, 8388613, 8388617, 14, 22, 38, 70, 134, 262, 518, 1030, 2054, 4102, 8204, 16396, 32780, 65548, 131084, 262156, 524300, 1048588, 2097164, 4194316, 8388620, 8212, 16404, 32788, 65556, 131092, 262164, 524308, 1048596, 2097172, 4194324, 8228, 16420, 32804, 65572, 131108, 262180, 524324, 1048612, 2097188, 4194340, 8260, 16452, 32836, 65604, 131140, 262212, 524356, 1048644, 2097220, 4194372, 8324, 16516, 32900, 65668, 131204, 262276, 524420, 1048708, 2097284, 4194436, 8452, 16644, 33028, 65796, 131332, 262404, 524548, 1048836, 2097412, 4194564, 8708, 16900, 33284, 66052, 131588, 262660, 524804, 1049092, 2097668, 4194820, 9220, 17412, 33796, 66564, 132100, 263172, 525316, 1049604, 2098180, 4195332, 10244, 18436, 34820, 67588, 133124, 264196, 526340, 1050628, 2099204, 4196356, 12292, 20484, 36868, 69636, 135172, 266244, 528388, 1052676, 2101252, 4198404] theorem low_weight_mask_coverage : ∀ e ∈ lowWeightEdges, weightVertexMask e ∈ lowWeightMasks := by set_option maxRecDepth 4096 in set_option maxHeartbeats 0 in first | simp only [lowWeightEdges, Finset.forall_mem_insert, Finset.mem_singleton, forall_eq] repeat' apply And.intro all_goals decide +kernel theorem low_weight_mask_certificate : ∀ i : Fin 7, ((weightDisjointPairsBucket lowWeightMasks i).map weightUnionMask).Nodup := by set_option maxRecDepth 4096 in set_option maxHeartbeats 0 in first | intro i fin_cases i all_goals decide +kernel theorem low_weight_edge_unique : UniqueDisjointUnions lowWeightEdges := by apply unique_disjoint_unions_of_weight_mask_certificate low_weight_mask_coverage · decide +kernel · exact low_weight_mask_certificate theorem two_shadow_pointwise_counterexample : ∃ (edges : Finset (Finset (Fin 24))) (e : Finset (Fin 24)), (∀ f ∈ edges, f.card = 3) ∧ UniqueDisjointUnions edges ∧ e ∈ edges ∧ twoShadowTripleWeight edges e < 2 := by set_option maxRecDepth 4096 in set_option maxHeartbeats 0 in first | refine ⟨lowWeightEdges, _, low_weight_edge_uniform, low_weight_edge_unique, low_weight_edge_mem, ?_⟩ rw [low_weight_edge_weight] norm_num theorem local_five_tokens_le_positive_deficits {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 5) : let P := (Finset.univ : Finset (Fin n)).powersetCard 2 (localFiveTokens edges).card ≤ 4 * (({p ∈ P | (localExtensions edges p).card = 1}).card + ∑ p ∈ P.filter (fun p => 0 < (localCoExtensions edges p).card), (3 - (localCoExtensions edges p).card)) := by have local_five_charge_true_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 5) (p : Finset (Fin n)) (hp : p.card = 2) : ((localFiveTokens edges).filter (fun q => localFourCharge edges q = (true,p))).card ≤ 4 * (3 - (localCoExtensions edges p).card) := by have local_five_charge_true_size_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 5) {x a t : Fin n} {b : Fin 2} {p : Finset (Fin n)} (htok : ((x,a),(t,b)) ∈ localFiveTokens edges) (h : localFourCharge edges ((x,a),(t,b)) = (true,p)) : (localCoExtensions edges p).card + (localFiveContainmentClass edges x a).card ≤ 6 := by obtain ⟨hxa,h4,hk,ht,hb⟩ := local_five_token_mem.mp htok obtain ⟨hxy,heq,hG⟩ := local_five_charge_true_spec htok h rw [← heq] at hG ⊢ have ha : a ∈ localFiveContainmentClass edges x a := local_mem_five_twin_class.mpr ⟨hxa,Finset.Subset.rfl⟩ have hB := local_containment_biclique_cross_bound hu (A := localFiveContainmentClass edges x a) (by omega) (by omega : 3 ≤ (localExtensions edges {x,a}).card) (fun h => (local_mem_five_twin_class.mp h).1 rfl) (fun _ h => (local_mem_five_twin_class.mp h).2) ha rfl ht hxy hG have hD := hd x t (local_five_token_pair_data htok).2.1 omega classical let S := (localFiveTokens edges).filter (fun q => localFourCharge edges q = (true,p)) let G := localCoExtensions edges p let O := (localOrderedPairs n).filter (fun q => localUnderlyingPair q = p) have hoc : O.card = 2 := local_orderings_two hp by_cases he : S = ∅ · simp [show {q ∈ localFiveTokens edges | localFourCharge edges q = (true,p)} = S from rfl,he] obtain ⟨q,hq⟩ := Finset.nonempty_iff_ne_empty.mpr he obtain ⟨⟨x,a⟩,⟨t,b⟩⟩ := q obtain ⟨htok,hch⟩ := Finset.mem_filter.mp hq have ⟨_,_,hG⟩ := local_five_charge_true_spec htok hch have hs := local_five_charge_true_size_bound hu hd htok hch have hk := (local_five_token_mem.mp htok).2.2.1 have hpos : 0 < G.card := Finset.card_pos.mpr ⟨_,hG⟩ have hcap : G.card ≤ 2 := by change (localCoExtensions edges p).card ≤ 2; omega by_cases hG1 : G.card = 1 · have hG_eq : G = {({a,t} : Finset (Fin n))} := by apply (Finset.eq_of_subset_of_card_le (show ({({a,t} : Finset (Fin n))} : Finset _) ⊆ G by simpa only [Finset.singleton_subset_iff] using hG) ?_).symm rw [hG1,Finset.card_singleton] let R := (localOrderedPairs n).filter (fun q => localUnderlyingPair q = {a,t}) have hR : R.card = 2 := local_orderings_two (local_mem_coextensions.mp hG).1 have hprod : (O ×ˢ (R ×ˢ (Finset.univ : Finset (Fin 2)))).card = 8 := by simp [Finset.card_product,hoc,hR] have hlim : 4 * (3 - (localCoExtensions edges p).card) = 8 := by change 4 * (3 - G.card) = 8 rw [hG1] rw [hlim, ← hprod] apply Finset.card_le_card_of_injOn (fun q => ((q.1.1,localFourNext edges q.1.1 q.1.2 q.2.1),((q.1.2,q.2.1),q.2.2))) · rintro ⟨⟨u,c⟩,⟨v,d⟩⟩ h change ((u,c),(v,d)) ∈ S at h obtain ⟨htok',hch'⟩ := Finset.mem_filter.mp h obtain ⟨hUN,heq,hP⟩ := local_five_charge_true_spec htok' hch' have hv : c ≠ v := (local_five_token_pair_data htok').1 have heq' : {c,v} = ({a,t} : Finset (Fin n)) := by change ({c,v} : Finset (Fin n)) ∈ G at hP rwa [hG_eq,Finset.mem_singleton] at hP exact Finset.mem_product.mpr ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hUN,heq⟩,Finset.mem_product.mpr ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hv,heq'⟩,Finset.mem_univ _⟩⟩ · intro u hu' v hv' he' apply Prod.ext · apply Prod.ext · exact congrArg (fun z : (Fin n × Fin n) × ((Fin n × Fin n) × Fin 2) => z.1.1) he' · exact congrArg (fun z : (Fin n × Fin n) × ((Fin n × Fin n) × Fin 2) => z.2.1.1) he' · exact congrArg (fun z : (Fin n × Fin n) × ((Fin n × Fin n) × Fin 2) => (z.2.1.2,z.2.2)) he' · have hG2 : G.card = 2 := by omega have hprod : (O ×ˢ G).card = 4 := by simp [Finset.card_product,hoc,hG2] have hlim : 4 * (3 - (localCoExtensions edges p).card) = 4 := by change 4 * (3 - G.card) = 4 rw [hG2] rw [hlim,← hprod] apply Finset.card_le_card_of_injOn (fun q => ((q.1.1,localFourNext edges q.1.1 q.1.2 q.2.1),localUnderlyingPair (q.1.2,q.2.1))) · rintro ⟨⟨u,c⟩,⟨v,d⟩⟩ h change ((u,c),(v,d)) ∈ S at h obtain ⟨htok',hch'⟩ := Finset.mem_filter.mp h obtain ⟨hUN,heq,hP⟩ := local_five_charge_true_spec htok' hch' exact Finset.mem_product.mpr ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hUN,heq⟩,hP⟩ · rintro ⟨⟨u,c⟩,⟨v,d⟩⟩ h ⟨⟨u',c'⟩,⟨v',d'⟩⟩ h' he' change ((u,c),(v,d)) ∈ S at h change ((u',c'),(v',d')) ∈ S at h' simp only [Prod.mk.injEq] at he' obtain ⟨⟨huu',hNext⟩,hpairs⟩ := he' subst u' change ({c,v} : Finset (Fin n)) = {c',v'} at hpairs obtain ⟨htok',hch'⟩ := Finset.mem_filter.mp h obtain ⟨htok'',hch''⟩ := Finset.mem_filter.mp h' have hs1 := local_five_charge_true_size_bound hu hd htok' hch' have hs2 := local_five_charge_true_size_bound hu hd htok'' hch'' have hG2' : (localCoExtensions edges p).card = 2 := hG2 obtain ⟨huc,h4',hk',hvN,hd'⟩ := local_five_token_mem.mp htok' obtain ⟨huc',h4'',hk'',hvN',hd''⟩ := local_five_token_mem.mp htok'' have hd0 : d = 0 := by simpa [localFiveSlots,show (localFiveContainmentClass edges u c).card ≠ 5 by omega] using hd' have hd0' : d' = 0 := by simpa [localFiveSlots,show (localFiveContainmentClass edges u c').card ≠ 5 by omega] using hd'' subst d subst d' have hcv := (local_five_token_pair_data htok').1 have hcv' := (local_five_token_pair_data htok'').1 have hcMem : c ∈ ({c',v'} : Finset (Fin n)) := hpairs ▸ Finset.mem_insert_self c {v} have hvMem : v ∈ ({c',v'} : Finset (Fin n)) := hpairs ▸ Finset.mem_insert_of_mem (Finset.mem_singleton_self v) simp only [Finset.mem_insert,Finset.mem_singleton] at hcMem hvMem rcases hcMem with e | e <;> rcases hvMem with e' | e' · exact (hcv (e.trans e'.symm)).elim · cases e cases e' rfl · subst v' subst c' obtain ⟨huNext,hEq,hP⟩ := local_five_charge_true_spec htok' hch' let y := localFourNext edges u c v change u ≠ y at huNext have hP' : ({c,v} : Finset (Fin n)) ∈ G := hP have hmore : ¬ G ⊆ {({c,v} : Finset (Fin n))} := by intro h have hh := Finset.card_le_card h rw [hG2,Finset.card_singleton] at hh omega obtain ⟨q₀,hq₀,hne⟩ := Finset.not_subset.mp hmore rw [Finset.mem_singleton] at hne have hPxy : {c,v} ∈ localCoExtensions edges {u,y} := hEq.symm ▸ hP have hqxy : q₀ ∈ localCoExtensions edges {u,y} := hEq.symm ▸ hq₀ obtain ⟨w,hw,hqw⟩ := Finset.not_disjoint_iff.mp (local_coextension_pairwise hu (by simp [huNext]) hPxy hqxy) simp only [Finset.mem_insert,Finset.mem_singleton] at hw exfalso rcases hw with e | e · subst w obtain ⟨z,hzc,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hqxy).1 hqw have hvz : v ≠ z := fun h => hne (h ▸ rfl) exact local_containment_biclique_cross_no_move hu (A := localFiveContainmentClass edges u c) (by omega) (fun h => (local_mem_five_twin_class.mp h).1 rfl) (fun _ h => (local_mem_five_twin_class.mp h).2) (local_mem_five_twin_class.mpr ⟨huc,Finset.Subset.rfl⟩) rfl hvN huNext hvz hPxy hqxy · subst w obtain ⟨z,hzv,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hqxy).1 hqw have hcz : c ≠ z := fun h => hne (h ▸ Finset.pair_comm _ _) rw [Finset.pair_comm c v] at hPxy exact local_containment_biclique_cross_no_move hu (A := localFiveContainmentClass edges u v) (by omega) (fun h => (local_mem_five_twin_class.mp h).1 rfl) (fun _ h => (local_mem_five_twin_class.mp h).2) (local_mem_five_twin_class.mpr ⟨huc',Finset.Subset.rfl⟩) rfl hvN' huNext hcz hPxy hqxy · exact (hcv (e.trans e'.symm)).elim have local_five_charge_false_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (p : Finset (Fin n)) (hp : p.card = 2) : ((localFiveTokens edges).filter (fun q => localFourCharge edges q = (false,p))).card ≤ 4 * (if (localExtensions edges p).card = 1 then 1 else 0) := by have local_five_charge_false_spec {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} {b : Fin 2} {p : Finset (Fin n)} (h : localFourCharge edges ((x,a),(t,b)) = (false,p)) : (localExtensions edges {a,t}).card = 1 ∧ {a,t} = p := by unfold localFourCharge at h split at h · exact ⟨by assumption,(Prod.mk.inj h).2⟩ · exact Bool.noConfusion (Prod.mk.inj h).1 classical let S := (localFiveTokens edges).filter (fun q => localFourCharge edges q = (false,p)) by_cases hd : (localExtensions edges p).card = 1 · simp only [hd,if_true,mul_one] let O := (localOrderedPairs n).filter (fun q => localUnderlyingPair q = p) have hc : (O ×ˢ (Finset.univ : Finset (Fin 2))).card = 4 := by rw [Finset.card_product,local_orderings_two hp] decide rw [← hc] apply Finset.card_le_card_of_injOn (fun q => ((q.1.2,q.2.1),q.2.2)) · rintro ⟨⟨x,a⟩,⟨t,b⟩⟩ h change ((x,a),(t,b)) ∈ S at h obtain ⟨htok,hch⟩ := Finset.mem_filter.mp h have hh := local_five_charge_false_spec hch have hp' := local_five_token_pair_data htok apply Finset.mem_product.mpr exact ⟨Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr hp'.1, hh.2⟩, Finset.mem_univ _⟩ · rintro ⟨⟨x,a⟩,⟨t,b⟩⟩ h ⟨⟨y,c⟩,⟨u,d⟩⟩ h' heq change ((x,a),(t,b)) ∈ S at h change ((y,c),(u,d)) ∈ S at h' simp only [Prod.mk.injEq] at heq rcases heq with ⟨⟨rfl,rfl⟩,rfl⟩ obtain ⟨htok,hch⟩ := Finset.mem_filter.mp h obtain ⟨htok',hch'⟩ := Finset.mem_filter.mp h' have ⟨h1,_⟩ := local_five_charge_false_spec hch have hx := (local_five_token_pair_data htok).2.2 have hy := (local_five_token_pair_data htok').2.2 have hxy := Finset.card_le_one.mp (by omega : (localExtensions edges {a,t}).card ≤ 1) _ hx _ hy cases hxy rfl · simp only [hd,if_false,Nat.mul_zero] apply Nat.le_of_eq apply Finset.card_eq_zero.mpr apply Finset.eq_empty_iff_forall_notMem.mpr intro q h obtain ⟨⟨x,a⟩,⟨t,b⟩⟩ := q have hh := local_five_charge_false_spec (Finset.mem_filter.mp h).2 exact hd (hh.2 ▸ hh.1) have local_four_next_spec {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} (hx : x ∈ localExtensions edges {a,t}) (h : (localExtensions edges {a,t}).card ≠ 1) : localFourNext edges x a t ∈ localExtensions edges {a,t} ∧ x ≠ localFourNext edges x a t := by classical have hex : ∃ y ∈ localExtensions edges {a,t}, x ≠ y := by by_contra hn push Not at hn have heq : localExtensions edges {a,t} = {x} := by ext z rw [Finset.mem_singleton] exact ⟨fun hz => (hn z hz).symm,fun hz => hz ▸ hx⟩ simp [heq] at h simpa only [localFourNext,dif_pos hex] using Classical.choose_spec hex classical dsimp only let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let Q := (Finset.univ : Finset Bool) ×ˢ P let cap := fun q : Bool × Finset (Fin n) => if q.1 then 4 * (if 0 < (localCoExtensions edges q.2).card then 3 - (localCoExtensions edges q.2).card else 0) else 4 * (if (localExtensions edges q.2).card = 1 then 1 else 0) let S := localFiveTokens edges have hmap : ∀ tok ∈ S, localFourCharge edges tok ∈ Q := by rintro ⟨⟨x,a⟩,⟨t,b⟩⟩ htok obtain ⟨hat,_,hx⟩ := local_five_token_pair_data htok apply Finset.mem_product.mpr refine ⟨Finset.mem_univ _,?_⟩ unfold localFourCharge split · simp [P,hat] · rename_i hne have hy := (local_four_next_spec hx hne).2 simp [P,hy] have hsum : S.card = ∑ q ∈ Q, ((S.filter (fun tok => localFourCharge edges tok = q)).card) := by simpa only [Finset.sum_const, nsmul_eq_mul, Nat.cast_id, mul_one] using (Finset.sum_fiberwise_of_maps_to hmap (fun _ => (1 : ℕ))).symm have hle : S.card ≤ ∑ q ∈ Q, cap q := by rw [hsum] apply Finset.sum_le_sum rintro ⟨flag,p⟩ hp obtain ⟨_,hpa⟩ := Finset.mem_product.mp hp have hpc := (Finset.mem_powersetCard.mp hpa).2 cases flag · exact local_five_charge_false_bound p hpc · by_cases hpos : 0 < (localCoExtensions edges p).card · simpa only [cap, if_true, hpos] using local_five_charge_true_bound hu hd p hpc · simp only [cap, if_true, hpos, if_false, Nat.mul_zero] apply Nat.le_of_eq apply Finset.card_eq_zero.mpr apply Finset.eq_empty_iff_forall_notMem.mpr rintro ⟨⟨x,a⟩,⟨t,b⟩⟩ h obtain ⟨htok,hch⟩ := Finset.mem_filter.mp h obtain ⟨_,_,hG⟩ := local_five_charge_true_spec htok hch exact hpos (Finset.card_pos.mpr ⟨_,hG⟩) refine hle.trans_eq ?_ rw [Finset.sum_product] simp only [show (Finset.univ : Finset Bool) = {false,true} by decide, Finset.sum_insert (by decide : false ∉ ({true} : Finset Bool)), Finset.sum_singleton, cap, Bool.false_eq_true, if_false, if_true, ← Finset.mul_sum, ← Finset.card_filter, ← Nat.mul_add] rw [Finset.sum_filter] theorem local_five_refined_bonus_sum {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 5) : ∑ p ∈ localOrderedPairs n, localFiveBonus edges p.1 p.2 ≤ ({p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2 | (localExtensions edges p).card = 1}).card + ∑ p ∈ ((Finset.univ : Finset (Fin n)).powersetCard 2).filter (fun p => 0 < (localCoExtensions edges p).card), (3 - (localCoExtensions edges p).card) := by have local_five_twin_class_card_le {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 5) {x a : Fin n} (h4 : 0 < (localExtensions edges {x,a}).card) : (localFiveContainmentClass edges x a).card ≤ 5 := by obtain ⟨t,ht⟩ := Finset.card_pos.mp (show 0 < (localExtensions edges {x,a}).card by omega) have hx : x ≠ t := (local_neighbors_ne ht).1.symm have hsub : localFiveContainmentClass edges x a ⊆ localExtensions edges {x,t} := by intro b hb obtain ⟨hxb,hb⟩ := local_mem_five_twin_class.mp hb exact local_neighbors_symm hxb (hb ht) exact (Finset.card_le_card hsub).trans (hd _ _ hx) classical let O := localOrderedPairs n let F := localFiveFatPairs edges let K := F.filter (fun p => 4 ≤ (localFiveContainmentClass edges p.1 p.2).card) let f := fun (p : Fin n × Fin n) => (localExtensions edges (localUnderlyingPair p)).card * (localFiveSlots (localFiveContainmentClass edges p.1 p.2).card).card have htok : (localFiveTokens edges).card = ∑ p ∈ K, f p := by simp only [localFiveTokens,Finset.card_map,Finset.card_sigma,Finset.card_product] rfl have h : 4 * (∑ p ∈ O, localFiveBonus edges p.1 p.2) ≤ (localFiveTokens edges).card := by rw [htok,Finset.mul_sum] have hs : ∑ p ∈ K, f p = ∑ p ∈ O, if 4 ≤ (localExtensions edges (localUnderlyingPair p)).card ∧ 4 ≤ (localFiveContainmentClass edges p.1 p.2).card then f p else 0 := by simpa only [K,F,localFiveFatPairs,Finset.filter_filter,Finset.sum_filter,and_comm,O] rw [hs] apply Finset.sum_le_sum intro p hp obtain ⟨x,a⟩ := p have hxa := local_mem_ordered_pairs.mp hp let d := (localExtensions edges {x,a}).card let k := (localFiveContainmentClass edges x a).card change 4 * localFiveBonus edges x a ≤ if 4 ≤ d ∧ 4 ≤ k then d * (localFiveSlots k).card else 0 by_cases hD : 4 ≤ d · have hK : k ≤ 5 := local_five_twin_class_card_le hd (by omega : 0 < d) change 4 * (if 4 ≤ d then k - 3 else 0) ≤ _ rw [if_pos hD] by_cases hk4 : 4 ≤ k · rw [if_pos (And.intro hD hk4)] by_cases hk5 : k = 5 · rw [hk5] simp [localFiveSlots] omega · have hk : k = 4 := by omega rw [hk] simp [localFiveSlots] omega · rw [if_neg (fun h => hk4 h.2)] omega · simp [localFiveBonus,show ¬4 ≤ (localExtensions edges {x,a}).card from hD,hD] have hc := local_five_tokens_le_positive_deficits hu hd dsimp only at hc change ∑ p ∈ O, localFiveBonus edges p.1 p.2 ≤ _ omega theorem local_five_refined_excess_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ (x a : Fin n), x ≠ a → (localExtensions edges {x, a}).card ≤ 5) : let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let d := fun p => (localExtensions edges p).card let g := fun p => (localCoExtensions edges p).card 2 * (∑ p ∈ P, (g p - 3)) ≤ 2 * (∑ p ∈ P, (d p - 2).choose 2) + (P.filter (fun p => d p = 1)).card + ∑ p ∈ P.filter (fun p => 0 < g p), (3 - g p) := by classical dsimp only let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let O := localOrderedPairs n let d := fun p => (localExtensions edges p).card let g := fun p => (localCoExtensions edges p).card let f := fun (p : Fin n × Fin n) => localFiveScore edges p.1 p.2 let b := fun (p : Fin n × Fin n) => localFiveBonus edges p.1 p.2 let U := ∑ p ∈ P, localFivePotential (d p) have hL : 2 * (∑ p ∈ P, (g p - 3)) ≤ ∑ p ∈ O, f p := local_five_score_sum_lower hu have hB : ∑ p ∈ O, b p ≤ (P.filter (fun p => d p = 1)).card + ∑ p ∈ P.filter (fun p => 0 < g p), (3 - g p) := local_five_refined_bonus_sum hu hd have sum_swap (v : (Fin n × Fin n) → ℕ) : ∑ p ∈ O, v p.swap = ∑ p ∈ O, v p := by refine Finset.sum_nbij Prod.swap ?_ ?_ ?_ (fun _ _ => rfl) · intro p hp exact local_mem_ordered_pairs.mpr (local_mem_ordered_pairs.mp hp).symm · intro p hp q hq hpq exact congrArg Prod.swap hpq · intro p hp exact ⟨p.swap, local_mem_ordered_pairs.mpr (local_mem_ordered_pairs.mp hp).symm, rfl⟩ have hpoint : ∀ p ∈ O, f p + f p.swap ≤ 2 * localFivePotential (d (localUnderlyingPair p)) + b p + b p.swap := by intro p hp exact local_five_pointwise_score_bound hu hd (local_mem_ordered_pairs.mp hp) have hsum := Finset.sum_le_sum hpoint simp only [Finset.sum_add_distrib, ← Finset.mul_sum, sum_swap] at hsum have hU : ∑ p ∈ O, localFivePotential (d (localUnderlyingPair p)) = 2 * U := local_five_ordered_pair_sum (fun p => localFivePotential (d p)) rw [hU] at hsum have hPotential : U = ∑ p ∈ P, (d p - 2).choose 2 := by apply Finset.sum_congr rfl intro p hp obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp (Finset.mem_powersetCard.mp hp).2 have hCap : d {a,b} ≤ 5 := hd a b hab interval_cases h : d {a,b} <;> decide rw [hPotential] at hsum change 2 * (∑ p ∈ P, (g p - 3)) ≤ 2 * (∑ p ∈ P, (d p - 2).choose 2) + (P.filter (fun p => d p = 1)).card + ∑ p ∈ P.filter (fun p => 0 < g p), (3 - g p) omega theorem residual_triple_bound_of_codegrees_le_five {n : ℕ} (edges available : Finset (Finset (Fin n))) (hu : UniqueDisjointUnions edges) (hUniform : ∀ e ∈ edges, e.card = 3) (hd : ∀ (x a : Fin n), x ≠ a → (localExtensions edges {x, a}).card ≤ 5) (hCovered : ∀ p : Finset (Fin n), p.card = 2 → 0 < (localExtensions edges p).card → p ∈ available) (hLabels : ∀ p : Finset (Fin n), p.card = 2 → 0 < (localCoExtensions edges p).card → p ∈ available) : let emptyLabels := available.filter (fun p => (localCoExtensions edges p).card = 0) 2 * edges.card + emptyLabels.card ≤ 2 * available.card := by classical dsimp only let P := (Finset.univ : Finset (Fin n)).powersetCard 2 have hPairs (p : Finset (Fin n)) (hp : p ∈ P) : p.card = 2 := (Finset.mem_powersetCard.mp hp).2 have hCoveredAll (e : Finset (Fin n)) (_ : e ∈ edges) : e.powersetCard 2 ⊆ P := by intro p hp exact Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _, (Finset.mem_powersetCard.mp hp).2⟩ have hCodegree (p : Finset (Fin n)) (hp : p ∈ P) : (localExtensions edges p).card = (edges.filter (fun e => p ⊆ e)).card := by refine Finset.card_bij (fun x _ => insert x p) ?_ ?_ ?_ · intro x hx exact Finset.mem_filter.mpr ⟨(Finset.mem_filter.mp hx).2.2, Finset.subset_insert _ _⟩ · intro x hx y _ h exact (Finset.mem_insert.mp (h ▸ Finset.mem_insert_self x p)).resolve_right (Finset.mem_filter.mp hx).2.1 · intro e he obtain ⟨hee, hpe⟩ := Finset.mem_filter.mp he have hdiff : (e \ p).card = 1 := by rw [Finset.card_sdiff_of_subset hpe, hUniform e hee, hPairs p hp] obtain ⟨x, hx⟩ := Finset.card_pos.mp (by omega : 0 < (e \ p).card) obtain ⟨hxe, hxp⟩ := Finset.mem_sdiff.mp hx have hxeq : insert x p = e := Finset.eq_of_subset_of_card_le (Finset.insert_subset_iff.mpr ⟨hxe, hpe⟩) (by rw [Finset.card_insert_of_notMem hxp, hPairs p hp, hUniform e hee]) exact ⟨x, Finset.mem_filter.mpr ⟨Finset.mem_univ _, hxp, hxeq ▸ hee⟩, hxeq⟩ have hTotal : ∑ p ∈ P, (localExtensions edges p).card = 3 * edges.card := calc ∑ p ∈ P, (localExtensions edges p).card = ∑ p ∈ P, ∑ e ∈ edges, if p ⊆ e then (1 : ℕ) else 0 := by apply Finset.sum_congr rfl intro p hp rw [hCodegree p hp, ← Finset.sum_filter (s := edges) (fun e => p ⊆ e) (fun _ => (1 : ℕ))] simp _ = ∑ e ∈ edges, ∑ p ∈ P, if p ⊆ e then (1 : ℕ) else 0 := Finset.sum_comm _ = ∑ _e ∈ edges, (3 : ℕ) := by apply Finset.sum_congr rfl intro e he have hfilter : P.filter (fun p => p ⊆ e) = e.powersetCard 2 := by ext p exact ⟨fun h => Finset.mem_powersetCard.mpr ⟨(Finset.mem_filter.mp h).2, hPairs p (Finset.mem_filter.mp h).1⟩, fun h => Finset.mem_filter.mpr ⟨hCoveredAll e he h, (Finset.mem_powersetCard.mp h).1⟩⟩ rw [← Finset.sum_filter (s := P) (fun p => p ⊆ e) (fun _ => (1 : ℕ))] simp [hfilter, hUniform e he] _ = 3 * edges.card := by simp [Nat.mul_comm] let d := fun p : Finset (Fin n) => (localExtensions edges p).card let g := fun p : Finset (Fin n) => (localCoExtensions edges p).card have h := (residual_weighted_bound_of_excess_le P d g edges.card hTotal (local_coextension_double_count edges).symm (local_five_refined_excess_bound hu hd)).1 have hS : (P.filter (fun p => 0 < d p)).card ≤ available.card := by apply Finset.card_le_card intro p hp obtain ⟨hP,hp⟩ := Finset.mem_filter.mp hp exact hCovered _ (hPairs _ hP) hp have hR : (P.filter (fun p => 0 < g p)).card ≤ (available.filter (fun p => ¬ g p = 0)).card := by apply Finset.card_le_card intro p hp obtain ⟨hP,hp⟩ := Finset.mem_filter.mp hp exact Finset.mem_filter.mpr ⟨hLabels _ (hPairs _ hP) hp, Nat.ne_of_gt hp⟩ have hZ : (available.filter (fun p => g p = 0)).card + (available.filter (fun p => ¬ g p = 0)).card = available.card := Finset.card_filter_add_card_filter_not (s := available) _ change 2 * edges.card + (available.filter (fun p => g p = 0)).card ≤ 2 * available.card omega noncomputable def matchingShadow {n : ℕ} (edges : Finset (Finset (Fin n))) : Finset (Finset (Fin n)) := edges.biUnion fun e => e.powersetCard 2 noncomputable def matchingLabels {n : ℕ} (edges : Finset (Finset (Fin n))) : Finset (Finset (Fin n)) := by classical exact (Finset.univ.powersetCard 2).filter fun q => ∃ p : Finset (Fin n), p.card = 2 ∧ Disjoint p q ∧ ∀ x ∈ q, insert x p ∈ edges theorem matching_shadow_mem {n : ℕ} {H : Finset (Finset (Fin n))} {p : Finset (Fin n)} : p ∈ matchingShadow H ↔ p.card = 2 ∧ ∃ e ∈ H, p ⊆ e := by constructor · intro h obtain ⟨e, he, hp⟩ := Finset.mem_biUnion.mp h obtain ⟨hsub, hcard⟩ := Finset.mem_powersetCard.mp hp exact ⟨hcard, e, he, hsub⟩ · rintro ⟨hcard, e, he, hsub⟩ exact Finset.mem_biUnion.mpr ⟨e, he, Finset.mem_powersetCard.mpr ⟨hsub, hcard⟩⟩ theorem matching_labels_mem {n : ℕ} {H : Finset (Finset (Fin n))} {q : Finset (Fin n)} : q ∈ matchingLabels H ↔ q.card = 2 ∧ ∃ p : Finset (Fin n), p.card = 2 ∧ Disjoint p q ∧ ∀ x ∈ q, insert x p ∈ H := by classical simp [matchingLabels, Finset.mem_powersetCard] theorem matching_supports_intersect {n : ℕ} {H : Finset (Finset (Fin n))} (hU : UniqueDisjointUnions H) {p r q : Finset (Fin n)} (hp : p.card = 2) (hq : q.card = 2) (hpq : Disjoint p q) (hrq : Disjoint r q) (hP : ∀ x ∈ q, insert x p ∈ H) (hR : ∀ x ∈ q, insert x r ∈ H) : ¬ Disjoint p r := by intro hpr obtain ⟨x, y, hxy, rfl⟩ := Finset.card_eq_two.mp hq have hxp : x ∉ p := fun h => Finset.disjoint_left.mp hpq h (by simp) have hyp : y ∉ p := fun h => Finset.disjoint_left.mp hpq h (by simp) have hxr : x ∉ r := fun h => Finset.disjoint_left.mp hrq h (by simp) have hyr : y ∉ r := fun h => Finset.disjoint_left.mp hrq h (by simp) have hdisj {u v : Fin n} (huv : u ≠ v) (hur : u ∉ r) (hvp : v ∉ p) : Disjoint (insert u p) (insert v r) := by rw [Finset.disjoint_left] intro z hz₁ hz₂ rcases Finset.mem_insert.mp hz₁ with rfl | hz₁ · exact (Finset.mem_insert.mp hz₂).elim huv hur · rcases Finset.mem_insert.mp hz₂ with rfl | hz₂ · exact hvp hz₁ · exact Finset.disjoint_left.mp hpr hz₁ hz₂ have hEq : insert x p ∪ insert y r = insert y p ∪ insert x r := by ext z simp only [Finset.mem_union, Finset.mem_insert] tauto rcases hU _ (hP x (by simp)) _ (hR y (by simp)) _ (hP y (by simp)) _ (hR x (by simp)) (hdisj hxy hxr hyp) (hdisj hxy.symm hyr hxp) hEq with h | h · have hx : x ∈ insert y p := h.1 ▸ Finset.mem_insert_self x p exact (Finset.mem_insert.mp hx).elim hxy hxp · obtain ⟨z, hz⟩ := Finset.card_pos.mp (by omega : 0 < p.card) have hz' : z ∈ insert x r := h.1 ▸ Finset.mem_insert_of_mem hz exact Finset.disjoint_left.mp hpr hz ((Finset.mem_insert.mp hz').resolve_left (fun hzx => hxp (hzx ▸ hz))) theorem matching_two_shadow_gluing {n : ℕ} (L R : Finset (Finset (Fin n))) (hL : ∀ e ∈ L, e.card = 3) (hR : ∀ e ∈ R, e.card = 3) (hU : UniqueDisjointUnions (L ∪ R)) (hM : ∀ p ∈ matchingShadow L ∩ matchingShadow R, ∀ r ∈ matchingShadow L ∩ matchingShadow R, p ≠ r → Disjoint p r) : (matchingShadow L).card + (matchingLabels L).card + ((matchingShadow R).card + (matchingLabels R).card) ≤ (matchingShadow (L ∪ R)).card + (matchingLabels (L ∪ R)).card := by classical let M := matchingShadow L ∩ matchingShadow R have pMem {H : Finset (Finset (Fin n))} {e p : Finset (Fin n)} (he : e ∈ H) (hpc : p.card = 2) (hpe : p ⊆ e) : p ∈ matchingShadow H := matching_shadow_mem.mpr ⟨hpc, e, he, hpe⟩ have tip {H : Finset (Finset (Fin n))} (hH : ∀ e ∈ H, e.card = 3) {p : Finset (Fin n)} (hp : p ∈ matchingShadow H) : ∃ x, x ∉ p ∧ insert x p ∈ H := by obtain ⟨hpc, e, he, hsub⟩ := matching_shadow_mem.mp hp obtain ⟨x, hx⟩ := Finset.exists_of_ssubset (show p ⊂ e from Finset.ssubset_iff_subset_ne.mpr ⟨hsub, fun h => by have hc := hH e he; rw [← h] at hc; omega⟩) refine ⟨x, hx.2, ?_⟩ have heq : insert x p = e := Finset.eq_of_subset_of_card_le (Finset.insert_subset hx.1 hsub) (by rw [Finset.card_insert_of_notMem hx.2, hpc, hH e he]) exact heq ▸ he have hTwo {x y : Fin n} (h : x ≠ y) : ({x,y} : Finset (Fin n)).card = 2 := by simp [h] have hPairU {p q : Finset (Fin n)} (hp : p.card = 2) (hq : q.card = 2) (hpq : Disjoint p q) (hu : ∀ x ∈ q, insert x p ∈ L ∪ R) {r : Finset (Fin n)} (hrq : Disjoint r q) (hv : ∀ x ∈ q, insert x r ∈ L ∪ R) : ∃ x, x ∈ p ∧ x ∈ r := by by_contra! h exact matching_supports_intersect hU hp hq hpq hrq hu hv (Finset.disjoint_left.mpr h) have oldSep : Disjoint (matchingLabels L) (matchingLabels R) := by rw [Finset.disjoint_left] intro q hqL hqR obtain ⟨hqc, p, hpc, hpq, hpL⟩ := matching_labels_mem.mp hqL obtain ⟨_, r, _, hrq, hrR⟩ := matching_labels_mem.mp hqR obtain ⟨x, hxp, hxr⟩ := hPairU hpc hqc hpq (fun z hz => Finset.mem_union_left _ (hpL z hz)) hrq (fun z hz => Finset.mem_union_right _ (hrR z hz)) obtain ⟨u, v, huv, rfl⟩ := Finset.card_eq_two.mp hqc have basePair (z : Fin n) (hz : z ∈ ({u,v} : Finset _)) : ({x,z} : Finset _) ∈ M := by have hxz : x ≠ z := fun h => Finset.disjoint_left.mp hpq hxp (h ▸ hz) exact Finset.mem_inter.mpr ⟨pMem (hpL z hz) (hTwo hxz) (by simp [Finset.insert_subset_iff, hxp]), pMem (hrR z hz) (hTwo hxz) (by simp [Finset.insert_subset_iff, hxr])⟩ have hxu := basePair u (by simp) have hxv := basePair v (by simp) have hne : ({x,u} : Finset _) ≠ {x,v} := by intro h have hu : u ∈ ({x,v} : Finset _) := h ▸ (by simp : u ∈ ({x,u} : Finset _)) rcases Finset.mem_insert.mp hu with hux | huv' · exact Finset.disjoint_left.mp hpq hxp (by simp [← hux]) · exact huv (Finset.mem_singleton.mp huv') exact Finset.disjoint_left.mp (hM _ hxu _ hxv hne) (by simp : x ∈ ({x,u} : Finset _)) (by simp) have chooseTips (p : Finset (Fin n)) (hp : p ∈ M) : ∃ a b, a ∉ p ∧ b ∉ p ∧ a ≠ b ∧ insert a p ∈ L ∧ insert b p ∈ R := by obtain ⟨a, ha, haL⟩ := tip hL (Finset.mem_inter.mp hp).1 obtain ⟨b, hb, hbR⟩ := tip hR (Finset.mem_inter.mp hp).2 refine ⟨a, b, ha, hb, ?_, haL, hbR⟩ rintro rfl obtain ⟨hpc, -, -, -⟩ := matching_shadow_mem.mp (Finset.mem_inter.mp hp).1 obtain ⟨x, hx⟩ := Finset.card_pos.mp (by omega : 0 < p.card) have hax : a ≠ x := fun h => ha (h ▸ hx) have hsub : ({a,x} : Finset _) ⊆ insert a p := by simp [Finset.insert_subset_iff, hx] have haxM : ({a,x} : Finset _) ∈ M := Finset.mem_inter.mpr ⟨pMem haL (hTwo hax) hsub, pMem hbR (hTwo hax) hsub⟩ have hne : p ≠ ({a,x} : Finset _) := fun h => ha (h.symm ▸ (by simp)) exact Finset.disjoint_left.mp (hM p hp _ haxM hne) hx (by simp) let data (p : {p // p ∈ M}) := Classical.choose (chooseTips p.val p.property) let dataB (p : {p // p ∈ M}) := Classical.choose (Classical.choose_spec (chooseTips p.val p.property)) let lab (p : {p // p ∈ M}) : Finset (Fin n) := {data p, dataB p} have cert (p : {p // p ∈ M}) : data p ∉ p.val ∧ dataB p ∉ p.val ∧ data p ≠ dataB p ∧ insert (data p) p.val ∈ L ∧ insert (dataB p) p.val ∈ R := Classical.choose_spec (Classical.choose_spec (chooseTips p.val p.property)) have lc (p : {p // p ∈ M}) : (lab p).card = 2 := hTwo (cert p).2.2.1 have pc (p : {p // p ∈ M}) : p.val.card = 2 := (matching_shadow_mem.mp (Finset.mem_inter.mp p.property).1).1 have pq (p : {p // p ∈ M}) : Disjoint p.val (lab p) := by rw [Finset.disjoint_left] intro x hx hy simpa [lab, show x ≠ data p from fun h => (cert p).1 (h ▸ hx), show x ≠ dataB p from fun h => (cert p).2.1 (h ▸ hx)] using hy have ins (p : {p // p ∈ M}) : ∀ x ∈ lab p, insert x p.val ∈ L ∪ R := by intro x hx simp only [lab, Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl · exact Finset.mem_union_left _ (cert p).2.2.2.1 · exact Finset.mem_union_right _ (cert p).2.2.2.2 have fresh (p : {p // p ∈ M}) {H K : Finset (Finset (Fin n))} {z : Fin n} (hHK : H = L ∧ K = R ∨ H = R ∧ K = L) (hz : z ∈ lab p) (hzK : insert z p.val ∈ K) : lab p ∉ matchingLabels H := by intro h obtain ⟨_, r, _, hrq, hrH⟩ := matching_labels_mem.mp h have hrU : ∀ x ∈ lab p, insert x r ∈ L ∪ R := by intro x hx rcases hHK with ⟨rfl, _⟩ | ⟨rfl, _⟩ · exact Finset.mem_union_left _ (hrH x hx) · exact Finset.mem_union_right _ (hrH x hx) obtain ⟨w, hwP, hwR⟩ := hPairU (pc p) (lc p) (pq p) (ins p) hrq hrU have hzw : z ≠ w := fun h => Finset.disjoint_left.mp (pq p) (h ▸ hwP) hz have hzP : z ∉ p.val := fun h => Finset.disjoint_left.mp (pq p) h hz have hHmem := pMem (hrH z hz) (hTwo hzw) (by simp [Finset.insert_subset_iff, hwR]) have hKmem := pMem hzK (hTwo hzw) (by simp [Finset.insert_subset_iff, hwP]) have hMem : ({z,w} : Finset _) ∈ M := by rcases hHK with ⟨rfl, rfl⟩ | ⟨rfl, rfl⟩ · exact Finset.mem_inter.mpr ⟨hHmem, hKmem⟩ · exact Finset.mem_inter.mpr ⟨hKmem, hHmem⟩ have hne : p.val ≠ ({z,w} : Finset _) := fun h => hzP (h.symm ▸ (by simp)) exact Finset.disjoint_left.mp (hM _ p.property _ hMem hne) hwP (by simp) let new := M.attach.image lab have newCard : new.card = M.card := by rw [Finset.card_image_of_injOn, Finset.card_attach] intro p _ r _ h apply Subtype.ext by_contra hp have hrq : Disjoint r.val (lab p) := h ▸ pq r have hv : ∀ x ∈ lab p, insert x r.val ∈ L ∪ R := h ▸ ins r obtain ⟨x, hx, hy⟩ := hPairU (pc p) (lc p) (pq p) (ins p) hrq hv exact Finset.disjoint_left.mp (hM _ p.property _ r.property hp) hx hy have newSep : Disjoint (matchingLabels L ∪ matchingLabels R) new := by rw [Finset.disjoint_left] intro q hq hn obtain ⟨p, _, rfl⟩ := Finset.mem_image.mp hn rcases Finset.mem_union.mp hq with h | h · exact fresh p (Or.inl ⟨rfl,rfl⟩) (by simp [lab]) (cert p).2.2.2.2 h · exact fresh p (Or.inr ⟨rfl,rfl⟩) (by simp [lab]) (cert p).2.2.2.1 h have hLabels : (matchingLabels L ∪ matchingLabels R) ∪ new ⊆ matchingLabels (L ∪ R) := by intro q hq rcases Finset.mem_union.mp hq with h | h · obtain ⟨hc, p, hp, hdis, he⟩ := matching_labels_mem.mp (show q ∈ matchingLabels (if q ∈ matchingLabels L then L else R) from by split <;> rename_i hqL · exact hqL · exact (Finset.mem_union.mp h).resolve_left hqL) exact matching_labels_mem.mpr ⟨hc, p, hp, hdis, fun x hx => by have hx' := he x hx split at hx' · exact Finset.mem_union_left _ hx' · exact Finset.mem_union_right _ hx'⟩ · obtain ⟨p, _, rfl⟩ := Finset.mem_image.mp h exact matching_labels_mem.mpr ⟨lc p, p.val, pc p, pq p, ins p⟩ have hCard := Finset.card_le_card hLabels rw [Finset.card_union_of_disjoint newSep, Finset.card_union_of_disjoint oldSep, newCard] at hCard have hS : matchingShadow (L ∪ R) = matchingShadow L ∪ matchingShadow R := by ext p simp only [matching_shadow_mem, Finset.mem_union] constructor · rintro ⟨hc, e, he, hp⟩ exact he.elim (fun h => Or.inl ⟨hc,e,h,hp⟩) (fun h => Or.inr ⟨hc,e,h,hp⟩) · rintro (⟨hc,e,he,hp⟩ | ⟨hc,e,he,hp⟩) · exact ⟨hc,e,Or.inl he,hp⟩ · exact ⟨hc,e,Or.inr he,hp⟩ have hSCard := Finset.card_union_add_card_inter (matchingShadow L) (matchingShadow R) rw [hS] change (matchingShadow L ∪ matchingShadow R).card + M.card = _ at hSCard omega theorem two_shadow_bound_of_matching_gluing {n : ℕ} (L R : Finset (Finset (Fin n))) (hL : ∀ e ∈ L, e.card = 3) (hR : ∀ e ∈ R, e.card = 3) (hU : UniqueDisjointUnions (L ∪ R)) (hM : ∀ p ∈ matchingShadow L ∩ matchingShadow R, ∀ r ∈ matchingShadow L ∩ matchingShadow R, p ≠ r → Disjoint p r) (hBoundL : 2 * L.card ≤ (matchingShadow L).card + (matchingLabels L).card) (hBoundR : 2 * R.card ≤ (matchingShadow R).card + (matchingLabels R).card) : 2 * (L ∪ R).card ≤ (matchingShadow (L ∪ R)).card + (matchingLabels (L ∪ R)).card := by have hCard := Finset.card_union_le L R have hBoth := matching_two_shadow_gluing L R hL hR hU hM omega /-- Equality is rigid as soon as removing all triples through the chosen block pairs leaves a family of maximum pair codegree at most five. -/ theorem classify_extremal_of_residual_pair_codegree_le_five {n : ℕ} {edges blocks : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hU : ∀ e ∈ edges, e.card = 3) (hE : edges.card = n.choose 2) (hB : ∀ B ∈ blocks, B.card = 5 ∧ ∀ t, t.card = 3 → t ⊆ B → t ∈ edges) (hD : ∀ p : Finset (Fin n), p.card = 2 → (localExtensions (fullFiveResidual edges blocks) p).card ≤ 5) : ∃ result : Finset (Finset (Fin n)), SteinerFive result ∧ IsExpansion edges result := by classical apply classify_extremal_of_residual_strong_bound hu hU hE hB hD let H := fullFiveResidual edges blocks let P := fullFiveMissingPairs blocks have hsub : H ⊆ edges := Finset.filter_subset _ _ have hR (t : Finset (Fin n)) (ht : t ∈ H) := (Finset.mem_filter.mp ht).2 obtain ⟨hS,hL⟩ := full_five_residual_shadows_subset_missing hu hsub hB hR have hUnique : UniqueDisjointUnions H := fun A hA B hB C hC D hD => hu A (hsub hA) B (hsub hB) C (hsub hC) D (hsub hD) have hLabel (q : Finset (Fin n)) (hq : q.card = 2) (hpos : 0 < (localCoExtensions H q).card) : q ∈ P := by obtain ⟨p,hp⟩ := Finset.card_pos.mp hpos obtain ⟨hp2,hqp⟩ := local_mem_coextensions.mp hp exact hL p hp2 (Finset.mem_powersetCard.mpr ⟨hqp,hq⟩) have hBound := residual_triple_bound_of_codegrees_le_five H P hUnique (fun e he => hU e (hsub he)) (fun x a hxa => hD {x,a} (by simp [hxa])) (fun p hp hpos => hS p hp (Finset.card_pos.mp hpos)) hLabel simpa only [fullFiveEmptyLabels, Finset.card_eq_zero] using hBound /-- The summed shadow bound and rigidity at simultaneous equality in the two shadows suffice for classification. Rigidity is only needed on families that contain no complete five-set. -/ theorem classify_extremal_of_two_shadow_rigidity {n : ℕ} (edges : Finset (Finset (Fin n))) (hu : UniqueDisjointUnions edges) (hU : ∀ e ∈ edges, e.card = 3) (hE : edges.card = n.choose 2) (hBound : ∀ H : Finset (Finset (Fin n)), H ⊆ edges → 2 * H.card ≤ (ordinaryPairShadow H).card + (commonPairLabelShadow H).card) (hRigid : ∀ H : Finset (Finset (Fin n)), H ⊆ edges → (∀ B : Finset (Fin n), B.card = 5 → ¬ B.powersetCard 3 ⊆ H) → H.card = (ordinaryPairShadow H).card → H.card = (commonPairLabelShadow H).card → H = ∅) : ∃ blocks : Finset (Finset (Fin n)), SteinerFive blocks ∧ IsExpansion edges blocks := by classical let blocks := (Finset.univ : Finset (Fin n)).powersetCard 5 |>.filter (fun B => B.powersetCard 3 ⊆ edges) have hB (B : Finset (Fin n)) (hBm : B ∈ blocks) : B.card = 5 ∧ ∀ t, t.card = 3 → t ⊆ B → t ∈ edges := by obtain ⟨hcard,hfull⟩ := Finset.mem_filter.mp hBm exact ⟨(Finset.mem_powersetCard.mp hcard).2, fun t ht htB => hfull (Finset.mem_powersetCard.mpr ⟨htB,ht⟩)⟩ apply classify_extremal_of_residual_weighted_bound (blocks := blocks) hu hU hE hB let H := fullFiveResidual edges blocks let P := fullFiveMissingPairs blocks let Z := fullFiveEmptyLabels H P let S := ordinaryPairShadow H let R := commonPairLabelShadow H have hsub : H ⊆ edges := Finset.filter_subset _ _ have hMeet (t : Finset (Fin n)) (ht : t ∈ H) := (Finset.mem_filter.mp ht).2 obtain ⟨_,hLabel⟩ := full_five_residual_shadows_subset_missing hu hsub hB hMeet have hS : S ⊆ P := by intro p hp obtain ⟨hp2,t,ht,hpt⟩ := mem_ordinaryPairShadow.mp hp apply Finset.mem_filter.mpr refine ⟨Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _,hp2⟩,?_⟩ intro B hBm hpB have hc := Finset.card_le_card (Finset.subset_inter hpt hpB) have hsmall := hMeet t ht B hBm omega have hR : R ⊆ P := by intro q hq obtain ⟨hq2,⟨p,hp⟩⟩ := Finset.mem_filter.mp hq obtain ⟨hp2,hqp⟩ := local_mem_coextensions.mp hp exact hLabel p hp2 (Finset.mem_powersetCard.mpr ⟨hqp,(Finset.mem_powersetCard.mp hq2).2⟩) have hZ : Z = P \ R := by ext q simp only [Z, fullFiveEmptyLabels, R, commonPairLabelShadow, Finset.mem_filter, Finset.mem_sdiff, Finset.not_nonempty_iff_eq_empty] constructor · rintro ⟨hq,hne⟩ exact ⟨hq,fun h => (Finset.not_nonempty_iff_eq_empty.mpr hne) h.2⟩ · rintro ⟨hq,hn⟩ have hq2 := (Finset.mem_filter.mp hq).1 exact ⟨hq,Finset.not_nonempty_iff_eq_empty.mp (fun h => hn ⟨hq2,h⟩)⟩ have hcZ : Z.card + R.card = P.card := by rw [hZ,Finset.card_sdiff_add_card_eq_card hR] have hcS := Finset.card_le_card hS have hbound := hBound H hsub change 2 * H.card ≤ S.card + R.card at hbound change 3 * H.card + Z.card ≤ 3 * P.card ∧ (3 * H.card + Z.card = 3 * P.card → Z = ∅ ∧ ∀ p ∈ P, (localExtensions H p).card ≤ 5) refine ⟨by omega, fun heq => ⟨Finset.card_eq_zero.mp (by omega),?_⟩⟩ have hNoFive (B : Finset (Fin n)) (hB5 : B.card = 5) (hBH : B.powersetCard 3 ⊆ H) : False := by have hBm : B ∈ blocks := Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _,hB5⟩,hBH.trans hsub⟩ obtain ⟨t,htB,ht3⟩ := Finset.exists_subset_card_eq (s := B) (n := 3) (by omega) have ht := hBH (Finset.mem_powersetCard.mpr ⟨htB,ht3⟩) have h := hMeet t ht B hBm rw [Finset.inter_eq_left.mpr htB,ht3] at h omega have hEmpty := hRigid H hsub hNoFive (by change H.card = S.card; omega) (by change H.card = R.card; omega) intro p _ simp [hEmpty,localExtensions] theorem outside_triples_inter_card_le_one_of_dense_link {n : ℕ} {edges : Finset (Finset (Fin n))} {x : Fin n} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ x → b ≠ x → a ≠ b → 3 ≤ (localExtensions edges {x,a} ∩ localExtensions edges {x,b}).card) {e f : Finset (Fin n)} (he : e ∈ edges) (hf : f ∈ edges) (he3 : e.card = 3) (hf3 : f.card = 3) (hxe : x ∉ e) (hxf : x ∉ f) (hef : e ≠ f) : (e ∩ f).card ≤ 1 := by classical by_contra hn obtain ⟨p,hp,hp2⟩ := Finset.exists_subset_card_eq (s := e ∩ f) (n := 2) (by omega) have factor (s : Finset (Fin n)) (hs : s ∈ edges) (hs3 : s.card = 3) (hps : p ⊆ s) : ∃ c ∈ localExtensions edges p, insert c p = s := by have hc1 : (s \ p).card = 1 := by rw [Finset.card_sdiff_of_subset hps,hs3,hp2] obtain ⟨c,hc⟩ := Finset.card_pos.mp (by omega : 0 < (s \ p).card) obtain ⟨hcs,hcp⟩ := Finset.mem_sdiff.mp hc have hs' := Finset.eq_of_subset_of_card_le (Finset.insert_subset_iff.mpr ⟨hcs,hps⟩) (by rw [hs3,Finset.card_insert_of_notMem hcp,hp2]) exact ⟨c, by simp [localExtensions,hcp,hs',hs],hs'⟩ obtain ⟨a,ha,rfl⟩ := factor e he he3 (hp.trans Finset.inter_subset_left) obtain ⟨b,hb,rfl⟩ := factor f hf hf3 (hp.trans Finset.inter_subset_right) have hax : a ≠ x := fun h => hxe (h ▸ Finset.mem_insert_self a p) have hbx : b ≠ x := fun h => hxf (h ▸ Finset.mem_insert_self b p) have hab : a ≠ b := fun h => hef (congrArg (fun v => insert v p) h) have hxp : x ∉ p := fun h => hxe (Finset.mem_insert_of_mem h) let T := localExtensions edges {x,a} ∩ localExtensions edges {x,b} have hex : ¬ T ⊆ p := fun h => by have hs := Finset.card_le_card h have hT : 3 ≤ T.card := hd a b hax hbx hab omega obtain ⟨t,ht,htp⟩ := Finset.not_subset.mp hex have hta := (Finset.mem_inter.mp ht).1 have htb := (Finset.mem_inter.mp ht).2 have htx := local_neighbors_symm hax.symm hta have hty := local_neighbors_symm hbx.symm htb have hxt : x ≠ t := by have h := (Finset.mem_filter.mp hta).2.1 intro heq exact h (heq ▸ Finset.mem_insert_self x {a}) have hdisj : Disjoint p ({x,t} : Finset (Fin n)) := by simp [Finset.disjoint_insert_right,hxp,htp] exact local_extension_edges_cross hu hp2 (by simp [hxt]) hab ha hb htx hty hdisj theorem edge_bound_of_dense_vertex_link {n : ℕ} (edges : Finset (Finset (Fin n))) (x : Fin n) (hu : UniqueDisjointUnions edges) (hU : ∀ e ∈ edges, e.card = 3) (hd : ∀ a b : Fin n, a ≠ x → b ≠ x → a ≠ b → 3 ≤ (localExtensions edges {x,a} ∩ localExtensions edges {x,b}).card) : 3 * edges.card ≤ 3 * (n-1).choose 2 + (n-1) := by classical let V := (Finset.univ : Finset (Fin n)).erase x let P := V.powersetCard 2 let L := P.filter (fun p => insert x p ∈ edges) let H := edges.filter (fun e => x ∉ e) have hV : V.card = n - 1 := by simp [V] have hInside : (edges.filter (fun e => x ∈ e)).card = L.card := by apply Finset.card_bij (fun e _ => e.erase x) · intro e he obtain ⟨he,hxe⟩ := Finset.mem_filter.mp he have h2 : (e.erase x).card = 2 := by rw [Finset.card_erase_of_mem hxe,hU e he] apply Finset.mem_filter.mpr refine ⟨Finset.mem_powersetCard.mpr ⟨?_,h2⟩,?_⟩ · intro y hy exact Finset.mem_erase.mpr ⟨(Finset.mem_erase.mp hy).1,Finset.mem_univ _⟩ · rwa [Finset.insert_erase hxe] · intro e he f hf h simpa only [Finset.insert_erase (Finset.mem_filter.mp he).2, Finset.insert_erase (Finset.mem_filter.mp hf).2] using congrArg (insert x) h · intro p hp obtain ⟨hp,hxe⟩ := Finset.mem_filter.mp hp have hxp : x ∉ p := fun h => Finset.notMem_erase x _ ((Finset.mem_powersetCard.mp hp).1 h) exact ⟨insert x p,Finset.mem_filter.mpr ⟨hxe,Finset.mem_insert_self _ _⟩, Finset.erase_insert hxp⟩ have hAll : L.card + H.card = edges.card := by rw [← hInside] exact Finset.card_filter_add_card_filter_not (s := edges) (fun e => x ∈ e) let I := H.sigma (fun e => e) have hI : I.card = 3 * H.card := by rw [Finset.card_sigma] calc _ = ∑ _e ∈ H, (3 : ℕ) := Finset.sum_congr rfl (fun e he => hU e (Finset.mem_filter.mp he).1) _ = _ := by simp [Nat.mul_comm] let good (i : (e : Finset (Fin n)) × Fin n) := i.1.erase i.2 ∈ L have hlin {e f : Finset (Fin n)} (he : e ∈ H) (hf : f ∈ H) (hne : e ≠ f) : (e ∩ f).card ≤ 1 := by obtain ⟨he,hxe⟩ := Finset.mem_filter.mp he obtain ⟨hf,hxf⟩ := Finset.mem_filter.mp hf exact outside_triples_inter_card_le_one_of_dense_link hu hd he hf (hU e he) (hU f hf) hxe hxf hne have hgood : (I.filter good).card ≤ V.card := by apply Finset.card_le_card_of_injOn (fun i => i.2) · rintro ⟨e,v⟩ hi obtain ⟨he,hv⟩ := Finset.mem_sigma.mp (Finset.mem_filter.mp hi).1 exact Finset.mem_erase.mpr ⟨fun h => (Finset.mem_filter.mp he).2 (h ▸ hv),Finset.mem_univ _⟩ · rintro ⟨e,v⟩ hi ⟨f,w⟩ hj hEq change v = w at hEq subst w obtain ⟨hmi,hgi⟩ := Finset.mem_filter.mp hi obtain ⟨hmj,hgj⟩ := Finset.mem_filter.mp hj obtain ⟨he,hve⟩ := Finset.mem_sigma.mp hmi obtain ⟨hf,hvf⟩ := Finset.mem_sigma.mp hmj by_cases hef : e = f · cases hef rfl exfalso have hdisj : Disjoint (e.erase v) (f.erase v) := by apply Finset.disjoint_left.mpr intro z hz hz' obtain ⟨hzv,hze⟩ := Finset.mem_erase.mp hz have h2 : ({z,v} : Finset (Fin n)).card = 2 := by simp [hzv] have hs : ({z,v} : Finset (Fin n)) ⊆ e ∩ f := Finset.insert_subset_iff.mpr ⟨Finset.mem_inter.mpr ⟨hze,(Finset.mem_erase.mp hz').2⟩, Finset.singleton_subset_iff.mpr (Finset.mem_inter.mpr ⟨hve,hvf⟩)⟩ have hc := Finset.card_le_card hs have hh : (e ∩ f).card ≤ 1 := hlin he hf hef omega have hvx : v ≠ x := fun h => (Finset.mem_filter.mp he).2 (h ▸ hve) have extensions {s : Finset (Fin n)} (hs : s ∈ H) (hv : v ∈ s) (hl : s.erase v ∈ L) : (s.erase v).card = 2 ∧ v ∈ localExtensions edges (s.erase v) ∧ x ∈ localExtensions edges (s.erase v) := by obtain ⟨hs,hxs⟩ := Finset.mem_filter.mp hs have hxs' : x ∉ s.erase v := fun h => hxs (Finset.mem_of_mem_erase h) exact ⟨by rw [Finset.card_erase_of_mem hv,hU s hs], by simp [localExtensions,Finset.insert_erase hv,hs], Finset.mem_filter.mpr ⟨Finset.mem_univ _,hxs',(Finset.mem_filter.mp hl).2⟩⟩ obtain ⟨he2,hve',hxe'⟩ := extensions he hve hgi obtain ⟨hf2,hvf',hxf'⟩ := extensions hf hvf hgj exact local_extension_edges_cross hu he2 hf2 hvx hve' hxe' hvf' hxf' hdisj have hbad : (I.filter (fun i => ¬ good i)).card ≤ (P \ L).card := by apply Finset.card_le_card_of_injOn (fun i => i.1.erase i.2) · rintro ⟨e,v⟩ hi obtain ⟨hmi,hgi⟩ := Finset.mem_filter.mp hi obtain ⟨he,hv⟩ := Finset.mem_sigma.mp hmi obtain ⟨hee,hxe⟩ := Finset.mem_filter.mp he apply Finset.mem_sdiff.mpr refine ⟨Finset.mem_powersetCard.mpr ⟨?_, by rw [Finset.card_erase_of_mem hv,hU e hee]⟩,hgi⟩ intro z hz exact Finset.mem_erase.mpr ⟨fun h => hxe (h ▸ Finset.mem_of_mem_erase hz),Finset.mem_univ _⟩ · rintro ⟨e,v⟩ hi ⟨f,w⟩ hj hEq obtain ⟨he,hv⟩ := Finset.mem_sigma.mp (Finset.mem_filter.mp hi).1 obtain ⟨hf,hw⟩ := Finset.mem_sigma.mp (Finset.mem_filter.mp hj).1 change e.erase v = f.erase w at hEq have hef : e = f := by by_contra hn have h2 : (e.erase v).card = 2 := by rw [Finset.card_erase_of_mem hv,hU e (Finset.mem_filter.mp he).1] have hp : e.erase v ⊆ e ∩ f := Finset.subset_inter (Finset.erase_subset _ _) (hEq ▸ Finset.erase_subset w f) have hcard := Finset.card_le_card hp have h : (e ∩ f).card ≤ 1 := hlin he hf hn omega subst f have hvw : v = w := by by_contra hn have hs : v ∈ e.erase w := Finset.mem_erase.mpr ⟨hn,hv⟩ exact Finset.notMem_erase v _ (hEq ▸ hs) subst w rfl have hSplit := Finset.card_filter_add_card_filter_not (s := I) good have hMissing := Finset.card_sdiff_add_card_eq_card (Finset.filter_subset (fun p => insert x p ∈ edges) P) change (P \ L).card + L.card = P.card at hMissing have hP : P.card = (n-1).choose 2 := by simp [P,hV] omega theorem no_extremal_of_dense_vertex_link {n : ℕ} (edges : Finset (Finset (Fin n))) (x : Fin n) (hn : 2 ≤ n) (hu : UniqueDisjointUnions edges) (hU : ∀ e ∈ edges, e.card = 3) (hd : ∀ a b : Fin n, a ≠ x → b ≠ x → a ≠ b → 3 ≤ (localExtensions edges {x,a} ∩ localExtensions edges {x,b}).card) : edges.card < n.choose 2 := by have h := edge_bound_of_dense_vertex_link edges x hu hU hd have heq : n.choose 2 = (n-1).choose 2 + (n-1) := by cases n with | zero => omega | succ k => simp [Nat.choose_succ_succ, Nat.add_comm] omega /-- With at most one missing triple on a five-set, each vertex outside it extends at most two of its pairs. -/ theorem near_five_external_pair_count {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {block : Finset (Fin n)} (hb : block.card = 5) (hm : (block.powersetCard 3 \ edges).card ≤ 1) {x : Fin n} (hx : x ∉ block) : ((block.powersetCard 2).filter (fun p => insert x p ∈ edges)).card ≤ 2 := by classical let P := (block.powersetCard 2).filter (fun p => insert x p ∈ edges) let good (p : Finset (Fin n)) := block \ p ∈ edges have hgood : (P.filter good).card ≤ 1 := by apply Finset.card_le_one.mpr intro p hp q hq obtain ⟨hpP,hpg⟩ := Finset.mem_filter.mp hp obtain ⟨hqP,hqg⟩ := Finset.mem_filter.mp hq obtain ⟨hpp,hxe⟩ := Finset.mem_filter.mp hpP obtain ⟨hqq,hxf⟩ := Finset.mem_filter.mp hqP have hpB := (Finset.mem_powersetCard.mp hpp).1 have hqB := (Finset.mem_powersetCard.mp hqq).1 have hdisj (r : Finset (Fin n)) : Disjoint (insert x r) (block \ r) := by rw [Finset.disjoint_insert_left] exact ⟨fun h => hx (Finset.mem_sdiff.mp h).1,Finset.disjoint_sdiff⟩ have hun {r : Finset (Fin n)} (hr : r ⊆ block) : insert x r ∪ (block \ r) = insert x block := by rw [Finset.insert_union, Finset.union_sdiff_of_subset hr] rcases hu _ hxe _ hpg _ hxf _ hqg (hdisj p) (hdisj q) ((hun hpB).trans (hun hqB).symm) with h | h · have hpx : x ∉ p := fun h => hx (hpB h) have hqx : x ∉ q := fun h => hx (hqB h) simpa only [Finset.erase_insert hpx, Finset.erase_insert hqx] using congrArg (fun s => s.erase x) h.1 · exact False.elim (hx ((Finset.mem_sdiff.mp (h.1 ▸ Finset.mem_insert_self x p)).1)) have hbad : (P.filter (fun p => ¬ good p)).card ≤ 1 := by apply le_trans _ hm apply Finset.card_le_card_of_injOn (fun p => block \ p) · intro p hp obtain ⟨hpP,hpn⟩ := Finset.mem_filter.mp hp obtain ⟨hpB,hp2⟩ := Finset.mem_powersetCard.mp (Finset.mem_filter.mp hpP).1 exact Finset.mem_sdiff.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.sdiff_subset, by rw [Finset.card_sdiff_of_subset hpB,hb,hp2]⟩,hpn⟩ · intro p hp q hq h have hpB := (Finset.mem_powersetCard.mp (Finset.mem_filter.mp (Finset.mem_filter.mp hp).1).1).1 have hqB := (Finset.mem_powersetCard.mp (Finset.mem_filter.mp (Finset.mem_filter.mp hq).1).1).1 simpa only [Finset.sdiff_sdiff_eq_self hpB, Finset.sdiff_sdiff_eq_self hqB] using congrArg (fun p => block \ p) h have hc := Finset.card_filter_add_card_filter_not (s := P) good change P.card ≤ 2 omega /-- In a five-set with at most one missing triple, any pair contained in the five-set shares a witness among two distinct candidate support pairs. -/ theorem near_five_one_of_two_supports {n : ℕ} {edges : Finset (Finset (Fin n))} {block p r q : Finset (Fin n)} (hm : (block.powersetCard 3 \ edges).card ≤ 1) (hp : p.card = 2) (hr : r.card = 2) (hpr : p ≠ r) (hpB : p ⊆ block) (hrB : r ⊆ block) (hqB : q ⊆ block) (hpq : Disjoint p q) (hrq : Disjoint r q) : q ⊆ localExtensions edges p ∨ q ⊆ localExtensions edges r := by classical by_contra hn push Not at hn obtain ⟨a,ha,ha'⟩ := Finset.not_subset.mp hn.1 obtain ⟨b,hb,hb'⟩ := Finset.not_subset.mp hn.2 have hnot {s : Finset (Fin n)} (hs : s.card = 2) (hsB : s ⊆ block) (hsq : Disjoint s q) {v : Fin n} (hv : v ∈ q) (hv' : v ∉ localExtensions edges s) : insert v s ∈ block.powersetCard 3 \ edges := by have hvs : v ∉ s := fun h => Finset.disjoint_left.mp hsq h hv refine Finset.mem_sdiff.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.insert_subset_iff.mpr ⟨hqB hv,hsB⟩,by rw [Finset.card_insert_of_notMem hvs,hs]⟩,?_⟩ intro h exact hv' (Finset.mem_filter.mpr ⟨Finset.mem_univ _,hvs,h⟩) have hab := Finset.card_le_one.mp hm _ (hnot hp hpB hpq ha ha') _ (hnot hr hrB hrq hb hb') have hsub {s : Finset (Fin n)} (hsq : Disjoint s q) {v : Fin n} (hv : v ∈ q) : (insert v s) \ q = s := by ext t simp only [Finset.mem_sdiff,Finset.mem_insert] constructor · rintro ⟨rfl | ht, htq⟩ · exact (htq hv).elim · exact ht · intro ht exact ⟨Or.inr ht,fun htq => Finset.disjoint_left.mp hsq ht htq⟩ exact hpr (by simpa only [hsub hpq ha,hsub hrq hb] using congrArg (fun s => s \ q) hab) /-- Two distinct complete or almost complete five-sets share at most one vertex. -/ theorem near_five_blocks_inter_card_le_one {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hU : ∀ e ∈ edges, e.card = 3) {B C : Finset (Fin n)} (hB : B.card = 5) (hC : C.card = 5) (hMB : (B.powersetCard 3 \ edges).card ≤ 1) (hMC : (C.powersetCard 3 \ edges).card ≤ 1) (hne : B ≠ C) : (B ∩ C).card ≤ 1 := by classical have base_exists {W : Finset (Fin n)} (hW : W.card = 5) (hMW : (W.powersetCard 3 \ edges).card ≤ 1) {q : Finset (Fin n)} (hq : q.card = 2) (hqW : q ⊆ W) : ∃ p ⊆ W, p.card = 2 ∧ q ⊆ localExtensions edges p := by let T := W \ q have hT : T.card = 3 := by rw [Finset.card_sdiff_of_subset hqW,hW,hq] obtain ⟨a,ha⟩ := Finset.card_pos.mp (by omega : 0 < T.card) have hTa : (T.erase a).card = 2 := by rw [Finset.card_erase_of_mem ha,hT] obtain ⟨b,hb⟩ := Finset.card_pos.mp (by omega : 0 < (T.erase a).card) obtain ⟨hba,hbT⟩ := Finset.mem_erase.mp hb have hTb : (T.erase b).card = 2 := by rw [Finset.card_erase_of_mem hbT,hT] have hab : T.erase a ≠ T.erase b := fun h => Finset.notMem_erase b T (h ▸ hb) have hdisj : Disjoint T q := Finset.disjoint_left.mpr (fun _ ha hb => (Finset.mem_sdiff.mp ha).2 hb) have hd₁ := hdisj.mono_left (Finset.erase_subset a T) have hd₂ := hdisj.mono_left (Finset.erase_subset b T) have hs₁ : T.erase a ⊆ W := (Finset.erase_subset _ _).trans Finset.sdiff_subset have hs₂ : T.erase b ⊆ W := (Finset.erase_subset _ _).trans Finset.sdiff_subset rcases near_five_one_of_two_supports hMW hTa hTb hab hs₁ hs₂ hqW hd₁ hd₂ with h | h · exact ⟨_,hs₁,hTa,h⟩ · exact ⟨_,hs₂,hTb,h⟩ have crossing {p q : Finset (Fin n)} (hp : p.card = 2) (hq : q.card = 2) (hpC : Disjoint p C) (hqC : q ⊆ C) (hsup : q ⊆ localExtensions edges p) : False := by obtain ⟨r,hrC,hr,hsr⟩ := base_exists hC hMC hq hqC obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hq have ha : a ∈ ({a,b} : Finset (Fin n)) := by simp have hb : b ∈ ({a,b} : Finset (Fin n)) := by simp exact local_extension_edges_cross hu hp hr hab (hsup ha) (hsup hb) (hsr ha) (hsr hb) (hpC.mono_right hrC) have hInt : (B ∩ C).card ≤ 4 := by have hs : B ∩ C ⊆ B := Finset.inter_subset_left have hs' : B ∩ C ⊆ C := Finset.inter_subset_right by_contra hn have heq := Finset.eq_of_subset_of_card_le hs (by omega) have heq' := Finset.eq_of_subset_of_card_le hs' (by omega) exact hne (heq.symm.trans heq') by_contra hn have hCases : (B ∩ C).card = 2 ∨ (B ∩ C).card = 3 ∨ (B ∩ C).card = 4 := by omega let T := B \ C have hT : T.card = 5 - (B ∩ C).card := by have ht : T = B \ (B ∩ C) := by ext z; simp [T] rw [ht,Finset.card_sdiff_of_subset Finset.inter_subset_left,hB] rcases hCases with h | h | h · have hT3 : T.card = 3 := by omega obtain ⟨a,ha⟩ := Finset.card_pos.mp (by omega : 0 < T.card) have hTa : (T.erase a).card = 2 := by rw [Finset.card_erase_of_mem ha,hT3] obtain ⟨b,hb⟩ := Finset.card_pos.mp (by omega : 0 < (T.erase a).card) have hTb : (T.erase b).card = 2 := by rw [Finset.card_erase_of_mem (Finset.mem_of_mem_erase hb),hT3] have hab : T.erase a ≠ T.erase b := fun h => Finset.notMem_erase b T (h ▸ hb) have hsub₁ : T.erase a ⊆ B := (Finset.erase_subset _ _).trans Finset.sdiff_subset have hsub₂ : T.erase b ⊆ B := (Finset.erase_subset _ _).trans Finset.sdiff_subset have hd : Disjoint T C := Finset.disjoint_left.mpr (fun _ ha hb => (Finset.mem_sdiff.mp ha).2 hb) have hd₁ : Disjoint (T.erase a) C := hd.mono_left (Finset.erase_subset _ _) have hd₂ : Disjoint (T.erase b) C := hd.mono_left (Finset.erase_subset _ _) rcases near_five_one_of_two_supports hMB hTa hTb hab hsub₁ hsub₂ Finset.inter_subset_left (hd₁.mono_right Finset.inter_subset_right) (hd₂.mono_right Finset.inter_subset_right) with h₁ | h₂ · exact crossing hTa h hd₁ Finset.inter_subset_right h₁ · exact crossing hTb h hd₂ Finset.inter_subset_right h₂ · have hT2 : T.card = 2 := by omega have hd : Disjoint T C := Finset.disjoint_left.mpr (fun _ ha hb => (Finset.mem_sdiff.mp ha).2 hb) let good (a : Fin n) := a ∈ localExtensions edges T have hbad : ((B ∩ C).filter (fun a => ¬ good a)).card ≤ 1 := by apply le_trans _ hMB apply Finset.card_le_card_of_injOn (fun a => insert a T) · intro a ha obtain ⟨haI,hna⟩ := Finset.mem_filter.mp ha have haC := (Finset.mem_inter.mp haI).2 have haT : a ∉ T := fun ht => Finset.disjoint_left.mp hd ht haC refine Finset.mem_sdiff.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.insert_subset_iff.mpr ⟨(Finset.mem_inter.mp haI).1,Finset.sdiff_subset⟩, by rw [Finset.card_insert_of_notMem haT,hT2]⟩,?_⟩ intro he exact hna (Finset.mem_filter.mpr ⟨Finset.mem_univ _,haT,he⟩) · intro a ha b hb hEq have haC := (Finset.mem_inter.mp (Finset.mem_filter.mp ha).1).2 change insert a T = insert b T at hEq exact (Finset.mem_insert.mp (hEq ▸ Finset.mem_insert_self a T)).resolve_right (fun h => Finset.disjoint_left.mp hd h haC) have hsum := Finset.card_filter_add_card_filter_not (s := B ∩ C) good obtain ⟨q,hq,hq2⟩ := Finset.exists_subset_card_eq (s := (B ∩ C).filter good) (n := 2) (by omega) exact crossing hT2 hq2 hd (hq.trans ((Finset.filter_subset _ _).trans Finset.inter_subset_right)) (fun a ha => (Finset.mem_filter.mp (hq ha)).2) · have hUnion := Finset.card_union_add_card_inter B C have hbnd := card_edges_on_six_le_eleven edges hU hu (B ∪ C) (by omega) let U := B.powersetCard 3 let V := C.powersetCard 3 have hUV : U ∩ V = (B ∩ C).powersetCard 3 := by ext t simp only [U,V,Finset.mem_inter,Finset.mem_powersetCard,Finset.subset_inter_iff] tauto have hu' : U.card = 10 := by simp [U,hB]; decide have hv' : V.card = 10 := by simp [V,hC]; decide have hi : (U ∩ V).card = 4 := by simp [hUV,h] have hBC := Finset.card_union_add_card_inter U V have hMiss : (U ∪ V) \ edges = (U \ edges) ∪ (V \ edges) := by ext t simp only [Finset.mem_sdiff,Finset.mem_union] tauto have hBad := Finset.card_union_le (U \ edges) (V \ edges) change (U \ edges).card ≤ 1 at hMB change (V \ edges).card ≤ 1 at hMC have hGood : (U ∪ V) ∩ edges ⊆ edges.filter (· ⊆ B ∪ C) := by intro t ht obtain ⟨ht,he⟩ := Finset.mem_inter.mp ht apply Finset.mem_filter.mpr refine ⟨he,?_⟩ rcases Finset.mem_union.mp ht with ht | ht · exact (Finset.mem_powersetCard.mp ht).1.trans Finset.subset_union_left · exact (Finset.mem_powersetCard.mp ht).1.trans Finset.subset_union_right have hsplit := Finset.card_sdiff_add_card_inter (U ∪ V) edges rw [hMiss] at hsplit have hG := Finset.card_le_card hGood omega /-- The usable tips in an almost complete block number at least twice the chosen external pairs. -/ theorem near_five_charge_count_at_vertex {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {block : Finset (Fin n)} (hb : block.card = 5) (hm : (block.powersetCard 3 \ edges).card ≤ 1) {x : Fin n} (hx : x ∉ block) (P : Finset (Finset (Fin n))) (hP : P ⊆ (block.powersetCard 2).filter (fun p => insert x p ∈ edges)) : 2 * P.card ≤ (P.biUnion (fun p => (block \ p).filter (fun z => insert z p ∈ edges))).card := by classical let charge (p : Finset (Fin n)) := (block \ p).filter (fun z => insert z p ∈ edges) let bad (p : Finset (Fin n)) := (block \ p).filter (fun z => insert z p ∉ edges) have hData {p : Finset (Fin n)} (hp : p ∈ P) : p ⊆ block ∧ p.card = 2 ∧ insert x p ∈ edges := by obtain ⟨hq,he⟩ := Finset.mem_filter.mp (hP hp) exact ⟨(Finset.mem_powersetCard.mp hq).1,(Finset.mem_powersetCard.mp hq).2,he⟩ have hBad {p : Finset (Fin n)} (hp : p ∈ P) : (bad p).card ≤ 1 := by obtain ⟨hpB,hp2,_⟩ := hData hp apply le_trans _ hm apply Finset.card_le_card_of_injOn (fun z => insert z p) · intro z hz obtain ⟨hzp,hze⟩ := Finset.mem_filter.mp hz obtain ⟨hzB,hzp'⟩ := Finset.mem_sdiff.mp hzp exact Finset.mem_sdiff.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.insert_subset hzB hpB,by rw [Finset.card_insert_of_notMem hzp',hp2]⟩,hze⟩ · intro z hz w hw hEq change insert z p = insert w p at hEq exact (Finset.mem_insert.mp (hEq ▸ Finset.mem_insert_self z p)).resolve_right (Finset.mem_sdiff.mp (Finset.mem_filter.mp hz).1).2 have hSplit {p : Finset (Fin n)} (hp : p ∈ P) : (charge p).card + (bad p).card = 3 := by obtain ⟨hpB,hp2,_⟩ := hData hp have heq : (block \ p).card = 3 := by rw [Finset.card_sdiff_of_subset hpB,hb,hp2] exact (Finset.card_filter_add_card_filter_not (s := block \ p) (fun z => insert z p ∈ edges)).trans heq have hCharge {p : Finset (Fin n)} (hp : p ∈ P) : 2 ≤ (charge p).card := by have := hSplit hp have := hBad hp omega have hCard : P.card ≤ 2 := (Finset.card_le_card hP).trans (near_five_external_pair_count hu hb hm hx) have hGoodUnique {p q : Finset (Fin n)} (hp : p ∈ P) (hq : q ∈ P) (hpg : block \ p ∈ edges) (hqg : block \ q ∈ edges) : p = q := by obtain ⟨hpB,hp2,hxp⟩ := hData hp obtain ⟨hqB,hq2,hxq⟩ := hData hq have hdisj (r : Finset (Fin n)) : Disjoint (insert x r) (block \ r) := by rw [Finset.disjoint_insert_left] exact ⟨fun h => hx (Finset.mem_sdiff.mp h).1,Finset.disjoint_sdiff⟩ have hun {r : Finset (Fin n)} (hr : r ⊆ block) : insert x r ∪ (block \ r) = insert x block := by rw [Finset.insert_union, Finset.union_sdiff_of_subset hr] rcases hu _ hxp _ hpg _ hxq _ hqg (hdisj p) (hdisj q) ((hun hpB).trans (hun hqB).symm) with h | h · have hpx : x ∉ p := fun h => hx (hpB h) have hqx : x ∉ q := fun h => hx (hqB h) simpa only [Finset.erase_insert hpx, Finset.erase_insert hqx] using congrArg (fun s => s.erase x) h.1 · exact False.elim (hx ((Finset.mem_sdiff.mp (h.1 ▸ Finset.mem_insert_self x p)).1)) have hSmallDisjoint {p q : Finset (Fin n)} (hp : p ∈ P) (hq : q ∈ P) (hneq : p ≠ q) (hSmall : (charge p).card < 3) : Disjoint (charge p) (charge q) := by have hPos : 0 < (bad p).card := by have := hSplit hp; omega obtain ⟨z,hz⟩ := Finset.card_pos.mp hPos obtain ⟨hzp,hzE⟩ := Finset.mem_filter.mp hz obtain ⟨hzB,hzp'⟩ := Finset.mem_sdiff.mp hzp obtain ⟨hpB,hp2,_⟩ := hData hp obtain ⟨hqB,hq2,_⟩ := hData hq have hzM : insert z p ∈ block.powersetCard 3 \ edges := Finset.mem_sdiff.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.insert_subset hzB hpB, by rw [Finset.card_insert_of_notMem hzp',hp2]⟩,hzE⟩ have comp (r : Finset (Fin n)) (hrB : r ⊆ block) (hr2 : r.card = 2) (hr : block \ r ∉ edges) : block \ r = insert z p := by apply Finset.card_le_one.mp hm _ _ _ hzM exact Finset.mem_sdiff.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.sdiff_subset, by rw [Finset.card_sdiff_of_subset hrB,hb,hr2]⟩,hr⟩ have hpg : block \ p ∈ edges := by by_contra hn have hEq := comp p hpB hp2 hn obtain ⟨j,hj⟩ := Finset.card_pos.mp (by omega : 0 < p.card) exact (Finset.mem_sdiff.mp (hEq.symm ▸ Finset.mem_insert_of_mem hj)).2 hj have hqg : block \ q ∉ edges := fun h => hneq (hGoodUnique hp hq hpg h) have hEq := comp q hqB hq2 hqg apply Finset.disjoint_left.mpr intro a hap haq obtain ⟨has,haE⟩ := Finset.mem_filter.mp hap have hnap := (Finset.mem_sdiff.mp has).2 have haz : a = z := (Finset.mem_insert.mp (hEq ▸ (Finset.mem_filter.mp haq).1)).resolve_right hnap exact hzE (haz ▸ haE) change 2 * P.card ≤ (P.biUnion charge).card rcases (show P.card = 0 ∨ P.card = 1 ∨ P.card = 2 by omega) with h | h | h · simp [h] · obtain ⟨p,rfl⟩ := Finset.card_eq_one.mp h have hc := hCharge (Finset.mem_singleton_self p) simpa using hc · obtain ⟨p,q,hneq,rfl⟩ := Finset.card_eq_two.mp h have hp : p ∈ ({p,q} : Finset _) := by simp have hq : q ∈ ({p,q} : Finset _) := by simp have hpc := hCharge hp have hqc := hCharge hq rw [Finset.biUnion_insert, Finset.singleton_biUnion] rw [h] by_cases hc : (charge p).card < 3 · rw [Finset.card_union_of_disjoint (hSmallDisjoint hp hq hneq hc)] omega by_cases hc' : (charge q).card < 3 · rw [Finset.card_union_of_disjoint (hSmallDisjoint hq hp hneq.symm hc').symm] omega have hpB := (hData hp).1 have hqB := (hData hq).1 have hpu : p.card ≤ (p ∪ q).card := Finset.card_le_card Finset.subset_union_left have hPLT : p.card < (p ∪ q).card := by by_contra hlt have hEq := Finset.eq_of_subset_of_card_le (Finset.subset_union_left : p ⊆ p ∪ q) (by omega) have hsub : q ⊆ p := hEq ▸ Finset.subset_union_right exact hneq (Finset.eq_of_subset_of_card_le hsub (by rw [(hData hp).2.1,(hData hq).2.1])).symm have hi : charge p ∩ charge q ⊆ block \ (p ∪ q) := by intro a ha obtain ⟨ha,hb⟩ := Finset.mem_inter.mp ha have ⟨haB,hap⟩ := Finset.mem_sdiff.mp (Finset.mem_filter.mp ha).1 have haq := (Finset.mem_sdiff.mp (Finset.mem_filter.mp hb).1).2 exact Finset.mem_sdiff.mpr ⟨haB,fun h => (Finset.mem_union.mp h).elim hap haq⟩ have hib := Finset.card_le_card hi rw [Finset.card_sdiff_of_subset (Finset.union_subset hpB hqB),hb] at hib have hval := Finset.card_union_add_card_inter (charge p) (charge q) have hp2 := (hData hp).2.1 omega /-- Every pair inside an almost complete five-set has an internal common support. -/ theorem near_five_pair_has_support {n : ℕ} {edges : Finset (Finset (Fin n))} {B q : Finset (Fin n)} (hB : B.card = 5) (hm : (B.powersetCard 3 \ edges).card ≤ 1) (hq : q.card = 2) (hqB : q ⊆ B) : ∃ p ⊆ B, p ∈ localCoExtensions edges q := by classical let T := B \ q have hT : T.card = 3 := by rw [Finset.card_sdiff_of_subset hqB,hB,hq] obtain ⟨a,ha⟩ := Finset.card_pos.mp (by omega : 0 < T.card) have hTa : (T.erase a).card = 2 := by rw [Finset.card_erase_of_mem ha,hT] obtain ⟨b,hb⟩ := Finset.card_pos.mp (by omega : 0 < (T.erase a).card) obtain ⟨_,hbT⟩ := Finset.mem_erase.mp hb have hTb : (T.erase b).card = 2 := by rw [Finset.card_erase_of_mem hbT,hT] have hab : T.erase a ≠ T.erase b := fun h => Finset.notMem_erase b T (h ▸ hb) have hdisj : Disjoint T q := Finset.disjoint_left.mpr (fun _ ha hb => (Finset.mem_sdiff.mp ha).2 hb) have hd₁ := hdisj.mono_left (Finset.erase_subset a T) have hd₂ := hdisj.mono_left (Finset.erase_subset b T) have hs₁ : T.erase a ⊆ B := (Finset.erase_subset _ _).trans Finset.sdiff_subset have hs₂ : T.erase b ⊆ B := (Finset.erase_subset _ _).trans Finset.sdiff_subset rcases near_five_one_of_two_supports hm hTa hTb hab hs₁ hs₂ hqB hd₁ hd₂ with h | h · exact ⟨_,hs₁,local_mem_coextensions.mpr ⟨hTa,h⟩⟩ · exact ⟨_,hs₂,local_mem_coextensions.mpr ⟨hTb,h⟩⟩ /-- A label meeting a block and supported by a pair inside it has no common support left among triples meeting the block at most once. -/ theorem block_supported_label_absent_in_residual {n : ℕ} {edges residual : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hsub : residual ⊆ edges) {B p q : Finset (Fin n)} {z : Fin n} (hq : q.card = 2) (hpB : p ⊆ B) (hzB : z ∈ B) (hzq : z ∈ q) (hp : p ∈ localCoExtensions edges q) (hr : ∀ t ∈ residual, (t ∩ B).card ≤ 1) : localCoExtensions residual q = ∅ := by classical apply Finset.eq_empty_iff_forall_notMem.mpr intro r hres obtain ⟨hr2,hext⟩ := local_mem_coextensions.mp hres have hr' : r ∈ localCoExtensions edges q := by apply local_mem_coextensions.mpr refine ⟨hr2,?_⟩ intro w hw obtain ⟨_,hwr,hwe⟩ := Finset.mem_filter.mp (hext hw) exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hwr,hsub hwe⟩ apply local_coextension_pairwise hu hq hp hr' apply Finset.disjoint_left.mpr intro y hyp hyr obtain ⟨_,hzr,hze⟩ := Finset.mem_filter.mp (hext hzq) have hyz : y ≠ z := fun h => hzr (h ▸ hyr) have hs : ({y,z} : Finset (Fin n)) ⊆ insert z r ∩ B := by simp only [Finset.insert_subset_iff,Finset.singleton_subset_iff,Finset.mem_inter] exact ⟨⟨Finset.mem_insert_of_mem hyr,hpB hyp⟩,Finset.mem_insert_self _ _,hzB⟩ have hc := Finset.card_le_card hs rw [Finset.card_pair hyz] at hc have := hr _ hze omega /-- Each external triple supplies at least two distinct labels per triple, counted globally after grouping by the assigned block and the external tip. -/ theorem near_five_external_edge_count {n : ℕ} {edges blocks residual : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hsub : residual ⊆ edges) (hU : ∀ e ∈ edges, e.card = 3) (hB : ∀ B ∈ blocks, B.card = 5 ∧ (B.powersetCard 3 \ edges).card ≤ 1) (hR : ∀ t ∈ residual, ∀ B ∈ blocks, (t ∩ B).card ≤ 1) : 2 * (edges.filter (fun e => (∃ B ∈ blocks, 2 ≤ (e ∩ B).card) ∧ ∀ B ∈ blocks, ¬ e ⊆ B)).card ≤ (fullFiveEmptyLabels residual (fullFiveMissingPairs blocks)).card := by classical let X := edges.filter (fun e => (∃ B ∈ blocks, 2 ≤ (e ∩ B).card) ∧ ∀ B ∈ blocks, ¬ e ⊆ B) change 2 * X.card ≤ _ let rank := Fintype.equivFin (Finset (Fin n)) have data (e : Finset (Fin n)) (he : e ∈ X) : ∃ (B p : Finset (Fin n)) (x : Fin n), B ∈ blocks ∧ p ⊆ B ∧ p.card = 2 ∧ x ∉ B ∧ insert x p = e ∧ (∀ C ∈ blocks, 2 ≤ (e ∩ C).card → rank B ≤ rank C) := by obtain ⟨hE,⟨C,hC,hc⟩,hn⟩ := Finset.mem_filter.mp he obtain ⟨B,hB',hmin⟩ := Finset.exists_min_image (blocks.filter (fun B => 2 ≤ (e ∩ B).card)) rank ⟨C,Finset.mem_filter.mpr ⟨hC,hc⟩⟩ obtain ⟨hBb,hBc⟩ := Finset.mem_filter.mp hB' obtain ⟨x,hxe,hxB⟩ := Finset.not_subset.mp (hn B hBb) let p := e ∩ B have hxp : x ∉ p := fun h => hxB (Finset.mem_inter.mp h).2 have hs : insert x p ⊆ e := Finset.insert_subset hxe Finset.inter_subset_left have hc := Finset.card_le_card hs rw [Finset.card_insert_of_notMem hxp,hU _ hE] at hc have hp : p.card = 2 := by change 2 ≤ p.card at hBc; omega refine ⟨B,p,x,hBb,Finset.inter_subset_right,hp,hxB,?_,fun C hC hCc => ?_⟩ · exact Finset.eq_of_subset_of_card_le hs (by rw [Finset.card_insert_of_notMem hxp,hp,hU _ hE]) · exact hmin C (Finset.mem_filter.mpr ⟨hC,hCc⟩) let block (e : {e // e ∈ X}) := Classical.choose (data e.1 e.2) have d₁ (e : {e // e ∈ X}) := Classical.choose_spec (data e.1 e.2) let pair (e : {e // e ∈ X}) := Classical.choose (d₁ e) have d₂ (e : {e // e ∈ X}) := Classical.choose_spec (d₁ e) let tip (e : {e // e ∈ X}) := Classical.choose (d₂ e) have spec (e : {e // e ∈ X}) : block e ∈ blocks ∧ pair e ⊆ block e ∧ (pair e).card = 2 ∧ tip e ∉ block e ∧ insert (tip e) (pair e) = e.1 ∧ (∀ C ∈ blocks, 2 ≤ (e.1 ∩ C).card → rank (block e) ≤ rank C) := Classical.choose_spec (d₂ e) let group (e : {e // e ∈ X}) := (block e,tip e) let I := X.attach.image group let fiber (i : Finset (Fin n) × Fin n) := X.attach.filter (fun e => group e = i) let P (i : Finset (Fin n) × Fin n) := (fiber i).image pair let T (i : Finset (Fin n) × Fin n) := (P i).biUnion (fun p => (i.1 \ p).filter (fun z => insert z p ∈ edges)) have fiberData {i : Finset (Fin n) × Fin n} {p : Finset (Fin n)} (hp : p ∈ P i) : ∃ e : {e // e ∈ X}, group e = i ∧ pair e = p := by obtain ⟨e,he,hp⟩ := Finset.mem_image.mp hp exact ⟨e,(Finset.mem_filter.mp he).2,hp⟩ have hgroup {i : Finset (Fin n) × Fin n} (hi : i ∈ I) : i.1 ∈ blocks ∧ i.2 ∉ i.1 := by obtain ⟨e,_,rfl⟩ := Finset.mem_image.mp hi exact ⟨(spec e).1,(spec e).2.2.2.1⟩ have hP {i : Finset (Fin n) × Fin n} : P i ⊆ (i.1.powersetCard 2).filter (fun p => insert i.2 p ∈ edges) := by intro p hp obtain ⟨e,rfl,rfl⟩ := fiberData hp obtain ⟨_,hpB,hp,_,he,_⟩ := spec e exact Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨hpB,hp⟩, he ▸ (Finset.mem_filter.mp e.2).1⟩ have hPcard (i : Finset (Fin n) × Fin n) : (P i).card = (fiber i).card := by apply Finset.card_image_of_injOn intro e he f hf hef have heg := (Finset.mem_filter.mp he).2 have hfg := (Finset.mem_filter.mp hf).2 have htip : tip e = tip f := congrArg Prod.snd (heg.trans hfg.symm) apply Subtype.ext exact (spec e).2.2.2.2.1.symm.trans (by rw [htip,hef,(spec f).2.2.2.2.1]) have hcount : 2 * X.card ≤ (I.sigma T).card := by have hpart : X.card = ∑ i ∈ I, (fiber i).card := by simpa only [Finset.card_attach] using Finset.card_eq_sum_card_image group X.attach rw [hpart, Finset.mul_sum, Finset.card_sigma] apply Finset.sum_le_sum intro i hi obtain ⟨hBi,hxi⟩ := hgroup hi rw [← hPcard] exact near_five_charge_count_at_vertex hu (hB _ hBi).1 (hB _ hBi).2 hxi (P i) hP have chargeData {i : Finset (Fin n) × Fin n} {z : Fin n} (hz : z ∈ T i) : ∃ e : {e // e ∈ X}, group e = i ∧ z ∈ i.1 ∧ pair e ∈ localCoExtensions edges {i.2,z} := by obtain ⟨p,hp,hz'⟩ := Finset.mem_biUnion.mp hz obtain ⟨⟨hzB,hzp⟩,hze⟩ := Finset.mem_filter.mp hz' |>.imp_left Finset.mem_sdiff.mp obtain ⟨e,rfl,rfl⟩ := fiberData hp obtain ⟨_,hpB,hp,hxB,he,_⟩ := spec e refine ⟨e,rfl,hzB,local_mem_coextensions.mpr ⟨hp,?_⟩⟩ intro v hv rcases Finset.mem_insert.mp hv with rfl | hv · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,fun h => hxB (hpB h), he ▸ (Finset.mem_filter.mp e.2).1⟩ · obtain rfl := Finset.mem_singleton.mp hv exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,hzp,hze⟩ let f (a : Sigma (fun _ : Finset (Fin n) × Fin n => Fin n)) := ({a.1.2,a.2} : Finset (Fin n)) have hm : ∀ a ∈ I.sigma T, f a ∈ fullFiveEmptyLabels residual (fullFiveMissingPairs blocks) := by rintro ⟨i,z⟩ ha obtain ⟨hi,hz⟩ := Finset.mem_sigma.mp ha obtain ⟨e,he,hzB,hp⟩ := chargeData hz change group e = i at he subst i obtain ⟨hBe,hpB,_,hxB,_,_⟩ := spec e have hxz : tip e ≠ z := fun h => hxB (h.symm ▸ hzB) have hq : (f ⟨group e,z⟩).card = 2 := Finset.card_pair hxz apply Finset.mem_filter.mpr refine ⟨Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _,hq⟩,?_⟩,?_⟩ · intro C hC hqC have hxC := hqC (Finset.mem_insert_self _ _) have hzC := hqC (Finset.mem_insert_of_mem (Finset.mem_singleton_self _)) have hne : block e ≠ C := fun h => hxB (h ▸ hxC) have hle := near_five_blocks_inter_card_le_one hu hU (hB _ hBe).1 (hB _ hC).1 (hB _ hBe).2 (hB _ hC).2 hne obtain ⟨r,hrC,hr⟩ := near_five_pair_has_support (hB _ hC).1 (hB _ hC).2 hq hqC apply local_coextension_pairwise hu hq hp hr apply Finset.disjoint_left.mpr intro y hyp hyr have heq := Finset.card_le_one.mp hle _ (Finset.mem_inter.mpr ⟨hpB hyp,hrC hyr⟩) _ (Finset.mem_inter.mpr ⟨hzB,hzC⟩) have hzp := (Finset.mem_filter.mp ((local_mem_coextensions.mp hp).2 (Finset.mem_insert_of_mem (Finset.mem_singleton_self z)))).2.1 change y = z at heq exact hzp (heq ▸ hyp) · exact block_supported_label_absent_in_residual hu hsub hq hpB hzB (Finset.mem_insert_of_mem (Finset.mem_singleton_self z)) hp (fun t ht => hR t ht _ hBe) have hinj : Set.InjOn f (↑(I.sigma T) : Set _) := by rintro ⟨i,z⟩ ha ⟨j,w⟩ hb heq obtain ⟨e,he,hzB,hp⟩ := chargeData (Finset.mem_sigma.mp ha).2 obtain ⟨g,hg,hwC,hq⟩ := chargeData (Finset.mem_sigma.mp hb).2 change group e = i at he change group g = j at hg subst i subst j obtain ⟨hBe,hpB,_,hxB,hee,hminE⟩ := spec e obtain ⟨hCg,hqC,_,hyC,hgg,hminG⟩ := spec g change ({tip e,z} : Finset (Fin n)) = {tip g,w} at heq have hxz : tip e ≠ z := fun h => hxB (h.symm ▸ hzB) have hd : ({tip e,z} : Finset (Fin n)).card = 2 := Finset.card_pair hxz have hi : (pair e ∩ pair g).Nonempty := by rw [← Finset.not_disjoint_iff_nonempty_inter] exact local_coextension_pairwise hu hd hp (heq ▸ hq) obtain ⟨y,hy⟩ := hi obtain ⟨hyp,hyq⟩ := Finset.mem_inter.mp hy have hx := Finset.mem_insert.mp (heq ▸ Finset.mem_insert_self (tip e) ({z} : Finset (Fin n))) have hz := Finset.mem_insert.mp (heq ▸ (Finset.mem_insert_of_mem (Finset.mem_singleton_self z) : z ∈ ({tip e,z} : Finset (Fin n)))) rcases hx with hxy | hxw · have hzw := Finset.mem_singleton.mp (hz.resolve_left (fun h => hxz (hxy.trans h.symm))) have hzp := (Finset.mem_filter.mp ((local_mem_coextensions.mp hp).2 (Finset.mem_insert_of_mem (Finset.mem_singleton_self z)))).2.1 have hBC : block e = block g := by by_contra hne have hle := near_five_blocks_inter_card_le_one hu hU (hB _ hBe).1 (hB _ hCg).1 (hB _ hBe).2 (hB _ hCg).2 hne have hyz := Finset.card_le_one.mp hle _ (Finset.mem_inter.mpr ⟨hpB hyp,hqC hyq⟩) _ (Finset.mem_inter.mpr ⟨hzB,hzw ▸ hwC⟩) change y = z at hyz exact hzp (hyz ▸ hyp) have hgroupEq : group e = group g := Prod.ext hBC hxy exact congrArg₂ (fun (i : Finset (Fin n) × Fin n) (z : Fin n) => (⟨i,z⟩ : Sigma (fun _ : Finset (Fin n) × Fin n => Fin n))) hgroupEq hzw · have hxw := Finset.mem_singleton.mp hxw have hzy := hz.resolve_right (fun h => hxz (hxw.trans (Finset.mem_singleton.mp h).symm)) have cross {a : {e // e ∈ X}} {C : Finset (Fin n)} {v : Fin n} (hv : v ∈ pair a) (hvC : v ∈ C) (htC : tip a ∈ C) : 2 ≤ (a.1 ∩ C).card := by have hn : tip a ≠ v := fun h => (spec a).2.2.2.1 (h.symm ▸ (spec a).2.1 hv) have hss : ({tip a,v} : Finset (Fin n)) ⊆ a.1 ∩ C := by rw [← (spec a).2.2.2.2.1] simp only [Finset.insert_subset_iff,Finset.singleton_subset_iff,Finset.mem_inter] exact ⟨⟨Finset.mem_insert_self _ _,htC⟩,Finset.mem_insert_of_mem hv,hvC⟩ simpa only [Finset.card_pair hn] using Finset.card_le_card hss have hBC := rank.injective (le_antisymm (hminE _ hCg (cross hyp (hqC hyq) (hxw ▸ hwC))) (hminG _ hBe (cross hyq (hpB hyp) (hzy ▸ hzB)))) exact (hxB (hBC ▸ (hxw ▸ hwC))).elim exact hcount.trans (Finset.card_le_card_of_injOn f hm hinj) /-- A packing of almost complete five-sets suffices if removing triples through its pairs leaves maximum pair codegree at most five. At equality each chosen five-set must in fact be complete. -/ theorem classify_extremal_of_near_five_residual_pair_codegree_le_five {n : ℕ} {edges blocks : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hU : ∀ e ∈ edges, e.card = 3) (hE : edges.card = n.choose 2) (hB : ∀ B ∈ blocks, B.card = 5 ∧ (B.powersetCard 3 \ edges).card ≤ 1) (hD : ∀ p : Finset (Fin n), p.card = 2 → (localExtensions (fullFiveResidual edges blocks) p).card ≤ 5) : ∃ result : Finset (Finset (Fin n)), SteinerFive result ∧ IsExpansion edges result := by classical let H := fullFiveResidual edges blocks let P := fullFiveMissingPairs blocks let Z := fullFiveEmptyLabels H P let I := blocks.biUnion (fun B => B.powersetCard 3) let C := blocks.biUnion (fun B => B.powersetCard 2) let X := edges.filter (fun e => (∃ B ∈ blocks, 2 ≤ (e ∩ B).card) ∧ ∀ B ∈ blocks, ¬ e ⊆ B) have hs : H ⊆ edges := Finset.filter_subset _ _ have hr (t : Finset (Fin n)) (ht : t ∈ H) (B : Finset (Fin n)) (hBm : B ∈ blocks) : (t ∩ B).card ≤ 1 := (Finset.mem_filter.mp ht).2 B hBm have hpair (p : Finset (Fin n)) (hp : p.card = 2) (hpos : 0 < (localExtensions H p).card) : p ∈ P := by obtain ⟨x,hx⟩ := Finset.card_pos.mp hpos apply Finset.mem_filter.mpr refine ⟨by simp [hp],?_⟩ intro B hBm hpB have he := (Finset.mem_filter.mp hx).2.2 have hle := hr _ he B hBm have hc := Finset.card_le_card (Finset.subset_inter (Finset.subset_insert x p) hpB) omega have hlabel (p : Finset (Fin n)) (hp : p.card = 2) (hpos : 0 < (localCoExtensions H p).card) : p ∈ P := by apply Finset.mem_filter.mpr refine ⟨by simp [hp],?_⟩ intro B hBm hpB obtain ⟨q,hqB,hq⟩ := near_five_pair_has_support (hB _ hBm).1 (hB _ hBm).2 hp hpB obtain ⟨z,hz⟩ := Finset.card_pos.mp (by omega : 0 < p.card) have hempty := block_supported_label_absent_in_residual hu hs hp hqB (hpB hz) hz hq (fun t ht => hr t ht _ hBm) rw [hempty] at hpos simp at hpos have hUnique : UniqueDisjointUnions H := fun A hA B hB C hC D hD => hu A (hs hA) B (hs hB) C (hs hC) D (hs hD) have hWeight : 2 * H.card + Z.card ≤ 2 * P.card := by simpa only [Z,fullFiveEmptyLabels, Finset.card_eq_zero] using residual_triple_bound_of_codegrees_le_five H P hUnique (fun e he => hU _ (hs he)) (fun x a hxa => hD {x,a} (by simp [hxa])) hpair hlabel have hx : 2 * X.card ≤ Z.card := near_five_external_edge_count hu hs hU hB hr have hdisj (k : ℕ) (hk : 2 ≤ k) : (↑blocks : Set (Finset (Fin n))).PairwiseDisjoint (fun B => B.powersetCard k) := by intro B hBm D hDm hne apply Finset.disjoint_left.mpr intro p hpB hpD obtain ⟨hsB,hp⟩ := Finset.mem_powersetCard.mp hpB have hsD := (Finset.mem_powersetCard.mp hpD).1 have hle := near_five_blocks_inter_card_le_one hu hU (hB _ hBm).1 (hB _ hDm).1 (hB _ hBm).2 (hB _ hDm).2 hne have hc := Finset.card_le_card (Finset.subset_inter hsB hsD) omega have hIC : I.card = C.card := by change (blocks.biUnion (fun B => B.powersetCard 3)).card = (blocks.biUnion (fun B => B.powersetCard 2)).card rw [Finset.card_biUnion (hdisj 3 (by decide)), Finset.card_biUnion (hdisj 2 (by decide))] apply Finset.sum_congr rfl intro B hBm rw [Finset.card_powersetCard,Finset.card_powersetCard,(hB _ hBm).1] decide let allPairs := (Finset.univ : Finset (Fin n)).powersetCard 2 have hC : C ⊆ allPairs := by intro p hp obtain ⟨B,_,hpB⟩ := Finset.mem_biUnion.mp hp exact Finset.mem_powersetCard.mpr ⟨Finset.subset_univ _,(Finset.mem_powersetCard.mp hpB).2⟩ have hP : P = allPairs \ C := by ext p constructor · intro h obtain ⟨hp,hn⟩ := Finset.mem_filter.mp h refine Finset.mem_sdiff.mpr ⟨hp,?_⟩ rintro hm obtain ⟨B,hB,hpB⟩ := Finset.mem_biUnion.mp hm exact hn B hB (Finset.mem_powersetCard.mp hpB).1 · intro h obtain ⟨hp,hn⟩ := Finset.mem_sdiff.mp h exact Finset.mem_filter.mpr ⟨hp,fun B hBm hpB => hn (Finset.mem_biUnion.mpr ⟨B,hBm,Finset.mem_powersetCard.mpr ⟨hpB,(Finset.mem_powersetCard.mp hp).2⟩⟩)⟩ have hPcard : P.card + C.card = n.choose 2 := by rw [hP,Finset.card_sdiff_add_card_eq_card hC] simp [allPairs] have hcover : edges ⊆ (I ∩ edges) ∪ X ∪ H := by intro e he by_cases hi : e ∈ I · exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_inter.mpr ⟨hi,he⟩)) have hn (B : Finset (Fin n)) (hBm : B ∈ blocks) : ¬ e ⊆ B := fun h => hi (Finset.mem_biUnion.mpr ⟨B,hBm,Finset.mem_powersetCard.mpr ⟨h,hU _ he⟩⟩) by_cases hb : ∃ B ∈ blocks, 2 ≤ (e ∩ B).card · exact Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨he,hb,hn⟩)) · exact Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨he,fun B hBm => by by_contra hh exact hb ⟨B,hBm,by omega⟩⟩) have htotal : edges.card ≤ (I ∩ edges).card + X.card + H.card := by have h := Finset.card_le_card hcover have h₁ := Finset.card_union_le ((I ∩ edges) ∪ X) H have h₂ := Finset.card_union_le (I ∩ edges) X omega have hI : I ⊆ edges := by have hEq : I ∩ edges = I := Finset.eq_of_subset_of_card_le Finset.inter_subset_left (by omega) exact hEq ▸ Finset.inter_subset_right apply classify_extremal_of_residual_pair_codegree_le_five hu hU hE _ hD intro B hBm exact ⟨(hB _ hBm).1,fun t ht htB => hI (Finset.mem_biUnion.mpr ⟨B,hBm,Finset.mem_powersetCard.mpr ⟨htB,ht⟩⟩)⟩ noncomputable def centeredLabels {n : ℕ} (x : Fin n) (H : Finset (Finset (Fin n))) : Finset (Finset (Fin n)) := by classical exact (Finset.univ.powersetCard 2).filter fun q => ∃ p : Finset (Fin n), p.card = 2 ∧ x ∈ p ∧ Disjoint p q ∧ ∀ y ∈ q, insert y p ∈ H theorem centered_labels_mem {n : ℕ} {x : Fin n} {H : Finset (Finset (Fin n))} {q : Finset (Fin n)} : q ∈ centeredLabels x H ↔ q.card = 2 ∧ ∃ p : Finset (Fin n), p.card = 2 ∧ x ∈ p ∧ Disjoint p q ∧ ∀ y ∈ q, insert y p ∈ H := by classical simp [centeredLabels, Finset.mem_powersetCard] theorem star_gluing_label_count {n : ℕ} (x : Fin n) (L R : Finset (Finset (Fin n))) (hU : UniqueDisjointUnions (L ∪ R)) (hStar : ∀ p ∈ matchingShadow L ∩ matchingShadow R, x ∈ p) : (matchingLabels (L ∪ R)).card + (centeredLabels x L).card + (centeredLabels x R).card = (centeredLabels x (L ∪ R)).card + (matchingLabels L).card + (matchingLabels R).card := by classical have hCenter {H : Finset (Finset (Fin n))} : centeredLabels x H ⊆ matchingLabels H := by intro q hq obtain ⟨hc, p, hp, _, hdis, hw⟩ := centered_labels_mem.mp hq exact matching_labels_mem.mpr ⟨hc,p,hp,hdis,hw⟩ have labelsMono {H K : Finset (Finset (Fin n))} (hHK : H ⊆ K) : matchingLabels H ⊆ matchingLabels K := by intro q hq obtain ⟨hc,p,hc',hd,hw⟩ := matching_labels_mem.mp hq exact matching_labels_mem.mpr ⟨hc,p,hc',hd,fun _ hz => hHK (hw _ hz)⟩ have sharedBase {p : Finset (Fin n)} {a b : Fin n} (hp : p.card = 2) (ha : insert a p ∈ L) (hb : insert b p ∈ R) : x ∈ p := hStar p (Finset.mem_inter.mpr ⟨ matching_shadow_mem.mpr ⟨hp,_,ha,Finset.subset_insert _ _⟩, matching_shadow_mem.mpr ⟨hp,_,hb,Finset.subset_insert _ _⟩⟩) have sharedAt {p r q : Finset (Fin n)} {w z : Fin n} (hwp : w ∈ p) (hwr : w ∈ r) (hz : z ∈ q) (hpq : Disjoint p q) (hL : insert z p ∈ L) (hR : insert z r ∈ R) : x = z ∨ x = w := by have hzw : z ≠ w := fun h => Finset.disjoint_left.mp hpq hwp (h ▸ hz) have pairCard : ({z,w} : Finset (Fin n)).card = 2 := by simp [hzw] have subL : ({z,w} : Finset (Fin n)) ⊆ insert z p := by simp [Finset.insert_subset_iff, hwp] have subR : ({z,w} : Finset (Fin n)) ⊆ insert z r := by simp [Finset.insert_subset_iff, hwr] have hx := hStar {z,w} (Finset.mem_inter.mpr ⟨ matching_shadow_mem.mpr ⟨pairCard, _, hL, subL⟩, matching_shadow_mem.mpr ⟨pairCard, _, hR, subR⟩⟩) simpa using hx have meet {p r q : Finset (Fin n)} (hp : p.card = 2) (hq : q.card = 2) (hpq : Disjoint p q) (hrq : Disjoint r q) (hP : ∀ z ∈ q, insert z p ∈ L ∪ R) (hR : ∀ z ∈ q, insert z r ∈ L ∪ R) : ∃ w, w ∈ p ∧ w ∈ r := by by_contra! hn exact matching_supports_intersect hU hp hq hpq hrq hP hR (Finset.disjoint_left.mpr hn) let AL := matchingLabels L \ centeredLabels x L let AR := matchingLabels R \ centeredLabels x R let CU := centeredLabels x (L ∪ R) have disjLR : Disjoint AL AR := by rw [Finset.disjoint_left] intro q hqL hqR obtain ⟨hoL, hnL⟩ := Finset.mem_sdiff.mp hqL obtain ⟨hoR, _⟩ := Finset.mem_sdiff.mp hqR obtain ⟨hc, p, hp, hpq, hL⟩ := matching_labels_mem.mp hoL obtain ⟨_, r, _, hrq, hR⟩ := matching_labels_mem.mp hoR obtain ⟨w, hwp, hwr⟩ := meet hp hc hpq hrq (fun z hz => Finset.mem_union_left _ (hL z hz)) (fun z hz => Finset.mem_union_right _ (hR z hz)) have hx : x = w := by by_contra hx obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hc have ha : a ∈ ({a,b} : Finset (Fin n)) := by simp have hb : b ∈ ({a,b} : Finset (Fin n)) := by simp exact hab (((sharedAt hwp hwr ha hpq (hL a ha) (hR a ha)).resolve_right hx).symm.trans ((sharedAt hwp hwr hb hpq (hL b hb) (hR b hb)).resolve_right hx)) exact hnL (centered_labels_mem.mpr ⟨hc,p,hp,hx.symm ▸ hwp,hpq,hL⟩) have disjCL : Disjoint CU AL := by rw [Finset.disjoint_left] intro q hqC hqA obtain ⟨hoL, hnL⟩ := Finset.mem_sdiff.mp hqA obtain ⟨hc, r, hr, hx, hrq, hR⟩ := centered_labels_mem.mp hqC obtain ⟨_, p, hp, hpq, hL⟩ := matching_labels_mem.mp hoL obtain ⟨z,hz,hzL⟩ : ∃ z ∈ q, insert z r ∉ L := by by_contra! hn exact hnL (centered_labels_mem.mpr ⟨hc,r,hr,hx,hrq,hn⟩) have hzR := (Finset.mem_union.mp (hR z hz)).resolve_left hzL obtain ⟨w,hwp,hwr⟩ := meet hp hc hpq hrq (fun y hy => Finset.mem_union_left _ (hL y hy)) hR have hxw := (sharedAt hwp hwr hz hpq (hL z hz) hzR).resolve_left (fun h => Finset.disjoint_left.mp hrq hx (h.symm ▸ hz)) exact hnL (centered_labels_mem.mpr ⟨hc,p,hp,hxw.symm ▸ hwp,hpq,hL⟩) have disjCR : Disjoint CU AR := by rw [Finset.disjoint_left] intro q hqC hqA obtain ⟨hoR, hnR⟩ := Finset.mem_sdiff.mp hqA obtain ⟨hc, p, hp, hx, hpq, hL⟩ := centered_labels_mem.mp hqC obtain ⟨_, r, hr, hrq, hR⟩ := matching_labels_mem.mp hoR obtain ⟨z,hz,hzR⟩ : ∃ z ∈ q, insert z p ∉ R := by by_contra! hn exact hnR (centered_labels_mem.mpr ⟨hc,p,hp,hx,hpq,hn⟩) have hzL := (Finset.mem_union.mp (hL z hz)).resolve_right hzR obtain ⟨w,hwp,hwr⟩ := meet hp hc hpq hrq hL (fun y hy => Finset.mem_union_right _ (hR y hy)) have hxw := (sharedAt hwp hwr hz hpq hzL (hR z hz)).resolve_left (fun h => Finset.disjoint_left.mp hpq hx (h.symm ▸ hz)) exact hnR (centered_labels_mem.mpr ⟨hc,r,hr, hxw.symm ▸ hwr,hrq,hR⟩) have hCover : matchingLabels (L ∪ R) = CU ∪ (AL ∪ AR) := by ext q constructor · intro hq by_cases hC : q ∈ CU · exact Finset.mem_union_left _ hC obtain ⟨hc,p,hp,hpq,hw⟩ := matching_labels_mem.mp hq by_cases hL : ∀ y ∈ q, insert y p ∈ L · refine Finset.mem_union_right _ (Finset.mem_union_left _ (Finset.mem_sdiff.mpr ⟨ matching_labels_mem.mpr ⟨hc,p,hp,hpq,hL⟩,?_⟩)) intro h obtain ⟨hc',r,hr,hx,hrq,hR⟩ := centered_labels_mem.mp h exact hC (centered_labels_mem.mpr ⟨hc',r,hr,hx,hrq, fun y hy => Finset.mem_union_left _ (hR y hy)⟩) by_cases hR : ∀ y ∈ q, insert y p ∈ R · refine Finset.mem_union_right _ (Finset.mem_union_right _ (Finset.mem_sdiff.mpr ⟨ matching_labels_mem.mpr ⟨hc,p,hp,hpq,hR⟩,?_⟩)) intro h obtain ⟨hc',r,hr,hx,hrq,hR'⟩ := centered_labels_mem.mp h exact hC (centered_labels_mem.mpr ⟨hc',r,hr,hx,hrq, fun y hy => Finset.mem_union_right _ (hR' y hy)⟩) push Not at hL hR obtain ⟨a,ha,haR⟩ := hR obtain ⟨b,hb,hbL⟩ := hL have hx := sharedBase hp ((Finset.mem_union.mp (hw a ha)).resolve_right haR) ((Finset.mem_union.mp (hw b hb)).resolve_left hbL) exact (hC (centered_labels_mem.mpr ⟨hc,p,hp,hx,hpq,hw⟩)).elim · intro hq rcases Finset.mem_union.mp hq with h | h · exact hCenter h rcases Finset.mem_union.mp h with h | h · exact labelsMono (fun _ hz => Finset.mem_union_left _ hz) (Finset.mem_sdiff.mp h).1 · exact labelsMono (fun _ hz => Finset.mem_union_right _ hz) (Finset.mem_sdiff.mp h).1 rw [hCover, Finset.card_union_of_disjoint (Finset.disjoint_union_right.mpr ⟨disjCL,disjCR⟩), Finset.card_union_of_disjoint disjLR] have hL := Finset.card_sdiff_add_card_eq_card (hCenter (H := L)) have hR := Finset.card_sdiff_add_card_eq_card (hCenter (H := R)) change AL.card + (centeredLabels x L).card = (matchingLabels L).card at hL change AR.card + (centeredLabels x R).card = (matchingLabels R).card at hR change CU.card + (AL.card + AR.card) + (centeredLabels x L).card + (centeredLabels x R).card = CU.card + (matchingLabels L).card + (matchingLabels R).card omega theorem disjoint_anchor_tip_unique {n : ℕ} {H : Finset (Finset (Fin n))} (hU : UniqueDisjointUnions H) {A P T : Finset (Fin n)} (hA : A.card = 2) (hAP : Disjoint A P) (hAT : Disjoint A T) (hT : ∀ v ∈ T, insert v A ∈ H) {x y : Fin n} (hx : x ∈ T) (hy : y ∈ T) (hxP : x ∉ P) (hyP : y ∉ P) (hPx : insert x P ∈ H) (hPy : insert y P ∈ H) : x = y := by by_contra hxy have hcard : ({x, y} : Finset (Fin n)).card = 2 := by simp [hxy] have hAxy : Disjoint A ({x, y} : Finset (Fin n)) := Finset.disjoint_of_subset_right (by intro z hz rcases Finset.mem_insert.mp hz with rfl | hz · exact hx · have hzy := Finset.mem_singleton.mp hz simpa [hzy] using hy) hAT have hPxy : Disjoint P ({x, y} : Finset (Fin n)) := by simp [Finset.disjoint_insert_right, Finset.disjoint_singleton_right, hxP, hyP] exact matching_supports_intersect hU hA hcard hAxy hPxy (by simpa using And.intro (hT x hx) (hT y hy)) (by simpa using And.intro hPx hPy) hAP theorem anchor_tip_induced_card_bound {n : ℕ} {H : Finset (Finset (Fin n))} (hUniform : ∀ e ∈ H, e.card = 3) (hU : UniqueDisjointUnions H) {A T : Finset (Fin n)} (hA : A.card = 2) (hAT : Disjoint A T) (hT : ∀ v ∈ T, insert v A ∈ H) : 3 * (H.filter (· ⊆ T)).card ≤ T.card.choose 2 := by classical let D := H.filter (· ⊆ T) let P := D.biUnion fun e => e.powersetCard 2 have hD {e} (he : e ∈ D) : e ∈ H ∧ e ⊆ T := Finset.mem_filter.mp he have hPairwise : (D : Set (Finset (Fin n))).PairwiseDisjoint (fun e => e.powersetCard 2) := by intro e he f hf hne change e ∈ D at he change f ∈ D at hf change Disjoint (e.powersetCard 2) (f.powersetCard 2) rw [Finset.disjoint_left] intro p hp hf' obtain ⟨hpe, hpc⟩ := Finset.mem_powersetCard.mp hp obtain ⟨hpf, _⟩ := Finset.mem_powersetCard.mp hf' have hsplit {g} (hg : g ∈ D) (hpg : p ⊆ g) : ∃ x, x ∈ T ∧ x ∉ p ∧ g = insert x p := by have hcard : (g \ p).card = 1 := by rw [Finset.card_sdiff_of_subset hpg, hUniform g (hD hg).1, hpc] obtain ⟨x, hxs⟩ := Finset.card_eq_one.mp hcard have hx : x ∈ g \ p := by rw [hxs]; simp obtain ⟨hxg, hxp⟩ := Finset.mem_sdiff.mp hx refine ⟨x, (hD hg).2 hxg, hxp, ?_⟩ rw [← Finset.singleton_union, ← hxs, Finset.sdiff_union_of_subset hpg] obtain ⟨x, hxT, hxp, hex⟩ := hsplit he hpe obtain ⟨y, hyT, hyp, hfy⟩ := hsplit hf hpf have he' : insert x p ∈ H := hex ▸ (hD he).1 have hf'' : insert y p ∈ H := hfy ▸ (hD hf).1 have hAP : Disjoint A p := Finset.disjoint_of_subset_right (hpe.trans (hD he).2) hAT have hxy := disjoint_anchor_tip_unique hU hA hAP hAT hT hxT hyT hxp hyp he' hf'' exact hne (by rw [hex, hfy, hxy]) have hPsub : P ⊆ T.powersetCard 2 := by intro p hp obtain ⟨e, he, hpe⟩ := Finset.mem_biUnion.mp hp obtain ⟨hpes, hpec⟩ := Finset.mem_powersetCard.mp hpe exact Finset.mem_powersetCard.mpr ⟨hpes.trans (hD he).2, hpec⟩ have hPcard : P.card = 3 * D.card := by rw [Finset.card_biUnion hPairwise] calc (∑ e ∈ D, (e.powersetCard 2).card) = ∑ _e ∈ D, 3 := by apply Finset.sum_congr rfl intro e he rw [Finset.card_powersetCard, hUniform e (hD he).1] decide _ = 3 * D.card := by simp [Nat.mul_comm] simpa [hPcard, Finset.card_powersetCard] using Finset.card_le_card hPsub /-- Edges avoiding an anchor and using exactly k of its tips consume k distinct pairs, each with k-1 tips and 3-k non-tips. -/ theorem anchor_tip_layer_bound {n k : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) (hU : ∀ e ∈ H, e.card = 3) {A T W : Finset (Fin n)} (hA : A.card = 2) (hAT : Disjoint A T) (hAW : Disjoint A W) (hTW : Disjoint T W) (hT : ∀ v ∈ T, insert v A ∈ H) : k * (H.filter (fun e => e ⊆ T ∪ W ∧ (e ∩ T).card = k)).card ≤ T.card.choose (k - 1) * W.card.choose (3 - k) := by classical let E := H.filter (fun e => e ⊆ T ∪ W ∧ (e ∩ T).card = k) let D := E.sigma (fun e => e ∩ T) let P := (T.powersetCard (k - 1)) ×ˢ (W.powersetCard (3 - k)) let f (a : Sigma (fun _ : Finset (Fin n) => Fin n)) := ((a.1.erase a.2) ∩ T, (a.1.erase a.2) ∩ W) have hD : D.card = k * E.card := by rw [Finset.card_sigma] calc _ = ∑ _ ∈ E, k := Finset.sum_congr rfl (fun e he => (Finset.mem_filter.mp he).2.2) _ = _ := by simp [Nat.mul_comm] have hP : P.card = T.card.choose (k - 1) * W.card.choose (3 - k) := by simp [P] have hsplit {e : Finset (Fin n)} (he : e ⊆ T ∪ W) : e ∩ T ∪ e ∩ W = e := by rw [← Finset.inter_union_distrib_left,Finset.inter_eq_left.mpr he] have hdisj (e : Finset (Fin n)) : Disjoint (e ∩ T) (e ∩ W) := hTW.mono Finset.inter_subset_right Finset.inter_subset_right have hmap : ∀ a ∈ D, f a ∈ P := by rintro ⟨e,v⟩ h obtain ⟨he,hv⟩ := Finset.mem_sigma.mp h change e ∈ E at he change v ∈ e ∩ T at hv obtain ⟨heH,heTW,heT⟩ := Finset.mem_filter.mp he obtain ⟨hve,hvT⟩ := Finset.mem_inter.mp hv have hvW : v ∉ W := fun h => Finset.disjoint_left.mp hTW hvT h have heW : (e ∩ W).card = 3 - k := by have hs := Finset.card_union_of_disjoint (hdisj e) rw [hsplit heTW,hU e heH,heT] at hs omega have heqT : e.erase v ∩ T = (e ∩ T).erase v := by ext x simp only [Finset.mem_inter,Finset.mem_erase] tauto have heqW : e.erase v ∩ W = e ∩ W := by ext x simp only [Finset.mem_inter,Finset.mem_erase] constructor · tauto · rintro ⟨hxe,hxW⟩ exact ⟨⟨fun h => hvW (h ▸ hxW),hxe⟩,hxW⟩ apply Finset.mem_product.mpr constructor · apply Finset.mem_powersetCard.mpr refine ⟨Finset.inter_subset_right,?_⟩ change (e.erase v ∩ T).card = _ rw [heqT,Finset.card_erase_of_mem hv,heT] · apply Finset.mem_powersetCard.mpr refine ⟨Finset.inter_subset_right,?_⟩ change (e.erase v ∩ W).card = _ rw [heqW,heW] have hinj : Set.InjOn f (↑D : Set _) := by rintro ⟨e,x⟩ hx ⟨g,y⟩ hy hEq obtain ⟨he,hx⟩ := Finset.mem_sigma.mp hx obtain ⟨hg,hy⟩ := Finset.mem_sigma.mp hy change e ∈ E at he change g ∈ E at hg change x ∈ e ∩ T at hx change y ∈ g ∩ T at hy obtain ⟨heH,heTW,_⟩ := Finset.mem_filter.mp he obtain ⟨hgH,hgTW,_⟩ := Finset.mem_filter.mp hg obtain ⟨hxe,hxT⟩ := Finset.mem_inter.mp hx obtain ⟨hyg,hyT⟩ := Finset.mem_inter.mp hy have hese : e.erase x ⊆ T ∪ W := (Finset.erase_subset _ _).trans heTW have hgse : g.erase y ⊆ T ∪ W := (Finset.erase_subset _ _).trans hgTW have hBase : e.erase x = g.erase y := by rw [← hsplit hese,← hsplit hgse, show e.erase x ∩ T = g.erase y ∩ T from congrArg Prod.fst hEq, show e.erase x ∩ W = g.erase y ∩ W from congrArg Prod.snd hEq] have hAP : Disjoint A (e.erase x) := (Finset.disjoint_union_right.mpr ⟨hAT,hAW⟩).mono_right hese have hxe' : insert x (e.erase x) = e := Finset.insert_erase hxe have hyg' : insert y (g.erase y) = g := Finset.insert_erase hyg have hxy := disjoint_anchor_tip_unique hu hA hAP hAT hT hxT hyT (Finset.notMem_erase _ _) (by rw [hBase]; exact Finset.notMem_erase _ _) (by rw [hxe']; exact heH) (by rw [hBase,hyg']; exact hgH) have heg : e = g := hxe'.symm.trans ((congrArg₂ insert hxy hBase).trans hyg') exact congrArg₂ (fun (s : Finset (Fin n)) (v : Fin n) => (⟨s,v⟩ : Sigma (fun _ : Finset (Fin n) => Fin n))) heg hxy rw [← hD,← hP] exact Finset.card_le_card_of_injOn f hmap hinj /-- On the common spokes of a center, the union of the two anchor links has no two adjacent edges. This does not require the anchor to be saturated. -/ theorem anchor_common_spokes_forbid_adjacent_union_edges {n : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) {a b c x y z : Fin n} (hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) (hxy : x ≠ y) (hxz : x ≠ z) (hyz : y ≠ z) (hx : x ∈ localExtensions H {a,c} ∩ localExtensions H {b,c}) (hy : y ∈ localExtensions H {a,c} ∩ localExtensions H {b,c}) (hz : z ∈ localExtensions H {a,c} ∩ localExtensions H {b,c}) (h₁ : insert a ({x,y} : Finset (Fin n)) ∈ H ∨ insert b {x,y} ∈ H) (h₂ : insert a ({x,z} : Finset (Fin n)) ∈ H ∨ insert b {x,z} ∈ H) : False := by set_option maxHeartbeats 2000000 in exact (by classical have info {t : Fin n} (ht : t ∈ localExtensions H {a,c} ∩ localExtensions H {b,c}) : t ≠ a ∧ t ≠ b ∧ t ≠ c ∧ insert c ({a,t} : Finset (Fin n)) ∈ H ∧ insert c ({b,t} : Finset (Fin n)) ∈ H := by obtain ⟨hA,hB⟩ := Finset.mem_inter.mp ht obtain ⟨_,hnotA,hAe⟩ := Finset.mem_filter.mp hA obtain ⟨_,hnotB,hBe⟩ := Finset.mem_filter.mp hB have heq (r : Fin n) : insert c ({r,t} : Finset (Fin n)) = insert t {r,c} := by ext v simp only [Finset.mem_insert,Finset.mem_singleton,or_assoc,or_left_comm,or_comm] refine ⟨fun h => hnotA (by simp [h]), fun h => hnotB (by simp [h]), fun h => hnotA (by simp [h]), ?_, ?_⟩ · rw [heq] exact hAe · rw [heq] exact hBe obtain ⟨hxa,hxb,hxc,_,_⟩ := info hx obtain ⟨hya,hyb,hyc,hay,hby⟩ := info hy obtain ⟨hza,hzb,hzc,haz,hbz⟩ := info hz have collision {i j k l : Fin n} (hi : i ∈ ({a,b} : Finset (Fin n))) (hj : j ∈ ({a,b} : Finset (Fin n))) (hk : k ∈ ({a,b} : Finset (Fin n))) (hl : l ∈ ({a,b} : Finset (Fin n))) (hij : i ≠ j) (hkl : k ≠ l) (hA : insert i ({x,y} : Finset (Fin n)) ∈ H) (hB : insert c ({j,z} : Finset (Fin n)) ∈ H) (hC : insert k ({x,z} : Finset (Fin n)) ∈ H) (hD : insert c ({l,y} : Finset (Fin n)) ∈ H) : False := by have data {t : Fin n} (ht : t ∈ ({a,b} : Finset (Fin n))) : t ≠ c ∧ t ≠ x ∧ t ≠ y ∧ t ≠ z := by simp only [Finset.mem_insert,Finset.mem_singleton] at ht rcases ht with rfl | rfl · exact ⟨hac,hxa.symm,hya.symm,hza.symm⟩ · exact ⟨hbc,hxb.symm,hyb.symm,hzb.symm⟩ obtain ⟨hic,hix,hiy,hiz⟩ := data hi obtain ⟨hjc,hjx,hjy,hjz⟩ := data hj obtain ⟨hkc,hkx,hky,hkz⟩ := data hk obtain ⟨hlc,hlx,hly,hlz⟩ := data hl have hd₁ : Disjoint (insert i ({x,y} : Finset (Fin n))) (insert c ({j,z} : Finset (Fin n))) := by simp [Finset.disjoint_insert_left,Finset.disjoint_insert_right, hij.symm,hic.symm,hiz.symm,hxc.symm,hjx,hxz.symm,hyc.symm,hjy,hyz.symm] have hd₂ : Disjoint (insert k ({x,z} : Finset (Fin n))) (insert c ({l,y} : Finset (Fin n))) := by simp [Finset.disjoint_insert_left,Finset.disjoint_insert_right, hkl.symm,hkc.symm,hky.symm,hxc.symm,hlx,hxy.symm,hzc.symm,hlz,hyz] have hp₁ : ({i,j} : Finset (Fin n)) = {a,b} := Finset.eq_of_subset_of_card_le (Finset.insert_subset hi (Finset.singleton_subset_iff.mpr hj)) (by simp [hab,hij]) have hp₂ : ({k,l} : Finset (Fin n)) = {a,b} := Finset.eq_of_subset_of_card_le (Finset.insert_subset hk (Finset.singleton_subset_iff.mpr hl)) (by simp [hab,hkl]) have hun : insert i ({x,y} : Finset (Fin n)) ∪ insert c {j,z} = insert k {x,z} ∪ insert c {l,y} := by have rearrange (r s p q : Fin n) : insert r ({x,p} : Finset (Fin n)) ∪ insert c {s,q} = ({r,s} : Finset (Fin n)) ∪ {x,c,p,q} := by ext v simp only [Finset.mem_union,Finset.mem_insert,Finset.mem_singleton,or_assoc,or_left_comm,or_comm] calc _ = ({i,j} : Finset (Fin n)) ∪ {x,c,y,z} := rearrange i j y z _ = ({k,l} : Finset (Fin n)) ∪ {x,c,z,y} := by rw [hp₁,hp₂] ext v simp only [Finset.mem_union,Finset.mem_insert,Finset.mem_singleton,or_assoc,or_left_comm,or_comm] _ = _ := (rearrange k l z y).symm rcases hu _ hA _ hB _ hC _ hD hd₁ hd₂ hun with h | h · have hh : y ∈ insert k ({x,z} : Finset (Fin n)) := h.1 ▸ Finset.mem_insert_of_mem (Finset.mem_insert_of_mem (Finset.mem_singleton_self y)) simpa [hky.symm,hxy.symm,hyz] using hh · have hh : x ∈ insert c ({l,y} : Finset (Fin n)) := h.1 ▸ Finset.mem_insert_of_mem (Finset.mem_insert_self x {y}) simpa [hxc,hlx.symm,hxy] using hh have ha : a ∈ ({a,b} : Finset (Fin n)) := by simp have hb : b ∈ ({a,b} : Finset (Fin n)) := by simp rcases h₁ with h₁ | h₁ <;> rcases h₂ with h₂ | h₂ · exact collision ha hb ha hb hab hab h₁ hbz h₂ hby · exact collision ha hb hb ha hab hab.symm h₁ hbz h₂ hay · exact collision hb ha ha hb hab.symm hab h₁ haz h₂ hby · exact collision hb ha hb ha hab.symm hab.symm h₁ haz h₂ hay) /-- The common spokes leave at most half their size in pairs covered by the union of the anchor links. -/ theorem anchor_link_union_card_on_common_spokes {n : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) {a b c : Fin n} (hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) (S : Finset (Fin n)) (hS : S ⊆ localExtensions H {a,c} ∩ localExtensions H {b,c}) : 2 * ((S.powersetCard 2).filter (fun p => insert a p ∈ H ∨ insert b p ∈ H)).card ≤ S.card := by classical let P := (S.powersetCard 2).filter (fun p => insert a p ∈ H ∨ insert b p ∈ H) change 2 * P.card ≤ _ have aux {p : Finset (Fin n)} (hp : p ∈ P) : p ⊆ S ∧ p.card = 2 ∧ (insert a p ∈ H ∨ insert b p ∈ H) := by obtain ⟨hm,hE⟩ := Finset.mem_filter.mp hp exact ⟨(Finset.mem_powersetCard.mp hm).1,(Finset.mem_powersetCard.mp hm).2,hE⟩ have hdisj : (↑P : Set (Finset (Fin n))).PairwiseDisjoint id := by intro p hp r hr hne change p ∈ P at hp change r ∈ P at hr change Disjoint p r apply Finset.disjoint_left.mpr intro x hxp hxr obtain ⟨hpS,hp,hpE⟩ := aux hp obtain ⟨hrS,hr,hrE⟩ := aux hr have rep {q : Finset (Fin n)} (hq : q.card = 2) (hx : x ∈ q) : ∃ y, x ≠ y ∧ q = {x,y} := by obtain ⟨u,v,huv,rfl⟩ := Finset.card_eq_two.mp hq simp only [Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl · exact ⟨v,huv,rfl⟩ · exact ⟨u,huv.symm,Finset.pair_comm _ _⟩ obtain ⟨y,hxy,rfl⟩ := rep hp hxp obtain ⟨z,hxz,rfl⟩ := rep hr hxr have hyz : y ≠ z := fun h => hne (by rw [h]) exact anchor_common_spokes_forbid_adjacent_union_edges hu hab hac hbc hxy hxz hyz (hS (hpS (by simp))) (hS (hpS (by simp))) (hS (hrS (by simp))) hpE hrE have hCard : (P.biUnion id).card = 2 * P.card := by rw [Finset.card_biUnion hdisj] calc _ = ∑ _ ∈ P, (2 : ℕ) := Finset.sum_congr rfl (fun p hp => (aux hp).2.1) _ = _ := by simp [Nat.mul_comm] rw [← hCard] apply Finset.card_le_card intro x hx obtain ⟨p,hp,hxp⟩ := Finset.mem_biUnion.mp hx exact (aux hp).1 hxp /-- A common link with at least four supports forces many missing pairs from the union of the two anchor links. -/ theorem anchor_common_link_missing_witness {n : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) {a b : Fin n} (hab : a ≠ b) (T : Finset (Fin n)) (haT : a ∉ T) (hbT : b ∉ T) : ∀ j : ℕ, j = ((T.powersetCard 2).filter (fun p => insert a p ∈ H ∧ insert b p ∈ H)).card → 4 ≤ j → ∃ S : Finset (Fin n), S ⊆ T ∧ S.card = j ∧ 2 * j.choose 2 ≤ 2 * ((S.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card + j := by classical let P := T.powersetCard 2 let L := P.filter (fun p => insert a p ∈ H) let R := P.filter (fun p => insert b p ∈ H) let J := L ∩ R have hJeq : J = P.filter (fun p => insert a p ∈ H ∧ insert b p ∈ H) := by ext p simp only [J,L,R,Finset.mem_filter,Finset.mem_inter] tauto intro j hj hlarge rw [← hJeq] at hj subst j have hsmall : ¬ J.card ≤ 3 := by omega have hJ {p : Finset (Fin n)} (hp : p ∈ J) : p ⊆ T ∧ p.card = 2 ∧ insert a p ∈ H ∧ insert b p ∈ H := by obtain ⟨hl,hr⟩ := Finset.mem_inter.mp hp obtain ⟨hs,hA⟩ := Finset.mem_filter.mp hl obtain ⟨hsub,hcard⟩ := Finset.mem_powersetCard.mp hs exact ⟨hsub,hcard,hA,(Finset.mem_filter.mp hr).2⟩ have hCo {p : Finset (Fin n)} (hp : p ∈ J) : p ∈ localCoExtensions H {a,b} := by obtain ⟨hpT,hp2,hpa,hpb⟩ := hJ hp apply local_mem_coextensions.mpr refine ⟨hp2,?_⟩ intro t ht rcases Finset.mem_insert.mp ht with rfl | ht · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,fun h => haT (hpT h),hpa⟩ · obtain rfl := Finset.mem_singleton.mp ht exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,fun h => hbT (hpT h),hpb⟩ have hStar : ∃ c, ∀ p ∈ J, c ∈ p := by rcases local_intersecting_pair_family J (fun p hp => (hJ hp).2.1) (fun p hp q hq => local_coextension_pairwise hu (Finset.card_pair hab) (hCo hp) (hCo hq)) with h | h | ⟨x,y,z,hxy,hxz,hyz,heq⟩ · omega · exact h · have hle : J.card ≤ 3 := by rw [heq] exact (Finset.card_insert_le _ _).trans (by exact Nat.add_le_add_right ((Finset.card_insert_le _ _).trans (by simp)) 1) omega obtain ⟨c,hc⟩ := hStar obtain ⟨p,hp⟩ := Finset.card_pos.mp (by omega : 0 < J.card) have hcT : c ∈ T := (hJ hp).1 (hc p hp) let S := (T.erase c).filter (fun z => ({c,z} : Finset (Fin n)) ∈ J) have hSp {z : Fin n} (hz : z ∈ S) : z ≠ c ∧ z ∈ T ∧ ({c,z} : Finset (Fin n)) ∈ J := by obtain ⟨hzt,hzj⟩ := Finset.mem_filter.mp hz obtain ⟨hn,ht⟩ := Finset.mem_erase.mp hzt exact ⟨hn,ht,hzj⟩ have hSJ : S.card = J.card := by have himage : S.image (fun z => ({c,z} : Finset (Fin n))) = J := by ext q constructor · intro hq obtain ⟨z,hz,rfl⟩ := Finset.mem_image.mp hq exact (hSp hz).2.2 · intro hq have hqc := hc q hq obtain ⟨x,y,hxy,rfl⟩ := Finset.card_eq_two.mp (hJ hq).2.1 simp only [Finset.mem_insert,Finset.mem_singleton] at hqc rcases hqc with hcx | hcy · subst c exact Finset.mem_image.mpr ⟨y,Finset.mem_filter.mpr ⟨Finset.mem_erase.mpr ⟨hxy.symm,(hJ hq).1 (by simp)⟩,hq⟩,rfl⟩ · subst c have heq : ({y,x} : Finset (Fin n)) = {x,y} := Finset.pair_comm _ _ exact Finset.mem_image.mpr ⟨x,Finset.mem_filter.mpr ⟨Finset.mem_erase.mpr ⟨hxy,(hJ hq).1 (by simp)⟩,heq.symm ▸ hq⟩,heq⟩ rw [← himage,Finset.card_image_of_injOn] intro x hx y _ hxy change ({c,x} : Finset (Fin n)) = {c,y} at hxy exact Finset.mem_singleton.mp ((Finset.mem_insert.mp (hxy ▸ (Finset.mem_insert_of_mem (Finset.mem_singleton_self x) : x ∈ ({c,x} : Finset (Fin n))))).resolve_left (hSp hx).1) have hST : S ⊆ T := fun _ hz => (hSp hz).2.1 have hS : S ⊆ localExtensions H {a,c} ∩ localExtensions H {b,c} := by intro z hz obtain ⟨hzc,hzT,hzJ⟩ := hSp hz obtain ⟨_,_,hza,hzb⟩ := hJ hzJ have heq (r : Fin n) : insert z ({r,c} : Finset (Fin n)) = insert r {c,z} := by ext v simp only [Finset.mem_insert,Finset.mem_singleton] tauto have hzna : z ≠ a := fun h => haT (h ▸ hzT) have hznb : z ≠ b := fun h => hbT (h ▸ hzT) apply Finset.mem_inter.mpr exact ⟨Finset.mem_filter.mpr ⟨Finset.mem_univ _,by simp [hzna,hzc],(heq a).symm ▸ hza⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _,by simp [hznb,hzc],(heq b).symm ▸ hzb⟩⟩ let D := (S.powersetCard 2).filter (fun p => insert a p ∈ H ∨ insert b p ∈ H) have hD : 2 * D.card ≤ S.card := anchor_link_union_card_on_common_spokes hu hab (fun h => haT (h.symm ▸ hcT)) (fun h => hbT (h.symm ▸ hcT)) S hS let F := (S.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H) have hF : S.powersetCard 2 \ D = F := by ext p simp only [D,F,Finset.mem_filter,Finset.mem_sdiff] tauto have hSplit := Finset.card_sdiff_add_card_eq_card (Finset.filter_subset _ _ : D ⊆ S.powersetCard 2) rw [hF,Finset.card_powersetCard] at hSplit change F.card + D.card = S.card.choose 2 at hSplit refine ⟨S,hST,hSJ,?_⟩ change 2 * J.card.choose 2 ≤ 2 * F.card + J.card rw [hSJ] at hD hSplit omega /-- The same missing-pair estimate on the entire leaf set. -/ theorem anchor_common_link_missing_count {n : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) {a b : Fin n} (hab : a ≠ b) (T : Finset (Fin n)) (haT : a ∉ T) (hbT : b ∉ T) (j : ℕ) (hj : j = ((T.powersetCard 2).filter (fun p => insert a p ∈ H ∧ insert b p ∈ H)).card) (hlarge : 4 ≤ j) : 2 * j.choose 2 ≤ 2 * ((T.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card + j := by obtain ⟨S,hs,_,hB⟩ := anchor_common_link_missing_witness hu hab T haT hbT j hj hlarge apply hB.trans have hm := Finset.card_le_card (Finset.filter_subset_filter _ (Finset.powersetCard_mono hs) : ((S.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)) ⊆ (T.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)) omega /-- The links of two anchors have at most three more edges in total than the number of pairs on their common ground set. -/ theorem anchor_two_link_card_sum_le {n : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) {a b : Fin n} (hab : a ≠ b) (T : Finset (Fin n)) (haT : a ∉ T) (hbT : b ∉ T) : ((T.powersetCard 2).filter (fun p => insert a p ∈ H)).card + ((T.powersetCard 2).filter (fun p => insert b p ∈ H)).card ≤ T.card.choose 2 + 3 := by classical let P := T.powersetCard 2 let L := P.filter (fun p => insert a p ∈ H) let R := P.filter (fun p => insert b p ∈ H) let J := P.filter (fun p => insert a p ∈ H ∧ insert b p ∈ H) let M := P.filter (fun p => insert a p ∉ H ∧ insert b p ∉ H) have hj : L ∩ R = J := by ext p simp only [L,R,J,Finset.mem_filter,Finset.mem_inter] tauto have hm : P \ (L ∪ R) = M := by ext p simp only [L,R,M,Finset.mem_filter,Finset.mem_union,Finset.mem_sdiff] tauto have hU : L ∪ R ⊆ P := Finset.union_subset (Finset.filter_subset _ _) (Finset.filter_subset _ _) have hCard := Finset.card_union_add_card_inter L R have hM := Finset.card_sdiff_add_card_eq_card hU rw [hj] at hCard rw [hm] at hM change M.card + (L ∪ R).card = (T.powersetCard 2).card at hM rw [Finset.card_powersetCard] at hM change L.card + R.card ≤ _ by_cases hs : J.card ≤ 3 · omega have h := anchor_common_link_missing_count hu hab T haT hbT J.card rfl (by omega) change 2 * J.card.choose 2 ≤ 2 * M.card + J.card at h have hLarge (k : ℕ) (hk : 4 ≤ k) : 3 * k ≤ 2 * k.choose 2 := by induction k, hk using Nat.le_induction with | base => decide | succ k hk ih => have heq : (k + 1).choose 2 = k + k.choose 2 := by simpa only [Nat.choose_one_right] using Nat.choose_succ_succ' k 1 change 3 * (k + 1) ≤ 2 * (k + 1).choose 2 rw [heq] omega have hn := hLarge J.card (by omega) omega /-- An edge supported on the tips is determined by any pair it contains. -/ theorem anchor_tip_edge_eq_of_pair_subset {n : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) (hU : ∀ e ∈ H, e.card = 3) {A T e f p : Finset (Fin n)} (hA : A.card = 2) (hAT : Disjoint A T) (hT : ∀ t ∈ T, insert t A ∈ H) (he : e ∈ H) (hf : f ∈ H) (heT : e ⊆ T) (hfT : f ⊆ T) (hp : p.card = 2) (hpe : p ⊆ e) (hpf : p ⊆ f) : e = f := by classical have split {g : Finset (Fin n)} (hg : g ∈ H) (hgT : g ⊆ T) (hpg : p ⊆ g) : ∃ t ∈ T, t ∉ p ∧ insert t p = g := by have hcard : (g \ p).card = 1 := by rw [Finset.card_sdiff_of_subset hpg,hU _ hg,hp] obtain ⟨t,ht⟩ := Finset.card_eq_one.mp hcard have ht' : t ∈ g \ p := by rw [ht]; simp obtain ⟨htg,htp⟩ := Finset.mem_sdiff.mp ht' exact ⟨t,hgT htg,htp,by rw [←Finset.singleton_union,←ht,Finset.sdiff_union_of_subset hpg]⟩ obtain ⟨x,hxT,hxp,hxe⟩ := split he heT hpe obtain ⟨y,hyT,hyp,hyf⟩ := split hf hfT hpf have hxy := disjoint_anchor_tip_unique hu hA (hAT.mono_right (hpe.trans heT)) hAT hT hxT hyT hxp hyp (by rw [hxe]; exact he) (by rw [hyf]; exact hf) exact hxe.symm.trans ((congrArg (fun z => insert z p) hxy).trans hyf) /-- Opposite pairs of triples on the tips are counted either as missing from both anchor links, or by a tip and one of the links containing the pair. -/ theorem anchor_tip_induced_card_bound_with_two_links {n : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) (hU : ∀ e ∈ H, e.card = 3) {a b : Fin n} (hab : a ≠ b) (T : Finset (Fin n)) (haT : a ∉ T) (hbT : b ∉ T) (hT : ∀ t ∈ T, insert t ({a,b} : Finset (Fin n)) ∈ H) : 3 * (H.filter (· ⊆ T)).card ≤ 2 * T.card + ((T.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card := by classical let E := H.filter (· ⊆ T) let I := E.sigma (fun e => e) let J := I.filter (fun q => insert a (q.1.erase q.2) ∈ H ∨ insert b (q.1.erase q.2) ∈ H) let K := I \ J let M := (T.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H) have hAT : Disjoint ({a,b} : Finset (Fin n)) T := by simp [Finset.disjoint_insert_left,Finset.disjoint_singleton_left,haT,hbT] have hA : ({a,b} : Finset (Fin n)).card = 2 := Finset.card_pair hab have data {q : Sigma (fun _ : Finset (Fin n) => Fin n)} (hq : q ∈ I) : q.1 ∈ H ∧ q.1 ⊆ T ∧ q.2 ∈ q.1 := by obtain ⟨he,hv⟩ := Finset.mem_sigma.mp hq change q.1 ∈ E at he exact ⟨(Finset.mem_filter.mp he).1,(Finset.mem_filter.mp he).2,hv⟩ have hI : I.card = 3 * E.card := by rw [Finset.card_sigma] calc _ = ∑ _ ∈ E, (3 : ℕ) := Finset.sum_congr rfl (fun e he => hU _ (Finset.mem_filter.mp he).1) _ = _ := by simp [Nat.mul_comm] have hK : K.card ≤ M.card := by apply Finset.card_le_card_of_injOn (fun q => q.1.erase q.2) · intro q hq obtain ⟨hqI,hqJ⟩ := Finset.mem_sdiff.mp hq obtain ⟨hE,hpT,hv⟩ := data hqI apply Finset.mem_filter.mpr refine ⟨Finset.mem_powersetCard.mpr ⟨(Finset.erase_subset _ _).trans hpT, ?_⟩,?_⟩ · rw [Finset.card_erase_of_mem hv,hU _ hE] · exact not_or.mp (fun h => hqJ (Finset.mem_filter.mpr ⟨hqI,h⟩)) · rintro ⟨e,x⟩ he ⟨f,y⟩ hf hEq obtain ⟨heH,heT,hxe⟩ := data (Finset.mem_sdiff.mp he).1 obtain ⟨hfH,hfT,hyf⟩ := data (Finset.mem_sdiff.mp hf).1 change e.erase x = f.erase y at hEq change x ∈ e at hxe change y ∈ f at hyf have h2 : (e.erase x).card = 2 := by rw [Finset.card_erase_of_mem hxe,hU _ heH] have hef := anchor_tip_edge_eq_of_pair_subset hu hU hA hAT hT heH hfH heT hfT h2 (Finset.erase_subset _ _) (hEq.symm ▸ Finset.erase_subset y f) change e = f at hef have hxy : x = y := by by_contra hn have hx : x ∈ f.erase y := Finset.mem_erase.mpr ⟨hn,hef ▸ hxe⟩ exact Finset.notMem_erase x e (hEq.symm ▸ hx) exact congrArg₂ (fun (s : Finset (Fin n)) (v : Fin n) => (⟨s,v⟩ : Sigma (fun _ : Finset (Fin n) => Fin n))) hef hxy let col (q : Sigma (fun _ : Finset (Fin n) => Fin n)) := if insert a (q.1.erase q.2) ∈ H then a else b have hcol {q : Sigma (fun _ : Finset (Fin n) => Fin n)} (hq : q ∈ J) : col q ∈ ({a,b} : Finset (Fin n)) ∧ insert (col q) (q.1.erase q.2) ∈ H := by have h := (Finset.mem_filter.mp hq).2 by_cases ha : insert a (q.1.erase q.2) ∈ H · simp [col,ha] · simp [col,ha,h.resolve_left ha] have hJ : J.card ≤ 2 * T.card := by have hb : J.card ≤ (({a,b} : Finset (Fin n)) ×ˢ T).card := by apply Finset.card_le_card_of_injOn (fun q => (col q,q.2)) · intro q hq obtain ⟨_,hs,hv⟩ := data (Finset.mem_filter.mp hq).1 exact Finset.mem_product.mpr ⟨(hcol hq).1,hs hv⟩ · rintro ⟨e,x⟩ he ⟨f,y⟩ hf hEq have hxy : x = y := congrArg Prod.snd hEq subst y have hc : col ⟨e,x⟩ = col ⟨f,x⟩ := congrArg Prod.fst hEq let z := col ⟨e,x⟩ obtain ⟨heH,heT,hxe⟩ := data (Finset.mem_filter.mp he).1 obtain ⟨hfH,hfT,hxf⟩ := data (Finset.mem_filter.mp hf).1 change x ∈ e at hxe change x ∈ f at hxf have hz : z ∉ T := fun ht => Finset.disjoint_left.mp hAT (hcol he).1 ht have hzx : z ≠ x := fun h => hz (h.symm ▸ heT hxe) have hep : (e.erase x).card = 2 := by rw [Finset.card_erase_of_mem hxe,hU _ heH] have hfp : (f.erase x).card = 2 := by rw [Finset.card_erase_of_mem hxf,hU _ hfH] have hex (g : Finset (Fin n)) (hgT : g ⊆ T) (hxg : x ∈ g) (hg : g ∈ H) (hzE : insert z (g.erase x) ∈ H) : (g.erase x) ∈ localCoExtensions H {z,x} := by have hcard : (g.erase x).card = 2 := by rw [Finset.card_erase_of_mem hxg,hU _ hg] apply local_mem_coextensions.mpr refine ⟨hcard,?_⟩ intro v hv rcases Finset.mem_insert.mp hv with rfl | hv · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,fun h => hz (hgT (Finset.mem_of_mem_erase h)),hzE⟩ · obtain rfl := Finset.mem_singleton.mp hv exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,Finset.notMem_erase _ _,by rw [Finset.insert_erase hxg]; exact hg⟩ have hfz : insert z (f.erase x) ∈ H := by change col ⟨e,x⟩ = col ⟨f,x⟩ at hc change insert (col ⟨e,x⟩) (f.erase x) ∈ H rw [hc] exact (hcol hf).2 have hd := local_coextension_pairwise hu (Finset.card_pair hzx) (hex e heT hxe heH (hcol he).2) (hex f hfT hxf hfH hfz) obtain ⟨v,hve,hvf⟩ := Finset.not_disjoint_iff.mp hd have hef := anchor_tip_edge_eq_of_pair_subset hu hU hA hAT hT heH hfH heT hfT (Finset.card_pair (Finset.ne_of_mem_erase hve).symm) (Finset.insert_subset hxe (Finset.singleton_subset_iff.mpr (Finset.mem_of_mem_erase hve))) (Finset.insert_subset hxf (Finset.singleton_subset_iff.mpr (Finset.mem_of_mem_erase hvf))) exact congrArg (fun s : Finset (Fin n) => (⟨s,x⟩ : Sigma (fun _ : Finset (Fin n) => Fin n))) hef simpa [Finset.card_product,hab] using hb have hsplit := Finset.card_sdiff_add_card_eq_card (Finset.filter_subset _ _ : J ⊆ I) change K.card + J.card = I.card at hsplit change 3 * E.card ≤ 2 * T.card + M.card omega /-- Partition into edges using both, exactly one, or neither anchor. The overlap and uncovered pair counts account for the two links. -/ theorem anchor_decomposition_card_le {n : ℕ} {H : Finset (Finset (Fin n))} (hU : ∀ e ∈ H, e.card = 3) {a b : Fin n} (hab : a ≠ b) (U : Finset (Fin n)) (hU' : U = (Finset.univ : Finset (Fin n)) \ {a,b}) : H.card + ((U.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card ≤ (localExtensions H {a,b}).card + U.card.choose 2 + ((U.powersetCard 2).filter (fun p => insert a p ∈ H ∧ insert b p ∈ H)).card + (H.filter (· ⊆ U)).card := by classical let A : Finset (Fin n) := {a,b} let T := localExtensions H A let K := U.powersetCard 2 let L (c : Fin n) := K.filter fun p => insert c p ∈ H let J := K.filter (fun p => insert a p ∈ H ∧ insert b p ∈ H) let M := K.filter (fun p => insert a p ∉ H ∧ insert b p ∉ H) let R := H.filter (· ⊆ U) have hA : A.card = 2 := Finset.card_pair hab have hIntoU {x : Fin n} (ha : x ≠ a) (hb : x ≠ b) : x ∈ U := by simp [hU',ha,hb] have hCover : H ⊆ (T.image (fun x => insert x A) ∪ (L a).image (insert a) ∪ (L b).image (insert b)) ∪ R := by have one {x y : Fin n} (hne : x ≠ y) (hpair : ({x,y} : Finset (Fin n)) = A) {e : Finset (Fin n)} (he : e ∈ H) (hx : x ∈ e) (hy : y ∉ e) : e ∈ (L x).image (insert x) := by refine Finset.mem_image.mpr ⟨e.erase x,?_, Finset.insert_erase hx⟩ apply Finset.mem_filter.mpr refine ⟨Finset.mem_powersetCard.mpr ⟨?_,by rw [Finset.card_erase_of_mem hx,hU _ he]⟩, by rwa [Finset.insert_erase hx]⟩ intro z hz obtain ⟨hn,hze⟩ := Finset.mem_erase.mp hz rw [hU',← show A = ({a,b} : Finset (Fin n)) from rfl,← hpair] have hzy : z ≠ y := fun h => hy (h ▸ hze) exact Finset.mem_sdiff.mpr ⟨Finset.mem_univ _,by simp [hn,hzy]⟩ intro e he by_cases hae : a ∈ e <;> by_cases hbe : b ∈ e · have hsub : A ⊆ e := Finset.insert_subset hae (Finset.singleton_subset_iff.mpr hbe) have hd : (e \ A).card = 1 := by rw [Finset.card_sdiff_of_subset hsub, hU e he, hA] obtain ⟨x,hx⟩ := Finset.card_eq_one.mp hd have hx' : x ∈ e \ A := by rw [hx]; simp have heq : insert x A = e := by rw [← Finset.singleton_union,←hx,Finset.sdiff_union_of_subset hsub] have hxT : x ∈ T := Finset.mem_filter.mpr ⟨Finset.mem_univ _,(Finset.mem_sdiff.mp hx').2,by rwa [heq]⟩ exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_image.mpr ⟨x,hxT,heq⟩))) · exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_union_right _ (one hab rfl he hae hbe))) · exact Finset.mem_union_left _ (Finset.mem_union_right _ (one hab.symm (Finset.pair_comm _ _) he hbe hae)) · exact Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨he,fun x hx => hIntoU (fun h => hae (h ▸ hx)) (fun h => hbe (h ▸ hx))⟩) have hCount : H.card ≤ T.card + (L a).card + (L b).card + R.card := by have h₁ := Finset.card_le_card hCover have h₂ := Finset.card_union_le (T.image (fun x => insert x A) ∪ (L a).image (insert a) ∪ (L b).image (insert b)) R have h₃ := Finset.card_union_le (T.image (fun x => insert x A) ∪ (L a).image (insert a)) ((L b).image (insert b)) have h₄ := Finset.card_union_le (T.image (fun x => insert x A)) ((L a).image (insert a)) have h₅ := Finset.card_image_le (s := T) (f := fun x => insert x A) have h₆ := Finset.card_image_le (s := L a) (f := insert a) have h₇ := Finset.card_image_le (s := L b) (f := insert b) omega have hJ : L a ∩ L b = J := by ext p simp only [L,J,Finset.mem_inter,Finset.mem_filter] tauto have hM : K \ (L a ∪ L b) = M := by ext p simp only [L,M,Finset.mem_union,Finset.mem_sdiff,Finset.mem_filter] tauto have hBal : (L a).card + (L b).card + M.card = U.card.choose 2 + J.card := by have h₁ := Finset.card_union_add_card_inter (L a) (L b) have h₂ := Finset.card_sdiff_add_card_eq_card (Finset.union_subset (Finset.filter_subset _ K) (Finset.filter_subset _ K) : L a ∪ L b ⊆ K) rw [hJ] at h₁ rw [hM] at h₂ have hK : K.card = U.card.choose 2 := Finset.card_powersetCard _ _ omega change H.card + M.card ≤ T.card + U.card.choose 2 + J.card + R.card omega /-- Numerical form of the one-exception argument with separate capacity for missing pairs on the common spokes. -/ theorem one_missed_anchor_spoke_counts_inconsistent (d j m r₀ r₁ : ℕ) (hd : 9 ≤ d) (h₀ : 3 * r₀ ≤ 2 * d + m) (h₁ : 2 * r₁ ≤ d) (h₁' : r₁ ≤ m + 2) (hm : 4 ≤ j → ∃ q : ℕ, 2 * j.choose 2 ≤ 2 * q + j ∧ 2 * r₁ + 2 * q ≤ 2 * m + 4 + j) : j + r₀ + r₁ < d + 3 + m := by by_cases hs : j ≤ 3 · omega have hj : 4 ≤ j := by omega obtain ⟨q,hq,hR⟩ := hm hj have hC (k : ℕ) (hk : 4 ≤ k) : 10 * k ≤ 4 * k.choose 2 + 16 := by induction k, hk using Nat.le_induction with | base => decide | succ k hk ih => have heq : (k + 1).choose 2 = k + k.choose 2 := by simpa only [Nat.choose_one_right] using Nat.choose_succ_succ' k 1 change 10 * (k + 1) ≤ 4 * (k + 1).choose 2 + 16 rw [heq] omega have hc := hC j hj omega /-- Reduction of a pair with exactly one missed tip to the local count on triples through that missed tip. -/ theorem one_missed_anchor_not_extremal_of_exception_bound {n : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) (hU : ∀ e ∈ H, e.card = 3) {a b w : Fin n} (hab : a ≠ b) (T : Finset (Fin n)) (hT : T = localExtensions H {a,b}) (hwT : w ∉ T) (hCov : insert w T = (Finset.univ : Finset (Fin n)) \ {a,b}) (hd : 9 ≤ T.card) (hExc : ∀ S : Finset (Fin n), S ⊆ insert w T → 2 * (H.filter (fun e => e ⊆ insert w T ∧ w ∈ e)).card + 2 * ((S.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card ≤ 2 * (((insert w T).powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card + 4 + S.card) : H.card < n.choose 2 := by classical let A : Finset (Fin n) := {a,b} let V := insert w T let M (S : Finset (Fin n)) := (S.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H) let J := (V.powersetCard 2).filter (fun p => insert a p ∈ H ∧ insert b p ∈ H) let R := H.filter (· ⊆ V) let R₀ := H.filter (· ⊆ T) let R₁ := H.filter (fun e => e ⊆ V ∧ w ∈ e) have hA : A.card = 2 := Finset.card_pair hab have haV : a ∉ V := by simp [V,hCov] have hbV : b ∉ V := by simp [V,hCov] have hAV : Disjoint A V := by rw [show V = _ from hCov]; exact Finset.disjoint_sdiff have hAT : Disjoint A T := hAV.mono_right (Finset.subset_insert _ _) have hAW : Disjoint A ({w} : Finset (Fin n)) := hAV.mono_right (Finset.singleton_subset_iff.mpr (Finset.mem_insert_self _ _)) have hTW : Disjoint T ({w} : Finset (Fin n)) := Finset.disjoint_singleton_right.mpr hwT have htip : ∀ t ∈ T, insert t A ∈ H := fun t ht => (Finset.mem_filter.mp (hT ▸ ht)).2.2 have h₀ : 3 * R₀.card ≤ 2 * T.card + (M V).card := by have hh := anchor_tip_induced_card_bound_with_two_links hu hU hab T (fun h => haV (Finset.mem_insert_of_mem h)) (fun h => hbV (Finset.mem_insert_of_mem h)) htip have hM : (M T).card ≤ (M V).card := Finset.card_le_card (Finset.filter_subset_filter _ (Finset.powersetCard_mono (Finset.subset_insert _ _)) : M T ⊆ M V) change 3 * R₀.card ≤ 2 * T.card + (M T).card at hh omega have hV : V = T ∪ ({w} : Finset (Fin n)) := by ext x simp [V,or_comm] have h₁ : 2 * R₁.card ≤ T.card := by have hh := anchor_tip_layer_bound (k := 2) hu hU hA hAT hAW hTW htip have hsub : R₁ ⊆ H.filter (fun e => e ⊆ T ∪ {w} ∧ (e ∩ T).card = 2) := by intro e he obtain ⟨heH,heV,hwe⟩ := Finset.mem_filter.mp he have heq : e ∩ T = e.erase w := by ext x simp only [Finset.mem_inter,Finset.mem_erase] constructor · rintro ⟨hxe,hxT⟩ exact ⟨fun h => hwT (h ▸ hxT),hxe⟩ · rintro ⟨hxw,hxe⟩ exact ⟨hxe,(Finset.mem_insert.mp (heV hxe)).resolve_left hxw⟩ exact Finset.mem_filter.mpr ⟨heH,hV ▸ heV, by rw [heq,Finset.card_erase_of_mem hwe,hU _ heH]⟩ exact (Nat.mul_le_mul_left _ (Finset.card_le_card hsub)).trans (by simpa using hh) have h₁' : R₁.card ≤ (M V).card + 2 := by have hh := hExc ∅ (Finset.empty_subset _) change 2 * R₁.card + 2 * (M ∅).card ≤ 2 * (M V).card + 4 + 0 at hh omega have hSp (hj : 4 ≤ J.card) : ∃ q : ℕ, 2 * J.card.choose 2 ≤ 2 * q + J.card ∧ 2 * R₁.card + 2 * q ≤ 2 * (M V).card + 4 + J.card := by obtain ⟨S,hSV,hSJ,hB⟩ := anchor_common_link_missing_witness hu hab V haV hbV J.card rfl hj refine ⟨(M S).card,hB,?_⟩ have hh := hExc S hSV change 2 * R₁.card + 2 * (M S).card ≤ 2 * (M V).card + 4 + S.card at hh rwa [hSJ] at hh have hbound := one_missed_anchor_spoke_counts_inconsistent T.card J.card (M V).card R₀.card R₁.card hd h₀ h₁ h₁' hSp have hR : R.card ≤ R₀.card + R₁.card := by have hsub : R ⊆ R₀ ∪ R₁ := by intro e he obtain ⟨heH,heV⟩ := Finset.mem_filter.mp he by_cases hw : w ∈ e · exact Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨heH,heV,hw⟩) · exact Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨heH,fun x hx => (Finset.mem_insert.mp (heV hx)).resolve_left (fun h => hw (h ▸ hx))⟩) exact (Finset.card_le_card hsub).trans (Finset.card_union_le _ _) have htotal := anchor_decomposition_card_le hU hab V hCov change H.card + (M V).card ≤ (localExtensions H {a,b}).card + V.card.choose 2 + J.card + R.card at htotal rw [← hT] at htotal have hvcard : V.card = T.card + 1 := Finset.card_insert_of_notMem hwT have hncard : V.card + 2 = n := by have h := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ A) rw [← show V = (Finset.univ : Finset (Fin n)) \ A from hCov,hA,Finset.card_univ,Fintype.card_fin] at h exact h have htarget : n.choose 2 = V.card.choose 2 + 2 * V.card + 1 := by have h₁ := Nat.choose_succ_succ' (V.card+1) 1 have h₂ := Nat.choose_succ_succ' V.card 1 have h₃ : V.card + 1 + 1 = n := by omega simp only [h₃, Nat.choose_one_right, show 1 + 1 = (2 : ℕ) by decide] at h₁ h₂ omega omega theorem anchor_one_exception_layer_add_missing_subregion_bound {n : ℕ} (H : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ H, e.card = 3) (hU : UniqueDisjointUnions H) {a b w : Fin n} {T : Finset (Fin n)} (hab : a ≠ b) (hwa : w ≠ a) (hwb : w ≠ b) (hwT : w ∉ T) (hAT : Disjoint ({a,b} : Finset (Fin n)) T) (hTips : ∀ t ∈ T, insert t ({a,b} : Finset (Fin n)) ∈ H) (V S : Finset (Fin n)) (hTV : T ⊆ V) (hSV : S ⊆ V) : (H.filter (fun e => w ∈ e ∧ e ⊆ insert w T)).card + ((S.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card ≤ ((V.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card + 2 + S.card / 2 := by classical let A : Finset (Fin n) := {a,b} let E := H.filter (fun e => w ∈ e ∧ e ⊆ insert w T) let missing (X : Finset (Fin n)) := (X.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H) let Good := E.filter (fun e => insert a (e.erase w) ∈ H ∨ insert b (e.erase w) ∈ H) let Bad := E \ Good let Inside := Bad.filter (fun e => e.erase w ⊆ S) let Outside := Bad \ Inside have hA : A.card = 2 := by simp [A, hab] have hView {e} (he : e ∈ E) : e ∈ H ∧ w ∈ e ∧ e ⊆ insert w T := Finset.mem_filter.mp he have hEraseT {e} (he : e ∈ E) : e.erase w ⊆ T := by intro x hx obtain ⟨hxw,hxe⟩ := Finset.mem_erase.mp hx exact (Finset.mem_insert.mp ((hView he).2.2 hxe)).resolve_left hxw have hEraseCard {e} (he : e ∈ E) : (e.erase w).card = 2 := by rw [Finset.card_erase_of_mem (hView he).2.1, hUniform e (hView he).1] have hPairsDisjoint {e f} (he : e ∈ E) (hf : f ∈ E) (hne : e ≠ f) : Disjoint (e.erase w) (f.erase w) := by rw [Finset.disjoint_left] intro x hxe hxf obtain ⟨y, hy⟩ := Finset.card_eq_one.mp (by rw [Finset.card_erase_of_mem hxe, hEraseCard he] : ((e.erase w).erase x).card = 1) obtain ⟨z, hz⟩ := Finset.card_eq_one.mp (by rw [Finset.card_erase_of_mem hxf, hEraseCard hf] : ((f.erase w).erase x).card = 1) have hy' : y ∈ (e.erase w).erase x := by rw [hy]; simp have hz' : z ∈ (f.erase w).erase x := by rw [hz]; simp obtain ⟨hyx, hye⟩ := Finset.mem_erase.mp hy' obtain ⟨hzx, hzf⟩ := Finset.mem_erase.mp hz' have hyw := (Finset.mem_erase.mp hye).1 have hzw := (Finset.mem_erase.mp hzf).1 have hxw := (Finset.mem_erase.mp hxe).1 have hEqE : e.erase w = {x,y} := by rw [← hy, Finset.insert_erase hxe] have hEqF : f.erase w = {x,z} := by rw [← hz, Finset.insert_erase hxf] let base : Finset (Fin n) := {w,x} have hWP : Disjoint A base := by have hxa : x ≠ a := fun h => Finset.disjoint_left.mp hAT (show x ∈ A by simp [A,h]) (hEraseT he hxe) have hxb : x ≠ b := fun h => Finset.disjoint_left.mp hAT (show x ∈ A by simp [A,h]) (hEraseT he hxe) simp [A, base, Finset.disjoint_insert_right, hxa, hxb, hwa, hwb] have hyBase : y ∉ base := by simp [base, hyx, hyw] have hzBase : z ∉ base := by simp [base, hzx, hzw] have hyH : insert y base ∈ H := by have hyeq : insert y base = insert w (e.erase w) := by rw [hEqE] ext v simp only [base, Finset.mem_insert, Finset.mem_singleton] tauto rw [hyeq, Finset.insert_erase (hView he).2.1] exact (hView he).1 have hzH : insert z base ∈ H := by have hzeq : insert z base = insert w (f.erase w) := by rw [hEqF] ext v simp only [base, Finset.mem_insert, Finset.mem_singleton] tauto rw [hzeq, Finset.insert_erase (hView hf).2.1] exact (hView hf).1 have hYZ := disjoint_anchor_tip_unique hU hA hWP hAT hTips (hEraseT he hye) (hEraseT hf hzf) hyBase hzBase hyH hzH apply hne rw [← Finset.insert_erase (hView he).2.1, ← Finset.insert_erase (hView hf).2.1, hEqE, hEqF, hYZ] have hMissing {e} (he : e ∈ Bad) : insert a (e.erase w) ∉ H ∧ insert b (e.erase w) ∉ H := by obtain ⟨heE, heG⟩ := Finset.mem_sdiff.mp he exact ⟨fun ha => heG (Finset.mem_filter.mpr ⟨heE, Or.inl ha⟩), fun hb => heG (Finset.mem_filter.mpr ⟨heE, Or.inr hb⟩)⟩ have hOutsideCard : Outside.card ≤ (missing V \ missing S).card := by refine Finset.card_le_card_of_injOn (fun e : Finset (Fin n) => e.erase w) ?_ ?_ · intro e he obtain ⟨heB, heI⟩ := Finset.mem_sdiff.mp he have heE := (Finset.mem_sdiff.mp heB).1 refine Finset.mem_sdiff.mpr ⟨Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨(hEraseT heE).trans hTV, hEraseCard heE⟩, hMissing heB⟩, ?_⟩ intro heS have hS := (Finset.mem_powersetCard.mp (Finset.mem_filter.mp heS).1).1 exact heI (Finset.mem_filter.mpr ⟨heB, hS⟩) · intro e he f hf hEq have hwe := (hView (Finset.mem_sdiff.mp (Finset.mem_sdiff.mp he).1).1).2.1 have hwf := (hView (Finset.mem_sdiff.mp (Finset.mem_sdiff.mp hf).1).1).2.1 exact (Finset.insert_erase hwe).symm.trans ((congrArg (insert w) hEq).trans (Finset.insert_erase hwf)) have hInsideCard : Inside.card ≤ S.card / 2 := by have hIE {e} (he : e ∈ Inside) : e ∈ E := (Finset.mem_sdiff.mp (Finset.mem_filter.mp he).1).1 have hDisj : (Inside : Set (Finset (Fin n))).PairwiseDisjoint (fun e => e.erase w) := by intro e he f hf hne exact hPairsDisjoint (hIE he) (hIE hf) hne have hSub : Inside.biUnion (fun e => e.erase w) ⊆ S := by intro x hx obtain ⟨e,he,hxe⟩ := Finset.mem_biUnion.mp hx exact (Finset.mem_filter.mp he).2 hxe have hCard := Finset.card_le_card hSub rw [Finset.card_biUnion hDisj] at hCard have hSum : ∑ e ∈ Inside, (e.erase w).card = 2 * Inside.card := by calc (∑ e ∈ Inside, (e.erase w).card) = ∑ _e ∈ Inside, 2 := Finset.sum_congr rfl (fun _ he => hEraseCard (hIE he)) _ = 2 * Inside.card := by simp [Nat.mul_comm] rw [hSum] at hCard omega let color (e : Finset (Fin n)) := if insert a (e.erase w) ∈ H then a else b have hColor {e} (he : e ∈ Good) : color e ∈ A ∧ insert (color e) (e.erase w) ∈ H := by obtain ⟨_, hCover⟩ := Finset.mem_filter.mp he by_cases ha : insert a (e.erase w) ∈ H · simp [color, A, ha] · simp [color, A, ha, hCover.resolve_left ha] have hGoodCard : Good.card ≤ 2 := by rw [← hA] refine Finset.card_le_card_of_injOn color (fun _ he => (hColor he).1) ?_ intro e he f hf hEq by_contra hne have heE := (Finset.mem_filter.mp he).1 have hfE := (Finset.mem_filter.mp hf).1 let Q : Finset (Fin n) := {color e,w} have hQ : Q.card = 2 := by have hcw : color e ≠ w := by intro h have hw : w ∈ A := h ▸ (hColor he).1 simp [A, hwa, hwb] at hw simp [Q, hcw] have hD {g} (hg : g ∈ E) : Disjoint (g.erase w) Q := by have hc : color e ∉ g.erase w := fun hx => Finset.disjoint_left.mp hAT (hColor he).1 (hEraseT hg hx) simp [Q, Finset.disjoint_insert_right, hc] have hExtensions {g} (hg : g ∈ E) (hCol : insert (color e) (g.erase w) ∈ H) : ∀ t ∈ Q, insert t (g.erase w) ∈ H := by intro t ht rcases Finset.mem_insert.mp ht with rfl | ht · exact hCol · rw [Finset.mem_singleton.mp ht, Finset.insert_erase (hView hg).2.1] exact (hView hg).1 have hFCol : insert (color e) (f.erase w) ∈ H := hEq ▸ (hColor hf).2 exact matching_supports_intersect hU (hEraseCard heE) hQ (hD heE) (hD hfE) (hExtensions heE (hColor he).2) (hExtensions hfE hFCol) (hPairsDisjoint heE hfE hne) have hGoodSub : Good ⊆ E := fun _ he => (Finset.mem_filter.mp he).1 have hCount := Finset.card_sdiff_add_card_eq_card hGoodSub change Bad.card + Good.card = E.card at hCount have hInsideSub : Inside ⊆ Bad := fun _ he => (Finset.mem_filter.mp he).1 have hParts := Finset.card_sdiff_add_card_eq_card hInsideSub change Outside.card + Inside.card = Bad.card at hParts have hMono : missing S ⊆ missing V := by intro p hp obtain ⟨hP, hMissingP⟩ := Finset.mem_filter.mp hp obtain ⟨hSub, hCard⟩ := Finset.mem_powersetCard.mp hP exact Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨hSub.trans hSV, hCard⟩, hMissingP⟩ have hMissingCount := Finset.card_sdiff_add_card_eq_card hMono change E.card + (missing S).card ≤ (missing V).card + 2 + S.card / 2 omega theorem anchor_one_exception_layer_le_missing_tips_add_two {n : ℕ} (H : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ H, e.card = 3) (hU : UniqueDisjointUnions H) {a b w : Fin n} {T : Finset (Fin n)} (hab : a ≠ b) (hwa : w ≠ a) (hwb : w ≠ b) (hwT : w ∉ T) (hAT : Disjoint ({a,b} : Finset (Fin n)) T) (hTips : ∀ t ∈ T, insert t ({a,b} : Finset (Fin n)) ∈ H) : (H.filter (fun e => w ∈ e ∧ e ⊆ insert w T)).card ≤ ((T.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card + 2 := by have h := anchor_one_exception_layer_add_missing_subregion_bound H hUniform hU hab hwa hwb hwT hAT hTips T ∅ Finset.Subset.rfl (Finset.empty_subset T) simp at h exact h theorem anchor_one_exception_layer_le_missing_add_two {n : ℕ} (H : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ H, e.card = 3) (hU : UniqueDisjointUnions H) {a b w : Fin n} {T : Finset (Fin n)} (hab : a ≠ b) (hwa : w ≠ a) (hwb : w ≠ b) (hwT : w ∉ T) (hAT : Disjoint ({a,b} : Finset (Fin n)) T) (hTips : ∀ t ∈ T, insert t ({a,b} : Finset (Fin n)) ∈ H) : (H.filter (fun e => w ∈ e ∧ e ⊆ insert w T)).card ≤ (((insert w T).powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card + 2 := by have h := anchor_one_exception_layer_le_missing_tips_add_two H hUniform hU hab hwa hwb hwT hAT hTips refine h.trans (Nat.add_le_add_right (Finset.card_le_card ?_) 2) intro p hp obtain ⟨hP,hMissing⟩ := Finset.mem_filter.mp hp obtain ⟨hSub,hCard⟩ := Finset.mem_powersetCard.mp hP exact Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨hSub.trans (Finset.subset_insert _ _),hCard⟩,hMissing⟩ theorem anchor_one_exception_layer_double_add_missing_subregion_bound {n : ℕ} (H : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ H, e.card = 3) (hU : UniqueDisjointUnions H) {a b w : Fin n} {T : Finset (Fin n)} (hab : a ≠ b) (hwa : w ≠ a) (hwb : w ≠ b) (hwT : w ∉ T) (hAT : Disjoint ({a,b} : Finset (Fin n)) T) (hTips : ∀ t ∈ T, insert t ({a,b} : Finset (Fin n)) ∈ H) (S : Finset (Fin n)) (hS : S ⊆ insert w T) : 2 * (H.filter (fun e => e ⊆ insert w T ∧ w ∈ e)).card + 2 * ((S.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card ≤ 2 * (((insert w T).powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card + 4 + S.card := by have h := anchor_one_exception_layer_add_missing_subregion_bound H hUniform hU hab hwa hwb hwT hAT hTips (insert w T) S (Finset.subset_insert _ _) hS have hFilter : H.filter (fun e => w ∈ e ∧ e ⊆ insert w T) = H.filter (fun e => e ⊆ insert w T ∧ w ∈ e) := by ext e simp only [Finset.mem_filter] tauto rw [hFilter] at h omega theorem saturation_pairs_small_or_star {n : ℕ} (J : Finset (Finset (Fin n))) (hCard : ∀ p ∈ J, p.card = 2) (hMeet : ∀ p ∈ J, ∀ q ∈ J, ¬ Disjoint p q) : J.card ≤ 3 ∨ ∃ c, ∀ p ∈ J, c ∈ p := by classical by_cases hSmall : J.card ≤ 3 · exact Or.inl hSmall right obtain ⟨p, hp⟩ := Finset.card_pos.mp (show 0 < J.card by omega) have hRest := Finset.card_erase_of_mem hp obtain ⟨q, hq⟩ := Finset.card_pos.mp (show 0 < (J.erase p).card by omega) obtain ⟨hqp, hqJ⟩ := Finset.mem_erase.mp hq obtain ⟨c, hcp, hcq⟩ := Finset.not_disjoint_iff.mp (hMeet p hp q hqJ) obtain ⟨x, hx⟩ := Finset.card_eq_one.mp (by rw [Finset.card_erase_of_mem hcp, hCard p hp] : (p.erase c).card = 1) obtain ⟨y, hy⟩ := Finset.card_eq_one.mp (by rw [Finset.card_erase_of_mem hcq, hCard q hqJ] : (q.erase c).card = 1) have hpx : p = {c, x} := by rw [← hx, Finset.insert_erase hcp] have hqy : q = {c, y} := by rw [← hy, Finset.insert_erase hcq] have hxc : x ≠ c := by intro h subst x exact Finset.notMem_erase c p (hx ▸ Finset.mem_singleton_self c) have hyc : y ≠ c := by intro h subst y exact Finset.notMem_erase c q (hy ▸ Finset.mem_singleton_self c) have hxy : x ≠ y := by intro h apply hqp rw [hpx, hqy, h] have hne {s : Finset (Fin n)} (hs : s ∈ J) (hcs : c ∉ s) : s = {x, y} := by obtain ⟨z, hzp, hzs⟩ := Finset.not_disjoint_iff.mp (hMeet p hp s hs) obtain ⟨w, hwq, hws⟩ := Finset.not_disjoint_iff.mp (hMeet q hqJ s hs) have hx' : x ∈ s := by rw [hpx, Finset.mem_insert, Finset.mem_singleton] at hzp rcases hzp with rfl | rfl · exact (hcs hzs).elim · exact hzs have hy' : y ∈ s := by rw [hqy, Finset.mem_insert, Finset.mem_singleton] at hwq rcases hwq with rfl | rfl · exact (hcs hws).elim · exact hws refine (Finset.eq_of_subset_of_card_le ?_ ?_).symm · intro z hz rcases Finset.mem_insert.mp hz with rfl | hz · exact hx' · simpa [Finset.mem_singleton.mp hz] using hy' · simp [hCard s hs, hxy] refine ⟨c, ?_⟩ intro s hs by_contra hcs have hTrio : J ⊆ ({p, q, s} : Finset (Finset (Fin n))) := by intro e he by_cases hce : c ∈ e · obtain ⟨w, hws, hwe⟩ := Finset.not_disjoint_iff.mp (hMeet s hs e he) rw [hne hs hcs, Finset.mem_insert, Finset.mem_singleton] at hws have hTwo {a : Fin n} (ha : a ∈ e) (hac : a ≠ c) : e = {c, a} := by refine (Finset.eq_of_subset_of_card_le ?_ ?_).symm · intro v hv rcases Finset.mem_insert.mp hv with rfl | hv · exact hce · simpa [Finset.mem_singleton.mp hv] using ha · simp [hCard e he, hac.symm] rcases hws with rfl | rfl · simp [hTwo hwe hxc, ← hpx] · simp [hTwo hwe hyc, ← hqy] · have he' : e = s := (hne he hce).trans (hne hs hcs).symm simp [he'] have hBound := Finset.card_le_card hTrio have hThree : ({p, q, s} : Finset (Finset (Fin n))).card ≤ 3 := by exact (Finset.card_insert_le _ _).trans (Nat.succ_le_succ Finset.card_le_two) omega theorem saturation_anchor_linear {n : ℕ} {H : Finset (Finset (Fin n))} (hUniform : ∀ e ∈ H, e.card = 3) (hU : UniqueDisjointUnions H) {A T e f p : Finset (Fin n)} (hA : A.card = 2) (hAT : Disjoint A T) (hT : ∀ v ∈ T, insert v A ∈ H) (he : e ∈ H) (hf : f ∈ H) (heT : e ⊆ T) (hfT : f ⊆ T) (hpc : p.card = 2) (hpe : p ⊆ e) (hpf : p ⊆ f) : e = f := by classical have hsplit {g} (hg : g ∈ H) (hgT : g ⊆ T) (hpg : p ⊆ g) : ∃ x, x ∈ T ∧ x ∉ p ∧ g = insert x p := by have hcard : (g \ p).card = 1 := by rw [Finset.card_sdiff_of_subset hpg, hUniform g hg, hpc] obtain ⟨x, hxs⟩ := Finset.card_eq_one.mp hcard have hx : x ∈ g \ p := by rw [hxs]; simp obtain ⟨hxg, hxp⟩ := Finset.mem_sdiff.mp hx refine ⟨x, hgT hxg, hxp, ?_⟩ rw [← Finset.singleton_union, ← hxs, Finset.sdiff_union_of_subset hpg] obtain ⟨x, hxT, hxp, hex⟩ := hsplit he heT hpe obtain ⟨y, hyT, hyp, hfy⟩ := hsplit hf hfT hpf have he' : insert x p ∈ H := hex ▸ he have hf' : insert y p ∈ H := hfy ▸ hf have hAP : Disjoint A p := Finset.disjoint_of_subset_right (hpe.trans heT) hAT have hxy := disjoint_anchor_tip_unique hU hA hAP hAT hT hxT hyT hxp hyp he' hf' rw [hex, hfy, hxy] theorem saturation_colored_opposite_count {n : ℕ} {H R : Finset (Finset (Fin n))} (hU : UniqueDisjointUnions H) (hR : R ⊆ H) (hSize : ∀ e ∈ R, e.card = 3) (hLinear : ∀ e ∈ R, ∀ f ∈ R, ∀ p : Finset (Fin n), p.card = 2 → p ⊆ e → p ⊆ f → e = f) (C W : Finset (Fin n)) (hW : ∀ e ∈ R, e ⊆ W) (hColor : ∀ e ∈ R, ∀ x ∈ e, ∃ a ∈ C, a ∉ e ∧ insert a (e.erase x) ∈ H) : 3 * R.card ≤ W.card * C.card := by classical let I := R.sigma (fun e => e) have hI {i : (e : Finset (Fin n)) × Fin n} (hi : i ∈ I) : i.1 ∈ R ∧ i.2 ∈ i.1 := Finset.mem_sigma.mp hi let color (i : (e : Finset (Fin n)) × Fin n) : Fin n := if h : i ∈ I then (hColor i.1 (hI h).1 i.2 (hI h).2).choose else i.2 have hCol {i} (hi : i ∈ I) : color i ∈ C ∧ color i ∉ i.1 ∧ insert (color i) (i.1.erase i.2) ∈ H := by simpa [color, dif_pos hi] using (hColor i.1 (hI hi).1 i.2 (hI hi).2).choose_spec let map (i : (e : Finset (Fin n)) × Fin n) := (i.2, color i) have hImage : Set.MapsTo map ↑I (↑(W ×ˢ C) : Set (Fin n × Fin n)) := by intro i hi change map i ∈ (W ×ˢ C : Finset (Fin n × Fin n)) exact Finset.mem_product.mpr ⟨hW i.1 (hI hi).1 (hI hi).2, (hCol hi).1⟩ have hInj : Set.InjOn map I := by rintro ⟨e,x⟩ hi ⟨f,y⟩ hj hEq change (x, color ⟨e,x⟩) = (y, color ⟨f,y⟩) at hEq obtain ⟨rfl, hcolors⟩ := Prod.mk.inj hEq have he := hI hi have hf := hI hj let a := color ⟨e,x⟩ have hColE : a ∉ e ∧ insert a (e.erase x) ∈ H := (hCol hi).2 have hColF : a ∉ f ∧ insert a (f.erase x) ∈ H := by simpa only [a, hcolors] using (hCol hj).2 suffices hEF : e = f by subst f; rfl by_contra hEF have hDisj : Disjoint (e.erase x) (f.erase x) := by rw [Finset.disjoint_left] intro z hz hz' obtain ⟨hzx, hze⟩ := Finset.mem_erase.mp hz have hpc : ({x,z} : Finset (Fin n)).card = 2 := by simp [hzx.symm] have hpE : ({x,z} : Finset (Fin n)) ⊆ e := by intro v hv rcases Finset.mem_insert.mp hv with rfl | hv · exact he.2 · simpa [Finset.mem_singleton.mp hv] using hze have hpF : ({x,z} : Finset (Fin n)) ⊆ f := by intro v hv rcases Finset.mem_insert.mp hv with rfl | hv · exact hf.2 · simpa [Finset.mem_singleton.mp hv] using (Finset.mem_erase.mp hz').2 exact hEF (hLinear e he.1 f hf.1 _ hpc hpE hpF) have hax : a ≠ x := fun h => hColE.1 (h ▸ he.2) have hq : ({a,x} : Finset (Fin n)).card = 2 := by simp [hax] have hpe : (e.erase x).card = 2 := by rw [Finset.card_erase_of_mem he.2, hSize e he.1] have hdE : Disjoint (e.erase x) ({a,x} : Finset (Fin n)) := by simp [Finset.disjoint_insert_right, hColE.1] have hdF : Disjoint (f.erase x) ({a,x} : Finset (Fin n)) := by simp [Finset.disjoint_insert_right, hColF.1] have htE : ∀ z ∈ ({a,x} : Finset (Fin n)), insert z (e.erase x) ∈ H := by intro z hz rcases Finset.mem_insert.mp hz with rfl | hz · exact hColE.2 · rw [Finset.mem_singleton.mp hz, Finset.insert_erase he.2] exact hR he.1 have htF : ∀ z ∈ ({a,x} : Finset (Fin n)), insert z (f.erase x) ∈ H := by intro z hz rcases Finset.mem_insert.mp hz with rfl | hz · exact hColF.2 · rw [Finset.mem_singleton.mp hz, Finset.insert_erase hf.2] exact hR hf.1 exact matching_supports_intersect hU hpe hq hdE hdF htE htF hDisj have hCard := Finset.card_le_card_of_injOn map hImage hInj have hIcard : I.card = 3 * R.card := by rw [Finset.card_sigma] calc (∑ e ∈ R, e.card) = ∑ _e ∈ R, 3 := Finset.sum_congr rfl hSize _ = 3 * R.card := by simp [Nat.mul_comm] rwa [hIcard, Finset.card_product] at hCard theorem saturation_splice_absence {n : ℕ} {H : Finset (Finset (Fin n))} (hU : UniqueDisjointUnions H) {a b x y : Fin n} {e : Finset (Fin n)} (hab : a ≠ b) (ha : a ∉ e) (hb : b ∉ e) (hx : x ∈ e) (hy : y ∉ e) (hya : y ≠ a) (hyb : y ≠ b) (hE : e ∈ H) (hAnchor : ({a,b,y} : Finset (Fin n)) ∈ H) (hOpp : insert a (e.erase x) ∈ H) : ({b,x,y} : Finset (Fin n)) ∉ H := by classical intro hBad let p : Finset (Fin n) := {b,y} let q : Finset (Fin n) := {a,x} let r := e.erase x have hP : p.card = 2 := by simp [p, hyb.symm] have hQ : q.card = 2 := by simp [q, (show a ≠ x from fun h => ha (h ▸ hx))] have hpq : Disjoint p q := by have hxb : x ≠ b := fun h => hb (h ▸ hx) have hxy : x ≠ y := fun h => hy (h ▸ hx) simp [p, q, Finset.disjoint_insert_right, hab, hya.symm, hxb, hxy] have hrq : Disjoint r q := by simp [r, q, Finset.disjoint_insert_right, ha] have hpr : Disjoint p r := by rw [disjoint_comm] simp [r, p, Finset.disjoint_insert_right, hb, hy] have hLeft : ∀ z ∈ q, insert z p ∈ H := by intro z hz rcases Finset.mem_insert.mp hz with rfl | hz · exact hAnchor · rw [Finset.mem_singleton.mp hz] simpa [p, Finset.insert_comm x b] using hBad have hRight : ∀ z ∈ q, insert z r ∈ H := by intro z hz rcases Finset.mem_insert.mp hz with rfl | hz · exact hOpp · rw [Finset.mem_singleton.mp hz] rwa [Finset.insert_erase hx] exact matching_supports_intersect hU hP hQ hpq hrq hLeft hRight hpr theorem saturated_anchor_not_extremal {n : ℕ} (hn : 9 ≤ n) (H : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ H, e.card = 3) (hU : UniqueDisjointUnions H) {a b : Fin n} (hab : a ≠ b) (hFull : ∀ x : Fin n, x ≠ a → x ≠ b → ({a,b,x} : Finset (Fin n)) ∈ H) : H.card < n.choose 2 := by classical let A : Finset (Fin n) := {a,b} let U : Finset (Fin n) := Finset.univ \ A let K := U.powersetCard 2 let L (c : Fin n) := K.filter fun p => insert c p ∈ H let J := L a ∩ L b let M := K \ (L a ∪ L b) let R := H.filter (· ⊆ U) let Good := R.filter fun e => ∀ x ∈ e, e.erase x ∈ L a ∪ L b let Bad := R \ Good have hA : A.card = 2 := by simp [A, hab] have hm : U.card + 2 = n := by have h := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ A) simpa [U, hA] using h have haU {x : Fin n} (hx : x ∈ U) : x ≠ a := fun h => (Finset.mem_sdiff.mp hx).2 (by simp [A, h]) have hbU {x : Fin n} (hx : x ∈ U) : x ≠ b := fun h => (Finset.mem_sdiff.mp hx).2 (by simp [A, h]) have hIntoU {x : Fin n} (ha : x ≠ a) (hb : x ≠ b) : x ∈ U := by simp [U, A, ha, hb] have hAnchorDisj : Disjoint A U := Finset.disjoint_sdiff have hAnchor {x} (hx : x ∈ U) : insert x A ∈ H := by change insert x ({a,b} : Finset (Fin n)) ∈ H have heq : insert x ({a,b} : Finset (Fin n)) = {a,b,x} := by ext y simp only [Finset.mem_insert, Finset.mem_singleton] tauto rw [heq] exact hFull x (haU hx) (hbU hx) have hL {p c} (hp : p ∈ L c) : p ⊆ U ∧ p.card = 2 ∧ insert c p ∈ H := by obtain ⟨hk, hH⟩ := Finset.mem_filter.mp hp obtain ⟨hs, hc⟩ := Finset.mem_powersetCard.mp hk exact ⟨hs, hc, hH⟩ have hR {e} (he : e ∈ R) : e ∈ H ∧ e ⊆ U := Finset.mem_filter.mp he have hGood {e} (he : e ∈ Good) : e ∈ R ∧ ∀ x ∈ e, e.erase x ∈ L a ∪ L b := Finset.mem_filter.mp he have hLinear {e f} (he : e ∈ R) (hf : f ∈ R) {p : Finset (Fin n)} (hc : p.card = 2) (hp : p ⊆ e) (hq : p ⊆ f) : e = f := saturation_anchor_linear hUniform hU hA hAnchorDisj (fun _ hv => hAnchor hv) (hR he).1 (hR hf).1 (hR he).2 (hR hf).2 hc hp hq have hGoodBound (W : Finset (Fin n)) (hW : ∀ e ∈ Good, e ⊆ W) : 3 * Good.card ≤ 2 * W.card := by have h := saturation_colored_opposite_count hU (R := Good) (fun _ he => (hR (hGood he).1).1) (fun e he => hUniform e (hR (hGood he).1).1) (fun _ he _ hf _ hc hp hq => hLinear (hGood he).1 (hGood hf).1 hc hp hq) A W hW (by intro e he x hx rcases Finset.mem_union.mp ((hGood he).2 x hx) with ha | hb · exact ⟨a, by simp [A], fun h => haU ((hR (hGood he).1).2 h) rfl, (hL ha).2.2⟩ · exact ⟨b, by simp [A], fun h => hbU ((hR (hGood he).1).2 h) rfl, (hL hb).2.2⟩) simpa [hA, Nat.mul_comm] using h have hBadBound : Bad.card ≤ M.card := by have hWitness {e} (he : e ∈ Bad) : ∃ p ∈ M, p ⊆ e := by obtain ⟨heR, heG⟩ := Finset.mem_sdiff.mp he have hNot : ¬ ∀ x ∈ e, e.erase x ∈ L a ∪ L b := by intro hh exact heG (Finset.mem_filter.mpr ⟨heR, hh⟩) push Not at hNot obtain ⟨x, hx, hn⟩ := hNot have hc : (e.erase x).card = 2 := by rw [Finset.card_erase_of_mem hx, hUniform e (hR heR).1] refine ⟨e.erase x, Finset.mem_sdiff.mpr ⟨?_, hn⟩, Finset.erase_subset _ _⟩ exact Finset.mem_powersetCard.mpr ⟨(Finset.erase_subset _ _).trans (hR heR).2, hc⟩ let f (e : Finset (Fin n)) := if h : e ∈ Bad then (hWitness h).choose else ∅ have hChoose {e} (he : e ∈ Bad) : f e ∈ M ∧ f e ⊆ e := by simpa [f, dif_pos he] using (hWitness he).choose_spec refine Finset.card_le_card_of_injOn f (fun _ he => (hChoose he).1) ?_ intro e he f' hf hEq change e ∈ Bad at he change f' ∈ Bad at hf apply hLinear (Finset.mem_sdiff.mp he).1 (Finset.mem_sdiff.mp hf).1 (Finset.mem_powersetCard.mp (Finset.mem_sdiff.mp (hChoose he).1).1).2 (hChoose he).2 simpa only [hEq] using (hChoose hf).2 have hRCard : R.card ≤ Good.card + M.card := by have hGR : Good ⊆ R := fun _ h => (hGood h).1 have hGc := Finset.card_sdiff_add_card_eq_card hGR change Bad.card + Good.card = R.card at hGc omega have hCover : H ⊆ (U.image (fun x => insert x A) ∪ (L a).image (insert a) ∪ (L b).image (insert b)) ∪ R := by intro e he by_cases hae : a ∈ e <;> by_cases hbe : b ∈ e · have hsub : A ⊆ e := by intro x hx simp only [A, Finset.mem_insert, Finset.mem_singleton] at hx rcases hx with rfl | rfl <;> assumption have hd : (e \ A).card = 1 := by rw [Finset.card_sdiff_of_subset hsub, hUniform e he, hA] obtain ⟨x, hx⟩ := Finset.card_eq_one.mp hd have hx' : x ∈ e \ A := by rw [hx]; simp have hxU : x ∈ U := Finset.mem_sdiff.mpr ⟨Finset.mem_univ _, (Finset.mem_sdiff.mp hx').2⟩ have hEq : insert x A = e := by rw [← Finset.singleton_union, ← hx, Finset.sdiff_union_of_subset hsub] exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_image.mpr ⟨x, hxU, hEq⟩))) · have hp : e.erase a ∈ L a := by apply Finset.mem_filter.mpr refine ⟨Finset.mem_powersetCard.mpr ⟨?_, ?_⟩, ?_⟩ · intro x hx exact hIntoU (Finset.mem_erase.mp hx).1 (fun h => hbe (h ▸ (Finset.mem_erase.mp hx).2)) · rw [Finset.card_erase_of_mem hae, hUniform e he] · rwa [Finset.insert_erase hae] exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_image.mpr ⟨e.erase a, hp, Finset.insert_erase hae⟩))) · have hp : e.erase b ∈ L b := by apply Finset.mem_filter.mpr refine ⟨Finset.mem_powersetCard.mpr ⟨?_, ?_⟩, ?_⟩ · intro x hx exact hIntoU (fun h => hae (h ▸ (Finset.mem_erase.mp hx).2)) (Finset.mem_erase.mp hx).1 · rw [Finset.card_erase_of_mem hbe, hUniform e he] · rwa [Finset.insert_erase hbe] exact Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_image.mpr ⟨e.erase b, hp, Finset.insert_erase hbe⟩)) · exact Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨he, fun x hx => hIntoU (fun h => hae (h ▸ hx)) (fun h => hbe (h ▸ hx))⟩) have hCount : H.card ≤ U.card + (L a).card + (L b).card + R.card := by have h₁ := Finset.card_le_card hCover have h₂ := Finset.card_union_le (U.image (fun x => insert x A) ∪ (L a).image (insert a) ∪ (L b).image (insert b)) R have h₃ := Finset.card_union_le (U.image (fun x => insert x A) ∪ (L a).image (insert a)) ((L b).image (insert b)) have h₄ := Finset.card_union_le (U.image (fun x => insert x A)) ((L a).image (insert a)) have h₅ := Finset.card_image_le (s := U) (f := fun x => insert x A) have h₆ := Finset.card_image_le (s := L a) (f := insert a) have h₇ := Finset.card_image_le (s := L b) (f := insert b) omega have hBal : (L a).card + (L b).card + M.card = U.card.choose 2 + J.card := by have h₁ := Finset.card_union_add_card_inter (L a) (L b) have h₂ := Finset.card_sdiff_add_card_eq_card (Finset.union_subset (Finset.filter_subset _ K) (Finset.filter_subset _ K) : L a ∪ L b ⊆ K) change M.card + (L a ∪ L b).card = K.card at h₂ change (L a ∪ L b).card + J.card = (L a).card + (L b).card at h₁ have hK : K.card = U.card.choose 2 := Finset.card_powersetCard _ _ omega have hTarget : n.choose 2 = U.card.choose 2 + 2 * U.card + 1 := by calc n.choose 2 = (U.card + 2).choose 2 := congrArg (fun k => k.choose 2) hm.symm _ = U.card.choose 2 + 2 * U.card + 1 := by have h₁ := Nat.choose_succ_succ' (U.card+1) 1 have h₂ := Nat.choose_succ_succ' U.card 1 have h₃ : U.card + 1 + 1 = U.card + 2 := by omega simp only [h₃, Nat.choose_one_right, show 1 + 1 = (2 : ℕ) by decide] at h₁ h₂ omega have hJm {p} (hp : p ∈ J) : p ⊆ U ∧ p.card = 2 ∧ insert a p ∈ H ∧ insert b p ∈ H := by obtain ⟨hpa, hpb⟩ := Finset.mem_inter.mp hp exact ⟨(hL hpa).1, (hL hpa).2.1, (hL hpa).2.2, (hL hpb).2.2⟩ have hMeet : ∀ p ∈ J, ∀ q ∈ J, ¬ Disjoint p q := by intro p hp q hq hDisj have hdP : Disjoint p A := by rw [disjoint_comm] exact Finset.disjoint_of_subset_right (hJm hp).1 hAnchorDisj have hdQ : Disjoint q A := by rw [disjoint_comm] exact Finset.disjoint_of_subset_right (hJm hq).1 hAnchorDisj exact matching_supports_intersect hU (hJm hp).2.1 hA hdP hdQ (by simpa [A] using (hJm hp).2.2) (by simpa [A] using (hJm hq).2.2) hDisj have hSmallBound (hSmall : J.card ≤ 3) : H.card < n.choose 2 := by have hG := hGoodBound U (fun _ he => (hR (hGood he).1).2) omega rcases saturation_pairs_small_or_star J (fun _ hp => (hJm hp).2.1) hMeet with hs | ⟨c,hc⟩ · exact hSmallBound hs by_cases hSmall : J.card ≤ 3 · exact hSmallBound hSmall let V := U.filter fun x => x ≠ c ∧ ({c,x} : Finset (Fin n)) ∈ J let W := U \ insert c V have hcU : c ∈ U := by obtain ⟨p,hp⟩ := Finset.card_pos.mp (show 0 < J.card by omega) exact (hJm hp).1 (hc p hp) have hVsub : V ⊆ U := Finset.filter_subset _ _ have hVc : c ∉ V := by simp [V] have hVcard : J.card ≤ V.card := by have hJV : J ⊆ V.image (fun x => ({c,x} : Finset (Fin n))) := by intro p hp have hpc := hc p hp have hCard : (p.erase c).card = 1 := by rw [Finset.card_erase_of_mem hpc, (hJm hp).2.1] obtain ⟨x, hx⟩ := Finset.card_eq_one.mp hCard have hpEq : ({c,x} : Finset (Fin n)) = p := by rw [← hx, Finset.insert_erase hpc] have hxp : x ∈ p.erase c := by rw [hx]; simp obtain ⟨hxc,hxp⟩ := Finset.mem_erase.mp hxp exact Finset.mem_image.mpr ⟨x, Finset.mem_filter.mpr ⟨(hJm hp).1 hxp, hxc, hpEq ▸ hp⟩, hpEq⟩ exact (Finset.card_le_card hJV).trans Finset.card_image_le have hWV : W.card + V.card + 1 = U.card := by have h := Finset.card_sdiff_add_card_eq_card (Finset.insert_subset hcU hVsub) change W.card + (insert c V).card = U.card at h rw [Finset.card_insert_of_notMem hVc] at h omega have hNoSplice {e} (he : e ∈ Good) {x y : Fin n} (hx : x ∈ e) (hy : y ∈ U) (hye : y ∉ e) (hP : ({x,y} : Finset (Fin n)) ∈ J) : False := by obtain ⟨heH, heU⟩ := hR (hGood he).1 have hae : a ∉ e := fun h => haU (heU h) rfl have hbe : b ∉ e := fun h => hbU (heU h) rfl rcases Finset.mem_union.mp ((hGood he).2 x hx) with h | h · exact saturation_splice_absence hU hab hae hbe hx hye (haU hy) (hbU hy) heH (hFull y (haU hy) (hbU hy)) (hL h).2.2 (hJm hP).2.2.2 · apply saturation_splice_absence hU hab.symm hbe hae hx hye (hbU hy) (haU hy) heH (by simpa [Finset.insert_comm a b] using hFull y (haU hy) (hbU hy)) (hL h).2.2 exact (hJm hP).2.2.1 have hGoodW : ∀ e ∈ Good, e ⊆ W := by intro e he x hx have heU := (hR (hGood he).1).2 have hcE : c ∉ e := by intro hce have hNot : ¬ V ⊆ e := by intro hs have h := Finset.card_le_card hs have hCard := hUniform e (hR (hGood he).1).1 omega obtain ⟨y, hyV, hyE⟩ := Finset.not_subset.mp hNot exact hNoSplice he hce (hVsub hyV) hyE (Finset.mem_filter.mp hyV).2.2 refine Finset.mem_sdiff.mpr ⟨heU hx, ?_⟩ intro hxV rcases Finset.mem_insert.mp hxV with rfl | hxV · exact hcE hx · have hPair : ({x,c} : Finset (Fin n)) ∈ J := by rw [Finset.pair_comm] exact (Finset.mem_filter.mp hxV).2.2 exact hNoSplice he hx hcU hcE hPair have hG := hGoodBound W hGoodW omega /-- On at least twelve vertices, a pair extending to all but one of the other vertices rules out extremal equality. -/ theorem one_missed_anchor_not_extremal {n : ℕ} (hn : 12 ≤ n) {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) (hU : ∀ e ∈ H, e.card = 3) {a b : Fin n} (hab : a ≠ b) (hdeg : (localExtensions H {a,b}).card = n - 3) : H.card < n.choose 2 := by classical let A : Finset (Fin n) := {a,b} let V := (Finset.univ : Finset (Fin n)) \ A let T := localExtensions H A have hTsub : T ⊆ V := fun _ ht => Finset.mem_sdiff.mpr ⟨Finset.mem_univ _,(Finset.mem_filter.mp ht).2.1⟩ have hVcard : V.card + 2 = n := by have h := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ A) simpa [V,A,hab] using h have hTcard : T.card = n - 3 := hdeg have hmiss : (V \ T).card = 1 := by rw [Finset.card_sdiff_of_subset hTsub] omega obtain ⟨w,hw⟩ := Finset.card_eq_one.mp hmiss have hwmem : w ∈ V \ T := by rw [hw]; simp obtain ⟨hwV,hwT⟩ := Finset.mem_sdiff.mp hwmem have hCov : insert w T = V := by rw [← Finset.singleton_union,← hw,Finset.sdiff_union_of_subset hTsub] have haV : a ∉ V := by simp [V,A] have hbV : b ∉ V := by simp [V,A] have hAT : Disjoint A T := (Finset.disjoint_sdiff : Disjoint A V).mono_right hTsub have hwa : w ≠ a := fun h => haV (h ▸ hwV) have hwb : w ≠ b := fun h => hbV (h ▸ hwV) have htip : ∀ t ∈ T, insert t A ∈ H := fun _ ht => (Finset.mem_filter.mp ht).2.2 apply one_missed_anchor_not_extremal_of_exception_bound hu hU hab T rfl hwT hCov (by omega) intro S hS exact anchor_one_exception_layer_double_add_missing_subregion_bound H hU hu hab hwa hwb hwT hAT htip S hS /-- If two adjacent leaf pairs are in both anchor links, an exterior leaf cannot meet both spokes in the union of the two links. -/ theorem anchor_common_spokes_forbid_two_exterior_neighbors {n : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) {a b c x y z : Fin n} (hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) (hxc : x ≠ c) (hxy : x ≠ y) (hxz : x ≠ z) (hyz : y ≠ z) (hxa : x ≠ a) (hxb : x ≠ b) (hy : y ∈ localExtensions H {a,c} ∩ localExtensions H {b,c}) (hz : z ∈ localExtensions H {a,c} ∩ localExtensions H {b,c}) (h₁ : insert a ({x,y} : Finset (Fin n)) ∈ H ∨ insert b {x,y} ∈ H) (h₂ : insert a ({x,z} : Finset (Fin n)) ∈ H ∨ insert b {x,z} ∈ H) : False := by set_option maxHeartbeats 2000000 in exact (by classical have info {t : Fin n} (ht : t ∈ localExtensions H {a,c} ∩ localExtensions H {b,c}) : t ≠ a ∧ t ≠ b ∧ t ≠ c ∧ insert a ({c,t} : Finset (Fin n)) ∈ H ∧ insert b ({c,t} : Finset (Fin n)) ∈ H := by obtain ⟨hA,hB⟩ := Finset.mem_inter.mp ht obtain ⟨_,hnotA,hAe⟩ := Finset.mem_filter.mp hA obtain ⟨_,hnotB,hBe⟩ := Finset.mem_filter.mp hB have heq (r : Fin n) : insert r ({c,t} : Finset (Fin n)) = insert t {r,c} := by ext v simp only [Finset.mem_insert,Finset.mem_singleton,or_left_comm,or_comm] refine ⟨fun h => hnotA (by simp [h]), fun h => hnotB (by simp [h]), fun h => hnotA (by simp [h]), ?_, ?_⟩ · rwa [heq] · rwa [heq] obtain ⟨hya,hyb,hyc,hay,hby⟩ := info hy obtain ⟨hza,hzb,hzc,haz,hbz⟩ := info hz have hCenter {t : Fin n} (ht : t ∈ ({a,b} : Finset (Fin n))) : t ≠ c := by simp only [Finset.mem_insert,Finset.mem_singleton] at ht exact ht.elim (fun h => h.symm ▸ hac) (fun h => h.symm ▸ hbc) have collision {i j k l : Fin n} (hi : i ∈ ({a,b} : Finset (Fin n))) (hj : j ∈ ({a,b} : Finset (Fin n))) (hk : k ∈ ({a,b} : Finset (Fin n))) (hl : l ∈ ({a,b} : Finset (Fin n))) (hij : i ≠ j) (hkl : k ≠ l) (hA : insert i ({x,y} : Finset (Fin n)) ∈ H) (hB : insert j ({c,z} : Finset (Fin n)) ∈ H) (hC : insert k ({x,z} : Finset (Fin n)) ∈ H) (hD : insert l ({c,y} : Finset (Fin n)) ∈ H) : False := by have data {t : Fin n} (ht : t ∈ ({a,b} : Finset (Fin n))) : t ≠ x ∧ t ≠ y ∧ t ≠ z := by simp only [Finset.mem_insert,Finset.mem_singleton] at ht rcases ht with rfl | rfl · exact ⟨hxa.symm,hya.symm,hza.symm⟩ · exact ⟨hxb.symm,hyb.symm,hzb.symm⟩ obtain ⟨hix,hiy,hiz⟩ := data hi obtain ⟨hjx,hjy,hjz⟩ := data hj obtain ⟨hkx,hky,hkz⟩ := data hk obtain ⟨hlx,hly,hlz⟩ := data hl -- The center is a leaf, separate from both anchors. have collideIf (hic : i ≠ c) (hkc : k ≠ c) : False := by have hd₁ : Disjoint (insert i ({x,y} : Finset (Fin n))) (insert j ({c,z} : Finset (Fin n))) := by simp [Finset.disjoint_insert_right,hij.symm,hic.symm,hiz.symm, hxc.symm,hjx,hxz.symm,hyc.symm,hjy,hyz.symm] have hd₂ : Disjoint (insert k ({x,z} : Finset (Fin n))) (insert l ({c,y} : Finset (Fin n))) := by simp [Finset.disjoint_insert_right,hkl.symm,hkc.symm,hky.symm, hxc.symm,hlx,hxy.symm,hzc.symm,hlz,hyz] have hp₁ : ({i,j} : Finset (Fin n)) = {a,b} := Finset.eq_of_subset_of_card_le (Finset.insert_subset hi (Finset.singleton_subset_iff.mpr hj)) (by simp [hab,hij]) have hp₂ : ({k,l} : Finset (Fin n)) = {a,b} := Finset.eq_of_subset_of_card_le (Finset.insert_subset hk (Finset.singleton_subset_iff.mpr hl)) (by simp [hab,hkl]) have rearrange (r s p q : Fin n) : insert r ({x,p} : Finset (Fin n)) ∪ insert s {c,q} = ({r,s} : Finset (Fin n)) ∪ {x,c,p,q} := by ext v simp only [Finset.mem_union,Finset.mem_insert,Finset.mem_singleton,or_left_comm,or_comm] have hun : insert i ({x,y} : Finset (Fin n)) ∪ insert j {c,z} = insert k {x,z} ∪ insert l {c,y} := by calc _ = ({i,j} : Finset (Fin n)) ∪ {x,c,y,z} := rearrange i j y z _ = ({k,l} : Finset (Fin n)) ∪ {x,c,z,y} := by rw [hp₁,hp₂] ext v simp only [Finset.mem_union,Finset.mem_insert,Finset.mem_singleton,or_left_comm,or_comm] _ = _ := (rearrange k l z y).symm rcases hu _ hA _ hB _ hC _ hD hd₁ hd₂ hun with h | h · have hh : y ∈ insert k ({x,z} : Finset (Fin n)) := h.1 ▸ Finset.mem_insert_of_mem (Finset.mem_insert_of_mem (Finset.mem_singleton_self y)) simpa [hky.symm,hxy.symm,hyz] using hh · have hh : x ∈ insert l ({c,y} : Finset (Fin n)) := h.1 ▸ Finset.mem_insert_of_mem (Finset.mem_insert_self x {y}) simpa [hxc,hlx.symm,hxy] using hh exact collideIf (hCenter hi) (hCenter hk) have ha : a ∈ ({a,b} : Finset (Fin n)) := by simp have hb : b ∈ ({a,b} : Finset (Fin n)) := by simp rcases h₁ with h₁ | h₁ <;> rcases h₂ with h₂ | h₂ · exact collision ha hb ha hb hab hab h₁ hbz h₂ hby · exact collision ha hb hb ha hab hab.symm h₁ hbz h₂ hay · exact collision hb ha ha hb hab.symm hab h₁ haz h₂ hby · exact collision hb ha hb ha hab.symm hab.symm h₁ haz h₂ hay) /-- In an extremal family on at least twelve vertices, every pair misses at least two possible extensions. -/ theorem extremal_pair_codegree_le_sub_four {n : ℕ} (hn : 12 ≤ n) {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) (hU : ∀ e ∈ H, e.card = 3) (hE : H.card = n.choose 2) {p : Finset (Fin n)} (hp : p.card = 2) : (localExtensions H p).card ≤ n - 4 := by classical obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp let A : Finset (Fin n) := {a,b} let V := (Finset.univ : Finset (Fin n)) \ A let T := localExtensions H A change T.card ≤ n - 4 have hT : T ⊆ V := fun _ ht => Finset.mem_sdiff.mpr ⟨Finset.mem_univ _,(Finset.mem_filter.mp ht).2.1⟩ have hv : V.card + 2 = n := by have h := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ A) simpa [V,A,hab] using h have ht := Finset.card_le_card hT by_contra hn' have hcase : T.card = n - 3 ∨ T.card = V.card := by omega rcases hcase with h | h · have hlt := one_missed_anchor_not_extremal hn hu hU hab h omega · have hTV := Finset.eq_of_subset_of_card_le hT h.ge have hext (x : Fin n) (hxa : x ≠ a) (hxb : x ≠ b) : ({a,b,x} : Finset (Fin n)) ∈ H := by have hx : x ∈ V := by simp [V,A,hxa,hxb] have hx' : x ∈ T := hTV.symm ▸ hx have hmem := (Finset.mem_filter.mp hx').2.2 have hEq : insert x A = {a,b,x} := by ext y simp only [A,Finset.mem_insert,Finset.mem_singleton,or_left_comm,or_comm] rwa [hEq] at hmem have hlt := saturated_anchor_not_extremal (by omega : 9 ≤ n) H hU hu hab hext omega /-- Two common spokes restrict the number of covered pairs from any other leaf. -/ theorem anchor_cover_neighbors_card_le_one {n : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) {a b c x : Fin n} (hab : a ≠ b) (hac : a ≠ c) (hbc : b ≠ c) (hxc : x ≠ c) (hxa : x ≠ a) (hxb : x ≠ b) (S : Finset (Fin n)) (hS : S ⊆ localExtensions H {a,c} ∩ localExtensions H {b,c}) : ((S.erase x).filter (fun y => insert a {x,y} ∈ H ∨ insert b {x,y} ∈ H)).card ≤ 1 := by classical by_contra! h obtain ⟨y,hy,z,hz,hyz⟩ := Finset.one_lt_card.mp h obtain ⟨hyS,hyE⟩ := Finset.mem_filter.mp hy obtain ⟨hzS,hzE⟩ := Finset.mem_filter.mp hz obtain ⟨hyx,hyS⟩ := Finset.mem_erase.mp hyS obtain ⟨hzx,hzS⟩ := Finset.mem_erase.mp hzS exact anchor_common_spokes_forbid_two_exterior_neighbors hu hab hac hbc hxc hyx.symm hzx.symm hyz hxa hxb (hS hyS) (hS hzS) hyE hzE /-- The number of pairs in both anchor links is at most the leaf count minus one. Their overlap forces missing pairs in the union of the links. -/ theorem anchor_common_and_missing_bounds {n : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) {a b : Fin n} (hab : a ≠ b) (W : Finset (Fin n)) (haW : a ∉ W) (hbW : b ∉ W) (hW : 4 ≤ W.card) (k m : ℕ) (hk : k = ((W.powersetCard 2).filter (fun p => insert a p ∈ H ∧ insert b p ∈ H)).card) (hm : m = ((W.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card) : k ≤ W.card - 1 ∧ (2 ≤ k → W.card - 3 ≤ m) ∧ (4 ≤ k → (W.card - 1) * (k - 2) ≤ 2 * m) := by classical let J := (W.powersetCard 2).filter (fun p => insert a p ∈ H ∧ insert b p ∈ H) let M := (W.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H) change k = J.card at hk change m = M.card at hm have hJ {p : Finset (Fin n)} (hp : p ∈ J) : p ⊆ W ∧ p.card = 2 ∧ insert a p ∈ H ∧ insert b p ∈ H := by obtain ⟨hp,hpa,hpb⟩ := Finset.mem_filter.mp hp obtain ⟨hsub,hcard⟩ := Finset.mem_powersetCard.mp hp exact ⟨hsub,hcard,hpa,hpb⟩ have hCo {p : Finset (Fin n)} (hp : p ∈ J) : p ∈ localCoExtensions H {a,b} := by obtain ⟨hpW,hp2,hpa,hpb⟩ := hJ hp apply local_mem_coextensions.mpr refine ⟨hp2,?_⟩ intro t ht rcases Finset.mem_insert.mp ht with rfl | ht · exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,fun h => haW (hpW h),hpa⟩ · obtain rfl := Finset.mem_singleton.mp ht exact Finset.mem_filter.mpr ⟨Finset.mem_univ _,fun h => hbW (hpW h),hpb⟩ have hMeet {p q : Finset (Fin n)} (hp : p ∈ J) (hq : q ∈ J) : ¬ Disjoint p q := local_coextension_pairwise hu (Finset.card_pair hab) (hCo hp) (hCo hq) have hSp {c y : Fin n} (hy : ({c,y} : Finset (Fin n)) ∈ J) (hyc : y ≠ c) : y ∈ localExtensions H {a,c} ∩ localExtensions H {b,c} := by obtain ⟨hyW,_,hya,hyb⟩ := hJ hy have hyW' : y ∈ W := hyW (by simp) have hyna : y ≠ a := fun h => haW (h ▸ hyW') have hynb : y ≠ b := fun h => hbW (h ▸ hyW') have heq (r : Fin n) : insert y ({r,c} : Finset (Fin n)) = insert r {c,y} := by ext v simp only [Finset.mem_insert,Finset.mem_singleton] tauto exact Finset.mem_inter.mpr ⟨Finset.mem_filter.mpr ⟨Finset.mem_univ _,by simp [hyna,hyc],(heq a).symm ▸ hya⟩, Finset.mem_filter.mpr ⟨Finset.mem_univ _,by simp [hynb,hyc],(heq b).symm ▸ hyb⟩⟩ have hMiss {x y : Fin n} (hx : x ∈ W) (hy : y ∈ W) (hxy : x ≠ y) (hn : ¬ (insert a {x,y} ∈ H ∨ insert b {x,y} ∈ H)) : ({x,y} : Finset (Fin n)) ∈ M := by exact Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.insert_subset hx (Finset.singleton_subset_iff.mpr hy),Finset.card_pair hxy⟩, not_or.mp hn⟩ have hNo {c x : Fin n} (hc : c ∈ W) (hx : x ∈ W) (hxc : x ≠ c) (S : Finset (Fin n)) (hs : S ⊆ localExtensions H {a,c} ∩ localExtensions H {b,c}) : ((S.erase x).filter (fun y => insert a {x,y} ∈ H ∨ insert b {x,y} ∈ H)).card ≤ 1 := anchor_cover_neighbors_card_le_one hu hab (fun h => haW (h.symm ▸ hc)) (fun h => hbW (h.symm ▸ hc)) hxc (fun h => haW (h ▸ hx)) (fun h => hbW (h ▸ hx)) S hs have hStar (hcF : ∃ c, ∀ p ∈ J, c ∈ p) (hk' : 0 < k) : ∃ c ∈ W, ∃ S ⊆ W.erase c, S.card = k ∧ S ⊆ localExtensions H {a,c} ∩ localExtensions H {b,c} := by obtain ⟨c,hc⟩ := hcF obtain ⟨p,hp⟩ := Finset.card_pos.mp (hk ▸ hk') have hcW : c ∈ W := (hJ hp).1 (hc p hp) let S := (W.erase c).filter (fun z => ({c,z} : Finset (Fin n)) ∈ J) have hS : S ⊆ W.erase c := Finset.filter_subset _ _ have hImage : S.image (fun z => ({c,z} : Finset (Fin n))) = J := by ext q constructor · intro hq obtain ⟨z,hz,rfl⟩ := Finset.mem_image.mp hq exact (Finset.mem_filter.mp hz).2 · intro hq have hqc := hc q hq obtain ⟨x,y,hxy,rfl⟩ := Finset.card_eq_two.mp (hJ hq).2.1 simp only [Finset.mem_insert,Finset.mem_singleton] at hqc rcases hqc with hcx | hcy · subst c exact Finset.mem_image.mpr ⟨y,Finset.mem_filter.mpr ⟨Finset.mem_erase.mpr ⟨hxy.symm,(hJ hq).1 (by simp)⟩,hq⟩,rfl⟩ · subst c have heq : ({y,x} : Finset (Fin n)) = {x,y} := Finset.pair_comm _ _ exact Finset.mem_image.mpr ⟨x,Finset.mem_filter.mpr ⟨Finset.mem_erase.mpr ⟨hxy,(hJ hq).1 (by simp)⟩,heq.symm ▸ hq⟩,heq⟩ refine ⟨c,hcW,S,hS,?_,fun y hy => hSp (Finset.mem_filter.mp hy).2 (Finset.mem_erase.mp (hS hy)).1⟩ rw [hk,← hImage,Finset.card_image_of_injOn] intro x hx y _ hxy change ({c,x} : Finset (Fin n)) = {c,y} at hxy exact Finset.mem_singleton.mp ((Finset.mem_insert.mp (hxy ▸ (Finset.mem_insert_of_mem (Finset.mem_singleton_self x) : x ∈ ({c,x} : Finset (Fin n))))).resolve_left (Finset.mem_erase.mp (hS hx)).1) have hStarLarge (hh : 4 ≤ k) : ∃ c, ∀ p ∈ J, c ∈ p := by rcases saturation_pairs_small_or_star J (fun p hp => (hJ hp).2.1) (fun _ hp _ hq => hMeet hp hq) with h | h · omega · exact h refine ⟨?_,?_,?_⟩ · rcases local_intersecting_pair_family J (fun p hp => (hJ hp).2.1) (fun _ hp _ hq => hMeet hp hq) with h | h | ⟨x,y,z,hxy,hxz,hyz,hJxyz⟩ · omega · by_cases hzero : k = 0 · omega obtain ⟨c,hc,S,hSW,hSk,_⟩ := hStar h (by omega) have hh := Finset.card_le_card hSW rw [Finset.card_erase_of_mem hc,hSk] at hh exact hh · have hbound : J.card ≤ 3 := by rw [hJxyz] exact (Finset.card_insert_le _ _).trans (by exact Nat.add_le_add_right ((Finset.card_insert_le _ _).trans (by simp)) 1) -- A common triangle has three edges, so the bound requires at least -- four leaves. At three leaves its overlap can indeed be three. omega · intro htwo obtain ⟨p,hp,q,hq,hpq⟩ := Finset.one_lt_card.mp (show 1 < J.card by omega) obtain ⟨c,hcp,hcq⟩ := Finset.not_disjoint_iff.mp (hMeet hp hq) have hc : c ∈ W := (hJ hp).1 hcp have spoke {r : Finset (Fin n)} (hr : r ∈ J) (hcr : c ∈ r) : ∃ y ∈ W, y ≠ c ∧ ({c,y} : Finset (Fin n)) = r := by have h := Finset.card_erase_of_mem hcr rw [(hJ hr).2.1] at h obtain ⟨y,hy⟩ := Finset.card_eq_one.mp h have hym : y ∈ r.erase c := by rw [hy]; simp obtain ⟨hyn,hyr⟩ := Finset.mem_erase.mp hym refine ⟨y,(hJ hr).1 hyr,hyn,?_⟩ rw [← hy,Finset.insert_erase hcr] obtain ⟨y,hyW,hyc,hy⟩ := spoke hp hcp obtain ⟨z,hzW,hzc,hz⟩ := spoke hq hcq have hyz : y ≠ z := fun h => hpq (hy.symm.trans (h ▸ hz)) let S : Finset (Fin n) := {y,z} let X := W \ insert c S have hSW : S ⊆ W := Finset.insert_subset hyW (Finset.singleton_subset_iff.mpr hzW) have hcS : c ∉ S := by simp [S,hyc.symm,hzc.symm] have hIS : (insert c S).card = 3 := by rw [Finset.card_insert_of_notMem hcS]; simp [S,hyz] have hX : X.card = W.card - 3 := by rw [Finset.card_sdiff_of_subset (Finset.insert_subset hc hSW),hIS] have hSE : S ⊆ localExtensions H {a,c} ∩ localExtensions H {b,c} := by intro i hi simp only [S,Finset.mem_insert,Finset.mem_singleton] at hi rcases hi with rfl | rfl · exact hSp (hy.symm ▸ hp) hyc · exact hSp (hz.symm ▸ hq) hzc have hPick (x : Fin n) (hx : x ∈ X) : ∃ u ∈ S, ({x,u} : Finset (Fin n)) ∈ M := by obtain ⟨hxW,hxN⟩ := Finset.mem_sdiff.mp hx have hxc : x ≠ c := fun h => hxN (h ▸ Finset.mem_insert_self c S) have hxS : x ∉ S := fun h => hxN (Finset.mem_insert_of_mem h) have h := hNo hc hxW hxc S hSE rw [Finset.erase_eq_of_notMem hxS] at h by_contra! hnone have heq : S.filter (fun u => insert a {x,u} ∈ H ∨ insert b {x,u} ∈ H) = S := by apply Finset.filter_eq_self.mpr intro u huS by_contra hn exact hnone u huS (hMiss hxW (hSW huS) (fun he => hxS (he ▸ huS)) hn) rw [heq,show S.card = 2 by simp [S,hyz]] at h omega let f (x : Fin n) : Finset (Fin n) := if hx : x ∈ X then {x,(hPick x hx).choose} else ∅ have hf : Set.MapsTo f X M := by intro x hx change x ∈ X at hx change f x ∈ M simpa only [f,dif_pos hx] using (hPick x hx).choose_spec.2 have hinj : (X : Set (Fin n)).InjOn f := by intro x hx x' hx' heq change x ∈ X at hx change x' ∈ X at hx' simp only [f,dif_pos hx,dif_pos hx'] at heq have hxIn : x ∈ ({x',(hPick x' hx').choose} : Finset (Fin n)) := heq ▸ Finset.mem_insert_self _ _ rcases Finset.mem_insert.mp hxIn with h | h · exact h · exact False.elim ((Finset.mem_sdiff.mp hx).2 (Finset.mem_insert_of_mem ((Finset.mem_singleton.mp h).symm ▸ (hPick x' hx').choose_spec.1))) rw [← hX,hm] exact Finset.card_le_card_of_injOn f hf hinj · intro hlarge obtain ⟨c,hc,S,hSW,hSk,hSE⟩ := hStar (hStarLarge hlarge) (by omega) let X := W.erase c let Covered (x y : Fin n) := insert a {x,y} ∈ H ∨ insert b {x,y} ∈ H let F (x : Fin n) := (S.erase x).filter (fun y => ¬ Covered x y) let D := X.sigma F have hF (x : Fin n) (hx : x ∈ X) : k - 2 ≤ (F x).card := by obtain ⟨hxc,hxW⟩ := Finset.mem_erase.mp hx have hcover := hNo hc hxW hxc S hSE change ((S.erase x).filter (Covered x)).card ≤ 1 at hcover have hSplit := Finset.card_filter_add_card_filter_not (s := S.erase x) (Covered x) change ((S.erase x).filter (Covered x)).card + (F x).card = (S.erase x).card at hSplit have hErase : S.card ≤ (S.erase x).card + 1 := by by_cases hxS : x ∈ S · rw [Finset.card_erase_of_mem hxS] have := Finset.card_pos.mpr ⟨x,hxS⟩ omega · rw [Finset.erase_eq_of_notMem hxS] omega omega have hD : (W.card - 1) * (k - 2) ≤ D.card := by rw [Finset.card_sigma] calc _ = ∑ _ ∈ X, (k - 2) := by simp [X,Finset.card_erase_of_mem hc,Nat.mul_comm] _ ≤ _ := Finset.sum_le_sum hF let f (i : Sigma (fun _ : Fin n => Fin n)) : Finset (Fin n) × Bool := ({i.1,i.2}, decide (i.1 < i.2)) let MB : Finset (Finset (Fin n) × Bool) := M ×ˢ Finset.univ have hf : Set.MapsTo f D MB := by intro i hi obtain ⟨hx,hy⟩ := Finset.mem_sigma.mp hi obtain ⟨hyS,hyN⟩ := Finset.mem_filter.mp hy obtain ⟨hneq,hyS⟩ := Finset.mem_erase.mp hyS change ({i.1,i.2}, decide (i.1 < i.2)) ∈ (M ×ˢ (Finset.univ : Finset Bool)) exact Finset.mem_product.mpr ⟨hMiss (Finset.mem_erase.mp hx).2 (Finset.mem_of_mem_erase (hSW hyS)) hneq.symm hyN,Finset.mem_univ _⟩ have hinj : (D : Set (Sigma (fun _ : Fin n => Fin n))).InjOn f := by rintro ⟨x,y⟩ hi ⟨x',y'⟩ hj heq have hxy : x ≠ y := (Finset.mem_erase.mp (Finset.mem_filter.mp (Finset.mem_sigma.mp hi).2).1).1.symm have hxy' : x' ≠ y' := (Finset.mem_erase.mp (Finset.mem_filter.mp (Finset.mem_sigma.mp hj).2).1).1.symm have hpair : ({x,y} : Finset (Fin n)) = {x',y'} := congrArg Prod.fst heq have hord : decide (x < y) = decide (x' < y') := congrArg Prod.snd heq have hx : x ∈ ({x',y'} : Finset (Fin n)) := hpair ▸ Finset.mem_insert_self _ _ have hy : y ∈ ({x',y'} : Finset (Fin n)) := hpair ▸ Finset.mem_insert_of_mem (Finset.mem_singleton_self _) simp only [Finset.mem_insert,Finset.mem_singleton] at hx hy rcases hx with rfl | rfl <;> rcases hy with rfl | rfl · exact False.elim (hxy rfl) · rfl · rcases lt_or_gt_of_ne hxy with h | h · simp [h,not_lt_of_ge h.le] at hord · simp [h,not_lt_of_ge h.le] at hord · exact False.elim (hxy rfl) have hcard := Finset.card_le_card_of_injOn f hf hinj rw [show MB = M ×ˢ (Finset.univ : Finset Bool) from rfl,Finset.card_product] at hcard have hbool : (Finset.univ : Finset Bool).card = 2 := by decide rw [hbool] at hcard omega /-- Split the triples away from the anchors into the tip region, the two single-exception layers, and at most one triple using both exceptions. -/ theorem anchor_two_exception_decomposition {n : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) (hU : ∀ e ∈ H, e.card = 3) {a b u v : Fin n} (hab : a ≠ b) (huv : u ≠ v) (W T : Finset (Fin n)) (hW : W = (Finset.univ : Finset (Fin n)) \ {a,b}) (hWT : W = T ∪ {u,v}) (huT : u ∉ T) (hvT : v ∉ T) (hT : T = localExtensions H {a,b}) : H.card + ((W.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card ≤ T.card + W.card.choose 2 + ((W.powersetCard 2).filter (fun p => insert a p ∈ H ∧ insert b p ∈ H)).card + (H.filter (· ⊆ T)).card + ((T.powersetCard 2).filter (fun p => insert u p ∈ H)).card + ((T.powersetCard 2).filter (fun p => insert v p ∈ H)).card + 1 := by classical let A : Finset (Fin n) := {a,b} let B : Finset (Fin n) := {u,v} let R := H.filter (· ⊆ W) let R₀ := H.filter (· ⊆ T) let P (w : Fin n) := (T.powersetCard 2).filter (fun p => insert w p ∈ H) let R₂ := H.filter (fun e => e ⊆ T ∪ B ∧ (e ∩ T).card = 1) have hAW : Disjoint A W := by rw [hW]; exact Finset.disjoint_sdiff have hAT : Disjoint A T := hAW.mono_right (hWT ▸ Finset.subset_union_left) have hAB : Disjoint A B := hAW.mono_right (hWT ▸ Finset.subset_union_right) have hTB : Disjoint T B := by rw [Finset.disjoint_insert_right,Finset.disjoint_singleton_right] exact ⟨huT,hvT⟩ have hTips : ∀ t ∈ T, insert t A ∈ H := fun _ ht => (Finset.mem_filter.mp (hT ▸ ht)).2.2 have hR₂ : R₂.card ≤ 1 := by have hh := anchor_tip_layer_bound (k := 1) hu hU (Finset.card_pair hab) hAT hAB hTB hTips simpa [R₂,B,huv,Nat.choose_zero_right,Nat.choose_self] using hh have hsub : R ⊆ R₀ ∪ (P u).image (insert u) ∪ (P v).image (insert v) ∪ R₂ := by intro e he obtain ⟨heH,heW⟩ := Finset.mem_filter.mp he have heV : e ⊆ T ∪ B := hWT ▸ heW have hcard := hU e heH have head {z : Fin n} (hz : z ∈ e) (hzT : z ∉ T) (hp : e.erase z ⊆ T) : e ∈ (P z).image (insert z) := by exact Finset.mem_image.mpr ⟨e.erase z,Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨hp,by rw [Finset.card_erase_of_mem hz,hcard]⟩, by rwa [Finset.insert_erase hz]⟩,Finset.insert_erase hz⟩ have inT {x : Fin n} (hx : x ∈ e) (hxu : x ≠ u) (hxv : x ≠ v) : x ∈ T := (Finset.mem_union.mp (heV hx)).resolve_right (by simp [B,hxu,hxv]) by_cases hue : u ∈ e <;> by_cases hve : v ∈ e · apply Finset.mem_union_right apply Finset.mem_filter.mpr refine ⟨heH,heV,?_⟩ have hBsub : B ⊆ e := Finset.insert_subset hue (Finset.singleton_subset_iff.mpr hve) have heq : e ∩ T = e \ B := by ext x simp only [Finset.mem_inter,Finset.mem_sdiff] exact ⟨fun h => ⟨h.1,Finset.disjoint_left.mp hTB h.2⟩,fun h => ⟨h.1,(Finset.mem_union.mp (heV h.1)).resolve_right h.2⟩⟩ rw [heq,Finset.card_sdiff_of_subset hBsub,hcard,show B.card = 2 from Finset.card_pair huv] · exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_union_right _ (head hue huT (fun x hx => let ⟨hxu,hxe⟩ := Finset.mem_erase.mp hx inT hxe hxu (fun h => hve (h ▸ hxe)))))) · exact Finset.mem_union_left _ (Finset.mem_union_right _ (head hve hvT (fun x hx => let ⟨hxv,hxe⟩ := Finset.mem_erase.mp hx inT hxe (fun h => hue (h ▸ hxe)) hxv))) · exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨heH,fun x hx => inT hx (fun h => hue (h ▸ hx)) (fun h => hve (h ▸ hx))⟩))) have hR := (Finset.card_le_card hsub).trans (Finset.card_union_le _ _) have h₁ := Finset.card_union_le (R₀ ∪ (P u).image (insert u)) ((P v).image (insert v)) have h₂ := Finset.card_union_le R₀ ((P u).image (insert u)) have h₃ := Finset.card_image_le (s := P u) (f := insert u) have h₄ := Finset.card_image_le (s := P v) (f := insert v) have hTotal := anchor_decomposition_card_le hU hab W hW rw [← hT] at hTotal change H.card + _ ≤ T.card + W.card.choose 2 + _ + R.card at hTotal change H.card + _ ≤ T.card + W.card.choose 2 + _ + R₀.card + (P u).card + (P v).card + 1 omega /-- Arithmetic exclusion when all or all but one of the leaves are tips. -/ theorem anchor_near_saturated_counts_inconsistent (d i k m r s : ℕ) (hd : 3 ≤ d) (hi : i ≤ 1) (hdi : i = 0 → 5 ≤ d) (hR : 3 * r ≤ 2 * d + m) (hS : 2 * s ≤ d) (hS' : s ≤ m + 2) (hS₀ : i = 0 → s = 0) (hSmall : 2 ≤ k → d + i - 3 ≤ m) (hLarge : 4 ≤ k → (d + i - 1) * (k - 2) ≤ 2 * m) : k + r + s < d + 2 * i + 1 + m := by by_contra! hbal by_cases h0 : i = 0 · have hd' := hdi h0 have hs := hS₀ h0 have hur : d + 3 + 2 * m ≤ 3 * k := by omega by_cases hk : k ≤ 1 · omega by_cases hk' : k ≤ 3 · have hm := hSmall (by omega) omega have hm := hLarge (by omega) have hmul := Nat.mul_le_mul_right (k - 2) (show 4 ≤ d+i-1 by omega) omega · have h1 : i = 1 := by omega have hur : 4 * m + 18 ≤ d + 6 * k := by omega by_cases hk : k ≤ 2 · omega by_cases hk' : k ≤ 3 · have hm := hSmall (by omega) omega have hm := hLarge (by omega) have heq : d + i - 1 = d := by omega rw [heq] at hm have hmul := Nat.mul_le_mul_right (k - 4) (show 3 ≤ d by omega) have hdprod : d * (k - 2) = 2 * d + d * (k - 4) := by have hEq : k - 2 = 2 + (k - 4) := by omega rw [hEq,Nat.mul_add,Nat.mul_comm d 2] rw [hdprod] at hm omega /-- A saturated pair rules out equality whenever there are at least five other vertices. -/ theorem saturated_codegree_not_extremal {n : ℕ} (hn : 7 ≤ n) {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) (hU : ∀ e ∈ H, e.card = 3) {a b : Fin n} (hab : a ≠ b) (hdeg : (localExtensions H {a,b}).card = n - 2) : H.card < n.choose 2 := by classical let A : Finset (Fin n) := {a,b} let W := (Finset.univ : Finset (Fin n)) \ A let T := localExtensions H A let M := (W.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H) let J := (W.powersetCard 2).filter (fun p => insert a p ∈ H ∧ insert b p ∈ H) let R := H.filter (· ⊆ W) have hTW : T ⊆ W := fun _ ht => Finset.mem_sdiff.mpr ⟨Finset.mem_univ _,(Finset.mem_filter.mp ht).2.1⟩ have hWcard : W.card + 2 = n := by have h := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ A) simpa [W,A,hab] using h have hTcard : T.card = n - 2 := hdeg have hT : T = W := Finset.eq_of_subset_of_card_le hTW (by omega) have haW : a ∉ W := by simp [W,A] have hbW : b ∉ W := by simp [W,A] have hTips : ∀ t ∈ W, insert t A ∈ H := fun _ ht => (Finset.mem_filter.mp (hT.symm ▸ ht)).2.2 have hTotal := anchor_decomposition_card_le hU hab W rfl change H.card + M.card ≤ T.card + W.card.choose 2 + J.card + R.card at hTotal rw [hT] at hTotal have hTarget : n.choose 2 = W.card.choose 2 + 2 * W.card + 1 := by have h₁ := Nat.choose_succ_succ' (W.card+1) 1 have h₂ := Nat.choose_succ_succ' W.card 1 have h₃ : W.card + 1 + 1 = n := by omega simp only [h₃,Nat.choose_one_right,show 1 + 1 = (2 : ℕ) by decide] at h₁ h₂ omega have hR : 3 * R.card ≤ 2 * W.card + M.card := anchor_tip_induced_card_bound_with_two_links hu hU hab W haW hbW hTips obtain ⟨_,hSmall,hLarge⟩ := anchor_common_and_missing_bounds hu hab W haW hbW (by omega) J.card M.card rfl rfl have h := anchor_near_saturated_counts_inconsistent W.card 0 J.card M.card R.card 0 (by omega) (by decide) (fun _ => by omega) hR (by omega) (by omega) (fun _ => rfl) (by simpa using hSmall) (by simpa using hLarge) omega theorem one_missed_anchor_not_extremal_of_three_tips {n : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) (hU : ∀ e ∈ H, e.card = 3) {a b w : Fin n} (hab : a ≠ b) (T : Finset (Fin n)) (hT : T = localExtensions H {a,b}) (hwT : w ∉ T) (hCov : insert w T = (Finset.univ : Finset (Fin n)) \ {a,b}) (hd : 3 ≤ T.card) : H.card < n.choose 2 := by classical let A : Finset (Fin n) := {a,b} let V := insert w T let M (S : Finset (Fin n)) := (S.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H) let J := (V.powersetCard 2).filter (fun p => insert a p ∈ H ∧ insert b p ∈ H) let R := H.filter (· ⊆ V) let R₀ := H.filter (· ⊆ T) let R₁ := H.filter (fun e => e ⊆ V ∧ w ∈ e) have hA : A.card = 2 := Finset.card_pair hab have haV : a ∉ V := by simp [V,hCov] have hbV : b ∉ V := by simp [V,hCov] have hAV : Disjoint A V := by rw [show V = _ from hCov]; exact Finset.disjoint_sdiff have hAT : Disjoint A T := hAV.mono_right (Finset.subset_insert _ _) have hAW : Disjoint A ({w} : Finset (Fin n)) := hAV.mono_right (Finset.singleton_subset_iff.mpr (Finset.mem_insert_self _ _)) have hTW : Disjoint T ({w} : Finset (Fin n)) := Finset.disjoint_singleton_right.mpr hwT have htip : ∀ t ∈ T, insert t A ∈ H := fun t ht => (Finset.mem_filter.mp (hT ▸ ht)).2.2 have h₀ : 3 * R₀.card ≤ 2 * T.card + (M V).card := by have hh := anchor_tip_induced_card_bound_with_two_links hu hU hab T (fun h => haV (Finset.mem_insert_of_mem h)) (fun h => hbV (Finset.mem_insert_of_mem h)) htip have hM : (M T).card ≤ (M V).card := Finset.card_le_card (Finset.filter_subset_filter _ (Finset.powersetCard_mono (Finset.subset_insert _ _)) : M T ⊆ M V) change 3 * R₀.card ≤ 2 * T.card + (M T).card at hh omega have hV : V = T ∪ ({w} : Finset (Fin n)) := by ext x simp [V,or_comm] have h₁ : 2 * R₁.card ≤ T.card := by have hh := anchor_tip_layer_bound (k := 2) hu hU hA hAT hAW hTW htip have hsub : R₁ ⊆ H.filter (fun e => e ⊆ T ∪ {w} ∧ (e ∩ T).card = 2) := by intro e he obtain ⟨heH,heV,hwe⟩ := Finset.mem_filter.mp he have heq : e ∩ T = e.erase w := by ext x simp only [Finset.mem_inter,Finset.mem_erase] constructor · rintro ⟨hxe,hxT⟩ exact ⟨fun h => hwT (h ▸ hxT),hxe⟩ · rintro ⟨hxw,hxe⟩ exact ⟨hxe,(Finset.mem_insert.mp (heV hxe)).resolve_left hxw⟩ exact Finset.mem_filter.mpr ⟨heH,hV ▸ heV, by rw [heq,Finset.card_erase_of_mem hwe,hU _ heH]⟩ exact (Nat.mul_le_mul_left _ (Finset.card_le_card hsub)).trans (by simpa using hh) have h₁' : R₁.card ≤ (M V).card + 2 := by have hwa : w ≠ a := fun h => haV (h ▸ Finset.mem_insert_self w T) have hwb : w ≠ b := fun h => hbV (h ▸ Finset.mem_insert_self w T) have hs := anchor_one_exception_layer_le_missing_add_two H hU hu hab hwa hwb hwT hAT htip simpa only [R₁,and_comm] using hs have hvcard : V.card = T.card + 1 := Finset.card_insert_of_notMem hwT obtain ⟨_,hSmall,hLarge⟩ := anchor_common_and_missing_bounds hu hab V haV hbV (by omega) J.card (M V).card rfl rfl have hbound := anchor_near_saturated_counts_inconsistent T.card 1 J.card (M V).card R₀.card R₁.card hd (by decide) (by intro h; contradiction) h₀ h₁ h₁' (by intro h; contradiction) (by simpa only [hvcard] using hSmall) (by simpa only [hvcard] using hLarge) have hR : R.card ≤ R₀.card + R₁.card := by have hsub : R ⊆ R₀ ∪ R₁ := by intro e he obtain ⟨heH,heV⟩ := Finset.mem_filter.mp he by_cases hw : w ∈ e · exact Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨heH,heV,hw⟩) · exact Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨heH,fun x hx => (Finset.mem_insert.mp (heV hx)).resolve_left (fun h => hw (h ▸ hx))⟩) exact (Finset.card_le_card hsub).trans (Finset.card_union_le _ _) have htotal := anchor_decomposition_card_le hU hab V hCov change H.card + (M V).card ≤ (localExtensions H {a,b}).card + V.card.choose 2 + J.card + R.card at htotal rw [← hT] at htotal have hncard : V.card + 2 = n := by have h := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ A) rw [← show V = (Finset.univ : Finset (Fin n)) \ A from hCov,hA,Finset.card_univ,Fintype.card_fin] at h exact h have htarget : n.choose 2 = V.card.choose 2 + 2 * V.card + 1 := by have h₁ := Nat.choose_succ_succ' (V.card+1) 1 have h₂ := Nat.choose_succ_succ' V.card 1 have h₃ : V.card + 1 + 1 = n := by omega simp only [h₃, Nat.choose_one_right, show 1 + 1 = (2 : ℕ) by decide] at h₁ h₂ omega omega theorem one_missed_codegree_not_extremal {n : ℕ} (hn : 6 ≤ n) {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) (hU : ∀ e ∈ H, e.card = 3) {a b : Fin n} (hab : a ≠ b) (hdeg : (localExtensions H {a,b}).card = n - 3) : H.card < n.choose 2 := by classical let A : Finset (Fin n) := {a,b} let V := (Finset.univ : Finset (Fin n)) \ A let T := localExtensions H A have hTsub : T ⊆ V := fun _ ht => Finset.mem_sdiff.mpr ⟨Finset.mem_univ _,(Finset.mem_filter.mp ht).2.1⟩ have hVcard : V.card + 2 = n := by have h := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ A) simpa [V,A,hab] using h have hTcard : T.card = n - 3 := hdeg have hmiss : (V \ T).card = 1 := by rw [Finset.card_sdiff_of_subset hTsub] omega obtain ⟨w,hw⟩ := Finset.card_eq_one.mp hmiss have hwmem : w ∈ V \ T := by rw [hw]; simp obtain ⟨hwV,hwT⟩ := Finset.mem_sdiff.mp hwmem have hCov : insert w T = V := by rw [← Finset.singleton_union,← hw,Finset.sdiff_union_of_subset hTsub] have haV : a ∉ V := by simp [V,A] have hbV : b ∉ V := by simp [V,A] exact one_missed_anchor_not_extremal_of_three_tips hu hU hab T rfl hwT hCov (by omega) /-- Count the triples wholly on the tips of a fixed anchor pair. -/ theorem anchor_tip_double_color_count {n : ℕ} (H : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ H, e.card = 3) (hU : UniqueDisjointUnions H) {a b : Fin n} (hab : a ≠ b) {T W : Finset (Fin n)} (hAW : Disjoint ({a,b} : Finset (Fin n)) W) (hTW : T ⊆ W) (hT : ∀ x ∈ T, insert x ({a,b} : Finset (Fin n)) ∈ H) : 3 * (H.filter (· ⊆ T)).card ≤ T.card.choose 2 ∧ ∃ t ≤ T.card, 3 * (H.filter (· ⊆ T)).card ≤ T.card + t + ((W.powersetCard 2).filter fun p => insert a p ∉ H ∧ insert b p ∉ H).card ∧ t * (T.card - 5) ≤ 2 * ((W.powersetCard 2).filter fun p => insert a p ∉ H ∧ insert b p ∉ H).card := by classical let A : Finset (Fin n) := {a,b} let R := H.filter (· ⊆ T) let M := (W.powersetCard 2).filter fun p => insert a p ∉ H ∧ insert b p ∉ H let I := R.sigma fun e => e let P := I.filter fun i => insert a (i.1.erase i.2) ∈ H let Q := (I \ P).filter fun i => insert b (i.1.erase i.2) ∈ H let N := (I \ P) \ Q let X := P.image Sigma.snd let Y := Q.image Sigma.snd let D := X ∩ Y have hA : A.card = 2 := by simp [A, hab] have hAT : Disjoint A T := Finset.disjoint_of_subset_right hTW hAW have hI {i} (hi : i ∈ I) : i.1 ∈ H ∧ i.1 ⊆ T ∧ i.2 ∈ i.1 := by obtain ⟨he,hx⟩ := Finset.mem_sigma.mp hi exact ⟨(Finset.mem_filter.mp he).1, (Finset.mem_filter.mp he).2, hx⟩ have hP {i} (hi : i ∈ P) : i ∈ I ∧ insert a (i.1.erase i.2) ∈ H := Finset.mem_filter.mp hi have hQ {i} (hi : i ∈ Q) : i ∈ I ∧ insert b (i.1.erase i.2) ∈ H := by obtain ⟨hi,hb⟩ := Finset.mem_filter.mp hi exact ⟨(Finset.mem_sdiff.mp hi).1,hb⟩ have hN {i} (hi : i ∈ N) : i ∈ I ∧ insert a (i.1.erase i.2) ∉ H ∧ insert b (i.1.erase i.2) ∉ H := by obtain ⟨hi,hq⟩ := Finset.mem_sdiff.mp hi obtain ⟨hj,hp⟩ := Finset.mem_sdiff.mp hi exact ⟨hj, fun ha => hp (Finset.mem_filter.mpr ⟨hj,ha⟩), fun hb => hq (Finset.mem_filter.mpr ⟨hi,hb⟩)⟩ have hIC : I.card = 3 * R.card := by rw [Finset.card_sigma] calc (∑ e ∈ R, e.card) = ∑ _e ∈ R, 3 := Finset.sum_congr rfl (fun e he => hUniform e (Finset.mem_filter.mp he).1) _ = 3 * R.card := by simp [Nat.mul_comm] have hOp {i} (hi : i ∈ I) : (i.1.erase i.2).card = 2 ∧ i.1.erase i.2 ⊆ T := by refine ⟨?_, (Finset.erase_subset _ _).trans (hI hi).2.1⟩ rw [Finset.card_erase_of_mem (hI hi).2.2, hUniform _ (hI hi).1] have hLin {e f : Finset (Fin n)} (he : e ∈ H) (hf : f ∈ H) (heT : e ⊆ T) (hfT : f ⊆ T) {p : Finset (Fin n)} (hp : p.card = 2) (hpe : p ⊆ e) (hpf : p ⊆ f) : e = f := saturation_anchor_linear hUniform hU hA hAT hT he hf heT hfT hp hpe hpf have hOpInj : Set.InjOn (fun i : (e : Finset (Fin n)) × Fin n => i.1.erase i.2) I := by intro ⟨e,x⟩ hi ⟨f,y⟩ hj h change e.erase x = f.erase y at h change ⟨e,x⟩ ∈ I at hi change ⟨f,y⟩ ∈ I at hj have heq := hLin (hI hi).1 (hI hj).1 (hI hi).2.1 (hI hj).2.1 (hOp hi).1 (Finset.erase_subset _ _) (h ▸ Finset.erase_subset y f) change e = f at heq subst f have hxy : x = y := by by_contra hne have hx : x ∈ e.erase y := Finset.mem_erase.mpr ⟨hne,(hI hi).2.2⟩ exact Finset.notMem_erase x e (h ▸ hx) subst y rfl have hAll : I.card ≤ (T.powersetCard 2).card := Finset.card_le_card_of_injOn (fun i => i.1.erase i.2) (fun _ hi => Finset.mem_powersetCard.mpr ⟨(hOp hi).2,(hOp hi).1⟩) hOpInj have hNC : N.card ≤ M.card := Finset.card_le_card_of_injOn (fun i => i.1.erase i.2) (fun _ hi => Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨(hOp (hN hi).1).2.trans hTW,(hOp (hN hi).1).1⟩,(hN hi).2⟩) (fun _ hi _ hj h => hOpInj (hN hi).1 (hN hj).1 h) have hNoAnchor {x} (hx : x ∈ T) : x ≠ a ∧ x ≠ b := ⟨fun h => Finset.disjoint_left.mp hAT (show x ∈ A by simp [A,h]) hx, fun h => Finset.disjoint_left.mp hAT (show x ∈ A by simp [A,h]) hx⟩ have hColorInj (c : Fin n) (hc : c ∈ A) {F : Finset ((e : Finset (Fin n)) × Fin n)} (hF : ∀ i ∈ F, i ∈ I ∧ insert c (i.1.erase i.2) ∈ H) : Set.InjOn (fun i : (e : Finset (Fin n)) × Fin n => i.2) F := by intro ⟨e,x⟩ hi ⟨f,y⟩ hj hxy change x = y at hxy subst y obtain ⟨hiI,hiH⟩ := hF _ hi obtain ⟨hjI,hjH⟩ := hF _ hj have hx : x ∈ e := (hI hiI).2.2 have hx' : x ∈ f := (hI hjI).2.2 suffices h : e = f by subst f; rfl by_contra hef have hd : Disjoint (e.erase x) (f.erase x) := by rw [Finset.disjoint_left] intro z hz hz' obtain ⟨hzx,hze⟩ := Finset.mem_erase.mp hz apply hef exact hLin (hI hiI).1 (hI hjI).1 (hI hiI).2.1 (hI hjI).2.1 (p := {x,z}) (by simp [hzx.symm]) (Finset.insert_subset hx (Finset.singleton_subset_iff.mpr hze)) (Finset.insert_subset hx' (Finset.singleton_subset_iff.mpr (Finset.mem_erase.mp hz').2)) let B : Finset (Fin n) := {c,x} have hcx : c ≠ x := fun h => Finset.disjoint_left.mp hAT (h ▸ hc) ((hI hiI).2.1 hx) have hB : B.card = 2 := by simp [B, hcx] have hDisj {g : Finset (Fin n)} (hg : g ⊆ T) : Disjoint (g.erase x) B := by have hcg : c ∉ g := fun h => Finset.disjoint_left.mp hAT hc (hg h) simp [B, Finset.disjoint_insert_right, hcg] have hExt {g : Finset (Fin n)} (hg : g ∈ H) (hxg : x ∈ g) (hcg : insert c (g.erase x) ∈ H) : ∀ z ∈ B, insert z (g.erase x) ∈ H := by intro z hz rcases Finset.mem_insert.mp hz with rfl | hz · exact hcg · rwa [Finset.mem_singleton.mp hz, Finset.insert_erase hxg] exact matching_supports_intersect hU (hOp hiI).1 hB (hDisj (hI hiI).2.1) (hDisj (hI hjI).2.1) (hExt (hI hiI).1 hx hiH) (hExt (hI hjI).1 hx' hjH) hd have hXP : X.card = P.card := Finset.card_image_of_injOn (hColorInj a (by simp [A]) (fun _ hi => hP hi)) have hYQ : Y.card = Q.card := Finset.card_image_of_injOn (hColorInj b (by simp [A]) (fun _ hi => hQ hi)) have hXT : X ⊆ T := by intro x hx obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hx exact (hI (hP hi).1).2.1 (hI (hP hi).1).2.2 have hYT : Y ⊆ T := by intro x hx obtain ⟨i,hi,rfl⟩ := Finset.mem_image.mp hx exact (hI (hQ hi).1).2.1 (hI (hQ hi).1).2.2 have hDsub : D ⊆ T := fun _ hx => hXT (Finset.mem_inter.mp hx).1 have hDcard := Finset.card_le_card hDsub have hPartP := Finset.card_sdiff_add_card_eq_card (Finset.filter_subset _ I : P ⊆ I) have hPartQ := Finset.card_sdiff_add_card_eq_card (Finset.filter_subset _ (I \ P) : Q ⊆ I \ P) have hPartD := Finset.card_union_add_card_inter X Y have hUnion := Finset.card_le_card (Finset.union_subset hXT hYT) have hOcc : 3 * R.card ≤ T.card + D.card + M.card := by change (I \ P).card + P.card = I.card at hPartP change N.card + Q.card = (I \ P).card at hPartQ change (X ∪ Y).card + D.card = X.card + Y.card at hPartD omega refine ⟨by simpa [hIC, Finset.card_powersetCard] using hAll, D.card,hDcard,hOcc,?_⟩ let F (x : Fin n) := T.filter fun y => ({x,y} : Finset (Fin n)) ∈ M have hF (x : Fin n) (hx : x ∈ D) : T.card - 5 ≤ (F x).card := by obtain ⟨hxX,hxY⟩ := Finset.mem_inter.mp hx obtain ⟨⟨e,u⟩,he,hu⟩ := Finset.mem_image.mp hxX obtain ⟨⟨f,v⟩,hf,hv⟩ := Finset.mem_image.mp hxY change u = x at hu change v = x at hv subst u subst v obtain ⟨heI,heA⟩ := hP he obtain ⟨hfI,hfB⟩ := hQ hf obtain ⟨heH,heT,hxe⟩ := hI heI obtain ⟨hfH,hfT,hxf⟩ := hI hfI have hEFcard : (e ∪ f).card ≤ 5 := by have h₁ := Finset.card_union_add_card_inter e f have h₂ : 0 < (e ∩ f).card := Finset.card_pos.mpr ⟨x,Finset.mem_inter.mpr ⟨hxe,hxf⟩⟩ have h₃ := hUniform e heH have h₄ := hUniform f hfH omega have hSub : T \ (e ∪ f) ⊆ F x := by intro y hy obtain ⟨hyT,hyEF⟩ := Finset.mem_sdiff.mp hy have hye : y ∉ e := fun h => hyEF (Finset.mem_union_left _ h) have hyf : y ∉ f := fun h => hyEF (Finset.mem_union_right _ h) have hxy : x ≠ y := fun h => hye (h ▸ hxe) have heNa : a ∉ e := fun h => (hNoAnchor (heT h)).1 rfl have heNb : b ∉ e := fun h => (hNoAnchor (heT h)).2 rfl have hfNa : a ∉ f := fun h => (hNoAnchor (hfT h)).1 rfl have hfNb : b ∉ f := fun h => (hNoAnchor (hfT h)).2 rfl have hAnchor : ({a,b,y} : Finset (Fin n)) ∈ H := by rw [show ({a,b,y} : Finset (Fin n)) = insert y A by ext z simp only [A, Finset.mem_insert, Finset.mem_singleton] tauto] exact hT y hyT have hAnchor' : ({b,a,y} : Finset (Fin n)) ∈ H := by rwa [show ({b,a,y} : Finset (Fin n)) = ({a,b,y} : Finset (Fin n)) by rw [Finset.insert_comm b a]] exact Finset.mem_filter.mpr ⟨hyT,Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.insert_subset (hTW (hDsub hx)) (Finset.singleton_subset_iff.mpr (hTW hyT)), by simp [hxy]⟩, saturation_splice_absence hU hab.symm hfNb hfNa hxf hyf (hNoAnchor hyT).2 (hNoAnchor hyT).1 hfH hAnchor' hfB, saturation_splice_absence hU hab heNa heNb hxe hye (hNoAnchor hyT).1 (hNoAnchor hyT).2 heH hAnchor heA⟩⟩ have hC := Finset.card_sdiff_add_card_eq_card (Finset.union_subset heT hfT) change (T \ (e ∪ f)).card + (e ∪ f).card = T.card at hC have hL := Finset.card_le_card hSub omega have hBound : (D.sigma F).card ≤ (M.sigma fun p => p).card := by refine Finset.card_le_card_of_injOn (fun i : (_ : Fin n) × Fin n => ⟨({i.1,i.2} : Finset (Fin n)),i.1⟩) ?_ ?_ · intro ⟨x,y⟩ h obtain ⟨hx,hy⟩ := Finset.mem_sigma.mp h exact Finset.mem_sigma.mpr ⟨(Finset.mem_filter.mp hy).2, by simp⟩ · intro ⟨x,y⟩ hi ⟨z,w⟩ hj heq have hxz := congrArg (fun s : (_ : Finset (Fin n)) × Fin n => s.2) heq dsimp at hxz subst z have hp := congrArg (fun s : (_ : Finset (Fin n)) × Fin n => s.1) heq dsimp at hp have hRepr {z} (hz : z ∈ F x) : z ≠ x := by intro he have hpC := (Finset.mem_powersetCard.mp (Finset.mem_filter.mp (Finset.mem_filter.mp hz).2).1).2 simp [he] at hpC have hyx := hRepr (Finset.mem_sigma.mp hi).2 have hwx := hRepr (Finset.mem_sigma.mp hj).2 have hYW : y = w := by have hh : y ∈ ({x,w} : Finset (Fin n)) := hp ▸ (by simp) simpa [hyx] using hh subst w rfl rw [Finset.card_sigma, Finset.card_sigma] at hBound have hS : (∑ p ∈ M, p.card) = 2 * M.card := by calc (∑ p ∈ M, p.card) = ∑ _p ∈ M, 2 := Finset.sum_congr rfl (fun _ hp => (Finset.mem_powersetCard.mp (Finset.mem_filter.mp hp).1).2) _ = 2 * M.card := by simp [Nat.mul_comm] calc D.card * (T.card - 5) = ∑ _x ∈ D, (T.card - 5) := by simp _ ≤ ∑ x ∈ D, (F x).card := Finset.sum_le_sum hF _ ≤ 2 * M.card := hS ▸ hBound /-- Opposite tip pairs of triples through a fixed exception have disjoint supports. -/ theorem anchor_exception_pair_disjoint {n : ℕ} {H : Finset (Finset (Fin n))} (hU : UniqueDisjointUnions H) {A T p q : Finset (Fin n)} (hA : A.card = 2) (hAT : Disjoint A T) (hTips : ∀ x ∈ T, insert x A ∈ H) {w : Fin n} (hwA : w ∉ A) (hwT : w ∉ T) (hp : p ∈ T.powersetCard 2) (hq : q ∈ T.powersetCard 2) (hep : insert w p ∈ H) (heq : insert w q ∈ H) (hne : p ≠ q) : Disjoint p q := by classical rw [Finset.disjoint_left] intro x hxp hxq obtain ⟨hpT,hpC⟩ := Finset.mem_powersetCard.mp hp obtain ⟨hqT,hqC⟩ := Finset.mem_powersetCard.mp hq obtain ⟨y,hy⟩ := Finset.card_eq_one.mp (by rw [Finset.card_erase_of_mem hxp,hpC] : (p.erase x).card = 1) obtain ⟨z,hz⟩ := Finset.card_eq_one.mp (by rw [Finset.card_erase_of_mem hxq,hqC] : (q.erase x).card = 1) have hy' : y ∈ p.erase x := by rw [hy]; simp have hz' : z ∈ q.erase x := by rw [hz]; simp obtain ⟨hyx,hyp⟩ := Finset.mem_erase.mp hy' obtain ⟨hzx,hzq⟩ := Finset.mem_erase.mp hz' have hP : p = {x,y} := (Finset.insert_erase hxp).symm.trans (by rw [hy]) have hQ : q = {x,z} := (Finset.insert_erase hxq).symm.trans (by rw [hz]) let B : Finset (Fin n) := {w,x} have hAB : Disjoint A B := by have hxA : x ∉ A := fun hx => Finset.disjoint_left.mp hAT hx (hpT hxp) simp [B, Finset.disjoint_insert_right, hwA, hxA] have hyw : y ≠ w := fun h => hwT (h ▸ hpT hyp) have hzw : z ≠ w := fun h => hwT (h ▸ hqT hzq) have hEy : insert y B ∈ H := by rw [show insert y B = insert w p by rw [hP] ext t simp only [B,Finset.mem_insert,Finset.mem_singleton] tauto] exact hep have hEz : insert z B ∈ H := by rw [show insert z B = insert w q by rw [hQ] ext t simp only [B,Finset.mem_insert,Finset.mem_singleton] tauto] exact heq have hyz := disjoint_anchor_tip_unique hU hA hAB hAT hTips (hpT hyp) (hqT hzq) (by simp [B, hyw, hyx]) (by simp [B, hzw, hzx]) hEy hEz exact hne (by rw [hP,hQ,hyz]) /-- Matchings of opposite pairs for two exceptional vertices, with their common missing pairs counted only once apart from one possible repetition. -/ theorem anchor_two_exception_layer_count {n : ℕ} {H : Finset (Finset (Fin n))} (hU : UniqueDisjointUnions H) {a b u v : Fin n} (hab : a ≠ b) (huv : u ≠ v) {T W : Finset (Fin n)} (hAW : Disjoint ({a,b} : Finset (Fin n)) W) (hTW : T ⊆ W) (huW : u ∈ W) (hvW : v ∈ W) (huT : u ∉ T) (hvT : v ∉ T) (hTips : ∀ x ∈ T, insert x ({a,b} : Finset (Fin n)) ∈ H) : ((T.powersetCard 2).filter fun p => insert u p ∈ H).card + ((T.powersetCard 2).filter fun p => insert v p ∈ H).card ≤ 2 * (T.card / 2) ∧ ((T.powersetCard 2).filter fun p => insert u p ∈ H).card + ((T.powersetCard 2).filter fun p => insert v p ∈ H).card ≤ ((W.powersetCard 2).filter fun p => insert a p ∉ H ∧ insert b p ∉ H).card + 5 := by classical let A : Finset (Fin n) := {a,b} let P (w : Fin n) := (T.powersetCard 2).filter fun p => insert w p ∈ H let M := (W.powersetCard 2).filter fun p => insert a p ∉ H ∧ insert b p ∉ H have hA : A.card = 2 := by simp [A,hab] have hAT : Disjoint A T := Finset.disjoint_of_subset_right hTW hAW have hNA {x} (hx : x ∈ W) : x ∉ A := fun h => Finset.disjoint_left.mp hAW h hx have hP {w p} (hp : p ∈ P w) : p ⊆ T ∧ p.card = 2 ∧ insert w p ∈ H := by obtain ⟨hp,h⟩ := Finset.mem_filter.mp hp obtain ⟨hs,hc⟩ := Finset.mem_powersetCard.mp hp exact ⟨hs,hc,h⟩ have hDisj {w} (hwW : w ∈ W) (hwT : w ∉ T) {p q} (hp : p ∈ P w) (hq : q ∈ P w) (hne : p ≠ q) : Disjoint p q := anchor_exception_pair_disjoint hU hA hAT hTips (hNA hwW) hwT (Finset.mem_filter.mp hp).1 (Finset.mem_filter.mp hq).1 (hP hp).2.2 (hP hq).2.2 hne have hMatch {w} (hwW : w ∈ W) (hwT : w ∉ T) : (P w).card ≤ T.card / 2 := by have hd : (P w : Set (Finset (Fin n))).PairwiseDisjoint id := by intro p hp q hq hne exact hDisj hwW hwT hp hq hne have hsub : (P w).biUnion id ⊆ T := by intro x hx obtain ⟨p,hp,hxp⟩ := Finset.mem_biUnion.mp hx exact (hP hp).1 hxp have hs := Finset.card_le_card hsub rw [Finset.card_biUnion hd] at hs have he : (∑ p ∈ P w, (id p).card) = 2 * (P w).card := by calc _ = ∑ _p ∈ P w, 2 := Finset.sum_congr rfl (fun _ hp => (hP hp).2.1) _ = _ := by simp [Nat.mul_comm] rw [he] at hs omega have hCommon (r s : Fin n) (hrs : r ≠ s) (hrT : r ∉ T) (hsT : s ∉ T) {F : Finset (Finset (Fin n))} (hm : ∀ p ∈ F, ∀ q ∈ F, p ≠ q → Disjoint p q) (hF : ∀ p ∈ F, p ∈ P r ∧ p ∈ P s) : F.card ≤ 1 := by have hNo (p q : Finset (Fin n)) (hp : p ∈ F) (hq : q ∈ F) : p = q := by by_contra hne let B : Finset (Fin n) := {r,s} have hB : B.card = 2 := by simp [B,hrs] have hD {z} (hz : z ∈ F) : Disjoint z B := by have hrz : r ∉ z := fun h => hrT ((hP (hF z hz).1).1 h) have hsz : s ∉ z := fun h => hsT ((hP (hF z hz).1).1 h) simp [B,Finset.disjoint_insert_right,hrz,hsz] have hExt {z} (hz : z ∈ F) : ∀ c ∈ B, insert c z ∈ H := by simpa [B] using And.intro (hP (hF z hz).1).2.2 (hP (hF z hz).2).2.2 exact matching_supports_intersect hU (hP (hF p hp).1).2.1 hB (hD hp) (hD hq) (hExt hp) (hExt hq) (hm p hp q hq hne) exact Finset.card_le_one.mpr (fun p hp q hq => hNo p q hp hq) have hu := hMatch huW huT have hv := hMatch hvW hvT change (P u).card + (P v).card ≤ 2 * (T.card / 2) ∧ (P u).card + (P v).card ≤ M.card + 5 refine ⟨by omega,?_⟩ have haT : a ∉ T := fun h => hNA (hTW h) (by simp [A]) have hbT : b ∉ T := fun h => hNA (hTW h) (by simp [A]) have hGood {w} (hw : w ∈ W) (ht : w ∉ T) {c} (hc : c ∈ A) (hcT : c ∉ T) : (P w ∩ P c).card ≤ 1 := hCommon w c (fun h => hNA hw (h ▸ hc)) ht hcT (fun _ hp _ hq hn => hDisj hw ht (Finset.mem_inter.mp hp).1 (Finset.mem_inter.mp hq).1 hn) (fun _ hp => Finset.mem_inter.mp hp) have hUa := hGood huW huT (show a ∈ A by simp [A]) haT have hUb := hGood huW huT (show b ∈ A by simp [A]) hbT have hVa := hGood hvW hvT (show a ∈ A by simp [A]) haT have hVb := hGood hvW hvT (show b ∈ A by simp [A]) hbT have hUV := hCommon u v huv huT hvT (fun _ hp _ hq hn => hDisj huW huT (Finset.mem_inter.mp hp).1 (Finset.mem_inter.mp hq).1 hn) (fun _ hp => (Finset.mem_inter.mp hp : _ ∧ _)) have hSub : P u ∪ P v ⊆ M ∪ (P u ∩ P a) ∪ (P u ∩ P b) ∪ (P v ∩ P a) ∪ (P v ∩ P b) := by intro p hp have hIn {w} (h : p ∈ P w) : p ∈ M ∨ p ∈ P w ∩ P a ∨ p ∈ P w ∩ P b := by have hK := (Finset.mem_filter.mp h).1 by_cases ha : insert a p ∈ H · exact Or.inr (Or.inl (Finset.mem_inter.mpr ⟨h,Finset.mem_filter.mpr ⟨hK,ha⟩⟩)) by_cases hb : insert b p ∈ H · exact Or.inr (Or.inr (Finset.mem_inter.mpr ⟨h,Finset.mem_filter.mpr ⟨hK,hb⟩⟩)) exact Or.inl (Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨(hP h).1.trans hTW,(hP h).2.1⟩,ha,hb⟩) simp only [Finset.mem_union] at hp ⊢ rcases hp with hp | hp · have := hIn hp tauto · have := hIn hp tauto have hc := Finset.card_le_card hSub have h₁ := Finset.card_union_le M (P u ∩ P a) have h₂ := Finset.card_union_le (M ∪ (P u ∩ P a)) (P u ∩ P b) have h₃ := Finset.card_union_le (M ∪ (P u ∩ P a) ∪ (P u ∩ P b)) (P v ∩ P a) have h₄ := Finset.card_union_le (M ∪ (P u ∩ P a) ∪ (P u ∩ P b) ∪ (P v ∩ P a)) (P v ∩ P b) have h₅ := Finset.card_union_add_card_inter (P u) (P v) omega /-- The counting bounds for an anchor with two missed tips force strict deficit. -/ theorem two_missed_anchor_count_contradiction (d k m r₀ r₁ r₂ t : ℕ) (hd : 1 ≤ d) (hk : k ≤ d + 1) (hBalance : d + 5 + m ≤ k + r₀ + r₁ + r₂) (hLin : 3 * r₀ ≤ d.choose 2) (ht : t ≤ d) (hColor : 3 * r₀ ≤ d + t + m) (hDouble : t * (d - 5) ≤ 2 * m) (hMatch : r₁ ≤ 2 * (d / 2)) (hMissing : r₁ ≤ m + 5) (hR₂ : r₂ ≤ 1) (hSmall : 2 ≤ k → k ≤ 3 → d - 1 ≤ m) (hLarge : 4 ≤ k → (d + 1) * (k - 2) ≤ 2 * m) : False := by have hMatch' : r₁ ≤ d := by omega have hNeed : 2 * m + 12 ≤ 3 * k + 2 * d := by omega by_cases hsmall : k ≤ 1 · by_cases hshort : d ≤ 5 · interval_cases d <;> norm_num [Nat.choose] at hLin hMatch <;> omega · have htmin : d - 1 ≤ t := by omega have hmmax : m ≤ d - 5 := by omega have hLower : 5 * (d - 5) ≤ t * (d - 5) := Nat.mul_le_mul_right _ (by omega) omega · by_cases h : k ≤ 3 · have := hSmall (by omega) h omega · have hdk : 3 ≤ d := by omega have hLarge' := hLarge (by omega) have hEq : (d + 1) * (k - 2) + 10 = (d - 2) * (k - 4) + 3 * k + 2 * d := by generalize hd' : d - 2 = x generalize hk' : k - 4 = y have hdx : d = x + 2 := by omega have hky : k = y + 4 := by omega have hk2 : k - 2 = y + 2 := by omega rw [hk2, hdx, hky] ring omega /-- A pair missing exactly two possible extensions rules out extremal equality. -/ theorem two_missed_anchor_not_extremal {n : ℕ} (hn : 5 ≤ n) {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) (hU : ∀ e ∈ H, e.card = 3) {a b : Fin n} (hab : a ≠ b) (hdeg : (localExtensions H {a,b}).card = n - 4) : H.card < n.choose 2 := by classical let A : Finset (Fin n) := {a,b} let W := (Finset.univ : Finset (Fin n)) \ A let T := localExtensions H A let M := (W.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H) let J := (W.powersetCard 2).filter (fun p => insert a p ∈ H ∧ insert b p ∈ H) let R := H.filter (· ⊆ T) let P (w : Fin n) := (T.powersetCard 2).filter (fun p => insert w p ∈ H) have hTW : T ⊆ W := fun _ ht => Finset.mem_sdiff.mpr ⟨Finset.mem_univ _,(Finset.mem_filter.mp ht).2.1⟩ have hWcard : W.card + 2 = n := by have h := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ A) simpa [W,A,hab] using h have hTcard : T.card = n - 4 := hdeg have hmiss : (W \ T).card = 2 := by rw [Finset.card_sdiff_of_subset hTW] omega obtain ⟨u,v,huv,huv'⟩ := Finset.card_eq_two.mp hmiss have hu' : u ∈ W \ T := by rw [huv']; simp have hv' : v ∈ W \ T := by rw [huv']; simp obtain ⟨huW,huT⟩ := Finset.mem_sdiff.mp hu' obtain ⟨hvW,hvT⟩ := Finset.mem_sdiff.mp hv' have hWT : W = T ∪ ({u,v} : Finset (Fin n)) := by rw [← huv',Finset.union_comm,Finset.sdiff_union_of_subset hTW] have haW : a ∉ W := by simp [W,A] have hbW : b ∉ W := by simp [W,A] have hAW : Disjoint A W := Finset.disjoint_sdiff have hTips : ∀ t ∈ T, insert t A ∈ H := fun _ ht => (Finset.mem_filter.mp ht).2.2 have hTotal := anchor_two_exception_decomposition hu hU hab huv W T rfl hWT huT hvT rfl change H.card + M.card ≤ T.card + W.card.choose 2 + J.card + R.card + (P u).card + (P v).card + 1 at hTotal have hTarget : n.choose 2 = W.card.choose 2 + 2 * W.card + 1 := by have h₁ := Nat.choose_succ_succ' (W.card+1) 1 have h₂ := Nat.choose_succ_succ' W.card 1 have h₃ : W.card + 1 + 1 = n := by omega simp only [h₃,Nat.choose_one_right,show 1 + 1 = (2 : ℕ) by decide] at h₁ h₂ omega by_contra! hfalse have hLargeW : 4 ≤ W.card := by by_contra! hsmall have hR : 3 * R.card ≤ T.card.choose 2 := anchor_tip_induced_card_bound hU hu (Finset.card_pair hab) (hAW.mono_right hTW) hTips have hP (w : Fin n) : (P w).card ≤ T.card.choose 2 := by rw [← Finset.card_powersetCard] exact Finset.card_le_card (Finset.filter_subset _ _) have hOne : T.card = 1 := by omega have hZero : T.card.choose 2 = 0 := by rw [hOne]; decide rw [hZero] at hR have hPu := hP u have hPv := hP v rw [hZero] at hPu hPv have hWthree : W.card = 3 := by omega have hJ : J.card ≤ W.card.choose 2 := by rw [← Finset.card_powersetCard] exact Finset.card_le_card (Finset.filter_subset _ _) have hChoose : W.card.choose 2 = 3 := by rw [hWthree]; decide omega obtain ⟨hk,hSmall,hLarge⟩ := anchor_common_and_missing_bounds hu hab W haW hbW hLargeW J.card M.card rfl rfl obtain ⟨hLin,t,ht,hColor,hDouble⟩ := anchor_tip_double_color_count H hU hu hab hAW hTW hTips obtain ⟨hMatch,hMissing⟩ := anchor_two_exception_layer_count hu hab huv hAW hTW huW hvW huT hvT hTips have heq : W.card = T.card + 2 := by omega rw [heq] at hk hSmall hLarge have hw : T.card + 2 - 1 = T.card + 1 := by omega have hw' : T.card + 2 - 3 = T.card - 1 := by omega rw [hw] at hk hLarge rw [hw'] at hSmall exact two_missed_anchor_count_contradiction T.card J.card M.card R.card ((P u).card + (P v).card) 1 t (by omega) hk (by omega) hLin ht hColor hDouble hMatch hMissing (by decide) (fun h _ => hSmall h) hLarge /-- Starting at order seven, an extremal pair misses at least three of its possible extensions. -/ theorem extremal_pair_codegree_le_sub_five {n : ℕ} (hn : 7 ≤ n) {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) (hU : ∀ e ∈ H, e.card = 3) (hE : H.card = n.choose 2) {p : Finset (Fin n)} (hp : p.card = 2) : (localExtensions H p).card ≤ n - 5 := by classical obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp let A : Finset (Fin n) := {a,b} let T := localExtensions H A let W := (Finset.univ : Finset (Fin n)) \ A have hT : T ⊆ W := fun _ ht => Finset.mem_sdiff.mpr ⟨Finset.mem_univ _,(Finset.mem_filter.mp ht).2.1⟩ have hW : W.card + 2 = n := by have h := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ A) simpa [W,A,hab] using h have hMax := Finset.card_le_card hT change T.card ≤ n - 5 by_contra! h have hcases : T.card = n - 2 ∨ T.card = n - 3 ∨ T.card = n - 4 := by omega rcases hcases with hfull | hone | htwo · have hl := saturated_codegree_not_extremal hn hu hU hab hfull omega · have hl := one_missed_codegree_not_extremal (by omega : 6 ≤ n) hu hU hab hone omega · have hl := two_missed_anchor_not_extremal (by omega : 5 ≤ n) hu hU hab htwo omega /-- The frozen classification holds for all orders from five through ten. -/ theorem classify_extremal_triple_families_of_order_le_ten {n : ℕ} (hn : 5 ≤ n) (hn' : n ≤ 10) (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hUnique : UniqueDisjointUnions edges) (hExtremal : edges.card = n.choose 2) : ∃ blocks : Finset (Finset (Fin n)), SteinerFive blocks ∧ IsExpansion edges blocks := by classical by_cases hsmall : n = 6 ∨ n = 7 · exact (no_extremal_family_on_six_or_seven hsmall edges hUniform hUnique hExtremal).elim apply classify_extremal_triple_families_of_pair_codegree_le_five edges hUniform hUnique hExtremal intro p hp obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp have hEq (c : Fin n) : insert c ({a,b} : Finset (Fin n)) = {a,b,c} := by ext x simp only [Finset.mem_insert,Finset.mem_singleton] tauto have hc : (localExtensions edges {a,b}).card = (edges.filter (fun e => ({a,b} : Finset (Fin n)) ⊆ e)).card := by simpa only [localExtensions,hEq] using extension_card_eq_pair_filter_card edges hUniform hab rw [← hc] by_cases hlarge : 7 ≤ n · have hbound := extremal_pair_codegree_le_sub_five hlarge hUnique hUniform hExtremal hp omega · exact (Finset.card_le_univ _).trans (by simpa using (show n ≤ 5 by omega)) /-- A high-codegree pair at equality is bounded in terms of its missing extensions. The hypotheses record the all-tip and mixed-layer two-color counts. -/ theorem anchor_many_exceptions_numeric (d r k mT mX R₀ R₁ R₂ R₃ t₀ t₁ : ℕ) (hd : 9 ≤ d) (hr : 3 ≤ r) (hBalance : d + 2 * r + 1 + (mT + mX) ≤ k + R₀ + R₁ + R₂ + R₃) (hTip : 3 * R₀ ≤ d + t₀ + mT) (hTipDouble : t₀ * (d - 5) ≤ 2 * mT) (hMixed : 2 * R₁ ≤ d + t₁ + mX + 2 * r.choose 2) (hMixedDouble : t₁ * (d - 3) ≤ 2 * mT) (hTwo : R₂ ≤ r.choose 2) (hSmall : 2 ≤ k → d + r - 3 ≤ mT + mX) (hLarge : 4 ≤ k → (d + r - 1) * (k - 2) ≤ 2 * (mT + mX)) : d + 12 * r ≤ 12 * r.choose 2 + 6 * R₃ := by have h₀ := (Nat.mul_le_mul_left t₀ (show 4 ≤ d - 5 by omega)).trans hTipDouble have h₁ := (Nat.mul_le_mul_left t₁ (show 6 ≤ d - 3 by omega)).trans hMixedDouble have hLayers : 6 * (R₀ + R₁) ≤ 5 * d + 4 * (mT + mX) + 6 * r.choose 2 := by omega have hOverlap : 6 * k ≤ 6 + 2 * (mT + mX) := by by_cases hk₁ : k ≤ 1 · omega by_cases hk₃ : k ≤ 3 · have := hSmall (by omega) omega · have h := (Nat.mul_le_mul_right (k - 2) (show 11 ≤ d + r - 1 by omega)).trans (hLarge (by omega)) omega omega /-- Decompose all triples away from the anchor by their number of tip vertices. -/ theorem anchor_exception_layer_partition {n : ℕ} {H : Finset (Finset (Fin n))} (hU : ∀ e ∈ H, e.card = 3) {W T : Finset (Fin n)} (hTW : T ⊆ W) : (H.filter (· ⊆ W)).card ≤ (H.filter (· ⊆ T)).card + ((W \ T).sigma (fun x => (T.powersetCard 2).filter (fun p => insert x p ∈ H))).card + (H.filter (fun e => e ⊆ T ∪ (W \ T) ∧ (e ∩ T).card = 1)).card + (H.filter (· ⊆ W \ T)).card := by classical let X := W \ T let R₀ := H.filter (· ⊆ T) let D := X.sigma (fun x => (T.powersetCard 2).filter (fun p => insert x p ∈ H)) let R₁ := D.image (fun i => insert i.1 i.2) let R₂ := H.filter (fun e => e ⊆ T ∪ X ∧ (e ∩ T).card = 1) let R₃ := H.filter (· ⊆ X) have hW : T ∪ X = W := by rw [Finset.union_comm] exact Finset.sdiff_union_of_subset hTW have hCover : H.filter (· ⊆ W) ⊆ R₀ ∪ R₁ ∪ R₂ ∪ R₃ := by intro e he obtain ⟨heH, heW⟩ := Finset.mem_filter.mp he have he₃ := hU e heH have hsub : e ∩ T ⊆ e := Finset.inter_subset_left have hle := Finset.card_le_card hsub by_cases heT : e ⊆ T · exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_filter.mpr ⟨heH, heT⟩))) have hu : (e ∩ T).card ≠ 3 := by intro h have heq := Finset.eq_of_subset_of_card_le hsub (by omega) exact heT (heq ▸ Finset.inter_subset_right) have cases : (e ∩ T).card = 0 ∨ (e ∩ T).card = 1 ∨ (e ∩ T).card = 2 := by omega rcases cases with h | h | h · apply Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨heH, ?_⟩) intro x hx refine Finset.mem_sdiff.mpr ⟨heW hx, fun hxt => ?_⟩ have hxI := Finset.mem_inter.mpr ⟨hx, hxt⟩ rw [Finset.card_eq_zero.mp h] at hxI exact Finset.notMem_empty _ hxI · exact Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_filter.mpr ⟨heH, hW ▸ heW, h⟩)) · have hdiff : (e \ (e ∩ T)).card = 1 := by rw [Finset.card_sdiff_of_subset hsub, he₃, h] obtain ⟨x, hx⟩ := Finset.card_eq_one.mp hdiff have hxe : x ∈ e ∧ x ∉ e ∩ T := Finset.mem_sdiff.mp (by simp [hx]) have hxX : x ∈ X := Finset.mem_sdiff.mpr ⟨heW hxe.1, fun hxt => hxe.2 (Finset.mem_inter.mpr ⟨hxe.1, hxt⟩)⟩ have heq : insert x (e ∩ T) = e := by rw [← Finset.singleton_union, ← hx, Finset.sdiff_union_of_subset hsub] have hxD : (⟨x,e ∩ T⟩ : Sigma (fun _ : Fin n => Finset (Fin n))) ∈ D := Finset.mem_sigma.mpr ⟨hxX, Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨Finset.inter_subset_right, h⟩, by change insert x (e ∩ T) ∈ H rwa [heq]⟩⟩ exact Finset.mem_union_left _ (Finset.mem_union_left _ (Finset.mem_union_right _ (Finset.mem_image.mpr ⟨_, hxD, heq⟩))) have hC := Finset.card_le_card hCover have h₁ := Finset.card_union_le (R₀ ∪ R₁ ∪ R₂) R₃ have h₂ := Finset.card_union_le (R₀ ∪ R₁) R₂ have h₃ := Finset.card_union_le R₀ R₁ have h₄ : R₁.card ≤ D.card := Finset.card_image_le change (H.filter (· ⊆ W)).card ≤ R₀.card + D.card + R₂.card + R₃.card omega /-- With at least nine tips and at least three missing tips, the codegree is bounded by the number of missed pairs and the number of triples on missed vertices. The only additional premise is the two-color bound on the mixed layer. -/ theorem extremal_anchor_many_exceptions_of_mixed_bound {n : ℕ} {H : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions H) (hU : ∀ e ∈ H, e.card = 3) (hE : H.card = n.choose 2) {a b : Fin n} (hab : a ≠ b) {T W : Finset (Fin n)} (hT : T = localExtensions H {a,b}) (hW : W = (Finset.univ : Finset (Fin n)) \ {a,b}) (hd : 9 ≤ T.card) (hr : 3 ≤ (W \ T).card) (hMixed : ∃ t : ℕ, 2 * ((W \ T).sigma (fun x => (T.powersetCard 2).filter (fun p => insert x p ∈ H))).card ≤ T.card + t + (((W.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)) \ ((T.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H))).card + 2 * (W \ T).card.choose 2 ∧ t * (T.card - 3) ≤ 2 * ((T.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H)).card) : T.card + 12 * (W \ T).card ≤ 12 * (W \ T).card.choose 2 + 6 * (H.filter (· ⊆ W \ T)).card := by classical let A : Finset (Fin n) := {a,b} let X := W \ T let R₀ := H.filter (· ⊆ T) let R₁ := X.sigma (fun x => (T.powersetCard 2).filter (fun p => insert x p ∈ H)) let R₂ := H.filter (fun e => e ⊆ T ∪ X ∧ (e ∩ T).card = 1) let R₃ := H.filter (· ⊆ X) let M (S : Finset (Fin n)) := (S.powersetCard 2).filter (fun p => insert a p ∉ H ∧ insert b p ∉ H) let J := (W.powersetCard 2).filter (fun p => insert a p ∈ H ∧ insert b p ∈ H) have hTW : T ⊆ W := by rw [hW, hT] exact fun _ ht => Finset.mem_sdiff.mpr ⟨Finset.mem_univ _, (Finset.mem_filter.mp ht).2.1⟩ have hAW : Disjoint A W := hW ▸ Finset.disjoint_sdiff have hAT : Disjoint A T := hAW.mono_right hTW have hAX : Disjoint A X := hAW.mono_right Finset.sdiff_subset have hTX : Disjoint T X := Finset.disjoint_sdiff have hTips : ∀ v ∈ T, insert v A ∈ H := fun _ hv => (Finset.mem_filter.mp (hT ▸ hv)).2.2 have haW : a ∉ W := by simp [hW] have hbW : b ∉ W := by simp [hW] have hX : W.card = T.card + X.card := by have h := Finset.card_sdiff_add_card_eq_card hTW change X.card + T.card = W.card at h omega have hWcard : W.card + 2 = n := by have h := Finset.card_sdiff_add_card_eq_card (Finset.subset_univ A) simpa [hW, A, hab] using h have hTarget : n.choose 2 = W.card.choose 2 + 2 * W.card + 1 := by have h₁ := Nat.choose_succ_succ' (W.card+1) 1 have h₂ := Nat.choose_succ_succ' W.card 1 have h₃ : W.card + 1 + 1 = n := by omega simp only [h₃, Nat.choose_one_right, show 1 + 1 = (2 : ℕ) by decide] at h₁ h₂ omega have hM : M T ⊆ M W := by intro p hp obtain ⟨hp, h⟩ := Finset.mem_filter.mp hp obtain ⟨hp, h₂⟩ := Finset.mem_powersetCard.mp hp exact Finset.mem_filter.mpr ⟨Finset.mem_powersetCard.mpr ⟨hp.trans hTW, h₂⟩, h⟩ have hMcard : (M T).card + (M W \ M T).card = (M W).card := by rw [Nat.add_comm] exact Finset.card_sdiff_add_card_eq_card hM have hD := anchor_decomposition_card_le hU hab W hW change H.card + (M W).card ≤ (localExtensions H {a,b}).card + W.card.choose 2 + J.card + (H.filter (· ⊆ W)).card at hD rw [← hT, hE, hTarget] at hD have hP := anchor_exception_layer_partition hU hTW change (H.filter (· ⊆ W)).card ≤ R₀.card + R₁.card + R₂.card + R₃.card at hP have hBal : T.card + 2 * X.card + 1 + ((M T).card + (M W \ M T).card) ≤ J.card + R₀.card + R₁.card + R₂.card + R₃.card := by omega have h₂ : R₂.card ≤ X.card.choose 2 := by simpa [R₂] using anchor_tip_layer_bound (k := 1) hu hU (Finset.card_pair hab) hAT hAX hTX hTips obtain ⟨_, hSmall, hLarge⟩ := anchor_common_and_missing_bounds hu hab W haW hbW (by omega) J.card (M W).card rfl rfl rw [hX, ← hMcard] at hSmall hLarge obtain ⟨_, t₀, _, ht₀, ht₀'⟩ := anchor_tip_double_color_count H hU hu hab hAT (fun _ h => h : T ⊆ T) hTips obtain ⟨t₁, ht₁, ht₁'⟩ := hMixed exact anchor_many_exceptions_numeric T.card X.card J.card (M T).card (M W \ M T).card R₀.card R₁.card R₂.card R₃.card t₀ t₁ hd hr hBal ht₀ ht₀' ht₁ ht₁' h₂ hSmall hLarge /-- The block and point incidence counts give the design divisibility conditions for an S(2,5,n). -/ theorem steiner_five_divisibility {n : ℕ} (hn : 0 < n) {blocks : Finset (Finset (Fin n))} (hs : SteinerFive blocks) : 4 ∣ n - 1 ∧ 10 ∣ n.choose 2 := by classical obtain ⟨hSize,hCover⟩ := hs constructor · let v : Fin n := ⟨0, hn⟩ let B := blocks.filter (fun b => v ∈ b) let W := (Finset.univ : Finset (Fin n)).erase v have hUnion : B.biUnion (fun b => b.erase v) = W := by ext x constructor · intro hx obtain ⟨b,_,hx⟩ := Finset.mem_biUnion.mp hx exact Finset.mem_erase.mpr ⟨(Finset.mem_erase.mp hx).1, Finset.mem_univ _⟩ · intro hx have hne := (Finset.mem_erase.mp hx).1 obtain ⟨b,⟨hb,hsub⟩,_⟩ := hCover {x,v} (Finset.card_pair hne) exact Finset.mem_biUnion.mpr ⟨b,Finset.mem_filter.mpr ⟨hb,hsub (by simp)⟩, Finset.mem_erase.mpr ⟨hne,hsub (by simp)⟩⟩ have hDisjoint : (B : Set (Finset (Fin n))).PairwiseDisjoint (fun b => b.erase v) := by intro b hb c hc hne apply Finset.disjoint_left.mpr intro x hxb hxc obtain ⟨hxbv,hxb⟩ := Finset.mem_erase.mp hxb obtain ⟨_,hxc⟩ := Finset.mem_erase.mp hxc obtain ⟨hb,hvb⟩ := Finset.mem_filter.mp (show b ∈ B from hb) obtain ⟨hc,hvc⟩ := Finset.mem_filter.mp (show c ∈ B from hc) obtain ⟨u,_,hu⟩ := hCover {x,v} (Finset.card_pair hxbv) exact hne ((hu b ⟨hb,Finset.insert_subset hxb (Finset.singleton_subset_iff.mpr hvb)⟩).trans (hu c ⟨hc,Finset.insert_subset hxc (Finset.singleton_subset_iff.mpr hvc)⟩).symm) have hCard : ∀ b ∈ B, (b.erase v).card = 4 := by intro b hb obtain ⟨hb,hvb⟩ := Finset.mem_filter.mp hb rw [Finset.card_erase_of_mem hvb, hSize b hb] have hW : W.card = n - 1 := by simp [W] refine ⟨B.card, ?_⟩ rw [← hW, ← hUnion, Finset.card_biUnion hDisjoint, Finset.sum_congr rfl hCard] simp [Nat.mul_comm] · let P := (Finset.univ : Finset (Fin n)).powersetCard 2 have hUnion : blocks.biUnion (fun b => b.powersetCard 2) = P := by ext p simp only [Finset.mem_biUnion, Finset.mem_powersetCard, P, Finset.subset_univ, true_and] constructor · rintro ⟨b,hb,hsub,h₂⟩ exact h₂ · intro h₂ obtain ⟨b,⟨hb,hsub⟩,_⟩ := hCover p h₂ exact ⟨b,hb,hsub,h₂⟩ have hDisjoint : (blocks : Set (Finset (Fin n))).PairwiseDisjoint (fun b => b.powersetCard 2) := by intro b hb c hc hne apply Finset.disjoint_left.mpr intro p hpb hpc obtain ⟨hpb,h₂⟩ := Finset.mem_powersetCard.mp hpb obtain ⟨hpc,_⟩ := Finset.mem_powersetCard.mp hpc obtain ⟨u,_,hu⟩ := hCover p h₂ exact hne ((hu b ⟨hb,hpb⟩).trans (hu c ⟨hc,hpc⟩).symm) have hCard : ∀ b ∈ blocks, (b.powersetCard 2).card = 10 := by intro b hb rw [Finset.card_powersetCard,hSize b hb] decide have hP : P.card = n.choose 2 := by simp [P,Finset.card_powersetCard] refine ⟨blocks.card, ?_⟩ rw [← hP, ← hUnion, Finset.card_biUnion hDisjoint, Finset.sum_congr rfl hCard] simp [Nat.mul_comm] theorem local_six_both_companions_same {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {x a b c : Fin n} (hxa : x ≠ a) (hmax : (localExtensions edges {x,a}).card ≤ 6) (hb : b ∈ localFiveCompanions x a) (hc : c ∈ localFiveCompanions a x) (hB : 4 ≤ (localFiveOverlap edges x a b).card) (hC : 4 ≤ (localFiveOverlap edges a x c).card) : b = c := by let B := localFiveOverlap edges x a b let C := localFiveOverlap edges a x c let T := localExtensions edges {x,a} have hBT : B ⊆ T := Finset.inter_subset_left have hCT : C ⊆ T := by rw [show T = localExtensions edges {a,x} from local_neighbors_comm] exact Finset.inter_subset_left have hcap := Finset.card_le_card (Finset.union_subset hBT hCT) have hc' := Finset.card_union_add_card_inter B C change B.card ≥ 4 at hB change C.card ≥ 4 at hC change T.card ≤ 6 at hmax have ⟨u,hu',v,hv',huv⟩ := Finset.one_lt_card.mp (by omega : 1 < (B ∩ C).card) obtain ⟨huB,huC⟩ := Finset.mem_inter.mp hu' obtain ⟨hvB,hvC⟩ := Finset.mem_inter.mp hv' have huBN : u ∈ localExtensions edges {x,b} := (Finset.mem_inter.mp huB).2 have huCN : u ∈ localExtensions edges {a,c} := (Finset.mem_inter.mp huC).2 have hvBN : v ∈ localExtensions edges {x,b} := (Finset.mem_inter.mp hvB).2 have hvCN : v ∈ localExtensions edges {a,c} := (Finset.mem_inter.mp hvC).2 have ⟨hba,hbx⟩ := local_mem_five_companions.mp hb have ⟨hcx,hca⟩ := local_mem_five_companions.mp hc by_contra hbc have hdis : Disjoint ({x,b} : Finset (Fin n)) {a,c} := by rw [Finset.disjoint_left] intro z hz hz' simp only [Finset.mem_insert,Finset.mem_singleton] at hz hz' aesop exact local_extension_edges_cross hu (by simp [hbx.symm]) (by simp [hca.symm]) huv huBN hvBN huCN hvCN hdis theorem local_six_opposite_score_zero_of_two {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {x t a b : Fin n} (hxt : x ≠ t) (hcap : (localExtensions edges {x,t}).card ≤ 6) (ha : a ∈ localFiveCompanions x t) (hb : b ∈ localFiveCompanions x t) (hab : a ≠ b) (hA : 4 ≤ (localFiveOverlap edges x t a).card) (hB : 4 ≤ (localFiveOverlap edges x t b).card) : localFiveScore edges t x = 0 := by unfold localFiveScore apply Finset.sum_eq_zero intro c hc suffices (localFiveOverlap edges t x c).card ≤ 3 by omega by_contra hn have hC : 4 ≤ (localFiveOverlap edges t x c).card := by omega exact hab ((local_six_both_companions_same hu hxt hcap ha hc hA hC).trans (local_six_both_companions_same hu hxt hcap hb hc hB hC).symm) theorem local_six_other_companion_small_of_three_common_extensions {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {x t y z : Fin n} (hxt : x ≠ t) (hxy : x ≠ y) (hyt : y ≠ t) (h5 : (localExtensions edges {x,t}).card ≤ 5) (hcommon : 3 ≤ (localFiveOverlap edges t x y).card) (hz : z ∈ localFiveCompanions x t) (hzy : z ≠ y) : (localFiveOverlap edges x t z).card ≤ 3 := by let U := localFiveOverlap edges x t z let R := localFiveOverlap edges t x y let T := localExtensions edges {x,t} have hUT : U ⊆ T := Finset.inter_subset_left have hRT : R ⊆ T := by rw [show T = localExtensions edges {t,x} from local_neighbors_comm] exact Finset.inter_subset_left have hc := Finset.card_le_card (Finset.union_subset hUT hRT) have hs := Finset.card_union_add_card_inter U R change T.card ≤ 5 at h5 change 3 ≤ R.card at hcommon change U.card ≤ 3 by_contra hU obtain ⟨a, ha, b, hb, hab⟩ := Finset.one_lt_card.mp (show 1 < (U ∩ R).card by omega) obtain ⟨hzt, hzx⟩ := local_mem_five_companions.mp hz have hdis : Disjoint ({x,z} : Finset (Fin n)) {t,y} := by rw [Finset.disjoint_left] intro w hw hw' simp only [Finset.mem_insert, Finset.mem_singleton] at hw hw' aesop exact local_extension_edges_cross hu (by simp [hzx.symm]) (by simp [hyt.symm]) hab (Finset.mem_inter.mp (Finset.mem_inter.mp ha).1).2 (Finset.mem_inter.mp (Finset.mem_inter.mp hb).1).2 (Finset.mem_inter.mp (Finset.mem_inter.mp ha).2).2 (Finset.mem_inter.mp (Finset.mem_inter.mp hb).2).2 hdis /-- A large common neighborhood through the other end prevents many large overlaps through the first end of a degree-six pair. -/ theorem local_six_score_le_seven_of_three_common_extensions {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 6) {x t y : Fin n} (hxt : x ≠ t) (hxy : x ≠ y) (hyt : y ≠ t) (h6 : (localExtensions edges {x,t}).card = 6) (hcommon : 3 ≤ (localFiveOverlap edges t x y).card) : localFiveScore edges x t ≤ 7 := by let T := localExtensions edges {x,t} let C := localFiveCompanions x t have hRsub : localFiveOverlap edges t x y ⊆ T := by rw [show T = localExtensions edges {t,x} from local_neighbors_comm] exact Finset.inter_subset_left obtain ⟨R, hR, hR3⟩ := Finset.exists_subset_card_eq hcommon have hRT : R ⊆ T := hR.trans hRsub have hB : (T \ R).card = 3 := by rw [Finset.card_sdiff_of_subset hRT, h6, hR3] obtain ⟨b, hb⟩ := Finset.card_pos.mp (show 0 < (T \ R).card by omega) have hbT := (Finset.mem_sdiff.mp hb).1 have hxb := (local_neighbors_ne hbT).1.symm have htb : t ∈ localExtensions edges {x,b} := local_neighbors_symm hxt hbT let F := C.filter fun z => b ∈ localExtensions edges {x,z} have hF : F.card ≤ 5 := by have hsub : F ⊆ (localExtensions edges {x,b}).erase t := by intro z hz obtain ⟨hz, hzb⟩ := Finset.mem_filter.mp hz obtain ⟨hzt, hzx⟩ := local_mem_five_companions.mp hz exact Finset.mem_erase.mpr ⟨hzt, local_neighbors_symm hzx.symm hzb⟩ have hc := Finset.card_le_card hsub rw [Finset.card_erase_of_mem htb] at hc have := hd x b hxb omega have hpoint (z : Fin n) (hz : z ∈ C) : (localFiveOverlap edges x t z).card - 3 ≤ (if b ∈ localExtensions edges {x,z} then 1 else 0) + (if z = y then 2 else 0) := by let U := localFiveOverlap edges x t z have hUT : U ⊆ T := Finset.inter_subset_left have hU6 := (Finset.card_le_card hUT).trans_eq h6 by_cases hzy : z = y · by_cases hbz : b ∈ localExtensions edges {x,z} · rw [if_pos hbz, if_pos hzy] change U.card - 3 ≤ 1 + 2 omega · have hsub : U ⊆ T.erase b := by intro w hw have hwz := (Finset.mem_inter.mp hw).2 exact Finset.mem_erase.mpr ⟨fun he => hbz (he ▸ hwz), hUT hw⟩ have hc := Finset.card_le_card hsub rw [Finset.card_erase_of_mem hbT, h6] at hc rw [if_neg hbz, if_pos hzy] change U.card - 3 ≤ 0 + 2 omega · obtain ⟨hzt, hzx⟩ := local_mem_five_companions.mp hz have hI : (U ∩ R).card ≤ 1 := by apply Finset.card_le_one_iff.mpr intro a d ha hd' by_contra had have hdis : Disjoint ({x,z} : Finset (Fin n)) {t,y} := by rw [Finset.disjoint_left] intro w hw hw' simp only [Finset.mem_insert, Finset.mem_singleton] at hw hw' aesop exact local_extension_edges_cross hu (by simp [hzx.symm]) (by simp [hyt.symm]) had (Finset.mem_inter.mp (Finset.mem_inter.mp ha).1).2 (Finset.mem_inter.mp (Finset.mem_inter.mp hd').1).2 (Finset.mem_inter.mp (hR (Finset.mem_inter.mp ha).2)).2 (Finset.mem_inter.mp (hR (Finset.mem_inter.mp hd').2)).2 hdis have hUB : U \ R ⊆ T \ R := fun w hw => Finset.mem_sdiff.mpr ⟨hUT (Finset.mem_sdiff.mp hw).1, (Finset.mem_sdiff.mp hw).2⟩ have hUBc := (Finset.card_le_card hUB).trans_eq hB have hsplit := Finset.card_sdiff_add_card_inter U R by_cases hc : U.card ≤ 3 · exact le_trans (show U.card - 3 ≤ 0 by omega) (Nat.zero_le _) · have he : U \ R = T \ R := Finset.eq_of_subset_of_card_le hUB (by omega) have hbU := (Finset.mem_sdiff.mp (he.symm ▸ hb)).1 have hbz := (Finset.mem_inter.mp hbU).2 rw [if_pos hbz, if_neg hzy] change U.card - 3 ≤ 1 + 0 omega unfold localFiveScore change (∑ z ∈ C, _) ≤ 7 refine (Finset.sum_le_sum hpoint).trans ?_ rw [Finset.sum_add_distrib, ← Finset.card_filter] change F.card + (∑ z ∈ C, if z = y then 2 else 0) ≤ 7 have hs : (∑ z ∈ C, if z = y then (2 : ℕ) else 0) ≤ 2 := by rw [Finset.sum_ite_eq'] split <;> omega omega theorem local_six_overlap_capacity {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) {x a : Fin n} (hxa : x ≠ a) : ∑ b ∈ localFiveCompanions x a, (localFiveOverlap edges x a b).card ≤ 5 * (localExtensions edges {x,a}).card := by classical let T := localExtensions edges {x,a} let C := localFiveCompanions x a have h : ∀ b ∈ C, (localFiveOverlap edges x a b).card = ({t ∈ T | t ∈ localExtensions edges {x,b}}).card := by intro b hb rfl have hSwap : ∑ b ∈ C, ({t ∈ T | t ∈ localExtensions edges {x,b}}).card = ∑ t ∈ T, ({b ∈ C | t ∈ localExtensions edges {x,b}}).card := by simp only [Finset.card_filter] exact Finset.sum_comm calc _ = ∑ b ∈ C, ({t ∈ T | t ∈ localExtensions edges {x,b}}).card := Finset.sum_congr rfl h _ = ∑ t ∈ T, ({b ∈ C | t ∈ localExtensions edges {x,b}}).card := hSwap _ ≤ ∑ _t ∈ T, (5 : ℕ) := by apply Finset.sum_le_sum intro t ht have hxt := (local_neighbors_ne ht).1.symm have ha : a ∈ localExtensions edges {x,t} := local_neighbors_symm hxa ht have hsub : {b ∈ C | t ∈ localExtensions edges {x,b}} ⊆ (localExtensions edges {x,t}).erase a := by intro b hb obtain ⟨hb,hbt⟩ := Finset.mem_filter.mp hb obtain ⟨hba,hbx⟩ := local_mem_five_companions.mp hb exact Finset.mem_erase.mpr ⟨hba,local_neighbors_symm hbx.symm hbt⟩ have hc := Finset.card_le_card hsub rw [Finset.card_erase_of_mem ha] at hc have := hd x t hxt omega _ = _ := by simp [T,Nat.mul_comm] def localSixPotential (d : ℕ) : ℕ := if d = 6 then 6 else localFivePotential d theorem local_six_excess_identity {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) (havg : ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, (localExtensions edges p).card = 3 * n.choose 2) : let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let d := fun p => (localExtensions edges p).card ∑ p ∈ P, ((localCoExtensions edges p).card - 3) = (∑ p ∈ P, localSixPotential (d p)) + 3 * (P.filter (fun p => d p = 0)).card + (P.filter (fun p => d p = 1)).card + ∑ p ∈ P, (3 - (localCoExtensions edges p).card) := by classical dsimp only let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let d := fun p => (localExtensions edges p).card let g := fun p => (localCoExtensions edges p).card have hsize : P.card = n.choose 2 := by simp [P,Finset.card_powersetCard] have hsum : ∑ p ∈ P, g p = ∑ p ∈ P, (d p).choose 2 := local_coextension_double_count edges have hg : ∑ p ∈ P, (g p + (3 - g p)) = ∑ p ∈ P, (3 + (g p - 3)) := by apply Finset.sum_congr rfl intro p hp omega have hcalc : ∑ p ∈ P, ((d p).choose 2 + 3) = ∑ p ∈ P, (2 * d p + localSixPotential (d p) + 3 * (if d p = 0 then 1 else 0) + (if d p = 1 then 1 else 0)) := by apply Finset.sum_congr rfl intro p hp obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp (Finset.mem_powersetCard.mp hp).2 have hl : d ({a,b} : Finset (Fin n)) ≤ 6 := hd a b hab interval_cases h : d ({a,b} : Finset (Fin n)) <;> decide simp only [Finset.sum_add_distrib,← Finset.mul_sum,← Finset.card_filter, Finset.sum_const,nsmul_eq_mul,Nat.cast_id,hsize] at hg hcalc change ∑ p ∈ P, d p = 3 * n.choose 2 at havg change ∑ p ∈ P, (g p - 3) = (∑ p ∈ P, localSixPotential (d p)) + 3 * (P.filter (fun p => d p = 0)).card + (P.filter (fun p => d p = 1)).card + ∑ p ∈ P, (3 - g p) omega theorem local_six_both_score_le {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) {x a : Fin n} (hxa : x ≠ a) (hpos : 0 < localFiveScore edges x a) (hA : 0 < localFiveScore edges a x) : localFiveScore edges x a + localFiveScore edges a x ≤ 2 * ((localExtensions edges {x,a}).card - 3) := by have ex : ∀ (u v : Fin n), 0 < localFiveScore edges u v → ∃ b ∈ localFiveCompanions u v, 4 ≤ (localFiveOverlap edges u v b).card := by intro u v hv by_contra hn push Not at hn have hh : localFiveScore edges u v = 0 := by unfold localFiveScore apply Finset.sum_eq_zero intro b hb have := hn b hb omega omega obtain ⟨b,hb,hB⟩ := ex x a hpos obtain ⟨c,hc,hC⟩ := ex a x hA have hmax := hd x a hxa have he := local_six_both_companions_same hu hxa hmax hb hc hB hC subst c have hW : localFiveScore edges x a = (localFiveOverlap edges x a b).card - 3 := by unfold localFiveScore apply Finset.sum_eq_single b · intro z hz hzb by_contra hh exact hzb (local_six_both_companions_same hu hxa hmax hz hc (by omega) hC) · exact fun h => (h hb).elim have hW' : localFiveScore edges a x = (localFiveOverlap edges a x b).card - 3 := by unfold localFiveScore apply Finset.sum_eq_single b · intro z hz hzb by_contra hh exact hzb (local_six_both_companions_same hu hxa hmax hb hz hB (by omega)).symm · exact fun h => (h hc).elim have h₁ : (localFiveOverlap edges x a b).card ≤ (localExtensions edges {x,a}).card := Finset.card_le_card Finset.inter_subset_left have h₂ : (localFiveOverlap edges a x b).card ≤ (localExtensions edges {a,x}).card := Finset.card_le_card Finset.inter_subset_left rw [local_neighbors_comm (a := a) (b := x)] at h₂ omega theorem local_six_score_at_five {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) {x a : Fin n} (hxa : x ≠ a) (h5 : (localExtensions edges {x,a}).card = 5) : let e := (localFiveContainmentClass edges x a).card - 1 let q := ({b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 4}).card localFiveScore edges x a = 2 * e + q ∧ 5 * e + 4 * q ≤ 25 := by dsimp only let T := localExtensions edges {x,a} let A := localFiveContainmentClass edges x a let C := localFiveCompanions x a have haa : a ∈ A := local_mem_five_twin_class.mpr ⟨hxa,Finset.Subset.rfl⟩ have hclass : A.erase a = C.filter (fun b => (localFiveOverlap edges x a b).card = 5) := by ext b rw [Finset.mem_erase,Finset.mem_filter,local_mem_five_companions,local_mem_five_twin_class] simp only [and_assoc,ne_comm (a := x) (b := b)] refine and_congr_right fun _ => and_congr_right fun _ => ?_ change T ⊆ localExtensions edges {x,b} ↔ (T ∩ localExtensions edges {x,b}).card = 5 constructor · intro h rw [Finset.inter_eq_left.mpr h] exact h5 · intro h have hh : T ∩ localExtensions edges {x,b} = T := Finset.eq_of_subset_of_card_le Finset.inter_subset_left (by rw [h5,h]) exact Finset.inter_eq_left.mp hh have heq : (localFiveContainmentClass edges x a).card - 1 = (C.filter (fun b => (localFiveOverlap edges x a b).card = 5)).card := by rw [← Finset.card_erase_of_mem haa,hclass] have hc : ∀ b : Fin n, (localFiveOverlap edges x a b).card ≤ 5 := fun b => (Finset.card_le_card (show localFiveOverlap edges x a b ⊆ T from Finset.inter_subset_left)).trans_eq h5 rw [heq] constructor · unfold localFiveScore rw [Finset.card_filter,Finset.card_filter,Finset.mul_sum,← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro b hb have h := hc b interval_cases he : (localFiveOverlap edges x a b).card <;> decide · have hcap := local_six_overlap_capacity hd hxa rw [h5] at hcap refine le_trans ?_ hcap rw [Finset.card_filter,Finset.card_filter,Finset.mul_sum,Finset.mul_sum,← Finset.sum_add_distrib] apply Finset.sum_le_sum intro b hb have h := hc b interval_cases he : (localFiveOverlap edges x a b).card <;> decide theorem local_six_score_at_six {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) {x a : Fin n} (hxa : x ≠ a) (h6 : (localExtensions edges {x,a}).card = 6) : let e := (localFiveContainmentClass edges x a).card - 1 let v := ({b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 5}).card let q := ({b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 4}).card localFiveScore edges x a = 3 * e + 2 * v + q ∧ 6 * e + 5 * v + 4 * q ≤ 30 := by dsimp only let T := localExtensions edges {x,a} let A := localFiveContainmentClass edges x a let C := localFiveCompanions x a have haa : a ∈ A := local_mem_five_twin_class.mpr ⟨hxa,Finset.Subset.rfl⟩ have hclass : A.erase a = C.filter (fun b => (localFiveOverlap edges x a b).card = 6) := by ext b rw [Finset.mem_erase,Finset.mem_filter,local_mem_five_companions,local_mem_five_twin_class] simp only [and_assoc,ne_comm (a := x) (b := b)] refine and_congr_right fun _ => and_congr_right fun _ => ?_ change T ⊆ localExtensions edges {x,b} ↔ (T ∩ localExtensions edges {x,b}).card = 6 constructor · intro h rw [Finset.inter_eq_left.mpr h] exact h6 · intro h have hh : T ∩ localExtensions edges {x,b} = T := Finset.eq_of_subset_of_card_le Finset.inter_subset_left (by rw [h6,h]) exact Finset.inter_eq_left.mp hh have heq : (localFiveContainmentClass edges x a).card - 1 = (C.filter (fun b => (localFiveOverlap edges x a b).card = 6)).card := by rw [← Finset.card_erase_of_mem haa,hclass] have hc : ∀ b : Fin n, (localFiveOverlap edges x a b).card ≤ 6 := fun b => (Finset.card_le_card (show localFiveOverlap edges x a b ⊆ T from Finset.inter_subset_left)).trans_eq h6 rw [heq] constructor · unfold localFiveScore rw [Finset.card_filter,Finset.card_filter,Finset.card_filter,Finset.mul_sum,Finset.mul_sum,← Finset.sum_add_distrib,← Finset.sum_add_distrib] apply Finset.sum_congr rfl intro b hb have h := hc b interval_cases he : (localFiveOverlap edges x a b).card <;> decide · have hcap := local_six_overlap_capacity hd hxa rw [h6] at hcap refine le_trans ?_ hcap rw [Finset.card_filter,Finset.card_filter,Finset.card_filter,Finset.mul_sum,Finset.mul_sum,Finset.mul_sum,← Finset.sum_add_distrib,← Finset.sum_add_distrib] apply Finset.sum_le_sum intro b hb have h := hc b interval_cases he : (localFiveOverlap edges x a b).card <;> decide theorem local_six_dense_columns {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) {x a : Fin n} {C : Finset (Fin n)} (hx : x ∉ C) (hSum : ∑ b ∈ C, (localFiveOverlap edges x a b).card = 6 * (localExtensions edges {x,a}).card) : ∀ t ∈ localExtensions edges {x,a}, localExtensions edges {x,t} ⊆ C ∧ (localExtensions edges {x,t}).card = 6 := by let T := localExtensions edges {x,a} let N := fun t => localExtensions edges {x,t} have hswap : (∑ b ∈ C, (T ∩ N b).card) = ∑ t ∈ T, (C ∩ N t).card := by simp only [← Finset.filter_mem_eq_inter, Finset.card_filter] rw [Finset.sum_comm] refine Finset.sum_congr rfl fun t ht => Finset.sum_congr rfl fun b hb => ?_ have hxb : x ≠ b := fun h => hx (h.symm ▸ hb) have hxt : x ≠ t := (local_neighbors_ne ht).1.symm have heq : t ∈ N b ↔ b ∈ N t := ⟨local_neighbors_symm hxb, local_neighbors_symm hxt⟩ by_cases h : t ∈ N b · simp [h, heq.mp h] · have hn : b ∉ N t := fun hb => h (heq.mpr hb) simp [h, hn] have hpoint : ∀ t ∈ T, (C ∩ N t).card ≤ 6 := by intro t ht exact (Finset.card_le_card Finset.inter_subset_right).trans (hd x t (local_neighbors_ne ht).1.symm) have hEq := (Finset.sum_eq_sum_iff_of_le hpoint).mp (by rw [← hswap] simpa [T,N,Nat.mul_comm,localFiveOverlap] using hSum) intro t ht have hI := hEq t ht have hc := hd x t (local_neighbors_ne ht).1.symm have he : C ∩ N t = N t := Finset.eq_of_subset_of_card_le Finset.inter_subset_right (hI ▸ hc) exact ⟨Finset.inter_eq_right.mp he, by change (N t).card = 6; rw [← he, hI]⟩ theorem local_six_dense_pair_overlap {n : ℕ} {edges : Finset (Finset (Fin n))} {x t u : Fin n} {C : Finset (Fin n)} (hC : C.card = 7) (ht : localExtensions edges {x,t} ⊆ C) (hu : localExtensions edges {x,u} ⊆ C) (hT : (localExtensions edges {x,t}).card = 6) (hU : (localExtensions edges {x,u}).card = 6) : 5 ≤ (localFiveOverlap edges x t u).card ∧ (localExtensions edges {x,t} ≠ localExtensions edges {x,u} → (localFiveOverlap edges x t u).card = 5) := by let A := localExtensions edges {x,t} let B := localExtensions edges {x,u} change 5 ≤ (A ∩ B).card ∧ (A ≠ B → (A ∩ B).card = 5) have h := Finset.card_union_add_card_inter A B have hc := Finset.card_le_card (Finset.union_subset ht hu) rw [hC] at hc change (A ∪ B).card ≤ 7 at hc change A.card = 6 at hT change B.card = 6 at hU refine ⟨by omega, fun hn => ?_⟩ have hh := Finset.card_le_card (show A ∩ B ⊆ A from Finset.inter_subset_left) suffices (A ∩ B).card ≠ 6 by omega intro he have ha : A ∩ B = A := Finset.eq_of_subset_of_card_le Finset.inter_subset_left (by omega) have hb : A ∩ B = B := Finset.eq_of_subset_of_card_le Finset.inter_subset_right (by omega) exact hn (ha.symm.trans hb) theorem local_six_dense_missing_column {n : ℕ} {edges : Finset (Finset (Fin n))} {x t : Fin n} {C : Finset (Fin n)} (hC : C.card = 7) (ht : localExtensions edges {x,t} ⊆ C) (hT : (localExtensions edges {x,t}).card = 6) : ∃ b ∈ C, C \ localExtensions edges {x,t} = {b} := by have hc : (C \ localExtensions edges {x,t}).card = 1 := by rw [Finset.card_sdiff_of_subset ht, hC, hT] obtain ⟨b, hb⟩ := Finset.card_eq_one.mp hc exact ⟨b, (Finset.mem_sdiff.mp (hb.symm ▸ Finset.mem_singleton_self b)).1, hb⟩ theorem local_six_dense_missing_tip {n : ℕ} {edges : Finset (Finset (Fin n))} {x a b : Fin n} (hq : (localFiveOverlap edges x a b).card + 1 = (localExtensions edges {x,a}).card) : ∃ t ∈ localExtensions edges {x,a}, t ∉ localExtensions edges {x,b} ∧ ∀ u ∈ localExtensions edges {x,a}, u ≠ t → u ∈ localExtensions edges {x,b} := by let T := localExtensions edges {x,a} let N := localExtensions edges {x,b} have hsum := Finset.card_sdiff_add_card_inter T N change (T ∩ N).card + 1 = T.card at hq have hc : (T \ N).card = 1 := by omega obtain ⟨t, ht⟩ := Finset.card_eq_one.mp hc obtain ⟨htT, htN⟩ := Finset.mem_sdiff.mp (ht.symm ▸ Finset.mem_singleton_self t) refine ⟨t, htT, htN, fun u hu hne => ?_⟩ by_contra hn exact hne (Finset.mem_singleton.mp (ht ▸ Finset.mem_sdiff.mpr ⟨hu, hn⟩)) theorem local_six_score_le_eleven_of_two_common_extensions {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 6) {x t y : Fin n} (hxt : x ≠ t) (hxy : x ≠ y) (hyt : y ≠ t) (h6 : (localExtensions edges {x,t}).card = 6) (hcommon : 2 ≤ (localFiveOverlap edges t x y).card) : localFiveScore edges x t ≤ 11 := by let T := localExtensions edges {x,t} let C := localFiveCompanions x t have hRsub : localFiveOverlap edges t x y ⊆ T := by rw [show T = localExtensions edges {t,x} from local_neighbors_comm] exact Finset.inter_subset_left obtain ⟨R, hR, hR2⟩ := Finset.exists_subset_card_eq hcommon have hRT : R ⊆ T := hR.trans hRsub let B := T \ R have hB : B.card = 4 := by change (T \ R).card = 4 rw [Finset.card_sdiff_of_subset hRT, h6, hR2] have hpoint (z : Fin n) (hz : z ∈ C) : 2 * ((localFiveOverlap edges x t z).card - 3) ≤ (B ∩ localExtensions edges {x,z}).card + (if z = y then 2 else 0) := by let U := localFiveOverlap edges x t z have he : U \ R = B ∩ localExtensions edges {x,z} := by ext v simp only [U,B,localFiveOverlap,T,Finset.mem_inter,Finset.mem_sdiff] tauto have hU6 : U.card ≤ 6 := (Finset.card_le_card (show U ⊆ T from Finset.inter_subset_left)).trans_eq h6 have hsplit := Finset.card_sdiff_add_card_inter U R have hUB : (U \ R).card ≤ 4 := by rw [he, ← hB] exact Finset.card_le_card Finset.inter_subset_left have hIB : (U ∩ R).card ≤ 2 := (Finset.card_le_card Finset.inter_subset_right).trans_eq hR2 change 2 * (U.card - 3) ≤ _ rw [← he] by_cases hzy : z = y · rw [if_pos hzy] omega · rw [if_neg hzy] obtain ⟨hzt, hzx⟩ := local_mem_five_companions.mp hz have hI : (U ∩ R).card ≤ 1 := by apply Finset.card_le_one_iff.mpr intro a d ha hd' by_contra had have hdis : Disjoint ({x,z} : Finset (Fin n)) {t,y} := by rw [Finset.disjoint_left] intro w hw hw' simp only [Finset.mem_insert, Finset.mem_singleton] at hw hw' aesop exact local_extension_edges_cross hu (by simp [hzx.symm]) (by simp [hyt.symm]) had (Finset.mem_inter.mp (Finset.mem_inter.mp ha).1).2 (Finset.mem_inter.mp (Finset.mem_inter.mp hd').1).2 (Finset.mem_inter.mp (hR (Finset.mem_inter.mp ha).2)).2 (Finset.mem_inter.mp (hR (Finset.mem_inter.mp hd').2)).2 hdis omega have hinc : ∑ z ∈ C, (B ∩ localExtensions edges {x,z}).card ≤ 20 := by simp only [← Finset.filter_mem_eq_inter, Finset.card_filter] rw [Finset.sum_comm] simp only [← Finset.card_filter] calc _ ≤ ∑ b ∈ B, 5 := by apply Finset.sum_le_sum intro b hb have hbT := (Finset.mem_sdiff.mp hb).1 have hxb := (local_neighbors_ne hbT).1.symm have htb := local_neighbors_symm hxt hbT have hsub : {z ∈ C | b ∈ localExtensions edges {x,z}} ⊆ (localExtensions edges {x,b}).erase t := by intro z hz obtain ⟨hz, hzb⟩ := Finset.mem_filter.mp hz obtain ⟨hzt, hzx⟩ := local_mem_five_companions.mp hz exact Finset.mem_erase.mpr ⟨hzt, local_neighbors_symm hzx.symm hzb⟩ have hc := Finset.card_le_card hsub rw [Finset.card_erase_of_mem htb] at hc have := hd x b hxb omega _ = 20 := by simp [hB] have hs : (∑ z ∈ C, if z = y then (2 : ℕ) else 0) ≤ 2 := by rw [Finset.sum_ite_eq'] split <;> omega have h := Finset.sum_le_sum hpoint rw [← Finset.mul_sum, Finset.sum_add_distrib] at h change 2 * localFiveScore edges x t ≤ _ at h omega theorem local_six_class_rays {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {x a t y : Fin n} (hxy : x ≠ y) (hk : 3 ≤ (localFiveContainmentClass edges x a).card) (hT : 3 ≤ (localExtensions edges {x,a}).card) (hxa : x ≠ a) (ht : t ∈ localExtensions edges {x,a}) (hy : {a,t} ∈ localCoExtensions edges {x,y}) : ∀ q ∈ localCoExtensions edges {x,y}, ∃ v ∈ localFiveOverlap edges t x y, q = {t,v} ∧ (v = a ∨ v ∉ localFiveContainmentClass edges x a) := by have local_six_cross_rays {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) {A T : Finset (Fin n)} (hA : 3 ≤ A.card) (hT : 3 ≤ T.card) {x : Fin n} (hAx : x ∉ A) (hl : ∀ a ∈ A, T ⊆ localExtensions edges {x,a}) {a t y : Fin n} (ha : a ∈ A) (he : localExtensions edges {x,a} = T) (ht : t ∈ T) (hxy : x ≠ y) (hat : {a,t} ∈ localCoExtensions edges {x,y}) : localCoExtensions edges {x,y} ⊆ insert {t,a} ((localExtensions edges {x,t} \ A).image (fun v => ({t,v} : Finset (Fin n)))) := by have hxt : x ≠ t := by have ht' : t ∈ localExtensions edges {x,a} := he.symm ▸ ht exact (local_neighbors_ne ht').1.symm have hTx : x ∉ T := fun h => (local_neighbors_ne (show x ∈ localExtensions edges {x,a} from he.symm ▸ h)).1 rfl have hrev : ∀ w ∈ T, A ⊆ localExtensions edges {x,w} := by intro w hw v hv have hxv : x ≠ v := fun h => hAx (h.symm ▸ hv) exact local_neighbors_symm hxv (hl v hv hw) intro q hq obtain ⟨u,hu,huq⟩ := Finset.not_disjoint_iff.mp (local_coextension_pairwise ‹UniqueDisjointUnions edges› (by simp [hxy]) hat hq) simp only [Finset.mem_insert,Finset.mem_singleton] at hu rcases hu with h | h · subst u obtain ⟨v,hva,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hq).1 huq by_cases htv : t = v · subst v simp [Finset.pair_comm t a] · exact (local_containment_biclique_cross_no_move ‹UniqueDisjointUnions edges› hA hAx hl ha he ht hxy htv hat hq).elim · subst u obtain ⟨v,hvt,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hq).1 huq by_cases hav : a = v · subst v simp apply Finset.mem_insert.mpr right apply Finset.mem_image.mpr have hp : v ∈ localExtensions edges {x,t} := by rw [local_neighbors_comm (a := x) (b := t)] exact local_neighbors_symm hvt.symm (local_pair_mem_coextensions.mp hq).2.1 refine ⟨v,Finset.mem_sdiff.mpr ⟨hp,?_⟩,rfl⟩ intro hv have hyta := (local_pair_mem_coextensions.mp hat).2.2 have hytv := (local_pair_mem_coextensions.mp hq).2.2 have hta : t ≠ a := (local_neighbors_ne (he.symm ▸ ht)).2 have hty : t ≠ y := (local_neighbors_ne hyta).2.symm have hex : ¬ T ⊆ {t,y} := by intro h have hh := Finset.card_le_card h have hcard : ({t,y} : Finset (Fin n)).card = 2 := by simp [hty] omega obtain ⟨w,hw,hw'⟩ := Finset.not_subset.mp hex simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at hw' have hxw : x ≠ w := fun h => hTx (h.symm ▸ hw) have hdis : Disjoint ({t,y} : Finset (Fin n)) {x,w} := by rw [Finset.disjoint_left] intro z hz hz' simp only [Finset.mem_insert,Finset.mem_singleton] at hz hz' aesop exact local_extension_edges_cross ‹UniqueDisjointUnions edges› (by simp [hty]) (by simp [hxw]) hav (local_neighbors_cycle hta.symm hyta) (local_neighbors_symm hvt.symm hytv) (hrev w hw ha) (hrev w hw hv) hdis have h := local_six_cross_rays hu hk hT (fun hx => (local_mem_five_twin_class.mp hx).1 rfl) (fun _ hz => (local_mem_five_twin_class.mp hz).2) (local_mem_five_twin_class.mpr ⟨hxa, Finset.Subset.rfl⟩) rfl ht hxy hy intro q hq have hq' := Finset.mem_insert.mp (h hq) have hb {v : Fin n} (hm : {t,v} ∈ localCoExtensions edges {x,y}) : v ∈ localFiveOverlap edges t x y := by obtain ⟨htv,hx,hy'⟩ := local_pair_mem_coextensions.mp hm exact Finset.mem_inter.mpr ⟨local_neighbors_symm htv hx,local_neighbors_symm htv hy'⟩ rcases hq' with he | he · refine ⟨a, hb (he ▸ hq), he, Or.inl rfl⟩ · obtain ⟨v,hv,rfl⟩ := Finset.mem_image.mp he exact ⟨v, hb hq, rfl, Or.inr (Finset.mem_sdiff.mp hv).2⟩ def localSixOverload {n : ℕ} (edges : Finset (Finset (Fin n))) (x a : Fin n) : ℕ := localFiveScore edges x a - 2 * localSixPotential (localExtensions edges {x,a}).card theorem local_six_source_cases {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) {x a : Fin n} (hxa : x ≠ a) (hB : 0 < localSixOverload edges x a) : let d := (localExtensions edges {x,a}).card let k := (localFiveContainmentClass edges x a).card let b := localSixOverload edges x a let q := ({z ∈ localFiveCompanions x a | (localFiveOverlap edges x a z).card = 4}).card (d = 4 ∧ 4 ≤ k ∧ k ≤ 6 ∧ b = k - 3) ∨ (d = 5 ∧ 2 ≤ k ∧ k ≤ 6 ∧ b ≤ k - 2 + 1 ∧ (k = 2 → q = 5 ∧ b = 1) ∧ (k = 3 → q = 3 ∧ b = 1) ∧ (k = 4 → b ≤ 2) ∧ (k = 5 → b ≤ 3) ∧ (k = 6 → b ≤ 4)) ∨ (d = 6 ∧ 4 ≤ k ∧ k ≤ 6 ∧ b ≤ k - 3) := by have local_six_score_at_small_degree {n : ℕ} {edges : Finset (Finset (Fin n))} {x a : Fin n} (h : (localExtensions edges {x,a}).card ≤ 3) : localFiveScore edges x a = 0 := by unfold localFiveScore apply Finset.sum_eq_zero intro b hb have hc : (localFiveOverlap edges x a b).card ≤ (localExtensions edges {x,a}).card := Finset.card_le_card Finset.inter_subset_left omega have local_six_score_at_four {n : ℕ} {edges : Finset (Finset (Fin n))} {x a : Fin n} (hxa : x ≠ a) (h4 : (localExtensions edges {x,a}).card = 4) : localFiveScore edges x a = (localFiveContainmentClass edges x a).card - 1 := by let T := localExtensions edges {x,a} let A := localFiveContainmentClass edges x a let C := localFiveCompanions x a have haa : a ∈ A := local_mem_five_twin_class.mpr ⟨hxa,Finset.Subset.rfl⟩ have hclass : A.erase a = C.filter (fun b => (localFiveOverlap edges x a b).card = 4) := by ext b rw [Finset.mem_erase,Finset.mem_filter,local_mem_five_companions,local_mem_five_twin_class] simp only [and_assoc,ne_comm (a := x) (b := b)] refine and_congr_right fun _ => and_congr_right fun _ => ?_ change T ⊆ localExtensions edges {x,b} ↔ (T ∩ localExtensions edges {x,b}).card = 4 constructor · intro h rw [Finset.inter_eq_left.mpr h] exact h4 · intro h have hh : T ∩ localExtensions edges {x,b} = T := Finset.eq_of_subset_of_card_le Finset.inter_subset_left (by rw [h4,h]) exact Finset.inter_eq_left.mp hh rw [← Finset.card_erase_of_mem haa,hclass,Finset.card_filter] apply Finset.sum_congr rfl intro b hb have hc : (localFiveOverlap edges x a b).card ≤ 4 := (Finset.card_le_card (show localFiveOverlap edges x a b ⊆ T from Finset.inter_subset_left)).trans_eq h4 interval_cases h : (localFiveOverlap edges x a b).card <;> decide dsimp only let d := (localExtensions edges {x,a}).card let k := (localFiveContainmentClass edges x a).card let b := localSixOverload edges x a have hd6 : d ≤ 6 := hd x a hxa have hd4 : 4 ≤ d := by by_contra h have hz := local_six_score_at_small_degree (edges := edges) (x := x) (a := a) (by omega : d ≤ 3) simp [localSixOverload, hz] at hB let N := fun t => localExtensions edges {x,t} have hA : ∀ t ∈ N a, localFiveContainmentClass edges x a ⊆ N t := by intro t ht z hz obtain ⟨hxz,hz⟩ := local_mem_five_twin_class.mp hz exact local_neighbors_symm hxz (hz ht) obtain ⟨t,ht⟩ := Finset.card_pos.mp (show 0 < (N a).card by change 0 < d; omega) have hk : k ≤ 6 := (Finset.card_le_card (hA t ht)).trans (hd x t (local_neighbors_ne ht).1.symm) change 0 < b at hB have hb : b = localFiveScore edges x a - 2 * localSixPotential d := rfl interval_cases heq : d · have hs := local_six_score_at_four (edges := edges) hxa heq simp [localSixPotential,localFivePotential] at hb change localFiveScore edges x a = k - 1 at hs exact Or.inl ⟨heq, by omega, hk, by omega⟩ · obtain ⟨hs,hc⟩ := local_six_score_at_five hd hxa heq simp [localSixPotential,localFivePotential] at hb change localFiveScore edges x a = 2 * (k - 1) + _ at hs change 5 * (k - 1) + 4 * _ ≤ 25 at hc exact Or.inr (Or.inl ⟨heq, by omega, hk, by omega, fun h => by omega, fun h => by omega, fun h => by omega, fun h => by omega, fun h => by omega⟩) · obtain ⟨hs,hc⟩ := local_six_score_at_six hd hxa heq simp [localSixPotential] at hb change localFiveScore edges x a = 3 * (k - 1) + 2 * _ + _ at hs change 6 * (k - 1) + 5 * _ + 4 * _ ≤ 30 at hc exact Or.inr (Or.inr ⟨heq, by omega, hk, by omega⟩) theorem local_six_tip_has_two_companions {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} (ht : t ∈ localExtensions edges {x,a}) (hT : 4 ≤ (localExtensions edges {x,a}).card) (hk : 4 ≤ (localFiveContainmentClass edges x a).card ∨ (3 ≤ (localFiveContainmentClass edges x a).card ∧ ∃ b ∈ localFiveCompanions x a, 4 ≤ (localFiveOverlap edges x a b).card ∧ b ∉ localFiveContainmentClass edges x a ∧ t ∈ localExtensions edges {x,b})) : ∃ u ∈ localFiveCompanions x t, ∃ v ∈ localFiveCompanions x t, u ≠ v ∧ 4 ≤ (localFiveOverlap edges x t u).card ∧ 4 ≤ (localFiveOverlap edges x t v).card := by let T := localExtensions edges {x,a} let A := localFiveContainmentClass edges x a let N := fun z => localExtensions edges {x,z} have hrev : ∀ u ∈ T, A ⊆ N u := by intro u hu z hz obtain ⟨hxz,hz⟩ := local_mem_five_twin_class.mp hz exact local_neighbors_symm hxz (hz hu) have pick (U : Finset (Fin n)) (hU : U ⊆ T) (hc : 4 ≤ U.card) : ∃ u ∈ U.erase t, ∃ v ∈ U.erase t, u ≠ v := by apply Finset.one_lt_card.mp by_cases htU : t ∈ U · rw [Finset.card_erase_of_mem htU] omega · rw [Finset.erase_eq_of_notMem htU] omega have hc (u : Fin n) (hu : u ∈ T.erase t) : u ∈ localFiveCompanions x t := by obtain ⟨hne,hu⟩ := Finset.mem_erase.mp hu exact local_mem_five_companions.mpr ⟨hne,(local_neighbors_ne hu).1⟩ rcases hk with hk | ⟨hk,b,hb,hB,hUA,hbt⟩ · obtain ⟨u,hu,v,hv,huv⟩ := pick T Finset.Subset.rfl hT refine ⟨u,hc u hu,v,hc v hv,huv,?_,?_⟩ all_goals apply hk.trans (Finset.card_le_card _) intro z hz exact Finset.mem_inter.mpr ⟨hrev t ht hz, hrev _ (Finset.mem_erase.mp (by assumption)).2 hz⟩ · let U := localFiveOverlap edges x a b obtain ⟨u,hu,v,hv,huv⟩ := pick U Finset.inter_subset_left hB have hsub (w : Fin n) (hw : w ∈ U.erase t) : insert b A ⊆ localFiveOverlap edges x t w := by have hw' := Finset.mem_inter.mp (Finset.mem_erase.mp hw).2 intro z hz rcases Finset.mem_insert.mp hz with rfl | hz · have hxb := (local_mem_five_companions.mp hb).2.symm exact Finset.mem_inter.mpr ⟨local_neighbors_symm hxb hbt,local_neighbors_symm hxb hw'.2⟩ · exact Finset.mem_inter.mpr ⟨hrev t ht hz,hrev w hw'.1 hz⟩ have hi : 4 ≤ (insert b A).card := by rw [Finset.card_insert_of_notMem hUA]; omega have hUT : U.erase t ⊆ T.erase t := by intro w hw obtain ⟨hne,hw⟩ := Finset.mem_erase.mp hw exact Finset.mem_erase.mpr ⟨hne,(Finset.mem_inter.mp hw).1⟩ exact ⟨u,hc u (hUT hu),v,hc v (hUT hv),huv, hi.trans (Finset.card_le_card (hsub u hu)),hi.trans (Finset.card_le_card (hsub v hv))⟩ theorem local_six_score_spare_of_rays {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) {x a t y : Fin n} (hk : 3 ≤ (localFiveContainmentClass edges x a).card) (hT : 4 ≤ (localExtensions edges {x,a}).card) (hxa : x ≠ a) (ht : t ∈ localExtensions edges {x,a}) (hxy : x ≠ y) (hy : {a,t} ∈ localCoExtensions edges {x,y}) (hg : 2 ≤ (localCoExtensions edges {x,y}).card) (ha : 4 ≤ (localFiveContainmentClass edges x a).card ∨ ∃ b ∈ localFiveCompanions x a, 4 ≤ (localFiveOverlap edges x a b).card ∧ b ∉ localFiveContainmentClass edges x a ∧ t ∈ localExtensions edges {x,b}) : (3 ≤ (localCoExtensions edges {x,y}).card ∨ 5 ≤ (localFiveContainmentClass edges x a).card) → (localExtensions edges {x,t}).card = 6 ∧ localFiveScore edges t x = 0 ∧ 0 < localFiveScore edges x t ∧ (if 3 ≤ (localCoExtensions edges {x,y}).card then 5 else 1) ≤ 12 - localFiveScore edges x t := by have local_six_cross_overlap {n : ℕ} {edges : Finset (Finset (Fin n))} {x t y : Fin n} (hxy : x ≠ y) (hstar : ∀ q ∈ localCoExtensions edges {x,y}, t ∈ q) : (localCoExtensions edges {x,y}).card ≤ (localFiveOverlap edges t x y).card := by let N := localFiveOverlap edges t x y have hsub : localCoExtensions edges {x,y} ⊆ N.image (fun v => ({t,v} : Finset (Fin n))) := by intro q hq obtain ⟨v,hvt,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hq).1 (hstar q hq) obtain ⟨_,hx,hy⟩ := local_pair_mem_coextensions.mp hq exact Finset.mem_image.mpr ⟨v, Finset.mem_inter.mpr ⟨local_neighbors_symm hvt.symm hx, local_neighbors_symm hvt.symm hy⟩, rfl⟩ exact (Finset.card_le_card hsub).trans Finset.card_image_le intro hn have hxt := (local_neighbors_ne ht).1.symm have hyt := (local_neighbors_ne (local_pair_mem_coextensions.mp hy).2.2).2 have hCap := hd x t hxt have hRays := local_six_class_rays hu hxy hk (by omega) hxa ht hy have hO := local_six_cross_overlap (t := t) hxy (fun q hq => by obtain ⟨v,hv,rfl,h⟩ := hRays q hq simp) obtain ⟨u,hu',v,hv,huv,hU,hV⟩ := local_six_tip_has_two_companions ht hT (ha.imp id (fun h => ⟨hk,h⟩)) have hz := local_six_opposite_score_zero_of_two hu hxt hCap hu' hv huv hU hV have hp : 0 < localFiveScore edges x t := by have hh : (localFiveOverlap edges x t u).card - 3 ≤ localFiveScore edges x t := Finset.single_le_sum (f := fun q => (localFiveOverlap edges x t q).card - 3) (fun _ _ => Nat.zero_le _) hu' omega by_cases hG : 3 ≤ (localCoExtensions edges {x,y}).card · have hR : 3 ≤ (localFiveOverlap edges t x y).card := hG.trans hO have h6 : (localExtensions edges {x,t}).card = 6 := by by_contra hne have h5 : (localExtensions edges {x,t}).card ≤ 5 := by omega have hUy : u = y := by by_contra hnu have hsmall := local_six_other_companion_small_of_three_common_extensions hu hxt hxy hyt h5 hR hu' hnu omega have hVy : v = y := by by_contra hnv have hsmall := local_six_other_companion_small_of_three_common_extensions hu hxt hxy hyt h5 hR hv hnv omega exact huv (hUy.trans hVy.symm) have h7 := local_six_score_le_seven_of_three_common_extensions hu hd hxt hxy hyt h6 hR exact ⟨h6,hz,hp,by rw [if_pos hG]; omega⟩ · have h5 := hn.resolve_left hG have hB := local_containment_biclique_cross_bound hu hk (by omega : 3 ≤ (localExtensions edges {x,a}).card) (fun hz => (local_mem_five_twin_class.mp hz).1 rfl) (fun _ hz => (local_mem_five_twin_class.mp hz).2) (local_mem_five_twin_class.mpr ⟨hxa,Finset.Subset.rfl⟩) rfl ht hxy hy have h6 : (localExtensions edges {x,t}).card = 6 := by omega have h11 := local_six_score_le_eleven_of_two_common_extensions hu hd hxt hxy hyt h6 (hg.trans hO) exact ⟨h6,hz,hp,by rw [if_neg hG]; omega⟩ theorem local_six_dense_tip_score {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) {x a t b : Fin n} {A C : Finset (Fin n)} (hxa : x ≠ a) (hT : 4 ≤ (localExtensions edges {x,a}).card) (ht : t ∈ localExtensions edges {x,a}) (hC : C.card = 7) (hDense : ∀ v ∈ localExtensions edges {x,a}, localExtensions edges {x,v} ⊆ C ∧ (localExtensions edges {x,v}).card = 6) (hDiff : ∀ v ∈ localExtensions edges {x,a}, v ≠ t → localExtensions edges {x,v} ≠ localExtensions edges {x,t}) (hA : A.card = 2) (hAt : A ⊆ localExtensions edges {x,t}) (hExact : ∀ v ∈ A, localExtensions edges {x,v} = localExtensions edges {x,a}) (hb : b ∈ localExtensions edges {x,t} \ A) (hbT : 4 ≤ (localFiveOverlap edges x a b).card) : localFiveScore edges t x = 0 ∧ 0 < localFiveScore edges x t ∧ localFiveScore edges x t + (localFiveOverlap edges x a b).card ≤ 2 * (localExtensions edges {x,a}).card + 4 := by let T := localExtensions edges {x,a} let N := fun v => localExtensions edges {x,v} let S := localFiveCompanions x t let w := fun v => (localFiveOverlap edges x t v).card - 3 have hxt := (local_neighbors_ne ht).1.symm have hD := (hDense t ht).2 have hIn (v : Fin n) (hv : v ∈ T) (hne : v ≠ t) : (localFiveOverlap edges x t v).card = 5 := (local_six_dense_pair_overlap hC (hDense t ht).1 (hDense v hv).1 hD (hDense v hv).2).2 (hDiff v hv hne).symm have hcomp (z : Fin n) (hz : z ∈ T.erase t) : z ∈ S := by obtain ⟨hne,hz'⟩ := Finset.mem_erase.mp hz exact local_mem_five_companions.mpr ⟨hne,(local_neighbors_ne hz').1⟩ obtain ⟨u,hu',v,hv,huv⟩ := Finset.one_lt_card.mp (show 1 < (T.erase t).card by rw [Finset.card_erase_of_mem ht] have hTc : 4 ≤ T.card := hT change 1 < T.card - 1 omega) have huv' (z : Fin n) (hz : z ∈ T.erase t) : 4 ≤ (localFiveOverlap edges x t z).card := by obtain ⟨hne,hz'⟩ := Finset.mem_erase.mp hz rw [hIn z hz' hne] decide have hz := local_six_opposite_score_zero_of_two hu hxt (by omega) (hcomp u hu') (hcomp v hv) huv (huv' u hu') (huv' v hv) have hp : 0 < localFiveScore edges x t := by have h := Finset.single_le_sum (f := w) (fun _ _ => Nat.zero_le _) (hcomp u hu') change (localFiveOverlap edges x t u).card - 3 ≤ localFiveScore edges x t at h have := huv' u hu' omega refine ⟨hz,hp,?_⟩ have hST : S.filter (fun z => z ∈ T) = T.erase t := by ext z rw [Finset.mem_filter, Finset.mem_erase] constructor · rintro ⟨hz,hz'⟩ exact ⟨(local_mem_five_companions.mp hz).1,hz'⟩ · intro hz exact ⟨hcomp z (Finset.mem_erase.mpr hz),hz.2⟩ have hscoreIn : ∑ z ∈ S with z ∈ T, w z = 2 * (T.card - 1) := by rw [hST] have he : ∑ z ∈ T.erase t, w z = ∑ _z ∈ T.erase t, (2 : ℕ) := by apply Finset.sum_congr rfl intro z hz obtain ⟨hne,hz'⟩ := Finset.mem_erase.mp hz simp [w,hIn z hz' hne] rw [he,Finset.sum_const,Finset.card_erase_of_mem ht,smul_eq_mul,Nat.mul_comm] let B := N t \ A have hB : B.card = 4 := by dsimp [B,N] rw [Finset.card_sdiff_of_subset hAt,hD,hA] have hscoreOut : ∑ z ∈ S with z ∉ T, w z ≤ 6 - (localFiveOverlap edges x a b).card := by have hpoint : ∀ z ∈ S.filter (fun z => z ∉ T), w z ≤ if z ∈ N b then 1 else 0 := by intro z hz obtain ⟨hz,hzT⟩ := Finset.mem_filter.mp hz have hzx := (local_mem_five_companions.mp hz).2 let U := localFiveOverlap edges x t z have hUB : U ⊆ B := by intro u hu' obtain ⟨ht',hz'⟩ := Finset.mem_inter.mp hu' refine Finset.mem_sdiff.mpr ⟨ht',fun huA => ?_⟩ have he := local_neighbors_symm hzx.symm hz' rw [hExact u huA] at he exact hzT he have h4 := (Finset.card_le_card hUB).trans_eq hB change U.card - 3 ≤ _ by_cases hp : 4 ≤ U.card · have he := Finset.eq_of_subset_of_card_le hUB (by omega : B.card ≤ U.card) have hb' : b ∈ U := he.symm ▸ hb have hbz := local_neighbors_symm hzx.symm (Finset.mem_inter.mp hb').2 rw [if_pos hbz] omega · exact le_trans (show U.card - 3 ≤ 0 by omega) (Nat.zero_le _) refine (Finset.sum_le_sum hpoint).trans ?_ rw [← Finset.card_filter] have hsub : ((S.filter fun z => z ∉ T).filter fun z => z ∈ N b) ⊆ N b \ T := by intro z hz exact Finset.mem_sdiff.mpr ⟨(Finset.mem_filter.mp hz).2, (Finset.mem_filter.mp (Finset.mem_filter.mp hz).1).2⟩ have hc := Finset.card_sdiff_add_card_inter (N b) T rw [Finset.inter_comm] at hc have h6 : (N b).card ≤ 6 := hd x b (local_neighbors_ne (Finset.mem_sdiff.mp hb).1).1.symm have hle : (N b \ T).card ≤ 6 - (localFiveOverlap edges x a b).card := by change (N b \ T).card ≤ 6 - (T ∩ N b).card omega exact (Finset.card_le_card hsub).trans hle have hsum := Finset.sum_filter_add_sum_filter_not S (fun z => z ∈ T) w rw [hscoreIn] at hsum change _ = localFiveScore edges x t at hsum have hTc : 4 ≤ T.card := hT have hBc : (localFiveOverlap edges x a b).card ≤ 6 := (Finset.card_le_card (show localFiveOverlap edges x a b ⊆ T from Finset.inter_subset_left)).trans (hd x a hxa) change _ ≤ 2 * T.card + 4 omega theorem local_six_dense_configuration {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) {x a : Fin n} {B : Finset (Fin n)} (hx : x ≠ a) (hB : B ⊆ localFiveCompanions x a) (hDis : Disjoint (localFiveContainmentClass edges x a) B) (hCard : (localFiveContainmentClass edges x a).card + B.card = 7) (hSum : ∑ b ∈ B, (localFiveOverlap edges x a b).card = (6 - (localFiveContainmentClass edges x a).card) * (localExtensions edges {x,a}).card) (hk : (localFiveContainmentClass edges x a).card ≤ 6) : let C := localFiveContainmentClass edges x a ∪ B C.card = 7 ∧ ∀ t ∈ localExtensions edges {x,a}, localExtensions edges {x,t} ⊆ C ∧ (localExtensions edges {x,t}).card = 6 := by dsimp only let A := localFiveContainmentClass edges x a let T := localExtensions edges {x,a} constructor · rw [Finset.card_union_of_disjoint hDis] exact hCard · apply local_six_dense_columns hd · simp only [Finset.mem_union, not_or] exact ⟨fun h => (local_mem_five_twin_class.mp h).1 rfl, fun h => (local_mem_five_companions.mp (hB h)).2 rfl⟩ · rw [Finset.sum_union hDis,hSum] have he : ∑ b ∈ A, (localFiveOverlap edges x a b).card = A.card * T.card := by calc _ = ∑ _b ∈ A, T.card := by apply Finset.sum_congr rfl intro b hb exact congrArg Finset.card (Finset.inter_eq_left.mpr (local_mem_five_twin_class.mp hb).2) _ = _ := by simp rw [he,← Nat.add_mul] change A.card ≤ 6 at hk have hh : A.card + (6 - A.card) = 6 := by omega rw [hh] theorem local_six_class_and_partial_disjoint {n : ℕ} {edges : Finset (Finset (Fin n))} {x a : Fin n} {B : Finset (Fin n)} (h : ∀ b ∈ B, (localFiveOverlap edges x a b).card < (localExtensions edges {x,a}).card) : Disjoint (localFiveContainmentClass edges x a) B := by rw [Finset.disjoint_left] intro b hb hb' have he := Finset.inter_eq_left.mpr (local_mem_five_twin_class.mp hb).2 exact (Nat.ne_of_lt (h b hb')) (congrArg Finset.card he) theorem local_six_nondegenerate_dense_target {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) {x a t : Fin n} (hxa : x ≠ a) (h5 : (localExtensions edges {x,a}).card = 5) (hk : (localFiveContainmentClass edges x a).card = 2) (hq : ({b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 4}).card = 5) (ht : t ∈ localExtensions edges {x,a}) : (localExtensions edges {x,t}).card = 6 ∧ localFiveScore edges t x = 0 ∧ 0 < localFiveScore edges x t ∧ localFiveScore edges x t ≤ 11 ∧ (localFiveScore edges x t = 11 → ∀ v ∈ localExtensions edges {x,t}, (localExtensions edges {x,v}).card = 5 → v = a) := by let A := localFiveContainmentClass edges x a let B := {b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 4} let C := A ∪ B let T := localExtensions edges {x,a} let N := fun v => localExtensions edges {x,v} have hB : B ⊆ localFiveCompanions x a := Finset.filter_subset _ _ have hPartial b (hb : b ∈ B) : (localFiveOverlap edges x a b).card = 4 := (Finset.mem_filter.mp hb).2 have hDis : Disjoint A B := local_six_class_and_partial_disjoint (fun b hb => by rw [hPartial b hb, h5]; decide) have hSum : ∑ b ∈ B, (localFiveOverlap edges x a b).card = (6 - A.card) * T.card := by calc _ = ∑ _b ∈ B, 4 := Finset.sum_congr rfl hPartial _ = _ := by simp [B,A,T,hk,h5,hq] have hCard : A.card + B.card = 7 := by simp [A,B,hk,hq] obtain ⟨hC,hDense⟩ := local_six_dense_configuration hd hxa hB hDis hCard hSum (by omega) have hAt : A ⊆ N t := by intro b hb obtain ⟨hxb,ht'⟩ := local_mem_five_twin_class.mp hb exact local_neighbors_symm hxb (ht' ht) obtain ⟨b,hb,he⟩ := local_six_dense_missing_column hC (hDense t ht).1 (hDense t ht).2 have hmiss : b ∉ N t := (Finset.mem_sdiff.mp (he.symm ▸ Finset.mem_singleton_self b)).2 have hbB : b ∈ B := (Finset.mem_union.mp hb).resolve_left (fun h => hmiss (hAt h)) obtain ⟨v,hv,hn,hRest⟩ := local_six_dense_missing_tip (show (localFiveOverlap edges x a b).card + 1 = T.card by rw [hPartial b hbB,h5]) have hv' : v = t := by by_contra hne have hxb := (local_mem_five_companions.mp (hB hbB)).2.symm exact hmiss (local_neighbors_symm hxb (hRest t ht (Ne.symm hne))) subst v have hDiff v (hv : v ∈ T) (hne : v ≠ t) : N v ≠ N t := by intro h have hxb := (local_mem_five_companions.mp (hB hbB)).2.symm exact hmiss (h ▸ local_neighbors_symm hxb (hRest v hv hne)) have haA : a ∈ A := local_mem_five_twin_class.mpr ⟨hxa, Finset.Subset.rfl⟩ obtain ⟨a',ha'⟩ := Finset.card_eq_one.mp (show (A.erase a).card = 1 by rw [Finset.card_erase_of_mem haA, hk]) have ha'A : a' ∈ A := (Finset.mem_erase.mp (ha'.symm ▸ Finset.mem_singleton_self a')).2 have hAeq : A = {a,a'} := by rw [← ha', Finset.insert_erase haA] have hxt := (local_neighbors_ne ht).1.symm have hD := (hDense t ht).2 let S := localFiveCompanions x t let O := S.filter (fun z => z ∉ T) let w := fun v => (localFiveOverlap edges x t v).card - 3 let B₀ := N t \ A let J := fun c => O.filter (fun z => c ∈ N z) have hB0 : B₀.card = 4 := by change (N t \ A).card = 4 rw [Finset.card_sdiff_of_subset hAt, hD, hk] have hBsub : B₀ ⊆ B := by intro c hc obtain ⟨hct,hcA⟩ := Finset.mem_sdiff.mp hc exact (Finset.mem_union.mp ((hDense t ht).1 hct)).resolve_left hcA have hcomp (z : Fin n) (hz : z ∈ T.erase t) : z ∈ S := by obtain ⟨hne,hz'⟩ := Finset.mem_erase.mp hz exact local_mem_five_companions.mpr ⟨hne,(local_neighbors_ne hz').1⟩ have hIn (v : Fin n) (hv : v ∈ T) (hne : v ≠ t) : (localFiveOverlap edges x t v).card = 5 := (local_six_dense_pair_overlap hC (hDense t ht).1 (hDense v hv).1 hD (hDense v hv).2).2 (hDiff v hv hne).symm obtain ⟨u,hu',v,hv,huv⟩ := Finset.one_lt_card.mp (show 1 < (T.erase t).card by rw [Finset.card_erase_of_mem ht, h5]; decide) have hbig (z : Fin n) (hz : z ∈ T.erase t) : 4 ≤ (localFiveOverlap edges x t z).card := by obtain ⟨hne,hz'⟩ := Finset.mem_erase.mp hz rw [hIn z hz' hne]; decide have hz := local_six_opposite_score_zero_of_two hu hxt (by omega) (hcomp u hu') (hcomp v hv) huv (hbig u hu') (hbig v hv) have hp : 0 < localFiveScore edges x t := by have hh := Finset.single_le_sum (f := w) (fun _ _ => Nat.zero_le _) (hcomp u hu') dsimp [w] at hh have := hbig u hu' change _ ≤ localFiveScore edges x t at hh omega have hST : S.filter (fun z => z ∈ T) = T.erase t := by ext z rw [Finset.mem_filter, Finset.mem_erase] constructor · rintro ⟨hz,hz'⟩ exact ⟨(local_mem_five_companions.mp hz).1,hz'⟩ · intro hz exact ⟨hcomp z (Finset.mem_erase.mpr hz),hz.2⟩ have hscoreIn : ∑ z ∈ S with z ∈ T, w z = 8 := by rw [hST] have he : ∑ z ∈ T.erase t, w z = ∑ _z ∈ T.erase t, (2 : ℕ) := Finset.sum_congr rfl fun z hz => by obtain ⟨hne,hz'⟩ := Finset.mem_erase.mp hz simp [w,hIn z hz' hne] rw [he,Finset.sum_const,Finset.card_erase_of_mem ht,h5] decide have hJsub c : J c ⊆ N c \ T := by intro z hz obtain ⟨hz,hc⟩ := Finset.mem_filter.mp hz obtain ⟨hz,hzT⟩ := Finset.mem_filter.mp hz exact Finset.mem_sdiff.mpr ⟨local_neighbors_symm (local_mem_five_companions.mp hz).2.symm hc,hzT⟩ have hJnum c (hc : c ∈ N t) : (J c).card ≤ 6 - (localFiveOverlap edges x a c).card := by refine (Finset.card_le_card (hJsub c)).trans ?_ have hcc := Finset.card_sdiff_add_card_inter (N c) T rw [Finset.inter_comm] at hcc have hc6 := hd x c (local_neighbors_ne hc).1.symm change (N c \ T).card ≤ 6 - (T ∩ N c).card change (N c).card ≤ 6 at hc6 omega have hJ2 c (hc : c ∈ B₀) : (J c).card ≤ 2 := by have h := hJnum c (Finset.mem_sdiff.mp hc).1 rw [hPartial c (hBsub hc)] at h exact h have hJ1 : (J a').card ≤ 1 := by have h := hJnum a' (hAt ha'A) change (J a').card ≤ 1 have he : localFiveOverlap edges x a a' = T := Finset.inter_eq_left.mpr (local_mem_five_twin_class.mp ha'A).2 rw [he,h5] at h exact h have hpoint (z : Fin n) (hz : z ∈ O) : 4 * w z ≤ (B₀ ∩ N z).card + (if a' ∈ N z then 4 else 0) := by let U := localFiveOverlap edges x t z have ha'out : a ∉ N z := by intro h have hzx := (local_mem_five_companions.mp (Finset.mem_filter.mp hz).1).2 exact (Finset.mem_filter.mp hz).2 (local_neighbors_symm hzx.symm h) have hsub : U ⊆ (B₀ ∩ N z) ∪ ({a'} ∩ N z) := by intro c hc obtain ⟨hcN,hcZ⟩ := Finset.mem_inter.mp hc by_cases hcA : c ∈ A · have he : c = a' := by rw [hAeq,Finset.mem_insert,Finset.mem_singleton] at hcA exact hcA.resolve_left (fun h => ha'out (h ▸ hcZ)) exact Finset.mem_union.mpr (Or.inr (Finset.mem_inter.mpr ⟨by simp [he],hcZ⟩)) · exact Finset.mem_union.mpr (Or.inl (Finset.mem_inter.mpr ⟨Finset.mem_sdiff.mpr ⟨hcN,hcA⟩,hcZ⟩)) have hUb := Finset.card_le_card hsub have hA4 := (Finset.card_le_card (show B₀ ∩ N z ⊆ B₀ from Finset.inter_subset_left)).trans_eq hB0 have hcard := Finset.card_union_le (B₀ ∩ N z) ({a'} ∩ N z) change 4 * (U.card - 3) ≤ _ by_cases hZ : a' ∈ N z · rw [if_pos hZ] have he : ({a'} ∩ N z).card = 1 := by rw [Finset.inter_eq_left.mpr (Finset.singleton_subset_iff.mpr hZ), Finset.card_singleton] omega · rw [if_neg hZ] have he : ({a'} ∩ N z).card = 0 := by simp [hZ] omega have hsum := Finset.sum_le_sum hpoint rw [← Finset.mul_sum,Finset.sum_add_distrib] at hsum have hind : (∑ z ∈ O, if a' ∈ N z then (4 : ℕ) else 0) = 4 * (J a').card := by rw [Finset.card_filter,Finset.mul_sum] exact Finset.sum_congr rfl fun z hz => by split <;> simp rw [hind] at hsum have hswap : (∑ z ∈ O, (B₀ ∩ N z).card) = ∑ c ∈ B₀, (J c).card := by simp only [J,← Finset.filter_mem_eq_inter,Finset.card_filter] exact Finset.sum_comm rw [hswap] at hsum have hcol := Finset.sum_le_sum hJ2 rw [Finset.sum_const,smul_eq_mul,hB0] at hcol have hscore := Finset.sum_filter_add_sum_filter_not S (fun z => z ∈ T) w rw [hscoreIn] at hscore change 8 + (∑ z ∈ O, w z) = localFiveScore edges x t at hscore refine ⟨hD,hz,hp,by omega,?_⟩ intro h11 v hv h5v have heq : ∑ c ∈ B₀, (J c).card = ∑ _c ∈ B₀, 2 := by rw [Finset.sum_const,smul_eq_mul,hB0] omega have hJb := (Finset.sum_eq_sum_iff_of_le hJ2).mp heq have h1 : (J a').card = 1 := by omega have hnB (c : Fin n) (hc : c ∈ B₀) : (N c).card = 6 := by have hi := hPartial c (hBsub hc) have hsec := Finset.card_le_card (hJsub c) rw [hJb c hc] at hsec have hs := Finset.card_sdiff_add_card_inter (N c) T rw [Finset.inter_comm] at hs change (T ∩ N c).card = 4 at hi have h6 := hd x c (local_neighbors_ne (Finset.mem_sdiff.mp hc).1).1.symm change (N c).card ≤ 6 at h6 omega have hnA' : (N a').card = 6 := by have hi : (T ∩ N a').card = 5 := by rw [Finset.inter_eq_left.mpr (local_mem_five_twin_class.mp ha'A).2,h5] have hsec := Finset.card_le_card (hJsub a') rw [h1] at hsec have hs := Finset.card_sdiff_add_card_inter (N a') T rw [Finset.inter_comm] at hs have h6 := hd x a' (local_mem_five_twin_class.mp ha'A).1 change (N a').card ≤ 6 at h6 omega by_cases hm : v ∈ A · rw [hAeq,Finset.mem_insert,Finset.mem_singleton] at hm rcases hm with rfl | rfl · rfl · change (N v).card = 5 at h5v omega · have hh := hnB v (Finset.mem_sdiff.mpr ⟨hv,hm⟩) change (N v).card = 5 at h5v omega def localSixFeeProfile {n : ℕ} (edges : Finset (Finset (Fin n))) (x a t : Fin n) (f : ℕ) : Prop := let d := (localExtensions edges {x,a}).card let k := (localFiveContainmentClass edges x a).card 0 < f ∧ f ≤ 48 ∧ 4 ≤ d ∧ (k = 2 ∧ d = 5 ∧ f = 12 ∧ ({b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 4}).card = 5 ∨ 3 ≤ k ∧ (k ≤ 4 → f ≤ 24) ∧ (k ≤ 5 → f ≤ 36) ∧ (4 ≤ k ∨ ∃ b ∈ localFiveCompanions x a, 4 ≤ (localFiveOverlap edges x a b).card ∧ b ∉ localFiveContainmentClass edges x a ∧ t ∈ localExtensions edges {x,b})) theorem local_six_source_allocation {n : ℕ} {edges : Finset (Finset (Fin n))} (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) (x a : Fin n) (hxa : x ≠ a) : ∃ T ⊆ localExtensions edges {x,a}, ∃ f : ℕ, T.card * f = 60 * localSixOverload edges x a ∧ ∀ t ∈ T, localSixFeeProfile edges x a t f := by let N := localExtensions edges {x,a} let d := N.card let k := (localFiveContainmentClass edges x a).card let b := localSixOverload edges x a by_cases h0 : b = 0 · refine ⟨∅,Finset.empty_subset _,0,?_,?_⟩ · change _ = 60 * b simp [h0] · simp have hb : 0 < b := Nat.pos_of_ne_zero h0 have h := local_six_source_cases hd hxa hb dsimp only at h rcases h with h | h | h · obtain ⟨hd4,hk4,hk6,he⟩ := h change d = 4 at hd4 change 4 ≤ k at hk4 change k ≤ 6 at hk6 change b = k - 3 at he refine ⟨N,Finset.Subset.rfl,15*b,?_,?_⟩ · change d * (15*b) = 60*b rw [hd4]; omega · intro t ht change 0 < 15*b ∧ 15*b ≤ 48 ∧ 4 ≤ d ∧ _ refine ⟨by omega,by omega,by omega,Or.inr ⟨by omega,?_,?_,Or.inl hk4⟩⟩ <;> omega · obtain ⟨hd5,hk2,hk6,_,h2,h3,h4,h5,h6⟩ := h change d = 5 at hd5 change 2 ≤ k at hk2 change k ≤ 6 at hk6 by_cases hK2 : k = 2 · obtain ⟨hq,he⟩ := h2 hK2 refine ⟨N,Finset.Subset.rfl,12,?_,?_⟩ · change d * 12 = 60*b rw [hd5] change b = 1 at he omega · intro t ht exact ⟨by decide,by decide,by change 4 ≤ d; omega,Or.inl ⟨hK2,hd5,rfl,hq⟩⟩ by_cases hK3 : k = 3 · obtain ⟨hq,he⟩ := h3 hK3 obtain ⟨v,hv⟩ := Finset.card_pos.mp (show 0 < ({z ∈ localFiveCompanions x a | (localFiveOverlap edges x a z).card = 4}).card by omega) obtain ⟨hv',hv4⟩ := Finset.mem_filter.mp hv let T := localFiveOverlap edges x a v change b = 1 at he refine ⟨T,Finset.inter_subset_left,15,by change T.card * 15 = 60*b; rw [hv4,he],?_⟩ intro t ht have hvA : v ∉ localFiveContainmentClass edges x a := by intro hvA have heq := Finset.inter_eq_left.mpr (local_mem_five_twin_class.mp hvA).2 have hh := congrArg Finset.card heq change (localFiveOverlap edges x a v).card = d at hh omega exact ⟨by decide,by decide,by change 4 ≤ d; omega,Or.inr ⟨by omega,fun _ => by decide, fun _ => by decide,Or.inr ⟨v,hv',by omega,hvA,(Finset.mem_inter.mp ht).2⟩⟩⟩ have hk4 : 4 ≤ k := by omega have hlim : (k ≤ 4 → b ≤ 2) ∧ (k ≤ 5 → b ≤ 3) ∧ b ≤ 4 := by change (k = 4 → b ≤ 2) at h4 change (k = 5 → b ≤ 3) at h5 change (k = 6 → b ≤ 4) at h6 omega refine ⟨N,Finset.Subset.rfl,12*b,?_,?_⟩ · change d*(12*b) = 60*b rw [hd5]; omega · intro t ht change 0 < 12*b ∧ 12*b ≤ 48 ∧ 4 ≤ d ∧ _ exact ⟨by omega,by omega,by omega,Or.inr ⟨by omega,fun _ => by omega, fun _ => by omega,Or.inl hk4⟩⟩ · obtain ⟨hd6,hk4,hk6,he⟩ := h change d = 6 at hd6 change 4 ≤ k at hk4 change k ≤ 6 at hk6 change b ≤ k - 3 at he refine ⟨N,Finset.Subset.rfl,10*b,?_,?_⟩ · change d*(10*b) = 60*b rw [hd6]; omega · intro t ht change 0 < 10*b ∧ 10*b ≤ 48 ∧ 4 ≤ d ∧ _ exact ⟨by omega,by omega,by omega,Or.inr ⟨by omega,fun _ => by omega, fun _ => by omega,Or.inl hk4⟩⟩ def localSixSpare {n : ℕ} (edges : Finset (Finset (Fin n))) (p : Fin n × Fin n) : ℕ := 2 * localSixPotential (localExtensions edges (localUnderlyingPair p)).card - (localFiveScore edges p.1 p.2 + localFiveScore edges p.2 p.1) theorem local_six_saturation_of_charge_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) (havg : ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, (localExtensions edges p).card = 3 * n.choose 2) (hCharge : let P := (Finset.univ : Finset (Fin n)).powersetCard 2 60 * (∑ q ∈ localOrderedPairs n, localSixOverload edges q.1 q.2) ≤ 116 * ((P.filter (fun p => (localExtensions edges p).card = 1)).card + ∑ p ∈ P, (3 - (localCoExtensions edges p).card)) + 24 * (∑ q ∈ localOrderedPairs n, localSixSpare edges q)) : (∀ x a : Fin n, x ≠ a → 2 ≤ (localExtensions edges {x,a}).card) ∧ (∀ x a : Fin n, x ≠ a → 3 ≤ (localCoExtensions edges {x,a}).card) ∧ (∀ x a : Fin n, x ≠ a → localFiveScore edges x a + localFiveScore edges a x = 2 * localSixPotential (localExtensions edges {x,a}).card) := by classical dsimp only at hCharge let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let O := localOrderedPairs n let d := fun p => (localExtensions edges p).card let g := fun p => (localCoExtensions edges p).card let w := fun (p : Fin n × Fin n) => localFiveScore edges p.1 p.2 let b := fun (p : Fin n × Fin n) => localSixOverload edges p.1 p.2 let s := localSixSpare edges let U := ∑ p ∈ P, localSixPotential (d p) let A₀ := (P.filter (fun p => d p = 0)).card let A₁ := (P.filter (fun p => d p = 1)).card let D := ∑ p ∈ P, (3 - g p) change 60 * (∑ p ∈ O, b p) ≤ 116 * (A₁+D) + 24 * (∑ p ∈ O, s p) at hCharge have hG : ∑ p ∈ P, (g p - 3) = U + 3 * A₀ + A₁ + D := local_six_excess_identity hd havg have hL : 2 * (∑ p ∈ P, (g p - 3)) ≤ ∑ p ∈ O, w p := local_five_score_sum_lower hu have sum_swap (v : (Fin n × Fin n) → ℕ) : ∑ p ∈ O, v p.swap = ∑ p ∈ O, v p := by refine Finset.sum_nbij Prod.swap ?_ ?_ ?_ (fun _ _ => rfl) · intro p hp exact local_mem_ordered_pairs.mpr (local_mem_ordered_pairs.mp hp).symm · intro p hp q hq hpq exact congrArg Prod.swap hpq · intro p hp exact ⟨p.swap,local_mem_ordered_pairs.mpr (local_mem_ordered_pairs.mp hp).symm,rfl⟩ have hpoint : ∀ p ∈ O, w p + w p.swap + s p = 2 * localSixPotential (d (localUnderlyingPair p)) + b p + b p.swap := by rintro ⟨x,a⟩ hp have hxa := local_mem_ordered_pairs.mp hp let d₀ := (localExtensions edges {x,a}).card let w₁ := localFiveScore edges x a let w₂ := localFiveScore edges a x change w₁ + w₂ + (2 * localSixPotential d₀ - (w₁+w₂)) = 2 * localSixPotential d₀ + (w₁ - 2 * localSixPotential d₀) + (w₂ - 2 * localSixPotential (localExtensions edges {a,x}).card) rw [local_neighbors_comm (a := a) (b := x)] change w₁ + w₂ + (2 * localSixPotential d₀ - (w₁+w₂)) = 2 * localSixPotential d₀ + (w₁ - 2 * localSixPotential d₀) + (w₂ - 2 * localSixPotential d₀) by_cases h1 : w₁ = 0 · omega by_cases h2 : w₂ = 0 · omega have hd6 : d₀ ≤ 6 := hd x a hxa have hW : w₁+w₂ ≤ 2*(d₀-3) := local_six_both_score_le hu hd hxa (by omega) (by omega) have hP : 2*(d₀-3) ≤ 2*localSixPotential d₀ := by interval_cases d₀ <;> decide omega have hsum := Finset.sum_congr rfl hpoint simp only [Finset.sum_add_distrib, ← Finset.mul_sum, sum_swap] at hsum have hU : ∑ p ∈ O, localSixPotential (d (localUnderlyingPair p)) = 2 * U := local_five_ordered_pair_sum (fun p => localSixPotential (d p)) rw [hU] at hsum have hD : A₀ = 0 ∧ A₁ = 0 ∧ D = 0 ∧ (∑ p ∈ O, b p) = 0 ∧ (∑ p ∈ O, s p) = 0 := by omega obtain ⟨ha₀,ha₁,hdef,hB0,hS0⟩ := hD refine ⟨?_,?_,?_⟩ · intro x a hxa have hp : ({x,a} : Finset (Fin n)) ∈ P := by simp [P,hxa] change 2 ≤ d ({x,a} : Finset (Fin n)) by_contra hn have h : d ({x,a} : Finset (Fin n)) = 0 ∨ d ({x,a} : Finset (Fin n)) = 1 := by omega rcases h with h0 | h1 · have hpos : 0 < A₀ := Finset.card_pos.mpr ⟨_,Finset.mem_filter.mpr ⟨hp,h0⟩⟩ omega · have hpos : 0 < A₁ := Finset.card_pos.mpr ⟨_,Finset.mem_filter.mpr ⟨hp,h1⟩⟩ omega · intro x a hxa have hp : ({x,a} : Finset (Fin n)) ∈ P := by simp [P,hxa] have hh : 3 - g ({x,a} : Finset (Fin n)) ≤ D := Finset.single_le_sum (fun q hq => Nat.zero_le (3 - g q)) hp change 3 ≤ g ({x,a} : Finset (Fin n)) omega · intro x a hxa have hp : (x,a) ∈ O := local_mem_ordered_pairs.mpr hxa have hp' : (a,x) ∈ O := local_mem_ordered_pairs.mpr hxa.symm have h₁ : b (x,a) ≤ ∑ p ∈ O, b p := Finset.single_le_sum (fun p hp => Nat.zero_le (b p)) hp have h₂ : b (a,x) ≤ ∑ p ∈ O, b p := Finset.single_le_sum (fun p hp => Nat.zero_le (b p)) hp' have h₃ : s (x,a) ≤ ∑ p ∈ O, s p := Finset.single_le_sum (fun p hp => Nat.zero_le (s p)) hp have he := hpoint (x,a) hp change w (x,a) + w (a,x) + s (x,a) = 2 * localSixPotential (d (localUnderlyingPair (x,a))) + b (x,a) + b (a,x) at he change w (x,a) + w (a,x) = 2 * localSixPotential (d (localUnderlyingPair (x,a))) omega theorem local_six_no_degree_six_without_exact_companions {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) (hD : ∀ x a : Fin n, x ≠ a → 2 ≤ (localExtensions edges {x,a}).card) (hG : ∀ x a : Fin n, x ≠ a → 3 ≤ (localCoExtensions edges {x,a}).card) {x a : Fin n} (hxa : x ≠ a) (h6 : (localExtensions edges {x,a}).card = 6) (hk : (localFiveContainmentClass edges x a).card = 1) (hq : ({b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 5}).card = 6) : False := by let T := localExtensions edges {x,a} let A := localFiveContainmentClass edges x a let B := {b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 5} let C := A ∪ B let N := fun z => localExtensions edges {x,z} have hAeq : A = {a} := by have ha : a ∈ A := local_mem_five_twin_class.mpr ⟨hxa,Finset.Subset.rfl⟩ apply (Finset.eq_of_subset_of_card_le (Finset.singleton_subset_iff.mpr ha) _).symm rw [Finset.card_singleton] exact hk.le have hB : B ⊆ localFiveCompanions x a := Finset.filter_subset _ _ have hPartial b (hb : b ∈ B) : (localFiveOverlap edges x a b).card = 5 := (Finset.mem_filter.mp hb).2 have hDis : Disjoint A B := local_six_class_and_partial_disjoint (fun b hb => by rw [hPartial b hb, h6]; decide) have hSum : ∑ b ∈ B, (localFiveOverlap edges x a b).card = (6 - A.card) * T.card := by calc _ = ∑ _b ∈ B, 5 := Finset.sum_congr rfl hPartial _ = _ := by simp [B,A,T,hk,h6,hq] have hCard : A.card + B.card = 7 := by simp [A,B,hk,hq] obtain ⟨hC,hDense⟩ := local_six_dense_configuration hd hxa hB hDis hCard hSum (by omega) obtain ⟨t,ht⟩ := Finset.card_pos.mp (show 0 < T.card by rw [h6]; decide) have hta := (local_neighbors_ne ht).2 have hxt := (local_neighbors_ne ht).1.symm have hX := local_neighbors_cycle hxa ht have hDat := hD a t hta.symm obtain ⟨hy,hxy⟩ := local_five_next_spec hX (by omega) let y := localFourNext edges x a t change x ≠ y at hxy change y ∈ localExtensions edges {a,t} at hy have hBase : {a,t} ∈ localCoExtensions edges {x,y} := local_pair_mem_coextensions.mpr ⟨hta.symm,hX,hy⟩ have hyt := (local_neighbors_ne hy).2 have hya := (local_neighbors_ne hy).1 have hsmall : localCoExtensions edges {x,y} ⊆ {{a,t}} := by intro q hq' obtain ⟨v,hv,hvq⟩ := Finset.not_disjoint_iff.mp (local_coextension_pairwise hu (Finset.card_pair hxy) hBase hq') simp only [Finset.mem_insert,Finset.mem_singleton] at hv rcases hv with heq | heq · subst v obtain ⟨w,hwa,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hq').1 hvq by_cases hwt : w = t · simp [hwt] exfalso obtain ⟨_,hxw,hyw⟩ := local_pair_mem_coextensions.mp hq' have hwT : w ∈ T := by rw [show T = localExtensions edges {a,x} from local_neighbors_comm] exact local_neighbors_symm hwa.symm hxw have hN := (local_six_dense_pair_overlap hC (hDense t ht).1 (hDense w hwT).1 (hDense t ht).2 (hDense w hwT).2).1 obtain ⟨b,hb,hb'⟩ := Finset.not_subset.mp (show ¬ localFiveOverlap edges x t w ⊆ {a,y} by intro h have hle := Finset.card_le_card h rw [Finset.card_pair hya.symm] at hle omega) have hbx := (local_neighbors_ne (Finset.mem_inter.mp hb).1).1 simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at hb' have hdis : Disjoint ({y,a} : Finset (Fin n)) {x,b} := by rw [Finset.disjoint_left] intro z hz hz' simp only [Finset.mem_insert,Finset.mem_singleton] at hz hz' rcases hz with rfl | rfl · exact hz'.elim hxy.symm (Ne.symm hb'.2) · exact hz'.elim hxa.symm (Ne.symm hb'.1) have htYa : t ∈ localExtensions edges {y,a} := by rw [local_neighbors_comm (a := y) (b := a)] exact local_neighbors_symm hta.symm hy have hwYa : w ∈ localExtensions edges {y,a} := by rw [local_neighbors_comm (a := y) (b := a)] exact local_neighbors_symm hwa.symm hyw exact local_extension_edges_cross hu (Finset.card_pair hya) (Finset.card_pair hbx.symm) (Ne.symm hwt) htYa hwYa (local_neighbors_symm hxt (Finset.mem_inter.mp hb).1) (local_neighbors_symm (local_neighbors_ne hwT).1.symm (Finset.mem_inter.mp hb).2) hdis · subst v obtain ⟨b,hbt,rfl⟩ := local_pair_with_center (local_mem_coextensions.mp hq').1 hvq by_cases hba : b = a · simp [hba,Finset.pair_comm t a] exfalso obtain ⟨_,hxb,hyb⟩ := local_pair_mem_coextensions.mp hq' have hbN : b ∈ N t := by change b ∈ localExtensions edges {x,t} rw [local_neighbors_comm (a := x) (b := t)] exact local_neighbors_symm hbt.symm hxb have hbB : b ∈ B := by rcases Finset.mem_union.mp ((hDense t ht).1 hbN) with hb | hb · change b ∈ A at hb rw [hAeq,Finset.mem_singleton] at hb exact (hba hb).elim · exact hb obtain ⟨w,hw,hw'⟩ := Finset.not_subset.mp (show ¬ localFiveOverlap edges x a b ⊆ {t,y} by intro h have hm := Finset.card_le_card h rw [hPartial b hbB,Finset.card_pair hyt.symm] at hm omega) have hwx := (local_neighbors_ne (Finset.mem_inter.mp hw).1).1 simp only [Finset.mem_insert,Finset.mem_singleton,not_or] at hw' have hdis : Disjoint ({y,t} : Finset (Fin n)) {x,w} := by rw [Finset.disjoint_left] intro z hz hz' simp only [Finset.mem_insert,Finset.mem_singleton] at hz hz' rcases hz with rfl | rfl · exact hz'.elim hxy.symm (Ne.symm hw'.2) · exact hz'.elim hxt.symm (Ne.symm hw'.1) have haY : a ∈ localExtensions edges {y,t} := by rw [local_neighbors_comm (a := y) (b := t)] exact local_neighbors_cycle hta.symm hy have hbY : b ∈ localExtensions edges {y,t} := by rw [local_neighbors_comm (a := y) (b := t)] exact local_neighbors_symm hbt.symm hyb exact local_extension_edges_cross hu (Finset.card_pair hyt) (Finset.card_pair hwx.symm) (Ne.symm hba) haY hbY (local_neighbors_symm hxa (Finset.mem_inter.mp hw).1) (local_neighbors_symm (local_mem_five_companions.mp (hB hbB)).2.symm (Finset.mem_inter.mp hw).2) hdis have h := (Finset.card_le_card hsmall) rw [Finset.card_singleton] at h have := hG _ _ hxy omega theorem local_six_visit_geometry {n : ℕ} {edges : Finset (Finset (Fin n))} {x a t : Fin n} (hxa : x ≠ a) (ht : t ∈ localExtensions edges {x,a}) : a ≠ t ∧ x ≠ t ∧ a ∈ localExtensions edges {x,t} ∧ x ∈ localExtensions edges {a,t} := by obtain ⟨htx,hta⟩ := local_neighbors_ne ht exact ⟨hta.symm,htx.symm,local_neighbors_symm hxa ht,local_neighbors_cycle hxa ht⟩ theorem local_six_sum_le_card_mul_of_injOn {α β : Type*} {A : Finset α} {B : Finset β} (f : α → β) (w : α → ℕ) (max : ℕ) (hM : ∀ a ∈ A, f a ∈ B) (hI : Set.InjOn f A) (hw : ∀ a ∈ A, w a ≤ max) : ∑ a ∈ A, w a ≤ max * B.card := by calc _ ≤ ∑ _a ∈ A, max := Finset.sum_le_sum hw _ = max * A.card := by simp [Nat.mul_comm] _ ≤ _ := Nat.mul_le_mul_left _ (Finset.card_le_card_of_injOn f hM hI) theorem local_six_sum_le_one_bonus {α : Type*} [DecidableEq α] {A : Finset α} (w : α → ℕ) (b : α) (m e : ℕ) (hw : ∀ a ∈ A, w a ≤ m + if a = b then e else 0) : ∑ a ∈ A, w a ≤ m * A.card + e := by refine (Finset.sum_le_sum hw).trans ?_ rw [Finset.sum_add_distrib,Finset.sum_const,smul_eq_mul,Finset.sum_ite_eq'] rw [Nat.mul_comm A.card m] split <;> omega theorem local_six_no_degree_six_with_one_exact_companion {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) (hS : ∀ x a : Fin n, x ≠ a → localFiveScore edges x a + localFiveScore edges a x = 2 * localSixPotential (localExtensions edges {x,a}).card) {x a : Fin n} (hxa : x ≠ a) (h6 : (localExtensions edges {x,a}).card = 6) (hk : (localFiveContainmentClass edges x a).card = 2) (hq : ({b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 5}).card = 4) (hr : ({b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 4}).card = 1) : False := by let T := localExtensions edges {x,a} let A := localFiveContainmentClass edges x a let Q := {b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 5} let R := {b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 4} let B := Q ∪ R let N := fun z => localExtensions edges {x,z} have hQ b (hb : b ∈ Q) : (localFiveOverlap edges x a b).card = 5 := (Finset.mem_filter.mp hb).2 have hR b (hb : b ∈ R) : (localFiveOverlap edges x a b).card = 4 := (Finset.mem_filter.mp hb).2 have hB : B ⊆ localFiveCompanions x a := by intro b hb rcases Finset.mem_union.mp hb with h | h exacts [(Finset.mem_filter.mp h).1, (Finset.mem_filter.mp h).1] have hQR : Disjoint Q R := by rw [Finset.disjoint_left] intro b hb hb' have := hQ b hb have := hR b hb' omega have hDis : Disjoint A B := local_six_class_and_partial_disjoint (fun b hb => by rw [h6] rcases Finset.mem_union.mp hb with h | h · rw [hQ b h]; decide · rw [hR b h]; decide) have hCard : A.card + B.card = 7 := by change A.card + (Q ∪ R).card = 7 rw [Finset.card_union_of_disjoint hQR,hk,hq,hr] have hSum : ∑ b ∈ B, (localFiveOverlap edges x a b).card = (6 - A.card) * T.card := by change (∑ b ∈ Q ∪ R, _) = _ rw [Finset.sum_union hQR, Finset.sum_congr rfl hQ, Finset.sum_congr rfl hR, Finset.sum_const,Finset.sum_const,smul_eq_mul,smul_eq_mul,hq,hr,hk,h6] obtain ⟨hC,hDense⟩ := local_six_dense_configuration hd hxa hB hDis hCard hSum (by omega) obtain ⟨b,hb,c,hc,hbc⟩ := Finset.one_lt_card.mp (show 1 < Q.card by rw [hq]; decide) obtain ⟨t,ht,htB,hRest⟩ := local_six_dense_missing_tip (show (localFiveOverlap edges x a b).card + 1 = T.card by rw [hQ b hb,h6]) have hxt := (local_neighbors_ne ht).1.symm have htN : b ∉ N t := by intro h exact htB (local_neighbors_symm hxt h) have hbC : b ∈ A ∪ B := Finset.mem_union.mpr (Or.inr (Finset.mem_union.mpr (Or.inl hb))) have hcC : c ∈ A ∪ B := Finset.mem_union.mpr (Or.inr (Finset.mem_union.mpr (Or.inl hc))) obtain ⟨v,hv,he⟩ := local_six_dense_missing_column hC (hDense t ht).1 (hDense t ht).2 have hvb : b = v := Finset.mem_singleton.mp (he ▸ Finset.mem_sdiff.mpr ⟨hbC,htN⟩) have hcN : c ∈ N t := by by_contra hn have hcv : c = v := Finset.mem_singleton.mp (he ▸ Finset.mem_sdiff.mpr ⟨hcC,hn⟩) exact hbc (hvb.trans hcv.symm) have hAt : A ⊆ N t := by intro w hw obtain ⟨hxw,hw'⟩ := local_mem_five_twin_class.mp hw exact local_neighbors_symm hxw (hw' ht) have hcA : c ∉ A := fun h => Finset.disjoint_left.mp hDis h (Finset.mem_union.mpr (Or.inl hc)) have hExact v (hv : v ∈ A) : N v = T := by obtain ⟨hxv,hv'⟩ := local_mem_five_twin_class.mp hv apply (Finset.eq_of_subset_of_card_le hv' _).symm rw [h6] exact hd x v hxv have hDiff v (hv : v ∈ T) (hne : v ≠ t) : N v ≠ N t := by intro h have hxb := (local_mem_five_companions.mp (hB (Finset.mem_union.mpr (Or.inl hb)))).2.symm exact htN (h ▸ local_neighbors_symm hxb (hRest v hv hne)) have ⟨hz,_,hW⟩ := local_six_dense_tip_score hu hd hxa (by omega) ht hC hDense hDiff hk hAt hExact (Finset.mem_sdiff.mpr ⟨hcN,hcA⟩) (by rw [hQ c hc]; decide) rw [hQ c hc,h6] at hW have hSat := hS x t hxt rw [(hDense t ht).2,hz] at hSat simp [localSixPotential] at hSat omega theorem local_six_eliminate_degree_six {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) (hD : ∀ x a : Fin n, x ≠ a → 2 ≤ (localExtensions edges {x,a}).card) (hG : ∀ x a : Fin n, x ≠ a → 3 ≤ (localCoExtensions edges {x,a}).card) (hS : ∀ x a : Fin n, x ≠ a → localFiveScore edges x a + localFiveScore edges a x = 2 * localSixPotential (localExtensions edges {x,a}).card) : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 5 := by have active (x a : Fin n) (hxa : x ≠ a) (h6 : (localExtensions edges {x,a}).card = 6) (hpos : 0 < localFiveScore edges x a) : False := by have hs := hS x a hxa rw [h6] at hs simp [localSixPotential] at hs have hscore : localFiveScore edges x a = 12 := by by_contra hne have hp : 0 < localFiveScore edges a x := by omega have hh := local_six_both_score_le hu hd hxa hpos hp omega obtain ⟨hf,hcap⟩ := local_six_score_at_six hd hxa h6 let k := (localFiveContainmentClass edges x a).card let q := ({b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 5}).card let r := ({b ∈ localFiveCompanions x a | (localFiveOverlap edges x a b).card = 4}).card change localFiveScore edges x a = 3*(k-1)+2*q+r at hf change 6*(k-1)+5*q+4*r ≤ 30 at hcap have ha : a ∈ localFiveContainmentClass edges x a := local_mem_five_twin_class.mpr ⟨hxa,Finset.Subset.rfl⟩ have hk : 1 ≤ k := Finset.card_pos.mpr ⟨a,ha⟩ by_cases e0 : k = 1 · exact local_six_no_degree_six_without_exact_companions hu hd hD hG hxa h6 e0 (by change q=6; omega) by_cases e1 : k = 2 · exact local_six_no_degree_six_with_one_exact_companion hu hd hS hxa h6 e1 (by change q=4; omega) (by change r=1; omega) have hk3 : 3 ≤ k := by omega obtain ⟨t,ht,hh⟩ : ∃ t ∈ localExtensions edges {x,a}, 4 ≤ k ∨ ∃ b ∈ localFiveCompanions x a, 4 ≤ (localFiveOverlap edges x a b).card ∧ b ∉ localFiveContainmentClass edges x a ∧ t ∈ localExtensions edges {x,b} := by by_cases h4 : 4 ≤ k · have ht := Finset.card_pos.mp (show 0 < (localExtensions edges {x,a}).card by omega) exact ⟨ht.choose,ht.choose_spec,Or.inl h4⟩ obtain ⟨b,hb,hB,hB'⟩ : ∃ b ∈ localFiveCompanions x a, 4 ≤ (localFiveOverlap edges x a b).card ∧ (localFiveOverlap edges x a b).card < 6 := by by_cases hq : 0 < q · obtain ⟨b,hb⟩ := Finset.card_pos.mp hq obtain ⟨hb,hB⟩ := Finset.mem_filter.mp hb exact ⟨b,hb,by omega,by omega⟩ · have hr : 0 < r := by omega obtain ⟨b,hb⟩ := Finset.card_pos.mp hr obtain ⟨hb,hB⟩ := Finset.mem_filter.mp hb exact ⟨b,hb,by omega,by omega⟩ have hbn : b ∉ localFiveContainmentClass edges x a := by intro hh have he := Finset.inter_eq_left.mpr (local_mem_five_twin_class.mp hh).2 change localFiveOverlap edges x a b = localExtensions edges {x,a} at he rw [he,h6] at hB' omega obtain ⟨t,ht⟩ := Finset.card_pos.mp (show 0 < (localFiveOverlap edges x a b).card by omega) exact ⟨t,(Finset.mem_inter.mp ht).1,Or.inr ⟨b,hb,hB,hbn,(Finset.mem_inter.mp ht).2⟩⟩ have ⟨hat,hxt,_,hX⟩ := local_six_visit_geometry hxa ht have hDat := hD a t hat obtain ⟨hy,hxy⟩ := local_five_next_spec hX (by omega) let y := localFourNext edges x a t have hBase : {a,t} ∈ localCoExtensions edges {x,y} := local_pair_mem_coextensions.mpr ⟨hat,hX,hy⟩ have hg : 3 ≤ (localCoExtensions edges {x,localFourNext edges x a t}).card := hG x y hxy obtain ⟨ht6,hz,_,hsp⟩ := local_six_score_spare_of_rays hu hd hk3 (by omega) hxa ht hxy hBase (by omega) hh (Or.inl hg) change 3 ≤ (localCoExtensions edges {x,y}).card at hg rw [if_pos hg] at hsp have hSat := hS x t hxt rw [ht6,hz] at hSat simp [localSixPotential] at hSat omega intro x a hxa have h := hd x a hxa by_contra hh have h6 : (localExtensions edges {x,a}).card = 6 := by omega have hs := hS x a hxa rw [h6] at hs simp [localSixPotential] at hs by_cases hp : 0 < localFiveScore edges x a · exact active x a hxa h6 hp · rw [← local_neighbors_comm (a := a) (b := x)] at h6 exact active a x hxa.symm h6 (by omega) theorem local_six_charge_bound {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ x a : Fin n, x ≠ a → (localExtensions edges {x,a}).card ≤ 6) : let P := (Finset.univ : Finset (Fin n)).powersetCard 2 60 * (∑ q ∈ localOrderedPairs n, localSixOverload edges q.1 q.2) ≤ 116 * ((P.filter (fun p => (localExtensions edges p).card = 1)).card + ∑ p ∈ P, (3 - (localCoExtensions edges p).card)) + 24 * (∑ q ∈ localOrderedPairs n, localSixSpare edges q) := by classical have local_six_alternate_rays_incompatible {n : ℕ} {edges : Finset (Finset (Fin n))} {a t x y : Fin n} (hat : a ≠ t) (hg : 2 ≤ (localCoExtensions edges {x,y}).card) (ha : ∀ p ∈ localCoExtensions edges {x,y}, a ∈ p) (ht : ∀ p ∈ localCoExtensions edges {x,y}, t ∈ p) : False := by have hsub : localCoExtensions edges {x,y} ⊆ {{a,t}} := by intro p hp have he : ({a,t} : Finset (Fin n)) ⊆ p := by simp [Finset.insert_subset_iff, ha p hp, ht p hp] have heq := Finset.eq_of_subset_of_card_le he (by rw [(local_mem_coextensions.mp hp).1]; simp [hat]) simp [← heq] have hc := Finset.card_le_card hsub rw [Finset.card_singleton] at hc omega dsimp only let P := (Finset.univ : Finset (Fin n)).powersetCard 2 let O := localOrderedPairs n let orient (p : Finset (Fin n)) := O.filter (fun q => localUnderlyingPair q = p) let d (p : Finset (Fin n)) := (localExtensions edges p).card let g (p : Finset (Fin n)) := (localCoExtensions edges p).card let e (p : Fin n × Fin n) := localSixOverload edges p.1 p.2 let s := localSixSpare edges have hex (p : Fin n × Fin n) : ∃ T ⊆ localExtensions edges (localUnderlyingPair p), ∃ f : ℕ, (p ∈ O → T.card * f = 60 * e p) ∧ ∀ t ∈ T, localSixFeeProfile edges p.1 p.2 t f := by by_cases h : p ∈ O · obtain ⟨T,hT,f,hf,hP⟩ := local_six_source_allocation hd p.1 p.2 (local_mem_ordered_pairs.mp h) exact ⟨T,hT,f,fun _ => hf,hP⟩ · exact ⟨∅,Finset.empty_subset _,0,fun hn => (h hn).elim,by simp⟩ choose T hT F hF hP using hex let I := Sigma (fun _ : Fin n × Fin n => Fin n) let J : Finset I := O.sigma T let x (j : Sigma (fun _ : Fin n × Fin n => Fin n)) := j.1.1 let a (j : Sigma (fun _ : Fin n × Fin n => Fin n)) := j.1.2 let t (j : Sigma (fun _ : Fin n × Fin n => Fin n)) := j.2 let y (j : I) := localFourNext edges (x j) (a j) (t j) let f (j : I) := F j.1 let k (j : I) := (localFiveContainmentClass edges (x j) (a j)).card let near (j : I) := ({a j,t j} : Finset (Fin n)) let dst (j : I) := ({x j,y j} : Finset (Fin n)) let spare (j : I) := (x j,t j) let W₁ (j : I) := if 3 ≤ k j ∧ d (near j) = 1 then f j else 0 let W₂ (j : I) := if 3 ≤ k j ∧ d (near j) ≠ 1 then if g (dst j) = 1 then f j else if g (dst j) = 2 then min (f j) 29 else 0 else 0 let W₃ (j : I) := f j - W₁ j - W₂ j have hp j (hj : j ∈ J) : localSixFeeProfile edges (x j) (a j) (t j) (f j) := hP j.1 j.2 (Finset.mem_sigma.mp hj).2 have hxa j (hj : j ∈ J) : x j ≠ a j := local_mem_ordered_pairs.mp (Finset.mem_sigma.mp hj).1 have ht j (hj : j ∈ J) : t j ∈ localExtensions edges {x j,a j} := hT j.1 (Finset.mem_sigma.mp hj).2 have hgeom j (hj : j ∈ J) : a j ≠ t j ∧ x j ≠ t j ∧ a j ∈ localExtensions edges {x j,t j} ∧ x j ∈ localExtensions edges (near j) := local_six_visit_geometry (hxa j hj) (ht j hj) have hf j (hj : j ∈ J) : f j ≤ 48 := (hp j hj).2.1 have hbalance j : f j = W₁ j + W₂ j + W₃ j := by dsimp [W₁,W₂,W₃] by_cases hK : 3 ≤ k j · by_cases hC : d (near j) = 1 · simp [hK,hC] · simp only [hK,hC,not_false_eq_true,true_and,if_false,if_true] split <;> try omega split <;> omega · simp [hK] let J₁ := J.filter (fun j => 0 < W₁ j) let J₂ := J.filter (fun j => 0 < W₂ j) let J₃ := J.filter (fun j => 0 < W₃ j) have h₁ j (hj : j ∈ J₁) : d (near j) = 1 ∧ 3 ≤ k j := by have h := (Finset.mem_filter.mp hj).2 change 0 < (if _ then f j else 0) at h split at h <;> omega have hpair j (hj : j ∈ J) (hn : d (near j) ≠ 1) : x j ≠ y j ∧ near j ∈ localCoExtensions edges (dst j) := by obtain ⟨hat,_,_,hX⟩ := hgeom j hj obtain ⟨hy,hxy⟩ := local_five_next_spec hX hn exact ⟨hxy,local_pair_mem_coextensions.mpr ⟨hat,hX,hy⟩⟩ have h₂ j (hj : j ∈ J₂) : (g (dst j) = 1 ∨ g (dst j) = 2) ∧ d (near j) ≠ 1 ∧ 3 ≤ k j := by have h := (Finset.mem_filter.mp hj).2 dsimp only [W₂] at h split at h · rename_i hg exact ⟨by split at h <;> try simp_all <;> split at h <;> simp_all,hg.2,hg.1⟩ · omega have h₃ j (hj : j ∈ J₃) : localFiveScore edges (x j) (t j) > 0 ∧ localFiveScore edges (t j) (x j) = 0 ∧ 0 < s (spare j) ∧ (k j = 2 → d (localUnderlyingPair j.1) = 5 ∧ W₃ j = 12 ∧ (s (spare j) = 1 → ∀ v ∈ localExtensions edges {x j,t j}, (localExtensions edges {x j,v}).card = 5 → v = a j)) ∧ (k j ≠ 2 → W₃ j ≤ 24 ∧ (s (spare j) < 5 → W₃ j ≤ 7)) := by have hJ := (Finset.mem_filter.mp hj).1 have hpos := (Finset.mem_filter.mp hj).2 obtain ⟨_,hf48,hD,hK | hK⟩ := hp j hJ · obtain ⟨hK,hd5,h12,hq⟩ := hK change k j = 2 at hK have hk3 : ¬ 3 ≤ k j := by omega have hw : W₃ j = 12 := by change f j = 12 at h12 simp [W₃,W₁,W₂,hk3,h12] obtain ⟨h6,hz,hp,h11,huniq⟩ := local_six_nondegenerate_dense_target hu hd (hxa j hJ) hd5 hK hq (ht j hJ) have he : s (spare j) = 12 - localFiveScore edges (x j) (t j) := by simp [s,spare,localSixSpare,localUnderlyingPair,h6,hz,localSixPotential] refine ⟨hp,hz,by omega,fun _ => ⟨hd5,hw,fun hh => huniq (by omega)⟩,?_⟩ exact fun hn => (hn hK).elim · obtain ⟨hK,h24,h36,hactive⟩ := hK change 3 ≤ k j at hK change (k j ≤ 4 → f j ≤ 24) at h24 change (k j ≤ 5 → f j ≤ 36) at h36 have hD3 : 3 ≤ (localExtensions edges {x j,a j}).card := by omega have hn : d (near j) ≠ 1 := by intro he have hz : W₃ j = 0 := by simp [W₃,W₁,W₂,hK,he] omega obtain ⟨hxy,hRay⟩ := hpair j hJ hn have hg1 : g (dst j) ≠ 1 := by intro he have hz : W₃ j = 0 := by simp [W₃,W₁,W₂,hK,hn,he] omega have hg2 : 2 ≤ g (dst j) := by have hc := Finset.card_pos.mpr ⟨_, hRay⟩ change 0 < g (dst j) at hc omega by_cases hg3 : 3 ≤ g (dst j) · obtain ⟨h6,hz,hp,hsp⟩ := local_six_score_spare_of_rays hu hd hK hD (hxa j hJ) (ht j hJ) hxy hRay hg2 hactive (Or.inl hg3) rw [if_pos hg3] at hsp have hc := local_containment_biclique_cross_bound hu hK hD3 (fun hx => (local_mem_five_twin_class.mp hx).1 rfl) (fun _ hz => (local_mem_five_twin_class.mp hz).2) (local_mem_five_twin_class.mpr ⟨hxa j hJ,Finset.Subset.rfl⟩) rfl (ht j hJ) hxy hRay change g (dst j) + k j ≤ (localExtensions edges {x j,t j}).card + 1 at hc have he : s (spare j) = 12 - localFiveScore edges (x j) (t j) := by simp [s,spare,localSixSpare,localUnderlyingPair,h6,hz,localSixPotential] have hm : W₃ j ≤ f j := (Nat.sub_le ..).trans (Nat.sub_le ..) exact ⟨hp,hz,by omega,fun h => by omega,fun _ => ⟨by have := h24 (by omega); omega,by omega⟩⟩ · have hg : g (dst j) = 2 := by omega have hw : W₃ j = f j - min (f j) 29 := by simp [W₃,W₁,W₂,hK,hn,hg] have hk5 : 5 ≤ k j := by by_contra hk have := h24 (by omega) omega have hc := local_containment_biclique_cross_bound hu hK hD3 (fun hx => (local_mem_five_twin_class.mp hx).1 rfl) (fun _ hz => (local_mem_five_twin_class.mp hz).2) (local_mem_five_twin_class.mpr ⟨hxa j hJ,Finset.Subset.rfl⟩) rfl (ht j hJ) hxy hRay change g (dst j) + k j ≤ (localExtensions edges {x j,t j}).card + 1 at hc have hcap := hd _ _ (hgeom j hJ).2.1 have h7 : W₃ j ≤ 7 := by have := h36 (by omega); omega obtain ⟨h6,hz,hp,hsp⟩ := local_six_score_spare_of_rays hu hd hK hD (hxa j hJ) (ht j hJ) hxy hRay hg2 hactive (Or.inr hk5) rw [if_neg hg3] at hsp have he : s (spare j) = 12 - localFiveScore edges (x j) (t j) := by simp [s,spare,localSixSpare,localUnderlyingPair,h6,hz,localSixPotential] exact ⟨hp,hz,by omega,fun h => by omega,fun _ => ⟨by omega,fun _ => h7⟩⟩ have nearP j (hj : j ∈ J) : near j ∈ P := by simp [near,P,(hgeom j hj).1] have dstP j (hj : j ∈ J₂) : dst j ∈ P := by have hxy := (hpair j (Finset.mem_filter.mp hj).1 (h₂ j hj).2.1).1 simp [dst,P,hxy] have spareO j (hj : j ∈ J₃) : spare j ∈ O := local_mem_ordered_pairs.mpr (hgeom j (Finset.mem_filter.mp hj).1).2.1 have one (p : Finset (Fin n)) (hp : p ∈ P) : ∑ j ∈ J₁ with near j = p, W₁ j ≤ 116 * (if d p = 1 then 1 else 0) := by let U := J₁.filter (fun j => near j = p) have hP2 := (Finset.mem_powersetCard.mp hp).2 by_cases hdp : d p = 1 · have hM : ∀ j ∈ U, (a j,t j) ∈ orient p := by intro j hj obtain ⟨hj,he⟩ := Finset.mem_filter.mp hj exact Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr (hgeom j (Finset.mem_filter.mp hj).1).1,he⟩ have hI : Set.InjOn (fun j => (a j,t j)) U := by intro j hj z hz he have hj' := hM j hj have hz' := hM z hz have hjJ := (Finset.mem_filter.mp (Finset.mem_filter.mp hj).1).1 have hzJ := (Finset.mem_filter.mp (Finset.mem_filter.mp hz).1).1 have hjx := (Finset.mem_filter.mp hj).2 ▸ (hgeom j hjJ).2.2.2 have hzx := (Finset.mem_filter.mp hz).2 ▸ (hgeom z hzJ).2.2.2 have hxx : x j = x z := Finset.card_le_one_iff.mp (show (localExtensions edges p).card ≤ 1 from hdp.le) hjx hzx obtain ⟨ha,ht⟩ := Prod.mk.inj he exact Sigma.ext (Prod.ext hxx ha) (heq_of_eq ht) have hW : ∀ j ∈ U, W₁ j ≤ 48 := by intro j hj have hj' := (Finset.mem_filter.mp hj).1 have hjJ := (Finset.mem_filter.mp hj').1 have ⟨hD,hk⟩ := h₁ j hj' simpa [W₁,hk,hD] using hf j hjJ have h := local_six_sum_le_card_mul_of_injOn (fun j => (a j,t j)) W₁ 48 hM hI hW change (∑ j ∈ U, W₁ j) ≤ _ rw [if_pos hdp] have hc := local_orderings_two hP2 change (orient p).card = 2 at hc rw [hc] at h exact h.trans (by decide) · rw [if_neg hdp] have hU : U = ∅ := Finset.eq_empty_iff_forall_notMem.mpr (fun j hj => by have ⟨hj,he⟩ := Finset.mem_filter.mp hj exact hdp (he ▸ (h₁ j hj).1)) change (∑ j ∈ U, _) ≤ 116*0 simp [hU] have two (p : Finset (Fin n)) (hpP : p ∈ P) : ∑ j ∈ J₂ with dst j = p, W₂ j ≤ 116 * (3 - g p) := by let U := J₂.filter (fun j => dst j = p) have hP2 := (Finset.mem_powersetCard.mp hpP).2 have haux j (hj : j ∈ U) : j ∈ J ∧ dst j = p ∧ near j ∈ localCoExtensions edges p ∧ x j ≠ y j ∧ d (near j) ≠ 1 ∧ 3 ≤ k j := by obtain ⟨hj,he⟩ := Finset.mem_filter.mp hj have hj' := (Finset.mem_filter.mp hj).1 have ⟨_,hD,hk⟩ := h₂ j hj obtain ⟨hxy,hmem⟩ := hpair j hj' hD exact ⟨hj',he,he ▸ hmem,hxy,hD,hk⟩ have hM j (hj : j ∈ U) : (x j,y j) ∈ orient p := Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr (haux j hj).2.2.2.1,(haux j hj).2.1⟩ have hc := local_orderings_two hP2 change (orient p).card = 2 at hc by_cases hg1 : g p = 1 · have hUni : ∀ j ∈ U, ∀ z ∈ U, near j = near z := by intro j hj z hz exact Finset.card_le_one_iff.mp (by change g p ≤ 1; omega) (haux j hj).2.2.1 (haux z hz).2.2.1 by_cases hne : U.Nonempty · obtain ⟨j₀,hj₀⟩ := hne let M := (orient p) ×ˢ (orient (near j₀)) have hM' : ∀ j ∈ U, ((x j,y j),(a j,t j)) ∈ M := by intro j hj have hjJ := (haux j hj).1 exact Finset.mem_product.mpr ⟨hM j hj,Finset.mem_filter.mpr ⟨local_mem_ordered_pairs.mpr (hgeom j hjJ).1,hUni j hj j₀ hj₀⟩⟩ have hi : Set.InjOn (fun j => ((x j,y j),(a j,t j))) U := by intro j hj z hz he obtain ⟨hL,hR⟩ := Prod.mk.inj he exact Sigma.ext (Prod.ext (Prod.mk.inj hL).1 (Prod.mk.inj hR).1) (heq_of_eq (Prod.mk.inj hR).2) have hw : ∀ j ∈ U, W₂ j ≤ 48 := by intro j hj obtain ⟨hj,he⟩ := Finset.mem_filter.mp hj have hJ := (Finset.mem_filter.mp hj).1 obtain ⟨_,hn,hk⟩ := h₂ j hj have hg : g (dst j) = 1 := he.symm ▸ hg1 simpa [W₂,hk,hn,hg] using hf j hJ have hsum := local_six_sum_le_card_mul_of_injOn _ W₂ 48 hM' hi hw have hc' := local_orderings_two (local_mem_coextensions.mp (haux j₀ hj₀).2.2.1).1 change (orient (near j₀)).card = 2 at hc' rw [Finset.card_product,hc,hc'] at hsum change (∑ j ∈ U, _) ≤ _ omega · have he : U = ∅ := Finset.not_nonempty_iff_eq_empty.mp hne change (∑ j ∈ U, _) ≤ _ simp [he] by_cases hg2 : g p = 2 · let M := (orient p) ×ˢ (localCoExtensions edges p) have hM' : ∀ j ∈ U, ((x j,y j),near j) ∈ M := fun j hj => Finset.mem_product.mpr ⟨hM j hj,(haux j hj).2.2.1⟩ have hi : Set.InjOn (fun j => ((x j,y j),near j)) U := by intro j hj z hz he obtain ⟨hL,hR⟩ := Prod.mk.inj he have hxx := (Prod.mk.inj hL).1 have hJ := (haux j hj).1 have hZ := (haux z hz).1 have hAT : a j ≠ t j := (hgeom j hJ).1 have hAZ : a z ≠ t z := (hgeom z hZ).1 have haR : a j ∈ near z := hR ▸ Finset.mem_insert_self _ _ simp only [near,Finset.mem_insert,Finset.mem_singleton] at haR rcases haR with ha | ha · have htR : t j ∈ near z := hR ▸ Finset.mem_insert_of_mem (Finset.mem_singleton_self _) simp only [near,Finset.mem_insert,Finset.mem_singleton] at htR have htR' := htR.resolve_left (fun ht => hAT (ha.trans ht.symm)) exact Sigma.ext (Prod.ext hxx ha) (heq_of_eq htR') · have hstar (i : Sigma (fun _ : Fin n × Fin n => Fin n)) (hi : i ∈ U) : ∀ q ∈ localCoExtensions edges p, t i ∈ q := by obtain ⟨hiJ,he,hm,hxy,_,hK⟩ := haux i hi have hD := (hp i hiJ).2.2.1 intro q hq have hm' : near i ∈ localCoExtensions edges (dst i) := by rw [he]; exact hm have hq' : q ∈ localCoExtensions edges (dst i) := by rw [he]; exact hq obtain ⟨v,hv,rfl,_⟩ := local_six_class_rays hu hxy hK (by omega) (hxa i hiJ) (ht i hiJ) hm' q hq' simp have htR : t j ∈ near z := hR ▸ Finset.mem_insert_of_mem (Finset.mem_singleton_self _) simp only [near,Finset.mem_insert,Finset.mem_singleton] at htR have htR' := htR.resolve_right (fun ht => hAT (ha.trans ht.symm)) have hg : 2 ≤ (localCoExtensions edges (dst j)).card := by rw [(haux j hj).2.1] change 2 ≤ g p omega exact (local_six_alternate_rays_incompatible hAT hg (fun q hq => by rw [ha]; exact hstar z hz q ((haux j hj).2.1 ▸ hq)) (fun q hq => hstar j hj q ((haux j hj).2.1 ▸ hq))).elim have hw : ∀ j ∈ U, W₂ j ≤ 29 := by intro j hj obtain ⟨hj,he⟩ := Finset.mem_filter.mp hj obtain ⟨_,hn,hk⟩ := h₂ j hj have hg : g (dst j) = 2 := he.symm ▸ hg2 simpa [W₂,hk,hn,hg,show 2 ≠ (1:ℕ) by decide] using (min_le_right (f j) 29) have hs := local_six_sum_le_card_mul_of_injOn _ W₂ 29 hM' hi hw rw [Finset.card_product,hc] at hs change (∑ j ∈ U, _) ≤ 29 * (2 * g p) at hs change (∑ j ∈ U, _) ≤ _ omega · have he : U = ∅ := Finset.eq_empty_iff_forall_notMem.mpr (fun j hj => by obtain ⟨hj,he⟩ := Finset.mem_filter.mp hj exact ((h₂ j hj).1.elim (fun h => hg1 (he ▸ h)) (fun h => hg2 (he ▸ h)))) change (∑ j ∈ U, _) ≤ _ simp [he] let U₃ (p : Fin n × Fin n) := J₃.filter (fun j => spare j = p) have three (p : Fin n × Fin n) (hpO : p ∈ O) : ∑ j ∈ U₃ p, W₃ j ≤ 48 * s p := by let U := U₃ p let B := localExtensions edges (localUnderlyingPair p) have hM : ∀ j ∈ U, a j ∈ B := by intro j hj obtain ⟨hj,he⟩ := Finset.mem_filter.mp hj have hmem : a j ∈ localExtensions edges (localUnderlyingPair (spare j)) := (hgeom j (Finset.mem_filter.mp hj).1).2.2.1 change a j ∈ localExtensions edges (localUnderlyingPair p) exact he ▸ hmem have hI : Set.InjOn a U := by intro j hj z hz he have hEq : spare j = spare z := (Finset.mem_filter.mp hj).2.trans (Finset.mem_filter.mp hz).2.symm exact Sigma.ext (Prod.ext (Prod.mk.inj hEq).1 he) (heq_of_eq (Prod.mk.inj hEq).2) have hB := hd p.1 p.2 (local_mem_ordered_pairs.mp hpO) change B.card ≤ 6 at hB have hU := (Finset.card_le_card_of_injOn _ hM hI).trans hB have hAux j (hj : j ∈ U) : j ∈ J₃ ∧ spare j = p := Finset.mem_filter.mp hj have hbnds j (hj : j ∈ U) : W₃ j ≤ 24 ∧ (s p < 5 → if k j = 2 then W₃ j = 12 else W₃ j ≤ 7) := by obtain ⟨hj,he⟩ := hAux j hj obtain ⟨_,_,_,hk,hm⟩ := h₃ j hj by_cases hk2 : k j = 2 · have hh := (hk hk2).2.1 exact ⟨by omega,fun _ => by simpa [hk2] using hh⟩ · obtain ⟨hh,hm'⟩ := hm hk2 exact ⟨hh,fun h => by simpa [hk2] using hm' (he.symm ▸ h)⟩ by_cases h5 : 5 ≤ s p · have hsum := local_six_sum_le_card_mul_of_injOn _ W₃ 24 hM hI (fun j hj => (hbnds j hj).1) exact hsum.trans (by omega) by_cases h2 : 2 ≤ s p · have hSum := local_six_sum_le_card_mul_of_injOn _ W₃ 12 hM hI (fun j hj => by have hh := (hbnds j hj).2 (by omega) split at hh <;> omega) exact hSum.trans (by omega) by_cases hEmpty : U = ∅ · change (∑ j ∈ U, _) ≤ _ simp [hEmpty] have hPos : 0 < s p := by obtain ⟨j,hj⟩ := Finset.nonempty_iff_ne_empty.mpr hEmpty exact (hAux j hj).2 ▸ (h₃ j (hAux j hj).1).2.2.1 have h1 : s p = 1 := by omega by_cases hExist : ∃ j ∈ U, k j = 2 · obtain ⟨j,hj,hk⟩ := hExist have hen : ∀ z ∈ U, k z = 2 → z = j := by intro z hz hkz obtain ⟨hj',he⟩ := hAux j hj obtain ⟨hz',he'⟩ := hAux z hz have hh := ((h₃ z hz').2.2.2.1 hkz).1 have hu := ((h₃ j hj').2.2.2.1 hk).2.2 (he.symm ▸ h1) have hmem : a z ∈ localExtensions edges {x j,t j} := by change a z ∈ localExtensions edges (localUnderlyingPair (spare j)) rw [he] exact hM z hz have hxx : x z = x j := by have heq := congrArg (fun q : Fin n × Fin n => q.1) (he'.trans he.symm) exact heq change (localExtensions edges {x z,a z}).card = 5 at hh rw [hxx] at hh exact hI hz hj (hu _ hmem hh) have hh := local_six_sum_le_one_bonus W₃ j 7 5 (fun z hz => by have h := (hbnds z hz).2 (by omega) by_cases hz2 : k z = 2 · have he := hen z hz hz2 have hW : W₃ z = 12 := by simpa [hz2] using h rw [if_pos he, hW] · have hh : W₃ z ≤ 7 := by simpa [hz2] using h omega) exact hh.trans (by omega) · have hsum := local_six_sum_le_card_mul_of_injOn _ W₃ 7 hM hI (fun j hj => by have hk : k j ≠ 2 := fun h => hExist ⟨j,hj,h⟩ simpa [hk] using (hbnds j hj).2 (by omega)) exact hsum.trans (by omega) have hSwap p : s p.swap = s p := by rcases p with ⟨x,a⟩ simp only [s,localSixSpare,Prod.swap,localUnderlyingPair] rw [Finset.pair_comm a x,Nat.add_comm (localFiveScore edges a x)] have hSpPoint p (hpO : p ∈ O) : (∑ j ∈ U₃ p, W₃ j) + (∑ j ∈ U₃ p.swap, W₃ j) ≤ 48 * s p := by have hpSwap : p.swap ∈ O := local_mem_ordered_pairs.mpr (local_mem_ordered_pairs.mp hpO).symm by_cases hn : (U₃ p).Nonempty · obtain ⟨j,hj⟩ := hn have hZero : U₃ p.swap = ∅ := by apply Finset.eq_empty_iff_forall_notMem.mpr intro i hi have ⟨hJ,hp⟩ := Finset.mem_filter.mp hj have ⟨hI,hi⟩ := Finset.mem_filter.mp hi have h1 := (h₃ j hJ).1 have h2 := (h₃ i hI).2.1 have hh1 : 0 < localFiveScore edges p.1 p.2 := hp ▸ h1 have h2' : localFiveScore edges (spare i).2 (spare i).1 = 0 := h2 rw [hi] at h2' have hh2 : localFiveScore edges p.1 p.2 = 0 := h2' omega simpa [hZero] using three p hpO · have he := Finset.not_nonempty_iff_eq_empty.mp hn simpa [he,hSwap p] using three p.swap hpSwap have sum_swap (v : (Fin n × Fin n) → ℕ) : ∑ p ∈ O, v p.swap = ∑ p ∈ O, v p := by refine Finset.sum_nbij Prod.swap ?_ ?_ ?_ (fun _ _ => rfl) · intro p hp exact local_mem_ordered_pairs.mpr (local_mem_ordered_pairs.mp hp).symm · intro p hp q hq hpq exact congrArg Prod.swap hpq · intro p hp exact ⟨p.swap,local_mem_ordered_pairs.mpr (local_mem_ordered_pairs.mp hp).symm,rfl⟩ have hb1 := Finset.sum_le_sum one have hb2 := Finset.sum_le_sum two have hb3 := Finset.sum_le_sum hSpPoint simp only [← Finset.mul_sum, ← Finset.card_filter] at hb1 simp only [← Finset.mul_sum] at hb2 simp only [Finset.sum_add_distrib, ← Finset.mul_sum] at hb3 have hs := sum_swap (fun p => ∑ j ∈ U₃ p, W₃ j) change (∑ p ∈ O, ∑ j ∈ U₃ p.swap, W₃ j) = ∑ p ∈ O, ∑ j ∈ U₃ p, W₃ j at hs rw [hs] at hb3 have htot1 : (∑ p ∈ P, ∑ j ∈ J₁ with near j = p, W₁ j) = ∑ j ∈ J₁, W₁ j := Finset.sum_fiberwise_of_maps_to (fun j hj => nearP j (Finset.mem_filter.mp hj).1) W₁ have htot2 := Finset.sum_fiberwise_of_maps_to dstP W₂ have htot3 := Finset.sum_fiberwise_of_maps_to spareO W₃ rw [htot1] at hb1 rw [htot2] at hb2 change _ + (∑ p ∈ O, ∑ j ∈ U₃ p, W₃ j) ≤ _ at hb3 have hSum3 : (∑ p ∈ O, ∑ j ∈ U₃ p, W₃ j) = ∑ j ∈ J₃, W₃ j := htot3 rw [hSum3] at hb3 have hfilter (W : Sigma (fun _ : Fin n × Fin n => Fin n) → ℕ) : (∑ j ∈ J with 0 < W j, W j) = ∑ j ∈ J, W j := by rw [Finset.sum_filter] exact Finset.sum_congr rfl fun j _ => by split <;> omega change _ ≤ _ at hb1 dsimp only [J₁] at hb1 dsimp only [J₂] at hb2 dsimp only [J₃] at hb3 rw [hfilter] at hb1 hb2 hb3 have hTot : ∑ j ∈ J, f j = 60 * (∑ p ∈ O, e p) := by change (∑ j ∈ O.sigma T, F j.1) = _ rw [Finset.sum_sigma, Finset.mul_sum] refine Finset.sum_congr rfl fun p hp => ?_ simpa only [Finset.sum_const, smul_eq_mul] using hF p hp have hbal : (∑ j ∈ J, f j) = (∑ j ∈ J, W₁ j) + (∑ j ∈ J, W₂ j) + (∑ j ∈ J, W₃ j) := by have he : (∑ j ∈ J, f j) = ∑ j ∈ J, (W₁ j + W₂ j + W₃ j) := Finset.sum_congr rfl (fun j _ => hbalance j) simpa only [Finset.sum_add_distrib] using he change 60 * (∑ p ∈ O, e p) ≤ 116 * ((P.filter (fun p => d p = 1)).card + ∑ p ∈ P, (3 - g p)) + 24 * (∑ p ∈ O, s p) rw [← hTot, hbal] omega theorem local_six_impossible_at_average_three {n : ℕ} {edges : Finset (Finset (Fin n))} (hu : UniqueDisjointUnions edges) (hd : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card ≤ 6) (havg : ∑ p ∈ (Finset.univ : Finset (Fin n)).powersetCard 2, (localExtensions edges p).card = 3 * n.choose 2) : ∀ a b : Fin n, a ≠ b → (localExtensions edges {a,b}).card = 3 := by obtain ⟨hD,hG,hS⟩ := local_six_saturation_of_charge_bound hu hd havg (local_six_charge_bound hu hd) exact local_five_impossible_at_average_three hu (local_six_eliminate_degree_six hu hd hD hG hS) havg /-- Equality families with pair codegree bounded by six are Steiner expansions. -/ theorem classify_extremal_triple_families_of_pair_codegree_le_six {n : ℕ} (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hUnique : UniqueDisjointUnions edges) (hExtremal : edges.card = n.choose 2) (hMax : ∀ pair : Finset (Fin n), pair.card = 2 → (edges.filter (fun e => pair ⊆ e)).card ≤ 6) : ∃ blocks : Finset (Finset (Fin n)), SteinerFive blocks ∧ IsExpansion edges blocks := by have hcard (a b : Fin n) (hab : a ≠ b) : (localExtensions edges {a,b}).card = (edges.filter (fun e => ({a,b} : Finset (Fin n)) ⊆ e)).card := by have hEq (c : Fin n) : insert c ({a,b} : Finset (Fin n)) = {a,b,c} := by ext x simp only [Finset.mem_insert, Finset.mem_singleton] tauto simpa only [localExtensions, hEq] using extension_card_eq_pair_filter_card edges hUniform hab have hDeg6 (a b : Fin n) (hab : a ≠ b) : (localExtensions edges {a,b}).card ≤ 6 := by rw [hcard a b hab] exact hMax _ (by simp [hab]) have hAvg := sum_local_extensions_card edges hUniform rw [hExtremal] at hAvg have hDeg3 := local_six_impossible_at_average_three hUnique hDeg6 hAvg apply classify_extremal_triple_families_of_pair_codegree_le_three edges hUniform hUnique hExtremal intro p hp obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp rw [← hcard a b hab, hDeg3 a b hab] /-- The codegree-six classification and the high-codegree exclusion give the classification through order eleven. -/ theorem classify_extremal_triple_families_of_order_le_eleven {n : ℕ} (hn : 5 ≤ n) (hn' : n ≤ 11) (edges : Finset (Finset (Fin n))) (hUniform : ∀ e ∈ edges, e.card = 3) (hUnique : UniqueDisjointUnions edges) (hExtremal : edges.card = n.choose 2) : ∃ blocks : Finset (Finset (Fin n)), SteinerFive blocks ∧ IsExpansion edges blocks := by by_cases hsmall : n ≤ 10 · exact classify_extremal_triple_families_of_order_le_ten hn hsmall edges hUniform hUnique hExtremal have hn11 : 7 ≤ n := by omega apply classify_extremal_triple_families_of_pair_codegree_le_six edges hUniform hUnique hExtremal intro p hp obtain ⟨a,b,hab,rfl⟩ := Finset.card_eq_two.mp hp have hEq (c : Fin n) : insert c ({a,b} : Finset (Fin n)) = {a,b,c} := by ext x simp only [Finset.mem_insert,Finset.mem_singleton] tauto have hc : (localExtensions edges {a,b}).card = (edges.filter (fun e => ({a,b} : Finset (Fin n)) ⊆ e)).card := by simpa only [localExtensions,hEq] using extension_card_eq_pair_filter_card edges hUniform hab rw [← hc] have hbound := extremal_pair_codegree_le_sub_five hn11 hUnique hUniform hExtremal hp omega /-- Two checked cases of the equality classification. -/ theorem cairn_equality_classification_partial : ( let uniqueUnions := fun {n : ℕ} (edges : Finset (Finset (Fin n))) => ∀ A ∈ edges, ∀ B ∈ edges, ∀ C ∈ edges, ∀ D ∈ edges, Disjoint A B → Disjoint C D → A ∪ B = C ∪ D → (A = C ∧ B = D) ∨ (A = D ∧ B = C) let isSteinerExpansion := fun {n : ℕ} (edges : Finset (Finset (Fin n))) => ∃ blocks : Finset (Finset (Fin n)), ((∀ block ∈ blocks, block.card = 5) ∧ ∀ pair : Finset (Fin n), pair.card = 2 → ∃! block : Finset (Fin n), block ∈ blocks ∧ pair ⊆ block) ∧ (∀ triple : Finset (Fin n), triple ∈ edges ↔ triple.card = 3 ∧ ∃ block ∈ blocks, triple ⊆ block) (∀ (n : ℕ) (edges : Finset (Finset (Fin n))), (∀ e ∈ edges, e.card = 3) → uniqueUnions edges → edges.card = n.choose 2 → (∀ pair : Finset (Fin n), pair.card = 2 → (edges.filter (fun e => pair ⊆ e)).card ≤ 6) → isSteinerExpansion edges) ∧ (∀ (n : ℕ), 5 ≤ n → n ≤ 11 → ∀ (edges : Finset (Finset (Fin n))), (∀ e ∈ edges, e.card = 3) → uniqueUnions edges → edges.card = n.choose 2 → isSteinerExpansion edges) ) := by constructor · intro n edges huniform hunique heq hmax exact classify_extremal_triple_families_of_pair_codegree_le_six edges huniform hunique heq hmax · intro n hlow hhigh edges huniform hunique heq exact classify_extremal_triple_families_of_order_le_eleven hlow hhigh edges huniform hunique heq end ResearchErdos643