Documentation

Mathlib.Combinatorics.Digraph.Basic

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 #

theorem Digraph.ext_iff {V : Type u_1} {x : Digraph V} {y : Digraph V} :
x = y x.Adj = y.Adj
theorem Digraph.ext {V : Type u_1} {x : Digraph V} {y : Digraph V} (Adj : x.Adj = y.Adj) :
x = y
structure Digraph (V : 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.

  • Adj : VVProp

    The adjacency relation of a digraph.

Instances For
    @[simp]
    theorem Digraph.mk'_apply_Adj {V : Type u_1} (x : VVBool) (v : V) (w : V) :
    (Digraph.mk' x).Adj v w = (x v w = true)
    def Digraph.mk' {V : Type u_1} :
    (VVBool) 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.

    Equations
    • Digraph.mk' = { toFun := fun (x : VVBool) => { Adj := fun (v w : V) => x v w = true }, inj' := }
    Instances For
      Equations

      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 .

      Equations
      Instances For

        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.

        Equations
        Instances For
          @[simp]
          theorem Digraph.completeBipartiteGraph_Adj (V : Type u_1) (W : Type u_2) (v : V W) (w : V W) :
          (Digraph.completeBipartiteGraph V W).Adj v w = (v.isLeft = true w.isRight = true v.isRight = true w.isLeft = true)
          def Digraph.completeBipartiteGraph (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.

          Equations
          Instances For
            theorem Digraph.adj_injective {V : Type u_2} :
            Function.Injective Digraph.Adj
            @[simp]
            theorem Digraph.adj_inj {V : Type u_2} {G : Digraph V} {H : Digraph V} :
            G.Adj = H.Adj G = H
            def Digraph.IsSubgraph {V : Type u_2} (x : Digraph V) (y : Digraph V) :

            The relation that one Digraph is a spanning subgraph of another. Note that Digraph.IsSubgraph G H should be spelled G ≤ H.

            Equations
            • x.IsSubgraph y = ∀ ⦃v w : V⦄, x.Adj v wy.Adj v w
            Instances For
              instance Digraph.instLE {V : Type u_2} :
              Equations
              • Digraph.instLE = { le := Digraph.IsSubgraph }
              @[simp]
              theorem Digraph.isSubgraph_eq_le {V : Type u_2} :
              Digraph.IsSubgraph = fun (x1 x2 : Digraph V) => x1 x2
              instance Digraph.instSup {V : Type u_2} :

              The supremum of two digraphs x ⊔ y has edges where either x or y have edges.

              Equations
              • Digraph.instSup = { sup := fun (x y : Digraph V) => { Adj := x.Adj y.Adj } }
              @[simp]
              theorem Digraph.sup_adj {V : Type u_2} (x : Digraph V) (y : Digraph V) (v : V) (w : V) :
              (x y).Adj v w x.Adj v w y.Adj v w
              instance Digraph.instInf {V : Type u_2} :

              The infimum of two digraphs x ⊓ y has edges where both x and y have edges.

              Equations
              • Digraph.instInf = { inf := fun (x y : Digraph V) => { Adj := x.Adj y.Adj } }
              @[simp]
              theorem Digraph.inf_adj {V : Type u_2} (x : Digraph V) (y : Digraph V) (v : V) (w : V) :
              (x y).Adj v w x.Adj v w y.Adj v w
              instance Digraph.hasCompl {V : Type u_2} :

              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.

              Equations
              • Digraph.hasCompl = { compl := fun (G : Digraph V) => { Adj := fun (v w : V) => ¬G.Adj v w } }
              @[simp]
              theorem Digraph.compl_adj {V : Type u_2} (G : Digraph V) (v : V) (w : V) :
              G.Adj v w ¬G.Adj v w
              instance Digraph.sdiff {V : Type u_2} :

              The difference of two digraphs x \ y has the edges of x with the edges of y removed.

              Equations
              • Digraph.sdiff = { sdiff := fun (x y : Digraph V) => { Adj := x.Adj \ y.Adj } }
              @[simp]
              theorem Digraph.sdiff_adj {V : Type u_2} (x : Digraph V) (y : Digraph V) (v : V) (w : V) :
              (x \ y).Adj v w x.Adj v w ¬y.Adj v w
              instance Digraph.supSet {V : Type u_2} :
              Equations
              • Digraph.supSet = { sSup := fun (s : Set (Digraph V)) => { Adj := fun (a b : V) => Gs, G.Adj a b } }
              instance Digraph.infSet {V : Type u_2} :
              Equations
              • Digraph.infSet = { sInf := fun (s : Set (Digraph V)) => { Adj := fun (a b : V) => ∀ ⦃G : Digraph V⦄, G sG.Adj a b } }
              @[simp]
              theorem Digraph.sSup_adj {V : Type u_2} {a : V} {b : V} {s : Set (Digraph V)} :
              (sSup s).Adj a b Gs, G.Adj a b
              @[simp]
              theorem Digraph.sInf_adj {V : Type u_2} {a : V} {b : V} {s : Set (Digraph V)} :
              (sInf s).Adj a b Gs, G.Adj a b
              @[simp]
              theorem Digraph.iSup_adj {ι : Sort u_1} {V : Type u_2} {a : V} {b : V} {f : ιDigraph V} :
              (⨆ (i : ι), f i).Adj a b ∃ (i : ι), (f i).Adj a b
              @[simp]
              theorem Digraph.iInf_adj {ι : Sort u_1} {V : Type u_2} {a : V} {b : V} {f : ιDigraph V} :
              (⨅ (i : ι), f i).Adj a b ∀ (i : ι), (f i).Adj a b

              For digraphs G, H, G ≤ H iff ∀ a b, G.Adj a b → H.Adj a b.

              Equations
              Equations
              @[simp]
              theorem Digraph.top_adj {V : Type u_2} (v : V) (w : V) :
              .Adj v w
              @[simp]
              theorem Digraph.bot_adj {V : Type u_2} (v : V) (w : V) :
              .Adj v w False
              @[simp]
              theorem Digraph.instInhabited_default (V : Type u_5) :
              default =
              Equations
              Equations
              • Digraph.instUniqueOfIsEmpty = { default := , uniq := }
              Equations
              • =
              instance Digraph.Sup.adjDecidable (V : Type u_2) (G : Digraph V) (H : Digraph V) [DecidableRel G.Adj] [DecidableRel H.Adj] :
              DecidableRel (G H).Adj
              Equations
              instance Digraph.Inf.adjDecidable (V : Type u_2) (G : Digraph V) (H : Digraph V) [DecidableRel G.Adj] [DecidableRel H.Adj] :
              DecidableRel (G H).Adj
              Equations
              instance Digraph.SDiff.adjDecidable (V : Type u_2) (G : Digraph V) (H : Digraph V) [DecidableRel G.Adj] [DecidableRel H.Adj] :
              DecidableRel (G \ H).Adj
              Equations
              instance Digraph.Compl.adjDecidable (V : Type u_2) (G : Digraph V) [DecidableRel G.Adj] :
              Equations