@@ -13,6 +13,8 @@ public import Mathlib.Data.Sym.Sym2
1313public import Mathlib.Order.CompleteBooleanAlgebra
1414public 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
156158namespace 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]
161163protected 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
755762theorem 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+
758776theorem 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
798816theorem 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]
802825theorem 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+
893922theorem commonNeighbors_top_eq {v w : V} :
894923 (⊤ : SimpleGraph V).commonNeighbors v w = Set.univ \ {v, w} := by
895924 ext u
0 commit comments