Documentation

CslibFrontier.Foundations.Combinatorics.SimpleGraph.TreeDecomposition.Basic

Tree decompositions and treewidth #

A tree decomposition of a graph G on V is a tree T on an index type ι together with a finite bag bag t ⊆ V for every node t, such that

  1. every vertex lies in some bag;
  2. both endpoints of every edge lie in a common bag;
  3. for every vertex v, the nodes whose bags contain v induce a connected subtree of T.

The width of a decomposition with finitely many nodes is the largest bag size minus one. The treewidth of G is the least width of a decomposition with finitely many nodes.

We work with finite bags and finite index trees throughout. SimpleGraph.etreewidth takes values in ℕ∞ and is ⊤ exactly when G has no such decomposition. Finitely many finite bags cover only finitely many vertices, so this happens if and only if V is infinite, whatever the edges of G (SimpleGraph.etreewidth_eq_top_iff). In particular ⊤ carries no graph information, and etreewidth is not the treewidth of infinite graphs, which allows decompositions over infinite trees. SimpleGraph.treewidth is the truncation to ℕ. It is the textbook treewidth for finite V, where the single-bag decomposition shows treewidth G ≤ card V - 1. A graph on an empty vertex type has treewidth 0.

Condition 3 is stated as preconnectedness of the induced subgraph, so a vertex lying in no bag would satisfy it vacuously; condition 1 rules that out.

Relation to open Mathlib pull requests #

Justin Lai's open pull request mathlib4#38334 defines the same structure, TreeDecomp, with the same three axioms; mathlib4#39864 (the Helly property for subtrees) and mathlib4#39939 (complete graphs and the clique bound) build on it. Here the index type is a universe-polymorphic parameter ι rather than W : Type, and width is ℕ-valued on a Fintype index. etreewidth minimizes over Fin n-indexed decompositions, so it is ⊤ exactly for infinite V, whereas #38334 minimizes over all index types, giving the edgeless graph on ℕ extended treewidth 0. The two agree for finite V. The rooted parent-array form (TreeDecomposition/Rooted, SimpleGraph.parentTree, IsTree.parent), minDegree_le_treewidth, treewidth_le_one_iff and treewidth_cycleGraph are additions on top of that work; the topmost-node proof that a clique lies in a bag is an alternative to the Helly argument. Upstreaming should follow that work rather than compete with it.

Main definitions #

Main results #

References #

structure SimpleGraph.TreeDecomposition {V : Type uV} (G : SimpleGraph V) (ι : Type uι) :
Type (max uV uι)

A tree decomposition of G indexed by a tree on ι: finite bags of vertices at the nodes of a tree, covering every vertex and every edge, such that the nodes whose bags contain a given vertex induce a connected subtree.

  • tree : SimpleGraph ι

    The index tree.

  • isTree : self.tree.IsTree

    The index graph is a tree.

  • bag : ι → Finset V

    The bag of vertices at each node.

  • exists_mem_bag (v : V) : ∃ (t : ι), v ∈ self.bag t

    Every vertex lies in some bag.

  • exists_adj_mem_bag ⦃u v : V⦄ : G.Adj u v → ∃ (t : ι), u ∈ self.bag t ∧ v ∈ self.bag t

    Both endpoints of every edge lie in a common bag.

  • preconnected_bag (v : V) : (induce {t : ι | v ∈ self.bag t} self.tree).Preconnected

    The nodes whose bags contain a given vertex induce a connected subtree.

def SimpleGraph.TreeDecomposition.width {V : Type uV} {ι : Type uι} {G : SimpleGraph V} [Fintype ι] (D : G.TreeDecomposition ι) :

The width of a tree decomposition with finitely many nodes: the largest bag size minus one.

theorem SimpleGraph.TreeDecomposition.width_le_iff {V : Type uV} {ι : Type uι} {G : SimpleGraph V} [Fintype ι] (D : G.TreeDecomposition ι) {k : ℕ} :
D.width ≤ k ↔ ∀ (t : ι), (D.bag t).card ≤ k + 1
theorem SimpleGraph.TreeDecomposition.card_bag_le {V : Type uV} {ι : Type uι} {G : SimpleGraph V} [Fintype ι] (D : G.TreeDecomposition ι) (t : ι) :
(D.bag t).card ≤ D.width + 1
theorem SimpleGraph.TreeDecomposition.le_width_of_le_card {V : Type uV} {ι : Type uι} {G : SimpleGraph V} [Fintype ι] (D : G.TreeDecomposition ι) {k : ℕ} {t : ι} (h : k + 1 ≤ (D.bag t).card) :
theorem SimpleGraph.TreeDecomposition.finite {V : Type uV} {ι : Type uι} {G : SimpleGraph V} [Finite ι] (D : G.TreeDecomposition ι) :

Finitely many finite bags cover the vertices, so a graph with a tree decomposition with finitely many nodes has a finite vertex type.

def SimpleGraph.TreeDecomposition.reindex {V : Type uV} {ι : Type uι} {κ : Type uκ} {G : SimpleGraph V} (D : G.TreeDecomposition ι) (e : ι ≃ κ) :

Transport a tree decomposition along an equivalence of index types.

