|
| 1 | +/- |
| 2 | +Copyright (c) 2024 Rida Hamadani. All rights reserved. |
| 3 | +Released under Apache 2.0 license as described in the file LICENSE. |
| 4 | +Authors: Rida Hamadani |
| 5 | +-/ |
| 6 | +import Mathlib.Combinatorics.Digraph.Basic |
| 7 | +import Mathlib.Combinatorics.SimpleGraph.Basic |
| 8 | + |
| 9 | +/-! |
| 10 | +
|
| 11 | +# Graph Orientation |
| 12 | +
|
| 13 | +This module introduces conversion operations between `Digraph`s and `SimpleGraph`s, by forgetting |
| 14 | +the edge orientations of `Digraph`. |
| 15 | +
|
| 16 | +## Main Definitions |
| 17 | +
|
| 18 | +- `Digraph.toSimpleGraphInclusive`: Converts a `Digraph` to a `SimpleGraph` by creating an |
| 19 | + undirected edge if either orientation exists in the digraph. |
| 20 | +- `Digraph.toSimpleGraphStrict`: Converts a `Digraph` to a `SimpleGraph` by creating an undirected |
| 21 | + edge only if both orientations exist in the digraph. |
| 22 | +
|
| 23 | +## TODO |
| 24 | +
|
| 25 | +- Show that there is an isomorphism between loopless complete digraphs and oriented graphs. |
| 26 | +- Define more ways to orient a `SimpleGraph`. |
| 27 | +- Provide lemmas on how `toSimpleGraphInclusive` and `toSimpleGraphStrict` relate to other lattice |
| 28 | + structures on `SimpleGraph`s and `Digraph`s. |
| 29 | +
|
| 30 | +## Tags |
| 31 | +
|
| 32 | +digraph, simple graph, oriented graphs |
| 33 | +-/ |
| 34 | + |
| 35 | +variable {V : Type*} |
| 36 | + |
| 37 | +namespace Digraph |
| 38 | + |
| 39 | +section toSimpleGraph |
| 40 | + |
| 41 | +/-! ### Orientation-forgetting maps on digraphs -/ |
| 42 | + |
| 43 | +/-- |
| 44 | +Orientation-forgetting map from `Digraph` to `SimpleGraph` that gives an unoriented edge if |
| 45 | +either orientation is present. |
| 46 | +-/ |
| 47 | +def toSimpleGraphInclusive (G : Digraph V) : SimpleGraph V := SimpleGraph.fromRel G.Adj |
| 48 | + |
| 49 | +/-- |
| 50 | +Orientation-forgetting map from `Digraph` to `SimpleGraph` that gives an unoriented edge if |
| 51 | +both orientations are present. |
| 52 | +-/ |
| 53 | +def toSimpleGraphStrict (G : Digraph V) : SimpleGraph V where |
| 54 | + Adj v w := v ≠ w ∧ G.Adj v w ∧ G.Adj w v |
| 55 | + symm _ _ h := And.intro h.1.symm h.2.symm |
| 56 | + loopless _ h := h.1 rfl |
| 57 | + |
| 58 | +lemma toSimpleGraphStrict_subgraph_toSimpleGraphInclusive (G : Digraph V) : |
| 59 | + G.toSimpleGraphStrict ≤ G.toSimpleGraphInclusive := |
| 60 | + fun _ _ h ↦ ⟨h.1, Or.inl h.2.1⟩ |
| 61 | + |
| 62 | +@[mono] |
| 63 | +lemma toSimpleGraphInclusive_mono : Monotone (toSimpleGraphInclusive : _ → SimpleGraph V) := by |
| 64 | + intro _ _ h₁ _ _ h₂ |
| 65 | + apply And.intro h₂.1 |
| 66 | + cases h₂.2 |
| 67 | + · exact Or.inl <| h₁ ‹_› |
| 68 | + · exact Or.inr <| h₁ ‹_› |
| 69 | + |
| 70 | +@[mono] |
| 71 | +lemma toSimpleGraphStrict_mono : Monotone (toSimpleGraphStrict : _ → SimpleGraph V) := |
| 72 | + fun _ _ h₁ _ _ h₂ ↦ And.intro h₂.1 <| And.intro (h₁ h₂.2.1) (h₁ h₂.2.2) |
| 73 | + |
| 74 | +@[simp] |
| 75 | +lemma toSimpleGraphInclusive_top : (⊤ : Digraph V).toSimpleGraphInclusive = ⊤ := by |
| 76 | + ext; exact ⟨And.left, fun h ↦ ⟨h.ne, Or.inl trivial⟩⟩ |
| 77 | + |
| 78 | +@[simp] |
| 79 | +lemma toSimpleGraphStrict_top : (⊤ : Digraph V).toSimpleGraphStrict = ⊤ := by |
| 80 | + ext; exact ⟨And.left, fun h ↦ ⟨h.ne, trivial, trivial⟩⟩ |
| 81 | + |
| 82 | +@[simp] |
| 83 | +lemma toSimpleGraphInclusive_bot : (⊥ : Digraph V).toSimpleGraphInclusive = ⊥ := by |
| 84 | + ext; exact ⟨fun ⟨_, h⟩ ↦ by tauto, False.elim⟩ |
| 85 | + |
| 86 | +@[simp] |
| 87 | +lemma toSimpleGraphStrict_bot : (⊥ : Digraph V).toSimpleGraphStrict = ⊥ := by |
| 88 | + ext; exact ⟨fun ⟨_, h⟩ ↦ by tauto, False.elim⟩ |
| 89 | + |
| 90 | +end toSimpleGraph |
| 91 | + |
| 92 | +end Digraph |
0 commit comments