|
| 1 | +/- |
| 2 | +Copyright (c) 2026 Jun Kwon. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Peter Nelson, Jun Kwon |
| 5 | +-/ |
| 6 | +module |
| 7 | + |
| 8 | +public import Mathlib.Combinatorics.Graph.Subgraph |
| 9 | + |
| 10 | +/-! |
| 11 | +# Intersection and union of graphs |
| 12 | +
|
| 13 | +This file defines the lattice-like structures on graphs. |
| 14 | +
|
| 15 | +## Main results |
| 16 | +
|
| 17 | +- `SemilatticeInf (Graph α β)` |
| 18 | +
|
| 19 | +## Implementation notes |
| 20 | +
|
| 21 | +Intersections are defined here as the maximal mutual subgraph of the given graphs. |
| 22 | +This has the effect of, when taking the intersection of non-compatible graphs, |
| 23 | +**any non-compatible edges are removed**. |
| 24 | +
|
| 25 | +## TODO |
| 26 | +
|
| 27 | ++ Add `ConditionallyCompleteCompleteLatticeInf (Graph α β)` after splitting |
| 28 | + `ConditionallyCompleteCompleteLattice`. |
| 29 | +
|
| 30 | +-/ |
| 31 | + |
| 32 | +public section |
| 33 | + |
| 34 | +open Function Set |
| 35 | + |
| 36 | +variable {α β : Type*} {x y : α} {e : β} {G H : Graph α β} |
| 37 | + |
| 38 | +namespace Graph |
| 39 | + |
| 40 | +/-- The infimum of two graphs `G` and `H`. The edges are precisely those on which `G` and `H` agree, |
| 41 | +and the edge set is a subset of `E(G) ∩ E(H)`, with equality if `G` and `H` are compatible. -/ |
| 42 | +instance : SemilatticeInf (Graph α β) where |
| 43 | + inf G H := { |
| 44 | + vertexSet := V(G) ∩ V(H) |
| 45 | + edgeSet := {e ∈ E(G) ∩ E(H) | ∀ x y, G.IsLink e x y ↔ H.IsLink e x y} |
| 46 | + IsLink e x y := G.IsLink e x y ∧ H.IsLink e x y |
| 47 | + isLink_symm _ _ _ _ h := ⟨h.1.symm, h.2.symm⟩ |
| 48 | + eq_or_eq_of_isLink_of_isLink _ _ _ _ _ h h' := h.1.left_eq_or_eq h'.1 |
| 49 | + edge_mem_iff_exists_isLink e := by |
| 50 | + simp only [edgeSet_eq_setOf_exists_isLink, mem_inter_iff, mem_setOf_eq] |
| 51 | + exact ⟨fun ⟨⟨⟨x, y, hexy⟩, ⟨z, w, hezw⟩⟩, h⟩ ↦ ⟨x, y, hexy, by rwa [← h]⟩, |
| 52 | + fun ⟨x, y, hfG, hfH⟩ ↦ ⟨⟨⟨_, _, hfG⟩, ⟨_, _, hfH⟩⟩, |
| 53 | + fun z w ↦ by rw [hfG.isLink_iff_sym2_eq, hfH.isLink_iff_sym2_eq]⟩⟩ |
| 54 | + left_mem_of_isLink e x y h := ⟨h.1.left_mem, h.2.left_mem⟩} |
| 55 | + inf_le_left G H := { |
| 56 | + vertexSet_mono := inter_subset_left |
| 57 | + isLink_mono := by simp +contextual} |
| 58 | + inf_le_right G H := { |
| 59 | + vertexSet_mono := inter_subset_right |
| 60 | + isLink_mono := by simp +contextual} |
| 61 | + le_inf H G₁ G₂ h₁ h₂ := { |
| 62 | + vertexSet_mono := subset_inter h₁.vertexSet_mono h₂.vertexSet_mono |
| 63 | + isLink_mono e x y h := by simp [h₁.isLink_mono h, h₂.isLink_mono h]} |
| 64 | + |
| 65 | +@[simp] lemma vertexSet_inf (G H : Graph α β) : V(G ⊓ H) = V(G) ∩ V(H) := rfl |
| 66 | + |
| 67 | +lemma edgeSet_inf (G H : Graph α β) : |
| 68 | + E(G ⊓ H) = {e ∈ E(G) ∩ E(H) | ∀ x y, G.IsLink e x y ↔ H.IsLink e x y} := rfl |
| 69 | + |
| 70 | +@[simp] lemma inf_isLink : (G ⊓ H).IsLink e x y ↔ G.IsLink e x y ∧ H.IsLink e x y := Iff.rfl |
| 71 | + |
| 72 | +@[simp] |
| 73 | +lemma inf_inc_iff : (G ⊓ H).Inc e x ↔ ∃ y, G.IsLink e x y ∧ H.IsLink e x y := by |
| 74 | + simp [Inc] |
| 75 | + |
| 76 | +@[simp] |
| 77 | +lemma inf_isLoopAt_iff : (G ⊓ H).IsLoopAt e x ↔ G.IsLoopAt e x ∧ H.IsLoopAt e x := by |
| 78 | + simp [← isLink_self_iff] |
| 79 | + |
| 80 | +@[simp] |
| 81 | +lemma inf_isNonloopAt_iff : (G ⊓ H).IsNonloopAt e x ↔ ∃ y ≠ x, G.IsLink e x y ∧ H.IsLink e x y := by |
| 82 | + simp [IsNonloopAt] |
| 83 | + |
| 84 | +@[simp] |
| 85 | +protected lemma disjoint_iff : Disjoint G H ↔ Disjoint V(G) V(H) := by |
| 86 | + rw [disjoint_iff, ← vertexSet_eq_empty_iff, vertexSet_inf, disjoint_iff_inter_eq_empty] |
| 87 | + |
| 88 | +protected lemma Compatible.edgeSet_inf (h : G.Compatible H) : E(G ⊓ H) = E(G) ∩ E(H) := by |
| 89 | + rw [G.edgeSet_inf] |
| 90 | + exact le_antisymm (fun e he ↦ he.1) fun e he ↦ ⟨he, fun _ _ ↦ h.isLink_congr he.1 he.2⟩ |
| 91 | + |
| 92 | +end Graph |
0 commit comments