chore: move Std.* data structures to Lean.*

This commit is contained in:
Mario Carneiro 2022-09-24 00:09:26 -04:00 committed by Leonardo de Moura
parent fd1ae3118c
commit 85119ba9d1
123 changed files with 223 additions and 291 deletions

View file

@ -52,8 +52,6 @@ structure AttributeImpl extends AttributeImplCore where
erase (decl : Name) : AttrM Unit := throwError "attribute cannot be erased"
deriving Inhabited
open Std (PersistentHashMap)
builtin_initialize attributeMapRef : IO.Ref (PersistentHashMap Name AttributeImpl) ← IO.mkRef {}
/-- Low level attribute registration function. -/
@ -304,7 +302,7 @@ end EnumAttributes
-/
abbrev AttributeImplBuilder := Name → List DataValue → Except String AttributeImpl
abbrev AttributeImplBuilderTable := Std.HashMap Name AttributeImplBuilder
abbrev AttributeImplBuilderTable := HashMap Name AttributeImplBuilder
builtin_initialize attributeImplBuilderTableRef : IO.Ref AttributeImplBuilderTable ← IO.mkRef {}

View file

@ -8,7 +8,7 @@ import Lean.Environment
namespace Lean
structure ClosedTermCache where
map : Std.PHashMap Expr Name := {}
map : PHashMap Expr Name := {}
constNames : NameSet := {}
deriving Inhabited

View file

@ -442,8 +442,6 @@ end Decl
@[export lean_ir_mk_dummy_extern_decl] def mkDummyExternDecl (f : FunId) (xs : Array Param) (ty : IRType) : Decl :=
Decl.fdecl f xs ty FnBody.unreachable {}
open Std (RBTree RBTree.empty RBMap)
/-- Set of variable and join point names -/
abbrev IndexSet := RBTree Index compare
instance : Inhabited IndexSet := ⟨{}⟩
@ -496,7 +494,7 @@ def LocalContext.isLocalVar (ctx : LocalContext) (idx : Index) : Bool :=
| _ => false
def LocalContext.contains (ctx : LocalContext) (idx : Index) : Bool :=
Std.RBMap.contains ctx idx
RBMap.contains ctx idx
def LocalContext.eraseJoinPointDecl (ctx : LocalContext) (j : JoinPointId) : LocalContext :=
ctx.erase j.idx

View file

