diff --git a/src/Init/Data/Hashable.lean b/src/Init/Data/Hashable.lean index 5420c44255..4a41888514 100644 --- a/src/Init/Data/Hashable.lean +++ b/src/Init/Data/Hashable.lean @@ -42,42 +42,4 @@ instance : Hashable Int where | Int.negSucc n => UInt64.ofNat (2 * n + 1) instance (P : Prop) : Hashable P where - hash := Function.const P 0 - --- TO DELETE - -instance : HashableUSize Nat where - hashUSize n := USize.ofNat n - -instance [HashableUSize α] [HashableUSize β] : HashableUSize (α × β) where - hashUSize | (a, b) => mixUSizeHash (hashUSize a) (hashUSize b) - -instance : HashableUSize Bool where - hashUSize - | true => 11 - | false => 13 - -instance [HashableUSize α] : HashableUSize (Option α) where - hashUSize - | none => 11 - | some a => mixUSizeHash (hashUSize a) 13 - -instance [HashableUSize α] : HashableUSize (List α) where - hashUSize as := as.foldl (fun r a => mixUSizeHash r (hashUSize a)) 7 - -instance : HashableUSize UInt32 where - hashUSize n := n.toUSize - -instance : HashableUSize UInt64 where - hashUSize n := n.toUSize - -instance : HashableUSize USize where - hashUSize n := n - -instance : HashableUSize Int where - hashUSize - | Int.ofNat n => USize.ofNat (2 * n) - | Int.negSucc n => USize.ofNat (2 * n + 1) - -instance (P : Prop) : HashableUSize P where - hashUSize := Function.const P 0 + hash p := 0 diff --git a/src/Lean/Compiler/IR/Basic.lean b/src/Lean/Compiler/IR/Basic.lean index f3a03fa022..8931dcb121 100644 --- a/src/Lean/Compiler/IR/Basic.lean +++ b/src/Lean/Compiler/IR/Basic.lean @@ -35,12 +35,12 @@ abbrev Index.lt (a b : Index) : Bool := a < b instance : BEq VarId := ⟨fun a b => a.idx == b.idx⟩ instance : ToString VarId := ⟨fun a => "x_" ++ toString a.idx⟩ instance : ToFormat VarId := ⟨fun a => toString a⟩ -instance : HashableUSize VarId := ⟨fun a => hashUSize a.idx⟩ +instance : Hashable VarId := ⟨fun a => hash a.idx⟩ instance : BEq JoinPointId := ⟨fun a b => a.idx == b.idx⟩ instance : ToString JoinPointId := ⟨fun a => "block_" ++ toString a.idx⟩ instance : ToFormat JoinPointId := ⟨fun a => toString a⟩ -instance : HashableUSize JoinPointId := ⟨fun a => hashUSize a.idx⟩ +instance : Hashable JoinPointId := ⟨fun a => hash a.idx⟩ abbrev MData := KVMap abbrev MData.empty : MData := {} diff --git a/src/Lean/Compiler/IR/Borrow.lean b/src/Lean/Compiler/IR/Borrow.lean index 4cdf9f439b..71c49ebc39 100644 --- a/src/Lean/Compiler/IR/Borrow.lean +++ b/src/Lean/Compiler/IR/Borrow.lean @@ -19,9 +19,9 @@ def beq : Key → Key → Bool instance : BEq Key := ⟨beq⟩ -def getHash : Key → USize - | (f, x) => mixUSizeHash (hashUSize f) (hashUSize x) -instance : HashableUSize Key := ⟨getHash⟩ +def getHash : Key → UInt64 + | (f, x) => mixHash (hash f) (hash x) +instance : Hashable Key := ⟨getHash⟩ end OwnedSet open OwnedSet (Key) in @@ -40,11 +40,11 @@ inductive Key where | jp (name : FunId) (jpid : JoinPointId) deriving BEq -def getHash : Key → USize - | Key.decl n => hashUSize n - | Key.jp n id => mixUSizeHash (hashUSize n) (hashUSize id) +def getHash : Key → UInt64 + | Key.decl n => hash n + | Key.jp n id => mixHash (hash n) (hash id) -instance : HashableUSize Key := ⟨getHash⟩ +instance : Hashable Key := ⟨getHash⟩ end ParamMap open ParamMap (Key) diff --git a/src/Lean/Elab/Deriving/Hashable.lean b/src/Lean/Elab/Deriving/Hashable.lean index 9f5f5cc723..f2b55effd7 100644 --- a/src/Lean/Elab/Deriving/Hashable.lean +++ b/src/Lean/Elab/Deriving/Hashable.lean @@ -86,5 +86,5 @@ def mkHashableHandler (declNames : Array Name) : CommandElabM Bool := do return false builtin_initialize - registerBuiltinDerivingHandler ``HashableUSize mkHashableHandler + registerBuiltinDerivingHandler ``Hashable mkHashableHandler registerTraceClass `Elab.Deriving.hashable diff --git a/src/Lean/HeadIndex.lean b/src/Lean/HeadIndex.lean index fa7bf42d47..6fa3e28d83 100644 --- a/src/Lean/HeadIndex.lean +++ b/src/Lean/HeadIndex.lean @@ -20,17 +20,17 @@ inductive HeadIndex where namespace HeadIndex -protected def HeadIndex.hash : HeadIndex → USize - | fvar fvarId => mixUSizeHash 11 $ hashUSize fvarId - | mvar mvarId => mixUSizeHash 13 $ hashUSize mvarId - | const constName => mixUSizeHash 17 $ hashUSize constName - | proj structName idx => mixUSizeHash 19 $ mixUSizeHash (hashUSize structName) (hashUSize idx) - | lit litVal => mixUSizeHash 23 $ hashUSize litVal +protected def HeadIndex.hash : HeadIndex → UInt64 + | fvar fvarId => mixHash 11 $ hash fvarId + | mvar mvarId => mixHash 13 $ hash mvarId + | const constName => mixHash 17 $ hash constName + | proj structName idx => mixHash 19 $ mixHash (hash structName) (hash idx) + | lit litVal => mixHash 23 $ hash litVal | sort => 29 | lam => 31 | forallE => 37 -instance : HashableUSize HeadIndex := ⟨HeadIndex.hash⟩ +instance : Hashable HeadIndex := ⟨HeadIndex.hash⟩ end HeadIndex diff --git a/src/Lean/Meta/Basic.lean b/src/Lean/Meta/Basic.lean index 7e6183d74a..fea3d4c869 100644 --- a/src/Lean/Meta/Basic.lean +++ b/src/Lean/Meta/Basic.lean @@ -80,8 +80,8 @@ structure InfoCacheKey where deriving Inhabited, BEq namespace InfoCacheKey -instance : HashableUSize InfoCacheKey := - ⟨fun ⟨transparency, expr, nargs⟩ => mixUSizeHash (hashUSize transparency) <| mixUSizeHash (hashUSize expr) (hashUSize nargs)⟩ +instance : Hashable InfoCacheKey := + ⟨fun ⟨transparency, expr, nargs⟩ => mixHash (hash transparency) <| mixHash (hash expr) (hash nargs)⟩ end InfoCacheKey open Std (PersistentArray PersistentHashMap) diff --git a/src/Lean/Meta/DiscrTreeTypes.lean b/src/Lean/Meta/DiscrTreeTypes.lean index 655893cf99..460991be47 100644 --- a/src/Lean/Meta/DiscrTreeTypes.lean +++ b/src/Lean/Meta/DiscrTreeTypes.lean @@ -20,15 +20,15 @@ inductive Key where | arrow : Key deriving Inhabited, BEq -protected def Key.hash : Key → USize - | Key.const n a => mixUSizeHash 5237 $ mixUSizeHash (hashUSize n) (hashUSize a) - | Key.fvar n a => mixUSizeHash 3541 $ mixUSizeHash (hashUSize n) (hashUSize a) - | Key.lit v => mixUSizeHash 1879 $ hashUSize v +protected def Key.hash : Key → UInt64 + | Key.const n a => mixHash 5237 $ mixHash (hash n) (hash a) + | Key.fvar n a => mixHash 3541 $ mixHash (hash n) (hash a) + | Key.lit v => mixHash 1879 $ hash v | Key.star => 7883 | Key.other => 2411 | Key.arrow => 17 -instance : HashableUSize Key := ⟨Key.hash⟩ +instance : Hashable Key := ⟨Key.hash⟩ inductive Trie (α : Type) where | node (vs : Array α) (children : Array (Key × Trie α)) : Trie α diff --git a/src/Lean/Meta/TransparencyMode.lean b/src/Lean/Meta/TransparencyMode.lean index 7988bccadc..3a36af4b7f 100644 --- a/src/Lean/Meta/TransparencyMode.lean +++ b/src/Lean/Meta/TransparencyMode.lean @@ -11,13 +11,13 @@ inductive TransparencyMode where namespace TransparencyMode -def hash : TransparencyMode → USize +def hash : TransparencyMode → UInt64 | all => 7 | default => 11 | reducible => 13 | instances => 17 -instance : HashableUSize TransparencyMode := ⟨hash⟩ +instance : Hashable TransparencyMode := ⟨hash⟩ def lt : TransparencyMode → TransparencyMode → Bool | reducible, default => true