From a9c256fe95523842a1ff025e73f6e9ce7c2db38a Mon Sep 17 00:00:00 2001 From: Son Ho Date: Fri, 18 Aug 2023 10:44:01 +0200 Subject: Add tests which use const generics as values --- tests/fstar/array/Array.Funs.fst | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/fstar/array') diff --git a/tests/fstar/array/Array.Funs.fst b/tests/fstar/array/Array.Funs.fst index 7c1d0b09..72163585 100644 --- a/tests/fstar/array/Array.Funs.fst +++ b/tests/fstar/array/Array.Funs.fst @@ -139,6 +139,10 @@ let index_index_array_fwd let* a = array_index_shared (array u32 32) 32 s i in array_index_shared u32 32 a j +(** [array::const_gen_ret]: forward function *) +let const_gen_ret_fwd (n : usize) : result usize = + Return n + (** [array::update_update_array]: forward function *) let update_update_array_fwd (s : array (array u32 32) 32) (i : usize) (j : usize) : result unit = -- cgit v1.2.3 From 8543092569616ef6a75949a72532f7b73dc696f2 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Fri, 18 Aug 2023 12:23:03 +0200 Subject: Regenerate the array tests --- tests/fstar/array/Array.Funs.fst | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/fstar/array') diff --git a/tests/fstar/array/Array.Funs.fst b/tests/fstar/array/Array.Funs.fst index 72163585..83256398 100644 --- a/tests/fstar/array/Array.Funs.fst +++ b/tests/fstar/array/Array.Funs.fst @@ -347,6 +347,14 @@ let f3_fwd : result u32 = ]) 16 18 in sum2_fwd s s0 +(** [array::SZ] *) +let sz_body : result usize = Return 32 +let sz_c : usize = eval_global sz_body + +(** [array::f5]: forward function *) +let f5_fwd (x : array u32 32) : result u32 = + array_index_shared u32 32 x 0 + (** [array::ite]: forward function *) let ite_fwd : result unit = let* s = array_to_slice_mut_fwd u32 2 (mk_array u32 2 [ 0; 0 ]) in -- cgit v1.2.3 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/array/Primitives.fst | 47 +++++++++++++++++++++++++++++++--------- 1 file changed, 37 insertions(+), 10 deletions(-) (limited to 'tests/fstar/array') diff --git a/tests/fstar/array/Primitives.fst b/tests/fstar/array/Primitives.fst index 9db82069..cd18cf29 100644 --- a/tests/fstar/array/Primitives.fst +++ b/tests/fstar/array/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/array/Primitives.fst | 384 ++++++++++++++++++++++++++++++++++----- 1 file changed, 339 insertions(+), 45 deletions(-) (limited to 'tests/fstar/array') diff --git a/tests/fstar/array/Primitives.fst b/tests/fstar/array/Primitives.fst index cd18cf29..5e154122 100644 --- a/tests/fstar/array/Primitives.fst +++ b/tests/fstar/array/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 1110b3da85e93ba0755a665edd5b8c986c54cef0 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 26 Oct 2023 16:15:35 +0200 Subject: Make minor modifications and update the array test for F* --- tests/fstar/array/Array.Clauses.Template.fst | 5 +- tests/fstar/array/Array.Funs.fst | 348 ++++++++++++++------------- tests/fstar/array/Array.Types.fst | 4 +- 3 files changed, 183 insertions(+), 174 deletions(-) (limited to 'tests/fstar/array') diff --git a/tests/fstar/array/Array.Clauses.Template.fst b/tests/fstar/array/Array.Clauses.Template.fst index 8a15e230..06056d61 100644 --- a/tests/fstar/array/Array.Clauses.Template.fst +++ b/tests/fstar/array/Array.Clauses.Template.fst @@ -8,11 +8,12 @@ open Array.Types (** [array::sum]: decreases clause *) unfold -let sum_loop_decreases (s : slice u32) (sum : u32) (i : usize) : nat = admit () +let sum_loop_decreases (s : slice u32) (sum0 : u32) (i : usize) : nat = + admit () (** [array::sum2]: decreases clause *) unfold -let sum2_loop_decreases (s : slice u32) (s2 : slice u32) (sum : u32) +let sum2_loop_decreases (s : slice u32) (s2 : slice u32) (sum0 : u32) (i : usize) : nat = admit () diff --git a/tests/fstar/array/Array.Funs.fst b/tests/fstar/array/Array.Funs.fst index 83256398..a6808c98 100644 --- a/tests/fstar/array/Array.Funs.fst +++ b/tests/fstar/array/Array.Funs.fst @@ -7,361 +7,369 @@ include Array.Clauses #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" +(** [array::incr]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) *) +let incr (x : u32) : result u32 = + u32_add x 1 + (** [array::array_to_shared_slice_]: forward function *) -let array_to_shared_slice__fwd - (t : Type0) (s : array t 32) : result (slice t) = - array_to_slice_shared t 32 s +let array_to_shared_slice_ (t : Type0) (s : array t 32) : result (slice t) = + array_to_slice t 32 s (** [array::array_to_mut_slice_]: forward function *) -let array_to_mut_slice__fwd (t : Type0) (s : array t 32) : result (slice t) = - array_to_slice_mut_fwd t 32 s +let array_to_mut_slice_ (t : Type0) (s : array t 32) : result (slice t) = + array_to_slice t 32 s (** [array::array_to_mut_slice_]: backward function 0 *) let array_to_mut_slice__back (t : Type0) (s : array t 32) (ret : slice t) : result (array t 32) = - array_to_slice_mut_back t 32 s ret + array_from_slice t 32 s ret (** [array::array_len]: forward function *) -let array_len_fwd (t : Type0) (s : array t 32) : result usize = - let* s0 = array_to_slice_shared t 32 s in let i = slice_len t s0 in Return i +let array_len (t : Type0) (s : array t 32) : result usize = + let* s0 = array_to_slice t 32 s in let i = slice_len t s0 in Return i (** [array::shared_array_len]: forward function *) -let shared_array_len_fwd (t : Type0) (s : array t 32) : result usize = - let* s0 = array_to_slice_shared t 32 s in let i = slice_len t s0 in Return i +let shared_array_len (t : Type0) (s : array t 32) : result usize = + let* s0 = array_to_slice t 32 s in let i = slice_len t s0 in Return i (** [array::shared_slice_len]: forward function *) -let shared_slice_len_fwd (t : Type0) (s : slice t) : result usize = +let shared_slice_len (t : Type0) (s : slice t) : result usize = let i = slice_len t s in Return i (** [array::index_array_shared]: forward function *) -let index_array_shared_fwd - (t : Type0) (s : array t 32) (i : usize) : result t = - array_index_shared t 32 s i +let index_array_shared (t : Type0) (s : array t 32) (i : usize) : result t = + array_index_usize t 32 s i (** [array::index_array_u32]: forward function *) -let index_array_u32_fwd (s : array u32 32) (i : usize) : result u32 = - array_index_shared u32 32 s i - -(** [array::index_array_generic]: forward function *) -let index_array_generic_fwd - (n : usize) (s : array u32 n) (i : usize) : result u32 = - array_index_shared u32 n s i - -(** [array::index_array_generic_call]: forward function *) -let index_array_generic_call_fwd - (n : usize) (s : array u32 n) (i : usize) : result u32 = - index_array_generic_fwd n s i +let index_array_u32 (s : array u32 32) (i : usize) : result u32 = + array_index_usize u32 32 s i (** [array::index_array_copy]: forward function *) -let index_array_copy_fwd (x : array u32 32) : result u32 = - array_index_shared u32 32 x 0 +let index_array_copy (x : array u32 32) : result u32 = + array_index_usize u32 32 x 0 (** [array::index_mut_array]: forward function *) -let index_mut_array_fwd (t : Type0) (s : array t 32) (i : usize) : result t = - array_index_mut_fwd t 32 s i +let index_mut_array (t : Type0) (s : array t 32) (i : usize) : result t = + array_index_usize t 32 s i (** [array::index_mut_array]: backward function 0 *) let index_mut_array_back (t : Type0) (s : array t 32) (i : usize) (ret : t) : result (array t 32) = - array_index_mut_back t 32 s i ret + array_update_usize t 32 s i ret (** [array::index_slice]: forward function *) -let index_slice_fwd (t : Type0) (s : slice t) (i : usize) : result t = - slice_index_shared t s i +let index_slice (t : Type0) (s : slice t) (i : usize) : result t = + slice_index_usize t s i (** [array::index_mut_slice]: forward function *) -let index_mut_slice_fwd (t : Type0) (s : slice t) (i : usize) : result t = - slice_index_mut_fwd t s i +let index_mut_slice (t : Type0) (s : slice t) (i : usize) : result t = + slice_index_usize t s i (** [array::index_mut_slice]: backward function 0 *) let index_mut_slice_back (t : Type0) (s : slice t) (i : usize) (ret : t) : result (slice t) = - slice_index_mut_back t s i ret + slice_update_usize t s i ret (** [array::slice_subslice_shared_]: forward function *) -let slice_subslice_shared__fwd +let slice_subslice_shared_ (x : slice u32) (y : usize) (z : usize) : result (slice u32) = - slice_subslice_shared u32 x (Mkrange y z) + core_slice_index_Slice_index u32 (core_ops_range_Range usize) + (core_slice_index_Range_coresliceindexSliceIndexInst u32) x + { start = y; end_ = z } (** [array::slice_subslice_mut_]: forward function *) -let slice_subslice_mut__fwd +let slice_subslice_mut_ (x : slice u32) (y : usize) (z : usize) : result (slice u32) = - slice_subslice_mut_fwd u32 x (Mkrange y z) + core_slice_index_Slice_index_mut u32 (core_ops_range_Range usize) + (core_slice_index_Range_coresliceindexSliceIndexInst u32) x + { start = y; end_ = z } (** [array::slice_subslice_mut_]: backward function 0 *) let slice_subslice_mut__back (x : slice u32) (y : usize) (z : usize) (ret : slice u32) : result (slice u32) = - slice_subslice_mut_back u32 x (Mkrange y z) ret + core_slice_index_Slice_index_mut_back u32 (core_ops_range_Range usize) + (core_slice_index_Range_coresliceindexSliceIndexInst u32) x + { start = y; end_ = z } ret (** [array::array_to_slice_shared_]: forward function *) -let array_to_slice_shared__fwd (x : array u32 32) : result (slice u32) = - array_to_slice_shared u32 32 x +let array_to_slice_shared_ (x : array u32 32) : result (slice u32) = + array_to_slice u32 32 x (** [array::array_to_slice_mut_]: forward function *) -let array_to_slice_mut__fwd (x : array u32 32) : result (slice u32) = - array_to_slice_mut_fwd u32 32 x +let array_to_slice_mut_ (x : array u32 32) : result (slice u32) = + array_to_slice u32 32 x (** [array::array_to_slice_mut_]: backward function 0 *) let array_to_slice_mut__back (x : array u32 32) (ret : slice u32) : result (array u32 32) = - array_to_slice_mut_back u32 32 x ret + array_from_slice u32 32 x ret (** [array::array_subslice_shared_]: forward function *) -let array_subslice_shared__fwd +let array_subslice_shared_ (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = - array_subslice_shared u32 32 x (Mkrange y z) + core_array_Array_index u32 (core_ops_range_Range usize) 32 + (core_slice_index_Slice_coreopsindexIndexInst u32 (core_ops_range_Range + usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x + { start = y; end_ = z } (** [array::array_subslice_mut_]: forward function *) -let array_subslice_mut__fwd +let array_subslice_mut_ (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = - array_subslice_mut_fwd u32 32 x (Mkrange y z) + core_array_Array_index_mut u32 (core_ops_range_Range usize) 32 + (core_slice_index_Slice_coreopsindexIndexMutInst u32 (core_ops_range_Range + usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x + { start = y; end_ = z } (** [array::array_subslice_mut_]: backward function 0 *) let array_subslice_mut__back (x : array u32 32) (y : usize) (z : usize) (ret : slice u32) : result (array u32 32) = - array_subslice_mut_back u32 32 x (Mkrange y z) ret + core_array_Array_index_mut_back u32 (core_ops_range_Range usize) 32 + (core_slice_index_Slice_coreopsindexIndexMutInst u32 (core_ops_range_Range + usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x + { start = y; end_ = z } ret (** [array::index_slice_0]: forward function *) -let index_slice_0_fwd (t : Type0) (s : slice t) : result t = - slice_index_shared t s 0 +let index_slice_0 (t : Type0) (s : slice t) : result t = + slice_index_usize t s 0 (** [array::index_array_0]: forward function *) -let index_array_0_fwd (t : Type0) (s : array t 32) : result t = - array_index_shared t 32 s 0 +let index_array_0 (t : Type0) (s : array t 32) : result t = + array_index_usize t 32 s 0 (** [array::index_index_array]: forward function *) -let index_index_array_fwd +let index_index_array (s : array (array u32 32) 32) (i : usize) (j : usize) : result u32 = - let* a = array_index_shared (array u32 32) 32 s i in - array_index_shared u32 32 a j - -(** [array::const_gen_ret]: forward function *) -let const_gen_ret_fwd (n : usize) : result usize = - Return n + let* a = array_index_usize (array u32 32) 32 s i in + array_index_usize u32 32 a j (** [array::update_update_array]: forward function *) -let update_update_array_fwd +let update_update_array (s : array (array u32 32) 32) (i : usize) (j : usize) : result unit = - let* a = array_index_mut_fwd (array u32 32) 32 s i in - let* a0 = array_index_mut_back u32 32 a j 0 in - let* _ = array_index_mut_back (array u32 32) 32 s i a0 in + let* a = array_index_usize (array u32 32) 32 s i in + let* a0 = array_update_usize u32 32 a j 0 in + let* _ = array_update_usize (array u32 32) 32 s i a0 in Return () (** [array::array_local_deep_copy]: forward function *) -let array_local_deep_copy_fwd (x : array u32 32) : result unit = +let array_local_deep_copy (x : array u32 32) : result unit = Return () (** [array::take_array]: forward function *) -let take_array_fwd (a : array u32 2) : result unit = +let take_array (a : array u32 2) : result unit = Return () (** [array::take_array_borrow]: forward function *) -let take_array_borrow_fwd (a : array u32 2) : result unit = +let take_array_borrow (a : array u32 2) : result unit = Return () (** [array::take_slice]: forward function *) -let take_slice_fwd (s : slice u32) : result unit = +let take_slice (s : slice u32) : result unit = Return () (** [array::take_mut_slice]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) -let take_mut_slice_fwd_back (s : slice u32) : result (slice u32) = +let take_mut_slice (s : slice u32) : result (slice u32) = Return s (** [array::take_all]: forward function *) -let take_all_fwd : result unit = - let* _ = take_array_fwd (mk_array u32 2 [ 0; 0 ]) in - let* _ = take_array_borrow_fwd (mk_array u32 2 [ 0; 0 ]) in - let* s = array_to_slice_shared u32 2 (mk_array u32 2 [ 0; 0 ]) in - let* _ = take_slice_fwd s in - let* s0 = array_to_slice_mut_fwd u32 2 (mk_array u32 2 [ 0; 0 ]) in - let* s1 = take_mut_slice_fwd_back s0 in - let* _ = array_to_slice_mut_back u32 2 (mk_array u32 2 [ 0; 0 ]) s1 in +let take_all : result unit = + let* _ = take_array (mk_array u32 2 [ 0; 0 ]) in + let* _ = take_array_borrow (mk_array u32 2 [ 0; 0 ]) in + let* s = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in + let* _ = take_slice s in + let* s0 = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in + let* s1 = take_mut_slice s0 in + let* _ = array_from_slice u32 2 (mk_array u32 2 [ 0; 0 ]) s1 in Return () (** [array::index_array]: forward function *) -let index_array_fwd (x : array u32 2) : result u32 = - array_index_shared u32 2 x 0 +let index_array (x : array u32 2) : result u32 = + array_index_usize u32 2 x 0 (** [array::index_array_borrow]: forward function *) -let index_array_borrow_fwd (x : array u32 2) : result u32 = - array_index_shared u32 2 x 0 +let index_array_borrow (x : array u32 2) : result u32 = + array_index_usize u32 2 x 0 (** [array::index_slice_u32_0]: forward function *) -let index_slice_u32_0_fwd (x : slice u32) : result u32 = - slice_index_shared u32 x 0 +let index_slice_u32_0 (x : slice u32) : result u32 = + slice_index_usize u32 x 0 (** [array::index_mut_slice_u32_0]: forward function *) -let index_mut_slice_u32_0_fwd (x : slice u32) : result u32 = - slice_index_shared u32 x 0 +let index_mut_slice_u32_0 (x : slice u32) : result u32 = + slice_index_usize u32 x 0 (** [array::index_mut_slice_u32_0]: backward function 0 *) let index_mut_slice_u32_0_back (x : slice u32) : result (slice u32) = - let* _ = slice_index_shared u32 x 0 in Return x + let* _ = slice_index_usize u32 x 0 in Return x (** [array::index_all]: forward function *) -let index_all_fwd : result u32 = - let* i = index_array_fwd (mk_array u32 2 [ 0; 0 ]) in - let* i0 = index_array_fwd (mk_array u32 2 [ 0; 0 ]) in +let index_all : result u32 = + let* i = index_array (mk_array u32 2 [ 0; 0 ]) in + let* i0 = index_array (mk_array u32 2 [ 0; 0 ]) in let* i1 = u32_add i i0 in - let* i2 = index_array_borrow_fwd (mk_array u32 2 [ 0; 0 ]) in + let* i2 = index_array_borrow (mk_array u32 2 [ 0; 0 ]) in let* i3 = u32_add i1 i2 in - let* s = array_to_slice_shared u32 2 (mk_array u32 2 [ 0; 0 ]) in - let* i4 = index_slice_u32_0_fwd s in + let* s = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in + let* i4 = index_slice_u32_0 s in let* i5 = u32_add i3 i4 in - let* s0 = array_to_slice_mut_fwd u32 2 (mk_array u32 2 [ 0; 0 ]) in - let* i6 = index_mut_slice_u32_0_fwd s0 in + let* s0 = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in + let* i6 = index_mut_slice_u32_0 s0 in let* i7 = u32_add i5 i6 in let* s1 = index_mut_slice_u32_0_back s0 in - let* _ = array_to_slice_mut_back u32 2 (mk_array u32 2 [ 0; 0 ]) s1 in + let* _ = array_from_slice u32 2 (mk_array u32 2 [ 0; 0 ]) s1 in Return i7 (** [array::update_array]: forward function *) -let update_array_fwd (x : array u32 2) : result unit = - let* _ = array_index_mut_back u32 2 x 0 1 in Return () +let update_array (x : array u32 2) : result unit = + let* _ = array_update_usize u32 2 x 0 1 in Return () (** [array::update_array_mut_borrow]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) -let update_array_mut_borrow_fwd_back (x : array u32 2) : result (array u32 2) = - array_index_mut_back u32 2 x 0 1 +let update_array_mut_borrow (x : array u32 2) : result (array u32 2) = + array_update_usize u32 2 x 0 1 (** [array::update_mut_slice]: merged forward/backward function (there is a single backward function, and the forward function returns ()) *) -let update_mut_slice_fwd_back (x : slice u32) : result (slice u32) = - slice_index_mut_back u32 x 0 1 +let update_mut_slice (x : slice u32) : result (slice u32) = + slice_update_usize u32 x 0 1 (** [array::update_all]: forward function *) -let update_all_fwd : result unit = - let* _ = update_array_fwd (mk_array u32 2 [ 0; 0 ]) in - let* x = update_array_mut_borrow_fwd_back (mk_array u32 2 [ 0; 0 ]) in - let* s = array_to_slice_mut_fwd u32 2 x in - let* s0 = update_mut_slice_fwd_back s in - let* _ = array_to_slice_mut_back u32 2 x s0 in +let update_all : result unit = + let* _ = update_array (mk_array u32 2 [ 0; 0 ]) in + let* x = update_array_mut_borrow (mk_array u32 2 [ 0; 0 ]) in + let* s = array_to_slice u32 2 x in + let* s0 = update_mut_slice s in + let* _ = array_from_slice u32 2 x s0 in Return () (** [array::range_all]: forward function *) -let range_all_fwd : result unit = +let range_all : result unit = let* s = - array_subslice_mut_fwd u32 4 (mk_array u32 4 [ 0; 0; 0; 0 ]) (Mkrange 1 3) - in - let* s0 = update_mut_slice_fwd_back s in + core_array_Array_index_mut u32 (core_ops_range_Range usize) 4 + (core_slice_index_Slice_coreopsindexIndexMutInst u32 + (core_ops_range_Range usize) + (core_slice_index_Range_coresliceindexSliceIndexInst u32)) + (mk_array u32 4 [ 0; 0; 0; 0 ]) { start = 1; end_ = 3 } in + let* s0 = update_mut_slice s in let* _ = - array_subslice_mut_back u32 4 (mk_array u32 4 [ 0; 0; 0; 0 ]) (Mkrange 1 3) - s0 in + core_array_Array_index_mut_back u32 (core_ops_range_Range usize) 4 + (core_slice_index_Slice_coreopsindexIndexMutInst u32 + (core_ops_range_Range usize) + (core_slice_index_Range_coresliceindexSliceIndexInst u32)) + (mk_array u32 4 [ 0; 0; 0; 0 ]) { start = 1; end_ = 3 } s0 in Return () (** [array::deref_array_borrow]: forward function *) -let deref_array_borrow_fwd (x : array u32 2) : result u32 = - array_index_shared u32 2 x 0 +let deref_array_borrow (x : array u32 2) : result u32 = + array_index_usize u32 2 x 0 (** [array::deref_array_mut_borrow]: forward function *) -let deref_array_mut_borrow_fwd (x : array u32 2) : result u32 = - array_index_shared u32 2 x 0 +let deref_array_mut_borrow (x : array u32 2) : result u32 = + array_index_usize u32 2 x 0 (** [array::deref_array_mut_borrow]: backward function 0 *) let deref_array_mut_borrow_back (x : array u32 2) : result (array u32 2) = - let* _ = array_index_shared u32 2 x 0 in Return x + let* _ = array_index_usize u32 2 x 0 in Return x (** [array::take_array_t]: forward function *) -let take_array_t_fwd (a : array t_t 2) : result unit = +let take_array_t (a : array ab_t 2) : result unit = Return () (** [array::non_copyable_array]: forward function *) -let non_copyable_array_fwd : result unit = - let* _ = take_array_t_fwd (mk_array t_t 2 [ TA; TB ]) in Return () +let non_copyable_array : result unit = + let* _ = take_array_t (mk_array ab_t 2 [ ABA; ABB ]) in Return () (** [array::sum]: loop 0: forward function *) -let rec sum_loop_fwd - (s : slice u32) (sum : u32) (i : usize) : - Tot (result u32) (decreases (sum_loop_decreases s sum i)) +let rec sum_loop + (s : slice u32) (sum0 : u32) (i : usize) : + Tot (result u32) (decreases (sum_loop_decreases s sum0 i)) = let i0 = slice_len u32 s in if i < i0 then - let* i1 = slice_index_shared u32 s i in - let* sum0 = u32_add sum i1 in + let* i1 = slice_index_usize u32 s i in + let* sum1 = u32_add sum0 i1 in let* i2 = usize_add i 1 in - sum_loop_fwd s sum0 i2 - else Return sum + sum_loop s sum1 i2 + else Return sum0 (** [array::sum]: forward function *) -let sum_fwd (s : slice u32) : result u32 = - sum_loop_fwd s 0 0 +let sum (s : slice u32) : result u32 = + sum_loop s 0 0 (** [array::sum2]: loop 0: forward function *) -let rec sum2_loop_fwd - (s : slice u32) (s2 : slice u32) (sum : u32) (i : usize) : - Tot (result u32) (decreases (sum2_loop_decreases s s2 sum i)) +let rec sum2_loop + (s : slice u32) (s2 : slice u32) (sum0 : u32) (i : usize) : + Tot (result u32) (decreases (sum2_loop_decreases s s2 sum0 i)) = let i0 = slice_len u32 s in if i < i0 then - let* i1 = slice_index_shared u32 s i in - let* i2 = slice_index_shared u32 s2 i in + let* i1 = slice_index_usize u32 s i in + let* i2 = slice_index_usize u32 s2 i in let* i3 = u32_add i1 i2 in - let* sum0 = u32_add sum i3 in + let* sum1 = u32_add sum0 i3 in let* i4 = usize_add i 1 in - sum2_loop_fwd s s2 sum0 i4 - else Return sum + sum2_loop s s2 sum1 i4 + else Return sum0 (** [array::sum2]: forward function *) -let sum2_fwd (s : slice u32) (s2 : slice u32) : result u32 = +let sum2 (s : slice u32) (s2 : slice u32) : result u32 = let i = slice_len u32 s in let i0 = slice_len u32 s2 in - if not (i = i0) then Fail Failure else sum2_loop_fwd s s2 0 0 + if not (i = i0) then Fail Failure else sum2_loop s s2 0 0 (** [array::f0]: forward function *) -let f0_fwd : result unit = - let* s = array_to_slice_mut_fwd u32 2 (mk_array u32 2 [ 1; 2 ]) in - let* s0 = slice_index_mut_back u32 s 0 1 in - let* _ = array_to_slice_mut_back u32 2 (mk_array u32 2 [ 1; 2 ]) s0 in +let f0 : result unit = + let* s = array_to_slice u32 2 (mk_array u32 2 [ 1; 2 ]) in + let* s0 = slice_update_usize u32 s 0 1 in + let* _ = array_from_slice u32 2 (mk_array u32 2 [ 1; 2 ]) s0 in Return () (** [array::f1]: forward function *) -let f1_fwd : result unit = - let* _ = array_index_mut_back u32 2 (mk_array u32 2 [ 1; 2 ]) 0 1 in - Return () +let f1 : result unit = + let* _ = array_update_usize u32 2 (mk_array u32 2 [ 1; 2 ]) 0 1 in Return () (** [array::f2]: forward function *) -let f2_fwd (i : u32) : result unit = +let f2 (i : u32) : result unit = Return () (** [array::f4]: forward function *) -let f4_fwd (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = - array_subslice_shared u32 32 x (Mkrange y z) +let f4 (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = + core_array_Array_index u32 (core_ops_range_Range usize) 32 + (core_slice_index_Slice_coreopsindexIndexInst u32 (core_ops_range_Range + usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x + { start = y; end_ = z } (** [array::f3]: forward function *) -let f3_fwd : result u32 = - let* i = array_index_shared u32 2 (mk_array u32 2 [ 1; 2 ]) 0 in - let* _ = f2_fwd i in - let* s = array_to_slice_shared u32 2 (mk_array u32 2 [ 1; 2 ]) in - let* s0 = - f4_fwd - (mk_array u32 32 [ - 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; 0; - 0; 0; 0; 0; 0; 0; 0; 0 - ]) 16 18 in - sum2_fwd s s0 +let f3 : result u32 = + let* i = array_index_usize u32 2 (mk_array u32 2 [ 1; 2 ]) 0 in + let* _ = f2 i in + let b = array_repeat u32 32 0 in + let* s = array_to_slice u32 2 (mk_array u32 2 [ 1; 2 ]) in + let* s0 = f4 b 16 18 in + sum2 s s0 (** [array::SZ] *) let sz_body : result usize = Return 32 let sz_c : usize = eval_global sz_body (** [array::f5]: forward function *) -let f5_fwd (x : array u32 32) : result u32 = - array_index_shared u32 32 x 0 +let f5 (x : array u32 32) : result u32 = + array_index_usize u32 32 x 0 (** [array::ite]: forward function *) -let ite_fwd : result unit = - let* s = array_to_slice_mut_fwd u32 2 (mk_array u32 2 [ 0; 0 ]) in - let* s0 = array_to_slice_mut_fwd u32 2 (mk_array u32 2 [ 0; 0 ]) in +let ite : result unit = + let* s = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in + let* s0 = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in let* s1 = index_mut_slice_u32_0_back s0 in - let* _ = array_to_slice_mut_back u32 2 (mk_array u32 2 [ 0; 0 ]) s1 in + let* _ = array_from_slice u32 2 (mk_array u32 2 [ 0; 0 ]) s1 in let* s2 = index_mut_slice_u32_0_back s in - let* _ = array_to_slice_mut_back u32 2 (mk_array u32 2 [ 0; 0 ]) s2 in + let* _ = array_from_slice u32 2 (mk_array u32 2 [ 0; 0 ]) s2 in Return () diff --git a/tests/fstar/array/Array.Types.fst b/tests/fstar/array/Array.Types.fst index 5e8e81d8..0ec9c12f 100644 --- a/tests/fstar/array/Array.Types.fst +++ b/tests/fstar/array/Array.Types.fst @@ -5,6 +5,6 @@ open Primitives #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" -(** [array::T] *) -type t_t = | TA : t_t | TB : t_t +(** [array::AB] *) +type ab_t = | ABA : ab_t | ABB : ab_t -- 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/array/Primitives.fst | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) (limited to 'tests/fstar/array') diff --git a/tests/fstar/array/Primitives.fst b/tests/fstar/array/Primitives.fst index 5e154122..3110b247 100644 --- a/tests/fstar/array/Primitives.fst +++ b/tests/fstar/array/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 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/array/Array.Funs.fst | 4 ++-- tests/fstar/array/Array.Opaque.fsti | 24 ++++++++++++++++++++++++ tests/fstar/array/Array.Types.fst | 2 +- tests/fstar/array/Primitives.fst | 4 +++- 4 files changed, 30 insertions(+), 4 deletions(-) create mode 100644 tests/fstar/array/Array.Opaque.fsti (limited to 'tests/fstar/array') diff --git a/tests/fstar/array/Array.Funs.fst b/tests/fstar/array/Array.Funs.fst index a6808c98..8f0bfbbd 100644 --- a/tests/fstar/array/Array.Funs.fst +++ b/tests/fstar/array/Array.Funs.fst @@ -277,12 +277,12 @@ let deref_array_mut_borrow_back (x : array u32 2) : result (array u32 2) = let* _ = array_index_usize u32 2 x 0 in Return x (** [array::take_array_t]: forward function *) -let take_array_t (a : array ab_t 2) : result unit = +let take_array_t (a : array aB_t 2) : result unit = Return () (** [array::non_copyable_array]: forward function *) let non_copyable_array : result unit = - let* _ = take_array_t (mk_array ab_t 2 [ ABA; ABB ]) in Return () + let* _ = take_array_t (mk_array aB_t 2 [ AB_A; AB_B ]) in Return () (** [array::sum]: loop 0: forward function *) let rec sum_loop diff --git a/tests/fstar/array/Array.Opaque.fsti b/tests/fstar/array/Array.Opaque.fsti new file mode 100644 index 00000000..484cb9ee --- /dev/null +++ b/tests/fstar/array/Array.Opaque.fsti @@ -0,0 +1,24 @@ +(** THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS *) +(** [array]: external function declarations *) +module Array.Opaque +open Primitives +include Array.Types + +#set-options "--z3rlimit 50 --fuel 1 --ifuel 1" + +(** [core::array::[T; N]::{15}::index]: forward function *) +val core_array_[T; N]_index_fwd + (t i : Type0) (n : usize) (inst : core_ops_index_Index (slice t) i) : + array t n -> i -> result inst.core_ops_index_Index_Output + +(** [core::array::[T; N]::{16}::index_mut]: forward function *) +val core_array_[T; N]_index_mut_fwd + (t i : Type0) (n : usize) (inst : core_ops_index_IndexMut (slice t) i) : + array t n -> i -> result inst.index_inst.core_ops_index_Index_Output + +(** [core::array::[T; N]::{16}::index_mut]: backward function 0 *) +val core_array_[T; N]_index_mut_back + (t i : Type0) (n : usize) (inst : core_ops_index_IndexMut (slice t) i) : + array t n -> i -> inst.index_inst.core_ops_index_Index_Output -> result + (array t n) + diff --git a/tests/fstar/array/Array.Types.fst b/tests/fstar/array/Array.Types.fst index 0ec9c12f..4e8d5566 100644 --- a/tests/fstar/array/Array.Types.fst +++ b/tests/fstar/array/Array.Types.fst @@ -6,5 +6,5 @@ open Primitives #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" (** [array::AB] *) -type ab_t = | ABA : ab_t | ABB : ab_t +type aB_t = | AB_A : aB_t | AB_B : aB_t diff --git a/tests/fstar/array/Primitives.fst b/tests/fstar/array/Primitives.fst index 3110b247..71d75c11 100644 --- a/tests/fstar/array/Primitives.fst +++ b/tests/fstar/array/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 9254f5aeadfc9d17f31e13c61a7843364220c4ed Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 9 Nov 2023 12:33:14 +0100 Subject: Progress on making the traits work for F* --- tests/fstar/array/Array.fst | 387 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 387 insertions(+) create mode 100644 tests/fstar/array/Array.fst (limited to 'tests/fstar/array') diff --git a/tests/fstar/array/Array.fst b/tests/fstar/array/Array.fst new file mode 100644 index 00000000..341f5239 --- /dev/null +++ b/tests/fstar/array/Array.fst @@ -0,0 +1,387 @@ +(** THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS *) +(** [array] *) +module Array +open Primitives + +#set-options "--z3rlimit 50 --fuel 1 --ifuel 1" + +(** [array::AB] *) +type aB_t = | AB_A : aB_t | AB_B : aB_t + +(** [array::incr]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) *) +let incr (x : u32) : result u32 = + u32_add x 1 + +(** [array::array_to_shared_slice_]: forward function *) +let array_to_shared_slice_ (t : Type0) (s : array t 32) : result (slice t) = + array_to_slice t 32 s + +(** [array::array_to_mut_slice_]: forward function *) +let array_to_mut_slice_ (t : Type0) (s : array t 32) : result (slice t) = + array_to_slice t 32 s + +(** [array::array_to_mut_slice_]: backward function 0 *) +let array_to_mut_slice__back + (t : Type0) (s : array t 32) (ret : slice t) : result (array t 32) = + array_from_slice t 32 s ret + +(** [array::array_len]: forward function *) +let array_len (t : Type0) (s : array t 32) : result usize = + let* s0 = array_to_slice t 32 s in let i = slice_len t s0 in Return i + +(** [array::shared_array_len]: forward function *) +let shared_array_len (t : Type0) (s : array t 32) : result usize = + let* s0 = array_to_slice t 32 s in let i = slice_len t s0 in Return i + +(** [array::shared_slice_len]: forward function *) +let shared_slice_len (t : Type0) (s : slice t) : result usize = + let i = slice_len t s in Return i + +(** [array::index_array_shared]: forward function *) +let index_array_shared (t : Type0) (s : array t 32) (i : usize) : result t = + array_index_usize t 32 s i + +(** [array::index_array_u32]: forward function *) +let index_array_u32 (s : array u32 32) (i : usize) : result u32 = + array_index_usize u32 32 s i + +(** [array::index_array_copy]: forward function *) +let index_array_copy (x : array u32 32) : result u32 = + array_index_usize u32 32 x 0 + +(** [array::index_mut_array]: forward function *) +let index_mut_array (t : Type0) (s : array t 32) (i : usize) : result t = + array_index_usize t 32 s i + +(** [array::index_mut_array]: backward function 0 *) +let index_mut_array_back + (t : Type0) (s : array t 32) (i : usize) (ret : t) : result (array t 32) = + array_update_usize t 32 s i ret + +(** [array::index_slice]: forward function *) +let index_slice (t : Type0) (s : slice t) (i : usize) : result t = + slice_index_usize t s i + +(** [array::index_mut_slice]: forward function *) +let index_mut_slice (t : Type0) (s : slice t) (i : usize) : result t = + slice_index_usize t s i + +(** [array::index_mut_slice]: backward function 0 *) +let index_mut_slice_back + (t : Type0) (s : slice t) (i : usize) (ret : t) : result (slice t) = + slice_update_usize t s i ret + +(** [array::slice_subslice_shared_]: forward function *) +let slice_subslice_shared_ + (x : slice u32) (y : usize) (z : usize) : result (slice u32) = + core_slice_index_Slice_index u32 (core_ops_range_Range usize) + (core_slice_index_Range_coresliceindexSliceIndexInst u32) x + { start = y; end_ = z } + +(** [array::slice_subslice_mut_]: forward function *) +let slice_subslice_mut_ + (x : slice u32) (y : usize) (z : usize) : result (slice u32) = + core_slice_index_Slice_index_mut u32 (core_ops_range_Range usize) + (core_slice_index_Range_coresliceindexSliceIndexInst u32) x + { start = y; end_ = z } + +(** [array::slice_subslice_mut_]: backward function 0 *) +let slice_subslice_mut__back + (x : slice u32) (y : usize) (z : usize) (ret : slice u32) : + result (slice u32) + = + core_slice_index_Slice_index_mut_back u32 (core_ops_range_Range usize) + (core_slice_index_Range_coresliceindexSliceIndexInst u32) x + { start = y; end_ = z } ret + +(** [array::array_to_slice_shared_]: forward function *) +let array_to_slice_shared_ (x : array u32 32) : result (slice u32) = + array_to_slice u32 32 x + +(** [array::array_to_slice_mut_]: forward function *) +let array_to_slice_mut_ (x : array u32 32) : result (slice u32) = + array_to_slice u32 32 x + +(** [array::array_to_slice_mut_]: backward function 0 *) +let array_to_slice_mut__back + (x : array u32 32) (ret : slice u32) : result (array u32 32) = + array_from_slice u32 32 x ret + +(** [array::array_subslice_shared_]: forward function *) +let array_subslice_shared_ + (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = + core_array_Array_index u32 (core_ops_range_Range usize) 32 + (core_slice_index_Slice_coreopsindexIndexInst u32 (core_ops_range_Range + usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x + { start = y; end_ = z } + +(** [array::array_subslice_mut_]: forward function *) +let array_subslice_mut_ + (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = + core_array_Array_index_mut u32 (core_ops_range_Range usize) 32 + (core_slice_index_Slice_coreopsindexIndexMutInst u32 (core_ops_range_Range + usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x + { start = y; end_ = z } + +(** [array::array_subslice_mut_]: backward function 0 *) +let array_subslice_mut__back + (x : array u32 32) (y : usize) (z : usize) (ret : slice u32) : + result (array u32 32) + = + core_array_Array_index_mut_back u32 (core_ops_range_Range usize) 32 + (core_slice_index_Slice_coreopsindexIndexMutInst u32 (core_ops_range_Range + usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x + { start = y; end_ = z } ret + +(** [array::index_slice_0]: forward function *) +let index_slice_0 (t : Type0) (s : slice t) : result t = + slice_index_usize t s 0 + +(** [array::index_array_0]: forward function *) +let index_array_0 (t : Type0) (s : array t 32) : result t = + array_index_usize t 32 s 0 + +(** [array::index_index_array]: forward function *) +let index_index_array + (s : array (array u32 32) 32) (i : usize) (j : usize) : result u32 = + let* a = array_index_usize (array u32 32) 32 s i in + array_index_usize u32 32 a j + +(** [array::update_update_array]: forward function *) +let update_update_array + (s : array (array u32 32) 32) (i : usize) (j : usize) : result unit = + let* a = array_index_usize (array u32 32) 32 s i in + let* a0 = array_update_usize u32 32 a j 0 in + let* _ = array_update_usize (array u32 32) 32 s i a0 in + Return () + +(** [array::array_local_deep_copy]: forward function *) +let array_local_deep_copy (x : array u32 32) : result unit = + Return () + +(** [array::take_array]: forward function *) +let take_array (a : array u32 2) : result unit = + Return () + +(** [array::take_array_borrow]: forward function *) +let take_array_borrow (a : array u32 2) : result unit = + Return () + +(** [array::take_slice]: forward function *) +let take_slice (s : slice u32) : result unit = + Return () + +(** [array::take_mut_slice]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) *) +let take_mut_slice (s : slice u32) : result (slice u32) = + Return s + +(** [array::take_all]: forward function *) +let take_all : result unit = + let* _ = take_array (mk_array u32 2 [ 0; 0 ]) in + let* _ = take_array_borrow (mk_array u32 2 [ 0; 0 ]) in + let* s = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in + let* _ = take_slice s in + let* s0 = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in + let* s1 = take_mut_slice s0 in + let* _ = array_from_slice u32 2 (mk_array u32 2 [ 0; 0 ]) s1 in + Return () + +(** [array::index_array]: forward function *) +let index_array (x : array u32 2) : result u32 = + array_index_usize u32 2 x 0 + +(** [array::index_array_borrow]: forward function *) +let index_array_borrow (x : array u32 2) : result u32 = + array_index_usize u32 2 x 0 + +(** [array::index_slice_u32_0]: forward function *) +let index_slice_u32_0 (x : slice u32) : result u32 = + slice_index_usize u32 x 0 + +(** [array::index_mut_slice_u32_0]: forward function *) +let index_mut_slice_u32_0 (x : slice u32) : result u32 = + slice_index_usize u32 x 0 + +(** [array::index_mut_slice_u32_0]: backward function 0 *) +let index_mut_slice_u32_0_back (x : slice u32) : result (slice u32) = + let* _ = slice_index_usize u32 x 0 in Return x + +(** [array::index_all]: forward function *) +let index_all : result u32 = + let* i = index_array (mk_array u32 2 [ 0; 0 ]) in + let* i0 = index_array (mk_array u32 2 [ 0; 0 ]) in + let* i1 = u32_add i i0 in + let* i2 = index_array_borrow (mk_array u32 2 [ 0; 0 ]) in + let* i3 = u32_add i1 i2 in + let* s = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in + let* i4 = index_slice_u32_0 s in + let* i5 = u32_add i3 i4 in + let* s0 = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in + let* i6 = index_mut_slice_u32_0 s0 in + let* i7 = u32_add i5 i6 in + let* s1 = index_mut_slice_u32_0_back s0 in + let* _ = array_from_slice u32 2 (mk_array u32 2 [ 0; 0 ]) s1 in + Return i7 + +(** [array::update_array]: forward function *) +let update_array (x : array u32 2) : result unit = + let* _ = array_update_usize u32 2 x 0 1 in Return () + +(** [array::update_array_mut_borrow]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) *) +let update_array_mut_borrow (x : array u32 2) : result (array u32 2) = + array_update_usize u32 2 x 0 1 + +(** [array::update_mut_slice]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) *) +let update_mut_slice (x : slice u32) : result (slice u32) = + slice_update_usize u32 x 0 1 + +(** [array::update_all]: forward function *) +let update_all : result unit = + let* _ = update_array (mk_array u32 2 [ 0; 0 ]) in + let* x = update_array_mut_borrow (mk_array u32 2 [ 0; 0 ]) in + let* s = array_to_slice u32 2 x in + let* s0 = update_mut_slice s in + let* _ = array_from_slice u32 2 x s0 in + Return () + +(** [array::range_all]: forward function *) +let range_all : result unit = + let* s = + core_array_Array_index_mut u32 (core_ops_range_Range usize) 4 + (core_slice_index_Slice_coreopsindexIndexMutInst u32 + (core_ops_range_Range usize) + (core_slice_index_Range_coresliceindexSliceIndexInst u32)) + (mk_array u32 4 [ 0; 0; 0; 0 ]) { start = 1; end_ = 3 } in + let* s0 = update_mut_slice s in + let* _ = + core_array_Array_index_mut_back u32 (core_ops_range_Range usize) 4 + (core_slice_index_Slice_coreopsindexIndexMutInst u32 + (core_ops_range_Range usize) + (core_slice_index_Range_coresliceindexSliceIndexInst u32)) + (mk_array u32 4 [ 0; 0; 0; 0 ]) { start = 1; end_ = 3 } s0 in + Return () + +(** [array::deref_array_borrow]: forward function *) +let deref_array_borrow (x : array u32 2) : result u32 = + array_index_usize u32 2 x 0 + +(** [array::deref_array_mut_borrow]: forward function *) +let deref_array_mut_borrow (x : array u32 2) : result u32 = + array_index_usize u32 2 x 0 + +(** [array::deref_array_mut_borrow]: backward function 0 *) +let deref_array_mut_borrow_back (x : array u32 2) : result (array u32 2) = + let* _ = array_index_usize u32 2 x 0 in Return x + +(** [array::take_array_t]: forward function *) +let take_array_t (a : array aB_t 2) : result unit = + Return () + +(** [array::non_copyable_array]: forward function *) +let non_copyable_array : result unit = + let* _ = take_array_t (mk_array aB_t 2 [ AB_A; AB_B ]) in Return () + +(** [array::sum]: decreases clause *) +unfold +let sum_loop_decreases (s : slice u32) (sum0 : u32) (i : usize) : nat = + admit () + +(** [array::sum]: loop 0: forward function *) +let rec sum_loop + (s : slice u32) (sum0 : u32) (i : usize) : + Tot (result u32) (decreases (sum_loop_decreases s sum0 i)) + = + let i0 = slice_len u32 s in + if i < i0 + then + let* i1 = slice_index_usize u32 s i in + let* sum1 = u32_add sum0 i1 in + let* i2 = usize_add i 1 in + sum_loop s sum1 i2 + else Return sum0 + +(** [array::sum]: forward function *) +let sum (s : slice u32) : result u32 = + sum_loop s 0 0 + +(** [array::sum2]: decreases clause *) +unfold +let sum2_loop_decreases (s : slice u32) (s2 : slice u32) (sum0 : u32) + (i : usize) : nat = + admit () + +(** [array::sum2]: loop 0: forward function *) +let rec sum2_loop + (s : slice u32) (s2 : slice u32) (sum0 : u32) (i : usize) : + Tot (result u32) (decreases (sum2_loop_decreases s s2 sum0 i)) + = + let i0 = slice_len u32 s in + if i < i0 + then + let* i1 = slice_index_usize u32 s i in + let* i2 = slice_index_usize u32 s2 i in + let* i3 = u32_add i1 i2 in + let* sum1 = u32_add sum0 i3 in + let* i4 = usize_add i 1 in + sum2_loop s s2 sum1 i4 + else Return sum0 + +(** [array::sum2]: forward function *) +let sum2 (s : slice u32) (s2 : slice u32) : result u32 = + let i = slice_len u32 s in + let i0 = slice_len u32 s2 in + if not (i = i0) then Fail Failure else sum2_loop s s2 0 0 + +(** [array::f0]: forward function *) +let f0 : result unit = + let* s = array_to_slice u32 2 (mk_array u32 2 [ 1; 2 ]) in + let* s0 = slice_update_usize u32 s 0 1 in + let* _ = array_from_slice u32 2 (mk_array u32 2 [ 1; 2 ]) s0 in + Return () + +(** [array::f1]: forward function *) +let f1 : result unit = + let* _ = array_update_usize u32 2 (mk_array u32 2 [ 1; 2 ]) 0 1 in Return () + +(** [array::f2]: forward function *) +let f2 (i : u32) : result unit = + Return () + +(** [array::f4]: forward function *) +let f4 (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = + core_array_Array_index u32 (core_ops_range_Range usize) 32 + (core_slice_index_Slice_coreopsindexIndexInst u32 (core_ops_range_Range + usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x + { start = y; end_ = z } + +(** [array::f3]: forward function *) +let f3 : result u32 = + let* i = array_index_usize u32 2 (mk_array u32 2 [ 1; 2 ]) 0 in + let* _ = f2 i in + let b = array_repeat u32 32 0 in + let* s = array_to_slice u32 2 (mk_array u32 2 [ 1; 2 ]) in + let* s0 = f4 b 16 18 in + sum2 s s0 + +(** [array::SZ] *) +let sz_body : result usize = Return 32 +let sz_c : usize = eval_global sz_body + +(** [array::f5]: forward function *) +let f5 (x : array u32 32) : result u32 = + array_index_usize u32 32 x 0 + +(** [array::ite]: forward function *) +let ite : result unit = + let* s = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in + let* s0 = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in + let* s1 = index_mut_slice_u32_0_back s0 in + let* _ = array_from_slice u32 2 (mk_array u32 2 [ 0; 0 ]) s1 in + let* s2 = index_mut_slice_u32_0_back s in + let* _ = array_from_slice u32 2 (mk_array u32 2 [ 0; 0 ]) s2 in + Return () + -- cgit v1.2.3 From eec2643daad40d3ceec51cd83eb01e7c9db1824d Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 9 Nov 2023 14:17:51 +0100 Subject: Remove a file --- tests/fstar/array/Array.fst | 387 -------------------------------------------- 1 file changed, 387 deletions(-) delete mode 100644 tests/fstar/array/Array.fst (limited to 'tests/fstar/array') diff --git a/tests/fstar/array/Array.fst b/tests/fstar/array/Array.fst deleted file mode 100644 index 341f5239..00000000 --- a/tests/fstar/array/Array.fst +++ /dev/null @@ -1,387 +0,0 @@ -(** THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS *) -(** [array] *) -module Array -open Primitives - -#set-options "--z3rlimit 50 --fuel 1 --ifuel 1" - -(** [array::AB] *) -type aB_t = | AB_A : aB_t | AB_B : aB_t - -(** [array::incr]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) *) -let incr (x : u32) : result u32 = - u32_add x 1 - -(** [array::array_to_shared_slice_]: forward function *) -let array_to_shared_slice_ (t : Type0) (s : array t 32) : result (slice t) = - array_to_slice t 32 s - -(** [array::array_to_mut_slice_]: forward function *) -let array_to_mut_slice_ (t : Type0) (s : array t 32) : result (slice t) = - array_to_slice t 32 s - -(** [array::array_to_mut_slice_]: backward function 0 *) -let array_to_mut_slice__back - (t : Type0) (s : array t 32) (ret : slice t) : result (array t 32) = - array_from_slice t 32 s ret - -(** [array::array_len]: forward function *) -let array_len (t : Type0) (s : array t 32) : result usize = - let* s0 = array_to_slice t 32 s in let i = slice_len t s0 in Return i - -(** [array::shared_array_len]: forward function *) -let shared_array_len (t : Type0) (s : array t 32) : result usize = - let* s0 = array_to_slice t 32 s in let i = slice_len t s0 in Return i - -(** [array::shared_slice_len]: forward function *) -let shared_slice_len (t : Type0) (s : slice t) : result usize = - let i = slice_len t s in Return i - -(** [array::index_array_shared]: forward function *) -let index_array_shared (t : Type0) (s : array t 32) (i : usize) : result t = - array_index_usize t 32 s i - -(** [array::index_array_u32]: forward function *) -let index_array_u32 (s : array u32 32) (i : usize) : result u32 = - array_index_usize u32 32 s i - -(** [array::index_array_copy]: forward function *) -let index_array_copy (x : array u32 32) : result u32 = - array_index_usize u32 32 x 0 - -(** [array::index_mut_array]: forward function *) -let index_mut_array (t : Type0) (s : array t 32) (i : usize) : result t = - array_index_usize t 32 s i - -(** [array::index_mut_array]: backward function 0 *) -let index_mut_array_back - (t : Type0) (s : array t 32) (i : usize) (ret : t) : result (array t 32) = - array_update_usize t 32 s i ret - -(** [array::index_slice]: forward function *) -let index_slice (t : Type0) (s : slice t) (i : usize) : result t = - slice_index_usize t s i - -(** [array::index_mut_slice]: forward function *) -let index_mut_slice (t : Type0) (s : slice t) (i : usize) : result t = - slice_index_usize t s i - -(** [array::index_mut_slice]: backward function 0 *) -let index_mut_slice_back - (t : Type0) (s : slice t) (i : usize) (ret : t) : result (slice t) = - slice_update_usize t s i ret - -(** [array::slice_subslice_shared_]: forward function *) -let slice_subslice_shared_ - (x : slice u32) (y : usize) (z : usize) : result (slice u32) = - core_slice_index_Slice_index u32 (core_ops_range_Range usize) - (core_slice_index_Range_coresliceindexSliceIndexInst u32) x - { start = y; end_ = z } - -(** [array::slice_subslice_mut_]: forward function *) -let slice_subslice_mut_ - (x : slice u32) (y : usize) (z : usize) : result (slice u32) = - core_slice_index_Slice_index_mut u32 (core_ops_range_Range usize) - (core_slice_index_Range_coresliceindexSliceIndexInst u32) x - { start = y; end_ = z } - -(** [array::slice_subslice_mut_]: backward function 0 *) -let slice_subslice_mut__back - (x : slice u32) (y : usize) (z : usize) (ret : slice u32) : - result (slice u32) - = - core_slice_index_Slice_index_mut_back u32 (core_ops_range_Range usize) - (core_slice_index_Range_coresliceindexSliceIndexInst u32) x - { start = y; end_ = z } ret - -(** [array::array_to_slice_shared_]: forward function *) -let array_to_slice_shared_ (x : array u32 32) : result (slice u32) = - array_to_slice u32 32 x - -(** [array::array_to_slice_mut_]: forward function *) -let array_to_slice_mut_ (x : array u32 32) : result (slice u32) = - array_to_slice u32 32 x - -(** [array::array_to_slice_mut_]: backward function 0 *) -let array_to_slice_mut__back - (x : array u32 32) (ret : slice u32) : result (array u32 32) = - array_from_slice u32 32 x ret - -(** [array::array_subslice_shared_]: forward function *) -let array_subslice_shared_ - (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = - core_array_Array_index u32 (core_ops_range_Range usize) 32 - (core_slice_index_Slice_coreopsindexIndexInst u32 (core_ops_range_Range - usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x - { start = y; end_ = z } - -(** [array::array_subslice_mut_]: forward function *) -let array_subslice_mut_ - (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = - core_array_Array_index_mut u32 (core_ops_range_Range usize) 32 - (core_slice_index_Slice_coreopsindexIndexMutInst u32 (core_ops_range_Range - usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x - { start = y; end_ = z } - -(** [array::array_subslice_mut_]: backward function 0 *) -let array_subslice_mut__back - (x : array u32 32) (y : usize) (z : usize) (ret : slice u32) : - result (array u32 32) - = - core_array_Array_index_mut_back u32 (core_ops_range_Range usize) 32 - (core_slice_index_Slice_coreopsindexIndexMutInst u32 (core_ops_range_Range - usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x - { start = y; end_ = z } ret - -(** [array::index_slice_0]: forward function *) -let index_slice_0 (t : Type0) (s : slice t) : result t = - slice_index_usize t s 0 - -(** [array::index_array_0]: forward function *) -let index_array_0 (t : Type0) (s : array t 32) : result t = - array_index_usize t 32 s 0 - -(** [array::index_index_array]: forward function *) -let index_index_array - (s : array (array u32 32) 32) (i : usize) (j : usize) : result u32 = - let* a = array_index_usize (array u32 32) 32 s i in - array_index_usize u32 32 a j - -(** [array::update_update_array]: forward function *) -let update_update_array - (s : array (array u32 32) 32) (i : usize) (j : usize) : result unit = - let* a = array_index_usize (array u32 32) 32 s i in - let* a0 = array_update_usize u32 32 a j 0 in - let* _ = array_update_usize (array u32 32) 32 s i a0 in - Return () - -(** [array::array_local_deep_copy]: forward function *) -let array_local_deep_copy (x : array u32 32) : result unit = - Return () - -(** [array::take_array]: forward function *) -let take_array (a : array u32 2) : result unit = - Return () - -(** [array::take_array_borrow]: forward function *) -let take_array_borrow (a : array u32 2) : result unit = - Return () - -(** [array::take_slice]: forward function *) -let take_slice (s : slice u32) : result unit = - Return () - -(** [array::take_mut_slice]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) *) -let take_mut_slice (s : slice u32) : result (slice u32) = - Return s - -(** [array::take_all]: forward function *) -let take_all : result unit = - let* _ = take_array (mk_array u32 2 [ 0; 0 ]) in - let* _ = take_array_borrow (mk_array u32 2 [ 0; 0 ]) in - let* s = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in - let* _ = take_slice s in - let* s0 = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in - let* s1 = take_mut_slice s0 in - let* _ = array_from_slice u32 2 (mk_array u32 2 [ 0; 0 ]) s1 in - Return () - -(** [array::index_array]: forward function *) -let index_array (x : array u32 2) : result u32 = - array_index_usize u32 2 x 0 - -(** [array::index_array_borrow]: forward function *) -let index_array_borrow (x : array u32 2) : result u32 = - array_index_usize u32 2 x 0 - -(** [array::index_slice_u32_0]: forward function *) -let index_slice_u32_0 (x : slice u32) : result u32 = - slice_index_usize u32 x 0 - -(** [array::index_mut_slice_u32_0]: forward function *) -let index_mut_slice_u32_0 (x : slice u32) : result u32 = - slice_index_usize u32 x 0 - -(** [array::index_mut_slice_u32_0]: backward function 0 *) -let index_mut_slice_u32_0_back (x : slice u32) : result (slice u32) = - let* _ = slice_index_usize u32 x 0 in Return x - -(** [array::index_all]: forward function *) -let index_all : result u32 = - let* i = index_array (mk_array u32 2 [ 0; 0 ]) in - let* i0 = index_array (mk_array u32 2 [ 0; 0 ]) in - let* i1 = u32_add i i0 in - let* i2 = index_array_borrow (mk_array u32 2 [ 0; 0 ]) in - let* i3 = u32_add i1 i2 in - let* s = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in - let* i4 = index_slice_u32_0 s in - let* i5 = u32_add i3 i4 in - let* s0 = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in - let* i6 = index_mut_slice_u32_0 s0 in - let* i7 = u32_add i5 i6 in - let* s1 = index_mut_slice_u32_0_back s0 in - let* _ = array_from_slice u32 2 (mk_array u32 2 [ 0; 0 ]) s1 in - Return i7 - -(** [array::update_array]: forward function *) -let update_array (x : array u32 2) : result unit = - let* _ = array_update_usize u32 2 x 0 1 in Return () - -(** [array::update_array_mut_borrow]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) *) -let update_array_mut_borrow (x : array u32 2) : result (array u32 2) = - array_update_usize u32 2 x 0 1 - -(** [array::update_mut_slice]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) *) -let update_mut_slice (x : slice u32) : result (slice u32) = - slice_update_usize u32 x 0 1 - -(** [array::update_all]: forward function *) -let update_all : result unit = - let* _ = update_array (mk_array u32 2 [ 0; 0 ]) in - let* x = update_array_mut_borrow (mk_array u32 2 [ 0; 0 ]) in - let* s = array_to_slice u32 2 x in - let* s0 = update_mut_slice s in - let* _ = array_from_slice u32 2 x s0 in - Return () - -(** [array::range_all]: forward function *) -let range_all : result unit = - let* s = - core_array_Array_index_mut u32 (core_ops_range_Range usize) 4 - (core_slice_index_Slice_coreopsindexIndexMutInst u32 - (core_ops_range_Range usize) - (core_slice_index_Range_coresliceindexSliceIndexInst u32)) - (mk_array u32 4 [ 0; 0; 0; 0 ]) { start = 1; end_ = 3 } in - let* s0 = update_mut_slice s in - let* _ = - core_array_Array_index_mut_back u32 (core_ops_range_Range usize) 4 - (core_slice_index_Slice_coreopsindexIndexMutInst u32 - (core_ops_range_Range usize) - (core_slice_index_Range_coresliceindexSliceIndexInst u32)) - (mk_array u32 4 [ 0; 0; 0; 0 ]) { start = 1; end_ = 3 } s0 in - Return () - -(** [array::deref_array_borrow]: forward function *) -let deref_array_borrow (x : array u32 2) : result u32 = - array_index_usize u32 2 x 0 - -(** [array::deref_array_mut_borrow]: forward function *) -let deref_array_mut_borrow (x : array u32 2) : result u32 = - array_index_usize u32 2 x 0 - -(** [array::deref_array_mut_borrow]: backward function 0 *) -let deref_array_mut_borrow_back (x : array u32 2) : result (array u32 2) = - let* _ = array_index_usize u32 2 x 0 in Return x - -(** [array::take_array_t]: forward function *) -let take_array_t (a : array aB_t 2) : result unit = - Return () - -(** [array::non_copyable_array]: forward function *) -let non_copyable_array : result unit = - let* _ = take_array_t (mk_array aB_t 2 [ AB_A; AB_B ]) in Return () - -(** [array::sum]: decreases clause *) -unfold -let sum_loop_decreases (s : slice u32) (sum0 : u32) (i : usize) : nat = - admit () - -(** [array::sum]: loop 0: forward function *) -let rec sum_loop - (s : slice u32) (sum0 : u32) (i : usize) : - Tot (result u32) (decreases (sum_loop_decreases s sum0 i)) - = - let i0 = slice_len u32 s in - if i < i0 - then - let* i1 = slice_index_usize u32 s i in - let* sum1 = u32_add sum0 i1 in - let* i2 = usize_add i 1 in - sum_loop s sum1 i2 - else Return sum0 - -(** [array::sum]: forward function *) -let sum (s : slice u32) : result u32 = - sum_loop s 0 0 - -(** [array::sum2]: decreases clause *) -unfold -let sum2_loop_decreases (s : slice u32) (s2 : slice u32) (sum0 : u32) - (i : usize) : nat = - admit () - -(** [array::sum2]: loop 0: forward function *) -let rec sum2_loop - (s : slice u32) (s2 : slice u32) (sum0 : u32) (i : usize) : - Tot (result u32) (decreases (sum2_loop_decreases s s2 sum0 i)) - = - let i0 = slice_len u32 s in - if i < i0 - then - let* i1 = slice_index_usize u32 s i in - let* i2 = slice_index_usize u32 s2 i in - let* i3 = u32_add i1 i2 in - let* sum1 = u32_add sum0 i3 in - let* i4 = usize_add i 1 in - sum2_loop s s2 sum1 i4 - else Return sum0 - -(** [array::sum2]: forward function *) -let sum2 (s : slice u32) (s2 : slice u32) : result u32 = - let i = slice_len u32 s in - let i0 = slice_len u32 s2 in - if not (i = i0) then Fail Failure else sum2_loop s s2 0 0 - -(** [array::f0]: forward function *) -let f0 : result unit = - let* s = array_to_slice u32 2 (mk_array u32 2 [ 1; 2 ]) in - let* s0 = slice_update_usize u32 s 0 1 in - let* _ = array_from_slice u32 2 (mk_array u32 2 [ 1; 2 ]) s0 in - Return () - -(** [array::f1]: forward function *) -let f1 : result unit = - let* _ = array_update_usize u32 2 (mk_array u32 2 [ 1; 2 ]) 0 1 in Return () - -(** [array::f2]: forward function *) -let f2 (i : u32) : result unit = - Return () - -(** [array::f4]: forward function *) -let f4 (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = - core_array_Array_index u32 (core_ops_range_Range usize) 32 - (core_slice_index_Slice_coreopsindexIndexInst u32 (core_ops_range_Range - usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x - { start = y; end_ = z } - -(** [array::f3]: forward function *) -let f3 : result u32 = - let* i = array_index_usize u32 2 (mk_array u32 2 [ 1; 2 ]) 0 in - let* _ = f2 i in - let b = array_repeat u32 32 0 in - let* s = array_to_slice u32 2 (mk_array u32 2 [ 1; 2 ]) in - let* s0 = f4 b 16 18 in - sum2 s s0 - -(** [array::SZ] *) -let sz_body : result usize = Return 32 -let sz_c : usize = eval_global sz_body - -(** [array::f5]: forward function *) -let f5 (x : array u32 32) : result u32 = - array_index_usize u32 32 x 0 - -(** [array::ite]: forward function *) -let ite : result unit = - let* s = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in - let* s0 = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in - let* s1 = index_mut_slice_u32_0_back s0 in - let* _ = array_from_slice u32 2 (mk_array u32 2 [ 0; 0 ]) s1 in - let* s2 = index_mut_slice_u32_0_back s in - let* _ = array_from_slice u32 2 (mk_array u32 2 [ 0; 0 ]) s2 in - Return () - -- 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 --- tests/fstar/array/Array.Opaque.fsti | 24 ------------------------ tests/fstar/array/Primitives.fst | 18 +++++++++++++++++- 2 files changed, 17 insertions(+), 25 deletions(-) delete mode 100644 tests/fstar/array/Array.Opaque.fsti (limited to 'tests/fstar/array') diff --git a/tests/fstar/array/Array.Opaque.fsti b/tests/fstar/array/Array.Opaque.fsti deleted file mode 100644 index 484cb9ee..00000000 --- a/tests/fstar/array/Array.Opaque.fsti +++ /dev/null @@ -1,24 +0,0 @@ -(** THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS *) -(** [array]: external function declarations *) -module Array.Opaque -open Primitives -include Array.Types - -#set-options "--z3rlimit 50 --fuel 1 --ifuel 1" - -(** [core::array::[T; N]::{15}::index]: forward function *) -val core_array_[T; N]_index_fwd - (t i : Type0) (n : usize) (inst : core_ops_index_Index (slice t) i) : - array t n -> i -> result inst.core_ops_index_Index_Output - -(** [core::array::[T; N]::{16}::index_mut]: forward function *) -val core_array_[T; N]_index_mut_fwd - (t i : Type0) (n : usize) (inst : core_ops_index_IndexMut (slice t) i) : - array t n -> i -> result inst.index_inst.core_ops_index_Index_Output - -(** [core::array::[T; N]::{16}::index_mut]: backward function 0 *) -val core_array_[T; N]_index_mut_back - (t i : Type0) (n : usize) (inst : core_ops_index_IndexMut (slice t) i) : - array t n -> i -> inst.index_inst.core_ops_index_Index_Output -> result - (array t n) - diff --git a/tests/fstar/array/Primitives.fst b/tests/fstar/array/Primitives.fst index 71d75c11..3297803c 100644 --- a/tests/fstar/array/Primitives.fst +++ b/tests/fstar/array/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 --- tests/fstar/array/Array.Funs.fst | 32 +++++++-------- tests/fstar/array/Primitives.fst | 88 ++++++++++++++++++++-------------------- 2 files changed, 59 insertions(+), 61 deletions(-) (limited to 'tests/fstar/array') diff --git a/tests/fstar/array/Array.Funs.fst b/tests/fstar/array/Array.Funs.fst index 8f0bfbbd..50fff38d 100644 --- a/tests/fstar/array/Array.Funs.fst +++ b/tests/fstar/array/Array.Funs.fst @@ -75,14 +75,14 @@ let index_mut_slice_back let slice_subslice_shared_ (x : slice u32) (y : usize) (z : usize) : result (slice u32) = core_slice_index_Slice_index u32 (core_ops_range_Range usize) - (core_slice_index_Range_coresliceindexSliceIndexInst u32) x + (core_slice_index_SliceIndexRangeUsizeSliceTInst u32) x { start = y; end_ = z } (** [array::slice_subslice_mut_]: forward function *) let slice_subslice_mut_ (x : slice u32) (y : usize) (z : usize) : result (slice u32) = core_slice_index_Slice_index_mut u32 (core_ops_range_Range usize) - (core_slice_index_Range_coresliceindexSliceIndexInst u32) x + (core_slice_index_SliceIndexRangeUsizeSliceTInst u32) x { start = y; end_ = z } (** [array::slice_subslice_mut_]: backward function 0 *) @@ -91,7 +91,7 @@ let slice_subslice_mut__back result (slice u32) = core_slice_index_Slice_index_mut_back u32 (core_ops_range_Range usize) - (core_slice_index_Range_coresliceindexSliceIndexInst u32) x + (core_slice_index_SliceIndexRangeUsizeSliceTInst u32) x { start = y; end_ = z } ret (** [array::array_to_slice_shared_]: forward function *) @@ -111,16 +111,16 @@ let array_to_slice_mut__back let array_subslice_shared_ (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = core_array_Array_index u32 (core_ops_range_Range usize) 32 - (core_slice_index_Slice_coreopsindexIndexInst u32 (core_ops_range_Range - usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x + (core_ops_index_IndexSliceTIInst u32 (core_ops_range_Range usize) + (core_slice_index_SliceIndexRangeUsizeSliceTInst u32)) x { start = y; end_ = z } (** [array::array_subslice_mut_]: forward function *) let array_subslice_mut_ (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = core_array_Array_index_mut u32 (core_ops_range_Range usize) 32 - (core_slice_index_Slice_coreopsindexIndexMutInst u32 (core_ops_range_Range - usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x + (core_ops_index_IndexMutSliceTIInst u32 (core_ops_range_Range usize) + (core_slice_index_SliceIndexRangeUsizeSliceTInst u32)) x { start = y; end_ = z } (** [array::array_subslice_mut_]: backward function 0 *) @@ -129,8 +129,8 @@ let array_subslice_mut__back result (array u32 32) = core_array_Array_index_mut_back u32 (core_ops_range_Range usize) 32 - (core_slice_index_Slice_coreopsindexIndexMutInst u32 (core_ops_range_Range - usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x + (core_ops_index_IndexMutSliceTIInst u32 (core_ops_range_Range usize) + (core_slice_index_SliceIndexRangeUsizeSliceTInst u32)) x { start = y; end_ = z } ret (** [array::index_slice_0]: forward function *) @@ -251,16 +251,14 @@ let update_all : result unit = let range_all : result unit = let* s = core_array_Array_index_mut u32 (core_ops_range_Range usize) 4 - (core_slice_index_Slice_coreopsindexIndexMutInst u32 - (core_ops_range_Range usize) - (core_slice_index_Range_coresliceindexSliceIndexInst u32)) + (core_ops_index_IndexMutSliceTIInst u32 (core_ops_range_Range usize) + (core_slice_index_SliceIndexRangeUsizeSliceTInst u32)) (mk_array u32 4 [ 0; 0; 0; 0 ]) { start = 1; end_ = 3 } in let* s0 = update_mut_slice s in let* _ = core_array_Array_index_mut_back u32 (core_ops_range_Range usize) 4 - (core_slice_index_Slice_coreopsindexIndexMutInst u32 - (core_ops_range_Range usize) - (core_slice_index_Range_coresliceindexSliceIndexInst u32)) + (core_ops_index_IndexMutSliceTIInst u32 (core_ops_range_Range usize) + (core_slice_index_SliceIndexRangeUsizeSliceTInst u32)) (mk_array u32 4 [ 0; 0; 0; 0 ]) { start = 1; end_ = 3 } s0 in Return () @@ -342,8 +340,8 @@ let f2 (i : u32) : result unit = (** [array::f4]: forward function *) let f4 (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = core_array_Array_index u32 (core_ops_range_Range usize) 32 - (core_slice_index_Slice_coreopsindexIndexInst u32 (core_ops_range_Range - usize) (core_slice_index_Range_coresliceindexSliceIndexInst u32)) x + (core_ops_index_IndexSliceTIInst u32 (core_ops_range_Range usize) + (core_slice_index_SliceIndexRangeUsizeSliceTInst u32)) x { start = y; end_ = z } (** [array::f3]: forward function *) diff --git a/tests/fstar/array/Primitives.fst b/tests/fstar/array/Primitives.fst index 3297803c..94322ead 100644 --- a/tests/fstar/array/Primitives.fst +++ b/tests/fstar/array/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 --- tests/fstar/array/Array.Clauses.Template.fst | 6 +- tests/fstar/array/Array.Funs.fst | 186 ++++++++++++++++++--------- tests/fstar/array/Array.Types.fst | 3 +- 3 files changed, 130 insertions(+), 65 deletions(-) (limited to 'tests/fstar/array') diff --git a/tests/fstar/array/Array.Clauses.Template.fst b/tests/fstar/array/Array.Clauses.Template.fst index 06056d61..08a2925f 100644 --- a/tests/fstar/array/Array.Clauses.Template.fst +++ b/tests/fstar/array/Array.Clauses.Template.fst @@ -6,12 +6,14 @@ open Array.Types #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" -(** [array::sum]: decreases clause *) +(** [array::sum]: decreases clause + Source: 'src/array.rs', lines 228:0-236:1 *) unfold let sum_loop_decreases (s : slice u32) (sum0 : u32) (i : usize) : nat = admit () -(** [array::sum2]: decreases clause *) +(** [array::sum2]: decreases clause + Source: 'src/array.rs', lines 238:0-247:1 *) unfold let sum2_loop_decreases (s : slice u32) (s2 : slice u32) (sum0 : u32) (i : usize) : nat = diff --git a/tests/fstar/array/Array.Funs.fst b/tests/fstar/array/Array.Funs.fst index 50fff38d..a8722a4f 100644 --- a/tests/fstar/array/Array.Funs.fst +++ b/tests/fstar/array/Array.Funs.fst @@ -8,84 +8,102 @@ include Array.Clauses #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" (** [array::incr]: 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/array.rs', lines 8:0-8:24 *) let incr (x : u32) : result u32 = u32_add x 1 -(** [array::array_to_shared_slice_]: forward function *) +(** [array::array_to_shared_slice_]: forward function + Source: 'src/array.rs', lines 16:0-16:53 *) let array_to_shared_slice_ (t : Type0) (s : array t 32) : result (slice t) = array_to_slice t 32 s -(** [array::array_to_mut_slice_]: forward function *) +(** [array::array_to_mut_slice_]: forward function + Source: 'src/array.rs', lines 21:0-21:58 *) let array_to_mut_slice_ (t : Type0) (s : array t 32) : result (slice t) = array_to_slice t 32 s -(** [array::array_to_mut_slice_]: backward function 0 *) +(** [array::array_to_mut_slice_]: backward function 0 + Source: 'src/array.rs', lines 21:0-21:58 *) let array_to_mut_slice__back (t : Type0) (s : array t 32) (ret : slice t) : result (array t 32) = array_from_slice t 32 s ret -(** [array::array_len]: forward function *) +(** [array::array_len]: forward function + Source: 'src/array.rs', lines 25:0-25:40 *) let array_len (t : Type0) (s : array t 32) : result usize = let* s0 = array_to_slice t 32 s in let i = slice_len t s0 in Return i -(** [array::shared_array_len]: forward function *) +(** [array::shared_array_len]: forward function + Source: 'src/array.rs', lines 29:0-29:48 *) let shared_array_len (t : Type0) (s : array t 32) : result usize = let* s0 = array_to_slice t 32 s in let i = slice_len t s0 in Return i -(** [array::shared_slice_len]: forward function *) +(** [array::shared_slice_len]: forward function + Source: 'src/array.rs', lines 33:0-33:44 *) let shared_slice_len (t : Type0) (s : slice t) : result usize = let i = slice_len t s in Return i -(** [array::index_array_shared]: forward function *) +(** [array::index_array_shared]: forward function + Source: 'src/array.rs', lines 37:0-37:57 *) let index_array_shared (t : Type0) (s : array t 32) (i : usize) : result t = array_index_usize t 32 s i -(** [array::index_array_u32]: forward function *) +(** [array::index_array_u32]: forward function + Source: 'src/array.rs', lines 44:0-44:53 *) let index_array_u32 (s : array u32 32) (i : usize) : result u32 = array_index_usize u32 32 s i -(** [array::index_array_copy]: forward function *) +(** [array::index_array_copy]: forward function + Source: 'src/array.rs', lines 48:0-48:45 *) let index_array_copy (x : array u32 32) : result u32 = array_index_usize u32 32 x 0 -(** [array::index_mut_array]: forward function *) +(** [array::index_mut_array]: forward function + Source: 'src/array.rs', lines 52:0-52:62 *) let index_mut_array (t : Type0) (s : array t 32) (i : usize) : result t = array_index_usize t 32 s i -(** [array::index_mut_array]: backward function 0 *) +(** [array::index_mut_array]: backward function 0 + Source: 'src/array.rs', lines 52:0-52:62 *) let index_mut_array_back (t : Type0) (s : array t 32) (i : usize) (ret : t) : result (array t 32) = array_update_usize t 32 s i ret -(** [array::index_slice]: forward function *) +(** [array::index_slice]: forward function + Source: 'src/array.rs', lines 56:0-56:46 *) let index_slice (t : Type0) (s : slice t) (i : usize) : result t = slice_index_usize t s i -(** [array::index_mut_slice]: forward function *) +(** [array::index_mut_slice]: forward function + Source: 'src/array.rs', lines 60:0-60:58 *) let index_mut_slice (t : Type0) (s : slice t) (i : usize) : result t = slice_index_usize t s i -(** [array::index_mut_slice]: backward function 0 *) +(** [array::index_mut_slice]: backward function 0 + Source: 'src/array.rs', lines 60:0-60:58 *) let index_mut_slice_back (t : Type0) (s : slice t) (i : usize) (ret : t) : result (slice t) = slice_update_usize t s i ret -(** [array::slice_subslice_shared_]: forward function *) +(** [array::slice_subslice_shared_]: forward function + Source: 'src/array.rs', lines 64:0-64:70 *) let slice_subslice_shared_ (x : slice u32) (y : usize) (z : usize) : result (slice u32) = core_slice_index_Slice_index u32 (core_ops_range_Range usize) (core_slice_index_SliceIndexRangeUsizeSliceTInst u32) x { start = y; end_ = z } -(** [array::slice_subslice_mut_]: forward function *) +(** [array::slice_subslice_mut_]: forward function + Source: 'src/array.rs', lines 68:0-68:75 *) let slice_subslice_mut_ (x : slice u32) (y : usize) (z : usize) : result (slice u32) = core_slice_index_Slice_index_mut u32 (core_ops_range_Range usize) (core_slice_index_SliceIndexRangeUsizeSliceTInst u32) x { start = y; end_ = z } -(** [array::slice_subslice_mut_]: backward function 0 *) +(** [array::slice_subslice_mut_]: backward function 0 + Source: 'src/array.rs', lines 68:0-68:75 *) let slice_subslice_mut__back (x : slice u32) (y : usize) (z : usize) (ret : slice u32) : result (slice u32) @@ -94,20 +112,24 @@ let slice_subslice_mut__back (core_slice_index_SliceIndexRangeUsizeSliceTInst u32) x { start = y; end_ = z } ret -(** [array::array_to_slice_shared_]: forward function *) +(** [array::array_to_slice_shared_]: forward function + Source: 'src/array.rs', lines 72:0-72:54 *) let array_to_slice_shared_ (x : array u32 32) : result (slice u32) = array_to_slice u32 32 x -(** [array::array_to_slice_mut_]: forward function *) +(** [array::array_to_slice_mut_]: forward function + Source: 'src/array.rs', lines 76:0-76:59 *) let array_to_slice_mut_ (x : array u32 32) : result (slice u32) = array_to_slice u32 32 x -(** [array::array_to_slice_mut_]: backward function 0 *) +(** [array::array_to_slice_mut_]: backward function 0 + Source: 'src/array.rs', lines 76:0-76:59 *) let array_to_slice_mut__back (x : array u32 32) (ret : slice u32) : result (array u32 32) = array_from_slice u32 32 x ret -(** [array::array_subslice_shared_]: forward function *) +(** [array::array_subslice_shared_]: forward function + Source: 'src/array.rs', lines 80:0-80:74 *) let array_subslice_shared_ (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = core_array_Array_index u32 (core_ops_range_Range usize) 32 @@ -115,7 +137,8 @@ let array_subslice_shared_ (core_slice_index_SliceIndexRangeUsizeSliceTInst u32)) x { start = y; end_ = z } -(** [array::array_subslice_mut_]: forward function *) +(** [array::array_subslice_mut_]: forward function + Source: 'src/array.rs', lines 84:0-84:79 *) let array_subslice_mut_ (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = core_array_Array_index_mut u32 (core_ops_range_Range usize) 32 @@ -123,7 +146,8 @@ let array_subslice_mut_ (core_slice_index_SliceIndexRangeUsizeSliceTInst u32)) x { start = y; end_ = z } -(** [array::array_subslice_mut_]: backward function 0 *) +(** [array::array_subslice_mut_]: backward function 0 + Source: 'src/array.rs', lines 84:0-84:79 *) let array_subslice_mut__back (x : array u32 32) (y : usize) (z : usize) (ret : slice u32) : result (array u32 32) @@ -133,21 +157,25 @@ let array_subslice_mut__back (core_slice_index_SliceIndexRangeUsizeSliceTInst u32)) x { start = y; end_ = z } ret -(** [array::index_slice_0]: forward function *) +(** [array::index_slice_0]: forward function + Source: 'src/array.rs', lines 88:0-88:38 *) let index_slice_0 (t : Type0) (s : slice t) : result t = slice_index_usize t s 0 -(** [array::index_array_0]: forward function *) +(** [array::index_array_0]: forward function + Source: 'src/array.rs', lines 92:0-92:42 *) let index_array_0 (t : Type0) (s : array t 32) : result t = array_index_usize t 32 s 0 -(** [array::index_index_array]: forward function *) +(** [array::index_index_array]: forward function + Source: 'src/array.rs', lines 103:0-103:71 *) let index_index_array (s : array (array u32 32) 32) (i : usize) (j : usize) : result u32 = let* a = array_index_usize (array u32 32) 32 s i in array_index_usize u32 32 a j -(** [array::update_update_array]: forward function *) +(** [array::update_update_array]: forward function + Source: 'src/array.rs', lines 114:0-114:70 *) let update_update_array (s : array (array u32 32) 32) (i : usize) (j : usize) : result unit = let* a = array_index_usize (array u32 32) 32 s i in @@ -155,28 +183,34 @@ let update_update_array let* _ = array_update_usize (array u32 32) 32 s i a0 in Return () -(** [array::array_local_deep_copy]: forward function *) +(** [array::array_local_deep_copy]: forward function + Source: 'src/array.rs', lines 118:0-118:43 *) let array_local_deep_copy (x : array u32 32) : result unit = Return () -(** [array::take_array]: forward function *) +(** [array::take_array]: forward function + Source: 'src/array.rs', lines 122:0-122:30 *) let take_array (a : array u32 2) : result unit = Return () -(** [array::take_array_borrow]: forward function *) +(** [array::take_array_borrow]: forward function + Source: 'src/array.rs', lines 123:0-123:38 *) let take_array_borrow (a : array u32 2) : result unit = Return () -(** [array::take_slice]: forward function *) +(** [array::take_slice]: forward function + Source: 'src/array.rs', lines 124:0-124:28 *) let take_slice (s : slice u32) : result unit = Return () (** [array::take_mut_slice]: 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/array.rs', lines 125:0-125:36 *) let take_mut_slice (s : slice u32) : result (slice u32) = Return s -(** [array::take_all]: forward function *) +(** [array::take_all]: forward function + Source: 'src/array.rs', lines 127:0-127:17 *) let take_all : result unit = let* _ = take_array (mk_array u32 2 [ 0; 0 ]) in let* _ = take_array_borrow (mk_array u32 2 [ 0; 0 ]) in @@ -187,27 +221,33 @@ let take_all : result unit = let* _ = array_from_slice u32 2 (mk_array u32 2 [ 0; 0 ]) s1 in Return () -(** [array::index_array]: forward function *) +(** [array::index_array]: forward function + Source: 'src/array.rs', lines 141:0-141:38 *) let index_array (x : array u32 2) : result u32 = array_index_usize u32 2 x 0 -(** [array::index_array_borrow]: forward function *) +(** [array::index_array_borrow]: forward function + Source: 'src/array.rs', lines 144:0-144:46 *) let index_array_borrow (x : array u32 2) : result u32 = array_index_usize u32 2 x 0 -(** [array::index_slice_u32_0]: forward function *) +(** [array::index_slice_u32_0]: forward function + Source: 'src/array.rs', lines 148:0-148:42 *) let index_slice_u32_0 (x : slice u32) : result u32 = slice_index_usize u32 x 0 -(** [array::index_mut_slice_u32_0]: forward function *) +(** [array::index_mut_slice_u32_0]: forward function + Source: 'src/array.rs', lines 152:0-152:50 *) let index_mut_slice_u32_0 (x : slice u32) : result u32 = slice_index_usize u32 x 0 -(** [array::index_mut_slice_u32_0]: backward function 0 *) +(** [array::index_mut_slice_u32_0]: backward function 0 + Source: 'src/array.rs', lines 152:0-152:50 *) let index_mut_slice_u32_0_back (x : slice u32) : result (slice u32) = let* _ = slice_index_usize u32 x 0 in Return x -(** [array::index_all]: forward function *) +(** [array::index_all]: forward function + Source: 'src/array.rs', lines 156:0-156:25 *) let index_all : result u32 = let* i = index_array (mk_array u32 2 [ 0; 0 ]) in let* i0 = index_array (mk_array u32 2 [ 0; 0 ]) in @@ -224,21 +264,25 @@ let index_all : result u32 = let* _ = array_from_slice u32 2 (mk_array u32 2 [ 0; 0 ]) s1 in Return i7 -(** [array::update_array]: forward function *) +(** [array::update_array]: forward function + Source: 'src/array.rs', lines 170:0-170:36 *) let update_array (x : array u32 2) : result unit = let* _ = array_update_usize u32 2 x 0 1 in Return () (** [array::update_array_mut_borrow]: 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/array.rs', lines 173:0-173:48 *) let update_array_mut_borrow (x : array u32 2) : result (array u32 2) = array_update_usize u32 2 x 0 1 (** [array::update_mut_slice]: 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/array.rs', lines 176:0-176:38 *) let update_mut_slice (x : slice u32) : result (slice u32) = slice_update_usize u32 x 0 1 -(** [array::update_all]: forward function *) +(** [array::update_all]: forward function + Source: 'src/array.rs', lines 180:0-180:19 *) let update_all : result unit = let* _ = update_array (mk_array u32 2 [ 0; 0 ]) in let* x = update_array_mut_borrow (mk_array u32 2 [ 0; 0 ]) in @@ -247,7 +291,8 @@ let update_all : result unit = let* _ = array_from_slice u32 2 x s0 in Return () -(** [array::range_all]: forward function *) +(** [array::range_all]: forward function + Source: 'src/array.rs', lines 191:0-191:18 *) let range_all : result unit = let* s = core_array_Array_index_mut u32 (core_ops_range_Range usize) 4 @@ -262,27 +307,33 @@ let range_all : result unit = (mk_array u32 4 [ 0; 0; 0; 0 ]) { start = 1; end_ = 3 } s0 in Return () -(** [array::deref_array_borrow]: forward function *) +(** [array::deref_array_borrow]: forward function + Source: 'src/array.rs', lines 200:0-200:46 *) let deref_array_borrow (x : array u32 2) : result u32 = array_index_usize u32 2 x 0 -(** [array::deref_array_mut_borrow]: forward function *) +(** [array::deref_array_mut_borrow]: forward function + Source: 'src/array.rs', lines 205:0-205:54 *) let deref_array_mut_borrow (x : array u32 2) : result u32 = array_index_usize u32 2 x 0 -(** [array::deref_array_mut_borrow]: backward function 0 *) +(** [array::deref_array_mut_borrow]: backward function 0 + Source: 'src/array.rs', lines 205:0-205:54 *) let deref_array_mut_borrow_back (x : array u32 2) : result (array u32 2) = let* _ = array_index_usize u32 2 x 0 in Return x -(** [array::take_array_t]: forward function *) +(** [array::take_array_t]: forward function + Source: 'src/array.rs', lines 213:0-213:31 *) let take_array_t (a : array aB_t 2) : result unit = Return () -(** [array::non_copyable_array]: forward function *) +(** [array::non_copyable_array]: forward function + Source: 'src/array.rs', lines 215:0-215:27 *) let non_copyable_array : result unit = let* _ = take_array_t (mk_array aB_t 2 [ AB_A; AB_B ]) in Return () -(** [array::sum]: loop 0: forward function *) +(** [array::sum]: loop 0: forward function + Source: 'src/array.rs', lines 228:0-236:1 *) let rec sum_loop (s : slice u32) (sum0 : u32) (i : usize) : Tot (result u32) (decreases (sum_loop_decreases s sum0 i)) @@ -296,11 +347,13 @@ let rec sum_loop sum_loop s sum1 i2 else Return sum0 -(** [array::sum]: forward function *) +(** [array::sum]: forward function + Source: 'src/array.rs', lines 228:0-228:28 *) let sum (s : slice u32) : result u32 = sum_loop s 0 0 -(** [array::sum2]: loop 0: forward function *) +(** [array::sum2]: loop 0: forward function + Source: 'src/array.rs', lines 238:0-247:1 *) let rec sum2_loop (s : slice u32) (s2 : slice u32) (sum0 : u32) (i : usize) : Tot (result u32) (decreases (sum2_loop_decreases s s2 sum0 i)) @@ -316,35 +369,41 @@ let rec sum2_loop sum2_loop s s2 sum1 i4 else Return sum0 -(** [array::sum2]: forward function *) +(** [array::sum2]: forward function + Source: 'src/array.rs', lines 238:0-238:41 *) let sum2 (s : slice u32) (s2 : slice u32) : result u32 = let i = slice_len u32 s in let i0 = slice_len u32 s2 in if not (i = i0) then Fail Failure else sum2_loop s s2 0 0 -(** [array::f0]: forward function *) +(** [array::f0]: forward function + Source: 'src/array.rs', lines 249:0-249:11 *) let f0 : result unit = let* s = array_to_slice u32 2 (mk_array u32 2 [ 1; 2 ]) in let* s0 = slice_update_usize u32 s 0 1 in let* _ = array_from_slice u32 2 (mk_array u32 2 [ 1; 2 ]) s0 in Return () -(** [array::f1]: forward function *) +(** [array::f1]: forward function + Source: 'src/array.rs', lines 254:0-254:11 *) let f1 : result unit = let* _ = array_update_usize u32 2 (mk_array u32 2 [ 1; 2 ]) 0 1 in Return () -(** [array::f2]: forward function *) +(** [array::f2]: forward function + Source: 'src/array.rs', lines 259:0-259:17 *) let f2 (i : u32) : result unit = Return () -(** [array::f4]: forward function *) +(** [array::f4]: forward function + Source: 'src/array.rs', lines 268:0-268:54 *) let f4 (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = core_array_Array_index u32 (core_ops_range_Range usize) 32 (core_ops_index_IndexSliceTIInst u32 (core_ops_range_Range usize) (core_slice_index_SliceIndexRangeUsizeSliceTInst u32)) x { start = y; end_ = z } -(** [array::f3]: forward function *) +(** [array::f3]: forward function + Source: 'src/array.rs', lines 261:0-261:18 *) let f3 : result u32 = let* i = array_index_usize u32 2 (mk_array u32 2 [ 1; 2 ]) 0 in let* _ = f2 i in @@ -353,15 +412,18 @@ let f3 : result u32 = let* s0 = f4 b 16 18 in sum2 s s0 -(** [array::SZ] *) +(** [array::SZ] + Source: 'src/array.rs', lines 272:0-272:19 *) let sz_body : result usize = Return 32 let sz_c : usize = eval_global sz_body -(** [array::f5]: forward function *) +(** [array::f5]: forward function + Source: 'src/array.rs', lines 275:0-275:31 *) let f5 (x : array u32 32) : result u32 = array_index_usize u32 32 x 0 -(** [array::ite]: forward function *) +(** [array::ite]: forward function + Source: 'src/array.rs', lines 280:0-280:12 *) let ite : result unit = let* s = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in let* s0 = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in diff --git a/tests/fstar/array/Array.Types.fst b/tests/fstar/array/Array.Types.fst index 4e8d5566..312f6018 100644 --- a/tests/fstar/array/Array.Types.fst +++ b/tests/fstar/array/Array.Types.fst @@ -5,6 +5,7 @@ open Primitives #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" -(** [array::AB] *) +(** [array::AB] + Source: 'src/array.rs', lines 3:0-3:11 *) type aB_t = | AB_A : aB_t | AB_B : aB_t -- cgit v1.2.3 From 94efdf274eb11f4f1ba9a510eb3dd6e190cfc507 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Wed, 29 Nov 2023 12:50:45 +0100 Subject: Regenerate the tests --- tests/fstar/array/Array.Clauses.Template.fst | 4 +- tests/fstar/array/Array.Funs.fst | 68 ++++++++++++++++------------ 2 files changed, 41 insertions(+), 31 deletions(-) (limited to 'tests/fstar/array') diff --git a/tests/fstar/array/Array.Clauses.Template.fst b/tests/fstar/array/Array.Clauses.Template.fst index 08a2925f..84347ab9 100644 --- a/tests/fstar/array/Array.Clauses.Template.fst +++ b/tests/fstar/array/Array.Clauses.Template.fst @@ -7,13 +7,13 @@ open Array.Types #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" (** [array::sum]: decreases clause - Source: 'src/array.rs', lines 228:0-236:1 *) + Source: 'src/array.rs', lines 242:0-250:1 *) unfold let sum_loop_decreases (s : slice u32) (sum0 : u32) (i : usize) : nat = admit () (** [array::sum2]: decreases clause - Source: 'src/array.rs', lines 238:0-247:1 *) + Source: 'src/array.rs', lines 252:0-261:1 *) unfold let sum2_loop_decreases (s : slice u32) (s2 : slice u32) (sum0 : u32) (i : usize) : nat = diff --git a/tests/fstar/array/Array.Funs.fst b/tests/fstar/array/Array.Funs.fst index a8722a4f..935bd9c9 100644 --- a/tests/fstar/array/Array.Funs.fst +++ b/tests/fstar/array/Array.Funs.fst @@ -209,8 +209,18 @@ let take_slice (s : slice u32) : result unit = let take_mut_slice (s : slice u32) : result (slice u32) = Return s +(** [array::const_array]: forward function + Source: 'src/array.rs', lines 127:0-127:32 *) +let const_array : result (array u32 2) = + Return (mk_array u32 2 [ 0; 0 ]) + +(** [array::const_slice]: forward function + Source: 'src/array.rs', lines 131:0-131:20 *) +let const_slice : result unit = + let* _ = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in Return () + (** [array::take_all]: forward function - Source: 'src/array.rs', lines 127:0-127:17 *) + Source: 'src/array.rs', lines 141:0-141:17 *) let take_all : result unit = let* _ = take_array (mk_array u32 2 [ 0; 0 ]) in let* _ = take_array_borrow (mk_array u32 2 [ 0; 0 ]) in @@ -222,32 +232,32 @@ let take_all : result unit = Return () (** [array::index_array]: forward function - Source: 'src/array.rs', lines 141:0-141:38 *) + Source: 'src/array.rs', lines 155:0-155:38 *) let index_array (x : array u32 2) : result u32 = array_index_usize u32 2 x 0 (** [array::index_array_borrow]: forward function - Source: 'src/array.rs', lines 144:0-144:46 *) + Source: 'src/array.rs', lines 158:0-158:46 *) let index_array_borrow (x : array u32 2) : result u32 = array_index_usize u32 2 x 0 (** [array::index_slice_u32_0]: forward function - Source: 'src/array.rs', lines 148:0-148:42 *) + Source: 'src/array.rs', lines 162:0-162:42 *) let index_slice_u32_0 (x : slice u32) : result u32 = slice_index_usize u32 x 0 (** [array::index_mut_slice_u32_0]: forward function - Source: 'src/array.rs', lines 152:0-152:50 *) + Source: 'src/array.rs', lines 166:0-166:50 *) let index_mut_slice_u32_0 (x : slice u32) : result u32 = slice_index_usize u32 x 0 (** [array::index_mut_slice_u32_0]: backward function 0 - Source: 'src/array.rs', lines 152:0-152:50 *) + Source: 'src/array.rs', lines 166:0-166:50 *) let index_mut_slice_u32_0_back (x : slice u32) : result (slice u32) = let* _ = slice_index_usize u32 x 0 in Return x (** [array::index_all]: forward function - Source: 'src/array.rs', lines 156:0-156:25 *) + Source: 'src/array.rs', lines 170:0-170:25 *) let index_all : result u32 = let* i = index_array (mk_array u32 2 [ 0; 0 ]) in let* i0 = index_array (mk_array u32 2 [ 0; 0 ]) in @@ -265,24 +275,24 @@ let index_all : result u32 = Return i7 (** [array::update_array]: forward function - Source: 'src/array.rs', lines 170:0-170:36 *) + Source: 'src/array.rs', lines 184:0-184:36 *) let update_array (x : array u32 2) : result unit = let* _ = array_update_usize u32 2 x 0 1 in Return () (** [array::update_array_mut_borrow]: merged forward/backward function (there is a single backward function, and the forward function returns ()) - Source: 'src/array.rs', lines 173:0-173:48 *) + Source: 'src/array.rs', lines 187:0-187:48 *) let update_array_mut_borrow (x : array u32 2) : result (array u32 2) = array_update_usize u32 2 x 0 1 (** [array::update_mut_slice]: merged forward/backward function (there is a single backward function, and the forward function returns ()) - Source: 'src/array.rs', lines 176:0-176:38 *) + Source: 'src/array.rs', lines 190:0-190:38 *) let update_mut_slice (x : slice u32) : result (slice u32) = slice_update_usize u32 x 0 1 (** [array::update_all]: forward function - Source: 'src/array.rs', lines 180:0-180:19 *) + Source: 'src/array.rs', lines 194:0-194:19 *) let update_all : result unit = let* _ = update_array (mk_array u32 2 [ 0; 0 ]) in let* x = update_array_mut_borrow (mk_array u32 2 [ 0; 0 ]) in @@ -292,7 +302,7 @@ let update_all : result unit = Return () (** [array::range_all]: forward function - Source: 'src/array.rs', lines 191:0-191:18 *) + Source: 'src/array.rs', lines 205:0-205:18 *) let range_all : result unit = let* s = core_array_Array_index_mut u32 (core_ops_range_Range usize) 4 @@ -308,32 +318,32 @@ let range_all : result unit = Return () (** [array::deref_array_borrow]: forward function - Source: 'src/array.rs', lines 200:0-200:46 *) + Source: 'src/array.rs', lines 214:0-214:46 *) let deref_array_borrow (x : array u32 2) : result u32 = array_index_usize u32 2 x 0 (** [array::deref_array_mut_borrow]: forward function - Source: 'src/array.rs', lines 205:0-205:54 *) + Source: 'src/array.rs', lines 219:0-219:54 *) let deref_array_mut_borrow (x : array u32 2) : result u32 = array_index_usize u32 2 x 0 (** [array::deref_array_mut_borrow]: backward function 0 - Source: 'src/array.rs', lines 205:0-205:54 *) + Source: 'src/array.rs', lines 219:0-219:54 *) let deref_array_mut_borrow_back (x : array u32 2) : result (array u32 2) = let* _ = array_index_usize u32 2 x 0 in Return x (** [array::take_array_t]: forward function - Source: 'src/array.rs', lines 213:0-213:31 *) + Source: 'src/array.rs', lines 227:0-227:31 *) let take_array_t (a : array aB_t 2) : result unit = Return () (** [array::non_copyable_array]: forward function - Source: 'src/array.rs', lines 215:0-215:27 *) + Source: 'src/array.rs', lines 229:0-229:27 *) let non_copyable_array : result unit = let* _ = take_array_t (mk_array aB_t 2 [ AB_A; AB_B ]) in Return () (** [array::sum]: loop 0: forward function - Source: 'src/array.rs', lines 228:0-236:1 *) + Source: 'src/array.rs', lines 242:0-250:1 *) let rec sum_loop (s : slice u32) (sum0 : u32) (i : usize) : Tot (result u32) (decreases (sum_loop_decreases s sum0 i)) @@ -348,12 +358,12 @@ let rec sum_loop else Return sum0 (** [array::sum]: forward function - Source: 'src/array.rs', lines 228:0-228:28 *) + Source: 'src/array.rs', lines 242:0-242:28 *) let sum (s : slice u32) : result u32 = sum_loop s 0 0 (** [array::sum2]: loop 0: forward function - Source: 'src/array.rs', lines 238:0-247:1 *) + Source: 'src/array.rs', lines 252:0-261:1 *) let rec sum2_loop (s : slice u32) (s2 : slice u32) (sum0 : u32) (i : usize) : Tot (result u32) (decreases (sum2_loop_decreases s s2 sum0 i)) @@ -370,14 +380,14 @@ let rec sum2_loop else Return sum0 (** [array::sum2]: forward function - Source: 'src/array.rs', lines 238:0-238:41 *) + Source: 'src/array.rs', lines 252:0-252:41 *) let sum2 (s : slice u32) (s2 : slice u32) : result u32 = let i = slice_len u32 s in let i0 = slice_len u32 s2 in if not (i = i0) then Fail Failure else sum2_loop s s2 0 0 (** [array::f0]: forward function - Source: 'src/array.rs', lines 249:0-249:11 *) + Source: 'src/array.rs', lines 263:0-263:11 *) let f0 : result unit = let* s = array_to_slice u32 2 (mk_array u32 2 [ 1; 2 ]) in let* s0 = slice_update_usize u32 s 0 1 in @@ -385,17 +395,17 @@ let f0 : result unit = Return () (** [array::f1]: forward function - Source: 'src/array.rs', lines 254:0-254:11 *) + Source: 'src/array.rs', lines 268:0-268:11 *) let f1 : result unit = let* _ = array_update_usize u32 2 (mk_array u32 2 [ 1; 2 ]) 0 1 in Return () (** [array::f2]: forward function - Source: 'src/array.rs', lines 259:0-259:17 *) + Source: 'src/array.rs', lines 273:0-273:17 *) let f2 (i : u32) : result unit = Return () (** [array::f4]: forward function - Source: 'src/array.rs', lines 268:0-268:54 *) + Source: 'src/array.rs', lines 282:0-282:54 *) let f4 (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = core_array_Array_index u32 (core_ops_range_Range usize) 32 (core_ops_index_IndexSliceTIInst u32 (core_ops_range_Range usize) @@ -403,7 +413,7 @@ let f4 (x : array u32 32) (y : usize) (z : usize) : result (slice u32) = { start = y; end_ = z } (** [array::f3]: forward function - Source: 'src/array.rs', lines 261:0-261:18 *) + Source: 'src/array.rs', lines 275:0-275:18 *) let f3 : result u32 = let* i = array_index_usize u32 2 (mk_array u32 2 [ 1; 2 ]) 0 in let* _ = f2 i in @@ -413,17 +423,17 @@ let f3 : result u32 = sum2 s s0 (** [array::SZ] - Source: 'src/array.rs', lines 272:0-272:19 *) + Source: 'src/array.rs', lines 286:0-286:19 *) let sz_body : result usize = Return 32 let sz_c : usize = eval_global sz_body (** [array::f5]: forward function - Source: 'src/array.rs', lines 275:0-275:31 *) + Source: 'src/array.rs', lines 289:0-289:31 *) let f5 (x : array u32 32) : result u32 = array_index_usize u32 32 x 0 (** [array::ite]: forward function - Source: 'src/array.rs', lines 280:0-280:12 *) + Source: 'src/array.rs', lines 294:0-294:12 *) let ite : result unit = let* s = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in let* s0 = array_to_slice u32 2 (mk_array u32 2 [ 0; 0 ]) in -- cgit v1.2.3 From 3b487893b2906e13b2388efc3512f2babc8514bf Mon Sep 17 00:00:00 2001 From: Son Ho Date: Wed, 29 Nov 2023 15:48:27 +0100 Subject: Regenerate the other files --- tests/fstar/array/Primitives.fst | 167 +++++++++++++++++++++++++++++++++++++-- 1 file changed, 159 insertions(+), 8 deletions(-) (limited to 'tests/fstar/array') diff --git a/tests/fstar/array/Primitives.fst b/tests/fstar/array/Primitives.fst index 94322ead..dd340c00 100644 --- a/tests/fstar/array/Primitives.fst +++ b/tests/fstar/array/Primitives.fst @@ -65,6 +65,10 @@ type const_raw_ptr (t : Type0) = { v : t } (*** Scalars *) /// Rem.: most of the following code was partially generated +assume val size_numbits : pos + +// TODO: we could use FStar.Int.int_t and FStar.UInt.int_t + let isize_min : int = -9223372036854775808 // TODO: should be opaque let isize_max : int = 9223372036854775807 // TODO: should be opaque let i8_min : int = -128 @@ -108,7 +112,6 @@ 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 @@ -171,7 +174,7 @@ 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 }) +let scalar_xor (#ty : scalar_ty) (x : scalar ty) (y : scalar ty) : scalar ty = match ty with | U8 -> FStar.UInt.logxor #8 x y @@ -179,6 +182,91 @@ let scalar_lxor (#ty : scalar_ty { is_unsigned ty && ty <> Usize }) | U32 -> FStar.UInt.logxor #32 x y | U64 -> FStar.UInt.logxor #64 x y | U128 -> FStar.UInt.logxor #128 x y + | Usize -> admit() // TODO + | I8 -> + // Encoding issues... + normalize_spec (FStar.Int.int_t 8); + normalize_spec (scalar I8); + FStar.Int.logxor #8 x y + | I16 -> + // Encoding issues... + normalize_spec (FStar.Int.int_t 16); + normalize_spec (scalar I16); + FStar.Int.logxor #16 x y + | I32 -> FStar.Int.logxor #32 x y + | I64 -> FStar.Int.logxor #64 x y + | I128 -> + // Encoding issues... + normalize_spec (FStar.Int.int_t 128); + normalize_spec (scalar I128); + FStar.Int.logxor #128 x y + | Isize -> admit() // TODO + +let scalar_or (#ty : scalar_ty) + (x : scalar ty) (y : scalar ty) : scalar ty = + match ty with + | U8 -> FStar.UInt.logor #8 x y + | U16 -> FStar.UInt.logor #16 x y + | U32 -> FStar.UInt.logor #32 x y + | U64 -> FStar.UInt.logor #64 x y + | U128 -> FStar.UInt.logor #128 x y + | Usize -> admit() // TODO + | I8 -> + // Encoding issues... + normalize_spec (FStar.Int.int_t 8); + normalize_spec (scalar I8); + FStar.Int.logor #8 x y + | I16 -> + // Encoding issues... + normalize_spec (FStar.Int.int_t 16); + normalize_spec (scalar I16); + FStar.Int.logor #16 x y + | I32 -> FStar.Int.logor #32 x y + | I64 -> FStar.Int.logor #64 x y + | I128 -> + // Encoding issues... + normalize_spec (FStar.Int.int_t 128); + normalize_spec (scalar I128); + FStar.Int.logor #128 x y + | Isize -> admit() // TODO + +let scalar_and (#ty : scalar_ty) + (x : scalar ty) (y : scalar ty) : scalar ty = + match ty with + | U8 -> FStar.UInt.logand #8 x y + | U16 -> FStar.UInt.logand #16 x y + | U32 -> FStar.UInt.logand #32 x y + | U64 -> FStar.UInt.logand #64 x y + | U128 -> FStar.UInt.logand #128 x y + | Usize -> admit() // TODO + | I8 -> + // Encoding issues... + normalize_spec (FStar.Int.int_t 8); + normalize_spec (scalar I8); + FStar.Int.logand #8 x y + | I16 -> + // Encoding issues... + normalize_spec (FStar.Int.int_t 16); + normalize_spec (scalar I16); + FStar.Int.logand #16 x y + | I32 -> FStar.Int.logand #32 x y + | I64 -> FStar.Int.logand #64 x y + | I128 -> + // Encoding issues... + normalize_spec (FStar.Int.int_t 128); + normalize_spec (scalar I128); + FStar.Int.logand #128 x y + | Isize -> admit() // TODO + +// Shift left +let scalar_shl (#ty0 #ty1 : scalar_ty) + (x : scalar ty0) (y : scalar ty1) : result (scalar ty0) = + admit() + +// Shift right +let scalar_shr (#ty0 #ty1 : scalar_ty) + (x : scalar ty0) (y : scalar ty1) : result (scalar ty0) = + admit() (** Cast an integer from a [src_ty] to a [tgt_ty] *) // TODO: check the semantics of casts in Rust @@ -304,12 +392,75 @@ let u32_mul = scalar_mul #U32 let u64_mul = scalar_mul #U64 let u128_mul = scalar_mul #U128 -/// 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 +/// Xor +let u8_xor = scalar_xor #U8 +let u16_xor = scalar_xor #U16 +let u32_xor = scalar_xor #U32 +let u64_xor = scalar_xor #U64 +let u128_xor = scalar_xor #U128 +let usize_xor = scalar_xor #Usize +let i8_xor = scalar_xor #I8 +let i16_xor = scalar_xor #I16 +let i32_xor = scalar_xor #I32 +let i64_xor = scalar_xor #I64 +let i128_xor = scalar_xor #I128 +let isize_xor = scalar_xor #Isize + +/// Or +let u8_or = scalar_or #U8 +let u16_or = scalar_or #U16 +let u32_or = scalar_or #U32 +let u64_or = scalar_or #U64 +let u128_or = scalar_or #U128 +let usize_or = scalar_or #Usize +let i8_or = scalar_or #I8 +let i16_or = scalar_or #I16 +let i32_or = scalar_or #I32 +let i64_or = scalar_or #I64 +let i128_or = scalar_or #I128 +let isize_or = scalar_or #Isize + +/// And +let u8_and = scalar_and #U8 +let u16_and = scalar_and #U16 +let u32_and = scalar_and #U32 +let u64_and = scalar_and #U64 +let u128_and = scalar_and #U128 +let usize_and = scalar_and #Usize +let i8_and = scalar_and #I8 +let i16_and = scalar_and #I16 +let i32_and = scalar_and #I32 +let i64_and = scalar_and #I64 +let i128_and = scalar_and #I128 +let isize_and = scalar_and #Isize + +/// Shift left +let u8_shl #ty = scalar_shl #U8 #ty +let u16_shl #ty = scalar_shl #U16 #ty +let u32_shl #ty = scalar_shl #U32 #ty +let u64_shl #ty = scalar_shl #U64 #ty +let u128_shl #ty = scalar_shl #U128 #ty +let usize_shl #ty = scalar_shl #Usize #ty +let i8_shl #ty = scalar_shl #I8 #ty +let i16_shl #ty = scalar_shl #I16 #ty +let i32_shl #ty = scalar_shl #I32 #ty +let i64_shl #ty = scalar_shl #I64 #ty +let i128_shl #ty = scalar_shl #I128 #ty +let isize_shl #ty = scalar_shl #Isize #ty + +/// Shift right +let u8_shr #ty = scalar_shr #U8 #ty +let u16_shr #ty = scalar_shr #U16 #ty +let u32_shr #ty = scalar_shr #U32 #ty +let u64_shr #ty = scalar_shr #U64 #ty +let u128_shr #ty = scalar_shr #U128 #ty +let usize_shr #ty = scalar_shr #Usize #ty +let i8_shr #ty = scalar_shr #I8 #ty +let i16_shr #ty = scalar_shr #I16 #ty +let i32_shr #ty = scalar_shr #I32 #ty +let i64_shr #ty = scalar_shr #I64 #ty +let i128_shr #ty = scalar_shr #I128 #ty +let isize_shr #ty = scalar_shr #Isize #ty (*** core::ops *) -- cgit v1.2.3