Skip to content

[WIP] feat(UnionFind): add construction witness#1761

Draft
Oppen wants to merge 6 commits intoleanprover-community:mainfrom
lambdaclass:simplify-unionfind-structure
Draft

[WIP] feat(UnionFind): add construction witness#1761
Oppen wants to merge 6 commits intoleanprover-community:mainfrom
lambdaclass:simplify-unionfind-structure

Conversation

@Oppen
Copy link
Copy Markdown

@Oppen Oppen commented Apr 7, 2026

At the moment, this is just for discussion in Zulip conversation

The new file RankBound.lean is meant to be deleted afterwards. It contains theorems I think I'd need to prove the complexity bounds in CSLib, and would be moved there. Specifically, I care about rank_le_log_subtreeSize. The goal of the PR is enabling me to prove that, so I included it here to make sure it fulfills that goal.

The main change is that UnionFind now requires the arr argument to carry a proof that it was built by applying certain constructors defined as WF.
The link operation now works only between roots of disjoint sets, to avoid depleting members of a set, breaking the rank bounds.

Oppen added 6 commits March 30, 2026 17:52
Remove the redundant `parentD_lt` and `rankD_lt` fields from the
`UnionFind` structure, keeping only `arr` and `valid : WF arr`.

Prove `WF.parentD_lt` and `WF.rankD_lt` by induction on the `WF`
predicate, using `rankD_lt_of_isAncestor` as a helper for the
compress case. These theorems are exposed as abbreviations on
`UnionFind` for backward compatibility.

Also moves `setParentBump_rankD_lt`, `setParent_rankD_lt`, and
`linkAux_size` before the `UnionFind` structure definition since
they operate on raw arrays and are needed by the WF proofs.

The `link` function now requires both `xroot` and `yroot` proofs
(previously only `yroot`) to satisfy the `WF.link` constructor.
@github-actions github-actions bot added the WIP work in progress label Apr 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

WIP work in progress

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant