Tree sets without a bundled well-formedness invariant, suitable for use in nested
inductive types. The well-formedness invariant is called Raw.WF. When in doubt, prefer TreeSet
over TreeSet.Raw. Lemmas about the operations on Std.TreeSet.Raw are available in the
module Std.Data.TreeSet.Raw.Lemmas.
A tree set stores elements of a certain type in a certain order. It depends on a comparator function that defines an ordering on the keys and provides efficient order-dependent queries, such as retrieval of the minimum or maximum.
To ensure that the operations behave as expected, the comparator function cmp should satisfy
certain laws that ensure a consistent ordering:
- If
ais less than (or equal) tob, thenbis greater than (or equal) toaand vice versa (see theOrientedCmptypeclass). - If
ais less than or equal tobandbis, in turn, less than or equal toc, thenais less than or equal toc(see theTransCmptypeclass).
Keys for which cmp a b = Ordering.eq are considered the same, i.e only one of them
can be contained in a single tree set at the same time.
To avoid expensive copies, users should make sure that the tree set is used linearly.
Internally, the tree sets are represented as size-bounded trees, a type of self-balancing binary search tree with efficient order statistic lookups.
- inner : TreeMap.Raw α Unit cmp
Internal implementation detail of the tree set.
Instances For
Well-formedness predicate for tree sets. Users of TreeSet will not need to interact with
this. Users of TreeSet.Raw will need to provide proofs of WF to lemmas and should use lemmas
like WF.empty and WF.insert (which are always named exactly like the operations they are about)
to show that set operations preserve well-formedness. The constructors of this type are internal
implementation details and should not be accessed by users.
Internal implementation detail of the tree map.
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Equations
- Std.TreeSet.Raw.empty = { inner := Std.TreeMap.Raw.empty }
Instances For
Equations
- Std.TreeSet.Raw.instEmptyCollection = { emptyCollection := Std.TreeSet.Raw.empty }
Two tree sets are equivalent in the sense of Equiv iff all the values are equal.
Equations
- Std.TreeSet.Raw.«term_~m_» = Lean.ParserDescr.trailingNode `Std.TreeSet.Raw.«term_~m_» 50 51 (Lean.ParserDescr.binary `andthen (Lean.ParserDescr.symbol " ~m ") (Lean.ParserDescr.cat `term 51))
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Instances For
Equations
- Std.TreeSet.Raw.instInsert = { insert := fun (e : α) (s : Std.TreeSet.Raw α cmp) => s.insert e }
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Equations
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Instances For
Equations
- Std.TreeSet.Raw.instMembership = { mem := fun (t : Std.TreeSet.Raw α cmp) (a : α) => t.contains a = true }
Equations
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Instances For
Checks if given key is contained and returns the key if it is, otherwise none.
The result in the some case is guaranteed to be pointer equal to the key in the map.
Instances For
Retrieves the key from the set that matches a. Ensures that such a key exists by requiring a proof
of a ∈ m. The result is guaranteed to be pointer equal to the key in the set.
Instances For
Checks if given key is contained and returns the key if it is, otherwise panics. If no panic occurs the result is guaranteed to be pointer equal to the key in the set.
Instances For
Checks if given key is contained and returns the key if it is, otherwise fallback.
If they key is contained the result is guaranteed to be pointer equal to the key in the set.
Instances For
We do not provide min for the raw trees.
We do not provide max for the raw trees.
We do not provide entryAtIdx for the raw trees.
Tries to retrieve the smallest element that is greater than or equal to the
given element, returning none if no such element exists.
Instances For
We do not provide getGE, getGT, getLE, getLT for the raw trees.
Tries to retrieve the smallest element that is greater than or equal to the given element, panicking if no such element exists.
Instances For
Tries to retrieve the smallest element that is greater than or equal to the
given element, returning fallback if no such element exists.
Instances For
Tries to retrieve the smallest element that is greater than the given element,
returning fallback if no such element exists.
Instances For
Tries to retrieve the largest element that is less than or equal to the
given element, returning fallback if no such element exists.
Instances For
Tries to retrieve the smallest element that is less than the given element,
returning fallback if no such element exists.
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Equations
- Std.TreeSet.Raw.filter f t = { inner := Std.TreeMap.Raw.filter (fun (a : α) (x : Unit) => f a) t.inner }
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Equations
- Std.TreeSet.Raw.foldlM f init t = Std.TreeMap.Raw.foldlM (fun (c : δ) (a : α) (x : Unit) => f c a) init t.inner
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Equations
- Std.TreeSet.Raw.foldM f init t = Std.TreeSet.Raw.foldlM f init t
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Equations
- Std.TreeSet.Raw.foldl f init t = Std.TreeMap.Raw.foldl (fun (c : δ) (a : α) (x : Unit) => f c a) init t.inner
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Equations
- Std.TreeSet.Raw.fold f init t = Std.TreeSet.Raw.foldl f init t
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Equations
- Std.TreeSet.Raw.foldrM f init t = Std.TreeMap.Raw.foldrM (fun (a : α) (x : Unit) (acc : δ) => f a acc) init t.inner
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Equations
- Std.TreeSet.Raw.foldr f init t = Std.TreeMap.Raw.foldr (fun (a : α) (x : Unit) (acc : δ) => f a acc) init t.inner
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Equations
- Std.TreeSet.Raw.revFold f init t = Std.TreeSet.Raw.foldr (fun (a : α) (acc : δ) => f acc a) init t
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Equations
- Std.TreeSet.Raw.forM f t = Std.TreeMap.Raw.forM (fun (a : α) (x : Unit) => f a) t.inner
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Equations
- Std.TreeSet.Raw.forIn f init t = Std.TreeMap.Raw.forIn (fun (a : α) (x : Unit) (c : δ) => f a c) init t.inner
Instances For
Equations
- Std.TreeSet.Raw.instForM = { forM := fun [Monad m] (t : Std.TreeSet.Raw α cmp) (f : α → m PUnit) => Std.TreeSet.Raw.forM f t }
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Equations
Instances For
Transforms a list into a tree set.
Equations
- Std.TreeSet.Raw.ofList l cmp = { inner := Std.TreeMap.Raw.unitOfList l cmp }
Instances For
Transforms a list into a tree set.
Equations
- Std.TreeSet.Raw.fromList l cmp = Std.TreeSet.Raw.ofList l cmp
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Instances For
Transforms an array into a tree set.
Equations
- Std.TreeSet.Raw.ofArray a cmp = { inner := Std.TreeMap.Raw.unitOfArray a cmp }
Instances For
Transforms an array into a tree set.
Equations
- Std.TreeSet.Raw.fromArray a cmp = Std.TreeSet.Raw.ofArray a cmp
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Equations
Instances For
Inserts multiple elements into the tree set by iterating over the given collection and calling
insert. If the same element (with respect to cmp) appears multiple times, the first occurrence
takes precedence.
Note: this precedence behavior is true for TreeSet and TreeSet.Raw. The insertMany function on
TreeMap, DTreeMap, TreeMap.Raw and DTreeMap.Raw behaves differently: it will prefer the last
appearance.
Equations
- t.insertMany l = { inner := t.inner.insertManyIfNewUnit l }
Instances For
Creates a new empty tree set. It is also possible and recommended to
use the empty collection notations ∅ and {} to create an empty tree set. simp replaces
empty with ∅.
Instances For
Equations
- Std.TreeSet.Raw.instRepr = { reprPrec := fun (m : Std.TreeSet.Raw α cmp) (prec : Nat) => Repr.addAppParen (Std.Format.text "Std.TreeSet.Raw.ofList " ++ repr m.toList) prec }