@ -25,9 +25,9 @@ instance : Hashable Key := ⟨getHash⟩
end OwnedSet
open OwnedSet (Key) in
abbrev OwnedSet := Std.HashMap Key Unit
def OwnedSet.insert (s : OwnedSet) (k : OwnedSet.Key) : OwnedSet := Std.HashMap.insert s k ()
def OwnedSet.contains (s : OwnedSet) (k : OwnedSet.Key) : Bool := Std.HashMap.contains s k
abbrev OwnedSet := HashMap Key Unit
def OwnedSet.insert (s : OwnedSet) (k : OwnedSet.Key) : OwnedSet := HashMap.insert s k ()
def OwnedSet.contains (s : OwnedSet) (k : OwnedSet.Key) : Bool := HashMap.contains s k
/-! We perform borrow inference in a block of mutually recursive functions.
Join points are viewed as local functions, and are identified using
@ -48,7 +48,7 @@ instance : Hashable Key := ⟨getHash⟩
end ParamMap
open ParamMap (Key)
abbrev ParamMap := Std.HashMap Key (Array Param)
abbrev ParamMap := HashMap Key (Array Param)
def ParamMap.fmt (map : ParamMap) : Format :=
let fmts := map.fold (fun fmt k ps =>

View file

@ -27,8 +27,6 @@ Assumptions:
Reason: `resetreuse.lean` ignores `box` and `unbox` instructions.
-/
open Std (AssocList)
def mkBoxedName (n : Name) : Name :=
Name.mkStr n "_boxed"
@ -115,7 +113,7 @@ structure BoxingState where
processing the same IR declaration.
-/
auxDecls : Array Decl := #[]
auxDeclCache : AssocList FnBody Expr := Std.AssocList.empty
auxDeclCache : AssocList FnBody Expr := AssocList.empty
nextAuxId : Nat := 1
abbrev M := ReaderT BoxingContext (StateT BoxingState Id)

View file

@ -69,8 +69,6 @@ private def logMessageIfAux {α : Type} [ToFormat α] (optName : Name) (a : α)
@[inline] def modifyEnv (f : Environment → Environment) : CompilerM Unit :=
modify fun s => { s with env := f s.env }
open Std (HashMap)
abbrev DeclMap := SMap Name Decl
/-- Create an array of decls to be saved on .olean file.

View file

@ -139,7 +139,7 @@ def addFunctionSummary (env : Environment) (fid : FunId) (v : Value) : Environme
def getFunctionSummary? (env : Environment) (fid : FunId) : Option Value :=
(functionSummariesExt.getState env).find? fid
abbrev Assignment := Std.HashMap VarId Value
abbrev Assignment := HashMap VarId Value
structure InterpContext where
currFnIdx : Nat := 0
@ -149,7 +149,7 @@ structure InterpContext where
structure InterpState where
assignments : Array Assignment
funVals : Std.PArray Value -- we take snapshots during fixpoint computations
funVals : PArray Value -- we take snapshots during fixpoint computations
abbrev M := ReaderT InterpContext (StateM InterpState)
@ -316,7 +316,7 @@ def elimDeadBranches (decls : Array Decl) : CompilerM (Array Decl) := do
let s ← get
let env := s.env
let assignments : Array Assignment := decls.map fun _ => {}
let funVals := Std.mkPArray decls.size Value.bot
let funVals := mkPArray decls.size Value.bot
let ctx : InterpContext := { decls := decls, env := env }
let s : InterpState := { assignments := assignments, funVals := funVals }
let (_, s) := (inferMain ctx).run s

View file

@ -50,8 +50,8 @@ end CollectUsedDecls
def collectUsedDecls (env : Environment) (decl : Decl) (used : NameSet := {}) : NameSet :=
(CollectUsedDecls.collectDecl decl env).run' used
abbrev VarTypeMap := Std.HashMap VarId IRType
abbrev JPParamsMap := Std.HashMap JoinPointId (Array Param)
abbrev VarTypeMap := HashMap VarId IRType
abbrev JPParamsMap := HashMap JoinPointId (Array Param)
namespace CollectMaps
abbrev Collector := (VarTypeMap × JPParamsMap) → (VarTypeMap × JPParamsMap)

View file

@ -9,7 +9,7 @@ import Lean.Compiler.IR.FreeVars
namespace Lean.IR.ExpandResetReuse
/-- Mapping from variable to projections -/
abbrev ProjMap := Std.HashMap VarId Expr
abbrev ProjMap := HashMap VarId Expr
namespace CollectProjMap
abbrev Collector := ProjMap → ProjMap
@[inline] def collectVDecl (x : VarId) (v : Expr) : Collector := fun m =>

View file

@ -79,13 +79,13 @@ def FnBody.hasLiveVar (b : FnBody) (ctx : LocalContext) (x : VarId) : Bool :=
(IsLive.visitFnBody x.idx b).run' ctx
abbrev LiveVarSet := VarIdSet
abbrev JPLiveVarMap := Std.RBMap JoinPointId LiveVarSet (fun j₁ j₂ => compare j₁.idx j₂.idx)
abbrev JPLiveVarMap := RBMap JoinPointId LiveVarSet (fun j₁ j₂ => compare j₁.idx j₂.idx)
instance : Inhabited LiveVarSet where
default := {}
def mkLiveVarSet (x : VarId) : LiveVarSet :=
Std.RBTree.empty.insert x
RBTree.empty.insert x
namespace LiveVars

View file

@ -19,7 +19,7 @@ structure VarInfo where
consume : Bool := false -- true if the variable RC must be "consumed"
deriving Inhabited
abbrev VarMap := Std.RBMap VarId VarInfo (fun x y => compare x.idx y.idx)
abbrev VarMap := RBMap VarId VarInfo (fun x y => compare x.idx y.idx)
structure Context where
env : Environment

View file

@ -14,7 +14,7 @@ namespace Lean.Compiler.LCNF
namespace CSE
structure State where
map : Std.PHashMap Expr FVarId := {}
map : PHashMap Expr FVarId := {}
subst : FVarSubst := {}
abbrev M := StateRefT State CompilerM

View file

@ -136,7 +136,7 @@ it is a free variable, a type (or type former), or `lcErased`.
`Check.lean` contains a substitution validator.
-/
abbrev FVarSubst := Std.HashMap FVarId Expr
abbrev FVarSubst := HashMap FVarId Expr
/--
Replace the free variables in `e` using the given substitution.

View file

@ -22,7 +22,7 @@ structure CandidateInfo where
The set of candidates that rely on this candidate to be a join point.
For a more detailed explanation see the documentation of `find`
-/
associated : Std.HashSet FVarId
associated : HashSet FVarId
deriving Inhabited
/--
@ -32,14 +32,14 @@ structure FindState where
/--
All current join point candidates accessible by their `FVarId`.
-/
candidates : Std.HashMap FVarId CandidateInfo := .empty
candidates : HashMap FVarId CandidateInfo := .empty
/--
The `FVarId`s of all `fun` declarations that were declared within the
current `fun`.
-/
scope : Std.HashSet FVarId := .empty
scope : HashSet FVarId := .empty
abbrev ReplaceCtx := Std.HashMap FVarId Name
abbrev ReplaceCtx := HashMap FVarId Name
abbrev FindM := ReaderT (Option FVarId) StateRefT FindState CompilerM
abbrev ReplaceM := ReaderT ReplaceCtx CompilerM
@ -62,7 +62,7 @@ private partial def eraseCandidate (fvarId : FVarId) : FindM Unit := do
/--
Combinator for modifying the candidates in `FindM`.
-/
private def modifyCandidates (f : Std.HashMap FVarId CandidateInfo → Std.HashMap FVarId CandidateInfo) : FindM Unit :=
private def modifyCandidates (f : HashMap FVarId CandidateInfo → HashMap FVarId CandidateInfo) : FindM Unit :=
modify (fun state => {state with candidates := f state.candidates })
/--

View file

@ -12,9 +12,9 @@ namespace Lean.Compiler.LCNF
LCNF local context.
-/
structure LCtx where
params : Std.HashMap FVarId Param := {}
letDecls : Std.HashMap FVarId LetDecl := {}
funDecls : Std.HashMap FVarId FunDecl := {}
params : HashMap FVarId Param := {}
letDecls : HashMap FVarId LetDecl := {}
funDecls : HashMap FVarId FunDecl := {}
deriving Inhabited
def LCtx.addParam (lctx : LCtx) (param : Param) : LCtx :=

View file

@ -13,7 +13,6 @@ namespace Lean.Compiler.LCNF
-/
namespace NormLevelParam
open Std
/-!
## Universe level parameter normalizer
@ -135,4 +134,4 @@ def Decl.setLevelParams (decl : Decl) : Decl :=
let levelParams := (visitCode decl.value ∘ visitParams decl.params ∘ visitExpr decl.type) {} |>.params.toList
{ decl with levelParams }
end Lean.Compiler.LCNF
end Lean.Compiler.LCNF

View file

@ -7,7 +7,7 @@ import Lean.Compiler.LCNF.PassManager
namespace Lean.Compiler.LCNF
abbrev BaseExtState := Std.PHashMap Name Decl
abbrev BaseExtState := PHashMap Name Decl
private abbrev declLt (a b : Decl) :=
Name.quickLt a.name b.name
@ -61,4 +61,4 @@ def forEachDecl (f : Decl → CoreM Unit) : CoreM Unit := do
f decl
baseExt.getState env |>.forM fun _ decl => f decl
end Lean.Compiler.LCNF
end Lean.Compiler.LCNF

View file

@ -72,7 +72,7 @@ structure FunDeclInfoMap where
/--
Mapping from local function name to inlining information.
-/
map : Std.HashMap FVarId FunDeclInfo := {}
map : HashMap FVarId FunDeclInfo := {}
deriving Inhabited
def FunDeclInfoMap.format (s : FunDeclInfoMap) : CompilerM Format := do

View file

@ -15,7 +15,7 @@ import Lean.Compiler.LCNF.PhaseExt
namespace Lean.Compiler.LCNF
namespace Specialize
abbrev Cache := Std.PHashMap Expr Name
abbrev Cache := PHashMap Expr Name
builtin_initialize specCacheExt : EnvExtension Cache ←
registerEnvExtension (pure {})

View file

@ -190,11 +190,11 @@ structure State where
/-- Local context containing the original Lean types (not LCNF ones). -/
lctx : LocalContext := {}
/-- Cache from Lean regular expression to LCNF expression. -/
cache : Std.PHashMap Expr Expr := {}
cache : PHashMap Expr Expr := {}
/-- `toLCNFType` cache -/
typeCache : Std.HashMap Expr Expr := {}
typeCache : HashMap Expr Expr := {}
/-- isTypeFormerType cache -/
isTypeFormerTypeCache : Std.HashMap Expr Bool := {}
isTypeFormerTypeCache : HashMap Expr Bool := {}
/-- LCNF sequence, we chain it to create a LCNF `Code` object. -/
seq : Array Element := #[]
/--

View file

@ -13,7 +13,7 @@ scoped notation:max "" => lcAny
namespace LCNF
structure LCNFTypeExtState where
types : Std.PHashMap Name Expr := {}
types : PHashMap Name Expr := {}
instLevelType : Core.InstantiateLevelCache := {}
deriving Inhabited
@ -319,4 +319,4 @@ partial def getArrowArity (e : Expr) :=
| .forallE _ _ b _ => getArrowArity b + 1
| _ => 0
end Lean.Compiler.LCNF
end Lean.Compiler.LCNF

View file

@ -22,7 +22,7 @@ register_builtin_option maxHeartbeats : Nat := {
def getMaxHeartbeats (opts : Options) : Nat :=
maxHeartbeats.get opts * 1000
abbrev InstantiateLevelCache := Std.PersistentHashMap Name (List Level × Expr)
abbrev InstantiateLevelCache := PersistentHashMap Name (List Level × Expr)
/-- Cache for the `CoreM` monad -/
structure Cache where

View file

@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
-/
universe u v w w'
namespace Std
namespace Lean
/-- List-like type to avoid extra level of indirection -/
inductive AssocList (α : Type u) (β : Type v) where
@ -100,8 +100,8 @@ def all (p : α → β → Bool) : AssocList α β → Bool
instance : ForIn m (AssocList α β) (α × β) where
forIn := AssocList.forIn
end Std.AssocList
end Lean.AssocList
def List.toAssocList {α : Type u} {β : Type v} : List (α × β) → Std.AssocList α β
| [] => Std.AssocList.nil
| (a,b) :: es => Std.AssocList.cons a b (toAssocList es)
def List.toAssocList' {α : Type u} {β : Type v} : List (α × β) → Lean.AssocList α β
| [] => Lean.AssocList.nil
| (a,b) :: es => Lean.AssocList.cons a b (toAssocList' es)

View file

@ -42,7 +42,7 @@ export Std
(Format ToFormat Format.nest Format.nil Format.joinSep Format.line
Format.sbracket Format.bracket Format.group Format.tag Format.pretty
Format.fill Format.paren Format.join)
export Std.ToFormat (format)
export ToFormat (format)
instance : ToFormat Name where
format n := n.toString

View file

@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
-/
import Lean.Data.AssocList
namespace Std
namespace Lean
universe u v w
def HashMapBucket (α : Type u) (β : Type v) :=
@ -127,7 +127,7 @@ end HashMapImp
def HashMap (α : Type u) (β : Type v) [BEq α] [Hashable α] :=
{ m : HashMapImp α β // m.WellFormed }
open Std.HashMapImp
open Lean.HashMapImp
def mkHashMap {α : Type u} {β : Type v} [BEq α] [Hashable α] (capacity := 0) : HashMap α β :=
⟨ mkHashMapImp capacity, WellFormed.mkWff capacity ⟩

View file

@ -3,7 +3,7 @@ Copyright (c) 2019 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Author: Leonardo de Moura
-/
namespace Std
namespace Lean
universe u v w
def HashSetBucket (α : Type u) :=

View file

@ -166,8 +166,6 @@ end JsonNumber
def strLt (a b : String) := Decidable.decide (a < b)
open Std (RBNode RBNode.leaf)
inductive Json where
| null
| bool (b : Bool)

View file

@ -7,11 +7,7 @@ Authors: Gabriel Ebner, Marc Huisinga
import Lean.Data.Json.Basic
import Lean.Data.Parsec
namespace Lean
open Std (RBNode RBNode.singleton RBNode.leaf)
namespace Json.Parser
namespace Lean.Json.Parser
open Lean.Parsec

View file

@ -15,7 +15,6 @@ for use in the LSP server. -/
namespace Lean.JsonRpc
open Json
open Std (RBNode)
/-- In JSON-RPC, each request from the client editor to the language server comes with a
request id so that the corresponding response can be identified or cancelled. -/

View file

@ -13,7 +13,6 @@ workers. These messages are not visible externally to users of the LSP server.
-/
namespace Lean.Lsp
open Std
/-! Most reference-related types have custom FromJson/ToJson implementations to
reduce the size of the resulting JSON. -/

View file

@ -12,11 +12,9 @@ namespace Lean
instance : Coe String Name := ⟨Name.mkSimple⟩
open Std (RBMap RBTree mkRBMap mkRBTree)
def NameMap (α : Type) := RBMap Name α Name.quickCmp
def NameMap (α : Type) := Std.RBMap Name α Name.quickCmp
@[inline] def mkNameMap (α : Type) : NameMap α := Std.mkRBMap Name α Name.quickCmp
@[inline] def mkNameMap (α : Type) : NameMap α := mkRBMap Name α Name.quickCmp
namespace NameMap
variable {α : Type}
@ -26,14 +24,14 @@ instance (α : Type) : EmptyCollection (NameMap α) := ⟨mkNameMap α⟩
instance (α : Type) : Inhabited (NameMap α) where
default := {}
def insert (m : NameMap α) (n : Name) (a : α) := Std.RBMap.insert m n a
def insert (m : NameMap α) (n : Name) (a : α) := RBMap.insert m n a
def contains (m : NameMap α) (n : Name) : Bool := Std.RBMap.contains m n
def contains (m : NameMap α) (n : Name) : Bool := RBMap.contains m n
@[inline] def find? (m : NameMap α) (n : Name) : Option α := Std.RBMap.find? m n
@[inline] def find? (m : NameMap α) (n : Name) : Option α := RBMap.find? m n
instance : ForIn m (NameMap α) (Name × α) :=
inferInstanceAs (ForIn _ (Std.RBMap ..) ..)
inferInstanceAs (ForIn _ (RBMap ..) ..)
end NameMap
@ -43,10 +41,10 @@ namespace NameSet
def empty : NameSet := mkRBTree Name Name.quickCmp
instance : EmptyCollection NameSet := ⟨empty⟩
instance : Inhabited NameSet := ⟨empty⟩
def insert (s : NameSet) (n : Name) : NameSet := Std.RBTree.insert s n
def contains (s : NameSet) (n : Name) : Bool := Std.RBMap.contains s n
def insert (s : NameSet) (n : Name) : NameSet := RBTree.insert s n
def contains (s : NameSet) (n : Name) : Bool := RBMap.contains s n
instance : ForIn m NameSet Name :=
inferInstanceAs (ForIn _ (Std.RBTree ..) ..)
inferInstanceAs (ForIn _ (RBTree ..) ..)
end NameSet
@ -60,14 +58,14 @@ abbrev insert (s : NameSSet) (n : Name) : NameSSet := SSet.insert s n
abbrev contains (s : NameSSet) (n : Name) : Bool := SSet.contains s n
end NameSSet
def NameHashSet := Std.HashSet Name
def NameHashSet := HashSet Name
namespace NameHashSet
@[inline] def empty : NameHashSet := Std.HashSet.empty
@[inline] def empty : NameHashSet := HashSet.empty
instance : EmptyCollection NameHashSet := ⟨empty⟩
instance : Inhabited NameHashSet := ⟨{}⟩
def insert (s : NameHashSet) (n : Name) := Std.HashSet.insert s n
def contains (s : NameHashSet) (n : Name) : Bool := Std.HashSet.contains s n
def insert (s : NameHashSet) (n : Name) := HashSet.insert s n
def contains (s : NameHashSet) (n : Name) : Bool := HashSet.contains s n
end NameHashSet
def MacroScopesView.isPrefixOf (v₁ v₂ : MacroScopesView) : Bool :=

View file

@ -5,7 +5,7 @@ Authors: Leonardo de Moura
-/
universe u v w
namespace Std
namespace Lean
inductive PersistentArrayNode (α : Type u) where
| node (cs : Array (PersistentArrayNode α)) : PersistentArrayNode α
@ -41,7 +41,7 @@ namespace PersistentArray
/- TODO: use proofs for showing that array accesses are not out of bounds.
We can do it after we reimplement the tactic framework. -/
variable {α : Type u}
open Std.PersistentArrayNode
open PersistentArrayNode
def empty : PersistentArray α := {}
@ -370,19 +370,15 @@ def mkPersistentArray {α : Type u} (n : Nat) (v : α) : PArray α :=
@[inline] def mkPArray {α : Type u} (n : Nat) (v : α) : PArray α :=
mkPersistentArray n v
end Std
end Lean
open Std (PersistentArray PersistentArray.empty)
open Lean (PersistentArray)
def List.toPersistentArrayAux {α : Type u} : List α → PersistentArray α → PersistentArray α
def List.toPArray' {α : Type u} (xs : List α) : PersistentArray α :=
let rec loop : List α → PersistentArray α → PersistentArray α
| [], t => t
| x::xs, t => toPersistentArrayAux xs (t.push x)
| x::xs, t => loop xs (t.push x)
loop xs {}
def List.toPersistentArray {α : Type u} (xs : List α) : PersistentArray α :=
xs.toPersistentArrayAux {}
def Array.toPersistentArray {α : Type u} (xs : Array α) : PersistentArray α :=
xs.foldl (init := PersistentArray.empty) fun p x => p.push x
@[inline] def Array.toPArray {α : Type u} (xs : Array α) : PersistentArray α :=
xs.toPersistentArray
def Array.toPArray' {α : Type u} (xs : Array α) : PersistentArray α :=
xs.foldl (init := .empty) fun p x => p.push x

View file

@ -3,7 +3,7 @@ Copyright (c) 2019 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
namespace Std
namespace Lean
universe u v w w'
namespace PersistentHashMap

View file

@ -5,7 +5,7 @@ Author: Leonardo de Moura
-/
import Lean.Data.PersistentHashMap
namespace Std
namespace Lean
universe u v
structure PersistentHashSet (α : Type u) [BEq α] [Hashable α] where

View file

@ -6,7 +6,6 @@ Authors: Leonardo de Moura
import Lean.Data.RBMap
namespace Lean
open Std
/- Similar to trie, but for arbitrary keys -/
inductive PrefixTreeNode (α : Type u) (β : Type v) where

View file

@ -3,7 +3,7 @@ Copyright (c) 2017 Microsoft Corporation. All rights reserved.
Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
namespace Std
namespace Lean
universe u v w w'
inductive Rbcolor where
@ -16,7 +16,7 @@ inductive RBNode (α : Type u) (β : α → Type v) where
namespace RBNode
variable {α : Type u} {β : α → Type v} {σ : Type w}
open Std.Rbcolor Nat
open Rbcolor Nat
def depth (f : Nat → Nat → Nat) : RBNode α β → Nat
| leaf => 0
@ -246,7 +246,7 @@ instance : EmptyCollection (RBNode α β) := ⟨leaf⟩
end RBNode
open Std.RBNode
open Lean.RBNode
/- TODO(Leo): define dRBMap -/
@ -310,7 +310,7 @@ instance : ForIn m (RBMap α β cmp) (α × β) where
| none => none
instance [Repr α] [Repr β] : Repr (RBMap α β cmp) where
reprPrec m prec := Repr.addAppParen ("Std.rbmapOf " ++ repr m.toList) prec
reprPrec m prec := Repr.addAppParen ("Lean.rbmapOf " ++ repr m.toList) prec
@[inline] def insert : RBMap α β cmp → α → β → RBMap α β cmp
| ⟨t, w⟩, k, v => ⟨t.insert cmp k v, WellFormed.insertWff w rfl⟩
@ -397,5 +397,3 @@ end RBMap
def rbmapOf {α : Type u} {β : Type v} (l : List (α × β)) (cmp : αα → Ordering) : RBMap α β cmp :=
RBMap.fromList l cmp
end Std

View file

@ -4,7 +4,7 @@ Released under Apache 2.0 license as described in the file LICENSE.
Authors: Leonardo de Moura
-/
import Lean.Data.RBMap
namespace Std
namespace Lean
universe u v w
def RBTree (α : Type u) (cmp : αα → Ordering) : Type u :=
@ -66,7 +66,7 @@ instance : ForIn m (RBTree α cmp) α where
| none => none
instance [Repr α] : Repr (RBTree α cmp) where
reprPrec t prec := Repr.addAppParen ("Std.rbtreeOf " ++ repr t.toList) prec
reprPrec t prec := Repr.addAppParen ("Lean.rbtreeOf " ++ repr t.toList) prec
@[inline] def insert (t : RBTree α cmp) (a : α) : RBTree α cmp :=
RBMap.insert t a ()

View file

@ -9,8 +9,6 @@ universe u v w w'
namespace Lean
open Std (HashMap PHashMap)
/-- Staged map for implementing the Environment. The idea is to store
imported entries into a hashtable and local entries into a persistent hashtable.

View file

@ -10,8 +10,6 @@ import Lean.Data.Format
namespace Lean
namespace Parser
open Std (RBNode RBNode.leaf RBNode.singleton RBNode.find RBNode.insert)
inductive Trie (α : Type) where
| Node : Option α → RBNode Char (fun _ => Trie α) → Trie α

View file

@ -9,7 +9,7 @@ import Lean.Data.RBMap
namespace Lean
namespace Xml
def Attributes := Std.RBMap String String compare
def Attributes := RBMap String String compare
instance : ToString Attributes := ⟨λ as => as.fold (λ s n v => s ++ s!" {n}=\"{v}\"") ""⟩
mutual

View file

@ -410,7 +410,7 @@ protected def elementPrefix : Parsec (Array Content → Element) := do
let name ← Name
let attributes ← many (S *> Attribute)
optional S *> pure ()
return Element.Element name (Std.RBMap.fromList attributes.toList compare)
return Element.Element name (RBMap.fromList attributes.toList compare)
/-- https://www.w3.org/TR/xml/#NT-EmptyElemTag -/
def EmptyElemTag (elem : Array Content → Element) : Parsec Element := do

View file

@ -71,7 +71,7 @@ structure ModuleDoc where
doc : String
declarationRange : DeclarationRange
private builtin_initialize moduleDocExt : SimplePersistentEnvExtension ModuleDoc (Std.PersistentArray ModuleDoc) ← registerSimplePersistentEnvExtension {
private builtin_initialize moduleDocExt : SimplePersistentEnvExtension ModuleDoc (PersistentArray ModuleDoc) ← registerSimplePersistentEnvExtension {
name := `moduleDocExt
addImportedFn := fun _ => {}
addEntryFn := fun s e => s.push e
@ -81,7 +81,7 @@ private builtin_initialize moduleDocExt : SimplePersistentEnvExtension ModuleDoc
def addMainModuleDoc (env : Environment) (doc : ModuleDoc) : Environment :=
moduleDocExt.addEntry env doc
def getMainModuleDoc (env : Environment) : Std.PersistentArray ModuleDoc :=
def getMainModuleDoc (env : Environment) : PersistentArray ModuleDoc :=
moduleDocExt.getState env
def getModuleDoc? (env : Environment) (moduleName : Name) : Option (Array ModuleDoc) :=

View file

@ -121,7 +121,7 @@ private def mkCoreContext (ctx : Context) (s : State) (heartbeats : Nat) : Core.
private def addTraceAsMessagesCore (ctx : Context) (log : MessageLog) (traceState : TraceState) : MessageLog := Id.run do
if traceState.traces.isEmpty then return log
let mut traces : Std.HashMap (String.Pos × String.Pos) (Array MessageData) := ∅
let mut traces : HashMap (String.Pos × String.Pos) (Array MessageData) := ∅
for traceElem in traceState.traces do
let ref := replaceRef traceElem.ref ctx.ref
let pos := ref.getPos?.getD 0
@ -221,7 +221,7 @@ opaque mkCommandElabAttribute : IO (KeyedDeclsAttribute CommandElab)
builtin_initialize commandElabAttribute : KeyedDeclsAttribute CommandElab ← mkCommandElabAttribute
private def mkInfoTree (elaborator : Name) (stx : Syntax) (trees : Std.PersistentArray InfoTree) : CommandElabM InfoTree := do
private def mkInfoTree (elaborator : Name) (stx : Syntax) (trees : PersistentArray InfoTree) : CommandElabM InfoTree := do
let ctx ← read
let s ← get
let scope := s.scopes.head!

View file

@ -9,7 +9,7 @@ namespace Lean.Elab
open Command
open Meta
private abbrev IndexSet := Std.RBTree Nat compare
private abbrev IndexSet := RBTree Nat compare
private abbrev LocalInst2Index := FVarIdMap Nat
private def implicitBinderF := Parser.Term.implicitBinder

View file

@ -213,7 +213,7 @@ def Code.getRef? : Code → Option Syntax
| .match ref .. => ref
| .jmp ref .. => ref
abbrev VarSet := Std.RBMap Name Syntax Name.cmp
abbrev VarSet := RBMap Name Syntax Name.cmp
/-- A code block, and the collection of variables updated by it. -/
structure CodeBlock where

View file

@ -133,7 +133,7 @@ private inductive Tree where
We store the `infoTrees` generated when elaborating `val`. These trees become
subtrees of the infotree nodes generated for `op` nodes.
-/
| term (ref : Syntax) (infoTrees : Std.PersistentArray InfoTree) (val : Expr)
| term (ref : Syntax) (infoTrees : PersistentArray InfoTree) (val : Expr)
/--
`ref` is the original syntax that expanded into `binop%`.
`macroName` is the `macro_rule` that produce the expansion. We store this information

View file

@ -6,11 +6,7 @@ Authors: Wojciech Nawrocki, Leonardo de Moura, Sebastian Ullrich
-/
import Lean.Meta.PPGoal
namespace Lean.Elab
open Std (PersistentArray PersistentArray.empty PersistentHashMap)
namespace ContextInfo
namespace Lean.Elab.ContextInfo
variable [Monad m] [MonadEnv m] [MonadMCtx m] [MonadOptions m] [MonadResolveName m] [MonadNameGenerator m]

View file

@ -153,7 +153,7 @@ inductive InfoTree where
/-- The context object is created by `liftTermElabM` at `Command.lean` -/
| context (i : ContextInfo) (t : InfoTree)
/-- The children contain information for nested term elaboration and tactic evaluation -/
| node (i : Info) (children : Std.PersistentArray InfoTree)
| node (i : Info) (children : PersistentArray InfoTree)
/-- The elaborator creates holes (aka metavariables) for tactics and postponed terms -/
| hole (mvarId : MVarId)
deriving Inhabited
@ -172,9 +172,9 @@ structure InfoState where
/-- Whether info trees should be recorded. -/
enabled : Bool := true
/-- Map from holes in the infotree to child infotrees. -/
assignment : Std.PersistentHashMap MVarId InfoTree := {}
assignment : PersistentHashMap MVarId InfoTree := {}
/-- Pending child trees of a node. -/
trees : Std.PersistentArray InfoTree := {}
trees : PersistentArray InfoTree := {}
deriving Inhabited
class MonadInfoTree (m : Type → Type) where

View file

@ -304,7 +304,7 @@ def tryContradiction (mvarId : MVarId) : MetaM Bool := do
mvarId.contradictionCore { genDiseq := true }
structure UnfoldEqnExtState where
map : Std.PHashMap Name Name := {}
map : PHashMap Name Name := {}
deriving Inhabited
/- We generate the unfold equation on demand, and do not save them on .olean files. -/

View file

@ -580,7 +580,7 @@ private partial def compileStxMatch (discrs : List Term) (alts : List Alt) : Ter
`(let discr := $discr; $stx)
| _, _ => unreachable!
abbrev IdxSet := Std.HashSet Nat
abbrev IdxSet := HashSet Nat
/--
Given `rhss` the right-hand-sides of a `match`-syntax notation,

View file

@ -11,7 +11,6 @@ import Lean.Elab.Binders
namespace Lean.Elab.Term.StructInst
open Std (HashMap)
open Meta
open TSyntax.Compat

View file

@ -278,7 +278,7 @@ private def getSomeSynthethicMVarsRef : TermElabM Syntax := do
private def throwStuckAtUniverseCnstr : TermElabM Unit := do
-- This code assumes `entries` is not empty. Note that `processPostponed` uses `exceptionOnFailure` to guarantee this property
let entries ← getPostponed
let mut found : Std.HashSet (Level × Level) := {}
let mut found : HashSet (Level × Level) := {}
let mut uniqueEntries := #[]
for entry in entries do
let mut lhs := entry.lhs

View file

@ -147,8 +147,8 @@ structure CacheKey where
Cache for the `save` tactic.
-/
structure Cache where
pre : Std.PHashMap CacheKey Snapshot := {}
post : Std.PHashMap CacheKey Snapshot := {}
pre : PHashMap CacheKey Snapshot := {}
post : PHashMap CacheKey Snapshot := {}
deriving Inhabited
end Tactic
@ -183,7 +183,7 @@ structure Context where
`elabTypeWithUnboldImplicit`. Both methods add implicit declarations
for the unbound variable and try again. -/
autoBoundImplicit : Bool := false
autoBoundImplicits : Std.PArray Expr := {}
autoBoundImplicits : PArray Expr := {}
/--
A name `n` is only eligible to be an auto implicit name if `autoBoundImplicitForbidden n = false`.
We use this predicate to disallow `f` to be considered an auto implicit name in a definition such

View file

@ -91,8 +91,6 @@ structure EnvironmentHeader where
moduleData : Array ModuleData := #[]
deriving Inhabited
open Std (HashMap)
/--
An environment stores declarations provided by the user. The kernel
currently supports different kinds of declarations such as definitions, theorems,
@ -698,8 +696,8 @@ partial def importModules (imports : List Import) (opts : Options) (trustLevel :
for mod in s.moduleData do
numConsts := numConsts + mod.constants.size
let mut modIdx : Nat := 0
let mut const2ModIdx : HashMap Name ModuleIdx := Std.mkHashMap (capacity := numConsts)
let mut constantMap : HashMap Name ConstantInfo := Std.mkHashMap (capacity := numConsts)
let mut const2ModIdx : HashMap Name ModuleIdx := mkHashMap (capacity := numConsts)
let mut constantMap : HashMap Name ConstantInfo := mkHashMap (capacity := numConsts)
for mod in s.moduleData do
for cinfo in mod.constants do
const2ModIdx := const2ModIdx.insert cinfo.name modIdx

View file

@ -246,24 +246,24 @@ instance : Repr FVarId where
/--
A set of unique free variable identifiers.
This is a persistent data structure implemented using red-black trees. -/
def FVarIdSet := Std.RBTree FVarId (Name.quickCmp ·.name ·.name)
def FVarIdSet := RBTree FVarId (Name.quickCmp ·.name ·.name)
deriving Inhabited, EmptyCollection
instance : ForIn m FVarIdSet FVarId := inferInstanceAs (ForIn _ (Std.RBTree ..) ..)
instance : ForIn m FVarIdSet FVarId := inferInstanceAs (ForIn _ (RBTree ..) ..)
/--
A set of unique free variable identifiers implemented using hashtables.
Hashtables are faster than red-black trees if they are used linearly.
They are not persistent data-structures. -/
def FVarIdHashSet := Std.HashSet FVarId
def FVarIdHashSet := HashSet FVarId
deriving Inhabited, EmptyCollection
/--
A mapping from free variable identifiers to values of type `α`.
This is a persistent data structure implemented using red-black trees. -/
def FVarIdMap (α : Type) := Std.RBMap FVarId α (Name.quickCmp ·.name ·.name)
def FVarIdMap (α : Type) := RBMap FVarId α (Name.quickCmp ·.name ·.name)
instance : EmptyCollection (FVarIdMap α) := inferInstanceAs (EmptyCollection (Std.RBMap ..))
instance : EmptyCollection (FVarIdMap α) := inferInstanceAs (EmptyCollection (RBMap ..))
instance : Inhabited (FVarIdMap α) where
default := {}
@ -276,16 +276,16 @@ structure MVarId where
instance : Repr MVarId where
reprPrec n p := reprPrec n.name p
def MVarIdSet := Std.RBTree MVarId (Name.quickCmp ·.name ·.name)
def MVarIdSet := RBTree MVarId (Name.quickCmp ·.name ·.name)
deriving Inhabited, EmptyCollection
instance : ForIn m MVarIdSet MVarId := inferInstanceAs (ForIn _ (Std.RBTree ..) ..)
instance : ForIn m MVarIdSet MVarId := inferInstanceAs (ForIn _ (RBTree ..) ..)
def MVarIdMap (α : Type) := Std.RBMap MVarId α (Name.quickCmp ·.name ·.name)
def MVarIdMap (α : Type) := RBMap MVarId α (Name.quickCmp ·.name ·.name)
instance : EmptyCollection (MVarIdMap α) := inferInstanceAs (EmptyCollection (Std.RBMap ..))
instance : EmptyCollection (MVarIdMap α) := inferInstanceAs (EmptyCollection (RBMap ..))
instance : ForIn m (MVarIdMap α) (MVarId × α) := inferInstanceAs (ForIn _ (Std.RBMap ..) ..)
instance : ForIn m (MVarIdMap α) (MVarId × α) := inferInstanceAs (ForIn _ (RBMap ..) ..)
instance : Inhabited (MVarIdMap α) where
default := {}
@ -1244,8 +1244,6 @@ def mkDecIsTrue (pred proof : Expr) :=
def mkDecIsFalse (pred proof : Expr) :=
mkAppB (mkConst `Decidable.isFalse) pred proof
open Std (HashMap HashSet PHashMap PHashSet)
abbrev ExprMap (α : Type) := HashMap Expr α
abbrev PersistentExprMap (α : Type) := PHashMap Expr α
abbrev ExprSet := HashSet Expr

View file

@ -55,8 +55,8 @@ abbrev Table (γ : Type) := SMap Key (List (AttributeEntry γ))
structure ExtensionState (γ : Type) where
newEntries : List OLeanEntry := []
table : Table γ := {}
declNames : Std.PHashSet Name := {}
erased : Std.PHashSet Name := {}
declNames : PHashSet Name := {}
erased : PHashSet Name := {}
deriving Inhabited
abbrev Extension (γ : Type) := ScopedEnvExtension OLeanEntry (AttributeEntry γ) (ExtensionState γ)

View file

@ -72,16 +72,16 @@ abbrev LMVarId := LevelMVarId
instance : Repr LMVarId where
reprPrec n p := reprPrec n.name p
def LMVarIdSet := Std.RBTree LMVarId (Name.quickCmp ·.name ·.name)
def LMVarIdSet := RBTree LMVarId (Name.quickCmp ·.name ·.name)
deriving Inhabited, EmptyCollection
instance : ForIn m LMVarIdSet LMVarId := inferInstanceAs (ForIn _ (Std.RBTree ..) ..)
instance : ForIn m LMVarIdSet LMVarId := inferInstanceAs (ForIn _ (RBTree ..) ..)
def LMVarIdMap (α : Type) := Std.RBMap LMVarId α (Name.quickCmp ·.name ·.name)
def LMVarIdMap (α : Type) := RBMap LMVarId α (Name.quickCmp ·.name ·.name)
instance : EmptyCollection (LMVarIdMap α) := inferInstanceAs (EmptyCollection (Std.RBMap ..))
instance : EmptyCollection (LMVarIdMap α) := inferInstanceAs (EmptyCollection (RBMap ..))
instance : ForIn m (LMVarIdMap α) (LMVarId × α) := inferInstanceAs (ForIn _ (Std.RBMap ..) ..)
instance : ForIn m (LMVarIdMap α) (LMVarId × α) := inferInstanceAs (ForIn _ (RBMap ..) ..)
instance : Inhabited (LMVarIdMap α) where
default := {}
@ -598,8 +598,6 @@ termination_by _ u v => (u, v)
end Level
open Std (HashMap HashSet PHashMap PHashSet)
abbrev LevelMap (α : Type) := HashMap Level α
abbrev PersistentLevelMap (α : Type) := PHashMap Level α
abbrev LevelSet := HashSet Level

View file

@ -148,7 +148,7 @@ def checkDecl : SimpleHandler := fun stx => do
lintField rest[1][0] stx[1] "computed field"
else if rest.getKind == ``«structure» then
unless rest[5][2].isNone do
let redecls : Std.HashSet String.Pos :=
let redecls : HashSet String.Pos :=
(← get).infoState.trees.foldl (init := {}) fun s tree =>
tree.foldInfo (init := s) fun _ info s =>
if let .ofFieldRedeclInfo info := info then

View file

@ -102,8 +102,6 @@ def hasExprMVar : LocalDecl → Bool
end LocalDecl
open Std (PersistentHashMap PersistentArray PArray)
/-- A LocalContext is an ordered set of local variable declarations.
It is used to store the free variables (also known as local constants) that
are in scope.

View file

@ -207,7 +207,7 @@ protected def toString (msg : Message) (includeEndPos := false) : IO String := d
end Message
structure MessageLog where
msgs : Std.PersistentArray Message := {}
msgs : PersistentArray Message := {}
deriving Inhabited
namespace MessageLog

View file

@ -15,8 +15,6 @@ structure AbstractMVarsResult where
namespace AbstractMVars
open Std (HashMap)
structure State where
ngen : NameGenerator
lctx : LocalContext

View file

@ -205,8 +205,6 @@ instance : Hashable InfoCacheKey :=
⟨fun ⟨transparency, expr, nargs⟩ => mixHash (hash transparency) <| mixHash (hash expr) (hash nargs)⟩
end InfoCacheKey
open Std (PersistentArray PersistentHashMap)
abbrev SynthInstanceCache := PersistentHashMap Expr (Option Expr)
abbrev InferTypeCache := PersistentExprStructMap Expr

View file

@ -38,7 +38,6 @@ inductive Trie (α : Type) where
end DiscrTree
open DiscrTree
open Std (PersistentHashMap)
structure DiscrTree (α : Type) where
root : PersistentHashMap Key (Trie α) := {}

View file

@ -50,7 +50,7 @@ private def shouldGenerateEqnThms (declName : Name) : MetaM Bool := do
return false
structure EqnsExtState where
map : Std.PHashMap Name (Array Name) := {}
map : PHashMap Name (Array Name) := {}
deriving Inhabited
/- We generate the equations on demand, and do not save them on .olean files. -/

View file

@ -8,7 +8,7 @@ import Lean.ScopedEnvExtension
namespace Lean.Meta
builtin_initialize globalInstanceExtension : SimpleScopedEnvExtension Name (Std.PersistentHashMap Name Unit) ←
builtin_initialize globalInstanceExtension : SimpleScopedEnvExtension Name (PersistentHashMap Name Unit) ←
registerSimpleScopedEnvExtension {
name := `ginstanceExt
initial := {}

View file

@ -26,8 +26,8 @@ instance : ToFormat InstanceEntry where
structure Instances where
discrTree : DiscrTree InstanceEntry := DiscrTree.empty
instanceNames : Std.PHashSet Name := {}
erased : Std.PHashSet Name := {}
instanceNames : PHashSet Name := {}
erased : PHashSet Name := {}
deriving Inhabited
def addInstanceEntry (d : Instances) (e : InstanceEntry) : Instances :=
@ -78,7 +78,7 @@ builtin_initialize
def getGlobalInstancesIndex : CoreM (DiscrTree InstanceEntry) :=
return Meta.instanceExtension.getState (← getEnv) |>.discrTree
def getErasedInstances : CoreM (Std.PHashSet Name) :=
def getErasedInstances : CoreM (PHashSet Name) :=
return Meta.instanceExtension.getState (← getEnv) |>.erased
def isInstance (declName : Name) : CoreM Bool :=
@ -91,7 +91,7 @@ structure DefaultInstanceEntry where
instanceName : Name
priority : Nat
abbrev PrioritySet := Std.RBTree Nat (fun x y => compare y x)
abbrev PrioritySet := RBTree Nat (fun x y => compare y x)
structure DefaultInstances where
defaultInstances : NameMap (List (Name × Nat)) := {}

View file

@ -10,12 +10,12 @@ namespace Lean.Meta
/--
A mapping that indentifies definitionally equal expressions.
We implement it as a mapping from `HeadIndex` to `Std.AssocList Expr α`.
We implement it as a mapping from `HeadIndex` to `AssocList Expr α`.
Remark: this map may be quite inefficient if there are many `HeadIndex` collisions.
-/
structure KExprMap (α : Type) where
map : Std.PHashMap HeadIndex (Std.AssocList Expr α) := {}
map : PHashMap HeadIndex (AssocList Expr α) := {}
deriving Inhabited
/-- Return `some v` if there is an entry `e ↦ v` in `m`. -/
@ -28,20 +28,20 @@ def KExprMap.find? (m : KExprMap α) (e : Expr) : MetaM (Option α) := do
return some a
return none
private def updateList (ps : Std.AssocList Expr α) (e : Expr) (v : α) : MetaM (Std.AssocList Expr α) := do
private def updateList (ps : AssocList Expr α) (e : Expr) (v : α) : MetaM (AssocList Expr α) := do
match ps with
| Std.AssocList.nil => return Std.AssocList.cons e v ps
| Std.AssocList.cons e' v' ps =>
| AssocList.nil => return AssocList.cons e v ps
| AssocList.cons e' v' ps =>
if (← isDefEq e e') then
return Std.AssocList.cons e v ps
return AssocList.cons e v ps
else
return Std.AssocList.cons e' v' (← updateList ps e v)
return AssocList.cons e' v' (← updateList ps e v)
/-- Insert `e ↦ v` into `m` -/
def KExprMap.insert (m : KExprMap α) (e : Expr) (v : α) : MetaM (KExprMap α) :=
let k := e.toHeadIndex
match m.map.find? k with
| none => return { map := m.map.insert k (Std.AssocList.cons e v Std.AssocList.nil) }
| none => return { map := m.map.insert k (AssocList.cons e v AssocList.nil) }
| some ps => return { map := m.map.insert k (← updateList ps e v) }
end Lean.Meta

View file

@ -64,7 +64,7 @@ where
loop lhss alts minors
structure State where
used : Std.HashSet Nat := {} -- used alternatives
used : HashSet Nat := {} -- used alternatives
counterExamples : List (List Example) := []
/-- Return true if the given (sub-)problem has been solved. -/
@ -675,7 +675,7 @@ register_builtin_option bootstrap.genMatcherCode : Bool := {
descr := "disable code generation for auxiliary matcher function"
}
builtin_initialize matcherExt : EnvExtension (Std.PHashMap (Expr × Bool) Name) ← registerEnvExtension (pure {})
builtin_initialize matcherExt : EnvExtension (PHashMap (Expr × Bool) Name) ← registerEnvExtension (pure {})
/-- Similar to `mkAuxDefinition`, but uses the cache `matcherExt`.
It also returns an Boolean that indicates whether a new matcher function was added to the environment or not. -/

View file

@ -17,7 +17,7 @@ def MatchEqns.size (e : MatchEqns) : Nat :=
e.eqnNames.size
structure MatchEqnsExtState where
map : Std.PHashMap Name MatchEqns := {}
map : PHashMap Name MatchEqns := {}
deriving Inhabited
/- We generate the equations and splitter on demand, and do not save them on .olean files. -/

View file

@ -29,8 +29,6 @@ namespace SynthInstance
def getMaxHeartbeats (opts : Options) : Nat :=
synthInstance.maxHeartbeats.get opts * 1000
open Std (HashMap)
builtin_initialize inferTCGoalsRLAttr : TagAttribute ←
registerTagAttribute `inferTCGoalsRL "instruct type class resolution procedure to solve goals from right to left for this instance"

View file

@ -63,9 +63,9 @@ inductive PreExpr
def toACExpr (op l r : Expr) : MetaM (Array Expr × ACExpr) := do
let (preExpr, vars) ←
toPreExpr (mkApp2 op l r)
|>.run Std.HashSet.empty
|>.run HashSet.empty
let vars := vars.toArray.insertionSort Expr.lt
let varMap := vars.foldl (fun xs x => xs.insert x xs.size) Std.HashMap.empty |>.find!
let varMap := vars.foldl (fun xs x => xs.insert x xs.size) HashMap.empty |>.find!
return (vars, toACExpr varMap preExpr)
where

View file

@ -9,7 +9,7 @@ namespace Lean.Meta
structure AuxLemmas where
idx : Nat := 1
lemmas : Std.PHashMap Expr (Name × List Name) := {}
lemmas : PHashMap Expr (Name × List Name) := {}
deriving Inhabited
builtin_initialize auxLemmasExt : EnvExtension AuxLemmas ← registerEnvExtension (pure {})

View file

@ -16,7 +16,7 @@ namespace Lean.Meta
to an expression. The free variables occurring in the expression must
be defined in the new goal. -/
structure FVarSubst where
map : Std.AssocList FVarId Expr := {}
map : AssocList FVarId Expr := {}
deriving Inhabited
namespace FVarSubst

View file

@ -127,7 +127,7 @@ def tryTheorem? (e : Expr) (thm : SimpTheorem) (discharge? : Expr → SimpM (Opt
/--
Remark: the parameter tag is used for creating trace messages. It is irrelevant otherwise.
-/
def rewrite? (e : Expr) (s : DiscrTree SimpTheorem) (erased : Std.PHashSet Origin) (discharge? : Expr → SimpM (Option Expr)) (tag : String) (rflOnly : Bool) : SimpM (Option Result) := do
def rewrite? (e : Expr) (s : DiscrTree SimpTheorem) (erased : PHashSet Origin) (discharge? : Expr → SimpM (Option Expr)) (tag : String) (rflOnly : Bool) : SimpM (Option Result) := do
let candidates ← s.getMatchWithExtra e
if candidates.isEmpty then
trace[Debug.Meta.Tactic.simp] "no theorems found for {tag}-rewriting {e}"

View file

@ -140,10 +140,10 @@ instance : BEq SimpTheorem where
structure SimpTheorems where
pre : DiscrTree SimpTheorem := DiscrTree.empty
post : DiscrTree SimpTheorem := DiscrTree.empty
lemmaNames : Std.PHashSet Origin := {}
toUnfold : Std.PHashSet Name := {}
erased : Std.PHashSet Origin := {}
toUnfoldThms : Std.PHashMap Name (Array Name) := {}
lemmaNames : PHashSet Origin := {}
toUnfold : PHashSet Name := {}
erased : PHashSet Origin := {}
toUnfoldThms : PHashMap Name (Array Name) := {}
deriving Inhabited
def addSimpTheoremEntry (d : SimpTheorems) (e : SimpTheorem) : SimpTheorems :=
@ -152,7 +152,7 @@ def addSimpTheoremEntry (d : SimpTheorems) (e : SimpTheorem) : SimpTheorems :=
else
{ d with pre := d.pre.insertCore e.keys e, lemmaNames := updateLemmaNames d.lemmaNames }
where
updateLemmaNames (s : Std.PHashSet Origin) : Std.PHashSet Origin :=
updateLemmaNames (s : PHashSet Origin) : PHashSet Origin :=
s.insert e.origin
def SimpTheorems.addDeclToUnfoldCore (d : SimpTheorems) (declName : Name) : SimpTheorems :=
@ -367,7 +367,7 @@ def mkSimpExt (extName : Name) : IO SimpExtension :=
| SimpEntry.toUnfoldThms n thms => d.registerDeclToUnfoldThms n thms
}
abbrev SimpExtensionMap := Std.HashMap Name SimpExtension
abbrev SimpExtensionMap := HashMap Name SimpExtension
builtin_initialize simpExtensionMapRef : IO.Ref SimpExtensionMap ← IO.mkRef {}

View file

@ -35,7 +35,7 @@ def Context.isDeclToUnfold (ctx : Context) (declName : Name) : Bool :=
def Context.mkDefault : MetaM Context :=
return { config := {}, simpTheorems := #[(← getSimpTheorems)], congrTheorems := (← getSimpCongrTheorems) }
abbrev UsedSimps := Std.HashMap Origin Nat
abbrev UsedSimps := HashMap Origin Nat
structure State where
cache : Cache := {}

View file

@ -301,8 +301,6 @@ structure DelayedMetavarAssignment where
fvars : Array Expr
mvarIdPending : MVarId
open Std (HashMap PersistentHashMap)
/-- The metavariable context is a set of metavariable declarations and their assignments.
For more information on specifics see the comment in the file that `MetavarContext` is defined in.

View file

@ -98,10 +98,10 @@ def initCacheForInput (input : String) : ParserCache := {
abbrev TokenTable := Trie Token
abbrev SyntaxNodeKindSet := Std.PersistentHashMap SyntaxNodeKind Unit
abbrev SyntaxNodeKindSet := PersistentHashMap SyntaxNodeKind Unit
def SyntaxNodeKindSet.insert (s : SyntaxNodeKindSet) (k : SyntaxNodeKind) : SyntaxNodeKindSet :=
Std.PersistentHashMap.insert s k ()
PersistentHashMap.insert s k ()
/--
Input string and related data. Recall that the `FileMap` is a helper structure for mapping
@ -1550,8 +1550,6 @@ def eoiFn : ParserFn := fun c s =>
def eoi : Parser :=
{ fn := eoiFn }
open Std (RBMap RBMap.empty)
/-- A multimap indexed by tokens. Used for indexing parsers by their leading token. -/
def TokenMap (α : Type) := RBMap Name (List α) Name.quickCmp
@ -1559,8 +1557,8 @@ namespace TokenMap
def insert (map : TokenMap α) (k : Name) (v : α) : TokenMap α :=
match map.find? k with
| none => Std.RBMap.insert map k [v]
| some vs => Std.RBMap.insert map k (v::vs)
| none => RBMap.insert map k [v]
| some vs => RBMap.insert map k (v::vs)
instance : Inhabited (TokenMap α) := ⟨RBMap.empty⟩
@ -1641,7 +1639,7 @@ structure ParserCategory where
behavior : LeadingIdentBehavior
deriving Inhabited
abbrev ParserCategories := Std.PersistentHashMap Name ParserCategory
abbrev ParserCategories := PersistentHashMap Name ParserCategory
def indexed {α : Type} (map : TokenMap α) (c : ParserContext) (s : ParserState) (behavior : LeadingIdentBehavior) : ParserState × List α :=
let (s, stx) := peekToken c s

View file

@ -38,7 +38,7 @@ def ppExpr (e : Expr) : MetaM Format := do
/-- Return a `fmt` representing pretty-printed `e` together with a map from tags in `fmt`
to `Elab.Info` nodes produced by the delaborator at various subexpressions of `e`. -/
def ppExprWithInfos (e : Expr) (optsPerPos : Delaborator.OptionsPerPos := {}) (delab := Delaborator.delab)
: MetaM (Format × Std.RBMap Nat Elab.Info compare) := do
: MetaM (Format × RBMap Nat Elab.Info compare) := do
let lctx := (← getLCtx).sanitizeNames.run' { options := (← getOptions) }
Meta.withLCtx lctx #[] do
let (stx, infos) ← delabCore e optsPerPos delab

View file

@ -15,7 +15,7 @@ in sync with the `Nat` "position" values that refer to them.
namespace Lean.PrettyPrinter.Delaborator
abbrev OptionsPerPos := Std.RBMap SubExpr.Pos Options compare
abbrev OptionsPerPos := RBMap SubExpr.Pos Options compare
namespace SubExpr

View file

@ -23,10 +23,7 @@ that are not strictly necessary.
-/
namespace Lean
open Lean.Meta
open Lean.SubExpr
open Std (RBMap)
open Meta SubExpr
register_builtin_option pp.analyze : Bool := {
defValue := false
@ -197,7 +194,7 @@ def isHBinOp (e : Expr) : Bool := Id.run do
def replaceLPsWithVars (e : Expr) : MetaM Expr := do
if !e.hasLevelParam then return e
let lps := collectLevelParams {} e |>.params
let mut replaceMap : Std.HashMap Name Level := {}
let mut replaceMap : HashMap Name Level := {}
for lp in lps do replaceMap := replaceMap.insert lp (← mkFreshLevelMVar)
return e.replaceLevel fun
| Level.param n .. => replaceMap.find! n

View file

@ -20,7 +20,7 @@ structure State (σ : Type) where
activeScopes : NameSet := {}
structure ScopedEntries (β : Type) where
map : SMap Name (Std.PArray β) := {}
map : SMap Name (PArray β) := {}
deriving Inhabited
structure StateStack (α : Type) (β : Type) (σ : Type) where
@ -51,7 +51,7 @@ def mkInitial (descr : Descr α β σ) : IO (StateStack α β σ) :=
def ScopedEntries.insert (scopedEntries : ScopedEntries β) (ns : Name) (b : β) : ScopedEntries β :=
match scopedEntries.map.find? ns with
| none => { map := scopedEntries.map.insert ns <| ({} : Std.PArray β).push b }
| none => { map := scopedEntries.map.insert ns <| ({} : PArray β).push b }
| some bs => { map := scopedEntries.map.insert ns <| bs.push b }
def addImportedFn (descr : Descr α β σ) (as : Array (Array (Entry α))) : ImportM (StateStack α β σ) := do

View file

@ -404,7 +404,7 @@ private def optionCompletion (ctx : ContextInfo) (stx : Syntax) (caps : ClientCa
else
(ss.toString, false)
-- HACK(WN): unfold the type so ForIn works
let (decls : Std.RBMap _ _ _) ← getOptionDecls
let (decls : RBMap _ _ _) ← getOptionDecls
let opts ← getOptions
let mut items := #[]
for ⟨name, decl⟩ in decls do

View file

@ -53,7 +53,6 @@ namespace Lean.Server.FileWorker
open Lsp
open IO
open Snapshots
open Std (RBMap RBMap.empty)
open JsonRpc
structure WorkerContext where
@ -146,7 +145,7 @@ structure WorkerState where
pendingRequests : PendingRequestMap
/-- A map of RPC session IDs. We allow asynchronous elab tasks and request handlers
to modify sessions. A single `Ref` ensures atomic transactions. -/
rpcSessions : Std.RBMap UInt64 (IO.Ref RpcSession) compare
rpcSessions : RBMap UInt64 (IO.Ref RpcSession) compare
abbrev WorkerM := ReaderT WorkerContext <| StateRefT WorkerState IO
@ -226,9 +225,9 @@ section Initialization
Elab.InfoTree.node (Elab.Info.ofCommandInfo {
elaborator := `import
stx := importStx
}) #[].toPersistentArray
)).toPersistentArray
)].toPersistentArray
}) #[].toPArray'
)).toPArray'
)].toPArray'
}}
let headerSnap := {
beginPos := 0
@ -261,7 +260,7 @@ section Initialization
return (ctx,
{ doc := doc
pendingRequests := RBMap.empty
rpcSessions := Std.RBMap.empty
rpcSessions := RBMap.empty
})
end Initialization

View file

@ -10,8 +10,8 @@ namespace Lean.Elab
/-- Visit nodes, passing in a surrounding context (the innermost one) and accumulating results on the way back up. -/
partial def InfoTree.visitM [Monad m]
(preNode : ContextInfo → Info → (children : Std.PersistentArray InfoTree) → m Unit := fun _ _ _ => pure ())
(postNode : ContextInfo → Info → (children : Std.PersistentArray InfoTree) → List (Option α) → m α)
(preNode : ContextInfo → Info → (children : PersistentArray InfoTree) → m Unit := fun _ _ _ => pure ())
(postNode : ContextInfo → Info → (children : PersistentArray InfoTree) → List (Option α) → m α)
: InfoTree → m (Option α) :=
go none
where go
@ -25,20 +25,20 @@ where go
/-- `InfoTree.visitM` specialized to `Unit` return type -/
def InfoTree.visitM' [Monad m]
(preNode : ContextInfo → Info → (children : Std.PersistentArray InfoTree) → m Unit := fun _ _ _ => pure ())
(postNode : ContextInfo → Info → (children : Std.PersistentArray InfoTree) → m Unit := fun _ _ _ => pure ())
(preNode : ContextInfo → Info → (children : PersistentArray InfoTree) → m Unit := fun _ _ _ => pure ())
(postNode : ContextInfo → Info → (children : PersistentArray InfoTree) → m Unit := fun _ _ _ => pure ())
(t : InfoTree) : m Unit := t.visitM preNode (fun ci i cs _ => postNode ci i cs) |> discard
/--
Visit nodes bottom-up, passing in a surrounding context (the innermost one) and the union of nested results (empty at leaves). -/
def InfoTree.collectNodesBottomUp (p : ContextInfo → Info → Std.PersistentArray InfoTree → List α → List α) (i : InfoTree) : List α :=
def InfoTree.collectNodesBottomUp (p : ContextInfo → Info → PersistentArray InfoTree → List α → List α) (i : InfoTree) : List α :=
i.visitM (m := Id) (postNode := fun ci i cs as => p ci i cs (as.filterMap id).join) |>.getD []
/--
For every branch of the `InfoTree`, find the deepest node in that branch for which `p` returns
`some _` and return the union of all such nodes. The visitor `p` is given a node together with
its innermost surrounding `ContextInfo`. -/
partial def InfoTree.deepestNodes (p : ContextInfo → Info → Std.PersistentArray InfoTree → Option α) (infoTree : InfoTree) : List α :=
partial def InfoTree.deepestNodes (p : ContextInfo → Info → PersistentArray InfoTree → Option α) (infoTree : InfoTree) : List α :=
infoTree.collectNodesBottomUp fun ctx i cs rs =>
if rs.isEmpty then
match p ctx i cs with

View file

@ -101,7 +101,6 @@ end Lean.Lsp.ModuleRefs
namespace Lean.Server
open IO
open Std
open Lsp
open Elab

View file

@ -56,7 +56,7 @@ def parseRequestParams (paramType : Type) [FromJson paramType] (params : Json)
message := s!"Cannot parse request params: {params.compress}\n{inner}" }
structure RequestContext where
rpcSessions : Std.RBMap UInt64 (IO.Ref FileWorker.RpcSession) compare
rpcSessions : RBMap UInt64 (IO.Ref FileWorker.RpcSession) compare
srcSearchPath : SearchPath
doc : FileWorker.EditableDocument
hLog : IO.FS.Stream
@ -181,7 +181,7 @@ structure RequestHandler where
fileSource : Json → Except RequestError Lsp.DocumentUri
handle : Json → RequestM (RequestTask Json)
builtin_initialize requestHandlers : IO.Ref (Std.PersistentHashMap String RequestHandler) ←
builtin_initialize requestHandlers : IO.Ref (PersistentHashMap String RequestHandler) ←
IO.mkRef {}
/-- NB: This method may only be called in `initialize` blocks (user or builtin).

