Inverse-Ackermann amortized step bounds for Union–Find #
This module is an abstract step-count step toward #3558 and #5441 (not a registered cited
endpoint of [Tar75] or [CLRS09]): it proves inverse-Ackermann amortized upper bounds on the
abstract findSteps/link traces of Cslib.DataStructure.DisjointSet.UnionFind.impl
(Batteries.UnionFind with union by rank and full path compression) using
Cslib.DataStructure.Amortized certificates over Execution.ofStep.
The rank-shifted potential potentialCore adapts the level/iteration potential from
[CLRS09] Section 21.4 (pp. 573–581, Lemmas 21.11–21.13 and Theorem 21.14) using the + d rank
shift (d := max 1 d ≥ 1). Each node i < uf.size receives a potential built from the level
k = ackLevel (uf.rank i + d) (uf.rank (uf.parent i) + d) and iteration count
i₀ = ackIter (uf.rank i + d) (uf.rank (uf.parent i) + d) in the (j + 1)-fold hierarchy
Nat.ackermann so that
ackermann k (uf.rank i + d) ≤ (ackermann k)^[i₀] (uf.rank i + d) ≤ uf.rank (uf.parent i) + d.
Shifting node ranks by d ≥ 1 ensures 1 ≤ uf.rank i + d everywhere, avoiding separate
rank-zero handling during find.
A single parameterized potential potentialCore zeroSingletons q d uf unifies two regimes:
zeroSingletons = true, d = 1(tarjanAmortized): initial potential atinit nis0, giving single-parameter amortized charges2 * α(n) + 2forOp.same,5 * α(n) + 2forOp.union, and1forOp.numComponents, hencetotal id traces ≤ m * (5 * α(n) + 2).zeroSingletons = false, d = m / n + 1(tarjanAmortizedAt): initial potential atinit nisn * (q * (m / n + 1)), while eachlinkhas amortized charge at mostq. Whenn ≤ m,n * (m / n + 1) ≤ 2 * m, yielding the two-parameter step boundtotal id traces ≤ m * (5 * α(m, n) + 2)(tarjan_run_two_param) for everym, n, together with the linear7 * mcorollary oncen * Nat.log 2 n ≤ m(tarjan_run_linear_of_dense).
Cost model and scope #
Like Cslib.DataStructure.DisjointSet.UnionFind, total id traces counts only the exact abstract
forest steps recorded by UnionFind.step (findSteps parent-pointer inspections per find, 1
link step per Op.union, and 1 counter read per Op.numComponents), excluding the O(n)
creation of init n. These theorems make no Word-RAM or pointer-machine instruction-cost claim
(#3558, #5441). Moreover, Nat.inverseAckermannTwo m n uses shift d = m / n + 1 in the
[CLRS09] recurrence rather than [Tar75]'s 4 * ⌈m / n⌉ threshold convention, matching
Tarjan's bound only up to small constant shifts/factors and the omitted init n cost.
Main definitions #
tarjanPotential,tarjanCharge: single-parameter CLRS/Tarjan potential and operation charges.tarjanPotentialAt,tarjanChargeAt: rank-shifted potential and per-operation charges for the two-parameter step analysis.
Main results #
tarjanAmortized,tarjanUniformAmortized:Amortizedcertificates for the single-parameterO(α(n))abstract step bound.tarjan_run_correct: adaptive client correctness andm * (5 * α(n) + 2)abstract step bound frominit n.tarjanAmortizedAt,tarjanUniformAmortizedAt:Amortizedcertificates parameterized byd.tarjan_run_two_param: two-parameterm * (5 * α(m, n) + 2)abstract step bound for all universe sizesnand operation countsm(step toward#3558and#5441).tarjan_run_linear_of_dense: lineartotal id traces ≤ 7 * mabstract step corollary whenevern * Nat.log 2 n ≤ m.
References #
- T. H. Cormen, C. E. Leiserson, R. L. Rivest, and C. Stein, Introduction to Algorithms (3rd ed.), MIT Press, 2009, Section 21.4, pp. 573–581 (Lemmas 21.11–21.13, Theorem 21.14).
- R. E. Tarjan, Efficiency of a Good But Not Linear Set Union Algorithm, JACM 22(2), pp. 215–225, 1975.
- D. C. Kozen, The Design and Analysis of Algorithms, Lectures 10–11, pp. 48–57, 1992.
Find-path traversal and path compression characterization #
Level, iteration index, and non-root potential #
Unified node potential and find/link step inequalities #
Public potentials, amortized certificates, and client step bounds #
Potential function on Fin n used for the single-parameter O(α(n)) step analysis.
Singletons carry zero potential, so tarjanPotential n _ (init n) = 0.
Every disjoint-set operation has single-parameter charge at most 5 * α(n) + 2.
Initial single-parameter potential at init n is 0.
Single-parameter O(α(n)) amortized abstract step certificate over impl n.
Uniform single-parameter amortized abstract step certificate 5 * α(n) + 2 over impl n.
Running the concrete union-find interpreter from init n agrees with abstract Partition n
semantics, preserves Rep, and satisfies both the exact per-operation and uniform 5 * α(n) + 2
abstract step bounds (excluding init n).
Rank-shifted potential function parameterized by d on Fin n used for the two-parameter
O(m α(m, n)) abstract step analysis. Initial potential at init n is
n * (inverseAckermannAt d n * max 1 d).
Every disjoint-set operation has rank-shifted charge at most 3 * α_d(n) + 2.
Initial rank-shifted potential at init n.
Rank-shifted amortized abstract step certificate over impl n.
Uniform rank-shifted amortized step certificate 3 * α_d(n) + 2 over impl n.
Two-parameter inverse-Ackermann abstract step bound (step toward #3558 and #5441): for
every universe size n and adaptive client on Fin n issuing m = history.length operations from
init n, the concrete Batteries.UnionFind execution agrees with Partition n and records at
most m * (5 * Nat.inverseAckermannTwo m n + 2) pointer/link steps (excluding init n).
Linear abstract step-count corollary of tarjan_run_two_param: whenever n * Nat.log 2 n ≤ m,
every m-operation adaptive client on Fin n records at most 7 * m pointer/link steps
(excluding init n).