Graph structures #
This file introduces a small hierarchy of graph-like combinatorial structures on a vertex
type α. Each structure carries its vertex and edge sets explicitly.
Design rationale #
We intentionally diverge from Mathlib's graph definitions (Mathlib.Combinatorics.Graph.Basic,
Mathlib.Combinatorics.SimpleGraph.Basic),
prioritizing representations that support algorithmic reasoning. In graph algorithm design,
it is common to manipulate graphs dynamically (adding or removing nodes/edges, contracting
edges, etc.). We therefore use set-based definitions for both vertex and edge sets with
minimal additional axioms, reducing early proof obligations and keeping proofs closer to
their textbook counterparts.
Main definitions #
Edge α β: an undirected edge with a label of typeβand endpoints as aSym2 α.DiEdge α β: a directed edge with a label of typeβand endpoints asα × α.Graph α β: a general graph whose edges areEdge α βvalues. Parallel edges and loops are permitted.SimpleGraph α: a simple graph with edges asSym2 α, no loops.DiGraph α β: a directed graph whose edges areDiEdge α βvalues. Parallel edges and loops are permitted.SimpleDiGraph α: a simple directed graph with edges asα × α, no loops.
Notation #
V(G): the vertex set ofG, viaHasVertexSet.E(G): the edge set ofG, viaHasEdgeSet.
Main API #
The structure fields are named with a ' suffix (e.g. incidence', loopless'). The
preferred API restates these in terms of V(G) and E(G):
Graph.incidence,SimpleGraph.incidence,DiGraph.incidence,SimpleDiGraph.incidenceSimpleGraph.loopless,SimpleDiGraph.loopless
Main forgetful maps #
SimpleGraph.toGraph: forget the looplessness axiom of a simple graph.SimpleDiGraph.toDiGraph: forget the looplessness axiom of a simple directed graph.
The corresponding Coe instances are registered.
Equations
Instances For
Equations
- One or more equations did not get rendered due to their size.
Instances For
A general graph on vertex type α with edge labels in β. Each edge bundles a label
and an unordered pair of endpoints. Parallel edges and loops are permitted, and both the
vertex and edge sets may be infinite.
- vertexSet : Set α
The set of vertices.
The set of edges.
Every endpoint of an edge is a vertex. Prefer
Graph.incidence.
Instances For
A simple graph on α with edges as unordered pairs of distinct vertices.
- vertexSet : Set α
The set of vertices.
The set of edges, each an unordered pair of vertices.
Both endpoints of every edge are vertices. Prefer
SimpleGraph.incidence.No edge is a loop. Prefer
SimpleGraph.loopless.
Instances For
A directed graph on vertex type α with edge labels in β. Each edge bundles a label
and an ordered pair of endpoints. Parallel edges and loops are permitted, and both the
vertex and edge sets may be infinite.
- vertexSet : Set α
The set of vertices.
The set of edges.
- incidence' (e : DiEdge α β) : e ∈ self.edgeSet → e.endpoints.1 ∈ self.vertexSet ∧ e.endpoints.2 ∈ self.vertexSet
Both endpoints of every edge are vertices. Prefer
DiGraph.incidence.
Instances For
A simple directed graph on α with edges as ordered pairs of distinct vertices.
- vertexSet : Set α
The set of vertices.
The set of directed edges.
Both endpoints of every directed edge are vertices. Prefer
SimpleDiGraph.incidence.No directed edge is a loop. Prefer
SimpleDiGraph.loopless.
Instances For
Forget the looplessness axiom of a SimpleGraph, viewing it as a Graph whose edges
are Edge α (Sym2 α) with the pair as both label and endpoints.
Equations
Instances For
Forget the looplessness axiom of a SimpleDiGraph, viewing it as a DiGraph whose
edges are DiEdge α (α × α) with the pair as both label and endpoints.
Equations
Instances For
Equations
Equations
Equations
- GraphLib.instHasVertexSetGraphSet = { vertexSet := GraphLib.Graph.vertexSet }
Equations
Equations
- GraphLib.instHasVertexSetDiGraphSet = { vertexSet := GraphLib.DiGraph.vertexSet }
Equations
Equations
- GraphLib.instHasEdgeSetGraphSetSym2 = { edgeSet := fun (G : GraphLib.Graph α β) => GraphLib.Edge.endpoints '' G.edgeSet }
Equations
Equations
- GraphLib.instHasEdgeSetDiGraphSetProd = { edgeSet := fun (G : GraphLib.DiGraph α β) => GraphLib.DiEdge.endpoints '' G.edgeSet }
Equations
Notation for the vertex set of a graph.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Notation for the edge set of a graph.
Equations
- One or more equations did not get rendered due to their size.