This module includes a dependently typed adaption of the Lean.RBMap
defined in Lean.Data.RBMap
module of the Lean core. Most of the code is
copied directly from there with only minor edits.
@[specialize #[]]
def
Lake.RBNode.dFind
{α : Type u}
{β : α → Type v}
(cmp : α → α → Ordering)
[h : Lake.EqOfCmpWrt α β cmp]
:
Lean.RBNode α β → (k : α) → Option (β k)
Equations
- One or more equations did not get rendered due to their size.
- Lake.RBNode.dFind cmp Lean.RBNode.leaf x = none
Instances For
A Dependently typed RBMap
.
Equations
- Lake.DRBMap α β cmp = { t // Lean.RBNode.WellFormed cmp t }
Instances For
instance
Lake.instCoeDRBMapRBMap
{α : Type u_1}
{β : Type u_2}
{cmp : α → α → Ordering}
:
Coe (Lake.DRBMap α (fun x => β) cmp) (Lean.RBMap α β cmp)
Equations
- Lake.instCoeDRBMapRBMap = { coe := id }
@[inline]
Equations
- Lake.mkDRBMap α β cmp = { val := Lean.RBNode.leaf, property := (_ : Lean.RBNode.WellFormed cmp Lean.RBNode.leaf) }
Instances For
instance
Lake.instEmptyCollectionDRBMap
(α : Type u)
(β : α → Type v)
(cmp : α → α → Ordering)
:
EmptyCollection (Lake.DRBMap α β cmp)
Equations
- Lake.instEmptyCollectionDRBMap α β cmp = { emptyCollection := Lake.DRBMap.empty }
def
Lake.DRBMap.depth
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
(f : Nat → Nat → Nat)
(t : Lake.DRBMap α β cmp)
:
Equations
- Lake.DRBMap.depth f t = Lean.RBNode.depth f t.val
Instances For
@[inline]
def
Lake.DRBMap.fold
{α : Type u}
{β : α → Type v}
{σ : Type w}
{cmp : α → α → Ordering}
(f : σ → (k : α) → β k → σ)
(init : σ)
:
Lake.DRBMap α β cmp → σ
Equations
- Lake.DRBMap.fold f x x = match x, x with | b, { val := t, property := property } => Lean.RBNode.fold f b t
Instances For
@[inline]
def
Lake.DRBMap.revFold
{α : Type u}
{β : α → Type v}
{σ : Type w}
{cmp : α → α → Ordering}
(f : σ → (k : α) → β k → σ)
(init : σ)
:
Lake.DRBMap α β cmp → σ
Equations
- Lake.DRBMap.revFold f x x = match x, x with | b, { val := t, property := property } => Lean.RBNode.revFold f b t
Instances For
@[inline]
def
Lake.DRBMap.foldM
{α : Type u}
{β : α → Type v}
{σ : Type w}
{cmp : α → α → Ordering}
{m : Type w → Type u_1}
[Monad m]
(f : σ → (k : α) → β k → m σ)
(init : σ)
:
Lake.DRBMap α β cmp → m σ
Equations
- Lake.DRBMap.foldM f x x = match x, x with | b, { val := t, property := property } => Lean.RBNode.foldM f b t
Instances For
@[inline]
def
Lake.DRBMap.forM
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
{m : Type u_1 → Type u_2}
[Monad m]
(f : (k : α) → β k → m PUnit)
(t : Lake.DRBMap α β cmp)
:
m PUnit
Equations
- Lake.DRBMap.forM f t = Lake.DRBMap.foldM (fun x k v => f k v) PUnit.unit t
Instances For
@[inline]
def
Lake.DRBMap.forIn
{α : Type u}
{β : α → Type v}
{σ : Type w}
{cmp : α → α → Ordering}
{m : Type w → Type u_1}
[Monad m]
(t : Lake.DRBMap α β cmp)
(init : σ)
(f : (k : α) × β k → σ → m (ForInStep σ))
:
m σ
Equations
- Lake.DRBMap.forIn t init f = Lean.RBNode.forIn t.val init fun a b acc => f { fst := a, snd := b } acc
Instances For
@[inline]
def
Lake.DRBMap.isEmpty
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
:
Lake.DRBMap α β cmp → Bool
Equations
- Lake.DRBMap.isEmpty x = match x with | { val := Lean.RBNode.leaf, property := property } => true | x => false
Instances For
@[specialize #[]]
def
Lake.DRBMap.toList
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
:
Lake.DRBMap α β cmp → List ((k : α) × β k)
Equations
- Lake.DRBMap.toList x = match x with | { val := t, property := property } => Lean.RBNode.revFold (fun ps k v => { fst := k, snd := v } :: ps) [] t
Instances For
@[inline]
def
Lake.DRBMap.min
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
:
Lake.DRBMap α β cmp → Option ((k : α) × β k)
Equations
- Lake.DRBMap.min x = match x with | { val := t, property := property } => match Lean.RBNode.min t with | some { fst := k, snd := v } => some { fst := k, snd := v } | none => none
Instances For
@[inline]
def
Lake.DRBMap.max
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
:
Lake.DRBMap α β cmp → Option ((k : α) × β k)
Equations
- Lake.DRBMap.max x = match x with | { val := t, property := property } => match Lean.RBNode.max t with | some { fst := k, snd := v } => some { fst := k, snd := v } | none => none
Instances For
instance
Lake.DRBMap.instReprDRBMap
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
[Repr ((k : α) × β k)]
:
Repr (Lake.DRBMap α β cmp)
Equations
- Lake.DRBMap.instReprDRBMap = { reprPrec := fun m prec => Repr.addAppParen (Std.Format.text "Lake.drbmapOf " ++ repr (Lake.DRBMap.toList m)) prec }
@[inline]
def
Lake.DRBMap.insert
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
:
Lake.DRBMap α β cmp → (k : α) → β k → Lake.DRBMap α β cmp
Equations
- One or more equations did not get rendered due to their size.
Instances For
@[inline]
def
Lake.DRBMap.erase
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
:
Lake.DRBMap α β cmp → α → Lake.DRBMap α β cmp
Equations
- Lake.DRBMap.erase x x = match x, x with | { val := t, property := w }, k => { val := Lean.RBNode.erase cmp k t, property := (_ : Lean.RBNode.WellFormed cmp (Lean.RBNode.erase cmp k t)) }
Instances For
@[specialize #[]]
def
Lake.DRBMap.ofList
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
:
List ((k : α) × β k) → Lake.DRBMap α β cmp
Equations
- Lake.DRBMap.ofList [] = Lake.mkDRBMap α β cmp
- Lake.DRBMap.ofList ({ fst := k, snd := v } :: xs) = Lake.DRBMap.insert (Lake.DRBMap.ofList xs) k v
Instances For
@[inline]
def
Lake.DRBMap.findCore?
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
:
Lake.DRBMap α β cmp → α → Option ((k : α) × β k)
Equations
- Lake.DRBMap.findCore? x x = match x, x with | { val := t, property := property }, x => Lean.RBNode.findCore cmp t x
Instances For
@[inline]
def
Lake.DRBMap.find?
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
[Lake.EqOfCmpWrt α β cmp]
:
Lake.DRBMap α β cmp → (k : α) → Option (β k)
Equations
- Lake.DRBMap.find? x x = match x, x with | { val := t, property := property }, x => Lake.RBNode.dFind cmp t x
Instances For
@[inline]
def
Lake.DRBMap.findD
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
[Lake.EqOfCmpWrt α β cmp]
(t : Lake.DRBMap α β cmp)
(k : α)
(v₀ : β k)
:
β k
Equations
- Lake.DRBMap.findD t k v₀ = Option.getD (Lake.DRBMap.find? t k) v₀
Instances For
@[inline]
def
Lake.DRBMap.lowerBound
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
:
Lake.DRBMap α β cmp → α → Option ((k : α) × β k)
(lowerBound k) retrieves the kv pair of the largest key smaller than or equal to k
,
if it exists.
Equations
- Lake.DRBMap.lowerBound x x = match x, x with | { val := t, property := property }, x => Lean.RBNode.lowerBound cmp t x none
Instances For
@[inline]
def
Lake.DRBMap.contains
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
[Lake.EqOfCmpWrt α β cmp]
(t : Lake.DRBMap α β cmp)
(k : α)
:
Equations
- Lake.DRBMap.contains t k = Option.isSome (Lake.DRBMap.find? t k)
Instances For
@[inline]
def
Lake.DRBMap.fromList
{α : Type u}
{β : α → Type v}
(l : List ((k : α) × β k))
(cmp : α → α → Ordering)
:
Lake.DRBMap α β cmp
Equations
- Lake.DRBMap.fromList l cmp = List.foldl (fun r p => Lake.DRBMap.insert r p.fst p.snd) (Lake.mkDRBMap α β cmp) l
Instances For
@[inline]
def
Lake.DRBMap.all
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
:
Lake.DRBMap α β cmp → ((k : α) → β k → Bool) → Bool
Equations
- Lake.DRBMap.all x x = match x, x with | { val := t, property := property }, p => Lean.RBNode.all p t
Instances For
@[inline]
def
Lake.DRBMap.any
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
:
Lake.DRBMap α β cmp → ((k : α) → β k → Bool) → Bool
Equations
- Lake.DRBMap.any x x = match x, x with | { val := t, property := property }, p => Lean.RBNode.any p t
Instances For
def
Lake.DRBMap.size
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
(m : Lake.DRBMap α β cmp)
:
Equations
- Lake.DRBMap.size m = Lake.DRBMap.fold (fun sz x x => sz + 1) 0 m
Instances For
def
Lake.DRBMap.maxDepth
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
(t : Lake.DRBMap α β cmp)
:
Equations
Instances For
@[inline]
def
Lake.DRBMap.min!
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
[Inhabited ((k : α) × β k)]
(t : Lake.DRBMap α β cmp)
:
(k : α) × β k
Equations
- Lake.DRBMap.min! t = match Lake.DRBMap.min t with | some p => p | none => panicWithPosWithDecl "Lake.Util.DRBMap" "Lake.DRBMap.min!" 136 14 "map is empty"
Instances For
@[inline]
def
Lake.DRBMap.max!
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
[Inhabited ((k : α) × β k)]
(t : Lake.DRBMap α β cmp)
:
(k : α) × β k
Equations
- Lake.DRBMap.max! t = match Lake.DRBMap.max t with | some p => p | none => panicWithPosWithDecl "Lake.Util.DRBMap" "Lake.DRBMap.max!" 141 14 "map is empty"
Instances For
@[inline]
def
Lake.DRBMap.find!
{α : Type u}
{β : α → Type v}
{cmp : α → α → Ordering}
[Lake.EqOfCmpWrt α β cmp]
(t : Lake.DRBMap α β cmp)
(k : α)
[Inhabited (β k)]
:
β k
Equations
- One or more equations did not get rendered due to their size.
Instances For
def
Lake.drbmapOf
{α : Type u}
{β : α → Type v}
(l : List ((k : α) × β k))
(cmp : α → α → Ordering)
:
Lake.DRBMap α β cmp
Equations
- Lake.drbmapOf l cmp = Lake.DRBMap.fromList l cmp