Documentation

Lean.Data.BudgetedCache

class Lean.BudgetedBEq (α : Type u) :

Equality for cache keys with a work budget. .undef means the comparison exhausted its budget. The comparison may break referential transparency by depending on pointer sharing, so it runs in BaseIO. A definite result must agree with the key's intended equality.

Instances
    structure Lean.BudgetedCache (α : Type u) (β : Type v) [Hashable α] :
    Type (max u v)

    A persistent cache storing one candidate per full hash. Insertion replaces both the key and value for that hash. Lookup verifies the candidate with budgeted equality and evicts it on exhaustion. Hash retrieval must take constant time; structural key equality is never used by the backing map.

    Instances For
      @[instance_reducible]
      instance Lean.instInhabitedBudgetedCache {a✝ : Type u_1} {a✝¹ : Type u_2} {a✝² : Hashable a✝} :
      Inhabited (BudgetedCache a✝ a✝¹)
      Equations
      @[instance_reducible]
      Equations
      @[inline]
      def Lean.BudgetedCache.insert {α : Type u} {β : Type v} [Hashable α] (c : BudgetedCache α β) (key : α) (value : β) :
      Equations
      Instances For
        @[inline]
        def Lean.BudgetedCache.find? {α : Type u} [Hashable α] {β : Type} [BudgetedBEq α] {m : Type → Type w} [Monad m] [MonadLiftT BaseIO m] (c : BudgetedCache α β) (key : α) (onEvict : BudgetedCache α β → m Unit) (budget : USize := 64) :
        m (Option β)

        Finds a cached value with the given comparison budget, as interpreted by BudgetedBEq. On exhaustion, calls onEvict with the cache after erasing the candidate. The caller must retain this update. Hits, absent hashes, and definite inequality do not call onEvict.

        Equations
        • One or more equations did not get rendered due to their size.
        Instances For