From ce8f5c8f67e41a74bfdf8f6d664ff4e45e9de850 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 7 Sep 2023 16:06:14 +0200 Subject: Regenerate the test files and fix a proof --- tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst | 6 +-- tests/fstar/hashmap_on_disk/Primitives.fst | 47 +++++++++++++++++++----- 2 files changed, 38 insertions(+), 15 deletions(-) (limited to 'tests/fstar/hashmap_on_disk') diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst b/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst index 1c94209c..5af90bd8 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst @@ -157,10 +157,6 @@ let hashmap_hash_map_insert_no_resize_fwd_back hash_mod l0 in Return { self with hashmap_hash_map_slots = v } -(** [core::num::u32::{8}::MAX] *) -let core_num_u32_max_body : result u32 = Return 4294967295 -let core_num_u32_max_c : u32 = eval_global core_num_u32_max_body - (** [hashmap_main::hashmap::HashMap::{0}::move_elements_from_list]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) let rec hashmap_hash_map_move_elements_from_list_loop_fwd_back @@ -218,7 +214,7 @@ let hashmap_hash_map_move_elements_fwd_back (there is a single backward function, and the forward function returns ()) *) let hashmap_hash_map_try_resize_fwd_back (t : Type0) (self : hashmap_hash_map_t t) : result (hashmap_hash_map_t t) = - let* max_usize = scalar_cast U32 Usize core_num_u32_max_c in + let* max_usize = scalar_cast U32 Usize core_u32_max in let capacity = vec_len (hashmap_list_t t) self.hashmap_hash_map_slots in let* n1 = usize_div max_usize 2 in let (i, i0) = self.hashmap_hash_map_max_load_factor in diff --git a/tests/fstar/hashmap_on_disk/Primitives.fst b/tests/fstar/hashmap_on_disk/Primitives.fst index 9db82069..cd18cf29 100644 --- a/tests/fstar/hashmap_on_disk/Primitives.fst +++ b/tests/fstar/hashmap_on_disk/Primitives.fst @@ -169,17 +169,44 @@ let scalar_cast (src_ty : scalar_ty) (tgt_ty : scalar_ty) (x : scalar src_ty) : /// The scalar types type isize : eqtype = scalar Isize -type i8 : eqtype = scalar I8 -type i16 : eqtype = scalar I16 -type i32 : eqtype = scalar I32 -type i64 : eqtype = scalar I64 -type i128 : eqtype = scalar I128 +type i8 : eqtype = scalar I8 +type i16 : eqtype = scalar I16 +type i32 : eqtype = scalar I32 +type i64 : eqtype = scalar I64 +type i128 : eqtype = scalar I128 type usize : eqtype = scalar Usize -type u8 : eqtype = scalar U8 -type u16 : eqtype = scalar U16 -type u32 : eqtype = scalar U32 -type u64 : eqtype = scalar U64 -type u128 : eqtype = scalar U128 +type u8 : eqtype = scalar U8 +type u16 : eqtype = scalar U16 +type u32 : eqtype = scalar U32 +type u64 : eqtype = scalar U64 +type u128 : eqtype = scalar U128 + + +let core_isize_min : isize = isize_min +let core_isize_max : isize = isize_max +let core_i8_min : i8 = i8_min +let core_i8_max : i8 = i8_max +let core_i16_min : i16 = i16_min +let core_i16_max : i16 = i16_max +let core_i32_min : i32 = i32_min +let core_i32_max : i32 = i32_max +let core_i64_min : i64 = i64_min +let core_i64_max : i64 = i64_max +let core_i128_min : i128 = i128_min +let core_i128_max : i128 = i128_max + +let core_usize_min : usize = usize_min +let core_usize_max : usize = usize_max +let core_u8_min : u8 = u8_min +let core_u8_max : u8 = u8_max +let core_u16_min : u16 = u16_min +let core_u16_max : u16 = u16_max +let core_u32_min : u32 = u32_min +let core_u32_max : u32 = u32_max +let core_u64_min : u64 = u64_min +let core_u64_max : u64 = u64_max +let core_u128_min : u128 = u128_min +let core_u128_max : u128 = u128_max /// Negation let isize_neg = scalar_neg #Isize -- cgit v1.2.3 From c8c9be9b7d9866f9761a21adbadd923d4a79bb09 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 26 Oct 2023 15:55:12 +0200 Subject: Update Primitives.fst --- tests/fstar/hashmap_on_disk/Primitives.fst | 384 +++++++++++++++++++++++++---- 1 file changed, 339 insertions(+), 45 deletions(-) (limited to 'tests/fstar/hashmap_on_disk') diff --git a/tests/fstar/hashmap_on_disk/Primitives.fst b/tests/fstar/hashmap_on_disk/Primitives.fst index cd18cf29..5e154122 100644 --- a/tests/fstar/hashmap_on_disk/Primitives.fst +++ b/tests/fstar/hashmap_on_disk/Primitives.fst @@ -55,8 +55,12 @@ type string = string let is_zero (n: nat) : bool = n = 0 let decrease (n: nat{n > 0}) : nat = n - 1 -let mem_replace_fwd (a : Type0) (x : a) (y : a) : a = x -let mem_replace_back (a : Type0) (x : a) (y : a) : a = y +let std_mem_replace (a : Type0) (x : a) (y : a) : a = x +let std_mem_replace_back (a : Type0) (x : a) (y : a) : a = y + +// We don't really use raw pointers for now +type mut_raw_ptr (t : Type0) = { v : t } +type const_raw_ptr (t : Type0) = { v : t } (*** Scalars *) /// Rem.: most of the following code was partially generated @@ -100,6 +104,11 @@ type scalar_ty = | U64 | U128 +let is_unsigned = function + | Isize | I8 | I16 | I32 | I64 | I128 -> false + | Usize | U8 | U16 | U32 | U64 | U128 -> true + + let scalar_min (ty : scalar_ty) : int = match ty with | Isize -> isize_min @@ -162,6 +171,15 @@ let scalar_sub (#ty : scalar_ty) (x : scalar ty) (y : scalar ty) : result (scala let scalar_mul (#ty : scalar_ty) (x : scalar ty) (y : scalar ty) : result (scalar ty) = mk_scalar ty (x * y) +let scalar_lxor (#ty : scalar_ty { is_unsigned ty && ty <> Usize }) + (x : scalar ty) (y : scalar ty) : scalar ty = + match ty with + | U8 -> FStar.UInt.logxor #8 x y + | U16 -> FStar.UInt.logxor #16 x y + | U32 -> FStar.UInt.logxor #32 x y + | U64 -> FStar.UInt.logxor #64 x y + | U128 -> FStar.UInt.logxor #128 x y + (** Cast an integer from a [src_ty] to a [tgt_ty] *) // TODO: check the semantics of casts in Rust let scalar_cast (src_ty : scalar_ty) (tgt_ty : scalar_ty) (x : scalar src_ty) : result (scalar tgt_ty) = @@ -258,7 +276,7 @@ let u32_add = scalar_add #U32 let u64_add = scalar_add #U64 let u128_add = scalar_add #U128 -/// Substraction +/// Subtraction let isize_sub = scalar_sub #Isize let i8_sub = scalar_sub #I8 let i16_sub = scalar_sub #I16 @@ -286,12 +304,65 @@ let u32_mul = scalar_mul #U32 let u64_mul = scalar_mul #U64 let u128_mul = scalar_mul #U128 -(*** Range *) -type range (a : Type0) = { +/// Logical operators, defined for unsigned types only, so far +let u8_xor = scalar_lxor #U8 +let u16_xor = scalar_lxor #U16 +let u32_xor = scalar_lxor #U32 +let u64_xor = scalar_lxor #U64 +let u128_xor = scalar_lxor #U128 + +(*** core::ops *) + +// Trait declaration: [core::ops::index::Index] +noeq type core_ops_index_Index (self idx : Type0) = { + output : Type0; + index : self → idx → result output +} + +// Trait declaration: [core::ops::index::IndexMut] +noeq type core_ops_index_IndexMut (self idx : Type0) = { + indexInst : core_ops_index_Index self idx; + index_mut : self → idx → result indexInst.output; + index_mut_back : self → idx → indexInst.output → result self; +} + +// Trait declaration [core::ops::deref::Deref] +noeq type core_ops_deref_Deref (self : Type0) = { + target : Type0; + deref : self → result target; +} + +// Trait declaration [core::ops::deref::DerefMut] +noeq type core_ops_deref_DerefMut (self : Type0) = { + derefInst : core_ops_deref_Deref self; + deref_mut : self → result derefInst.target; + deref_mut_back : self → derefInst.target → result self; +} + +type core_ops_range_Range (a : Type0) = { start : a; end_ : a; } +(*** [alloc] *) + +let alloc_boxed_Box_deref (t : Type0) (x : t) : result t = Return x +let alloc_boxed_Box_deref_mut (t : Type0) (x : t) : result t = Return x +let alloc_boxed_Box_deref_mut_back (t : Type) (_ : t) (x : t) : result t = Return x + +// Trait instance +let alloc_boxed_Box_coreOpsDerefInst (self : Type0) : core_ops_deref_Deref self = { + target = self; + deref = alloc_boxed_Box_deref self; +} + +// Trait instance +let alloc_boxed_Box_coreOpsDerefMutInst (self : Type0) : core_ops_deref_DerefMut self = { + derefInst = alloc_boxed_Box_coreOpsDerefInst self; + deref_mut = alloc_boxed_Box_deref_mut self; + deref_mut_back = alloc_boxed_Box_deref_mut_back self; +} + (*** Array *) type array (a : Type0) (n : usize) = s:list a{length s = n} @@ -305,15 +376,11 @@ let mk_array (a : Type0) (n : usize) normalize_term_spec (FStar.List.Tot.length l); l -let array_index_shared (a : Type0) (n : usize) (x : array a n) (i : usize) : result a = - if i < length x then Return (index x i) - else Fail Failure - -let array_index_mut_fwd (a : Type0) (n : usize) (x : array a n) (i : usize) : result a = +let array_index_usize (a : Type0) (n : usize) (x : array a n) (i : usize) : result a = if i < length x then Return (index x i) else Fail Failure -let array_index_mut_back (a : Type0) (n : usize) (x : array a n) (i : usize) (nx : a) : result (array a n) = +let array_update_usize (a : Type0) (n : usize) (x : array a n) (i : usize) (nx : a) : result (array a n) = if i < length x then Return (list_update x i nx) else Fail Failure @@ -322,55 +389,47 @@ type slice (a : Type0) = s:list a{length s <= usize_max} let slice_len (a : Type0) (s : slice a) : usize = length s -let slice_index_shared (a : Type0) (x : slice a) (i : usize) : result a = - if i < length x then Return (index x i) - else Fail Failure - -let slice_index_mut_fwd (a : Type0) (x : slice a) (i : usize) : result a = +let slice_index_usize (a : Type0) (x : slice a) (i : usize) : result a = if i < length x then Return (index x i) else Fail Failure -let slice_index_mut_back (a : Type0) (x : slice a) (i : usize) (nx : a) : result (slice a) = +let slice_update_usize (a : Type0) (x : slice a) (i : usize) (nx : a) : result (slice a) = if i < length x then Return (list_update x i nx) else Fail Failure (*** Subslices *) -let array_to_slice_shared (a : Type0) (n : usize) (x : array a n) : result (slice a) = Return x -let array_to_slice_mut_fwd (a : Type0) (n : usize) (x : array a n) : result (slice a) = Return x -let array_to_slice_mut_back (a : Type0) (n : usize) (x : array a n) (s : slice a) : result (array a n) = +let array_to_slice (a : Type0) (n : usize) (x : array a n) : result (slice a) = Return x +let array_from_slice (a : Type0) (n : usize) (x : array a n) (s : slice a) : result (array a n) = if length s = n then Return s else Fail Failure // TODO: finish the definitions below (there lacks [List.drop] and [List.take] in the standard library *) -let array_subslice_shared (a : Type0) (n : usize) (x : array a n) (r : range usize) : result (slice a) = - admit() - -let array_subslice_mut_fwd (a : Type0) (n : usize) (x : array a n) (r : range usize) : result (slice a) = +let array_subslice (a : Type0) (n : usize) (x : array a n) (r : core_ops_range_Range usize) : result (slice a) = admit() -let array_subslice_mut_back (a : Type0) (n : usize) (x : array a n) (r : range usize) (ns : slice a) : result (array a n) = +let array_update_subslice (a : Type0) (n : usize) (x : array a n) (r : core_ops_range_Range usize) (ns : slice a) : result (array a n) = admit() -let slice_subslice_shared (a : Type0) (x : slice a) (r : range usize) : result (slice a) = +let array_repeat (a : Type0) (n : usize) (x : a) : array a n = admit() -let slice_subslice_mut_fwd (a : Type0) (x : slice a) (r : range usize) : result (slice a) = +let slice_subslice (a : Type0) (x : slice a) (r : core_ops_range_Range usize) : result (slice a) = admit() -let slice_subslice_mut_back (a : Type0) (x : slice a) (r : range usize) (ns : slice a) : result (slice a) = +let slice_update_subslice (a : Type0) (x : slice a) (r : core_ops_range_Range usize) (ns : slice a) : result (slice a) = admit() (*** Vector *) -type vec (a : Type0) = v:list a{length v <= usize_max} +type alloc_vec_Vec (a : Type0) = v:list a{length v <= usize_max} -let vec_new (a : Type0) : vec a = assert_norm(length #a [] == 0); [] -let vec_len (a : Type0) (v : vec a) : usize = length v +let alloc_vec_Vec_new (a : Type0) : alloc_vec_Vec a = assert_norm(length #a [] == 0); [] +let alloc_vec_Vec_len (a : Type0) (v : alloc_vec_Vec a) : usize = length v // The **forward** function shouldn't be used -let vec_push_fwd (a : Type0) (v : vec a) (x : a) : unit = () -let vec_push_back (a : Type0) (v : vec a) (x : a) : - Pure (result (vec a)) +let alloc_vec_Vec_push_fwd (a : Type0) (v : alloc_vec_Vec a) (x : a) : unit = () +let alloc_vec_Vec_push (a : Type0) (v : alloc_vec_Vec a) (x : a) : + Pure (result (alloc_vec_Vec a)) (requires True) (ensures (fun res -> match res with @@ -385,18 +444,253 @@ let vec_push_back (a : Type0) (v : vec a) (x : a) : else Fail Failure // The **forward** function shouldn't be used -let vec_insert_fwd (a : Type0) (v : vec a) (i : usize) (x : a) : result unit = +let alloc_vec_Vec_insert_fwd (a : Type0) (v : alloc_vec_Vec a) (i : usize) (x : a) : result unit = if i < length v then Return () else Fail Failure -let vec_insert_back (a : Type0) (v : vec a) (i : usize) (x : a) : result (vec a) = +let alloc_vec_Vec_insert (a : Type0) (v : alloc_vec_Vec a) (i : usize) (x : a) : result (alloc_vec_Vec a) = if i < length v then Return (list_update v i x) else Fail Failure -// The **backward** function shouldn't be used -let vec_index_fwd (a : Type0) (v : vec a) (i : usize) : result a = - if i < length v then Return (index v i) else Fail Failure -let vec_index_back (a : Type0) (v : vec a) (i : usize) (x : a) : result unit = - if i < length v then Return () else Fail Failure +// Trait declaration: [core::slice::index::private_slice_index::Sealed] +type core_slice_index_private_slice_index_Sealed (self : Type0) = unit + +// Trait declaration: [core::slice::index::SliceIndex] +noeq type core_slice_index_SliceIndex (self t : Type0) = { + sealedInst : core_slice_index_private_slice_index_Sealed self; + output : Type0; + get : self → t → result (option output); + get_mut : self → t → result (option output); + get_mut_back : self → t → option output → result t; + get_unchecked : self → const_raw_ptr t → result (const_raw_ptr output); + get_unchecked_mut : self → mut_raw_ptr t → result (mut_raw_ptr output); + index : self → t → result output; + index_mut : self → t → result output; + index_mut_back : self → t → output → result t; +} + +// [core::slice::index::[T]::index]: forward function +let core_slice_index_Slice_index + (t idx : Type0) (inst : core_slice_index_SliceIndex idx (slice t)) + (s : slice t) (i : idx) : result inst.output = + let* x = inst.get i s in + match x with + | None -> Fail Failure + | Some x -> Return x + +// [core::slice::index::Range:::get]: forward function +let core_slice_index_Range_get (t : Type0) (i : core_ops_range_Range usize) (s : slice t) : + result (option (slice t)) = + admit () // TODO + +// [core::slice::index::Range::get_mut]: forward function +let core_slice_index_Range_get_mut + (t : Type0) : core_ops_range_Range usize → slice t → result (option (slice t)) = + admit () // TODO + +// [core::slice::index::Range::get_mut]: backward function 0 +let core_slice_index_Range_get_mut_back + (t : Type0) : + core_ops_range_Range usize → slice t → option (slice t) → result (slice t) = + admit () // TODO + +// [core::slice::index::Range::get_unchecked]: forward function +let core_slice_index_Range_get_unchecked + (t : Type0) : + core_ops_range_Range usize → const_raw_ptr (slice t) → result (const_raw_ptr (slice t)) = + // Don't know what the model should be - for now we always fail to make + // sure code which uses it fails + fun _ _ -> Fail Failure + +// [core::slice::index::Range::get_unchecked_mut]: forward function +let core_slice_index_Range_get_unchecked_mut + (t : Type0) : + core_ops_range_Range usize → mut_raw_ptr (slice t) → result (mut_raw_ptr (slice t)) = + // Don't know what the model should be - for now we always fail to make + // sure code which uses it fails + fun _ _ -> Fail Failure + +// [core::slice::index::Range::index]: forward function +let core_slice_index_Range_index + (t : Type0) : core_ops_range_Range usize → slice t → result (slice t) = + admit () // TODO + +// [core::slice::index::Range::index_mut]: forward function +let core_slice_index_Range_index_mut + (t : Type0) : core_ops_range_Range usize → slice t → result (slice t) = + admit () // TODO + +// [core::slice::index::Range::index_mut]: backward function 0 +let core_slice_index_Range_index_mut_back + (t : Type0) : core_ops_range_Range usize → slice t → slice t → result (slice t) = + admit () // TODO + +// [core::slice::index::[T]::index_mut]: forward function +let core_slice_index_Slice_index_mut + (t idx : Type0) (inst : core_slice_index_SliceIndex idx (slice t)) : + slice t → idx → result inst.output = + admit () // + +// [core::slice::index::[T]::index_mut]: backward function 0 +let core_slice_index_Slice_index_mut_back + (t idx : Type0) (inst : core_slice_index_SliceIndex idx (slice t)) : + slice t → idx → inst.output → result (slice t) = + admit () // TODO + +// [core::array::[T; N]::index]: forward function +let core_array_Array_index + (t idx : Type0) (n : usize) (inst : core_ops_index_Index (slice t) idx) + (a : array t n) (i : idx) : result inst.output = + admit () // TODO + +// [core::array::[T; N]::index_mut]: forward function +let core_array_Array_index_mut + (t idx : Type0) (n : usize) (inst : core_ops_index_IndexMut (slice t) idx) + (a : array t n) (i : idx) : result inst.indexInst.output = + admit () // TODO + +// [core::array::[T; N]::index_mut]: backward function 0 +let core_array_Array_index_mut_back + (t idx : Type0) (n : usize) (inst : core_ops_index_IndexMut (slice t) idx) + (a : array t n) (i : idx) (x : inst.indexInst.output) : result (array t n) = + admit () // TODO + +// Trait implementation: [core::slice::index::[T]] +let core_slice_index_Slice_coreopsindexIndexInst (t idx : Type0) + (inst : core_slice_index_SliceIndex idx (slice t)) : + core_ops_index_Index (slice t) idx = { + output = inst.output; + index = core_slice_index_Slice_index t idx inst; +} + +// Trait implementation: [core::slice::index::private_slice_index::Range] +let core_slice_index_private_slice_index_Range_coresliceindexprivate_slice_indexSealedInst + : core_slice_index_private_slice_index_Sealed (core_ops_range_Range usize) = () + +// Trait implementation: [core::slice::index::Range] +let core_slice_index_Range_coresliceindexSliceIndexInst (t : Type0) : + core_slice_index_SliceIndex (core_ops_range_Range usize) (slice t) = { + sealedInst = core_slice_index_private_slice_index_Range_coresliceindexprivate_slice_indexSealedInst; + output = slice t; + get = core_slice_index_Range_get t; + get_mut = core_slice_index_Range_get_mut t; + get_mut_back = core_slice_index_Range_get_mut_back t; + get_unchecked = core_slice_index_Range_get_unchecked t; + get_unchecked_mut = core_slice_index_Range_get_unchecked_mut t; + index = core_slice_index_Range_index t; + index_mut = core_slice_index_Range_index_mut t; + index_mut_back = core_slice_index_Range_index_mut_back t; +} -let vec_index_mut_fwd (a : Type0) (v : vec a) (i : usize) : result a = - if i < length v then Return (index v i) else Fail Failure -let vec_index_mut_back (a : Type0) (v : vec a) (i : usize) (nx : a) : result (vec a) = - if i < length v then Return (list_update v i nx) else Fail Failure +// Trait implementation: [core::slice::index::[T]] +let core_slice_index_Slice_coreopsindexIndexMutInst (t idx : Type0) + (inst : core_slice_index_SliceIndex idx (slice t)) : + core_ops_index_IndexMut (slice t) idx = { + indexInst = core_slice_index_Slice_coreopsindexIndexInst t idx inst; + index_mut = core_slice_index_Slice_index_mut t idx inst; + index_mut_back = core_slice_index_Slice_index_mut_back t idx inst; +} + +// Trait implementation: [core::array::[T; N]] +let core_array_Array_coreopsindexIndexInst (t idx : Type0) (n : usize) + (inst : core_ops_index_Index (slice t) idx) : + core_ops_index_Index (array t n) idx = { + output = inst.output; + index = core_array_Array_index t idx n inst; +} + +// Trait implementation: [core::array::[T; N]] +let core_array_Array_coreopsindexIndexMutInst (t idx : Type0) (n : usize) + (inst : core_ops_index_IndexMut (slice t) idx) : + core_ops_index_IndexMut (array t n) idx = { + indexInst = core_array_Array_coreopsindexIndexInst t idx n inst.indexInst; + index_mut = core_array_Array_index_mut t idx n inst; + index_mut_back = core_array_Array_index_mut_back t idx n inst; +} + +// [core::slice::index::usize::get]: forward function +let core_slice_index_usize_get + (t : Type0) : usize → slice t → result (option t) = + admit () // TODO + +// [core::slice::index::usize::get_mut]: forward function +let core_slice_index_usize_get_mut + (t : Type0) : usize → slice t → result (option t) = + admit () // TODO + +// [core::slice::index::usize::get_mut]: backward function 0 +let core_slice_index_usize_get_mut_back + (t : Type0) : usize → slice t → option t → result (slice t) = + admit () // TODO + +// [core::slice::index::usize::get_unchecked]: forward function +let core_slice_index_usize_get_unchecked + (t : Type0) : usize → const_raw_ptr (slice t) → result (const_raw_ptr t) = + admit () // TODO + +// [core::slice::index::usize::get_unchecked_mut]: forward function +let core_slice_index_usize_get_unchecked_mut + (t : Type0) : usize → mut_raw_ptr (slice t) → result (mut_raw_ptr t) = + admit () // TODO + +// [core::slice::index::usize::index]: forward function +let core_slice_index_usize_index (t : Type0) : usize → slice t → result t = + admit () // TODO + +// [core::slice::index::usize::index_mut]: forward function +let core_slice_index_usize_index_mut (t : Type0) : usize → slice t → result t = + admit () // TODO + +// [core::slice::index::usize::index_mut]: backward function 0 +let core_slice_index_usize_index_mut_back + (t : Type0) : usize → slice t → t → result (slice t) = + admit () // TODO + +// Trait implementation: [core::slice::index::private_slice_index::usize] +let core_slice_index_private_slice_index_usize_coresliceindexprivate_slice_indexSealedInst + : core_slice_index_private_slice_index_Sealed usize = () + +// Trait implementation: [core::slice::index::usize] +let core_slice_index_usize_coresliceindexSliceIndexInst (t : Type0) : + core_slice_index_SliceIndex usize (slice t) = { + sealedInst = core_slice_index_private_slice_index_usize_coresliceindexprivate_slice_indexSealedInst; + output = t; + get = core_slice_index_usize_get t; + get_mut = core_slice_index_usize_get_mut t; + get_mut_back = core_slice_index_usize_get_mut_back t; + get_unchecked = core_slice_index_usize_get_unchecked t; + get_unchecked_mut = core_slice_index_usize_get_unchecked_mut t; + index = core_slice_index_usize_index t; + index_mut = core_slice_index_usize_index_mut t; + index_mut_back = core_slice_index_usize_index_mut_back t; +} + +// [alloc::vec::Vec::index]: forward function +let alloc_vec_Vec_index (t idx : Type0) (inst : core_slice_index_SliceIndex idx (slice t)) + (self : alloc_vec_Vec t) (i : idx) : result inst.output = + admit () // TODO + +// [alloc::vec::Vec::index_mut]: forward function +let alloc_vec_Vec_index_mut (t idx : Type0) (inst : core_slice_index_SliceIndex idx (slice t)) + (self : alloc_vec_Vec t) (i : idx) : result inst.output = + admit () // TODO + +// [alloc::vec::Vec::index_mut]: backward function 0 +let alloc_vec_Vec_index_mut_back + (t idx : Type0) (inst : core_slice_index_SliceIndex idx (slice t)) + (self : alloc_vec_Vec t) (i : idx) (x : inst.output) : result (alloc_vec_Vec t) = + admit () // TODO + +// Trait implementation: [alloc::vec::Vec] +let alloc_vec_Vec_coreopsindexIndexInst (t idx : Type0) + (inst : core_slice_index_SliceIndex idx (slice t)) : + core_ops_index_Index (alloc_vec_Vec t) idx = { + output = inst.output; + index = alloc_vec_Vec_index t idx inst; +} + +// Trait implementation: [alloc::vec::Vec] +let alloc_vec_Vec_coreopsindexIndexMutInst (t idx : Type0) + (inst : core_slice_index_SliceIndex idx (slice t)) : + core_ops_index_IndexMut (alloc_vec_Vec t) idx = { + indexInst = alloc_vec_Vec_coreopsindexIndexInst t idx inst; + index_mut = alloc_vec_Vec_index_mut t idx inst; + index_mut_back = alloc_vec_Vec_index_mut_back t idx inst; +} -- cgit v1.2.3 From 4f824528f5e0c0f898b20917c6c06821efb934da Mon Sep 17 00:00:00 2001 From: Son Ho Date: Fri, 27 Oct 2023 12:12:18 +0200 Subject: Regenerate some of the F* test files --- tests/fstar/hashmap_on_disk/Primitives.fst | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'tests/fstar/hashmap_on_disk') diff --git a/tests/fstar/hashmap_on_disk/Primitives.fst b/tests/fstar/hashmap_on_disk/Primitives.fst index 5e154122..3110b247 100644 --- a/tests/fstar/hashmap_on_disk/Primitives.fst +++ b/tests/fstar/hashmap_on_disk/Primitives.fst @@ -55,8 +55,8 @@ type string = string let is_zero (n: nat) : bool = n = 0 let decrease (n: nat{n > 0}) : nat = n - 1 -let std_mem_replace (a : Type0) (x : a) (y : a) : a = x -let std_mem_replace_back (a : Type0) (x : a) (y : a) : a = y +let core_mem_replace (a : Type0) (x : a) (y : a) : a = x +let core_mem_replace_back (a : Type0) (x : a) (y : a) : a = y // We don't really use raw pointers for now type mut_raw_ptr (t : Type0) = { v : t } @@ -426,6 +426,13 @@ type alloc_vec_Vec (a : Type0) = v:list a{length v <= usize_max} let alloc_vec_Vec_new (a : Type0) : alloc_vec_Vec a = assert_norm(length #a [] == 0); [] let alloc_vec_Vec_len (a : Type0) (v : alloc_vec_Vec a) : usize = length v +// Helper +let alloc_vec_Vec_index_usize (#a : Type0) (v : alloc_vec_Vec a) (i : usize) (x : a) : result a = + if i < length v then Return (index v i) else Fail Failure +// Helper +let alloc_vec_Vec_update_usize (#a : Type0) (v : alloc_vec_Vec a) (i : usize) (x : a) : result (alloc_vec_Vec a) = + if i < length v then Return (list_update v i x) else Fail Failure + // The **forward** function shouldn't be used let alloc_vec_Vec_push_fwd (a : Type0) (v : alloc_vec_Vec a) (x : a) : unit = () let alloc_vec_Vec_push (a : Type0) (v : alloc_vec_Vec a) (x : a) : @@ -694,3 +701,11 @@ let alloc_vec_Vec_coreopsindexIndexMutInst (t idx : Type0) index_mut = alloc_vec_Vec_index_mut t idx inst; index_mut_back = alloc_vec_Vec_index_mut_back t idx inst; } + +(*** Theorems *) + +let alloc_vec_Vec_index_mut_back_eq (#a : Type0) (v : alloc_vec_Vec a) (i : usize) (x : a) : + Lemma ( + alloc_vec_Vec_index_mut_back a usize (core_slice_index_usize_coresliceindexSliceIndexInst a) v i x == + alloc_vec_Vec_update_usize v i x) = + admit() -- cgit v1.2.3 From 1c4b1222dbf5e090c26e613694d63577343ab2fd Mon Sep 17 00:00:00 2001 From: Son Ho Date: Fri, 27 Oct 2023 12:18:02 +0200 Subject: Fix a minor issue and regenerate some F* test files --- .../HashmapMain.Clauses.Template.fst | 38 +- .../fstar/hashmap_on_disk/HashmapMain.Clauses.fst | 32 +- tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst | 569 +++++++++++---------- .../fstar/hashmap_on_disk/HashmapMain.Opaque.fsti | 8 +- tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti | 16 +- 5 files changed, 333 insertions(+), 330 deletions(-) (limited to 'tests/fstar/hashmap_on_disk') diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.Template.fst b/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.Template.fst index 615c670d..61885ac7 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.Template.fst +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.Template.fst @@ -8,56 +8,56 @@ open HashmapMain.Types (** [hashmap_main::hashmap::HashMap::{0}::allocate_slots]: decreases clause *) unfold -let hashmap_hash_map_allocate_slots_loop_decreases (t : Type0) - (slots : vec (hashmap_list_t t)) (n : usize) : nat = +let hashmap_HashMap_allocate_slots_loop_decreases (t : Type0) + (slots : alloc_vec_Vec (hashmap_List_t t)) (n : usize) : nat = admit () (** [hashmap_main::hashmap::HashMap::{0}::clear]: decreases clause *) unfold -let hashmap_hash_map_clear_loop_decreases (t : Type0) - (slots : vec (hashmap_list_t t)) (i : usize) : nat = +let hashmap_HashMap_clear_loop_decreases (t : Type0) + (slots : alloc_vec_Vec (hashmap_List_t t)) (i : usize) : nat = admit () (** [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: decreases clause *) unfold -let hashmap_hash_map_insert_in_list_loop_decreases (t : Type0) (key : usize) - (value : t) (ls : hashmap_list_t t) : nat = +let hashmap_HashMap_insert_in_list_loop_decreases (t : Type0) (key : usize) + (value : t) (ls : hashmap_List_t t) : nat = admit () (** [hashmap_main::hashmap::HashMap::{0}::move_elements_from_list]: decreases clause *) unfold -let hashmap_hash_map_move_elements_from_list_loop_decreases (t : Type0) - (ntable : hashmap_hash_map_t t) (ls : hashmap_list_t t) : nat = +let hashmap_HashMap_move_elements_from_list_loop_decreases (t : Type0) + (ntable : hashmap_HashMap_t t) (ls : hashmap_List_t t) : nat = admit () (** [hashmap_main::hashmap::HashMap::{0}::move_elements]: decreases clause *) unfold -let hashmap_hash_map_move_elements_loop_decreases (t : Type0) - (ntable : hashmap_hash_map_t t) (slots : vec (hashmap_list_t t)) (i : usize) - : nat = +let hashmap_HashMap_move_elements_loop_decreases (t : Type0) + (ntable : hashmap_HashMap_t t) (slots : alloc_vec_Vec (hashmap_List_t t)) + (i : usize) : nat = admit () (** [hashmap_main::hashmap::HashMap::{0}::contains_key_in_list]: decreases clause *) unfold -let hashmap_hash_map_contains_key_in_list_loop_decreases (t : Type0) - (key : usize) (ls : hashmap_list_t t) : nat = +let hashmap_HashMap_contains_key_in_list_loop_decreases (t : Type0) + (key : usize) (ls : hashmap_List_t t) : nat = admit () (** [hashmap_main::hashmap::HashMap::{0}::get_in_list]: decreases clause *) unfold -let hashmap_hash_map_get_in_list_loop_decreases (t : Type0) (key : usize) - (ls : hashmap_list_t t) : nat = +let hashmap_HashMap_get_in_list_loop_decreases (t : Type0) (key : usize) + (ls : hashmap_List_t t) : nat = admit () (** [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: decreases clause *) unfold -let hashmap_hash_map_get_mut_in_list_loop_decreases (t : Type0) - (ls : hashmap_list_t t) (key : usize) : nat = +let hashmap_HashMap_get_mut_in_list_loop_decreases (t : Type0) + (ls : hashmap_List_t t) (key : usize) : nat = admit () (** [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: decreases clause *) unfold -let hashmap_hash_map_remove_from_list_loop_decreases (t : Type0) (key : usize) - (ls : hashmap_list_t t) : nat = +let hashmap_HashMap_remove_from_list_loop_decreases (t : Type0) (key : usize) + (ls : hashmap_List_t t) : nat = admit () diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.fst b/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.fst index 699ff3b2..be5a4ab1 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.fst +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.fst @@ -8,54 +8,54 @@ open HashmapMain.Types (** [hashmap::HashMap::allocate_slots]: decreases clause *) unfold -let hashmap_hash_map_allocate_slots_loop_decreases (t : Type0) (slots : vec (hashmap_list_t t)) +let hashmap_HashMap_allocate_slots_loop_decreases (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (n : usize) : nat = n (** [hashmap::HashMap::clear]: decreases clause *) unfold -let hashmap_hash_map_clear_loop_decreases (t : Type0) (slots : vec (hashmap_list_t t)) +let hashmap_HashMap_clear_loop_decreases (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (i : usize) : nat = if i < length slots then length slots - i else 0 (** [hashmap::HashMap::insert_in_list]: decreases clause *) unfold -let hashmap_hash_map_insert_in_list_loop_decreases (t : Type0) (key : usize) (value : t) - (ls : hashmap_list_t t) : hashmap_list_t t = +let hashmap_HashMap_insert_in_list_loop_decreases (t : Type0) (key : usize) (value : t) + (ls : hashmap_List_t t) : hashmap_List_t t = ls (** [hashmap::HashMap::move_elements_from_list]: decreases clause *) unfold -let hashmap_hash_map_move_elements_from_list_loop_decreases (t : Type0) - (ntable : hashmap_hash_map_t t) (ls : hashmap_list_t t) : hashmap_list_t t = +let hashmap_HashMap_move_elements_from_list_loop_decreases (t : Type0) + (ntable : hashmap_HashMap_t t) (ls : hashmap_List_t t) : hashmap_List_t t = ls (** [hashmap::HashMap::move_elements]: decreases clause *) unfold -let hashmap_hash_map_move_elements_loop_decreases (t : Type0) (ntable : hashmap_hash_map_t t) - (slots : vec (hashmap_list_t t)) (i : usize) : nat = +let hashmap_HashMap_move_elements_loop_decreases (t : Type0) (ntable : hashmap_HashMap_t t) + (slots : alloc_vec_Vec (hashmap_List_t t)) (i : usize) : nat = if i < length slots then length slots - i else 0 (** [hashmap::HashMap::contains_key_in_list]: decreases clause *) unfold -let hashmap_hash_map_contains_key_in_list_loop_decreases (t : Type0) (key : usize) - (ls : hashmap_list_t t) : hashmap_list_t t = +let hashmap_HashMap_contains_key_in_list_loop_decreases (t : Type0) (key : usize) + (ls : hashmap_List_t t) : hashmap_List_t t = ls (** [hashmap::HashMap::get_in_list]: decreases clause *) unfold -let hashmap_hash_map_get_in_list_loop_decreases (t : Type0) (key : usize) (ls : hashmap_list_t t) : - hashmap_list_t t = +let hashmap_HashMap_get_in_list_loop_decreases (t : Type0) (key : usize) (ls : hashmap_List_t t) : + hashmap_List_t t = ls (** [hashmap::HashMap::get_mut_in_list]: decreases clause *) unfold -let hashmap_hash_map_get_mut_in_list_loop_decreases (t : Type0) - (ls : hashmap_list_t t) (key : usize) : hashmap_list_t t = +let hashmap_HashMap_get_mut_in_list_loop_decreases (t : Type0) + (ls : hashmap_List_t t) (key : usize) : hashmap_List_t t = ls (** [hashmap::HashMap::remove_from_list]: decreases clause *) unfold -let hashmap_hash_map_remove_from_list_loop_decreases (t : Type0) (key : usize) - (ls : hashmap_list_t t) : hashmap_list_t t = +let hashmap_HashMap_remove_from_list_loop_decreases (t : Type0) (key : usize) + (ls : hashmap_List_t t) : hashmap_List_t t = ls diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst b/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst index 5af90bd8..5f227596 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst @@ -9,525 +9,528 @@ include HashmapMain.Clauses #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" (** [hashmap_main::hashmap::hash_key]: forward function *) -let hashmap_hash_key_fwd (k : usize) : result usize = +let hashmap_hash_key (k : usize) : result usize = Return k (** [hashmap_main::hashmap::HashMap::{0}::allocate_slots]: loop 0: forward function *) -let rec hashmap_hash_map_allocate_slots_loop_fwd - (t : Type0) (slots : vec (hashmap_list_t t)) (n : usize) : - Tot (result (vec (hashmap_list_t t))) - (decreases (hashmap_hash_map_allocate_slots_loop_decreases t slots n)) +let rec hashmap_HashMap_allocate_slots_loop + (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (n : usize) : + Tot (result (alloc_vec_Vec (hashmap_List_t t))) + (decreases (hashmap_HashMap_allocate_slots_loop_decreases t slots n)) = if n > 0 then - let* slots0 = vec_push_back (hashmap_list_t t) slots HashmapListNil in + let* slots0 = alloc_vec_Vec_push (hashmap_List_t t) slots Hashmap_List_Nil + in let* n0 = usize_sub n 1 in - hashmap_hash_map_allocate_slots_loop_fwd t slots0 n0 + hashmap_HashMap_allocate_slots_loop t slots0 n0 else Return slots (** [hashmap_main::hashmap::HashMap::{0}::allocate_slots]: forward function *) -let hashmap_hash_map_allocate_slots_fwd - (t : Type0) (slots : vec (hashmap_list_t t)) (n : usize) : - result (vec (hashmap_list_t t)) +let hashmap_HashMap_allocate_slots + (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (n : usize) : + result (alloc_vec_Vec (hashmap_List_t t)) = - hashmap_hash_map_allocate_slots_loop_fwd t slots n + hashmap_HashMap_allocate_slots_loop t slots n (** [hashmap_main::hashmap::HashMap::{0}::new_with_capacity]: forward function *) -let hashmap_hash_map_new_with_capacity_fwd +let hashmap_HashMap_new_with_capacity (t : Type0) (capacity : usize) (max_load_dividend : usize) (max_load_divisor : usize) : - result (hashmap_hash_map_t t) + result (hashmap_HashMap_t t) = - let v = vec_new (hashmap_list_t t) in - let* slots = hashmap_hash_map_allocate_slots_fwd t v capacity in + let v = alloc_vec_Vec_new (hashmap_List_t t) in + let* slots = hashmap_HashMap_allocate_slots t v capacity in let* i = usize_mul capacity max_load_dividend in let* i0 = usize_div i max_load_divisor in Return { - hashmap_hash_map_num_entries = 0; - hashmap_hash_map_max_load_factor = (max_load_dividend, max_load_divisor); - hashmap_hash_map_max_load = i0; - hashmap_hash_map_slots = slots + num_entries = 0; + max_load_factor = (max_load_dividend, max_load_divisor); + max_load = i0; + slots = slots } (** [hashmap_main::hashmap::HashMap::{0}::new]: forward function *) -let hashmap_hash_map_new_fwd (t : Type0) : result (hashmap_hash_map_t t) = - hashmap_hash_map_new_with_capacity_fwd t 32 4 5 +let hashmap_HashMap_new (t : Type0) : result (hashmap_HashMap_t t) = + hashmap_HashMap_new_with_capacity t 32 4 5 (** [hashmap_main::hashmap::HashMap::{0}::clear]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) -let rec hashmap_hash_map_clear_loop_fwd_back - (t : Type0) (slots : vec (hashmap_list_t t)) (i : usize) : - Tot (result (vec (hashmap_list_t t))) - (decreases (hashmap_hash_map_clear_loop_decreases t slots i)) +let rec hashmap_HashMap_clear_loop + (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (i : usize) : + Tot (result (alloc_vec_Vec (hashmap_List_t t))) + (decreases (hashmap_HashMap_clear_loop_decreases t slots i)) = - let i0 = vec_len (hashmap_list_t t) slots in + let i0 = alloc_vec_Vec_len (hashmap_List_t t) slots in if i < i0 then let* i1 = usize_add i 1 in - let* slots0 = vec_index_mut_back (hashmap_list_t t) slots i HashmapListNil - in - hashmap_hash_map_clear_loop_fwd_back t slots0 i1 + let* slots0 = + alloc_vec_Vec_index_mut_back (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t + t)) slots i Hashmap_List_Nil in + hashmap_HashMap_clear_loop t slots0 i1 else Return slots (** [hashmap_main::hashmap::HashMap::{0}::clear]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) -let hashmap_hash_map_clear_fwd_back - (t : Type0) (self : hashmap_hash_map_t t) : result (hashmap_hash_map_t t) = - let* v = hashmap_hash_map_clear_loop_fwd_back t self.hashmap_hash_map_slots 0 - in - Return - { self with hashmap_hash_map_num_entries = 0; hashmap_hash_map_slots = v } +let hashmap_HashMap_clear + (t : Type0) (self : hashmap_HashMap_t t) : result (hashmap_HashMap_t t) = + let* v = hashmap_HashMap_clear_loop t self.slots 0 in + Return { self with num_entries = 0; slots = v } (** [hashmap_main::hashmap::HashMap::{0}::len]: forward function *) -let hashmap_hash_map_len_fwd - (t : Type0) (self : hashmap_hash_map_t t) : result usize = - Return self.hashmap_hash_map_num_entries +let hashmap_HashMap_len + (t : Type0) (self : hashmap_HashMap_t t) : result usize = + Return self.num_entries (** [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: loop 0: forward function *) -let rec hashmap_hash_map_insert_in_list_loop_fwd - (t : Type0) (key : usize) (value : t) (ls : hashmap_list_t t) : +let rec hashmap_HashMap_insert_in_list_loop + (t : Type0) (key : usize) (value : t) (ls : hashmap_List_t t) : Tot (result bool) - (decreases (hashmap_hash_map_insert_in_list_loop_decreases t key value ls)) + (decreases (hashmap_HashMap_insert_in_list_loop_decreases t key value ls)) = begin match ls with - | HashmapListCons ckey cvalue tl -> + | Hashmap_List_Cons ckey cvalue tl -> if ckey = key then Return false - else hashmap_hash_map_insert_in_list_loop_fwd t key value tl - | HashmapListNil -> Return true + else hashmap_HashMap_insert_in_list_loop t key value tl + | Hashmap_List_Nil -> Return true end (** [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: forward function *) -let hashmap_hash_map_insert_in_list_fwd - (t : Type0) (key : usize) (value : t) (ls : hashmap_list_t t) : result bool = - hashmap_hash_map_insert_in_list_loop_fwd t key value ls +let hashmap_HashMap_insert_in_list + (t : Type0) (key : usize) (value : t) (ls : hashmap_List_t t) : result bool = + hashmap_HashMap_insert_in_list_loop t key value ls (** [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: loop 0: backward function 0 *) -let rec hashmap_hash_map_insert_in_list_loop_back - (t : Type0) (key : usize) (value : t) (ls : hashmap_list_t t) : - Tot (result (hashmap_list_t t)) - (decreases (hashmap_hash_map_insert_in_list_loop_decreases t key value ls)) +let rec hashmap_HashMap_insert_in_list_loop_back + (t : Type0) (key : usize) (value : t) (ls : hashmap_List_t t) : + Tot (result (hashmap_List_t t)) + (decreases (hashmap_HashMap_insert_in_list_loop_decreases t key value ls)) = begin match ls with - | HashmapListCons ckey cvalue tl -> + | Hashmap_List_Cons ckey cvalue tl -> if ckey = key - then Return (HashmapListCons ckey value tl) + then Return (Hashmap_List_Cons ckey value tl) else - let* tl0 = hashmap_hash_map_insert_in_list_loop_back t key value tl in - Return (HashmapListCons ckey cvalue tl0) - | HashmapListNil -> - let l = HashmapListNil in Return (HashmapListCons key value l) + let* tl0 = hashmap_HashMap_insert_in_list_loop_back t key value tl in + Return (Hashmap_List_Cons ckey cvalue tl0) + | Hashmap_List_Nil -> + let l = Hashmap_List_Nil in Return (Hashmap_List_Cons key value l) end (** [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: backward function 0 *) -let hashmap_hash_map_insert_in_list_back - (t : Type0) (key : usize) (value : t) (ls : hashmap_list_t t) : - result (hashmap_list_t t) +let hashmap_HashMap_insert_in_list_back + (t : Type0) (key : usize) (value : t) (ls : hashmap_List_t t) : + result (hashmap_List_t t) = - hashmap_hash_map_insert_in_list_loop_back t key value ls + hashmap_HashMap_insert_in_list_loop_back t key value ls (** [hashmap_main::hashmap::HashMap::{0}::insert_no_resize]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) -let hashmap_hash_map_insert_no_resize_fwd_back - (t : Type0) (self : hashmap_hash_map_t t) (key : usize) (value : t) : - result (hashmap_hash_map_t t) +let hashmap_HashMap_insert_no_resize + (t : Type0) (self : hashmap_HashMap_t t) (key : usize) (value : t) : + result (hashmap_HashMap_t t) = - let* hash = hashmap_hash_key_fwd key in - let i = vec_len (hashmap_list_t t) self.hashmap_hash_map_slots in + let* hash = hashmap_hash_key key in + let i = alloc_vec_Vec_len (hashmap_List_t t) self.slots in let* hash_mod = usize_rem hash i in let* l = - vec_index_mut_fwd (hashmap_list_t t) self.hashmap_hash_map_slots hash_mod - in - let* inserted = hashmap_hash_map_insert_in_list_fwd t key value l in + alloc_vec_Vec_index_mut (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + self.slots hash_mod in + let* inserted = hashmap_HashMap_insert_in_list t key value l in if inserted then - let* i0 = usize_add self.hashmap_hash_map_num_entries 1 in - let* l0 = hashmap_hash_map_insert_in_list_back t key value l in + let* i0 = usize_add self.num_entries 1 in + let* l0 = hashmap_HashMap_insert_in_list_back t key value l in let* v = - vec_index_mut_back (hashmap_list_t t) self.hashmap_hash_map_slots - hash_mod l0 in - Return - { self with hashmap_hash_map_num_entries = i0; hashmap_hash_map_slots = v - } + alloc_vec_Vec_index_mut_back (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t + t)) self.slots hash_mod l0 in + Return { self with num_entries = i0; slots = v } else - let* l0 = hashmap_hash_map_insert_in_list_back t key value l in + let* l0 = hashmap_HashMap_insert_in_list_back t key value l in let* v = - vec_index_mut_back (hashmap_list_t t) self.hashmap_hash_map_slots - hash_mod l0 in - Return { self with hashmap_hash_map_slots = v } + alloc_vec_Vec_index_mut_back (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t + t)) self.slots hash_mod l0 in + Return { self with slots = v } (** [hashmap_main::hashmap::HashMap::{0}::move_elements_from_list]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) -let rec hashmap_hash_map_move_elements_from_list_loop_fwd_back - (t : Type0) (ntable : hashmap_hash_map_t t) (ls : hashmap_list_t t) : - Tot (result (hashmap_hash_map_t t)) +let rec hashmap_HashMap_move_elements_from_list_loop + (t : Type0) (ntable : hashmap_HashMap_t t) (ls : hashmap_List_t t) : + Tot (result (hashmap_HashMap_t t)) (decreases ( - hashmap_hash_map_move_elements_from_list_loop_decreases t ntable ls)) + hashmap_HashMap_move_elements_from_list_loop_decreases t ntable ls)) = begin match ls with - | HashmapListCons k v tl -> - let* ntable0 = hashmap_hash_map_insert_no_resize_fwd_back t ntable k v in - hashmap_hash_map_move_elements_from_list_loop_fwd_back t ntable0 tl - | HashmapListNil -> Return ntable + | Hashmap_List_Cons k v tl -> + let* ntable0 = hashmap_HashMap_insert_no_resize t ntable k v in + hashmap_HashMap_move_elements_from_list_loop t ntable0 tl + | Hashmap_List_Nil -> Return ntable end (** [hashmap_main::hashmap::HashMap::{0}::move_elements_from_list]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) -let hashmap_hash_map_move_elements_from_list_fwd_back - (t : Type0) (ntable : hashmap_hash_map_t t) (ls : hashmap_list_t t) : - result (hashmap_hash_map_t t) +let hashmap_HashMap_move_elements_from_list + (t : Type0) (ntable : hashmap_HashMap_t t) (ls : hashmap_List_t t) : + result (hashmap_HashMap_t t) = - hashmap_hash_map_move_elements_from_list_loop_fwd_back t ntable ls + hashmap_HashMap_move_elements_from_list_loop t ntable ls (** [hashmap_main::hashmap::HashMap::{0}::move_elements]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) -let rec hashmap_hash_map_move_elements_loop_fwd_back - (t : Type0) (ntable : hashmap_hash_map_t t) (slots : vec (hashmap_list_t t)) - (i : usize) : - Tot (result ((hashmap_hash_map_t t) & (vec (hashmap_list_t t)))) - (decreases (hashmap_hash_map_move_elements_loop_decreases t ntable slots i)) +let rec hashmap_HashMap_move_elements_loop + (t : Type0) (ntable : hashmap_HashMap_t t) + (slots : alloc_vec_Vec (hashmap_List_t t)) (i : usize) : + Tot (result ((hashmap_HashMap_t t) & (alloc_vec_Vec (hashmap_List_t t)))) + (decreases (hashmap_HashMap_move_elements_loop_decreases t ntable slots i)) = - let i0 = vec_len (hashmap_list_t t) slots in + let i0 = alloc_vec_Vec_len (hashmap_List_t t) slots in if i < i0 then - let* l = vec_index_mut_fwd (hashmap_list_t t) slots i in - let ls = mem_replace_fwd (hashmap_list_t t) l HashmapListNil in - let* ntable0 = - hashmap_hash_map_move_elements_from_list_fwd_back t ntable ls in + let* l = + alloc_vec_Vec_index_mut (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t + t)) slots i in + let ls = core_mem_replace (hashmap_List_t t) l Hashmap_List_Nil in + let* ntable0 = hashmap_HashMap_move_elements_from_list t ntable ls in let* i1 = usize_add i 1 in - let l0 = mem_replace_back (hashmap_list_t t) l HashmapListNil in - let* slots0 = vec_index_mut_back (hashmap_list_t t) slots i l0 in - hashmap_hash_map_move_elements_loop_fwd_back t ntable0 slots0 i1 + let l0 = core_mem_replace_back (hashmap_List_t t) l Hashmap_List_Nil in + let* slots0 = + alloc_vec_Vec_index_mut_back (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t + t)) slots i l0 in + hashmap_HashMap_move_elements_loop t ntable0 slots0 i1 else Return (ntable, slots) (** [hashmap_main::hashmap::HashMap::{0}::move_elements]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) -let hashmap_hash_map_move_elements_fwd_back - (t : Type0) (ntable : hashmap_hash_map_t t) (slots : vec (hashmap_list_t t)) - (i : usize) : - result ((hashmap_hash_map_t t) & (vec (hashmap_list_t t))) +let hashmap_HashMap_move_elements + (t : Type0) (ntable : hashmap_HashMap_t t) + (slots : alloc_vec_Vec (hashmap_List_t t)) (i : usize) : + result ((hashmap_HashMap_t t) & (alloc_vec_Vec (hashmap_List_t t))) = - hashmap_hash_map_move_elements_loop_fwd_back t ntable slots i + hashmap_HashMap_move_elements_loop t ntable slots i (** [hashmap_main::hashmap::HashMap::{0}::try_resize]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) -let hashmap_hash_map_try_resize_fwd_back - (t : Type0) (self : hashmap_hash_map_t t) : result (hashmap_hash_map_t t) = +let hashmap_HashMap_try_resize + (t : Type0) (self : hashmap_HashMap_t t) : result (hashmap_HashMap_t t) = let* max_usize = scalar_cast U32 Usize core_u32_max in - let capacity = vec_len (hashmap_list_t t) self.hashmap_hash_map_slots in + let capacity = alloc_vec_Vec_len (hashmap_List_t t) self.slots in let* n1 = usize_div max_usize 2 in - let (i, i0) = self.hashmap_hash_map_max_load_factor in + let (i, i0) = self.max_load_factor in let* i1 = usize_div n1 i in if capacity <= i1 then let* i2 = usize_mul capacity 2 in - let* ntable = hashmap_hash_map_new_with_capacity_fwd t i2 i i0 in - let* (ntable0, _) = - hashmap_hash_map_move_elements_fwd_back t ntable - self.hashmap_hash_map_slots 0 in + let* ntable = hashmap_HashMap_new_with_capacity t i2 i i0 in + let* (ntable0, _) = hashmap_HashMap_move_elements t ntable self.slots 0 in Return - { - ntable0 - with - hashmap_hash_map_num_entries = self.hashmap_hash_map_num_entries; - hashmap_hash_map_max_load_factor = (i, i0) + { ntable0 with num_entries = self.num_entries; max_load_factor = (i, i0) } - else Return { self with hashmap_hash_map_max_load_factor = (i, i0) } + else Return { self with max_load_factor = (i, i0) } (** [hashmap_main::hashmap::HashMap::{0}::insert]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) -let hashmap_hash_map_insert_fwd_back - (t : Type0) (self : hashmap_hash_map_t t) (key : usize) (value : t) : - result (hashmap_hash_map_t t) +let hashmap_HashMap_insert + (t : Type0) (self : hashmap_HashMap_t t) (key : usize) (value : t) : + result (hashmap_HashMap_t t) = - let* self0 = hashmap_hash_map_insert_no_resize_fwd_back t self key value in - let* i = hashmap_hash_map_len_fwd t self0 in - if i > self0.hashmap_hash_map_max_load - then hashmap_hash_map_try_resize_fwd_back t self0 + let* self0 = hashmap_HashMap_insert_no_resize t self key value in + let* i = hashmap_HashMap_len t self0 in + if i > self0.max_load + then hashmap_HashMap_try_resize t self0 else Return self0 (** [hashmap_main::hashmap::HashMap::{0}::contains_key_in_list]: loop 0: forward function *) -let rec hashmap_hash_map_contains_key_in_list_loop_fwd - (t : Type0) (key : usize) (ls : hashmap_list_t t) : +let rec hashmap_HashMap_contains_key_in_list_loop + (t : Type0) (key : usize) (ls : hashmap_List_t t) : Tot (result bool) - (decreases (hashmap_hash_map_contains_key_in_list_loop_decreases t key ls)) + (decreases (hashmap_HashMap_contains_key_in_list_loop_decreases t key ls)) = begin match ls with - | HashmapListCons ckey x tl -> + | Hashmap_List_Cons ckey x tl -> if ckey = key then Return true - else hashmap_hash_map_contains_key_in_list_loop_fwd t key tl - | HashmapListNil -> Return false + else hashmap_HashMap_contains_key_in_list_loop t key tl + | Hashmap_List_Nil -> Return false end (** [hashmap_main::hashmap::HashMap::{0}::contains_key_in_list]: forward function *) -let hashmap_hash_map_contains_key_in_list_fwd - (t : Type0) (key : usize) (ls : hashmap_list_t t) : result bool = - hashmap_hash_map_contains_key_in_list_loop_fwd t key ls +let hashmap_HashMap_contains_key_in_list + (t : Type0) (key : usize) (ls : hashmap_List_t t) : result bool = + hashmap_HashMap_contains_key_in_list_loop t key ls (** [hashmap_main::hashmap::HashMap::{0}::contains_key]: forward function *) -let hashmap_hash_map_contains_key_fwd - (t : Type0) (self : hashmap_hash_map_t t) (key : usize) : result bool = - let* hash = hashmap_hash_key_fwd key in - let i = vec_len (hashmap_list_t t) self.hashmap_hash_map_slots in +let hashmap_HashMap_contains_key + (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : result bool = + let* hash = hashmap_hash_key key in + let i = alloc_vec_Vec_len (hashmap_List_t t) self.slots in let* hash_mod = usize_rem hash i in let* l = - vec_index_fwd (hashmap_list_t t) self.hashmap_hash_map_slots hash_mod in - hashmap_hash_map_contains_key_in_list_fwd t key l + alloc_vec_Vec_index (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + self.slots hash_mod in + hashmap_HashMap_contains_key_in_list t key l (** [hashmap_main::hashmap::HashMap::{0}::get_in_list]: loop 0: forward function *) -let rec hashmap_hash_map_get_in_list_loop_fwd - (t : Type0) (key : usize) (ls : hashmap_list_t t) : +let rec hashmap_HashMap_get_in_list_loop + (t : Type0) (key : usize) (ls : hashmap_List_t t) : Tot (result t) - (decreases (hashmap_hash_map_get_in_list_loop_decreases t key ls)) + (decreases (hashmap_HashMap_get_in_list_loop_decreases t key ls)) = begin match ls with - | HashmapListCons ckey cvalue tl -> + | Hashmap_List_Cons ckey cvalue tl -> if ckey = key then Return cvalue - else hashmap_hash_map_get_in_list_loop_fwd t key tl - | HashmapListNil -> Fail Failure + else hashmap_HashMap_get_in_list_loop t key tl + | Hashmap_List_Nil -> Fail Failure end (** [hashmap_main::hashmap::HashMap::{0}::get_in_list]: forward function *) -let hashmap_hash_map_get_in_list_fwd - (t : Type0) (key : usize) (ls : hashmap_list_t t) : result t = - hashmap_hash_map_get_in_list_loop_fwd t key ls +let hashmap_HashMap_get_in_list + (t : Type0) (key : usize) (ls : hashmap_List_t t) : result t = + hashmap_HashMap_get_in_list_loop t key ls (** [hashmap_main::hashmap::HashMap::{0}::get]: forward function *) -let hashmap_hash_map_get_fwd - (t : Type0) (self : hashmap_hash_map_t t) (key : usize) : result t = - let* hash = hashmap_hash_key_fwd key in - let i = vec_len (hashmap_list_t t) self.hashmap_hash_map_slots in +let hashmap_HashMap_get + (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : result t = + let* hash = hashmap_hash_key key in + let i = alloc_vec_Vec_len (hashmap_List_t t) self.slots in let* hash_mod = usize_rem hash i in let* l = - vec_index_fwd (hashmap_list_t t) self.hashmap_hash_map_slots hash_mod in - hashmap_hash_map_get_in_list_fwd t key l + alloc_vec_Vec_index (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + self.slots hash_mod in + hashmap_HashMap_get_in_list t key l (** [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: loop 0: forward function *) -let rec hashmap_hash_map_get_mut_in_list_loop_fwd - (t : Type0) (ls : hashmap_list_t t) (key : usize) : +let rec hashmap_HashMap_get_mut_in_list_loop + (t : Type0) (ls : hashmap_List_t t) (key : usize) : Tot (result t) - (decreases (hashmap_hash_map_get_mut_in_list_loop_decreases t ls key)) + (decreases (hashmap_HashMap_get_mut_in_list_loop_decreases t ls key)) = begin match ls with - | HashmapListCons ckey cvalue tl -> + | Hashmap_List_Cons ckey cvalue tl -> if ckey = key then Return cvalue - else hashmap_hash_map_get_mut_in_list_loop_fwd t tl key - | HashmapListNil -> Fail Failure + else hashmap_HashMap_get_mut_in_list_loop t tl key + | Hashmap_List_Nil -> Fail Failure end (** [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: forward function *) -let hashmap_hash_map_get_mut_in_list_fwd - (t : Type0) (ls : hashmap_list_t t) (key : usize) : result t = - hashmap_hash_map_get_mut_in_list_loop_fwd t ls key +let hashmap_HashMap_get_mut_in_list + (t : Type0) (ls : hashmap_List_t t) (key : usize) : result t = + hashmap_HashMap_get_mut_in_list_loop t ls key (** [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: loop 0: backward function 0 *) -let rec hashmap_hash_map_get_mut_in_list_loop_back - (t : Type0) (ls : hashmap_list_t t) (key : usize) (ret : t) : - Tot (result (hashmap_list_t t)) - (decreases (hashmap_hash_map_get_mut_in_list_loop_decreases t ls key)) +let rec hashmap_HashMap_get_mut_in_list_loop_back + (t : Type0) (ls : hashmap_List_t t) (key : usize) (ret : t) : + Tot (result (hashmap_List_t t)) + (decreases (hashmap_HashMap_get_mut_in_list_loop_decreases t ls key)) = begin match ls with - | HashmapListCons ckey cvalue tl -> + | Hashmap_List_Cons ckey cvalue tl -> if ckey = key - then Return (HashmapListCons ckey ret tl) + then Return (Hashmap_List_Cons ckey ret tl) else - let* tl0 = hashmap_hash_map_get_mut_in_list_loop_back t tl key ret in - Return (HashmapListCons ckey cvalue tl0) - | HashmapListNil -> Fail Failure + let* tl0 = hashmap_HashMap_get_mut_in_list_loop_back t tl key ret in + Return (Hashmap_List_Cons ckey cvalue tl0) + | Hashmap_List_Nil -> Fail Failure end (** [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: backward function 0 *) -let hashmap_hash_map_get_mut_in_list_back - (t : Type0) (ls : hashmap_list_t t) (key : usize) (ret : t) : - result (hashmap_list_t t) +let hashmap_HashMap_get_mut_in_list_back + (t : Type0) (ls : hashmap_List_t t) (key : usize) (ret : t) : + result (hashmap_List_t t) = - hashmap_hash_map_get_mut_in_list_loop_back t ls key ret + hashmap_HashMap_get_mut_in_list_loop_back t ls key ret (** [hashmap_main::hashmap::HashMap::{0}::get_mut]: forward function *) -let hashmap_hash_map_get_mut_fwd - (t : Type0) (self : hashmap_hash_map_t t) (key : usize) : result t = - let* hash = hashmap_hash_key_fwd key in - let i = vec_len (hashmap_list_t t) self.hashmap_hash_map_slots in +let hashmap_HashMap_get_mut + (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : result t = + let* hash = hashmap_hash_key key in + let i = alloc_vec_Vec_len (hashmap_List_t t) self.slots in let* hash_mod = usize_rem hash i in let* l = - vec_index_mut_fwd (hashmap_list_t t) self.hashmap_hash_map_slots hash_mod - in - hashmap_hash_map_get_mut_in_list_fwd t l key + alloc_vec_Vec_index_mut (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + self.slots hash_mod in + hashmap_HashMap_get_mut_in_list t l key (** [hashmap_main::hashmap::HashMap::{0}::get_mut]: backward function 0 *) -let hashmap_hash_map_get_mut_back - (t : Type0) (self : hashmap_hash_map_t t) (key : usize) (ret : t) : - result (hashmap_hash_map_t t) +let hashmap_HashMap_get_mut_back + (t : Type0) (self : hashmap_HashMap_t t) (key : usize) (ret : t) : + result (hashmap_HashMap_t t) = - let* hash = hashmap_hash_key_fwd key in - let i = vec_len (hashmap_list_t t) self.hashmap_hash_map_slots in + let* hash = hashmap_hash_key key in + let i = alloc_vec_Vec_len (hashmap_List_t t) self.slots in let* hash_mod = usize_rem hash i in let* l = - vec_index_mut_fwd (hashmap_list_t t) self.hashmap_hash_map_slots hash_mod - in - let* l0 = hashmap_hash_map_get_mut_in_list_back t l key ret in + alloc_vec_Vec_index_mut (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + self.slots hash_mod in + let* l0 = hashmap_HashMap_get_mut_in_list_back t l key ret in let* v = - vec_index_mut_back (hashmap_list_t t) self.hashmap_hash_map_slots hash_mod - l0 in - Return { self with hashmap_hash_map_slots = v } + alloc_vec_Vec_index_mut_back (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + self.slots hash_mod l0 in + Return { self with slots = v } (** [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: loop 0: forward function *) -let rec hashmap_hash_map_remove_from_list_loop_fwd - (t : Type0) (key : usize) (ls : hashmap_list_t t) : +let rec hashmap_HashMap_remove_from_list_loop + (t : Type0) (key : usize) (ls : hashmap_List_t t) : Tot (result (option t)) - (decreases (hashmap_hash_map_remove_from_list_loop_decreases t key ls)) + (decreases (hashmap_HashMap_remove_from_list_loop_decreases t key ls)) = begin match ls with - | HashmapListCons ckey x tl -> + | Hashmap_List_Cons ckey x tl -> if ckey = key then let mv_ls = - mem_replace_fwd (hashmap_list_t t) (HashmapListCons ckey x tl) - HashmapListNil in + core_mem_replace (hashmap_List_t t) (Hashmap_List_Cons ckey x tl) + Hashmap_List_Nil in begin match mv_ls with - | HashmapListCons i cvalue tl0 -> Return (Some cvalue) - | HashmapListNil -> Fail Failure + | Hashmap_List_Cons i cvalue tl0 -> Return (Some cvalue) + | Hashmap_List_Nil -> Fail Failure end - else hashmap_hash_map_remove_from_list_loop_fwd t key tl - | HashmapListNil -> Return None + else hashmap_HashMap_remove_from_list_loop t key tl + | Hashmap_List_Nil -> Return None end (** [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: forward function *) -let hashmap_hash_map_remove_from_list_fwd - (t : Type0) (key : usize) (ls : hashmap_list_t t) : result (option t) = - hashmap_hash_map_remove_from_list_loop_fwd t key ls +let hashmap_HashMap_remove_from_list + (t : Type0) (key : usize) (ls : hashmap_List_t t) : result (option t) = + hashmap_HashMap_remove_from_list_loop t key ls (** [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: loop 0: backward function 1 *) -let rec hashmap_hash_map_remove_from_list_loop_back - (t : Type0) (key : usize) (ls : hashmap_list_t t) : - Tot (result (hashmap_list_t t)) - (decreases (hashmap_hash_map_remove_from_list_loop_decreases t key ls)) +let rec hashmap_HashMap_remove_from_list_loop_back + (t : Type0) (key : usize) (ls : hashmap_List_t t) : + Tot (result (hashmap_List_t t)) + (decreases (hashmap_HashMap_remove_from_list_loop_decreases t key ls)) = begin match ls with - | HashmapListCons ckey x tl -> + | Hashmap_List_Cons ckey x tl -> if ckey = key then let mv_ls = - mem_replace_fwd (hashmap_list_t t) (HashmapListCons ckey x tl) - HashmapListNil in + core_mem_replace (hashmap_List_t t) (Hashmap_List_Cons ckey x tl) + Hashmap_List_Nil in begin match mv_ls with - | HashmapListCons i cvalue tl0 -> Return tl0 - | HashmapListNil -> Fail Failure + | Hashmap_List_Cons i cvalue tl0 -> Return tl0 + | Hashmap_List_Nil -> Fail Failure end else - let* tl0 = hashmap_hash_map_remove_from_list_loop_back t key tl in - Return (HashmapListCons ckey x tl0) - | HashmapListNil -> Return HashmapListNil + let* tl0 = hashmap_HashMap_remove_from_list_loop_back t key tl in + Return (Hashmap_List_Cons ckey x tl0) + | Hashmap_List_Nil -> Return Hashmap_List_Nil end (** [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: backward function 1 *) -let hashmap_hash_map_remove_from_list_back - (t : Type0) (key : usize) (ls : hashmap_list_t t) : - result (hashmap_list_t t) +let hashmap_HashMap_remove_from_list_back + (t : Type0) (key : usize) (ls : hashmap_List_t t) : + result (hashmap_List_t t) = - hashmap_hash_map_remove_from_list_loop_back t key ls + hashmap_HashMap_remove_from_list_loop_back t key ls (** [hashmap_main::hashmap::HashMap::{0}::remove]: forward function *) -let hashmap_hash_map_remove_fwd - (t : Type0) (self : hashmap_hash_map_t t) (key : usize) : result (option t) = - let* hash = hashmap_hash_key_fwd key in - let i = vec_len (hashmap_list_t t) self.hashmap_hash_map_slots in +let hashmap_HashMap_remove + (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : result (option t) = + let* hash = hashmap_hash_key key in + let i = alloc_vec_Vec_len (hashmap_List_t t) self.slots in let* hash_mod = usize_rem hash i in let* l = - vec_index_mut_fwd (hashmap_list_t t) self.hashmap_hash_map_slots hash_mod - in - let* x = hashmap_hash_map_remove_from_list_fwd t key l in + alloc_vec_Vec_index_mut (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + self.slots hash_mod in + let* x = hashmap_HashMap_remove_from_list t key l in begin match x with | None -> Return None - | Some x0 -> - let* _ = usize_sub self.hashmap_hash_map_num_entries 1 in Return (Some x0) + | Some x0 -> let* _ = usize_sub self.num_entries 1 in Return (Some x0) end (** [hashmap_main::hashmap::HashMap::{0}::remove]: backward function 0 *) -let hashmap_hash_map_remove_back - (t : Type0) (self : hashmap_hash_map_t t) (key : usize) : - result (hashmap_hash_map_t t) +let hashmap_HashMap_remove_back + (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : + result (hashmap_HashMap_t t) = - let* hash = hashmap_hash_key_fwd key in - let i = vec_len (hashmap_list_t t) self.hashmap_hash_map_slots in + let* hash = hashmap_hash_key key in + let i = alloc_vec_Vec_len (hashmap_List_t t) self.slots in let* hash_mod = usize_rem hash i in let* l = - vec_index_mut_fwd (hashmap_list_t t) self.hashmap_hash_map_slots hash_mod - in - let* x = hashmap_hash_map_remove_from_list_fwd t key l in + alloc_vec_Vec_index_mut (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + self.slots hash_mod in + let* x = hashmap_HashMap_remove_from_list t key l in begin match x with | None -> - let* l0 = hashmap_hash_map_remove_from_list_back t key l in + let* l0 = hashmap_HashMap_remove_from_list_back t key l in let* v = - vec_index_mut_back (hashmap_list_t t) self.hashmap_hash_map_slots - hash_mod l0 in - Return { self with hashmap_hash_map_slots = v } + alloc_vec_Vec_index_mut_back (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t + t)) self.slots hash_mod l0 in + Return { self with slots = v } | Some x0 -> - let* i0 = usize_sub self.hashmap_hash_map_num_entries 1 in - let* l0 = hashmap_hash_map_remove_from_list_back t key l in + let* i0 = usize_sub self.num_entries 1 in + let* l0 = hashmap_HashMap_remove_from_list_back t key l in let* v = - vec_index_mut_back (hashmap_list_t t) self.hashmap_hash_map_slots - hash_mod l0 in - Return - { self with hashmap_hash_map_num_entries = i0; hashmap_hash_map_slots = v - } + alloc_vec_Vec_index_mut_back (hashmap_List_t t) usize + (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t + t)) self.slots hash_mod l0 in + Return { self with num_entries = i0; slots = v } end (** [hashmap_main::hashmap::test1]: forward function *) -let hashmap_test1_fwd : result unit = - let* hm = hashmap_hash_map_new_fwd u64 in - let* hm0 = hashmap_hash_map_insert_fwd_back u64 hm 0 42 in - let* hm1 = hashmap_hash_map_insert_fwd_back u64 hm0 128 18 in - let* hm2 = hashmap_hash_map_insert_fwd_back u64 hm1 1024 138 in - let* hm3 = hashmap_hash_map_insert_fwd_back u64 hm2 1056 256 in - let* i = hashmap_hash_map_get_fwd u64 hm3 128 in +let hashmap_test1 : result unit = + let* hm = hashmap_HashMap_new u64 in + let* hm0 = hashmap_HashMap_insert u64 hm 0 42 in + let* hm1 = hashmap_HashMap_insert u64 hm0 128 18 in + let* hm2 = hashmap_HashMap_insert u64 hm1 1024 138 in + let* hm3 = hashmap_HashMap_insert u64 hm2 1056 256 in + let* i = hashmap_HashMap_get u64 hm3 128 in if not (i = 18) then Fail Failure else - let* hm4 = hashmap_hash_map_get_mut_back u64 hm3 1024 56 in - let* i0 = hashmap_hash_map_get_fwd u64 hm4 1024 in + let* hm4 = hashmap_HashMap_get_mut_back u64 hm3 1024 56 in + let* i0 = hashmap_HashMap_get u64 hm4 1024 in if not (i0 = 56) then Fail Failure else - let* x = hashmap_hash_map_remove_fwd u64 hm4 1024 in + let* x = hashmap_HashMap_remove u64 hm4 1024 in begin match x with | None -> Fail Failure | Some x0 -> if not (x0 = 56) then Fail Failure else - let* hm5 = hashmap_hash_map_remove_back u64 hm4 1024 in - let* i1 = hashmap_hash_map_get_fwd u64 hm5 0 in + let* hm5 = hashmap_HashMap_remove_back u64 hm4 1024 in + let* i1 = hashmap_HashMap_get u64 hm5 0 in if not (i1 = 42) then Fail Failure else - let* i2 = hashmap_hash_map_get_fwd u64 hm5 128 in + let* i2 = hashmap_HashMap_get u64 hm5 128 in if not (i2 = 18) then Fail Failure else - let* i3 = hashmap_hash_map_get_fwd u64 hm5 1056 in + let* i3 = hashmap_HashMap_get u64 hm5 1056 in if not (i3 = 256) then Fail Failure else Return () end -(** Unit test for [hashmap_main::hashmap::test1] *) -let _ = assert_norm (hashmap_test1_fwd = Return ()) - (** [hashmap_main::insert_on_disk]: forward function *) -let insert_on_disk_fwd +let insert_on_disk (key : usize) (value : u64) (st : state) : result (state & unit) = - let* (st0, hm) = hashmap_utils_deserialize_fwd st in - let* hm0 = hashmap_hash_map_insert_fwd_back u64 hm key value in - let* (st1, _) = hashmap_utils_serialize_fwd hm0 st0 in + let* (st0, hm) = hashmap_utils_deserialize st in + let* hm0 = hashmap_HashMap_insert u64 hm key value in + let* (st1, _) = hashmap_utils_serialize hm0 st0 in Return (st1, ()) (** [hashmap_main::main]: forward function *) -let main_fwd : result unit = +let main : result unit = Return () -(** Unit test for [hashmap_main::main] *) -let _ = assert_norm (main_fwd = Return ()) - diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Opaque.fsti b/tests/fstar/hashmap_on_disk/HashmapMain.Opaque.fsti index 78a6c3ba..d6cecf36 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Opaque.fsti +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Opaque.fsti @@ -7,10 +7,10 @@ include HashmapMain.Types #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" (** [hashmap_main::hashmap_utils::deserialize]: forward function *) -val hashmap_utils_deserialize_fwd - : state -> result (state & (hashmap_hash_map_t u64)) +val hashmap_utils_deserialize + : state -> result (state & (hashmap_HashMap_t u64)) (** [hashmap_main::hashmap_utils::serialize]: forward function *) -val hashmap_utils_serialize_fwd - : hashmap_hash_map_t u64 -> state -> result (state & unit) +val hashmap_utils_serialize + : hashmap_HashMap_t u64 -> state -> result (state & unit) diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti b/tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti index e289174b..24b78c2a 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti @@ -6,17 +6,17 @@ open Primitives #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" (** [hashmap_main::hashmap::List] *) -type hashmap_list_t (t : Type0) = -| HashmapListCons : usize -> t -> hashmap_list_t t -> hashmap_list_t t -| HashmapListNil : hashmap_list_t t +type hashmap_List_t (t : Type0) = +| Hashmap_List_Cons : usize -> t -> hashmap_List_t t -> hashmap_List_t t +| Hashmap_List_Nil : hashmap_List_t t (** [hashmap_main::hashmap::HashMap] *) -type hashmap_hash_map_t (t : Type0) = +type hashmap_HashMap_t (t : Type0) = { - hashmap_hash_map_num_entries : usize; - hashmap_hash_map_max_load_factor : (usize & usize); - hashmap_hash_map_max_load : usize; - hashmap_hash_map_slots : vec (hashmap_list_t t); + num_entries : usize; + max_load_factor : (usize & usize); + max_load : usize; + slots : alloc_vec_Vec (hashmap_List_t t); } (** The state type used in the state-error monad *) -- cgit v1.2.3 From 67fb76ae5801fdb8f134394425e466dbe611a54b Mon Sep 17 00:00:00 2001 From: Son Ho Date: Fri, 27 Oct 2023 12:26:20 +0200 Subject: Regenerate more F* files --- tests/fstar/hashmap_on_disk/Primitives.fst | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'tests/fstar/hashmap_on_disk') diff --git a/tests/fstar/hashmap_on_disk/Primitives.fst b/tests/fstar/hashmap_on_disk/Primitives.fst index 3110b247..71d75c11 100644 --- a/tests/fstar/hashmap_on_disk/Primitives.fst +++ b/tests/fstar/hashmap_on_disk/Primitives.fst @@ -707,5 +707,7 @@ let alloc_vec_Vec_coreopsindexIndexMutInst (t idx : Type0) let alloc_vec_Vec_index_mut_back_eq (#a : Type0) (v : alloc_vec_Vec a) (i : usize) (x : a) : Lemma ( alloc_vec_Vec_index_mut_back a usize (core_slice_index_usize_coresliceindexSliceIndexInst a) v i x == - alloc_vec_Vec_update_usize v i x) = + alloc_vec_Vec_update_usize v i x) + [SMTPat (alloc_vec_Vec_index_mut_back a usize (core_slice_index_usize_coresliceindexSliceIndexInst a) v i x)] + = admit() -- cgit v1.2.3 From 00705bba68fed61d3b0bcde2c5fe0ecc83880870 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 9 Nov 2023 18:37:07 +0100 Subject: Update the failing proofs --- .../fstar/hashmap_on_disk/HashmapMain.Properties.fst | 20 ++++++++++---------- tests/fstar/hashmap_on_disk/Primitives.fst | 18 +++++++++++++++++- 2 files changed, 27 insertions(+), 11 deletions(-) (limited to 'tests/fstar/hashmap_on_disk') diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Properties.fst b/tests/fstar/hashmap_on_disk/HashmapMain.Properties.fst index 106fe05a..358df29e 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Properties.fst +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Properties.fst @@ -13,36 +13,36 @@ open HashmapMain.Funs /// [state_v] gives us the hash map currently stored on disk assume -val state_v : state -> hashmap_hash_map_t u64 +val state_v : state -> hashmap_HashMap_t u64 /// [serialize] updates the hash map stored on disk assume -val serialize_lem (hm : hashmap_hash_map_t u64) (st : state) : Lemma ( - match hashmap_utils_serialize_fwd hm st with +val serialize_lem (hm : hashmap_HashMap_t u64) (st : state) : Lemma ( + match hashmap_utils_serialize hm st with | Fail _ -> True | Return (st', ()) -> state_v st' == hm) - [SMTPat (hashmap_utils_serialize_fwd hm st)] + [SMTPat (hashmap_utils_serialize hm st)] /// [deserialize] gives us the hash map stored on disk, without updating it assume val deserialize_lem (st : state) : Lemma ( - match hashmap_utils_deserialize_fwd st with + match hashmap_utils_deserialize st with | Fail _ -> True | Return (st', hm) -> hm == state_v st /\ st' == st) - [SMTPat (hashmap_utils_deserialize_fwd st)] + [SMTPat (hashmap_utils_deserialize st)] (*** Lemmas *) /// The obvious lemma about [insert_on_disk]: the updated hash map stored on disk /// is exactly the hash map produced from inserting the binding ([key], [value]) /// in the hash map previously stored on disk. -val insert_on_disk_fwd_lem (key : usize) (value : u64) (st : state) : Lemma ( - match insert_on_disk_fwd key value st with +val insert_on_disk_lem (key : usize) (value : u64) (st : state) : Lemma ( + match insert_on_disk key value st with | Fail _ -> True | Return (st', ()) -> let hm = state_v st in - match hashmap_hash_map_insert_fwd_back u64 hm key value with + match hashmap_HashMap_insert u64 hm key value with | Fail _ -> False | Return hm' -> hm' == state_v st') -let insert_on_disk_fwd_lem key value st = () +let insert_on_disk_lem key value st = () diff --git a/tests/fstar/hashmap_on_disk/Primitives.fst b/tests/fstar/hashmap_on_disk/Primitives.fst index 71d75c11..3297803c 100644 --- a/tests/fstar/hashmap_on_disk/Primitives.fst +++ b/tests/fstar/hashmap_on_disk/Primitives.fst @@ -427,7 +427,7 @@ let alloc_vec_Vec_new (a : Type0) : alloc_vec_Vec a = assert_norm(length #a [] let alloc_vec_Vec_len (a : Type0) (v : alloc_vec_Vec a) : usize = length v // Helper -let alloc_vec_Vec_index_usize (#a : Type0) (v : alloc_vec_Vec a) (i : usize) (x : a) : result a = +let alloc_vec_Vec_index_usize (#a : Type0) (v : alloc_vec_Vec a) (i : usize) : result a = if i < length v then Return (index v i) else Fail Failure // Helper let alloc_vec_Vec_update_usize (#a : Type0) (v : alloc_vec_Vec a) (i : usize) (x : a) : result (alloc_vec_Vec a) = @@ -704,6 +704,22 @@ let alloc_vec_Vec_coreopsindexIndexMutInst (t idx : Type0) (*** Theorems *) +let alloc_vec_Vec_index_eq (#a : Type0) (v : alloc_vec_Vec a) (i : usize) : + Lemma ( + alloc_vec_Vec_index a usize (core_slice_index_usize_coresliceindexSliceIndexInst a) v i == + alloc_vec_Vec_index_usize v i) + [SMTPat (alloc_vec_Vec_index a usize (core_slice_index_usize_coresliceindexSliceIndexInst a) v i)] + = + admit() + +let alloc_vec_Vec_index_mut_eq (#a : Type0) (v : alloc_vec_Vec a) (i : usize) : + Lemma ( + alloc_vec_Vec_index_mut a usize (core_slice_index_usize_coresliceindexSliceIndexInst a) v i == + alloc_vec_Vec_index_usize v i) + [SMTPat (alloc_vec_Vec_index_mut a usize (core_slice_index_usize_coresliceindexSliceIndexInst a) v i)] + = + admit() + let alloc_vec_Vec_index_mut_back_eq (#a : Type0) (v : alloc_vec_Vec a) (i : usize) (x : a) : Lemma ( alloc_vec_Vec_index_mut_back a usize (core_slice_index_usize_coresliceindexSliceIndexInst a) v i x == -- cgit v1.2.3 From 5e92ae6b361f9221f5c5f9a39ab4c28a36597a77 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 21 Nov 2023 11:40:59 +0100 Subject: Regenerate most of the test files --- .../HashmapMain.Clauses.Template.fst | 18 ++-- tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst | 116 ++++++++++----------- tests/fstar/hashmap_on_disk/Primitives.fst | 88 ++++++++-------- 3 files changed, 111 insertions(+), 111 deletions(-) (limited to 'tests/fstar/hashmap_on_disk') diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.Template.fst b/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.Template.fst index 61885ac7..106fa94b 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.Template.fst +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.Template.fst @@ -6,56 +6,56 @@ open HashmapMain.Types #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" -(** [hashmap_main::hashmap::HashMap::{0}::allocate_slots]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: decreases clause *) unfold let hashmap_HashMap_allocate_slots_loop_decreases (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (n : usize) : nat = admit () -(** [hashmap_main::hashmap::HashMap::{0}::clear]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::clear]: decreases clause *) unfold let hashmap_HashMap_clear_loop_decreases (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (i : usize) : nat = admit () -(** [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: decreases clause *) unfold let hashmap_HashMap_insert_in_list_loop_decreases (t : Type0) (key : usize) (value : t) (ls : hashmap_List_t t) : nat = admit () -(** [hashmap_main::hashmap::HashMap::{0}::move_elements_from_list]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements_from_list]: decreases clause *) unfold let hashmap_HashMap_move_elements_from_list_loop_decreases (t : Type0) (ntable : hashmap_HashMap_t t) (ls : hashmap_List_t t) : nat = admit () -(** [hashmap_main::hashmap::HashMap::{0}::move_elements]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements]: decreases clause *) unfold let hashmap_HashMap_move_elements_loop_decreases (t : Type0) (ntable : hashmap_HashMap_t t) (slots : alloc_vec_Vec (hashmap_List_t t)) (i : usize) : nat = admit () -(** [hashmap_main::hashmap::HashMap::{0}::contains_key_in_list]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: decreases clause *) unfold let hashmap_HashMap_contains_key_in_list_loop_decreases (t : Type0) (key : usize) (ls : hashmap_List_t t) : nat = admit () -(** [hashmap_main::hashmap::HashMap::{0}::get_in_list]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: decreases clause *) unfold let hashmap_HashMap_get_in_list_loop_decreases (t : Type0) (key : usize) (ls : hashmap_List_t t) : nat = admit () -(** [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: decreases clause *) unfold let hashmap_HashMap_get_mut_in_list_loop_decreases (t : Type0) (ls : hashmap_List_t t) (key : usize) : nat = admit () -(** [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: decreases clause *) unfold let hashmap_HashMap_remove_from_list_loop_decreases (t : Type0) (key : usize) (ls : hashmap_List_t t) : nat = diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst b/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst index 5f227596..30bcfb2e 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst @@ -12,7 +12,7 @@ include HashmapMain.Clauses let hashmap_hash_key (k : usize) : result usize = Return k -(** [hashmap_main::hashmap::HashMap::{0}::allocate_slots]: loop 0: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: loop 0: forward function *) let rec hashmap_HashMap_allocate_slots_loop (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (n : usize) : Tot (result (alloc_vec_Vec (hashmap_List_t t))) @@ -26,14 +26,14 @@ let rec hashmap_HashMap_allocate_slots_loop hashmap_HashMap_allocate_slots_loop t slots0 n0 else Return slots -(** [hashmap_main::hashmap::HashMap::{0}::allocate_slots]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: forward function *) let hashmap_HashMap_allocate_slots (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (n : usize) : result (alloc_vec_Vec (hashmap_List_t t)) = hashmap_HashMap_allocate_slots_loop t slots n -(** [hashmap_main::hashmap::HashMap::{0}::new_with_capacity]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::new_with_capacity]: forward function *) let hashmap_HashMap_new_with_capacity (t : Type0) (capacity : usize) (max_load_dividend : usize) (max_load_divisor : usize) : @@ -51,11 +51,11 @@ let hashmap_HashMap_new_with_capacity slots = slots } -(** [hashmap_main::hashmap::HashMap::{0}::new]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::new]: forward function *) let hashmap_HashMap_new (t : Type0) : result (hashmap_HashMap_t t) = hashmap_HashMap_new_with_capacity t 32 4 5 -(** [hashmap_main::hashmap::HashMap::{0}::clear]: loop 0: merged forward/backward function +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::clear]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) let rec hashmap_HashMap_clear_loop (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (i : usize) : @@ -68,24 +68,24 @@ let rec hashmap_HashMap_clear_loop let* i1 = usize_add i 1 in let* slots0 = alloc_vec_Vec_index_mut_back (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t - t)) slots i Hashmap_List_Nil in + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) slots i + Hashmap_List_Nil in hashmap_HashMap_clear_loop t slots0 i1 else Return slots -(** [hashmap_main::hashmap::HashMap::{0}::clear]: merged forward/backward function +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::clear]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) let hashmap_HashMap_clear (t : Type0) (self : hashmap_HashMap_t t) : result (hashmap_HashMap_t t) = let* v = hashmap_HashMap_clear_loop t self.slots 0 in Return { self with num_entries = 0; slots = v } -(** [hashmap_main::hashmap::HashMap::{0}::len]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::len]: forward function *) let hashmap_HashMap_len (t : Type0) (self : hashmap_HashMap_t t) : result usize = Return self.num_entries -(** [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: loop 0: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: loop 0: forward function *) let rec hashmap_HashMap_insert_in_list_loop (t : Type0) (key : usize) (value : t) (ls : hashmap_List_t t) : Tot (result bool) @@ -99,12 +99,12 @@ let rec hashmap_HashMap_insert_in_list_loop | Hashmap_List_Nil -> Return true end -(** [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: forward function *) let hashmap_HashMap_insert_in_list (t : Type0) (key : usize) (value : t) (ls : hashmap_List_t t) : result bool = hashmap_HashMap_insert_in_list_loop t key value ls -(** [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: loop 0: backward function 0 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: loop 0: backward function 0 *) let rec hashmap_HashMap_insert_in_list_loop_back (t : Type0) (key : usize) (value : t) (ls : hashmap_List_t t) : Tot (result (hashmap_List_t t)) @@ -121,14 +121,14 @@ let rec hashmap_HashMap_insert_in_list_loop_back let l = Hashmap_List_Nil in Return (Hashmap_List_Cons key value l) end -(** [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: backward function 0 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: backward function 0 *) let hashmap_HashMap_insert_in_list_back (t : Type0) (key : usize) (value : t) (ls : hashmap_List_t t) : result (hashmap_List_t t) = hashmap_HashMap_insert_in_list_loop_back t key value ls -(** [hashmap_main::hashmap::HashMap::{0}::insert_no_resize]: merged forward/backward function +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_no_resize]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) let hashmap_HashMap_insert_no_resize (t : Type0) (self : hashmap_HashMap_t t) (key : usize) (value : t) : @@ -139,7 +139,7 @@ let hashmap_HashMap_insert_no_resize let* hash_mod = usize_rem hash i in let* l = alloc_vec_Vec_index_mut (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) self.slots hash_mod in let* inserted = hashmap_HashMap_insert_in_list t key value l in if inserted @@ -148,18 +148,18 @@ let hashmap_HashMap_insert_no_resize let* l0 = hashmap_HashMap_insert_in_list_back t key value l in let* v = alloc_vec_Vec_index_mut_back (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t - t)) self.slots hash_mod l0 in + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) + self.slots hash_mod l0 in Return { self with num_entries = i0; slots = v } else let* l0 = hashmap_HashMap_insert_in_list_back t key value l in let* v = alloc_vec_Vec_index_mut_back (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t - t)) self.slots hash_mod l0 in + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) + self.slots hash_mod l0 in Return { self with slots = v } -(** [hashmap_main::hashmap::HashMap::{0}::move_elements_from_list]: loop 0: merged forward/backward function +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements_from_list]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) let rec hashmap_HashMap_move_elements_from_list_loop (t : Type0) (ntable : hashmap_HashMap_t t) (ls : hashmap_List_t t) : @@ -174,7 +174,7 @@ let rec hashmap_HashMap_move_elements_from_list_loop | Hashmap_List_Nil -> Return ntable end -(** [hashmap_main::hashmap::HashMap::{0}::move_elements_from_list]: merged forward/backward function +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements_from_list]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) let hashmap_HashMap_move_elements_from_list (t : Type0) (ntable : hashmap_HashMap_t t) (ls : hashmap_List_t t) : @@ -182,7 +182,7 @@ let hashmap_HashMap_move_elements_from_list = hashmap_HashMap_move_elements_from_list_loop t ntable ls -(** [hashmap_main::hashmap::HashMap::{0}::move_elements]: loop 0: merged forward/backward function +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) let rec hashmap_HashMap_move_elements_loop (t : Type0) (ntable : hashmap_HashMap_t t) @@ -195,20 +195,20 @@ let rec hashmap_HashMap_move_elements_loop then let* l = alloc_vec_Vec_index_mut (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t - t)) slots i in + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) slots i + in let ls = core_mem_replace (hashmap_List_t t) l Hashmap_List_Nil in let* ntable0 = hashmap_HashMap_move_elements_from_list t ntable ls in let* i1 = usize_add i 1 in let l0 = core_mem_replace_back (hashmap_List_t t) l Hashmap_List_Nil in let* slots0 = alloc_vec_Vec_index_mut_back (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t - t)) slots i l0 in + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) slots i + l0 in hashmap_HashMap_move_elements_loop t ntable0 slots0 i1 else Return (ntable, slots) -(** [hashmap_main::hashmap::HashMap::{0}::move_elements]: merged forward/backward function +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) let hashmap_HashMap_move_elements (t : Type0) (ntable : hashmap_HashMap_t t) @@ -217,7 +217,7 @@ let hashmap_HashMap_move_elements = hashmap_HashMap_move_elements_loop t ntable slots i -(** [hashmap_main::hashmap::HashMap::{0}::try_resize]: merged forward/backward function +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::try_resize]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) let hashmap_HashMap_try_resize (t : Type0) (self : hashmap_HashMap_t t) : result (hashmap_HashMap_t t) = @@ -236,7 +236,7 @@ let hashmap_HashMap_try_resize } else Return { self with max_load_factor = (i, i0) } -(** [hashmap_main::hashmap::HashMap::{0}::insert]: merged forward/backward function +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) let hashmap_HashMap_insert (t : Type0) (self : hashmap_HashMap_t t) (key : usize) (value : t) : @@ -248,7 +248,7 @@ let hashmap_HashMap_insert then hashmap_HashMap_try_resize t self0 else Return self0 -(** [hashmap_main::hashmap::HashMap::{0}::contains_key_in_list]: loop 0: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: loop 0: forward function *) let rec hashmap_HashMap_contains_key_in_list_loop (t : Type0) (key : usize) (ls : hashmap_List_t t) : Tot (result bool) @@ -262,12 +262,12 @@ let rec hashmap_HashMap_contains_key_in_list_loop | Hashmap_List_Nil -> Return false end -(** [hashmap_main::hashmap::HashMap::{0}::contains_key_in_list]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: forward function *) let hashmap_HashMap_contains_key_in_list (t : Type0) (key : usize) (ls : hashmap_List_t t) : result bool = hashmap_HashMap_contains_key_in_list_loop t key ls -(** [hashmap_main::hashmap::HashMap::{0}::contains_key]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key]: forward function *) let hashmap_HashMap_contains_key (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : result bool = let* hash = hashmap_hash_key key in @@ -275,11 +275,11 @@ let hashmap_HashMap_contains_key let* hash_mod = usize_rem hash i in let* l = alloc_vec_Vec_index (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) self.slots hash_mod in hashmap_HashMap_contains_key_in_list t key l -(** [hashmap_main::hashmap::HashMap::{0}::get_in_list]: loop 0: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: loop 0: forward function *) let rec hashmap_HashMap_get_in_list_loop (t : Type0) (key : usize) (ls : hashmap_List_t t) : Tot (result t) @@ -293,12 +293,12 @@ let rec hashmap_HashMap_get_in_list_loop | Hashmap_List_Nil -> Fail Failure end -(** [hashmap_main::hashmap::HashMap::{0}::get_in_list]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: forward function *) let hashmap_HashMap_get_in_list (t : Type0) (key : usize) (ls : hashmap_List_t t) : result t = hashmap_HashMap_get_in_list_loop t key ls -(** [hashmap_main::hashmap::HashMap::{0}::get]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get]: forward function *) let hashmap_HashMap_get (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : result t = let* hash = hashmap_hash_key key in @@ -306,11 +306,11 @@ let hashmap_HashMap_get let* hash_mod = usize_rem hash i in let* l = alloc_vec_Vec_index (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) self.slots hash_mod in hashmap_HashMap_get_in_list t key l -(** [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: loop 0: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: loop 0: forward function *) let rec hashmap_HashMap_get_mut_in_list_loop (t : Type0) (ls : hashmap_List_t t) (key : usize) : Tot (result t) @@ -324,12 +324,12 @@ let rec hashmap_HashMap_get_mut_in_list_loop | Hashmap_List_Nil -> Fail Failure end -(** [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: forward function *) let hashmap_HashMap_get_mut_in_list (t : Type0) (ls : hashmap_List_t t) (key : usize) : result t = hashmap_HashMap_get_mut_in_list_loop t ls key -(** [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: loop 0: backward function 0 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: loop 0: backward function 0 *) let rec hashmap_HashMap_get_mut_in_list_loop_back (t : Type0) (ls : hashmap_List_t t) (key : usize) (ret : t) : Tot (result (hashmap_List_t t)) @@ -345,14 +345,14 @@ let rec hashmap_HashMap_get_mut_in_list_loop_back | Hashmap_List_Nil -> Fail Failure end -(** [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: backward function 0 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: backward function 0 *) let hashmap_HashMap_get_mut_in_list_back (t : Type0) (ls : hashmap_List_t t) (key : usize) (ret : t) : result (hashmap_List_t t) = hashmap_HashMap_get_mut_in_list_loop_back t ls key ret -(** [hashmap_main::hashmap::HashMap::{0}::get_mut]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut]: forward function *) let hashmap_HashMap_get_mut (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : result t = let* hash = hashmap_hash_key key in @@ -360,11 +360,11 @@ let hashmap_HashMap_get_mut let* hash_mod = usize_rem hash i in let* l = alloc_vec_Vec_index_mut (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) self.slots hash_mod in hashmap_HashMap_get_mut_in_list t l key -(** [hashmap_main::hashmap::HashMap::{0}::get_mut]: backward function 0 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut]: backward function 0 *) let hashmap_HashMap_get_mut_back (t : Type0) (self : hashmap_HashMap_t t) (key : usize) (ret : t) : result (hashmap_HashMap_t t) @@ -374,16 +374,16 @@ let hashmap_HashMap_get_mut_back let* hash_mod = usize_rem hash i in let* l = alloc_vec_Vec_index_mut (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) self.slots hash_mod in let* l0 = hashmap_HashMap_get_mut_in_list_back t l key ret in let* v = alloc_vec_Vec_index_mut_back (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) self.slots hash_mod l0 in Return { self with slots = v } -(** [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: loop 0: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: loop 0: forward function *) let rec hashmap_HashMap_remove_from_list_loop (t : Type0) (key : usize) (ls : hashmap_List_t t) : Tot (result (option t)) @@ -404,12 +404,12 @@ let rec hashmap_HashMap_remove_from_list_loop | Hashmap_List_Nil -> Return None end -(** [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: forward function *) let hashmap_HashMap_remove_from_list (t : Type0) (key : usize) (ls : hashmap_List_t t) : result (option t) = hashmap_HashMap_remove_from_list_loop t key ls -(** [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: loop 0: backward function 1 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: loop 0: backward function 1 *) let rec hashmap_HashMap_remove_from_list_loop_back (t : Type0) (key : usize) (ls : hashmap_List_t t) : Tot (result (hashmap_List_t t)) @@ -432,14 +432,14 @@ let rec hashmap_HashMap_remove_from_list_loop_back | Hashmap_List_Nil -> Return Hashmap_List_Nil end -(** [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: backward function 1 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: backward function 1 *) let hashmap_HashMap_remove_from_list_back (t : Type0) (key : usize) (ls : hashmap_List_t t) : result (hashmap_List_t t) = hashmap_HashMap_remove_from_list_loop_back t key ls -(** [hashmap_main::hashmap::HashMap::{0}::remove]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove]: forward function *) let hashmap_HashMap_remove (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : result (option t) = let* hash = hashmap_hash_key key in @@ -447,7 +447,7 @@ let hashmap_HashMap_remove let* hash_mod = usize_rem hash i in let* l = alloc_vec_Vec_index_mut (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) self.slots hash_mod in let* x = hashmap_HashMap_remove_from_list t key l in begin match x with @@ -455,7 +455,7 @@ let hashmap_HashMap_remove | Some x0 -> let* _ = usize_sub self.num_entries 1 in Return (Some x0) end -(** [hashmap_main::hashmap::HashMap::{0}::remove]: backward function 0 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove]: backward function 0 *) let hashmap_HashMap_remove_back (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : result (hashmap_HashMap_t t) @@ -465,7 +465,7 @@ let hashmap_HashMap_remove_back let* hash_mod = usize_rem hash i in let* l = alloc_vec_Vec_index_mut (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t t)) + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) self.slots hash_mod in let* x = hashmap_HashMap_remove_from_list t key l in begin match x with @@ -473,16 +473,16 @@ let hashmap_HashMap_remove_back let* l0 = hashmap_HashMap_remove_from_list_back t key l in let* v = alloc_vec_Vec_index_mut_back (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t - t)) self.slots hash_mod l0 in + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) + self.slots hash_mod l0 in Return { self with slots = v } | Some x0 -> let* i0 = usize_sub self.num_entries 1 in let* l0 = hashmap_HashMap_remove_from_list_back t key l in let* v = alloc_vec_Vec_index_mut_back (hashmap_List_t t) usize - (core_slice_index_usize_coresliceindexSliceIndexInst (hashmap_List_t - t)) self.slots hash_mod l0 in + (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t t)) + self.slots hash_mod l0 in Return { self with num_entries = i0; slots = v } end diff --git a/tests/fstar/hashmap_on_disk/Primitives.fst b/tests/fstar/hashmap_on_disk/Primitives.fst index 3297803c..94322ead 100644 --- a/tests/fstar/hashmap_on_disk/Primitives.fst +++ b/tests/fstar/hashmap_on_disk/Primitives.fst @@ -351,14 +351,14 @@ let alloc_boxed_Box_deref_mut (t : Type0) (x : t) : result t = Return x let alloc_boxed_Box_deref_mut_back (t : Type) (_ : t) (x : t) : result t = Return x // Trait instance -let alloc_boxed_Box_coreOpsDerefInst (self : Type0) : core_ops_deref_Deref self = { +let alloc_boxed_Box_coreopsDerefInst (self : Type0) : core_ops_deref_Deref self = { target = self; deref = alloc_boxed_Box_deref self; } // Trait instance -let alloc_boxed_Box_coreOpsDerefMutInst (self : Type0) : core_ops_deref_DerefMut self = { - derefInst = alloc_boxed_Box_coreOpsDerefInst self; +let alloc_boxed_Box_coreopsDerefMutInst (self : Type0) : core_ops_deref_DerefMut self = { + derefInst = alloc_boxed_Box_coreopsDerefInst self; deref_mut = alloc_boxed_Box_deref_mut self; deref_mut_back = alloc_boxed_Box_deref_mut_back self; } @@ -483,23 +483,23 @@ let core_slice_index_Slice_index | Some x -> Return x // [core::slice::index::Range:::get]: forward function -let core_slice_index_Range_get (t : Type0) (i : core_ops_range_Range usize) (s : slice t) : +let core_slice_index_RangeUsize_get (t : Type0) (i : core_ops_range_Range usize) (s : slice t) : result (option (slice t)) = admit () // TODO // [core::slice::index::Range::get_mut]: forward function -let core_slice_index_Range_get_mut +let core_slice_index_RangeUsize_get_mut (t : Type0) : core_ops_range_Range usize → slice t → result (option (slice t)) = admit () // TODO // [core::slice::index::Range::get_mut]: backward function 0 -let core_slice_index_Range_get_mut_back +let core_slice_index_RangeUsize_get_mut_back (t : Type0) : core_ops_range_Range usize → slice t → option (slice t) → result (slice t) = admit () // TODO // [core::slice::index::Range::get_unchecked]: forward function -let core_slice_index_Range_get_unchecked +let core_slice_index_RangeUsize_get_unchecked (t : Type0) : core_ops_range_Range usize → const_raw_ptr (slice t) → result (const_raw_ptr (slice t)) = // Don't know what the model should be - for now we always fail to make @@ -507,7 +507,7 @@ let core_slice_index_Range_get_unchecked fun _ _ -> Fail Failure // [core::slice::index::Range::get_unchecked_mut]: forward function -let core_slice_index_Range_get_unchecked_mut +let core_slice_index_RangeUsize_get_unchecked_mut (t : Type0) : core_ops_range_Range usize → mut_raw_ptr (slice t) → result (mut_raw_ptr (slice t)) = // Don't know what the model should be - for now we always fail to make @@ -515,17 +515,17 @@ let core_slice_index_Range_get_unchecked_mut fun _ _ -> Fail Failure // [core::slice::index::Range::index]: forward function -let core_slice_index_Range_index +let core_slice_index_RangeUsize_index (t : Type0) : core_ops_range_Range usize → slice t → result (slice t) = admit () // TODO // [core::slice::index::Range::index_mut]: forward function -let core_slice_index_Range_index_mut +let core_slice_index_RangeUsize_index_mut (t : Type0) : core_ops_range_Range usize → slice t → result (slice t) = admit () // TODO // [core::slice::index::Range::index_mut]: backward function 0 -let core_slice_index_Range_index_mut_back +let core_slice_index_RangeUsize_index_mut_back (t : Type0) : core_ops_range_Range usize → slice t → slice t → result (slice t) = admit () // TODO @@ -559,44 +559,44 @@ let core_array_Array_index_mut_back (a : array t n) (i : idx) (x : inst.indexInst.output) : result (array t n) = admit () // TODO -// Trait implementation: [core::slice::index::[T]] -let core_slice_index_Slice_coreopsindexIndexInst (t idx : Type0) - (inst : core_slice_index_SliceIndex idx (slice t)) : - core_ops_index_Index (slice t) idx = { - output = inst.output; - index = core_slice_index_Slice_index t idx inst; -} - // Trait implementation: [core::slice::index::private_slice_index::Range] -let core_slice_index_private_slice_index_Range_coresliceindexprivate_slice_indexSealedInst +let core_slice_index_private_slice_index_SealedRangeUsizeInst : core_slice_index_private_slice_index_Sealed (core_ops_range_Range usize) = () // Trait implementation: [core::slice::index::Range] -let core_slice_index_Range_coresliceindexSliceIndexInst (t : Type0) : +let core_slice_index_SliceIndexRangeUsizeSliceTInst (t : Type0) : core_slice_index_SliceIndex (core_ops_range_Range usize) (slice t) = { - sealedInst = core_slice_index_private_slice_index_Range_coresliceindexprivate_slice_indexSealedInst; + sealedInst = core_slice_index_private_slice_index_SealedRangeUsizeInst; output = slice t; - get = core_slice_index_Range_get t; - get_mut = core_slice_index_Range_get_mut t; - get_mut_back = core_slice_index_Range_get_mut_back t; - get_unchecked = core_slice_index_Range_get_unchecked t; - get_unchecked_mut = core_slice_index_Range_get_unchecked_mut t; - index = core_slice_index_Range_index t; - index_mut = core_slice_index_Range_index_mut t; - index_mut_back = core_slice_index_Range_index_mut_back t; + get = core_slice_index_RangeUsize_get t; + get_mut = core_slice_index_RangeUsize_get_mut t; + get_mut_back = core_slice_index_RangeUsize_get_mut_back t; + get_unchecked = core_slice_index_RangeUsize_get_unchecked t; + get_unchecked_mut = core_slice_index_RangeUsize_get_unchecked_mut t; + index = core_slice_index_RangeUsize_index t; + index_mut = core_slice_index_RangeUsize_index_mut t; + index_mut_back = core_slice_index_RangeUsize_index_mut_back t; +} + +// Trait implementation: [core::slice::index::[T]] +let core_ops_index_IndexSliceTIInst (t idx : Type0) + (inst : core_slice_index_SliceIndex idx (slice t)) : + core_ops_index_Index (slice t) idx = { + output = inst.output; + index = core_slice_index_Slice_index t idx inst; } // Trait implementation: [core::slice::index::[T]] -let core_slice_index_Slice_coreopsindexIndexMutInst (t idx : Type0) +let core_ops_index_IndexMutSliceTIInst (t idx : Type0) (inst : core_slice_index_SliceIndex idx (slice t)) : core_ops_index_IndexMut (slice t) idx = { - indexInst = core_slice_index_Slice_coreopsindexIndexInst t idx inst; + indexInst = core_ops_index_IndexSliceTIInst t idx inst; index_mut = core_slice_index_Slice_index_mut t idx inst; index_mut_back = core_slice_index_Slice_index_mut_back t idx inst; } // Trait implementation: [core::array::[T; N]] -let core_array_Array_coreopsindexIndexInst (t idx : Type0) (n : usize) +let core_ops_index_IndexArrayInst (t idx : Type0) (n : usize) (inst : core_ops_index_Index (slice t) idx) : core_ops_index_Index (array t n) idx = { output = inst.output; @@ -604,10 +604,10 @@ let core_array_Array_coreopsindexIndexInst (t idx : Type0) (n : usize) } // Trait implementation: [core::array::[T; N]] -let core_array_Array_coreopsindexIndexMutInst (t idx : Type0) (n : usize) +let core_ops_index_IndexMutArrayIInst (t idx : Type0) (n : usize) (inst : core_ops_index_IndexMut (slice t) idx) : core_ops_index_IndexMut (array t n) idx = { - indexInst = core_array_Array_coreopsindexIndexInst t idx n inst.indexInst; + indexInst = core_ops_index_IndexArrayInst t idx n inst.indexInst; index_mut = core_array_Array_index_mut t idx n inst; index_mut_back = core_array_Array_index_mut_back t idx n inst; } @@ -651,13 +651,13 @@ let core_slice_index_usize_index_mut_back admit () // TODO // Trait implementation: [core::slice::index::private_slice_index::usize] -let core_slice_index_private_slice_index_usize_coresliceindexprivate_slice_indexSealedInst +let core_slice_index_private_slice_index_SealedUsizeInst : core_slice_index_private_slice_index_Sealed usize = () // Trait implementation: [core::slice::index::usize] -let core_slice_index_usize_coresliceindexSliceIndexInst (t : Type0) : +let core_slice_index_SliceIndexUsizeSliceTInst (t : Type0) : core_slice_index_SliceIndex usize (slice t) = { - sealedInst = core_slice_index_private_slice_index_usize_coresliceindexprivate_slice_indexSealedInst; + sealedInst = core_slice_index_private_slice_index_SealedUsizeInst; output = t; get = core_slice_index_usize_get t; get_mut = core_slice_index_usize_get_mut t; @@ -706,24 +706,24 @@ let alloc_vec_Vec_coreopsindexIndexMutInst (t idx : Type0) let alloc_vec_Vec_index_eq (#a : Type0) (v : alloc_vec_Vec a) (i : usize) : Lemma ( - alloc_vec_Vec_index a usize (core_slice_index_usize_coresliceindexSliceIndexInst a) v i == + alloc_vec_Vec_index a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i == alloc_vec_Vec_index_usize v i) - [SMTPat (alloc_vec_Vec_index a usize (core_slice_index_usize_coresliceindexSliceIndexInst a) v i)] + [SMTPat (alloc_vec_Vec_index a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i)] = admit() let alloc_vec_Vec_index_mut_eq (#a : Type0) (v : alloc_vec_Vec a) (i : usize) : Lemma ( - alloc_vec_Vec_index_mut a usize (core_slice_index_usize_coresliceindexSliceIndexInst a) v i == + alloc_vec_Vec_index_mut a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i == alloc_vec_Vec_index_usize v i) - [SMTPat (alloc_vec_Vec_index_mut a usize (core_slice_index_usize_coresliceindexSliceIndexInst a) v i)] + [SMTPat (alloc_vec_Vec_index_mut a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i)] = admit() let alloc_vec_Vec_index_mut_back_eq (#a : Type0) (v : alloc_vec_Vec a) (i : usize) (x : a) : Lemma ( - alloc_vec_Vec_index_mut_back a usize (core_slice_index_usize_coresliceindexSliceIndexInst a) v i x == + alloc_vec_Vec_index_mut_back a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i x == alloc_vec_Vec_update_usize v i x) - [SMTPat (alloc_vec_Vec_index_mut_back a usize (core_slice_index_usize_coresliceindexSliceIndexInst a) v i x)] + [SMTPat (alloc_vec_Vec_index_mut_back a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i x)] = admit() -- cgit v1.2.3 From 137cc7335e64fcb70c254e7fd2a6fa353fb43e61 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 21 Nov 2023 14:57:38 +0100 Subject: Regenerate the files --- .../HashmapMain.Clauses.Template.fst | 27 +++-- tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst | 120 ++++++++++++++------- .../fstar/hashmap_on_disk/HashmapMain.Opaque.fsti | 6 +- tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti | 6 +- 4 files changed, 106 insertions(+), 53 deletions(-) (limited to 'tests/fstar/hashmap_on_disk') diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.Template.fst b/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.Template.fst index 106fa94b..7b274f59 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.Template.fst +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Clauses.Template.fst @@ -6,56 +6,65 @@ open HashmapMain.Types #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: decreases clause + Source: 'src/hashmap.rs', lines 50:4-56:5 *) unfold let hashmap_HashMap_allocate_slots_loop_decreases (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (n : usize) : nat = admit () -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::clear]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::clear]: decreases clause + Source: 'src/hashmap.rs', lines 80:4-88:5 *) unfold let hashmap_HashMap_clear_loop_decreases (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (i : usize) : nat = admit () -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: decreases clause + Source: 'src/hashmap.rs', lines 97:4-114:5 *) unfold let hashmap_HashMap_insert_in_list_loop_decreases (t : Type0) (key : usize) (value : t) (ls : hashmap_List_t t) : nat = admit () -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements_from_list]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements_from_list]: decreases clause + Source: 'src/hashmap.rs', lines 183:4-196:5 *) unfold let hashmap_HashMap_move_elements_from_list_loop_decreases (t : Type0) (ntable : hashmap_HashMap_t t) (ls : hashmap_List_t t) : nat = admit () -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements]: decreases clause + Source: 'src/hashmap.rs', lines 171:4-180:5 *) unfold let hashmap_HashMap_move_elements_loop_decreases (t : Type0) (ntable : hashmap_HashMap_t t) (slots : alloc_vec_Vec (hashmap_List_t t)) (i : usize) : nat = admit () -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: decreases clause + Source: 'src/hashmap.rs', lines 206:4-219:5 *) unfold let hashmap_HashMap_contains_key_in_list_loop_decreases (t : Type0) (key : usize) (ls : hashmap_List_t t) : nat = admit () -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: decreases clause + Source: 'src/hashmap.rs', lines 224:4-237:5 *) unfold let hashmap_HashMap_get_in_list_loop_decreases (t : Type0) (key : usize) (ls : hashmap_List_t t) : nat = admit () -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: decreases clause + Source: 'src/hashmap.rs', lines 245:4-254:5 *) unfold let hashmap_HashMap_get_mut_in_list_loop_decreases (t : Type0) (ls : hashmap_List_t t) (key : usize) : nat = admit () -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: decreases clause *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: decreases clause + Source: 'src/hashmap.rs', lines 265:4-291:5 *) unfold let hashmap_HashMap_remove_from_list_loop_decreases (t : Type0) (key : usize) (ls : hashmap_List_t t) : nat = diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst b/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst index 30bcfb2e..fa570309 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst @@ -8,11 +8,13 @@ include HashmapMain.Clauses #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" -(** [hashmap_main::hashmap::hash_key]: forward function *) +(** [hashmap_main::hashmap::hash_key]: forward function + Source: 'src/hashmap.rs', lines 27:0-27:32 *) let hashmap_hash_key (k : usize) : result usize = Return k -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: loop 0: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: loop 0: forward function + Source: 'src/hashmap.rs', lines 50:4-56:5 *) let rec hashmap_HashMap_allocate_slots_loop (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (n : usize) : Tot (result (alloc_vec_Vec (hashmap_List_t t))) @@ -26,14 +28,16 @@ let rec hashmap_HashMap_allocate_slots_loop hashmap_HashMap_allocate_slots_loop t slots0 n0 else Return slots -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: forward function + Source: 'src/hashmap.rs', lines 50:4-50:76 *) let hashmap_HashMap_allocate_slots (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (n : usize) : result (alloc_vec_Vec (hashmap_List_t t)) = hashmap_HashMap_allocate_slots_loop t slots n -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::new_with_capacity]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::new_with_capacity]: forward function + Source: 'src/hashmap.rs', lines 59:4-63:13 *) let hashmap_HashMap_new_with_capacity (t : Type0) (capacity : usize) (max_load_dividend : usize) (max_load_divisor : usize) : @@ -51,12 +55,14 @@ let hashmap_HashMap_new_with_capacity slots = slots } -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::new]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::new]: forward function + Source: 'src/hashmap.rs', lines 75:4-75:24 *) let hashmap_HashMap_new (t : Type0) : result (hashmap_HashMap_t t) = hashmap_HashMap_new_with_capacity t 32 4 5 (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::clear]: loop 0: merged forward/backward function - (there is a single backward function, and the forward function returns ()) *) + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 80:4-88:5 *) let rec hashmap_HashMap_clear_loop (t : Type0) (slots : alloc_vec_Vec (hashmap_List_t t)) (i : usize) : Tot (result (alloc_vec_Vec (hashmap_List_t t))) @@ -74,18 +80,21 @@ let rec hashmap_HashMap_clear_loop else Return slots (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::clear]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) *) + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 80:4-80:27 *) let hashmap_HashMap_clear (t : Type0) (self : hashmap_HashMap_t t) : result (hashmap_HashMap_t t) = let* v = hashmap_HashMap_clear_loop t self.slots 0 in Return { self with num_entries = 0; slots = v } -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::len]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::len]: forward function + Source: 'src/hashmap.rs', lines 90:4-90:30 *) let hashmap_HashMap_len (t : Type0) (self : hashmap_HashMap_t t) : result usize = Return self.num_entries -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: loop 0: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: loop 0: forward function + Source: 'src/hashmap.rs', lines 97:4-114:5 *) let rec hashmap_HashMap_insert_in_list_loop (t : Type0) (key : usize) (value : t) (ls : hashmap_List_t t) : Tot (result bool) @@ -99,12 +108,14 @@ let rec hashmap_HashMap_insert_in_list_loop | Hashmap_List_Nil -> Return true end -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: forward function + Source: 'src/hashmap.rs', lines 97:4-97:71 *) let hashmap_HashMap_insert_in_list (t : Type0) (key : usize) (value : t) (ls : hashmap_List_t t) : result bool = hashmap_HashMap_insert_in_list_loop t key value ls -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: loop 0: backward function 0 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: loop 0: backward function 0 + Source: 'src/hashmap.rs', lines 97:4-114:5 *) let rec hashmap_HashMap_insert_in_list_loop_back (t : Type0) (key : usize) (value : t) (ls : hashmap_List_t t) : Tot (result (hashmap_List_t t)) @@ -121,7 +132,8 @@ let rec hashmap_HashMap_insert_in_list_loop_back let l = Hashmap_List_Nil in Return (Hashmap_List_Cons key value l) end -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: backward function 0 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: backward function 0 + Source: 'src/hashmap.rs', lines 97:4-97:71 *) let hashmap_HashMap_insert_in_list_back (t : Type0) (key : usize) (value : t) (ls : hashmap_List_t t) : result (hashmap_List_t t) @@ -129,7 +141,8 @@ let hashmap_HashMap_insert_in_list_back hashmap_HashMap_insert_in_list_loop_back t key value ls (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_no_resize]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) *) + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 117:4-117:54 *) let hashmap_HashMap_insert_no_resize (t : Type0) (self : hashmap_HashMap_t t) (key : usize) (value : t) : result (hashmap_HashMap_t t) @@ -160,7 +173,8 @@ let hashmap_HashMap_insert_no_resize Return { self with slots = v } (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements_from_list]: loop 0: merged forward/backward function - (there is a single backward function, and the forward function returns ()) *) + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 183:4-196:5 *) let rec hashmap_HashMap_move_elements_from_list_loop (t : Type0) (ntable : hashmap_HashMap_t t) (ls : hashmap_List_t t) : Tot (result (hashmap_HashMap_t t)) @@ -175,7 +189,8 @@ let rec hashmap_HashMap_move_elements_from_list_loop end (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements_from_list]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) *) + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 183:4-183:72 *) let hashmap_HashMap_move_elements_from_list (t : Type0) (ntable : hashmap_HashMap_t t) (ls : hashmap_List_t t) : result (hashmap_HashMap_t t) @@ -183,7 +198,8 @@ let hashmap_HashMap_move_elements_from_list hashmap_HashMap_move_elements_from_list_loop t ntable ls (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements]: loop 0: merged forward/backward function - (there is a single backward function, and the forward function returns ()) *) + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 171:4-180:5 *) let rec hashmap_HashMap_move_elements_loop (t : Type0) (ntable : hashmap_HashMap_t t) (slots : alloc_vec_Vec (hashmap_List_t t)) (i : usize) : @@ -209,7 +225,8 @@ let rec hashmap_HashMap_move_elements_loop else Return (ntable, slots) (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) *) + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 171:4-171:95 *) let hashmap_HashMap_move_elements (t : Type0) (ntable : hashmap_HashMap_t t) (slots : alloc_vec_Vec (hashmap_List_t t)) (i : usize) : @@ -218,7 +235,8 @@ let hashmap_HashMap_move_elements hashmap_HashMap_move_elements_loop t ntable slots i (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::try_resize]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) *) + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 140:4-140:28 *) let hashmap_HashMap_try_resize (t : Type0) (self : hashmap_HashMap_t t) : result (hashmap_HashMap_t t) = let* max_usize = scalar_cast U32 Usize core_u32_max in @@ -237,7 +255,8 @@ let hashmap_HashMap_try_resize else Return { self with max_load_factor = (i, i0) } (** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) *) + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 129:4-129:48 *) let hashmap_HashMap_insert (t : Type0) (self : hashmap_HashMap_t t) (key : usize) (value : t) : result (hashmap_HashMap_t t) @@ -248,7 +267,8 @@ let hashmap_HashMap_insert then hashmap_HashMap_try_resize t self0 else Return self0 -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: loop 0: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: loop 0: forward function + Source: 'src/hashmap.rs', lines 206:4-219:5 *) let rec hashmap_HashMap_contains_key_in_list_loop (t : Type0) (key : usize) (ls : hashmap_List_t t) : Tot (result bool) @@ -262,12 +282,14 @@ let rec hashmap_HashMap_contains_key_in_list_loop | Hashmap_List_Nil -> Return false end -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: forward function + Source: 'src/hashmap.rs', lines 206:4-206:68 *) let hashmap_HashMap_contains_key_in_list (t : Type0) (key : usize) (ls : hashmap_List_t t) : result bool = hashmap_HashMap_contains_key_in_list_loop t key ls -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key]: forward function + Source: 'src/hashmap.rs', lines 199:4-199:49 *) let hashmap_HashMap_contains_key (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : result bool = let* hash = hashmap_hash_key key in @@ -279,7 +301,8 @@ let hashmap_HashMap_contains_key self.slots hash_mod in hashmap_HashMap_contains_key_in_list t key l -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: loop 0: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: loop 0: forward function + Source: 'src/hashmap.rs', lines 224:4-237:5 *) let rec hashmap_HashMap_get_in_list_loop (t : Type0) (key : usize) (ls : hashmap_List_t t) : Tot (result t) @@ -293,12 +316,14 @@ let rec hashmap_HashMap_get_in_list_loop | Hashmap_List_Nil -> Fail Failure end -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: forward function + Source: 'src/hashmap.rs', lines 224:4-224:70 *) let hashmap_HashMap_get_in_list (t : Type0) (key : usize) (ls : hashmap_List_t t) : result t = hashmap_HashMap_get_in_list_loop t key ls -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get]: forward function + Source: 'src/hashmap.rs', lines 239:4-239:55 *) let hashmap_HashMap_get (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : result t = let* hash = hashmap_hash_key key in @@ -310,7 +335,8 @@ let hashmap_HashMap_get self.slots hash_mod in hashmap_HashMap_get_in_list t key l -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: loop 0: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: loop 0: forward function + Source: 'src/hashmap.rs', lines 245:4-254:5 *) let rec hashmap_HashMap_get_mut_in_list_loop (t : Type0) (ls : hashmap_List_t t) (key : usize) : Tot (result t) @@ -324,12 +350,14 @@ let rec hashmap_HashMap_get_mut_in_list_loop | Hashmap_List_Nil -> Fail Failure end -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: forward function + Source: 'src/hashmap.rs', lines 245:4-245:86 *) let hashmap_HashMap_get_mut_in_list (t : Type0) (ls : hashmap_List_t t) (key : usize) : result t = hashmap_HashMap_get_mut_in_list_loop t ls key -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: loop 0: backward function 0 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: loop 0: backward function 0 + Source: 'src/hashmap.rs', lines 245:4-254:5 *) let rec hashmap_HashMap_get_mut_in_list_loop_back (t : Type0) (ls : hashmap_List_t t) (key : usize) (ret : t) : Tot (result (hashmap_List_t t)) @@ -345,14 +373,16 @@ let rec hashmap_HashMap_get_mut_in_list_loop_back | Hashmap_List_Nil -> Fail Failure end -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: backward function 0 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: backward function 0 + Source: 'src/hashmap.rs', lines 245:4-245:86 *) let hashmap_HashMap_get_mut_in_list_back (t : Type0) (ls : hashmap_List_t t) (key : usize) (ret : t) : result (hashmap_List_t t) = hashmap_HashMap_get_mut_in_list_loop_back t ls key ret -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut]: forward function + Source: 'src/hashmap.rs', lines 257:4-257:67 *) let hashmap_HashMap_get_mut (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : result t = let* hash = hashmap_hash_key key in @@ -364,7 +394,8 @@ let hashmap_HashMap_get_mut self.slots hash_mod in hashmap_HashMap_get_mut_in_list t l key -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut]: backward function 0 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut]: backward function 0 + Source: 'src/hashmap.rs', lines 257:4-257:67 *) let hashmap_HashMap_get_mut_back (t : Type0) (self : hashmap_HashMap_t t) (key : usize) (ret : t) : result (hashmap_HashMap_t t) @@ -383,7 +414,8 @@ let hashmap_HashMap_get_mut_back self.slots hash_mod l0 in Return { self with slots = v } -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: loop 0: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: loop 0: forward function + Source: 'src/hashmap.rs', lines 265:4-291:5 *) let rec hashmap_HashMap_remove_from_list_loop (t : Type0) (key : usize) (ls : hashmap_List_t t) : Tot (result (option t)) @@ -404,12 +436,14 @@ let rec hashmap_HashMap_remove_from_list_loop | Hashmap_List_Nil -> Return None end -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: forward function + Source: 'src/hashmap.rs', lines 265:4-265:69 *) let hashmap_HashMap_remove_from_list (t : Type0) (key : usize) (ls : hashmap_List_t t) : result (option t) = hashmap_HashMap_remove_from_list_loop t key ls -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: loop 0: backward function 1 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: loop 0: backward function 1 + Source: 'src/hashmap.rs', lines 265:4-291:5 *) let rec hashmap_HashMap_remove_from_list_loop_back (t : Type0) (key : usize) (ls : hashmap_List_t t) : Tot (result (hashmap_List_t t)) @@ -432,14 +466,16 @@ let rec hashmap_HashMap_remove_from_list_loop_back | Hashmap_List_Nil -> Return Hashmap_List_Nil end -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: backward function 1 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: backward function 1 + Source: 'src/hashmap.rs', lines 265:4-265:69 *) let hashmap_HashMap_remove_from_list_back (t : Type0) (key : usize) (ls : hashmap_List_t t) : result (hashmap_List_t t) = hashmap_HashMap_remove_from_list_loop_back t key ls -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove]: forward function *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove]: forward function + Source: 'src/hashmap.rs', lines 294:4-294:52 *) let hashmap_HashMap_remove (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : result (option t) = let* hash = hashmap_hash_key key in @@ -455,7 +491,8 @@ let hashmap_HashMap_remove | Some x0 -> let* _ = usize_sub self.num_entries 1 in Return (Some x0) end -(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove]: backward function 0 *) +(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove]: backward function 0 + Source: 'src/hashmap.rs', lines 294:4-294:52 *) let hashmap_HashMap_remove_back (t : Type0) (self : hashmap_HashMap_t t) (key : usize) : result (hashmap_HashMap_t t) @@ -486,7 +523,8 @@ let hashmap_HashMap_remove_back Return { self with num_entries = i0; slots = v } end -(** [hashmap_main::hashmap::test1]: forward function *) +(** [hashmap_main::hashmap::test1]: forward function + Source: 'src/hashmap.rs', lines 315:0-315:10 *) let hashmap_test1 : result unit = let* hm = hashmap_HashMap_new u64 in let* hm0 = hashmap_HashMap_insert u64 hm 0 42 in @@ -522,7 +560,8 @@ let hashmap_test1 : result unit = if not (i3 = 256) then Fail Failure else Return () end -(** [hashmap_main::insert_on_disk]: forward function *) +(** [hashmap_main::insert_on_disk]: forward function + Source: 'src/hashmap_main.rs', lines 7:0-7:43 *) let insert_on_disk (key : usize) (value : u64) (st : state) : result (state & unit) = let* (st0, hm) = hashmap_utils_deserialize st in @@ -530,7 +569,8 @@ let insert_on_disk let* (st1, _) = hashmap_utils_serialize hm0 st0 in Return (st1, ()) -(** [hashmap_main::main]: forward function *) +(** [hashmap_main::main]: forward function + Source: 'src/hashmap_main.rs', lines 16:0-16:13 *) let main : result unit = Return () diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Opaque.fsti b/tests/fstar/hashmap_on_disk/HashmapMain.Opaque.fsti index d6cecf36..1f47eb33 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Opaque.fsti +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Opaque.fsti @@ -6,11 +6,13 @@ include HashmapMain.Types #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" -(** [hashmap_main::hashmap_utils::deserialize]: forward function *) +(** [hashmap_main::hashmap_utils::deserialize]: forward function + Source: 'src/hashmap_utils.rs', lines 10:0-10:43 *) val hashmap_utils_deserialize : state -> result (state & (hashmap_HashMap_t u64)) -(** [hashmap_main::hashmap_utils::serialize]: forward function *) +(** [hashmap_main::hashmap_utils::serialize]: forward function + Source: 'src/hashmap_utils.rs', lines 5:0-5:42 *) val hashmap_utils_serialize : hashmap_HashMap_t u64 -> state -> result (state & unit) diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti b/tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti index 24b78c2a..e77954ad 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti @@ -5,12 +5,14 @@ open Primitives #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" -(** [hashmap_main::hashmap::List] *) +(** [hashmap_main::hashmap::List] + Source: 'src/hashmap.rs', lines 19:0-19:16 *) type hashmap_List_t (t : Type0) = | Hashmap_List_Cons : usize -> t -> hashmap_List_t t -> hashmap_List_t t | Hashmap_List_Nil : hashmap_List_t t -(** [hashmap_main::hashmap::HashMap] *) +(** [hashmap_main::hashmap::HashMap] + Source: 'src/hashmap.rs', lines 35:0-35:21 *) type hashmap_HashMap_t (t : Type0) = { num_entries : usize; -- cgit v1.2.3 From 959d6fce38c8d8ca6eaed3ad6f458b87f91a9abc Mon Sep 17 00:00:00 2001 From: Son Ho Date: Mon, 27 Nov 2023 09:37:31 +0100 Subject: Update the generation of files for external definitions and regenerate the tests --- tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst | 2 +- .../hashmap_on_disk/HashmapMain.FunsExternal.fsti | 18 ++++++++++++++++++ tests/fstar/hashmap_on_disk/HashmapMain.Opaque.fsti | 18 ------------------ 3 files changed, 19 insertions(+), 19 deletions(-) create mode 100644 tests/fstar/hashmap_on_disk/HashmapMain.FunsExternal.fsti delete mode 100644 tests/fstar/hashmap_on_disk/HashmapMain.Opaque.fsti (limited to 'tests/fstar/hashmap_on_disk') diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst b/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst index fa570309..f2d09a38 100644 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Funs.fst @@ -3,7 +3,7 @@ module HashmapMain.Funs open Primitives include HashmapMain.Types -include HashmapMain.Opaque +include HashmapMain.FunsExternal include HashmapMain.Clauses #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.FunsExternal.fsti b/tests/fstar/hashmap_on_disk/HashmapMain.FunsExternal.fsti new file mode 100644 index 00000000..b00bbcde --- /dev/null +++ b/tests/fstar/hashmap_on_disk/HashmapMain.FunsExternal.fsti @@ -0,0 +1,18 @@ +(** THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS *) +(** [hashmap_main]: external function declarations *) +module HashmapMain.FunsExternal +open Primitives +include HashmapMain.Types + +#set-options "--z3rlimit 50 --fuel 1 --ifuel 1" + +(** [hashmap_main::hashmap_utils::deserialize]: forward function + Source: 'src/hashmap_utils.rs', lines 10:0-10:43 *) +val hashmap_utils_deserialize + : state -> result (state & (hashmap_HashMap_t u64)) + +(** [hashmap_main::hashmap_utils::serialize]: forward function + Source: 'src/hashmap_utils.rs', lines 5:0-5:42 *) +val hashmap_utils_serialize + : hashmap_HashMap_t u64 -> state -> result (state & unit) + diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Opaque.fsti b/tests/fstar/hashmap_on_disk/HashmapMain.Opaque.fsti deleted file mode 100644 index 1f47eb33..00000000 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Opaque.fsti +++ /dev/null @@ -1,18 +0,0 @@ -(** THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS *) -(** [hashmap_main]: external function declarations *) -module HashmapMain.Opaque -open Primitives -include HashmapMain.Types - -#set-options "--z3rlimit 50 --fuel 1 --ifuel 1" - -(** [hashmap_main::hashmap_utils::deserialize]: forward function - Source: 'src/hashmap_utils.rs', lines 10:0-10:43 *) -val hashmap_utils_deserialize - : state -> result (state & (hashmap_HashMap_t u64)) - -(** [hashmap_main::hashmap_utils::serialize]: forward function - Source: 'src/hashmap_utils.rs', lines 5:0-5:42 *) -val hashmap_utils_serialize - : hashmap_HashMap_t u64 -> state -> result (state & unit) - -- cgit v1.2.3 From bef2bd34fcb0817f1b7d16b95122bcc3c6f05c72 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Mon, 27 Nov 2023 10:29:25 +0100 Subject: Generate a dedicated file for the external types --- tests/fstar/hashmap_on_disk/HashmapMain.Types.fst | 24 ++++++++++++++++++++ tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti | 26 ---------------------- .../hashmap_on_disk/HashmapMain.TypesExternal.fsti | 10 +++++++++ 3 files changed, 34 insertions(+), 26 deletions(-) create mode 100644 tests/fstar/hashmap_on_disk/HashmapMain.Types.fst delete mode 100644 tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti create mode 100644 tests/fstar/hashmap_on_disk/HashmapMain.TypesExternal.fsti (limited to 'tests/fstar/hashmap_on_disk') diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Types.fst b/tests/fstar/hashmap_on_disk/HashmapMain.Types.fst new file mode 100644 index 00000000..afebcde3 --- /dev/null +++ b/tests/fstar/hashmap_on_disk/HashmapMain.Types.fst @@ -0,0 +1,24 @@ +(** THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS *) +(** [hashmap_main]: type definitions *) +module HashmapMain.Types +open Primitives +include HashmapMain.TypesExternal + +#set-options "--z3rlimit 50 --fuel 1 --ifuel 1" + +(** [hashmap_main::hashmap::List] + Source: 'src/hashmap.rs', lines 19:0-19:16 *) +type hashmap_List_t (t : Type0) = +| Hashmap_List_Cons : usize -> t -> hashmap_List_t t -> hashmap_List_t t +| Hashmap_List_Nil : hashmap_List_t t + +(** [hashmap_main::hashmap::HashMap] + Source: 'src/hashmap.rs', lines 35:0-35:21 *) +type hashmap_HashMap_t (t : Type0) = +{ + num_entries : usize; + max_load_factor : (usize & usize); + max_load : usize; + slots : alloc_vec_Vec (hashmap_List_t t); +} + diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti b/tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti deleted file mode 100644 index e77954ad..00000000 --- a/tests/fstar/hashmap_on_disk/HashmapMain.Types.fsti +++ /dev/null @@ -1,26 +0,0 @@ -(** THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS *) -(** [hashmap_main]: type definitions *) -module HashmapMain.Types -open Primitives - -#set-options "--z3rlimit 50 --fuel 1 --ifuel 1" - -(** [hashmap_main::hashmap::List] - Source: 'src/hashmap.rs', lines 19:0-19:16 *) -type hashmap_List_t (t : Type0) = -| Hashmap_List_Cons : usize -> t -> hashmap_List_t t -> hashmap_List_t t -| Hashmap_List_Nil : hashmap_List_t t - -(** [hashmap_main::hashmap::HashMap] - Source: 'src/hashmap.rs', lines 35:0-35:21 *) -type hashmap_HashMap_t (t : Type0) = -{ - num_entries : usize; - max_load_factor : (usize & usize); - max_load : usize; - slots : alloc_vec_Vec (hashmap_List_t t); -} - -(** The state type used in the state-error monad *) -val state : Type0 - diff --git a/tests/fstar/hashmap_on_disk/HashmapMain.TypesExternal.fsti b/tests/fstar/hashmap_on_disk/HashmapMain.TypesExternal.fsti new file mode 100644 index 00000000..75747408 --- /dev/null +++ b/tests/fstar/hashmap_on_disk/HashmapMain.TypesExternal.fsti @@ -0,0 +1,10 @@ +(** THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS *) +(** [hashmap_main]: external type declarations *) +module HashmapMain.TypesExternal +open Primitives + +#set-options "--z3rlimit 50 --fuel 1 --ifuel 1" + +(** The state type used in the state-error monad *) +val state : Type0 + -- cgit v1.2.3