@[simp]
theorem SimpleGraph.TreeDecomposition.reindex_bag {V : Type uV} {ι : Type uι} {κ : Type uκ} {G : SimpleGraph V} (D : G.TreeDecomposition ι) (e : ι ≃ κ) (a : κ) :
(D.reindex e).bag a = D.bag (e.symm a)
@[simp]
theorem SimpleGraph.TreeDecomposition.width_reindex {V : Type uV} {ι : Type uι} {κ : Type uκ} {G : SimpleGraph V} [Fintype ι] [Fintype κ] (D : G.TreeDecomposition ι) (e : ι ≃ κ) :
noncomputable def SimpleGraph.TreeDecomposition.comap {V : Type uV} {W : Type uW} {ι : Type uι} {G : SimpleGraph V} {H : SimpleGraph W} (D : G.TreeDecomposition ι) (f : H →g G) (hf : Function.Injective ⇑f) :

Pull a tree decomposition of G back along an injective homomorphism H →g G: the bags are the preimages of the bags.

@[simp]
theorem SimpleGraph.TreeDecomposition.mem_comap_bag {V : Type uV} {W : Type uW} {ι : Type uι} {G : SimpleGraph V} {H : SimpleGraph W} (D : G.TreeDecomposition ι) (f : H →g G) (hf : Function.Injective ⇑f) {t : ι} {v : W} :
v ∈ (D.comap f hf).bag t ↔ f v ∈ D.bag t
theorem SimpleGraph.TreeDecomposition.width_comap_le {V : Type uV} {W : Type uW} {ι : Type uι} {G : SimpleGraph V} {H : SimpleGraph W} [Fintype ι] (D : G.TreeDecomposition ι) (f : H →g G) (hf : Function.Injective ⇑f) :
(D.comap f hf).width ≤ D.width

The decomposition of a graph on a finite vertex type with a single bag containing every vertex.

Treewidth #

noncomputable def SimpleGraph.etreewidth {V : Type uV} (G : SimpleGraph V) :

The extended treewidth of G: the least width of a tree decomposition of G with finitely many nodes, or ⊤ if there is none. Nodes are indexed by Fin n, which loses no generality (SimpleGraph.etreewidth_le_width).

Since finitely many finite bags cover only finitely many vertices, etreewidth G = ⊤ if and only if V is infinite (SimpleGraph.etreewidth_eq_top_iff). So ⊤ carries no information about the edges of G, and this is not the treewidth of infinite graphs, which allows decompositions over infinite trees.

theorem SimpleGraph.etreewidth_le_width {V : Type uV} {ι : Type uι} {G : SimpleGraph V} [Fintype ι] (D : G.TreeDecomposition ι) :
theorem SimpleGraph.le_etreewidth_iff {V : Type uV} {G : SimpleGraph V} {k : ℕ∞} :
k ≤ G.etreewidth ↔ ∀ (n : ℕ) (D : G.TreeDecomposition (Fin n)), k ≤ ↑D.width

etreewidth G = ⊤ exactly when the vertex type is infinite, whatever the edges of G.

noncomputable def SimpleGraph.treewidth {V : Type uV} (G : SimpleGraph V) :

The treewidth of G: the least width of a tree decomposition of G with finitely many nodes. This is meaningful for finite V, where such a decomposition always exists. For infinite V it is the junk value 0 (see SimpleGraph.etreewidth_eq_top_iff). A graph on an empty vertex type has treewidth 0 (one empty bag), not the value -1 used by some texts.

theorem SimpleGraph.treewidth_le_width {V : Type uV} {ι : Type uι} {G : SimpleGraph V} [Finite V] [Fintype ι] (D : G.TreeDecomposition ι) :
theorem SimpleGraph.le_treewidth_iff {V : Type uV} {G : SimpleGraph V} [Finite V] {k : ℕ} :
k ≤ G.treewidth ↔ ∀ (n : ℕ) (D : G.TreeDecomposition (Fin n)), k ≤ D.width
theorem SimpleGraph.treewidth_le_iff {V : Type uV} {G : SimpleGraph V} [Finite V] {k : ℕ} :
G.treewidth ≤ k ↔ ∃ (n : ℕ) (D : G.TreeDecomposition (Fin n)), D.width ≤ k
theorem SimpleGraph.etreewidth_le_of_hom {V : Type uV} {W : Type uW} {G : SimpleGraph V} {H : SimpleGraph W} (f : H →g G) (hf : Function.Injective ⇑f) :

Treewidth does not increase along injective homomorphisms.

theorem SimpleGraph.treewidth_le_of_hom {V : Type uV} {W : Type uW} {G : SimpleGraph V} {H : SimpleGraph W} [Finite V] (f : H →g G) (hf : Function.Injective ⇑f) :

Treewidth does not increase along injective homomorphisms into a finite graph.

theorem SimpleGraph.treewidth_mono {V : Type uV} {G : SimpleGraph V} [Finite V] {G' : SimpleGraph V} (h : G' ≤ G) :

Treewidth is monotone under taking subgraphs.

theorem SimpleGraph.Iso.etreewidth_eq {V : Type uV} {W : Type uW} {G : SimpleGraph V} {H : SimpleGraph W} (e : G ≃g H) :
theorem SimpleGraph.Iso.treewidth_eq {V : Type uV} {W : Type uW} {G : SimpleGraph V} {H : SimpleGraph W} (e : G ≃g H) :