Skip to content

Commit b300f2c

Browse files
committed
feat(Combinatorics/SimpleGraph/Basic): Disjoint for graph sets (leanprover-community#41795)
1 parent b9a117e commit b300f2c

2 files changed

Lines changed: 39 additions & 2 deletions

File tree

Mathlib/Combinatorics/SimpleGraph/Basic.lean

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,8 @@ public import Mathlib.Data.Sym.Sym2
1313
public import Mathlib.Order.CompleteBooleanAlgebra
1414
public import Mathlib.Tactic.CrossRefAttribute
1515

16+
import Mathlib.Data.Set.Lattice
17+
1618
/-!
1719
# Simple graphs
1820
@@ -155,7 +157,7 @@ def completeBipartiteGraph (V W : Type*) : SimpleGraph (V ⊕ W) where
155157

156158
namespace SimpleGraph
157159

158-
variable {ι : Sort*} {V : Type u} (G : SimpleGraph V) {a b c u v w : V} {e : Sym2 V}
160+
variable {ι : Sort*} {V : Type u} (G H : SimpleGraph V) {a b c u v w : V} {e : Sym2 V}
159161

160162
@[simp]
161163
protected theorem irrefl {v : V} : ¬G.Adj v v :=
@@ -553,6 +555,11 @@ variable {G G₁ G₂}
553555
@[simp] lemma disjoint_edgeSet : Disjoint G₁.edgeSet G₂.edgeSet ↔ Disjoint G₁ G₂ := by
554556
rw [Set.disjoint_iff, disjoint_iff_inf_le, ← edgeSet_inf, ← edgeSet_bot, OrderEmbedding.le_iff_le]
555557

558+
theorem disjoint_of_disjoint_support (h : Disjoint G.support H.support) : Disjoint G H := by
559+
simp_rw [Set.disjoint_left, mem_support] at h
560+
rw [← disjoint_edgeSet, Set.disjoint_left, Sym2.forall]
561+
grind [mem_edgeSet]
562+
556563
@[simp] lemma edgeSet_eq_empty : G.edgeSet = ∅ ↔ G = ⊥ := by rw [← edgeSet_bot, edgeSet_inj]
557564

558565
@[simp] lemma edgeSet_nonempty : G.edgeSet.Nonempty ↔ G ≠ ⊥ := by
@@ -755,6 +762,17 @@ theorem mk'_mem_incidenceSet_right_iff : s(a, b) ∈ G.incidenceSet b ↔ G.Adj
755762
theorem edge_mem_incidenceSet_iff {e : G.edgeSet} : ↑e ∈ G.incidenceSet a ↔ a ∈ (e : Sym2 V) :=
756763
and_iff_right e.2
757764

765+
theorem iUnion_incidenceSet : ⋃ v, G.incidenceSet v = G.edgeSet := by
766+
ext ⟨_, _⟩
767+
simp [mk'_mem_incidenceSet_iff]
768+
769+
variable {G H} in
770+
theorem disjoint_incidenceSet :
771+
(∀ v, Disjoint (G.incidenceSet v) (H.incidenceSet v)) ↔ Disjoint G H := by
772+
simp_rw [← disjoint_edgeSet, ← iUnion_incidenceSet, Set.disjoint_iUnion_left,
773+
Set.disjoint_iUnion_right, Set.disjoint_left, Sym2.forall]
774+
grind [mk'_mem_incidenceSet_iff]
775+
758776
theorem incidenceSet_inter_incidenceSet_subset (h : a ≠ b) :
759777
G.incidenceSet a ∩ G.incidenceSet b ⊆ {s(a, b)} := fun _e he =>
760778
(Sym2.mem_and_mem_iff h).1 ⟨he.1.2, he.2.2
@@ -798,6 +816,11 @@ variable (v) in
798816
theorem neighborSet_ne_univ : G.neighborSet v ≠ .univ :=
799817
Set.ne_univ_iff_exists_notMem _ |>.mpr ⟨v, G.notMem_neighborSet_self⟩
800818

819+
variable {G H} in
820+
theorem disjoint_neighborSet :
821+
(∀ v, Disjoint (G.neighborSet v) (H.neighborSet v)) ↔ Disjoint G H := by
822+
simp_rw [← disjoint_edgeSet, Set.disjoint_left, mem_neighborSet, Sym2.forall, mem_edgeSet]
823+
801824
@[simp]
802825
theorem mem_incidenceSet (v w : V) : s(v, w) ∈ G.incidenceSet v ↔ G.Adj v w := by
803826
simp [incidenceSet]
@@ -890,6 +913,12 @@ instance decidableMemCommonNeighbors [DecidableRel G.Adj] (v w : V) :
890913
DecidablePred (· ∈ G.commonNeighbors v w) :=
891914
inferInstanceAs <| DecidablePred fun u => u ∈ G.neighborSet v ∧ u ∈ G.neighborSet w
892915

916+
variable {G H} in
917+
theorem disjoint_commonNeighbors :
918+
(∀ u v, Disjoint (G.commonNeighbors u v) (H.commonNeighbors u v)) ↔ Disjoint G H := by
919+
simp_rw [← disjoint_edgeSet, Set.disjoint_left, mem_commonNeighbors, Sym2.forall, mem_edgeSet]
920+
grind
921+
893922
theorem commonNeighbors_top_eq {v w : V} :
894923
(⊤ : SimpleGraph V).commonNeighbors v w = Set.univ \ {v, w} := by
895924
ext u

Mathlib/Combinatorics/SimpleGraph/Finite.lean

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ open Finset Function
4747

4848
namespace SimpleGraph
4949

50-
variable {V : Type*} (G : SimpleGraph V) {e : Sym2 V}
50+
variable {V : Type*} (G H : SimpleGraph V) {e : Sym2 V}
5151

5252
section EdgeFinset
5353

@@ -197,6 +197,10 @@ protected alias ⟨IsIsolated.of_neighborFinset_eq_empty, IsIsolated.neighborFin
197197

198198
attribute [simp] IsIsolated.neighborFinset_eq_empty
199199

200+
theorem disjoint_neighborFinset_of_disjoint [Fintype <| H.neighborSet v] (h : Disjoint G H) :
201+
Disjoint (G.neighborFinset v) (H.neighborFinset v) := by
202+
simp [← Finset.disjoint_coe, disjoint_neighborSet.mpr h v]
203+
200204
/-- `G.degree v` is the number of vertices adjacent to `v`. -/
201205
def degree : ℕ := #(G.neighborFinset v)
202206

@@ -289,6 +293,10 @@ theorem incidenceFinset_subset [DecidableEq V] [Fintype G.edgeSet] :
289293
G.incidenceFinset v ⊆ G.edgeFinset :=
290294
Set.toFinset_subset_toFinset.mpr (G.incidenceSet_subset v)
291295

296+
theorem disjoint_incidenceFinset_of_disjoint [DecidableEq V] [Fintype <| H.neighborSet v]
297+
(h : Disjoint G H) : Disjoint (G.incidenceFinset v) (H.incidenceFinset v) := by
298+
simp [← Finset.disjoint_coe, disjoint_incidenceSet.mpr h v]
299+
292300
/-- The degree of a vertex is at most the number of edges. -/
293301
theorem degree_le_card_edgeFinset [Fintype G.edgeSet] :
294302
G.degree v ≤ #G.edgeFinset := by

0 commit comments

Comments
 (0)