Documentation

CslibFrontier.DataStructure.VanEmdeBoas.Erase

Single-recursion van Emde Boas deletion #

This module defines and verifies key deletion on recursive minimum-excluded van Emde Boas trees ([Dem15], p. 5; [CLRS09], Section 20.3, p. 554).

At each internal depth d + 1:

These are mathematical correctness statements about the functional Lean representation, without a machine running-time claim.

Main definitions #

Main results #

References #

Header-selected cluster target for an internal-node deletion step (m < M and m ≤ x ≤ M).

  • newMin : ℕ

    Updated local minimum of the parent node.

  • clusterIdx : Fin (universeSize d)

    Index of the cluster from which low is to be removed.

  • low : ℕ

    Low-order coordinate to remove from cluster clusterIdx.

Non-recursive O(1) header helper selecting (newMin, clusterIdx, low) when m < M and m ≤ x ≤ M ([Dem15], p. 5; [CLRS09], Section 20.3, p. 554).

def Cslib.DataStructure.VanEmdeBoas.Tree.clusterMax {d : ℕ} (newMin : ℕ) (s : Tree d) (c : Fin (universeSize d) → Tree d) :

Reconstruct a node's maximum in O(1) header reads from newMin, s.maximum, and the maximal occupied cluster's cached maximum ([Dem15], p. 5; [CLRS09], Section 20.3, p. 554).

Delete a key from a van Emde Boas tree, performing at most one recursive call per depth level ([Dem15], p. 5; [CLRS09], Section 20.3, p. 554).

@[simp]

Deleting any key from the empty tree at depth d returns empty d.

theorem Cslib.DataStructure.VanEmdeBoas.Tree.valid_erase {d : ℕ} {t : Tree d} (ht : t.Valid) (x : ℕ) :
(t.erase x).Valid

Deletion of any key preserves the recursive van Emde Boas representation invariant.

theorem Cslib.DataStructure.VanEmdeBoas.Tree.contains_erase {d : ℕ} {t : Tree d} (ht : t.Valid) (x y : ℕ) :
(t.erase x).Contains y ↔ y ≠ x ∧ t.Contains y

Deletion removes x and preserves membership of every other key.

theorem Cslib.DataStructure.VanEmdeBoas.Tree.erase_eq_of_not_contains {d : ℕ} {t : Tree d} (ht : t.Valid) {x : ℕ} (hx : ¬t.Contains x) :
t.erase x = t

Deleting a key not represented by a valid tree returns the exact tree t.