The areas / V30. Combinatorics
Mathlib.Combinatorics.Digraph.Basic
52 declarations. Mathlib docs · Source
Digraphs
This module defines directed graphs on a vertex type V,
which is the same notion as a relation V → V → Prop.
While this might be too simple of a notion to deserve the grandeur of a new definition,
the intention here is to develop relations using the language of graph theory.
Note that in this treatment, a digraph may have self loops.
The type Digraph V is structurally equivalent to Quiver.{0} V,
but a difference between these is that Quiver is a class —
its purpose is to attach a quiver structure to a particular type V.
In contrast, for Digraph V we are interested in working with the entire lattice
of digraphs on V.
Main definitions
-
Digraphis a structure for relations. UnlikeSimpleGraph, the relation does not need to be symmetric or irreflexive. -
CompleteAtomicBooleanAlgebrainstance: Under the subgraph relation,Digraphforms aCompleteAtomicBooleanAlgebra. In other words, this is the complete lattice of spanning subgraphs of the complete graph.
def Digraph.ctorIdx E1 #
{V : Type u_1} → Digraph V → ℕ
theorem Digraph.mk.injEq E0 #
∀ {V : Type u_1} (Adj Adj_1 : V → V → Prop), ({ Adj := Adj } = { Adj := Adj_1 }) = (Adj = Adj_1)
theorem Digraph.mk.inj E1 #
∀ {V : Type u_1} {Adj Adj_1 : V → V → Prop}, { Adj := Adj } = { Adj := Adj_1 } → Adj = Adj_1
structure Digraph E3 #
Type u_1 → Type u_1
A digraph is a relation Adj on a vertex type V.
The relation describes which pairs of vertices are adjacent.
In this treatment, a digraph may have self-loops.
theorem Digraph.ext E1 #
∀ {V : Type u_1} {x y : Digraph V}, x.Adj = y.Adj → x = y
theorem Digraph.ext_iff E0 #
∀ {V : Type u_1} {x y : Digraph V}, x = y ↔ x.Adj = y.Adj
ctor Digraph.mk E0 #
{V : Type u_1} → (V → V → Prop) → Digraph V
abbrev Digraph.Adj E1 #
{V : Type u_1} → Digraph V → V → V → Prop
The adjacency relation of a digraph.
def Digraph.mk' E1 #
{V : Type u_1} → (V → V → Bool) ↪ Digraph V
Constructor for digraphs using a Boolean function.
This is useful for creating a digraph with a decidable Adj relation,
and it's used in the construction of the Fintype (Digraph V) instance.
theorem Digraph.mk'_apply_Adj E0 #
∀ {V : Type u_1} (x : V → V → Bool) (v w : V), (Digraph.mk' x).Adj v w = (x v w = true)
instance instDecidableRelAdjCoeEmbeddingForallForallBoolDigraphMk' E0 #
{V : Type u_1} → (adj : V → V → Bool) → DecidableRel (Digraph.mk' adj).Adj
instance instFintypeDigraphOfDecidableEq E0 #
{V : Type u_1} → [DecidableEq V] → [Fintype V] → Fintype (Digraph V)
def Digraph.completeDigraph E1 #
(V : Type u_1) → Digraph V
The complete digraph on a type V (denoted by ⊤)
is the digraph whose vertices are all adjacent.
Note that every vertex is adjacent to itself in ⊤.
def Digraph.emptyDigraph E1 #
(V : Type u_1) → Digraph V
The empty digraph on a type V (denoted by ⊥)
is the digraph such that no pairs of vertices are adjacent.
Note that ⊥ is called the empty digraph because it has no edges.
def Digraph.completeBipartiteGraph E1 #
(V : Type u_1) → (W : Type u_2) → Digraph (V ⊕ W)
Two vertices are adjacent in the complete bipartite digraph on two vertex types if and only if they are not from the same side. Any bipartite digraph may be regarded as a subgraph of one of these.
theorem Digraph.completeBipartiteGraph_Adj E0 #
∀ (V : Type u_1) (W : Type u_2) (v w : V ⊕ W),
(Digraph.completeBipartiteGraph V W).Adj v w =
(v.isLeft = true ∧ w.isRight = true ∨ v.isRight = true ∧ w.isLeft = true)
theorem Digraph.adj_injective E1 #
∀ {V : Type u_2}, Function.Injective Digraph.Adj
theorem Digraph.adj_inj E0 #
∀ {V : Type u_2} {G H : Digraph V}, G.Adj = H.Adj ↔ G = H
def Digraph.IsSubgraph E1 #
{V : Type u_2} → Digraph V → Digraph V → Prop
The relation that one Digraph is a spanning subgraph of another.
Note that Digraph.IsSubgraph G H should be spelled G ≤ H.
instance Digraph.instLE E0 #
{V : Type u_2} → LE (Digraph V)
For digraphs G, H, G ≤ H iff ∀ a b, G.Adj a b → H.Adj a b.
theorem Digraph.isSubgraph_eq_le E0 #
∀ {V : Type u_2}, Digraph.IsSubgraph = fun x1 x2 ↦ x1 ≤ x2
instance Digraph.instMax E0 #
{V : Type u_2} → Max (Digraph V)
The supremum of two digraphs x ⊔ y has edges where either x or y have edges.
theorem Digraph.sup_adj E0 #
∀ {V : Type u_2} (x y : Digraph V) (v w : V), (x ⊔ y).Adj v w ↔ x.Adj v w ∨ y.Adj v w
instance Digraph.instMin E0 #
{V : Type u_2} → Min (Digraph V)
The infimum of two digraphs x ⊓ y has edges where both x and y have edges.
theorem Digraph.inf_adj E0 #
∀ {V : Type u_2} (x y : Digraph V) (v w : V), (x ⊓ y).Adj v w ↔ x.Adj v w ∧ y.Adj v w
instance Digraph.instCompl E0 #
{V : Type u_2} → Compl (Digraph V)
We define Gᶜ to be the Digraph V such that no two adjacent vertices in G
are adjacent in the complement, and every nonadjacent pair of vertices is adjacent.
theorem Digraph.compl_adj E0 #
∀ {V : Type u_2} (G : Digraph V) (v w : V), Gᶜ.Adj v w ↔ ¬G.Adj v w
instance Digraph.sdiff E0 #
{V : Type u_2} → SDiff (Digraph V)
The difference of two digraphs x \ y has the edges of x with the edges of y removed.
theorem Digraph.sdiff_adj E0 #
∀ {V : Type u_2} (x y : Digraph V) (v w : V), (x \ y).Adj v w ↔ x.Adj v w ∧ ¬y.Adj v w
instance Digraph.supSet E0 #
{V : Type u_2} → SupSet (Digraph V)
instance Digraph.infSet E0 #
{V : Type u_2} → InfSet (Digraph V)
theorem Digraph.sSup_adj E0 #
∀ {V : Type u_2} {a b : V} {s : Set (Digraph V)}, (sSup s).Adj a b ↔ ∃ G ∈ s, G.Adj a b
theorem Digraph.sInf_adj E0 #
∀ {V : Type u_2} {a b : V} {s : Set (Digraph V)}, (sInf s).Adj a b ↔ ∀ G ∈ s, G.Adj a b
theorem Digraph.iSup_adj E0 #
∀ {ι : Sort u_1} {V : Type u_2} {a b : V} {f : ι → Digraph V}, (⨆ i, f i).Adj a b ↔ ∃ i, (f i).Adj a b
theorem Digraph.iInf_adj E0 #
∀ {ι : Sort u_1} {V : Type u_2} {a b : V} {f : ι → Digraph V}, (⨅ i, f i).Adj a b ↔ ∀ (i : ι), (f i).Adj a b
instance Digraph.instPartialOrder E0 #
{V : Type u_2} → PartialOrder (Digraph V)
instance Digraph.distribLattice E0 #
{V : Type u_2} → DistribLattice (Digraph V)
instance Digraph.completeAtomicBooleanAlgebra E0 #
{V : Type u_2} → CompleteAtomicBooleanAlgebra (Digraph V)
theorem Digraph.top_adj E0 #
∀ {V : Type u_2} (v w : V), ⊤.Adj v w
theorem Digraph.bot_adj E0 #
∀ {V : Type u_2} (v w : V), ⊥.Adj v w ↔ False
theorem Digraph.completeDigraph_eq_top E0 #
∀ (V : Type u_3), Digraph.completeDigraph V = ⊤
theorem Digraph.emptyDigraph_eq_bot E0 #
∀ (V : Type u_3), Digraph.emptyDigraph V = ⊥
theorem Digraph.default_def E0 #
∀ (V : Type u_3), default = ⊥
instance Digraph.instInhabited E0 #
(V : Type u_3) → Inhabited (Digraph V)
instance Digraph.instUniqueOfIsEmpty E0 #
{V : Type u_2} → [IsEmpty V] → Unique (Digraph V)
instance Digraph.instNontrivialOfNonempty E0 #
∀ {V : Type u_2} [Nonempty V], Nontrivial (Digraph V)
instance Digraph.Bot.adjDecidable E0 #
(V : Type u_2) → DecidableRel ⊥.Adj
instance Digraph.Sup.adjDecidable E0 #
(V : Type u_2) → (G H : Digraph V) → [DecidableRel G.Adj] → [DecidableRel H.Adj] → DecidableRel (G ⊔ H).Adj
instance Digraph.Inf.adjDecidable E0 #
(V : Type u_2) → (G H : Digraph V) → [DecidableRel G.Adj] → [DecidableRel H.Adj] → DecidableRel (G ⊓ H).Adj
instance Digraph.SDiff.adjDecidable E0 #
(V : Type u_2) → (G H : Digraph V) → [DecidableRel G.Adj] → [DecidableRel H.Adj] → DecidableRel (G \ H).Adj
instance Digraph.Top.adjDecidable E0 #
(V : Type u_2) → DecidableRel ⊤.Adj
instance Digraph.Compl.adjDecidable E0 #
(V : Type u_2) → (G : Digraph V) → [DecidableRel G.Adj] → DecidableRel Gᶜ.Adj