summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--backends/lean/Base/Primitives/Vec.lean8
-rw-r--r--tests/lean/Hashmap/Funs.lean4
-rw-r--r--tests/lean/HashmapMain/Funs.lean4
-rw-r--r--tests/lean/Loops/Funs.lean2
4 files changed, 9 insertions, 9 deletions
diff --git a/backends/lean/Base/Primitives/Vec.lean b/backends/lean/Base/Primitives/Vec.lean
index d37fb5fd..c4c4d9f2 100644
--- a/backends/lean/Base/Primitives/Vec.lean
+++ b/backends/lean/Base/Primitives/Vec.lean
@@ -79,7 +79,7 @@ theorem Vec.insert_spec {α : Type u} (v: Vec α) (i: Usize) (x: α)
∃ nv, v.insert α i x = ret nv ∧ nv.val = v.val.update i.val x := by
simp [insert, *]
-def Vec.index (α : Type u) (v: Vec α) (i: Usize) : Result α :=
+def Vec.index_shared (α : Type u) (v: Vec α) (i: Usize) : Result α :=
match v.val.indexOpt i.val with
| none => fail .arrayOutOfBounds
| some x => ret x
@@ -90,10 +90,10 @@ def Vec.index (α : Type u) (v: Vec α) (i: Usize) : Result α :=
-/
@[pspec]
-theorem Vec.index_spec {α : Type u} [Inhabited α] (v: Vec α) (i: Usize)
+theorem Vec.index_shared_spec {α : Type u} [Inhabited α] (v: Vec α) (i: Usize)
(hbound : i.val < v.length) :
- ∃ x, v.index α i = ret x ∧ x = v.val.index i.val := by
- simp only [index]
+ ∃ x, v.index_shared α i = ret x ∧ x = v.val.index i.val := by
+ simp only [index_shared]
-- TODO: dependent rewrite
have h := List.indexOpt_eq_index v.val i.val (by scalar_tac) (by simp [*])
simp [*]
diff --git a/tests/lean/Hashmap/Funs.lean b/tests/lean/Hashmap/Funs.lean
index 2fa981ce..d6796932 100644
--- a/tests/lean/Hashmap/Funs.lean
+++ b/tests/lean/Hashmap/Funs.lean
@@ -239,7 +239,7 @@ def HashMap.contains_key
let hash ← hash_key key
let i := Vec.len (List T) self.slots
let hash_mod ← hash % i
- let l ← Vec.index (List T) self.slots hash_mod
+ let l ← Vec.index_shared (List T) self.slots hash_mod
HashMap.contains_key_in_list T key l
/- [hashmap::HashMap::{0}::get_in_list]: loop 0: forward function -/
@@ -262,7 +262,7 @@ def HashMap.get (T : Type) (self : HashMap T) (key : Usize) : Result T :=
let hash ← hash_key key
let i := Vec.len (List T) self.slots
let hash_mod ← hash % i
- let l ← Vec.index (List T) self.slots hash_mod
+ let l ← Vec.index_shared (List T) self.slots hash_mod
HashMap.get_in_list T key l
/- [hashmap::HashMap::{0}::get_mut_in_list]: loop 0: forward function -/
diff --git a/tests/lean/HashmapMain/Funs.lean b/tests/lean/HashmapMain/Funs.lean
index ea28b03f..74fe8a54 100644
--- a/tests/lean/HashmapMain/Funs.lean
+++ b/tests/lean/HashmapMain/Funs.lean
@@ -261,7 +261,7 @@ def hashmap.HashMap.contains_key
let hash ← hashmap.hash_key key
let i := Vec.len (hashmap.List T) self.slots
let hash_mod ← hash % i
- let l ← Vec.index (hashmap.List T) self.slots hash_mod
+ let l ← Vec.index_shared (hashmap.List T) self.slots hash_mod
hashmap.HashMap.contains_key_in_list T key l
/- [hashmap_main::hashmap::HashMap::{0}::get_in_list]: loop 0: forward function -/
@@ -286,7 +286,7 @@ def hashmap.HashMap.get
let hash ← hashmap.hash_key key
let i := Vec.len (hashmap.List T) self.slots
let hash_mod ← hash % i
- let l ← Vec.index (hashmap.List T) self.slots hash_mod
+ let l ← Vec.index_shared (hashmap.List T) self.slots hash_mod
hashmap.HashMap.get_in_list T key l
/- [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: loop 0: forward function -/
diff --git a/tests/lean/Loops/Funs.lean b/tests/lean/Loops/Funs.lean
index fac0c5a9..5fbe200f 100644
--- a/tests/lean/Loops/Funs.lean
+++ b/tests/lean/Loops/Funs.lean
@@ -178,7 +178,7 @@ divergent def get_elem_shared_loop
/- [loops::get_elem_shared]: forward function -/
def get_elem_shared (slots : Vec (List Usize)) (x : Usize) : Result Usize :=
do
- let l ← Vec.index (List Usize) slots (Usize.ofInt 0)
+ let l ← Vec.index_shared (List Usize) slots (Usize.ofInt 0)
get_elem_shared_loop x l
/- [loops::id_mut]: forward function -/