- leaf: {α : Type u} → {β : α → Type v} → Lean.RBNode α β
- node: {α : Type u} → {β : α → Type v} → Lean.RBColor → Lean.RBNode α β → (key : α) → β key → Lean.RBNode α β → Lean.RBNode α β
Equations
- Lean.RBNode.depth f Lean.RBNode.leaf = 0
- Lean.RBNode.depth f (Lean.RBNode.node color l key val r) = (f (Lean.RBNode.depth f l) (Lean.RBNode.depth f r)).succ
Equations
- Lean.RBNode.leaf.min = none
- (Lean.RBNode.node color Lean.RBNode.leaf k v rchild).min = some ⟨k, v⟩
- (Lean.RBNode.node color l key val rchild).min = l.min
Equations
- Lean.RBNode.leaf.max = none
- (Lean.RBNode.node color lchild k v Lean.RBNode.leaf).max = some ⟨k, v⟩
- (Lean.RBNode.node color lchild key val r).max = r.max
@[specialize #[]]
def
Lean.RBNode.fold
{α : Type u}
{β : α → Type v}
{σ : Type w}
(f : σ → (k : α) → β k → σ)
(init : σ)
:
Lean.RBNode α β → σ
Equations
- Lean.RBNode.fold f x Lean.RBNode.leaf = x
- Lean.RBNode.fold f x (Lean.RBNode.node color l k v r) = Lean.RBNode.fold f (f (Lean.RBNode.fold f x l) k v) r
@[specialize #[]]
def
Lean.RBNode.forM
{α : Type u}
{β : α → Type v}
{m : Type → Type u_1}
[Monad m]
(f : (k : α) → β k → m Unit)
:
Lean.RBNode α β → m Unit
Equations
- Lean.RBNode.forM f Lean.RBNode.leaf = pure ()
- Lean.RBNode.forM f (Lean.RBNode.node color l key val r) = do Lean.RBNode.forM f l f key val Lean.RBNode.forM f r
@[specialize #[]]
def
Lean.RBNode.foldM
{α : Type u}
{β : α → Type v}
{σ : Type w}
{m : Type w → Type u_1}
[Monad m]
(f : σ → (k : α) → β k → m σ)
(init : σ)
:
Lean.RBNode α β → m σ
Equations
- Lean.RBNode.foldM f x Lean.RBNode.leaf = pure x
- Lean.RBNode.foldM f x (Lean.RBNode.node color l k v r) = do let b ← Lean.RBNode.foldM f x l let b ← f b k v Lean.RBNode.foldM f b r
@[inline]
def
Lean.RBNode.forIn
{α : Type u}
{β : α → Type v}
{σ : Type w}
{m : Type w → Type u_1}
[Monad m]
(as : Lean.RBNode α β)
(init : σ)
(f : (k : α) → β k → σ → m (ForInStep σ))
:
m σ
Equations
- as.forIn init f = do let __do_lift ← Lean.RBNode.forIn.visit f as init match __do_lift with | ForInStep.done b => pure b | ForInStep.yield b => pure b
@[specialize #[]]
def
Lean.RBNode.forIn.visit
{α : Type u}
{β : α → Type v}
{σ : Type w}
{m : Type w → Type u_1}
[Monad m]
(f : (k : α) → β k → σ → m (ForInStep σ))
:
Lean.RBNode α β → σ → m (ForInStep σ)
Equations
- One or more equations did not get rendered due to their size.
- Lean.RBNode.forIn.visit f Lean.RBNode.leaf x = pure (ForInStep.yield x)
@[specialize #[]]
def
Lean.RBNode.revFold
{α : Type u}
{β : α → Type v}
{σ : Type w}
(f : σ → (k : α) → β k → σ)
(init : σ)
:
Lean.RBNode α β → σ
Equations
- Lean.RBNode.revFold f x Lean.RBNode.leaf = x
- Lean.RBNode.revFold f x (Lean.RBNode.node color l k v r) = Lean.RBNode.revFold f (f (Lean.RBNode.revFold f x r) k v) l
@[specialize #[]]
def
Lean.RBNode.all
{α : Type u}
{β : α → Type v}
(p : (k : α) → β k → Bool)
:
Lean.RBNode α β → Bool
Equations
- Lean.RBNode.all p Lean.RBNode.leaf = true
- Lean.RBNode.all p (Lean.RBNode.node color l key val r) = (p key val && Lean.RBNode.all p l && Lean.RBNode.all p r)
@[specialize #[]]
def
Lean.RBNode.any
{α : Type u}
{β : α → Type v}
(p : (k : α) → β k → Bool)
:
Lean.RBNode α β → Bool
Equations
- Lean.RBNode.any p Lean.RBNode.leaf = false
- Lean.RBNode.any p (Lean.RBNode.node color l key val r) = (p key val || Lean.RBNode.any p l || Lean.RBNode.any p r)
Equations
- Lean.RBNode.singleton k v = Lean.RBNode.node Lean.RBColor.red Lean.RBNode.leaf k v Lean.RBNode.leaf
@[inline]
def
Lean.RBNode.balance1
{α : Type u}
{β : α → Type v}
:
Lean.RBNode α β → (a : α) → β a → Lean.RBNode α β → Lean.RBNode α β
Equations
- One or more equations did not get rendered due to their size.
@[inline]
def
Lean.RBNode.balance2
{α : Type u}
{β : α → Type v}
:
Lean.RBNode α β → (a : α) → β a → Lean.RBNode α β → Lean.RBNode α β
Equations
- One or more equations did not get rendered due to their size.
Equations
- x.isRed = match x with | Lean.RBNode.node Lean.RBColor.red lchild key val rchild => true | x => false
Equations
- x.isBlack = match x with | Lean.RBNode.node Lean.RBColor.black lchild key val rchild => true | x => false
@[specialize #[]]
def
Lean.RBNode.ins
{α : Type u}
{β : α → Type v}
(cmp : α → α → Ordering)
:
Lean.RBNode α β → (k : α) → β k → Lean.RBNode α β
Equations
- One or more equations did not get rendered due to their size.
- Lean.RBNode.ins cmp Lean.RBNode.leaf x✝ x = Lean.RBNode.node Lean.RBColor.red Lean.RBNode.leaf x✝ x Lean.RBNode.leaf
Equations
- x.setBlack = match x with | Lean.RBNode.node color l k v r => Lean.RBNode.node Lean.RBColor.black l k v r | e => e
@[specialize #[]]
def
Lean.RBNode.insert
{α : Type u}
{β : α → Type v}
(cmp : α → α → Ordering)
(t : Lean.RBNode α β)
(k : α)
(v : β k)
:
Lean.RBNode α β
Equations
- Lean.RBNode.insert cmp t k v = if t.isRed = true then (Lean.RBNode.ins cmp t k v).setBlack else Lean.RBNode.ins cmp t k v
Equations
- x.setRed = match x with | Lean.RBNode.node color a k v b => Lean.RBNode.node Lean.RBColor.red a k v b | e => e
def
Lean.RBNode.balLeft
{α : Type u}
{β : α → Type v}
:
Lean.RBNode α β → (k : α) → β k → Lean.RBNode α β → Lean.RBNode α β
Equations
- One or more equations did not get rendered due to their size.
def
Lean.RBNode.balRight
{α : Type u}
{β : α → Type v}
(l : Lean.RBNode α β)
(k : α)
(v : β k)
(r : Lean.RBNode α β)
:
Lean.RBNode α β
Equations
- One or more equations did not get rendered due to their size.
The number of nodes in the tree.
Equations
- Lean.RBNode.leaf.size = 0
- (Lean.RBNode.node color l key val r).size = l.size + r.size + 1
@[irreducible]
def
Lean.RBNode.appendTrees
{α : Type u}
{β : α → Type v}
:
Lean.RBNode α β → Lean.RBNode α β → Lean.RBNode α β
@[specialize #[]]
def
Lean.RBNode.del
{α : Type u}
{β : α → Type v}
(cmp : α → α → Ordering)
(x : α)
:
Lean.RBNode α β → Lean.RBNode α β
Equations
- One or more equations did not get rendered due to their size.
- Lean.RBNode.del cmp x Lean.RBNode.leaf = Lean.RBNode.leaf
@[specialize #[]]
def
Lean.RBNode.erase
{α : Type u}
{β : α → Type v}
(cmp : α → α → Ordering)
(x : α)
(t : Lean.RBNode α β)
:
Lean.RBNode α β
Equations
- Lean.RBNode.erase cmp x t = let t := Lean.RBNode.del cmp x t; t.setBlack
@[specialize #[]]
def
Lean.RBNode.findCore
{α : Type u}
{β : α → Type v}
(cmp : α → α → Ordering)
:
Lean.RBNode α β → α → Option ((k : α) × β k)
Equations
- One or more equations did not get rendered due to their size.
- Lean.RBNode.findCore cmp Lean.RBNode.leaf x = none
@[specialize #[]]
def
Lean.RBNode.find
{α : Type u}
(cmp : α → α → Ordering)
{β : Type v}
:
(Lean.RBNode α fun (x : α) => β) → α → Option β
Equations
- Lean.RBNode.find cmp Lean.RBNode.leaf x = none
- Lean.RBNode.find cmp (Lean.RBNode.node color a ky vy b) x = match cmp x ky with | Ordering.lt => Lean.RBNode.find cmp a x | Ordering.gt => Lean.RBNode.find cmp b x | Ordering.eq => some vy
@[specialize #[]]
def
Lean.RBNode.lowerBound
{α : Type u}
{β : α → Type v}
(cmp : α → α → Ordering)
:
Lean.RBNode α β → α → Option (Sigma β) → Option (Sigma β)
Equations
- One or more equations did not get rendered due to their size.
- Lean.RBNode.lowerBound cmp Lean.RBNode.leaf x✝ x = x
inductive
Lean.RBNode.WellFormed
{α : Type u}
{β : α → Type v}
(cmp : α → α → Ordering)
:
Lean.RBNode α β → Prop
- leafWff: ∀ {α : Type u} {β : α → Type v} {cmp : α → α → Ordering}, Lean.RBNode.WellFormed cmp Lean.RBNode.leaf
- insertWff: ∀ {α : Type u} {β : α → Type v} {cmp : α → α → Ordering} {n n' : Lean.RBNode α β} {k : α} {v : β k}, Lean.RBNode.WellFormed cmp n → n' = Lean.RBNode.insert cmp n k v → Lean.RBNode.WellFormed cmp n'
- eraseWff: ∀ {α : Type u} {β : α → Type v} {cmp : α → α → Ordering} {n n' : Lean.RBNode α β} {k : α}, Lean.RBNode.WellFormed cmp n → n' = Lean.RBNode.erase cmp k n → Lean.RBNode.WellFormed cmp n'
@[specialize #[]]
def
Lean.RBNode.mapM
{α : Type v}
{β : α → Type v}
{γ : α → Type v}
{M : Type v → Type v}
[Applicative M]
(f : (a : α) → β a → M (γ a))
:
Lean.RBNode α β → M (Lean.RBNode α γ)
Equations
- One or more equations did not get rendered due to their size.
- Lean.RBNode.mapM f Lean.RBNode.leaf = pure Lean.RBNode.leaf
@[specialize #[]]
def
Lean.RBNode.map
{α : Type u}
{β : α → Type v}
{γ : α → Type v}
(f : (a : α) → β a → γ a)
:
Lean.RBNode α β → Lean.RBNode α γ
Equations
- Lean.RBNode.map f Lean.RBNode.leaf = Lean.RBNode.leaf
- Lean.RBNode.map f (Lean.RBNode.node color l key val r) = Lean.RBNode.node color (Lean.RBNode.map f l) key (f key val) (Lean.RBNode.map f r)
Equations
- n.toArray = Lean.RBNode.fold (fun (acc : Array (Sigma β)) (k : α) (v : β k) => acc.push ⟨k, v⟩) ∅ n
instance
Lean.RBNode.instEmptyCollection
{α : Type u}
{β : α → Type v}
:
EmptyCollection (Lean.RBNode α β)
Equations
- Lean.RBNode.instEmptyCollection = { emptyCollection := Lean.RBNode.leaf }
Equations
- Lean.RBMap α β cmp = { t : Lean.RBNode α fun (x : α) => β // Lean.RBNode.WellFormed cmp t }
@[inline]
Equations
- Lean.mkRBMap α β cmp = ⟨Lean.RBNode.leaf, ⋯⟩
@[inline]
Equations
- Lean.RBMap.empty = Lean.mkRBMap α β cmp
instance
Lean.instEmptyCollectionRBMap
(α : Type u)
(β : Type v)
(cmp : α → α → Ordering)
:
EmptyCollection (Lean.RBMap α β cmp)
Equations
- Lean.instEmptyCollectionRBMap α β cmp = { emptyCollection := Lean.RBMap.empty }
instance
Lean.instInhabitedRBMap
(α : Type u)
(β : Type v)
(cmp : α → α → Ordering)
:
Inhabited (Lean.RBMap α β cmp)
Equations
- Lean.instInhabitedRBMap α β cmp = { default := ∅ }
def
Lean.RBMap.depth
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
(f : Nat → Nat → Nat)
(t : Lean.RBMap α β cmp)
:
Equations
- Lean.RBMap.depth f t = Lean.RBNode.depth f t.val
@[inline]
def
Lean.RBMap.fold
{α : Type u}
{β : Type v}
{σ : Type w}
{cmp : α → α → Ordering}
(f : σ → α → β → σ)
(init : σ)
:
Lean.RBMap α β cmp → σ
Equations
- Lean.RBMap.fold f x✝ x = match x✝, x with | b, ⟨t, property⟩ => Lean.RBNode.fold f b t
@[inline]
def
Lean.RBMap.revFold
{α : Type u}
{β : Type v}
{σ : Type w}
{cmp : α → α → Ordering}
(f : σ → α → β → σ)
(init : σ)
:
Lean.RBMap α β cmp → σ
Equations
- Lean.RBMap.revFold f x✝ x = match x✝, x with | b, ⟨t, property⟩ => Lean.RBNode.revFold f b t
@[inline]
def
Lean.RBMap.foldM
{α : Type u}
{β : Type v}
{σ : Type w}
{cmp : α → α → Ordering}
{m : Type w → Type u_1}
[Monad m]
(f : σ → α → β → m σ)
(init : σ)
:
Lean.RBMap α β cmp → m σ
Equations
- Lean.RBMap.foldM f x✝ x = match x✝, x with | b, ⟨t, property⟩ => Lean.RBNode.foldM f b t
@[inline]
def
Lean.RBMap.forM
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
{m : Type u_1 → Type u_2}
[Monad m]
(f : α → β → m PUnit)
(t : Lean.RBMap α β cmp)
:
m PUnit
Equations
- Lean.RBMap.forM f t = Lean.RBMap.foldM (fun (x : PUnit) (k : α) (v : β) => f k v) PUnit.unit t
@[inline]
def
Lean.RBMap.isEmpty
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
:
Lean.RBMap α β cmp → Bool
@[specialize #[]]
def
Lean.RBMap.toList
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
:
Lean.RBMap α β cmp → List (α × β)
Equations
- x.toList = match x with | ⟨t, property⟩ => Lean.RBNode.revFold (fun (ps : List (α × β)) (k : α) (v : β) => (k, v) :: ps) [] t
instance
Lean.RBMap.instRepr
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
[Repr α]
[Repr β]
:
Repr (Lean.RBMap α β cmp)
Equations
- Lean.RBMap.instRepr = { reprPrec := fun (m : Lean.RBMap α β cmp) (prec : Nat) => Repr.addAppParen (Std.Format.text "Lean.rbmapOf " ++ repr m.toList) prec }
@[inline]
def
Lean.RBMap.insert
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
:
Lean.RBMap α β cmp → α → β → Lean.RBMap α β cmp
Equations
- x✝¹.insert x✝ x = match x✝¹, x✝, x with | ⟨t, w⟩, k, v => ⟨Lean.RBNode.insert cmp t k v, ⋯⟩
@[inline]
def
Lean.RBMap.erase
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
:
Lean.RBMap α β cmp → α → Lean.RBMap α β cmp
Equations
- x✝.erase x = match x✝, x with | ⟨t, w⟩, k => ⟨Lean.RBNode.erase cmp k t, ⋯⟩
@[specialize #[]]
def
Lean.RBMap.ofList
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
:
List (α × β) → Lean.RBMap α β cmp
Equations
- Lean.RBMap.ofList [] = Lean.mkRBMap α β cmp
- Lean.RBMap.ofList ((k, v) :: xs) = (Lean.RBMap.ofList xs).insert k v
@[inline]
def
Lean.RBMap.findCore?
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
:
Lean.RBMap α β cmp → α → Option ((_ : α) × β)
Equations
- x✝.findCore? x = match x✝, x with | ⟨t, property⟩, x => Lean.RBNode.findCore cmp t x
@[inline]
def
Lean.RBMap.find?
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
:
Lean.RBMap α β cmp → α → Option β
Equations
- x✝.find? x = match x✝, x with | ⟨t, property⟩, x => Lean.RBNode.find cmp t x
@[inline]
def
Lean.RBMap.findD
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
(t : Lean.RBMap α β cmp)
(k : α)
(v₀ : β)
:
β
Equations
- t.findD k v₀ = (t.find? k).getD v₀
@[inline]
def
Lean.RBMap.lowerBound
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
:
Lean.RBMap α β cmp → α → Option ((_ : α) × β)
(lowerBound k) retrieves the kv pair of the largest key smaller than or equal to k
,
if it exists.
Equations
- x✝.lowerBound x = match x✝, x with | ⟨t, property⟩, x => Lean.RBNode.lowerBound cmp t x none
@[inline]
def
Lean.RBMap.contains
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
(t : Lean.RBMap α β cmp)
(a : α)
:
Returns true if the given key a
is in the RBMap.
Equations
- t.contains a = (t.find? a).isSome
@[inline]
def
Lean.RBMap.fromList
{α : Type u}
{β : Type v}
(l : List (α × β))
(cmp : α → α → Ordering)
:
Lean.RBMap α β cmp
Equations
- Lean.RBMap.fromList l cmp = List.foldl (fun (r : Lean.RBMap α β cmp) (p : α × β) => r.insert p.fst p.snd) (Lean.mkRBMap α β cmp) l
@[inline]
def
Lean.RBMap.fromArray
{α : Type u}
{β : Type v}
(l : Array (α × β))
(cmp : α → α → Ordering)
:
Lean.RBMap α β cmp
Equations
- Lean.RBMap.fromArray l cmp = Array.foldl (fun (r : Lean.RBMap α β cmp) (p : α × β) => r.insert p.fst p.snd) (Lean.mkRBMap α β cmp) l 0
@[inline]
def
Lean.RBMap.all
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
:
Lean.RBMap α β cmp → (α → β → Bool) → Bool
Returns true if the given predicate is true for all items in the RBMap.
Equations
- x✝.all x = match x✝, x with | ⟨t, property⟩, p => Lean.RBNode.all p t
@[inline]
def
Lean.RBMap.any
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
:
Lean.RBMap α β cmp → (α → β → Bool) → Bool
Returns true if the given predicate is true for any item in the RBMap.
Equations
- x✝.any x = match x✝, x with | ⟨t, property⟩, p => Lean.RBNode.any p t
The number of items in the RBMap.
Equations
- m.size = Lean.RBMap.fold (fun (sz : Nat) (x : α) (x : β) => sz + 1) 0 m
def
Lean.RBMap.maxDepth
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
(t : Lean.RBMap α β cmp)
:
Equations
- t.maxDepth = Lean.RBNode.depth Nat.max t.val
@[inline]
def
Lean.RBMap.min!
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
[Inhabited α]
[Inhabited β]
(t : Lean.RBMap α β cmp)
:
α × β
Equations
- t.min! = match t.min with | some p => p | none => panicWithPosWithDecl "Lean.Data.RBMap" "Lean.RBMap.min!" 366 14 "map is empty"
@[inline]
def
Lean.RBMap.max!
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
[Inhabited α]
[Inhabited β]
(t : Lean.RBMap α β cmp)
:
α × β
Equations
- t.max! = match t.max with | some p => p | none => panicWithPosWithDecl "Lean.Data.RBMap" "Lean.RBMap.max!" 371 14 "map is empty"
@[inline]
def
Lean.RBMap.find!
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
[Inhabited β]
(t : Lean.RBMap α β cmp)
(k : α)
:
β
Attempts to find the value with key k : α
in t
and panics if there is no such key.
Equations
- t.find! k = match t.find? k with | some b => b | none => panicWithPosWithDecl "Lean.Data.RBMap" "Lean.RBMap.find!" 377 14 "key is not in the map"
def
Lean.RBMap.mergeBy
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
(mergeFn : α → β → β → β)
(t₁ : Lean.RBMap α β cmp)
(t₂ : Lean.RBMap α β cmp)
:
Lean.RBMap α β cmp
Merges the maps t₁
and t₂
, if a key a : α
exists in both,
then use mergeFn a b₁ b₂
to produce the new merged value.
Equations
- One or more equations did not get rendered due to their size.
def
Lean.RBMap.intersectBy
{α : Type u}
{β : Type v}
{cmp : α → α → Ordering}
{γ : Type v₁}
{δ : Type v₂}
(mergeFn : α → β → γ → δ)
(t₁ : Lean.RBMap α β cmp)
(t₂ : Lean.RBMap α γ cmp)
:
Lean.RBMap α δ cmp
Intersects the maps t₁
and t₂
using mergeFn a b₁ b₂
to produce the new value.
Equations
- One or more equations did not get rendered due to their size.
def
Lean.rbmapOf
{α : Type u}
{β : Type v}
(l : List (α × β))
(cmp : α → α → Ordering)
:
Lean.RBMap α β cmp
Equations
- Lean.rbmapOf l cmp = Lean.RBMap.fromList l cmp