Documentation

Mathlib.Combinatorics.Hypergraph.Basic

Undirected hypergraphs #

An undirected hypergraph (here abbreviated as hypergraph) H is a generalization of a graph (see Mathlib.Combinatorics.Graph or Mathlib.Combinatorics.SimpleGraph) and consists of a set of vertices, usually denoted V or V(H), and a set of hyperedges, here called edges and denoted E or E(H). In contrast with a graph, where edges are unordered pairs of vertices, in hypergraphs, edges are unordered sets of vertices; i.e., they are subsets of the vertex set V.

A hypergraph where V = ∅ and E = ∅ is empty, denoted . A hypergraph with a nonempty vertex set (V ≠ ∅) and empty edge set is trivial. A hypergraph where the edge set is the power set of the vertex set (or, equivalently, where all possible subsets of the vertex sets are in the edge set) is complete.

If a edge e contains only one vertex (i.e., |e| = 1), then it is a loop.

This module defines Hypergraph α for a vertex type α (edges are defined as Set (Set α)).

Main definitions #

For H : Hypergraph α:

Implementation details #

This implementation is heavily inspired by Peter Nelson and Jun Kwon's Graph implementation, which was in turn inspired by Matroid.

Paraphrasing Mathlib.Combinatorics.Graph.Basic: "The main tradeoff is that parts of the API will need to care about whether a term x : α or e : Set α is a 'real' vertex or edge of the graph, rather than something outside the vertex or edge set. This is an issue, but is likely amenable to automation."

Because edgeSet is a Set (Set α), rather than a multiset, here we are assuming that all hypergraphs are without repeated edge.

structure Hypergraph (α : Type u_4) :
Type u_4

An undirected hypergraph with vertices of type α and edges of type Set α, as described by vertex and edge sets vertexSet : Set α and edgeSet : Set (Set α).

The requirement subset_vertexSet_of_mem_edgeSet ensures that all vertices in edges are part of vertexSet, i.e., all edges are subsets of the vertexSet.

  • vertexSet : Set α

    The vertex set

  • edgeSet : Set (Set α)

    The edge set

  • subset_vertexSet_of_mem_edgeSet' e : Set α : e self.edgeSete self.vertexSet

    All edges must be subsets of the vertex set

