chore: remove HashableUSize instances

This commit is contained in:
Leonardo de Moura 2021-06-02 08:48:11 -07:00
parent e619e7c093
commit 37da993032
8 changed files with 27 additions and 65 deletions

View file

@ -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

View file

@ -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 := {}

View file

@ -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)

View file

@ -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

View file

@ -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

View file

@ -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)

View file

@ -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 α

View file

@ -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