Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Complexity.lean
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,11 @@ public import Complexity.Algorithms.Lean.Sort.Bitonic.ZeroOne
public import Complexity.Algorithms.Lean.UniformProbing
public import Complexity.Algorithms.Lean.VanEmdeBoas.Basic
public import Complexity.Algorithms.Lean.VanEmdeBoas.Elements
public import Complexity.Algorithms.Lean.VanEmdeBoas.Erase
public import Complexity.Algorithms.Lean.VanEmdeBoas.Insert
public import Complexity.Algorithms.Lean.VanEmdeBoas.Layout
public import Complexity.Algorithms.Lean.VanEmdeBoas.Predecessor
public import Complexity.Algorithms.Lean.VanEmdeBoas.Stateful
public import Complexity.Algorithms.Lean.VanEmdeBoas.Successor
public import Complexity.Algorithms.MatrixMultiplication.Schonhage.Alphabets
public import Complexity.Algorithms.MatrixMultiplication.Schonhage.BandBounds
Expand Down
28 changes: 27 additions & 1 deletion Complexity/Algorithms/Lean/VanEmdeBoas/Elements.lean
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,11 @@ Authors: Samuel Schlesinger
module
-- upstream: candidate

public import Complexity.Algorithms.Lean.VanEmdeBoas.Erase
public import Complexity.Algorithms.Lean.VanEmdeBoas.Insert
public import Complexity.Algorithms.Lean.VanEmdeBoas.Predecessor
public import Complexity.Algorithms.Lean.VanEmdeBoas.Successor
public import Mathlib.Data.Finset.Erase
public import Mathlib.Data.Finset.Filter
public import Mathlib.Data.Finset.Range

Expand All @@ -26,9 +29,12 @@ the observation.
## Main results

* `Tree.mem_elements_iff`: the finite set agrees with the recursive mathematical interpretation.
* `Tree.elements_insert`: insertion adds exactly one key to the finite set.
* `Tree.elements_insert`, `Tree.elements_erase`: insertion and deletion commute with the
finite-set observation.
* `Tree.successor_elements_some_iff`, `Tree.successor_elements_none_iff`: strict successor and
its absence are characterized by the finite set.
* `Tree.predecessor_elements_some_iff`, `Tree.predecessor_elements_none_iff`: strict predecessor
and its absence are characterized by the finite set.

## References

Expand Down Expand Up @@ -77,4 +83,24 @@ theorem successor_elements_none_iff {t : Tree d} (ht : t.Valid) (x : ℕ) :
simp only [mem_elements_iff ht]
exact successor_eq_none_iff ht x

/-- The finite-set observation commutes with deletion of any key `x : ℕ`. -/
theorem elements_erase {t : Tree d} (ht : t.Valid) (x : ℕ) :
(t.erase x).elements = t.elements.erase x := by
ext y
rw [mem_elements_iff (valid_erase ht x), Finset.mem_erase, mem_elements_iff ht]
exact contains_erase ht x y

/-- A successful predecessor is the greatest finite-set element strictly below the query. -/
theorem predecessor_elements_some_iff {t : Tree d} (ht : t.Valid) (x y : ℕ) :
t.predecessor x = some y ↔ y ∈ t.elements ∧ y < x ∧
∀ z, z ∈ t.elements → z < x → z ≤ y := by
simp only [mem_elements_iff ht]
exact predecessor_eq_some_iff ht x y

/-- An absent predecessor means that every finite-set element is at least the query. -/
theorem predecessor_elements_none_iff {t : Tree d} (ht : t.Valid) (x : ℕ) :
t.predecessor x = none ↔ ∀ z, z ∈ t.elements → x ≤ z := by
simp only [mem_elements_iff ht]
exact predecessor_eq_none_iff ht x

end Cslib.Algorithms.Lean.VanEmdeBoas.Tree
Loading
Loading