View file

@ -30,7 +30,6 @@ instance : ToString RpcRef where
end Lean.Lsp
namespace Lean.Server
open Std
structure RpcObjectStore : Type where
/-- Objects that are being kept alive for the RPC client, together with their type names,
@ -39,7 +38,7 @@ structure RpcObjectStore : Type where
Note that we may currently have multiple references to the same object. It is only disposed
of once all of those are gone. This simplifies the client a bit as it can drop every reference
received separately. -/
aliveRefs : Std.PersistentHashMap Lsp.RpcRef Dynamic := {}
aliveRefs : PersistentHashMap Lsp.RpcRef Dynamic := {}
/-- Value to use for the next `RpcRef`. It is monotonically increasing to avoid any possible
bugs resulting from its reuse. -/
nextRef : USize := 0
@ -71,7 +70,7 @@ The type wrapper `WithRpcRef` is used for these fields which should be sent as
a reference.
- Any type with `FromJson` and `ToJson` instance is automatically `RpcEncodable`.
- If a type has an `Std.Dynamic` instance, then `WithRpcRef` can be used for its references.
- If a type has an `Dynamic` instance, then `WithRpcRef` can be used for its references.
- `deriving RpcEncodable` acts like `FromJson`/`ToJson` but marshalls any `WithRpcRef` fields
as `Lsp.RpcRef`s.
-/

