Documentation

CslibFrontier.DataStructure.OrderedSet.Basic

Optional minima, maxima and strict predecessors of finite ordered sets #

The least- and greatest-result contracts include absence: none means the eligible set is empty. They are independent of any tree, storage representation or cost model. The strict predecessor of a query is the greatest key strictly below it; the strict successor used by Cslib.DataStructure.OrderedSet.spec is least (s.filter (x < ·)).

Main definitions #

Main results #

References #

Uses Mathlib's finite-set minimum, maximum and linear-order API.

A complete optional-minimum contract: none means no eligible key exists.

The mathematical minimum, independent of any representation.

least s satisfies the optional-minimum contract for s.

theorem Cslib.DataStructure.OrderedSet.LeastResult.eq_least {α : Type u_1} [LinearOrder α] {s : Finset α} {a : Option α} (h : LeastResult s a) :
a = least s

Every result satisfying the optional-minimum contract for s is least s.

@[simp]

least agrees with Finset.min (WithTop α is Option α).

A complete optional-maximum contract: none means no eligible key exists.

The mathematical maximum, independent of any representation.

greatest s satisfies the optional-maximum contract for s.

Every result satisfying the optional-maximum contract for s is greatest s.

The optional-maximum contract characterizes greatest.

@[simp]

greatest agrees with Finset.max (WithBot α is Option α).

def Cslib.DataStructure.OrderedSet.predecessor {α : Type u_1} [LinearOrder α] (s : Finset α) (x : α) :

The strict predecessor: the greatest key of s strictly below x, or none.

theorem Cslib.DataStructure.OrderedSet.predecessor_eq_none_iff {α : Type u_1} [LinearOrder α] {s : Finset α} {x : α} :
predecessor s x = none ↔ ∀ b ∈ s, x ≤ b

A strict predecessor is absent exactly when every key is at least the query.

theorem Cslib.DataStructure.OrderedSet.predecessor_eq_some_iff {α : Type u_1} [LinearOrder α] {s : Finset α} {x a : α} :
predecessor s x = some a ↔ a ∈ s ∧ a < x ∧ ∀ b ∈ s, b < x → b ≤ a

A strict predecessor is the greatest key strictly below the query.