Reference · The Applied Higher-Order Functions catalogue
rainbow.algorithms.proofs.ahof.union-find
AHoF Union-Find (Disjoint-Set) connectivity: maintain a partition of elements into disjoint sets under union operations, answering connectivity queries by comparing set representatives. Two elements are connected exactly when they have the same representative -- an equality decided by antisymmetry (each is at most the other): connected? ra rb = (ra <= rb) AND (rb <= ra) over the exact-rational representative ids. Proved native and axiom-free: the connectivity test as a boolean conjunction of two decidable comparisons; that equal representatives are connected; that distinct representatives are not; and the certificate that connected elements' representatives coincide (each <= the other as native nnrat/at-most, i.e. antisymmetry). The union operation and the find-with-path-compression are executable; what is proved is the connectivity decision. This is the connectivity primitive behind Kruskal's MST and dynamic connectivity. Requires audit/decide-nnrat-at-most, logic/if-data, nnrat/at-most, nnrat/decide-at-most-true-sound (all in the D63 checkpoint). Scope (measured by the kernel): this module has 3 worked instances (statements about specific values). None of its theorems is a guarantee about the algorithm for all inputs; `lein verify rainbow.algorithms.proofs.ahof.union-find` prints this classification.
union-find/connected?
union-find/connected? : (x₁ x₂ : ℚ≥0) → data/Bool
ℚ≥0 = nnrat/NonnegativeRational
union-find/same-representative-connected
union-find/same-representative-connected : → floyd-cycle/meet? 3 3 = data/true
= = equality/Eq
union-find/different-representative-disconnected
union-find/different-representative-disconnected : → floyd-cycle/meet? 3 5 = data/false
= = equality/Eq
union-find/connected-implies-le
union-find/connected-implies-le : → 3 ≤ 3
≤ = nnrat/at-most