View file

@ -18,7 +18,7 @@ private structure RpcProcedure where
/- We store the builtin RPC handlers in a Ref and users' handlers in an extension. This ensures
that users don't need to import core Lean modules to make builtin handlers work, but also that
they *can* easily create custom handlers and use them in the same file. -/
builtin_initialize builtinRpcProcedures : IO.Ref (Std.PHashMap Name RpcProcedure) ←
builtin_initialize builtinRpcProcedures : IO.Ref (PHashMap Name RpcProcedure) ←
IO.mkRef {}
builtin_initialize userRpcProcedures : MapDeclarationExtension Name ←
mkMapDeclarationExtension `userRpcProcedures

View file

@ -36,7 +36,7 @@ structure Snapshot where
/-- We cache interactive diagnostics in order not to invoke the pretty-printer again on messages
from previous snapshots when publishing diagnostics for every new snapshot (this is quadratic),
as well as not to invoke it once again when handling `$/lean/interactiveDiagnostics`. -/
interactiveDiags : Std.PersistentArray Widget.InteractiveDiagnostic
interactiveDiags : PersistentArray Widget.InteractiveDiagnostic
tacticCache : IO.Ref Tactic.Cache
instance : Inhabited Snapshot where
@ -60,7 +60,7 @@ def env (s : Snapshot) : Environment :=
def msgLog (s : Snapshot) : MessageLog :=
s.cmdState.messages
def diagnostics (s : Snapshot) : Std.PersistentArray Lsp.Diagnostic :=
def diagnostics (s : Snapshot) : PersistentArray Lsp.Diagnostic :=
s.interactiveDiags.map fun d => d.toDiagnostic
def infoTree (s : Snapshot) : InfoTree :=
@ -173,7 +173,7 @@ where
/-- Compute the current interactive diagnostics log by finding a "diff" relative to the parent
snapshot. We need to do this because unlike the `MessageLog` itself, interactive diags are not
part of the command state. -/
withNewInteractiveDiags (msgLog : MessageLog) : IO (Std.PersistentArray Widget.InteractiveDiagnostic) := do
withNewInteractiveDiags (msgLog : MessageLog) : IO (PersistentArray Widget.InteractiveDiagnostic) := do
let newMsgCount := msgLog.msgs.size - snap.msgLog.msgs.size
let mut ret := snap.interactiveDiags
for i in List.iota newMsgCount do

View file

@ -65,7 +65,6 @@ non-standard extensions in case they're needed, for example to communicate tacti
namespace Lean.Server.Watchdog
open IO
open Std (RBMap RBMap.empty)
open Lsp
open JsonRpc
open System.Uri

View file

@ -40,7 +40,7 @@ def StructureInfo.getProjFn? (info : StructureInfo) (i : Nat) : Option Name :=
/-- Auxiliary state for structures defined in the current module. -/
private structure StructureState where
map : Std.PersistentHashMap Name StructureInfo := {}
map : PersistentHashMap Name StructureInfo := {}
deriving Inhabited
builtin_initialize structureExt : SimplePersistentEnvExtension StructureInfo StructureState ← registerSimplePersistentEnvExtension {

View file

@ -168,7 +168,7 @@ def mkRoot (e : Expr) : SubExpr := ⟨e, Pos.root⟩
def isRoot (s : SubExpr) : Bool := s.pos.isRoot
/-- Map from subexpr positions to values. -/
abbrev PosMap (α : Type u) := Std.RBMap Pos α compare
abbrev PosMap (α : Type u) := RBMap Pos α compare
def bindingBody! : SubExpr → SubExpr
| ⟨.forallE _ _ b _, p⟩ => ⟨b, p.pushBindingBody⟩

View file

@ -8,7 +8,7 @@ import Lean.Expr
namespace Lean
structure HasConstCache (declName : Name) where
cache : Std.HashMapImp Expr Bool := Std.mkHashMapImp
cache : HashMapImp Expr Bool := mkHashMapImp
unsafe def HasConstCache.containsUnsafe (e : Expr) : StateM (HasConstCache declName) Bool := do
if let some r := (← get).cache.find? (beq := ⟨ptrEq⟩) e then

View file

@ -29,8 +29,6 @@ instance {α β ε : Type} {m : Type → Type} [MonadCache α β m] [Monad m] :
findCached? a := ExceptT.lift $ MonadCache.findCached? a
cache a b := ExceptT.lift $ MonadCache.cache a b
open Std (HashMap)
/-- Adapter for implementing `MonadCache` interface using `HashMap`s.
We just have to specify how to extract/modify the `HashMap`. -/
class MonadHashMapCacheAdapter (α β : Type) (m : Type → Type) [BEq α] [Hashable α] where
@ -63,7 +61,7 @@ instance : MonadHashMapCacheAdapter α β (MonadCacheT α β m) where
modifyCache f := (modify f : StateRefT' ..)
@[inline] def run {σ} (x : MonadCacheT α β m σ) : m σ :=
x.run' Std.mkHashMap
x.run' mkHashMap
instance : Monad (MonadCacheT α β m) := inferInstanceAs (Monad (StateRefT' _ _ _))
instance : MonadLift m (MonadCacheT α β m) := inferInstanceAs (MonadLift m (StateRefT' _ _ _))
@ -87,7 +85,7 @@ instance : MonadHashMapCacheAdapter α β (MonadStateCacheT α β m) where
modifyCache f := (modify f : StateT ..)
@[inline] def run {σ} (x : MonadStateCacheT α β m σ) : m σ :=
x.run' Std.mkHashMap
x.run' mkHashMap
instance : Monad (MonadStateCacheT α β m) := inferInstanceAs (Monad (StateT _ _))
instance : MonadLift m (MonadStateCacheT α β m) := inferInstanceAs (MonadLift m (StateT _ _))

View file

@ -11,7 +11,6 @@ namespace Lean.SCC
compiler mutually recursive definitions, where each function
(and nested let-rec) in the mutual block is a vertex.
So, the graphs are small. -/
open Std
section
variable (α : Type) [BEq α] [Hashable α]
@ -24,7 +23,7 @@ structure Data where
structure State where
stack : List α := []
nextIndex : Nat := 0
data : Std.HashMap α Data := {}
data : HashMap α Data := {}
sccs : List (List α) := []
abbrev M := StateM (State α)

View file

@ -10,7 +10,6 @@ import Lean.Data.PersistentHashSet
open ShareCommon
namespace Lean.ShareCommon
open Std
def objectFactory :=
StateFactory.mk {

View file

@ -57,8 +57,6 @@ try to follow these guidelines:
namespace Lean
open Std (PersistentArray)
structure TraceElem where
ref : Syntax
msg : MessageData
@ -68,7 +66,7 @@ structure TraceState where
traces : PersistentArray TraceElem := {}
deriving Inhabited
builtin_initialize inheritedTraceOptions : IO.Ref (Std.HashSet Name) ← IO.mkRef ∅
builtin_initialize inheritedTraceOptions : IO.Ref (HashSet Name) ← IO.mkRef ∅
class MonadTrace (m : Type → Type) where
modifyTraceState : (TraceState → TraceState) → m Unit
@ -89,7 +87,7 @@ def printTraces : m Unit := do
def resetTraceState : m Unit :=
modifyTraceState (fun _ => {})
private def checkTraceOption (inherited : Std.HashSet Name) (opts : Options) (cls : Name) : Bool :=
private def checkTraceOption (inherited : HashSet Name) (opts : Options) (cls : Name) : Bool :=
!opts.isEmpty && go (`trace ++ cls)
where
go (opt : Name) : Bool :=

View file

@ -57,7 +57,7 @@ private def mkPPContext (nCtx : NamingContext) (ctx : MessageDataContext) : PPCo
private inductive EmbedFmt
/-- Tags denote `Info` objects. -/
| expr (ctx : Elab.ContextInfo) (infos : Std.RBMap Nat Elab.Info compare)
| expr (ctx : Elab.ContextInfo) (infos : RBMap Nat Elab.Info compare)
| goal (ctx : Elab.ContextInfo) (lctx : LocalContext) (g : MVarId)
/-- Some messages (in particular, traces) are too costly to print eagerly. Instead, we allow
the user to expand sub-traces interactively. -/

View file

@ -51,7 +51,7 @@ structure UserWidget where
private abbrev WidgetSourceRegistry := SimplePersistentEnvExtension
(UInt64 × Name)
(Std.RBMap UInt64 Name compare)
(RBMap UInt64 Name compare)
-- Mapping widgetSourceId to hash of sourcetext
builtin_initialize userWidgetRegistry : MapDeclarationExtension UserWidget ← mkMapDeclarationExtension `widgetRegistry

Some files were not shown because too many files have changed in this diff Show more