summaryrefslogtreecommitdiff
path: root/tests/lean/hashmap_on_disk/HashmapMain
diff options
context:
space:
mode:
authorJonathan Protzenko2023-02-02 23:36:14 -0800
committerSon HO2023-06-04 21:44:33 +0200
commit40e7df701d246faa453003374206014606ca6b6d (patch)
tree4f4a199c90ce53937eae8ec4ecb9e0d1f7564a2c /tests/lean/hashmap_on_disk/HashmapMain
parentdad646759a3ab9175c8797f144dec9d8e07b54b3 (diff)
WIP
Diffstat (limited to 'tests/lean/hashmap_on_disk/HashmapMain')
-rw-r--r--tests/lean/hashmap_on_disk/HashmapMain/Clauses/Template.lean113
-rw-r--r--tests/lean/hashmap_on_disk/HashmapMain/Funs.lean8
-rw-r--r--tests/lean/hashmap_on_disk/HashmapMain/Opaque.lean18
-rw-r--r--tests/lean/hashmap_on_disk/HashmapMain/Types.lean4
4 files changed, 129 insertions, 14 deletions
diff --git a/tests/lean/hashmap_on_disk/HashmapMain/Clauses/Template.lean b/tests/lean/hashmap_on_disk/HashmapMain/Clauses/Template.lean
new file mode 100644
index 00000000..bf331d6e
--- /dev/null
+++ b/tests/lean/hashmap_on_disk/HashmapMain/Clauses/Template.lean
@@ -0,0 +1,113 @@
+-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS
+-- [hashmap_main]: templates for the decreases clauses
+import Base.Primitives
+import HashmapMain.Types
+
+/- [hashmap_main::hashmap::HashMap::{0}::allocate_slots]: termination measure -/
+@[simp]
+def hashmap_hash_map_allocate_slots_loop_terminates (T : Type)
+ (slots : vec (hashmap_list_t T)) (n : USize) :=
+ (slots, n)
+
+syntax "hashmap_hash_map_allocate_slots_loop_decreases" term+ : tactic
+
+macro_rules
+| `(tactic| hashmap_hash_map_allocate_slots_loop_decreases $slots $n) =>
+ `(tactic| sorry)
+
+/- [hashmap_main::hashmap::HashMap::{0}::clear_slots]: termination measure -/
+@[simp]
+def hashmap_hash_map_clear_slots_loop_terminates (T : Type)
+ (slots : vec (hashmap_list_t T)) (i : USize) :=
+ (slots, i)
+
+syntax "hashmap_hash_map_clear_slots_loop_decreases" term+ : tactic
+
+macro_rules
+| `(tactic| hashmap_hash_map_clear_slots_loop_decreases $slots $i) =>
+ `(tactic| sorry)
+
+/- [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: termination measure -/
+@[simp]
+def hashmap_hash_map_insert_in_list_loop_terminates (T : Type) (key : USize)
+ (value : T) (ls : hashmap_list_t T) :=
+ (key, value, ls)
+
+syntax "hashmap_hash_map_insert_in_list_loop_decreases" term+ : tactic
+
+macro_rules
+| `(tactic| hashmap_hash_map_insert_in_list_loop_decreases $key $value $ls) =>
+ `(tactic| sorry)
+
+/- [hashmap_main::hashmap::HashMap::{0}::move_elements_from_list]: termination measure -/
+@[simp]
+def hashmap_hash_map_move_elements_from_list_loop_terminates (T : Type)
+ (ntable : hashmap_hash_map_t T) (ls : hashmap_list_t T) :=
+ (ntable, ls)
+
+syntax "hashmap_hash_map_move_elements_from_list_loop_decreases" term+ : tactic
+
+macro_rules
+| `(tactic| hashmap_hash_map_move_elements_from_list_loop_decreases $ntable
+$ls) =>`(tactic| sorry)
+
+/- [hashmap_main::hashmap::HashMap::{0}::move_elements]: termination measure -/
+@[simp]
+def hashmap_hash_map_move_elements_loop_terminates (T : Type)
+ (ntable : hashmap_hash_map_t T) (slots : vec (hashmap_list_t T)) (i : USize)
+ :=
+ (ntable, slots, i)
+
+syntax "hashmap_hash_map_move_elements_loop_decreases" term+ : tactic
+
+macro_rules
+| `(tactic| hashmap_hash_map_move_elements_loop_decreases $ntable $slots $i) =>
+ `(tactic| sorry)
+
+/- [hashmap_main::hashmap::HashMap::{0}::contains_key_in_list]: termination measure -/
+@[simp]
+def hashmap_hash_map_contains_key_in_list_loop_terminates (T : Type)
+ (key : USize) (ls : hashmap_list_t T) :=
+ (key, ls)
+
+syntax "hashmap_hash_map_contains_key_in_list_loop_decreases" term+ : tactic
+
+macro_rules
+| `(tactic| hashmap_hash_map_contains_key_in_list_loop_decreases $key $ls) =>
+ `(tactic| sorry)
+
+/- [hashmap_main::hashmap::HashMap::{0}::get_in_list]: termination measure -/
+@[simp]
+def hashmap_hash_map_get_in_list_loop_terminates (T : Type) (key : USize)
+ (ls : hashmap_list_t T) :=
+ (key, ls)
+
+syntax "hashmap_hash_map_get_in_list_loop_decreases" term+ : tactic
+
+macro_rules
+| `(tactic| hashmap_hash_map_get_in_list_loop_decreases $key $ls) =>`(tactic| sorry)
+
+/- [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: termination measure -/
+@[simp]
+def hashmap_hash_map_get_mut_in_list_loop_terminates (T : Type)
+ (ls : hashmap_list_t T) (key : USize) :=
+ (ls, key)
+
+syntax "hashmap_hash_map_get_mut_in_list_loop_decreases" term+ : tactic
+
+macro_rules
+| `(tactic| hashmap_hash_map_get_mut_in_list_loop_decreases $ls $key) =>
+ `(tactic| sorry)
+
+/- [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: termination measure -/
+@[simp]
+def hashmap_hash_map_remove_from_list_loop_terminates (T : Type) (key : USize)
+ (ls : hashmap_list_t T) :=
+ (key, ls)
+
+syntax "hashmap_hash_map_remove_from_list_loop_decreases" term+ : tactic
+
+macro_rules
+| `(tactic| hashmap_hash_map_remove_from_list_loop_decreases $key $ls) =>
+ `(tactic| sorry)
+
diff --git a/tests/lean/hashmap_on_disk/HashmapMain/Funs.lean b/tests/lean/hashmap_on_disk/HashmapMain/Funs.lean
index 5e78d9cf..ffe3416a 100644
--- a/tests/lean/hashmap_on_disk/HashmapMain/Funs.lean
+++ b/tests/lean/hashmap_on_disk/HashmapMain/Funs.lean
@@ -5,6 +5,8 @@ import HashmapMain.Types
import HashmapMain.Opaque
import HashmapMain.Clauses.Template
+section variable (opaque_defs: OpaqueDecls)
+
/- [hashmap_main::hashmap::hash_key] -/
def hashmap_hash_key_fwd (k : USize) : result USize := result.ret k
@@ -637,15 +639,15 @@ def hashmap_test1_fwd : result Unit :=
/- Unit test for [hashmap_main::hashmap::test1] -/
-#assert (hashmap_test1_fwd = ret ())
+#assert (hashmap_test1_fwd = .ret ())
/- [hashmap_main::insert_on_disk] -/
def insert_on_disk_fwd
(key : USize) (value : UInt64) (st : state) : result (state × Unit) :=
do
- let (st0, hm) <- hashmap_utils_deserialize_fwd st
+ let (st0, hm) <- opaque_defs.hashmap_utils_deserialize_fwd st
let hm0 <- hashmap_hash_map_insert_fwd_back UInt64 hm key value
- let (st1, _) <- hashmap_utils_serialize_fwd hm0 st0
+ let (st1, _) <- opaque_defs.hashmap_utils_serialize_fwd hm0 st0
result.ret (st1, ())
/- [hashmap_main::main] -/
diff --git a/tests/lean/hashmap_on_disk/HashmapMain/Opaque.lean b/tests/lean/hashmap_on_disk/HashmapMain/Opaque.lean
index 87b10c59..8b41934d 100644
--- a/tests/lean/hashmap_on_disk/HashmapMain/Opaque.lean
+++ b/tests/lean/hashmap_on_disk/HashmapMain/Opaque.lean
@@ -3,11 +3,13 @@
import Base.Primitives
import HashmapMain.Types
-/- [hashmap_main::hashmap_utils::deserialize] -/
-axiom hashmap_utils_deserialize_fwd
- : state -> result (state × (hashmap_hash_map_t UInt64))
-
-/- [hashmap_main::hashmap_utils::serialize] -/
-axiom hashmap_utils_serialize_fwd
- : hashmap_hash_map_t UInt64 -> state -> result (state × Unit)
-
+structure OpaqueDecls where
+
+ /- [hashmap_main::hashmap_utils::deserialize] -/
+ hashmap_utils_deserialize_fwd
+ : state -> result (state × (hashmap_hash_map_t UInt64))
+
+ /- [hashmap_main::hashmap_utils::serialize] -/
+ hashmap_utils_serialize_fwd
+ : hashmap_hash_map_t UInt64 -> state -> result (state × Unit)
+
diff --git a/tests/lean/hashmap_on_disk/HashmapMain/Types.lean b/tests/lean/hashmap_on_disk/HashmapMain/Types.lean
index d1cd9579..2a3ea462 100644
--- a/tests/lean/hashmap_on_disk/HashmapMain/Types.lean
+++ b/tests/lean/hashmap_on_disk/HashmapMain/Types.lean
@@ -15,7 +15,5 @@ structure hashmap_hash_map_t (T : Type) where
hashmap_hash_map_max_load : USize
hashmap_hash_map_slots : vec (hashmap_list_t T)
-
-/- The state type used in the state-error monad -/
-axiom state : Type
+/- The state type used in the state-error monad -/ axiom state : Type