Documentation

CslibFrontier.Foundations.Combinatorics.SimpleGraph.MinimumSpanningTree

Cut Property (Blue Rule) and Minimum Spanning Tree Uniqueness on SimpleGraph #

This module formalizes minimum-weight spanning trees (SimpleGraph.IsMST), outgoing cut edges (SimpleGraph.IsOutgoingEdge, SimpleGraph.outgoingEdges), minimum-weight outgoing edges (SimpleGraph.IsMOE), the cycle-exchange cut property, and distinct-weight MST uniqueness on Mathlib's SimpleGraph V, following Section 2 (Properties 1 and 2, p. 68) of [GHS83] and bridging both sequential Kruskal (CslibFrontier.Algorithms.Lean.Kruskal.SimpleGraph) and the distributed GHS protocol (CslibFrontier.Computability.Distributed.MinimumSpanningTree.GHS).

Main definitions #

Main results #

References #

Spanning trees, edge-weight sums, and minimum spanning trees #

T is a spanning tree of G when T is a spanning subgraph (T ≤ G) that is a tree (T.IsTree).

noncomputable def SimpleGraph.edgeWeightSum {V : Type u_1} {W : Type u_2} [AddCommMonoid W] (H : SimpleGraph V) (w : Sym2 V → W) :
W

Total weight ∑ᶠ e ∈ H.edgeSet, w e of the undirected edges of H : SimpleGraph V. Using finsum avoids carrying [DecidableRel H.Adj] or [Fintype H.edgeSet] in quantified optimality statements while simplifying to ∑ e ∈ H.edgeFinset, w e whenever [Fintype H.edgeSet] is available.

@[simp]
theorem SimpleGraph.edgeWeightSum_eq_sum_edgeFinset {V : Type u_1} {W : Type u_2} [AddCommMonoid W] (H : SimpleGraph V) [Fintype ↑H.edgeSet] (w : Sym2 V → W) :
H.edgeWeightSum w = ∑ e ∈ H.edgeFinset, w e
def SimpleGraph.IsMST {V : Type u_1} {W : Type u_2} [AddCommMonoid W] [LE W] (G : SimpleGraph V) (w : Sym2 V → W) (T : SimpleGraph V) :

T is a minimum-weight spanning tree (MST) of G with respect to edge weights w if T is a spanning tree of G whose total edge weight is less than or equal to that of every spanning tree of G.

Outgoing cut edges and minimum-weight outgoing edges (MOEs) #

def SimpleGraph.IsOutgoingEdge {V : Type u_1} (G : SimpleGraph V) (S : Finset V) (e : Sym2 V) :

e is an outgoing edge of S : Finset V in G ([GHS83], §2, p. 68) when e ∈ G.edgeSet has one endpoint in S and the other outside S.

theorem SimpleGraph.IsOutgoingEdge.mem_edgeSet {V : Type u_1} {G : SimpleGraph V} {S : Finset V} {e : Sym2 V} (h : G.IsOutgoingEdge S e) :
theorem SimpleGraph.IsOutgoingEdge.mono {V : Type u_1} {H G : SimpleGraph V} (hle : H ≤ G) {S : Finset V} {e : Sym2 V} (h : H.IsOutgoingEdge S e) :
theorem SimpleGraph.isOutgoingEdge_mk {V : Type u_1} {G : SimpleGraph V} {S : Finset V} {u v : V} :
G.IsOutgoingEdge S s(u, v) ↔ G.Adj u v ∧ (u ∈ S ∧ v ∉ S ∨ u ∉ S ∧ v ∈ S)
def SimpleGraph.crossesCut {V : Type u_1} [DecidableEq V] (S : Finset V) (e : Sym2 V) :

Symmetry-preserving computable Boolean check testing whether e : Sym2 V has one endpoint in S and one outside S.

def SimpleGraph.outgoingEdges {V : Type u_1} [DecidableEq V] (G : SimpleGraph V) [Fintype ↑G.edgeSet] (S : Finset V) :

Computable Finset of outgoing edges of S in G.

@[simp]
theorem SimpleGraph.mem_outgoingEdges {V : Type u_1} [DecidableEq V] (G : SimpleGraph V) [Fintype ↑G.edgeSet] (S : Finset V) (e : Sym2 V) :
def SimpleGraph.IsMOE {V : Type u_1} {W : Type u_2} [LE W] (G : SimpleGraph V) (w : Sym2 V → W) (S : Finset V) (e : Sym2 V) :

e is a minimum-weight outgoing edge (MOE) of S in (G, w) if e is an outgoing edge of S and its weight is at most that of every outgoing edge of S.

