summaryrefslogtreecommitdiff
path: root/tests/lean/Hashmap
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lean/Hashmap')
-rw-r--r--tests/lean/Hashmap/Funs.lean70
-rw-r--r--tests/lean/Hashmap/FunsExternal.lean19
-rw-r--r--tests/lean/Hashmap/FunsExternal_Template.lean16
-rw-r--r--tests/lean/Hashmap/Types.lean5
-rw-r--r--tests/lean/Hashmap/TypesExternal.lean7
-rw-r--r--tests/lean/Hashmap/TypesExternal_Template.lean9
6 files changed, 94 insertions, 32 deletions
diff --git a/tests/lean/Hashmap/Funs.lean b/tests/lean/Hashmap/Funs.lean
index 4f05fbc8..d7ac3b05 100644
--- a/tests/lean/Hashmap/Funs.lean
+++ b/tests/lean/Hashmap/Funs.lean
@@ -2,17 +2,18 @@
-- [hashmap]: function definitions
import Base
import Hashmap.Types
+import Hashmap.FunsExternal
open Primitives
namespace hashmap
/- [hashmap::hash_key]:
- Source: 'tests/src/hashmap.rs', lines 35:0-35:32 -/
+ Source: 'tests/src/hashmap.rs', lines 37:0-37:32 -/
def hash_key (k : Usize) : Result Usize :=
Result.ok k
/- [hashmap::{hashmap::HashMap<T>}::allocate_slots]: loop 0:
- Source: 'tests/src/hashmap.rs', lines 58:4-64:5 -/
+ Source: 'tests/src/hashmap.rs', lines 60:4-66:5 -/
divergent def HashMap.allocate_slots_loop
(T : Type) (slots : alloc.vec.Vec (List T)) (n : Usize) :
Result (alloc.vec.Vec (List T))
@@ -26,7 +27,7 @@ divergent def HashMap.allocate_slots_loop
else Result.ok slots
/- [hashmap::{hashmap::HashMap<T>}::allocate_slots]:
- Source: 'tests/src/hashmap.rs', lines 58:4-58:76 -/
+ Source: 'tests/src/hashmap.rs', lines 60:4-60:76 -/
def HashMap.allocate_slots
(T : Type) (slots : alloc.vec.Vec (List T)) (n : Usize) :
Result (alloc.vec.Vec (List T))
@@ -34,7 +35,7 @@ def HashMap.allocate_slots
HashMap.allocate_slots_loop T slots n
/- [hashmap::{hashmap::HashMap<T>}::new_with_capacity]:
- Source: 'tests/src/hashmap.rs', lines 67:4-71:13 -/
+ Source: 'tests/src/hashmap.rs', lines 69:4-73:13 -/
def HashMap.new_with_capacity
(T : Type) (capacity : Usize) (max_load_dividend : Usize)
(max_load_divisor : Usize) :
@@ -53,12 +54,12 @@ def HashMap.new_with_capacity
}
/- [hashmap::{hashmap::HashMap<T>}::new]:
- Source: 'tests/src/hashmap.rs', lines 83:4-83:24 -/
+ Source: 'tests/src/hashmap.rs', lines 85:4-85:24 -/
def HashMap.new (T : Type) : Result (HashMap T) :=
HashMap.new_with_capacity T 32#usize 4#usize 5#usize
/- [hashmap::{hashmap::HashMap<T>}::clear]: loop 0:
- Source: 'tests/src/hashmap.rs', lines 88:4-96:5 -/
+ Source: 'tests/src/hashmap.rs', lines 90:4-98:5 -/
divergent def HashMap.clear_loop
(T : Type) (slots : alloc.vec.Vec (List T)) (i : Usize) :
Result (alloc.vec.Vec (List T))
@@ -76,19 +77,19 @@ divergent def HashMap.clear_loop
else Result.ok slots
/- [hashmap::{hashmap::HashMap<T>}::clear]:
- Source: 'tests/src/hashmap.rs', lines 88:4-88:27 -/
+ Source: 'tests/src/hashmap.rs', lines 90:4-90:27 -/
def HashMap.clear (T : Type) (self : HashMap T) : Result (HashMap T) :=
do
let hm ← HashMap.clear_loop T self.slots 0#usize
Result.ok { self with num_entries := 0#usize, slots := hm }
/- [hashmap::{hashmap::HashMap<T>}::len]:
- Source: 'tests/src/hashmap.rs', lines 98:4-98:30 -/
+ Source: 'tests/src/hashmap.rs', lines 100:4-100:30 -/
def HashMap.len (T : Type) (self : HashMap T) : Result Usize :=
Result.ok self.num_entries
/- [hashmap::{hashmap::HashMap<T>}::insert_in_list]: loop 0:
- Source: 'tests/src/hashmap.rs', lines 105:4-122:5 -/
+ Source: 'tests/src/hashmap.rs', lines 107:4-124:5 -/
divergent def HashMap.insert_in_list_loop
(T : Type) (key : Usize) (value : T) (ls : List T) :
Result (Bool × (List T))
@@ -104,7 +105,7 @@ divergent def HashMap.insert_in_list_loop
| List.Nil => Result.ok (true, List.Cons key value List.Nil)
/- [hashmap::{hashmap::HashMap<T>}::insert_in_list]:
- Source: 'tests/src/hashmap.rs', lines 105:4-105:71 -/
+ Source: 'tests/src/hashmap.rs', lines 107:4-107:71 -/
def HashMap.insert_in_list
(T : Type) (key : Usize) (value : T) (ls : List T) :
Result (Bool × (List T))
@@ -112,7 +113,7 @@ def HashMap.insert_in_list
HashMap.insert_in_list_loop T key value ls
/- [hashmap::{hashmap::HashMap<T>}::insert_no_resize]:
- Source: 'tests/src/hashmap.rs', lines 125:4-125:54 -/
+ Source: 'tests/src/hashmap.rs', lines 127:4-127:54 -/
def HashMap.insert_no_resize
(T : Type) (self : HashMap T) (key : Usize) (value : T) :
Result (HashMap T)
@@ -136,7 +137,7 @@ def HashMap.insert_no_resize
Result.ok { self with slots := v }
/- [hashmap::{hashmap::HashMap<T>}::move_elements_from_list]: loop 0:
- Source: 'tests/src/hashmap.rs', lines 191:4-204:5 -/
+ Source: 'tests/src/hashmap.rs', lines 193:4-206:5 -/
divergent def HashMap.move_elements_from_list_loop
(T : Type) (ntable : HashMap T) (ls : List T) : Result (HashMap T) :=
match ls with
@@ -147,13 +148,13 @@ divergent def HashMap.move_elements_from_list_loop
| List.Nil => Result.ok ntable
/- [hashmap::{hashmap::HashMap<T>}::move_elements_from_list]:
- Source: 'tests/src/hashmap.rs', lines 191:4-191:72 -/
+ Source: 'tests/src/hashmap.rs', lines 193:4-193:72 -/
def HashMap.move_elements_from_list
(T : Type) (ntable : HashMap T) (ls : List T) : Result (HashMap T) :=
HashMap.move_elements_from_list_loop T ntable ls
/- [hashmap::{hashmap::HashMap<T>}::move_elements]: loop 0:
- Source: 'tests/src/hashmap.rs', lines 179:4-188:5 -/
+ Source: 'tests/src/hashmap.rs', lines 181:4-190:5 -/
divergent def HashMap.move_elements_loop
(T : Type) (ntable : HashMap T) (slots : alloc.vec.Vec (List T)) (i : Usize)
:
@@ -174,7 +175,7 @@ divergent def HashMap.move_elements_loop
else Result.ok (ntable, slots)
/- [hashmap::{hashmap::HashMap<T>}::move_elements]:
- Source: 'tests/src/hashmap.rs', lines 179:4-179:95 -/
+ Source: 'tests/src/hashmap.rs', lines 181:4-181:95 -/
def HashMap.move_elements
(T : Type) (ntable : HashMap T) (slots : alloc.vec.Vec (List T)) (i : Usize)
:
@@ -183,7 +184,7 @@ def HashMap.move_elements
HashMap.move_elements_loop T ntable slots i
/- [hashmap::{hashmap::HashMap<T>}::try_resize]:
- Source: 'tests/src/hashmap.rs', lines 148:4-148:28 -/
+ Source: 'tests/src/hashmap.rs', lines 150:4-150:28 -/
def HashMap.try_resize (T : Type) (self : HashMap T) : Result (HashMap T) :=
do
let max_usize ← Scalar.cast .Usize core_u32_max
@@ -207,7 +208,7 @@ def HashMap.try_resize (T : Type) (self : HashMap T) : Result (HashMap T) :=
else Result.ok { self with max_load_factor := (i, i1) }
/- [hashmap::{hashmap::HashMap<T>}::insert]:
- Source: 'tests/src/hashmap.rs', lines 137:4-137:48 -/
+ Source: 'tests/src/hashmap.rs', lines 139:4-139:48 -/
def HashMap.insert
(T : Type) (self : HashMap T) (key : Usize) (value : T) :
Result (HashMap T)
@@ -220,7 +221,7 @@ def HashMap.insert
else Result.ok self1
/- [hashmap::{hashmap::HashMap<T>}::contains_key_in_list]: loop 0:
- Source: 'tests/src/hashmap.rs', lines 214:4-227:5 -/
+ Source: 'tests/src/hashmap.rs', lines 216:4-229:5 -/
divergent def HashMap.contains_key_in_list_loop
(T : Type) (key : Usize) (ls : List T) : Result Bool :=
match ls with
@@ -231,13 +232,13 @@ divergent def HashMap.contains_key_in_list_loop
| List.Nil => Result.ok false
/- [hashmap::{hashmap::HashMap<T>}::contains_key_in_list]:
- Source: 'tests/src/hashmap.rs', lines 214:4-214:68 -/
+ Source: 'tests/src/hashmap.rs', lines 216:4-216:68 -/
def HashMap.contains_key_in_list
(T : Type) (key : Usize) (ls : List T) : Result Bool :=
HashMap.contains_key_in_list_loop T key ls
/- [hashmap::{hashmap::HashMap<T>}::contains_key]:
- Source: 'tests/src/hashmap.rs', lines 207:4-207:49 -/
+ Source: 'tests/src/hashmap.rs', lines 209:4-209:49 -/
def HashMap.contains_key
(T : Type) (self : HashMap T) (key : Usize) : Result Bool :=
do
@@ -250,7 +251,7 @@ def HashMap.contains_key
HashMap.contains_key_in_list T key l
/- [hashmap::{hashmap::HashMap<T>}::get_in_list]: loop 0:
- Source: 'tests/src/hashmap.rs', lines 232:4-245:5 -/
+ Source: 'tests/src/hashmap.rs', lines 234:4-247:5 -/
divergent def HashMap.get_in_list_loop
(T : Type) (key : Usize) (ls : List T) : Result T :=
match ls with
@@ -261,12 +262,12 @@ divergent def HashMap.get_in_list_loop
| List.Nil => Result.fail .panic
/- [hashmap::{hashmap::HashMap<T>}::get_in_list]:
- Source: 'tests/src/hashmap.rs', lines 232:4-232:70 -/
+ Source: 'tests/src/hashmap.rs', lines 234:4-234:70 -/
def HashMap.get_in_list (T : Type) (key : Usize) (ls : List T) : Result T :=
HashMap.get_in_list_loop T key ls
/- [hashmap::{hashmap::HashMap<T>}::get]:
- Source: 'tests/src/hashmap.rs', lines 247:4-247:55 -/
+ Source: 'tests/src/hashmap.rs', lines 249:4-249:55 -/
def HashMap.get (T : Type) (self : HashMap T) (key : Usize) : Result T :=
do
let hash ← hash_key key
@@ -278,7 +279,7 @@ def HashMap.get (T : Type) (self : HashMap T) (key : Usize) : Result T :=
HashMap.get_in_list T key l
/- [hashmap::{hashmap::HashMap<T>}::get_mut_in_list]: loop 0:
- Source: 'tests/src/hashmap.rs', lines 253:4-262:5 -/
+ Source: 'tests/src/hashmap.rs', lines 255:4-264:5 -/
divergent def HashMap.get_mut_in_list_loop
(T : Type) (ls : List T) (key : Usize) :
Result (T × (T → Result (List T)))
@@ -301,7 +302,7 @@ divergent def HashMap.get_mut_in_list_loop
| List.Nil => Result.fail .panic
/- [hashmap::{hashmap::HashMap<T>}::get_mut_in_list]:
- Source: 'tests/src/hashmap.rs', lines 253:4-253:86 -/
+ Source: 'tests/src/hashmap.rs', lines 255:4-255:86 -/
def HashMap.get_mut_in_list
(T : Type) (ls : List T) (key : Usize) :
Result (T × (T → Result (List T)))
@@ -309,7 +310,7 @@ def HashMap.get_mut_in_list
HashMap.get_mut_in_list_loop T ls key
/- [hashmap::{hashmap::HashMap<T>}::get_mut]:
- Source: 'tests/src/hashmap.rs', lines 265:4-265:67 -/
+ Source: 'tests/src/hashmap.rs', lines 267:4-267:67 -/
def HashMap.get_mut
(T : Type) (self : HashMap T) (key : Usize) :
Result (T × (T → Result (HashMap T)))
@@ -331,7 +332,7 @@ def HashMap.get_mut
Result.ok (t, back)
/- [hashmap::{hashmap::HashMap<T>}::remove_from_list]: loop 0:
- Source: 'tests/src/hashmap.rs', lines 273:4-299:5 -/
+ Source: 'tests/src/hashmap.rs', lines 275:4-301:5 -/
divergent def HashMap.remove_from_list_loop
(T : Type) (key : Usize) (ls : List T) : Result ((Option T) × (List T)) :=
match ls with
@@ -350,13 +351,13 @@ divergent def HashMap.remove_from_list_loop
| List.Nil => Result.ok (none, List.Nil)
/- [hashmap::{hashmap::HashMap<T>}::remove_from_list]:
- Source: 'tests/src/hashmap.rs', lines 273:4-273:69 -/
+ Source: 'tests/src/hashmap.rs', lines 275:4-275:69 -/
def HashMap.remove_from_list
(T : Type) (key : Usize) (ls : List T) : Result ((Option T) × (List T)) :=
HashMap.remove_from_list_loop T key ls
/- [hashmap::{hashmap::HashMap<T>}::remove]:
- Source: 'tests/src/hashmap.rs', lines 302:4-302:52 -/
+ Source: 'tests/src/hashmap.rs', lines 304:4-304:52 -/
def HashMap.remove
(T : Type) (self : HashMap T) (key : Usize) :
Result ((Option T) × (HashMap T))
@@ -380,8 +381,17 @@ def HashMap.remove
let v ← index_mut_back l1
Result.ok (some x1, { self with num_entries := i1, slots := v })
+/- [hashmap::insert_on_disk]:
+ Source: 'tests/src/hashmap.rs', lines 335:0-335:43 -/
+def insert_on_disk
+ (key : Usize) (value : U64) (st : State) : Result (State × Unit) :=
+ do
+ let (st1, hm) ← utils.deserialize st
+ let hm1 ← HashMap.insert U64 hm key value
+ utils.serialize hm1 st1
+
/- [hashmap::test1]:
- Source: 'tests/src/hashmap.rs', lines 323:0-323:10 -/
+ Source: 'tests/src/hashmap.rs', lines 350:0-350:10 -/
def test1 : Result Unit :=
do
let hm ← HashMap.new U64
diff --git a/tests/lean/Hashmap/FunsExternal.lean b/tests/lean/Hashmap/FunsExternal.lean
new file mode 100644
index 00000000..329e5d82
--- /dev/null
+++ b/tests/lean/Hashmap/FunsExternal.lean
@@ -0,0 +1,19 @@
+-- [hashmap]: external functions.
+import Base
+import Hashmap.Types
+open Primitives
+open hashmap
+
+-- TODO: fill those bodies
+
+/- [hashmap::utils::deserialize]:
+ Source: 'tests/src/hashmap.rs', lines 330:4-330:47 -/
+def utils.deserialize
+ : State → Result (State × (HashMap U64)) :=
+ fun _ => .fail .panic
+
+/- [hashmap::utils::serialize]:
+ Source: 'tests/src/hashmap.rs', lines 325:4-325:46 -/
+def utils.serialize
+ : HashMap U64 → State → Result (State × Unit) :=
+ fun _ _ => .fail .panic
diff --git a/tests/lean/Hashmap/FunsExternal_Template.lean b/tests/lean/Hashmap/FunsExternal_Template.lean
new file mode 100644
index 00000000..2af57d10
--- /dev/null
+++ b/tests/lean/Hashmap/FunsExternal_Template.lean
@@ -0,0 +1,16 @@
+-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
+-- [hashmap]: external functions.
+-- This is a template file: rename it to "FunsExternal.lean" and fill the holes.
+import Base
+import Hashmap.Types
+open Primitives
+open hashmap
+
+/- [hashmap::utils::deserialize]:
+ Source: 'tests/src/hashmap.rs', lines 330:4-330:47 -/
+axiom utils.deserialize : State → Result (State × (HashMap U64))
+
+/- [hashmap::utils::serialize]:
+ Source: 'tests/src/hashmap.rs', lines 325:4-325:46 -/
+axiom utils.serialize : HashMap U64 → State → Result (State × Unit)
+
diff --git a/tests/lean/Hashmap/Types.lean b/tests/lean/Hashmap/Types.lean
index a98b972f..b4301106 100644
--- a/tests/lean/Hashmap/Types.lean
+++ b/tests/lean/Hashmap/Types.lean
@@ -1,18 +1,19 @@
-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
-- [hashmap]: type definitions
import Base
+import Hashmap.TypesExternal
open Primitives
namespace hashmap
/- [hashmap::List]
- Source: 'tests/src/hashmap.rs', lines 27:0-27:16 -/
+ Source: 'tests/src/hashmap.rs', lines 29:0-29:16 -/
inductive List (T : Type) :=
| Cons : Usize → T → List T → List T
| Nil : List T
/- [hashmap::HashMap]
- Source: 'tests/src/hashmap.rs', lines 43:0-43:21 -/
+ Source: 'tests/src/hashmap.rs', lines 45:0-45:21 -/
structure HashMap (T : Type) where
num_entries : Usize
max_load_factor : (Usize × Usize)
diff --git a/tests/lean/Hashmap/TypesExternal.lean b/tests/lean/Hashmap/TypesExternal.lean
new file mode 100644
index 00000000..b32c4c42
--- /dev/null
+++ b/tests/lean/Hashmap/TypesExternal.lean
@@ -0,0 +1,7 @@
+-- [hashmap]: external types.
+import Base
+open Primitives
+
+/- The state type used in the state-error monad -/
+axiom State : Type
+
diff --git a/tests/lean/Hashmap/TypesExternal_Template.lean b/tests/lean/Hashmap/TypesExternal_Template.lean
new file mode 100644
index 00000000..03c3d157
--- /dev/null
+++ b/tests/lean/Hashmap/TypesExternal_Template.lean
@@ -0,0 +1,9 @@
+-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
+-- [hashmap]: external types.
+-- This is a template file: rename it to "TypesExternal.lean" and fill the holes.
+import Base
+open Primitives
+
+/- The state type used in the state-error monad -/
+axiom State : Type
+