AFTD Auto-Formalizing Theoretical Domains

Kruskal.UF.SamePartition.symm

theoremverifiedimported Lean

Symmetry of the same-partition relation. Fix $n \in \bbn$, and regard a union-find state on $n$ nodes as a function $\mathrm{Fin}\,n \to \bbn$ assigning each node a representative. If two such states $\mathit{uf}_1$ and $\mathit{uf}_2$ induce the same partition — that is, for all nodes $i, j$ one has $\mathit{uf}_1(i) = \mathit{uf}_1(j)$ if and only if $\mathit{uf}_2(i) = \mathit{uf}_2(j)$ — then $\mathit{uf}_2$ and $\mathit{uf}_1$ likewise induce the same partition.

Statement

set_option relaxedAutoImplicit false in
set_option autoImplicit false in
@[symm] lemma Kruskal.UF.SamePartition.symm {n : ℕ} {uf1 uf2 : UF n}
    (h : UF.SamePartition uf1 uf2) : UF.SamePartition uf2 uf1
Source
TCSlib, `Kruskal.UF.SamePartition.symm`
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
none — Lean reports it depends on no axioms
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.SamePartition$\mathtt{SamePartition}\,\mathit{uf}_1\,\mathit{uf}_2$ holds when two union-find states induce the same equivalence relation on nodes: for…
Used by 2
  • 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.processEdges_optimalOptimality of the greedy edge-selection sweep. Let $\mathit{edges}$ be a list of weighted edges on $n$ vertices, sorted in nondecreasing…

Lean source view module on GitHub

set_option relaxedAutoImplicit false in
set_option autoImplicit false in
@[symm] lemma Kruskal.UF.SamePartition.symm {n : ℕ} {uf1 uf2 : UF n}
    (h : UF.SamePartition uf1 uf2) : UF.SamePartition uf2 uf1 :=
  fun i j => (h i j).symm
See it in the graphDiscuss this resultChallenge it