Instances For
    @[instance_reducible]
    instance SimpleGraph.instDecidableIsMOE {V : Type u_1} {W : Type u_2} [DecidableEq V] (G : SimpleGraph V) [Fintype ↑G.edgeSet] [LE W] [DecidableLE W] (w : Sym2 V → W) (S : Finset V) (e : Sym2 V) :
    Decidable (G.IsMOE w S e)

    Computable check for IsMOE on a finite decidable graph.

    theorem SimpleGraph.IsMOE.unique_of_injOn {V : Type u_1} {W : Type u_2} [LinearOrder W] {G : SimpleGraph V} {w : Sym2 V → W} (hinj : Set.InjOn w G.edgeSet) {S : Finset V} {e₁ e₂ : Sym2 V} (h₁ : G.IsMOE w S e₁) (h₂ : G.IsMOE w S e₂) :
    e₁ = e₂
    theorem SimpleGraph.exists_isOutgoingEdge {V : Type u_1} [Fintype V] {G : SimpleGraph V} (hconn : G.Connected) {S : Finset V} (hne : S.Nonempty) (hproper : S ≠ Finset.univ) :
    ∃ (e : Sym2 V), G.IsOutgoingEdge S e

    Every nonempty proper subset S of a finite connected graph has at least one outgoing edge.

    theorem SimpleGraph.exists_isMOE {V : Type u_1} {W : Type u_2} [Fintype V] [LinearOrder W] {G : SimpleGraph V} (hconn : G.Connected) (w : Sym2 V → W) {S : Finset V} (hne : S.Nonempty) (hproper : S ≠ Finset.univ) :
    ∃ (e : Sym2 V), G.IsMOE w S e

    Every nonempty proper subset S of a finite connected graph has a minimum-weight outgoing edge.

    theorem SimpleGraph.existsUnique_isMOE_of_injOn {V : Type u_1} {W : Type u_2} [Fintype V] [LinearOrder W] {G : SimpleGraph V} (hconn : G.Connected) {w : Sym2 V → W} (hinj : Set.InjOn w G.edgeSet) {S : Finset V} (hne : S.Nonempty) (hproper : S ≠ Finset.univ) :
    ∃! e : Sym2 V, G.IsMOE w S e

    Under injective edge weights on G.edgeSet, every nonempty proper subset S of a finite connected graph has a unique minimum-weight outgoing edge.

    Fundamental cycle-exchange lemma on spanning trees #

    theorem SimpleGraph.IsSpanningTree.swap_edge {V : Type u_1} {W : Type u_2} [Finite V] [AddCommMonoid W] {G T : SimpleGraph V} (hT : G.IsSpanningTree T) {S : Finset V} {u v : V} (hu : u ∈ S) (hv : v ∉ S) (hadj : G.Adj u v) (hnotMem : s(u, v) ∉ T.edgeSet) (w : Sym2 V → W) :
    ∃ (e' : Sym2 V), T.IsOutgoingEdge S e' ∧ e' ≠ s(u, v) ∧ G.IsSpanningTree ((T ⊔ edge u v).deleteEdges {e'}) ∧ ((T ⊔ edge u v).deleteEdges {e'}).edgeWeightSum w + w e' = T.edgeWeightSum w + w s(u, v)

    Cycle-exchange lemma across a cut: if T is a spanning tree of G on [Finite V] and G.Adj u v crosses (S, Sᶜ) (u ∈ S, v ∉ S) with s(u, v) ∉ T.edgeSet, there is an edge e' ∈ T.edgeSet crossing (S, Sᶜ) in T such that (T ⊔ edge u v).deleteEdges {e'} is a spanning tree of G with the exact swapped weight sum.

    Cut optimality (GHS Property 1) and distinct-weight blue rule #

    theorem SimpleGraph.IsMST.exists_sup_edge_of_isMOE {V : Type u_1} {W : Type u_2} [Finite V] [AddCancelCommMonoid W] [LinearOrder W] [IsOrderedCancelAddMonoid W] {G T H : SimpleGraph V} {w : Sym2 V → W} (hMST : G.IsMST w T) {S : Finset V} (hHT : H ≤ T) (hHS : ∀ ⦃x y : V⦄, H.Adj x y → x ∈ S ∧ y ∈ S) {u v : V} (hmoe : G.IsMOE w S s(u, v)) :
    ∃ (T' : SimpleGraph V), G.IsMST w T' ∧ H ⊔ edge u v ≤ T'

    GHS Property 1 ([GHS83], §2, p. 68): given a minimum-weight spanning tree T of G, any subgraph H ≤ T whose edges lie inside S : Finset V (in particular, a connected fragment of T on vertex set S), and any minimum-weight outgoing edge s(u, v) of S, there exists a minimum-weight spanning tree T' of G containing both H and s(u, v).

    theorem SimpleGraph.IsMOE.mem_edgeSet_of_isMST_of_injOn {V : Type u_1} {W : Type u_2} [Finite V] [AddCancelCommMonoid W] [LinearOrder W] [IsOrderedCancelAddMonoid W] {G T : SimpleGraph V} {w : Sym2 V → W} (hinj : Set.InjOn w G.edgeSet) {S : Finset V} {e : Sym2 V} (hmoe : G.IsMOE w S e) (hMST : G.IsMST w T) :

    Distinct-weight cut / blue-rule theorem: when w is injective on G.edgeSet, the minimum-weight outgoing edge across any cut S : Finset V belongs to every minimum-weight spanning tree of G.

    Existence and distinct-weight uniqueness of the MST (GHS Property 2) #

    theorem SimpleGraph.exists_isMST {V : Type u_1} {W : Type u_2} [Finite V] [AddCommMonoid W] [LinearOrder W] {G : SimpleGraph V} (hconn : G.Connected) (w : Sym2 V → W) :
    ∃ (T : SimpleGraph V), G.IsMST w T

    Every finite connected graph admits a minimum-weight spanning tree.

    theorem SimpleGraph.IsMST.eq_of_injOn {V : Type u_1} {W : Type u_2} [Finite V] [AddCancelCommMonoid W] [LinearOrder W] [IsOrderedCancelAddMonoid W] {G T₁ T₂ : SimpleGraph V} {w : Sym2 V → W} (hinj : Set.InjOn w G.edgeSet) (h₁ : G.IsMST w T₁) (h₂ : G.IsMST w T₂) :
    T₁ = T₂

    GHS Property 2 ([GHS83], §2, p. 68): when w is injective on G.edgeSet, any two minimum-weight spanning trees of G are equal.

    theorem SimpleGraph.existsUnique_isMST_of_injOn {V : Type u_1} {W : Type u_2} [Finite V] [AddCancelCommMonoid W] [LinearOrder W] [IsOrderedCancelAddMonoid W] {G : SimpleGraph V} (hconn : G.Connected) {w : Sym2 V → W} (hinj : Set.InjOn w G.edgeSet) :

    On a finite connected graph with edge weights injective on G.edgeSet, there exists a unique minimum-weight spanning tree.

    Cut-MOE subgraphs and acyclicity #

    theorem SimpleGraph.le_of_forall_isMOE_of_isMST_of_injOn {V : Type u_1} {W : Type u_2} [Finite V] [AddCancelCommMonoid W] [LinearOrder W] [IsOrderedCancelAddMonoid W] {G H T : SimpleGraph V} {w : Sym2 V → W} (hinj : Set.InjOn w G.edgeSet) (hMOE : ∀ e ∈ H.edgeSet, ∃ (S : Finset V), G.IsMOE w S e) (hMST : G.IsMST w T) :
    H ≤ T

    Any subgraph H whose edges are all cut-MOEs of (G, w) is contained in every MST of (G, w) when w is injective on G.edgeSet.

    theorem SimpleGraph.isAcyclic_of_forall_isMOE_of_injOn {V : Type u_1} {W : Type u_2} [Finite V] [AddCancelCommMonoid W] [LinearOrder W] [IsOrderedCancelAddMonoid W] {G H : SimpleGraph V} (hconn : G.Connected) {w : Sym2 V → W} (hinj : Set.InjOn w G.edgeSet) (hMOE : ∀ e ∈ H.edgeSet, ∃ (S : Finset V), G.IsMOE w S e) :

    On a finite connected graph with injective edge weights, any subgraph whose edges are all cut-MOEs is acyclic (since it is a subgraph of the unique MST).

    theorem SimpleGraph.isMST_of_forall_isMOE_of_connected_of_injOn {V : Type u_1} {W : Type u_2} [Finite V] [AddCancelCommMonoid W] [LinearOrder W] [IsOrderedCancelAddMonoid W] {G H : SimpleGraph V} (hconn : G.Connected) {w : Sym2 V → W} (hinj : Set.InjOn w G.edgeSet) (hHconn : H.Connected) (hMOE : ∀ e ∈ H.edgeSet, ∃ (S : Finset V), G.IsMOE w S e) :
    G.IsMST w H

    On a finite connected graph with injective edge weights, any connected graph H whose edges are all cut-MOEs of (G, w) is the unique minimum-weight spanning tree of (G, w).