AFTD Auto-Formalizing Theoretical Domains

Kruskal.merge_noop

theoremverifiedimported Lean

Merging within a single component leaves the state unchanged. Let $\mathit{uf}\colon \mathrm{Fin}\,n \to \bbn$ be a union-find state on $n$ nodes, and let $i,j$ be two nodes whose representatives agree, $\mathit{uf}(i) = \mathit{uf}(j)$. Then merging the components of $i$ and $j$ has no effect: the merged state equals $\mathit{uf}$.

Statement

set_option relaxedAutoImplicit false in
set_option autoImplicit false in
lemma Kruskal.merge_noop {n : ℕ} (uf : UF n) (i j : Fin n) (h : uf i = uf j) :
    uf.merge i j = uf
Source
TCSlib, `Kruskal.merge_noop`
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.
Verified
07 Oct 2026
Axioms
Quot.soundpropext
Built on 3
  • 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.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 2
  • 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.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…

Lean source view module on GitHub

set_option relaxedAutoImplicit false inset_option autoImplicit false inlemma Kruskal.merge_noop {n : ℕ} (uf : UF n) (i j : Fin n) (h : uf i = uf j) :    uf.merge i j = uf := by  funext k; unfold UF.merge; aesop
See it in the graphDiscuss this resultChallenge it