Tree decompositions and treewidth #
Mathlib has no treewidth as of 2026-08-25, so this module introduces it from
scratch, in the shape needed by the van Dobben de Bruyn--Gijswijt theorem
treewidth ≤ gonality (TreewidthGonality/Gonality/TreewidthGonality.lean).
The connectivity convention (binds every downstream module) #
Two conventions were available for "the vertex set S induces a connected
subgraph of H": SimpleGraph.Subgraph connectivity, and the induced graph
on the coercion of S to a Set. This library uses the induced-graph
form throughout:
(H.induce (↑S : Set V)).Connected
for S : Finset V, and likewise for subsets of the tree's node type. Reasons:
SimpleGraph.induceproduces an honestSimpleGraph ↥s, so the wholeSimpleGraph.Connected/Walk/ReachableAPI applies verbatim with noSubgraph.vertsside conditions;SimpleGraph.Connectedalready bundlesNonempty, which is exactly the nonemptiness condition brambles need, so one field does two jobs;- the coercion
↑S : Set Vkeeps theFinsetbookkeeping (cardinalities,Finset.filter) available on the other side of the statement.
TreewidthGonality/Treewidth/Bramble.lean and TreewidthGonality/Gonality/BrambleGonality.lean
use the same form. Do not mix in Subgraph.Connected without converting.
Multigraph note #
Treewidth is defined for a SimpleGraph. For a chip-firing multigraph G the
intended instantiation is underlyingSimpleGraph G: parallel edges and loops do
not change treewidth, so nothing is lost.
Contents #
TreeDecomposition H— a bundled tree decomposition: a finite tree together with bags satisfying vertex coverage, edge coverage, and coherence.TreeDecomposition.width,treewidth(ansInfoverℕ).trivialDecomposition— the one-bag decomposition, which makes the set of achievable widths nonempty;treewidth_le_card_sub_one.
A tree decomposition of a simple graph H: a finite tree tree on a
node type Node, together with a bag of vertices at each node, such that
cover_vertex— every vertex lies in some bag;cover_edge— the two endpoints of every edge lie in a common bag;coherent— for each vertexvthe set of nodes whose bag containsvinduces a connected (in particular nonempty) subtree.
coherent implies cover_vertex (connectedness bundles nonemptiness), but both
are kept: cover_vertex is the field callers actually use, and stating it
separately keeps the definition readable.
- Node : Type
The nodes of the decomposition tree.
- nodeDecidableEq : DecidableEq self.Node
- tree : SimpleGraph self.Node
The decomposition tree.
treereally is a tree: connected and acyclic.The bag of vertices sitting at each node.
Every vertex appears in some bag.
Every edge has both endpoints in a common bag.
The nodes containing a fixed vertex form a connected subtree.
Instances For
The width of a tree decomposition: one less than the largest bag size.
The subtraction is truncated ℕ subtraction, which is harmless: sup (card - 1)
and sup card - 1 agree in every case, including the degenerate all-bags-empty
one.
Instances For
Every bag has at most width + 1 vertices.
Every bag has at most Fintype.card V vertices.
The set of widths realized by some tree decomposition of H.
Equations
- Utilities.Treewidth.widthSet H = {w : ℕ | ∃ (D : Utilities.Treewidth.TreeDecomposition H), D.width = w}
Instances For
The treewidth of H: the least width of a tree decomposition.
This is an sInf over ℕ, which is total; widthSet_nonempty (via
trivialDecomposition) is what makes the value meaningful rather than the
sInf ∅ = 0 default.
Equations
Instances For
The trivial tree decomposition: a single node whose bag is all of V.
Equations
- One or more equations did not get rendered due to their size.
Instances For
Some tree decomposition exists, so treewidth is an infimum over a nonempty
set of naturals.
Any tree decomposition bounds the treewidth.
The treewidth is realized by an actual decomposition.
treewidth H ≤ |V| - 1, from the one-bag decomposition.