Kruskal.UF.mergeAll
defimported Lean
$\mathtt{mergeAll}\,\mathit{uf}\,\mathit{es}$ folds a list of weighted edges
$\mathit{es}$ into the union-find $\mathit{uf}$ by calling merge on
each edge's endpoints in sequence.
Statement
set_option relaxedAutoImplicit false in set_option autoImplicit false in def Kruskal.UF.mergeAll {n : ℕ} (uf : UF n) : List (WEdge n) → UF n
- Defined in
- TCSlib, `Kruskal.UF.mergeAll`
- Lean proof
- By Harsha Polavaram, from github.com/Shilun-Allan-Li/tcslib at
c8a02591b1e5(Copyright (c) 2026 Harsha Polavaram. All rights reserved, Apache-2.0). Compiled here against leanprover/lean4:v4.33.1, Mathlib v4.33.1; written for leanprover/lean4:v4.25.0.Kruskal.UF.mergeAll← Kruskal.UF.mergeAll (TCSlib/GraphTheory/Kruskal/Basic.lean:52): verbatim
- Verified
- 07 Oct 2026
- Axioms
- none listed
- Built on 4
- Kruskal.UFThe union-find state for $n$ nodes is defined as a function $\mathrm{Fin}\,n \to \mathbb{N}$ mapping each node to its current…
- Kruskal.UF.find_defFind equals direct lookup. Let $\mathit{uf} \colon \mathrm{Fin}\,n \to \bbn$ be a union-find state on $n$ nodes, and let $i$ be one of its…
- Kruskal.WEdgeA weighted edge over $n$ vertices is a structure with two endpoints $u, v : \mathrm{Fin}\,n$ and a natural-number weight…
- Kruskal.UF.merge$\mathtt{merge}\,\mathit{uf}\,i\,j$ unifies the components of nodes $i$ and $j$ by reassigning every node whose representative equals…
- Used by 9
- Kruskal.mergeAll_congrMerging edges preserves equal partitions. Let $\mathit{uf}_1, \mathit{uf}_2 : \mathrm{Fin}\,n \to \bbn$ be two union-find states over $n$…
- Kruskal.uf_exchangeUnion-find form of the exchange argument. Let $\mathit{uf}\colon \mathrm{Fin}\,n \to \bbn$ be a union-find state whose classes coincide…
- Kruskal.kruskal_optimalOptimality of Kruskal's algorithm. Let $E$ be a list of weighted edges on $n$ vertices, and let $S$ be another such list in which every…
- Kruskal.mergeAll_permPermutation invariance of edge merging. Fix $n$ and an initial union-find state $\mathit{uf} : \mathrm{Fin}\,n \to \bbn$. If two lists of…
- Kruskal.mergeAll_cons_eqPeeling the leading edge off a merge fold. Let $\mathit{uf} : \mathrm{Fin}\,n \to \bbn$ be a union-find state on $n$ nodes, let $e$ be a…
- Kruskal.processEdges_optimalOptimality of the greedy edge-selection sweep. Let $\mathit{edges}$ be a list of weighted edges on $n$ vertices, sorted in nondecreasing…
- Kruskal.mergeAll_init_iffCorrectness of union-find merging from the initial state. Fix a natural number $n$, and let $\mathit{edges}$ be a list of weighted edges…
- Kruskal.reduce_to_restDropping a redundant edge from a candidate set. Let $\mathit{uf}$ be a union-find state on $n$ nodes, let $e$ be a weighted edge with…
- Kruskal.mergeAll_iff_reachMerging preserves the reachability invariant. Fix $n$ and let $uf : \mathrm{Fin}\,n \to \bbn$ be a union-find state assigning each of the…
Lean source view module on GitHub
set_option relaxedAutoImplicit false in set_option autoImplicit false in def Kruskal.UF.mergeAll {n : ℕ} (uf : UF n) : List (WEdge n) → UF n | [] => uf | e :: rest => (uf.merge e.u e.v).mergeAll rest