Graph minors, the Hadwiger number and Wagner planarity
DefinitionTenChallenges_MinorThe minor relation for Mathlib's simple graphs, shared by Challenges 1 and 6 of the Ten Challenges benchmark.
- Minor. For graphs on and on , a minor structure of in consists of branch sets for which are pairwise disjoint, each inducing a connected (hence nonempty) subgraph of , such that for every edge of some vertex of is adjacent in to some vertex of . is a minor of when such a structure exists.
- Hadwiger number. For a finite graph , is the largest such that the complete graph is a minor of .
- Planarity. and denote the complete graph on five vertices and the complete bipartite graph with sides of size three; is Wagner-planar if neither nor is a minor of . By Wagner's theorem this is planarity for finite graphs.
Formalization Note. Minor H G is a structure (data, not a proposition); " is a minor of " is Nonempty (Minor H G). The Hadwiger number is Nat.findGreatest over , so it is for the graph with no vertices.
import Mathlib.Combinatorics.SimpleGraph.Coloring.Vertex
namespace SimpleGraph
variable {V W : Type*}
/-- The data witnessing that `H` is a minor of `G`, as simple graphs. -/
structure Minor (H : SimpleGraph W) (G : SimpleGraph V) where
/-- The branch sets of the minor.
Seeing the minor as a quotient graph, `branchSet w` is exactly the fiber of `w` under the quotient
map. -/
branchSet : W → Set V
/-- The branch sets are pairwise disjoint. -/
pairwise_disjoint_branchSet : Pairwise fun w₁ w₂ ↦ Disjoint (branchSet w₁) (branchSet w₂)
/-- Each branch set is connected (in particular nonempty). -/
connectedOn_branchSet (w : W) : (G.induce (branchSet w)).Connected
/-- Adjacency in the minor induce adjacency between some points of the corresponding branch set.
-/
exists_mem_branchSet_of_adj ⦃w₁ w₂ : W⦄ :
H.Adj w₁ w₂ → ∃ v₁ ∈ branchSet w₁, ∃ v₂ ∈ branchSet w₂, G.Adj v₁ v₂
/-- The Hadwiger number: the largest `r` such that `K_r` is a minor of `G`. -/
noncomputable def hadwigerNumber [Fintype V] (G : SimpleGraph V) : ℕ := by
classical
exact Nat.findGreatest (fun r =>
Nonempty (Minor (completeGraph (Fin r)) G)) (Fintype.card V)
/-- K₅ -/
abbrev K5 := completeGraph (Fin 5)
/-- K₃,₃ -/
abbrev K33 := completeBipartiteGraph (Fin 3) (Fin 3)
/-- Planarity via Wagner's criterion: no `K₅` or `K₃,₃` minor. -/
def IsWagnerPlanar (G : SimpleGraph V) : Prop :=
¬ Nonempty (Minor K5 G) ∧ ¬ Nonempty (Minor K33 G)
end SimpleGraph
Read-back
What the Lean code literally says, in plain math · claude-fable-5-1
Setting. Every declaration in this file lives in the SimpleGraph namespace. and are arbitrary types (possibly infinite, in arbitrary universes); no finiteness or decidability is assumed unless stated. A simple graph on a type is, as in Mathlib, an irreflexive symmetric adjacency relation; denotes adjacency in .
Structure Minor H G. For a simple graph on and a simple graph on , a minor witness of in consists of exactly the following data and conditions:
- Branch sets. A function , .
- Pairwise disjointness. For all with : .
- Connectedness. For every , the induced subgraph (vertex set ; two vertices of are adjacent iff they are adjacent in ) is connected in Mathlib's sense, which means both that and that any two vertices are joined by a walk ( allowed) all of whose vertices lie in .
- Edge lifting. For all : if , then there exist and with .
Nothing else is required: the branch sets need not cover ; no condition is imposed when (edges of between and are allowed); if is empty, is the empty function and conditions 2–4 hold vacuously, so every graph admits a minor witness of the graph with no vertices. In the rest of the file "Nonempty (Minor H G)" means that at least one such witness exists; below I abbreviate this as " is a minor of ", always in exactly this sense.
hadwigerNumber G. Defined only when is a finite type (Fintype V), using classical decidability. It is the natural number
i.e. the largest with such that — the complete graph on , in which — is a minor of in the above sense, with the convention that the result is when no qualifies. Since always qualifies (empty vertex type, vacuous conditions), the value is exactly ; values are never examined.
K5. The complete graph on : five vertices, all ten pairs of distinct vertices adjacent.
K33. Mathlib's completeBipartiteGraph (Fin 3) (Fin 3): the vertex type is the disjoint union (six vertices, each tagged "left" or "right"), and iff ( is left and is right) or ( is right and is left). There are no edges inside a side; all nine left–right pairs are adjacent.
IsWagnerPlanar G. For a simple graph on an arbitrary type (no finiteness assumed), the proposition
Unfolded: there is no family of pairwise disjoint subsets of , each nonempty and connected inside , such that for every two distinct indices some vertex of is -adjacent to some vertex of ; and there is no family of pairwise disjoint subsets of , each nonempty and connected inside , such that for every left index and every right index some vertex of is -adjacent to some vertex of . No other notion of planarity (embeddings in the plane, Euler's formula, etc.) appears in the definition.
Confirmed by the mission captain (proposal self-audit).
Confirmed by the mission captain (proposal self-audit).
Confirmed by the moderator at approval.