Instances For
    theorem Hypergraph.ext {α : Type u_4} {x y : Hypergraph α} (vertexSet : x.vertexSet = y.vertexSet) (edgeSet : x.edgeSet = y.edgeSet) :
    x = y
    theorem Hypergraph.ext_iff {α : Type u_4} {x y : Hypergraph α} :

    Notation #

    V(H) denotes the vertexSet of a hypergraph H

    Equations
    • One or more equations did not get rendered due to their size.
    Instances For

      E(H) denotes the edgeSet of a hypergraph H

      Equations
      • One or more equations did not get rendered due to their size.
      Instances For

        Vertex-Hyperedge Incidence #

        @[simp]
        theorem Hypergraph.subset_vertexSet_of_mem_edgeSet {α : Type u_1} {e : Set α} {H : Hypergraph α} (he : e H.edgeSet) :
        theorem Hypergraph.mem_vertexSet_of_mem_edgeSet {α : Type u_1} {x : α} {e : Set α} {H : Hypergraph α} (he : e H.edgeSet) (hx : x e) :
        theorem Hypergraph.edgeSet.ext_iff {α : Type u_1} {e e' : Set α} {H : Hypergraph α} (he : e H.edgeSet) (he' : e' H.edgeSet) :
        e = e' xH.vertexSet, x e x e'

        Vertex and Hyperedge Adjacency #

        def Hypergraph.Adj {α : Type u_1} (H : Hypergraph α) (x y : α) :

        Predicate for adjacency. Two vertices x and y are adjacent if there is some edge e ∈ E(H) where x and y are both incident to e.

        Note that we do not need to explicitly check that x, y ∈ V(H) here because a vertex that is not in the vertex set cannot be incident to any edge.

        Equations
        Instances For
          theorem Hypergraph.Adj.symm {α : Type u_1} {x y : α} {H : Hypergraph α} (h : H.Adj x y) :
          H.Adj y x
          theorem Hypergraph.adj_comm {α : Type u_1} {H : Hypergraph α} (x y : α) :
          H.Adj x y H.Adj y x
          def Hypergraph.EAdj {α : Type u_1} (H : Hypergraph α) (e f : Set α) :

          Predicate for edge adjacency. Analogous to Hypergraph.Adj, edges e and f are adjacent if there is some vertex x ∈ V(H) where x is incident to both e and f.

          Equations
          Instances For
            theorem Hypergraph.EAdj.exists_vertex {α : Type u_1} {e f : Set α} {H : Hypergraph α} (h : H.EAdj e f) :
            xH.vertexSet, x e x f
            theorem Hypergraph.EAdj.symm {α : Type u_1} {e f : Set α} {H : Hypergraph α} (h : H.EAdj e f) :
            H.EAdj f e
            theorem Hypergraph.EAdj.inter_nonempty {α : Type u_1} {e f : Set α} {H : Hypergraph α} (hef : H.EAdj e f) :
            theorem Hypergraph.eAdj_comm {α : Type u_1} {H : Hypergraph α} (e f : Set α) :
            H.EAdj e f H.EAdj f e

            Basic Hypergraph Definitions & Predicates #

            def Hypergraph.image {α : Type u_1} {β : Type u_2} (H : Hypergraph α) (f : αβ) :

            The image of a hypergraph H : Hypergraph α under a function f : α → β is the hypergraph Hᶠ : Hypergraph β where the vertex set of Hᶠ is the image of V(H) under f and the edge set of Hᶠ is the set of images of the edges (subsets of vertices) in E(H).

            Equations
            Instances For
              @[simp]
              theorem Hypergraph.image_vertexSet {α : Type u_1} {β : Type u_2} (H : Hypergraph α) (f : αβ) :
              @[simp]
              theorem Hypergraph.image_edgeSet {α : Type u_1} {β : Type u_2} (H : Hypergraph α) (f : αβ) :
              theorem Hypergraph.mem_edgeSet_image {α : Type u_1} {β : Type u_2} {H : Hypergraph α} {f : αβ} {e : Set β} :
              e (H.image f).edgeSet e'H.edgeSet, f '' e' = e
              theorem Hypergraph.image_mem_edgeSet_image {α : Type u_1} {β : Type u_2} {e : Set α} {H : Hypergraph α} {f : αβ} (he : e H.edgeSet) :
              f '' e (H.image f).edgeSet
              theorem Hypergraph.image_image {α : Type u_1} {β : Type u_2} {γ : Type u_3} {f : αβ} {g : βγ} (H : Hypergraph α) :
              (H.image f).image g = H.image (g f)
              def Hypergraph.IsIsolated {α : Type u_1} (H : Hypergraph α) (x : α) :

              A vertex is isolated if it is not incident to any edges (including loops).

              Equations
              Instances For
                def Hypergraph.IsLoop {α : Type u_1} (H : Hypergraph α) (e : Set α) :

                A loop is an edge whose associated vertex subset consists of a single vertex.

                Equations
                Instances For
                  theorem Hypergraph.isLoop_iff_mem_edgeSet_and_singleton {α : Type u_1} {e : Set α} {H : Hypergraph α} :
                  H.IsLoop e e H.edgeSet ∃ (x : α), e = {x}
                  theorem Hypergraph.isLoop_iff_mem_and_ncard_one {α : Type u_1} {e : Set α} {H : Hypergraph α} :
                  theorem Hypergraph.IsLoop.ncard_one {α : Type u_1} {e : Set α} {H : Hypergraph α} (h : H.IsLoop e) :
                  e.ncard = 1
                  def Hypergraph.IsNonempty {α : Type u_1} (H : Hypergraph α) :

                  A hypergraph is nonempty if it has at least one vertex or at least one edge.

                  Equations
                  Instances For
                    @[implicit_reducible]
                    instance Hypergraph.instBot (α : Type u_4) :

                    The empty hypergraph (bottom) on a type.

                    Equations
                    @[simp]
                    @[simp]
                    theorem Hypergraph.ne_bot_iff {α : Type u_1} {H : Hypergraph α} :
                    theorem Hypergraph.IsNonempty.ne_bot {α : Type u_1} {H : Hypergraph α} :

                    Alias of the reverse direction of Hypergraph.ne_bot_iff.

                    @[simp]
                    def Hypergraph.IsTrivial {α : Type u_1} (H : Hypergraph α) :

                    A hypergraph is trivial if it has at least one vertex but no edges.

                    Equations
                    Instances For
                      def Hypergraph.trivialOn {α : Type u_1} (f : Set α) :

                      The trivial hypergraph with a given vertex set is defined by having no edges on that vertex set.

                      Equations
                      Instances For
                        @[simp]
                        theorem Hypergraph.trivialOn_edgeSet {α : Type u_1} (f : Set α) :
                        @[simp]
                        theorem Hypergraph.trivialOn_vertexSet {α : Type u_1} (f : Set α) :
                        theorem Hypergraph.IsTrivial.not_mem_edgeSet {α : Type u_1} {e : Set α} {H : Hypergraph α} (h : H.IsTrivial) :
                        eH.edgeSet
                        def Hypergraph.IsComplete {α : Type u_1} (H : Hypergraph α) :

                        A hypergraph is complete if every subset of the vertex set is in the edge set.

                        Equations
                        Instances For
                          def Hypergraph.completeOn {α : Type u_1} (f : Set α) :

                          The complete hypergraph with a given vertex set, which has each subset of the vertex set as an edge.

                          Equations
                          Instances For
                            @[simp]
                            theorem Hypergraph.completeOn_vertexSet {α : Type u_1} (f : Set α) :
                            @[simp]
                            theorem Hypergraph.completeOn_edgeSet {α : Type u_1} (f : Set α) :
                            theorem Hypergraph.mem_completeOn {α : Type u_1} {e f : Set α} :
                            theorem Hypergraph.IsComplete.mem_iff {α : Type u_1} {e : Set α} {H : Hypergraph α} (h : H.IsComplete) :