The areas / V30. Combinatorics
Mathlib.Combinatorics.Hypergraph.Basic
69 declarations and 1 deprecated aliases. Mathlib docs · Source
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
Hypergraph αis the type of undirected hypergraphs with vertices of typeαand edges of typeSet α. In addition to vertices and hyperedges, aHypergraphmust have the property that all edges are subsets of the vertex set.
For H : Hypergraph α:
H.vertexSet(abbrev.V(H)) denotes the vertex set ofHas a term inSet α.H.edgeSet(abbrev.E(H)) denotes the edge set ofHas a term inSet (Set α). Hyperedges must be subsets ofV(H).H.Adj x ymeans that there exists some edge containing bothxandy(or, in other words,xandyare incident to some shared edgee).H.EAdj e fmeans that there exists some vertex that is incident to the edgeseandf : Set α.
Implementation notes
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.
Notation
Vertex-Hyperedge Incidence
Vertex and Hyperedge Adjacency
Basic Hypergraph Definitions & Predicates
def Hypergraph.ctorIdx E1 #
{α : Type u_4} → Hypergraph α → ℕ
theorem Hypergraph.mk.inj E1 #
∀ {α : Type u_4} {vertexSet : Set α} {edgeSet : Set (Set α)}
{subset_vertexSet_of_mem_edgeSet' : ∀ ⦃e : Set α⦄, e ∈ edgeSet → e ⊆ vertexSet} {vertexSet_1 : Set α}
{edgeSet_1 : Set (Set α)} {subset_vertexSet_of_mem_edgeSet'_1 : ∀ ⦃e : Set α⦄, e ∈ edgeSet_1 → e ⊆ vertexSet_1},
{ vertexSet := vertexSet, edgeSet := edgeSet, subset_vertexSet_of_mem_edgeSet' := subset_vertexSet_of_mem_edgeSet' } =
{ vertexSet := vertexSet_1, edgeSet := edgeSet_1,
subset_vertexSet_of_mem_edgeSet' := subset_vertexSet_of_mem_edgeSet'_1 } →
vertexSet = vertexSet_1 ∧ edgeSet = edgeSet_1
theorem Hypergraph.mk.congr_simp E1 #
∀ {α : Type u_4} (vertexSet vertexSet_1 : Set α) (e_vertexSet : vertexSet = vertexSet_1)
(edgeSet edgeSet_1 : Set (Set α)) (e_edgeSet : edgeSet = edgeSet_1)
(subset_vertexSet_of_mem_edgeSet' : ∀ ⦃e : Set α⦄, e ∈ edgeSet → e ⊆ vertexSet),
{ vertexSet := vertexSet, edgeSet := edgeSet, subset_vertexSet_of_mem_edgeSet' := subset_vertexSet_of_mem_edgeSet' } =
{ vertexSet := vertexSet_1, edgeSet := edgeSet_1, subset_vertexSet_of_mem_edgeSet' := ⋯ }
theorem Hypergraph.mk.injEq E0 #
∀ {α : Type u_4} (vertexSet : Set α) (edgeSet : Set (Set α))
(subset_vertexSet_of_mem_edgeSet' : ∀ ⦃e : Set α⦄, e ∈ edgeSet → e ⊆ vertexSet) (vertexSet_1 : Set α)
(edgeSet_1 : Set (Set α)) (subset_vertexSet_of_mem_edgeSet'_1 : ∀ ⦃e : Set α⦄, e ∈ edgeSet_1 → e ⊆ vertexSet_1),
({ vertexSet := vertexSet, edgeSet := edgeSet,
subset_vertexSet_of_mem_edgeSet' := subset_vertexSet_of_mem_edgeSet' } =
{ vertexSet := vertexSet_1, edgeSet := edgeSet_1,
subset_vertexSet_of_mem_edgeSet' := subset_vertexSet_of_mem_edgeSet'_1 }) =
(vertexSet = vertexSet_1 ∧ edgeSet = edgeSet_1)
structure Hypergraph E3 #
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.
theorem Hypergraph.ext E1 #
∀ {α : Type u_4} {x y : Hypergraph α}, x.vertexSet = y.vertexSet → x.edgeSet = y.edgeSet → x = y
theorem Hypergraph.ext_iff E0 #
∀ {α : Type u_4} {x y : Hypergraph α}, x = y ↔ x.vertexSet = y.vertexSet ∧ x.edgeSet = y.edgeSet
ctor Hypergraph.mk E0 #
{α : Type u_4} →
(vertexSet : Set α) → (edgeSet : Set (Set α)) → (∀ ⦃e : Set α⦄, e ∈ edgeSet → e ⊆ vertexSet) → Hypergraph α
abbrev Hypergraph.vertexSet E1 #
{α : Type u_4} → Hypergraph α → Set α
The vertex set
abbrev Hypergraph.edgeSet E1 #
{α : Type u_4} → Hypergraph α → Set (Set α)
The edge set
theorem Hypergraph.subset_vertexSet_of_mem_edgeSet' E1 #
∀ {α : Type u_4} (self : Hypergraph α) ⦃e : Set α⦄, e ∈ self.edgeSet → e ⊆ self.vertexSet
All edges must be subsets of the vertex set
def Hypergraph.«termV(_)» E1 #
Lean.ParserDescr
V(H) denotes the vertexSet of a hypergraph H
def Hypergraph.«termE(_)» E1 #
Lean.ParserDescr
E(H) denotes the edgeSet of a hypergraph H
theorem Hypergraph.subset_vertexSet_of_mem_edgeSet E0 #
∀ {α : Type u_1} {e : Set α} {H : Hypergraph α}, e ∈ H.edgeSet → e ⊆ H.vertexSet
theorem Membership.mem.subset_vertexSet E1 #
∀ {α : Type u_1} {e : Set α} {H : Hypergraph α}, e ∈ H.edgeSet → e ⊆ H.vertexSet
Alias of Hypergraph.subset_vertexSet_of_mem_edgeSet.
theorem Hypergraph.edgeSet_subset_powerset_vertexSet E1 #
∀ {α : Type u_1} {H : Hypergraph α}, H.edgeSet ⊆ 𝒫 H.vertexSet
theorem Hypergraph.mem_vertexSet_of_mem_edgeSet E0 #
∀ {α : Type u_1} {x : α} {e : Set α} {H : Hypergraph α}, e ∈ H.edgeSet → x ∈ e → x ∈ H.vertexSet
theorem Hypergraph.edgeSet.ext_iff E0 #
∀ {α : Type u_1} {e e' : Set α} {H : Hypergraph α},
e ∈ H.edgeSet → e' ∈ H.edgeSet → (e = e' ↔ ∀ x ∈ H.vertexSet, x ∈ e ↔ x ∈ e')
theorem Hypergraph.sUnion_edgeSet_subset_vertexSet E1 #
∀ {α : Type u_1} {H : Hypergraph α}, ⋃₀ H.edgeSet ⊆ H.vertexSet
def Hypergraph.Adj E1 #
{α : Type u_1} → Hypergraph α → α → α → Prop
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.
theorem Hypergraph.Adj.symm E1 #
∀ {α : Type u_1} {x y : α} {H : Hypergraph α}, H.Adj x y → H.Adj y x
theorem Hypergraph.adj_comm E1 #
∀ {α : Type u_1} {H : Hypergraph α} (x y : α), H.Adj x y ↔ H.Adj y x
def Hypergraph.EAdj E1 #
{α : Type u_1} → Hypergraph α → Set α → Set α → Prop
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.
theorem Hypergraph.EAdj.exists_vertex E1 #
∀ {α : Type u_1} {e f : Set α} {H : Hypergraph α}, H.EAdj e f → ∃ x ∈ H.vertexSet, x ∈ e ∧ x ∈ f
theorem Hypergraph.EAdj.symm E1 #
∀ {α : Type u_1} {e f : Set α} {H : Hypergraph α}, H.EAdj e f → H.EAdj f e
theorem Hypergraph.EAdj.inter_nonempty E1 #
∀ {α : Type u_1} {e f : Set α} {H : Hypergraph α}, H.EAdj e f → (e ∩ f).Nonempty
theorem Hypergraph.eAdj_comm E1 #
∀ {α : Type u_1} {H : Hypergraph α} (e f : Set α), H.EAdj e f ↔ H.EAdj f e
def Hypergraph.image E1 #
{α : Type u_1} → {β : Type u_2} → Hypergraph α → (α → β) → Hypergraph β
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).
theorem Hypergraph.image_edgeSet E0 #
∀ {α : Type u_1} {β : Type u_2} (H : Hypergraph α) (f : α → β), (H.image f).edgeSet = Set.image f '' H.edgeSet
theorem Hypergraph.image_vertexSet E0 #
∀ {α : Type u_1} {β : Type u_2} (H : Hypergraph α) (f : α → β), (H.image f).vertexSet = f '' H.vertexSet
theorem Hypergraph.mem_edgeSet_image E0 #
∀ {α : 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 E1 #
∀ {α : Type u_1} {β : Type u_2} {e : Set α} {H : Hypergraph α} {f : α → β}, e ∈ H.edgeSet → f '' e ∈ (H.image f).edgeSet
theorem Hypergraph.image_image E1 #
∀ {α : 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 E1 #
{α : Type u_1} → Hypergraph α → α → Prop
A vertex is isolated if it is not incident to any edges (including loops).
theorem Hypergraph.sUnion_edgeSet_eq_vertexSet_iff_all_vertex_not_isolated E1 #
∀ {α : Type u_1} {H : Hypergraph α}, ⋃₀ H.edgeSet = H.vertexSet ↔ ∀ x ∈ H.vertexSet, ¬H.IsIsolated x
def Hypergraph.IsLoop E1 #
{α : Type u_1} → Hypergraph α → Set α → Prop
A loop is an edge whose associated vertex subset consists of a single vertex.
theorem Hypergraph.isLoop_iff_mem_edgeSet_and_singleton E1 #
∀ {α : Type u_1} {e : Set α} {H : Hypergraph α}, H.IsLoop e ↔ e ∈ H.edgeSet ∧ ∃ x, e = {x}
theorem Hypergraph.isLoop_iff_mem_and_ncard_one E1 #
∀ {α : Type u_1} {e : Set α} {H : Hypergraph α}, H.IsLoop e ↔ e ∈ H.edgeSet ∧ e.ncard = 1
theorem Hypergraph.IsLoop.ncard_one E1 #
∀ {α : Type u_1} {e : Set α} {H : Hypergraph α}, H.IsLoop e → e.ncard = 1
def Hypergraph.IsNonempty E1 #
{α : Type u_1} → Hypergraph α → Prop
A hypergraph is nonempty if it has at least one vertex or at least one edge.
instance Hypergraph.instBot E0 #
(α : Type u_4) → Bot (Hypergraph α)
The empty hypergraph (bottom) on a type.
theorem Hypergraph.bot_vertexSet E0 #
∀ (α : Type u_4), ⊥.vertexSet = ∅
theorem Hypergraph.bot_edgeSet E0 #
∀ (α : Type u_4), ⊥.edgeSet = ∅
theorem Hypergraph.IsNonempty.of_nonempty_vertexSet E0 #
∀ {α : Type u_1} {H : Hypergraph α}, H.vertexSet.Nonempty → H.IsNonempty
theorem Hypergraph.IsNonempty.of_nonempty_edgeSet E0 #
∀ {α : Type u_1} {H : Hypergraph α}, H.edgeSet.Nonempty → H.IsNonempty
theorem Hypergraph.ne_bot_iff E0 #
∀ {α : Type u_1} {H : Hypergraph α}, H ≠ ⊥ ↔ H.IsNonempty
theorem Hypergraph.IsNonempty.ne_bot E1 #
∀ {α : Type u_1} {H : Hypergraph α}, H.IsNonempty → H ≠ ⊥
Alias of the reverse direction of Hypergraph.ne_bot_iff.
theorem Hypergraph.not_isNonempty_iff E0 #
∀ {α : Type u_1} {H : Hypergraph α}, ¬H.IsNonempty ↔ H = ⊥
def Hypergraph.IsTrivial E1 #
{α : Type u_1} → Hypergraph α → Prop
A hypergraph is trivial if it has at least one vertex but no edges.
def Hypergraph.trivialOn E1 #
{α : Type u_1} → Set α → Hypergraph α
The trivial hypergraph with a given vertex set is defined by having no edges on that vertex set.
theorem Hypergraph.trivialOn_vertexSet E0 #
∀ {α : Type u_1} (f : Set α), (Hypergraph.trivialOn f).vertexSet = f
theorem Hypergraph.trivialOn_edgeSet E0 #
∀ {α : Type u_1} (f : Set α), (Hypergraph.trivialOn f).edgeSet = ∅
theorem Hypergraph.IsTrivial.trivialOn E1 #
∀ {α : Type u_1} {f : Set α}, f.Nonempty → (Hypergraph.trivialOn f).IsTrivial
theorem Hypergraph.IsTrivial.isNonempty E1 #
∀ {α : Type u_1} {H : Hypergraph α}, H.IsTrivial → H.IsNonempty
theorem Hypergraph.IsTrivial.notMem_edgeSet E1 #
∀ {α : Type u_1} {e : Set α} {H : Hypergraph α}, H.IsTrivial → e ∉ H.edgeSet
def Hypergraph.IsComplete E1 #
{α : Type u_1} → Hypergraph α → Prop
A hypergraph is complete if every subset of the vertex set is in the edge set.
def Hypergraph.completeOn E1 #
{α : Type u_1} → Set α → Hypergraph α
The complete hypergraph with a given vertex set, which has each subset of the vertex set as an edge.
theorem Hypergraph.completeOn_vertexSet E0 #
∀ {α : Type u_1} (f : Set α), (Hypergraph.completeOn f).vertexSet = f
theorem Hypergraph.completeOn_edgeSet E0 #
∀ {α : Type u_1} (f : Set α), (Hypergraph.completeOn f).edgeSet = 𝒫 f
theorem Hypergraph.mem_completeOn E0 #
∀ {α : Type u_1} {e f : Set α}, e ∈ (Hypergraph.completeOn f).edgeSet ↔ e ⊆ f
theorem Hypergraph.IsComplete.mem_iff E0 #
∀ {α : Type u_1} {e : Set α} {H : Hypergraph α}, H.IsComplete → (e ∈ H.edgeSet ↔ e ⊆ H.vertexSet)
theorem Hypergraph.IsComplete.completeOn E1 #
∀ {α : Type u_1} (f : Set α), (Hypergraph.completeOn f).IsComplete
theorem Hypergraph.IsComplete.isNonempty E1 #
∀ {α : Type u_1} {H : Hypergraph α}, H.IsComplete → H.IsNonempty
theorem Hypergraph.IsComplete.not_isTrivial E1 #
∀ {α : Type u_1} {H : Hypergraph α}, H.IsComplete → ¬H.IsTrivial
theorem Hypergraph.not_isTrivial_completeOn E1 #
∀ {α : Type u_1} (f : Set α), ¬(Hypergraph.completeOn f).IsTrivial
def Hypergraph.IsLinear E1 #
{α : Type u_1} → Hypergraph α → Prop
A hypergraph is linear if any two distinct edges share at most one vertex.
theorem Hypergraph.isLinear_def E0 #
∀ {α : Type u_1} {H : Hypergraph α}, H.IsLinear ↔ H.edgeSet.Pairwise fun e e' ↦ (e ∩ e').Subsingleton
theorem Hypergraph.IsLinear.inter_subsingleton E1 #
∀ {α : Type u_1} {H : Hypergraph α},
H.IsLinear → ∀ {e e' : Set α}, e ∈ H.edgeSet → e' ∈ H.edgeSet → e ≠ e' → (e ∩ e').Subsingleton
theorem Hypergraph.IsTrivial.isLinear E1 #
∀ {α : Type u_1} {H : Hypergraph α}, H.IsTrivial → H.IsLinear
A hypergraph with no edges is linear.
Deprecated aliases
| Name | New name | Since |
|---|---|---|
Hypergraph.IsTrivial.not_mem_edgeSet | Hypergraph.IsTrivial.notMem_edgeSet | 2026-09-28 |