|
| 1 | +/- |
| 2 | +Copyright (c) 2025 Pim Otte. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Pim Otte |
| 5 | +-/ |
| 6 | + |
| 7 | +import Mathlib.Combinatorics.SimpleGraph.Path |
| 8 | +import Mathlib.Data.Set.Card |
| 9 | + |
| 10 | +/-! |
| 11 | +# Representation of components by a set of vertices |
| 12 | +
|
| 13 | +## Main definition |
| 14 | +
|
| 15 | +* `SimpleGraph.ConnectedComponent.Represents` says that a set of vertices represents a set of |
| 16 | + components if it contains exactly one vertex from each component. |
| 17 | +-/ |
| 18 | + |
| 19 | +universe u |
| 20 | + |
| 21 | +variable {V : Type u} |
| 22 | +variable {G : SimpleGraph V} |
| 23 | + |
| 24 | +namespace SimpleGraph.ConnectedComponent |
| 25 | + |
| 26 | +/-- A set of vertices represents a set of components if it contains exactly one vertex from |
| 27 | +each component. -/ |
| 28 | +def Represents (s : Set V) (C : Set G.ConnectedComponent) : Prop := |
| 29 | + Set.BijOn G.connectedComponentMk s C |
| 30 | + |
| 31 | +namespace Represents |
| 32 | + |
| 33 | +variable {C : Set G.ConnectedComponent} {s : Set V} {c : G.ConnectedComponent} |
| 34 | + |
| 35 | +lemma image_out (C : Set G.ConnectedComponent) : |
| 36 | + Represents (Quot.out '' C) C := |
| 37 | + Set.BijOn.mk (by rintro c ⟨x, ⟨hx, rfl⟩⟩; simp_all [connectedComponentMk]) (by |
| 38 | + rintro x ⟨c, ⟨hc, rfl⟩⟩ y ⟨d, ⟨hd, rfl⟩⟩ hxy |
| 39 | + simp only [connectedComponentMk] at hxy |
| 40 | + aesop) (fun _ _ ↦ by simpa [connectedComponentMk]) |
| 41 | + |
| 42 | +lemma existsUnique_rep (hrep : Represents s C) (h : c ∈ C) : ∃! x, x ∈ s ∩ c.supp := by |
| 43 | + obtain ⟨x, ⟨hx, rfl⟩⟩ := hrep.2.2 h |
| 44 | + use x |
| 45 | + simp only [Set.mem_inter_iff, hx, SetLike.mem_coe, mem_supp_iff, and_self, and_imp, true_and] |
| 46 | + exact fun y hy hyx ↦ hrep.2.1 hy hx hyx |
| 47 | + |
| 48 | +lemma disjoint_supp_of_not_mem (hrep : Represents s C) (h : c ∉ C) : Disjoint s c.supp := by |
| 49 | + rw [Set.disjoint_left] |
| 50 | + intro a ha hc |
| 51 | + simp only [mem_supp_iff] at hc |
| 52 | + subst hc |
| 53 | + exact h (hrep.1 ha) |
| 54 | + |
| 55 | +lemma ncard_inter (hrep : Represents s C) (h : c ∈ C) : (s ∩ c.supp).ncard = 1 := by |
| 56 | + rw [Set.ncard_eq_one] |
| 57 | + obtain ⟨a, ha⟩ := hrep.existsUnique_rep h |
| 58 | + aesop |
| 59 | + |
| 60 | +lemma ncard_sdiff_of_mem [Fintype V] (hrep : Represents s C) (h : c ∈ C) : |
| 61 | + (c.supp \ s).ncard = c.supp.ncard - 1 := by |
| 62 | + simp [← Set.ncard_inter_add_ncard_diff_eq_ncard c.supp s (Set.toFinite _), Set.inter_comm, |
| 63 | + ncard_inter hrep h] |
| 64 | + |
| 65 | +lemma ncard_sdiff_of_not_mem [Fintype V] (hrep : Represents s C) (h : c ∉ C) : |
| 66 | + (c.supp \ s).ncard = c.supp.ncard := by |
| 67 | + simp [← Set.ncard_inter_add_ncard_diff_eq_ncard c.supp s (Set.toFinite _), Set.inter_comm, |
| 68 | + Set.disjoint_iff_inter_eq_empty.mp (hrep.disjoint_supp_of_not_mem h)] |
| 69 | + |
| 70 | +end SimpleGraph.ConnectedComponent.Represents |
0 commit comments