summaryrefslogtreecommitdiff
path: root/tests/fstar/array
diff options
context:
space:
mode:
Diffstat (limited to 'tests/fstar/array')
-rw-r--r--tests/fstar/array/Array.Clauses.Template.fst11
-rw-r--r--tests/fstar/array/Array.Funs.fst566
-rw-r--r--tests/fstar/array/Array.Types.fst5
-rw-r--r--tests/fstar/array/Primitives.fst464
4 files changed, 747 insertions, 299 deletions
diff --git a/tests/fstar/array/Array.Clauses.Template.fst b/tests/fstar/array/Array.Clauses.Template.fst
index 8a15e230..84347ab9 100644
--- a/tests/fstar/array/Array.Clauses.Template.fst
+++ b/tests/fstar/array/Array.Clauses.Template.fst
@@ -6,13 +6,16 @@ open Array.Types
#set-options "--z3rlimit 50 --fuel 1 --ifuel 1"
-(** [array::sum]: decreases clause *)
+(** [array::sum]: decreases clause
+ Source: 'src/array.rs', lines 242:0-250:1 *)
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 *)
+(** [array::sum2]: decreases clause
+ Source: 'src/array.rs', lines 252:0-261:1 *)
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 7c1d0b09..935bd9c9 100644
--- a/tests/fstar/array/Array.Funs.fst
+++ b/tests/fstar/array/Array.Funs.fst
@@ -7,349 +7,439 @@ include Array.Clauses
#set-options "--z3rlimit 50 --fuel 1 --ifuel 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
-
-(** [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
-
-(** [array::array_to_mut_slice_]: backward function 0 *)
+(** [array::incr]: merged forward/backward function
+ (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
+ 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
+ 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
+ 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_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
+(** [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 *)
-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
+(** [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 *)
-let shared_slice_len_fwd (t : Type0) (s : slice t) : result usize =
+(** [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 *)
-let index_array_shared_fwd
- (t : Type0) (s : array t 32) (i : usize) : result t =
- array_index_shared 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_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_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
+(** [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 *)
-let index_array_copy_fwd (x : array u32 32) : result u32 =
- array_index_shared u32 32 x 0
+(** [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 *)
-let index_mut_array_fwd (t : Type0) (s : array t 32) (i : usize) : result t =
- array_index_mut_fwd t 32 s i
+(** [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_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
+(** [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 *)
-let index_mut_slice_fwd (t : Type0) (s : slice t) (i : usize) : result t =
- slice_index_mut_fwd t s i
+(** [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_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
+(** [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) =
- slice_subslice_shared u32 x (Mkrange y z)
+ 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 *)
-let slice_subslice_mut__fwd
+(** [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) =
- slice_subslice_mut_fwd u32 x (Mkrange y z)
+ 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)
=
- slice_subslice_mut_back u32 x (Mkrange y 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
-
-(** [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
-
-(** [array::array_to_slice_mut_]: backward function 0 *)
+ core_slice_index_Slice_index_mut_back u32 (core_ops_range_Range usize)
+ (core_slice_index_SliceIndexRangeUsizeSliceTInst u32) x
+ { start = y; end_ = z } ret
+
+(** [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
+ 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
+ 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_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
+(** [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) =
- array_subslice_shared u32 32 x (Mkrange y z)
-
-(** [array::array_subslice_mut_]: forward function *)
-let array_subslice_mut__fwd
+ 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::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) =
- array_subslice_mut_fwd u32 32 x (Mkrange y z)
+ core_array_Array_index_mut u32 (core_ops_range_Range usize) 32
+ (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 *)
+(** [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)
=
- array_subslice_mut_back u32 32 x (Mkrange y 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
-
-(** [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
-
-(** [array::index_index_array]: forward function *)
-let index_index_array_fwd
+ core_array_Array_index_mut_back u32 (core_ops_range_Range usize) 32
+ (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
+ 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
+ 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
+ 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_shared (array u32 32) 32 s i in
- array_index_shared u32 32 a j
+ 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
+(** [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_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 =
+(** [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 *)
-let take_array_fwd (a : array u32 2) : result unit =
+(** [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 *)
-let take_array_borrow_fwd (a : array u32 2) : result unit =
+(** [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 *)
-let take_slice_fwd (s : slice u32) : result unit =
+(** [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 ()) *)
-let take_mut_slice_fwd_back (s : slice u32) : result (slice u32) =
+ (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 *)
-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
+(** [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 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
+ 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
+(** [array::index_array]: forward function
+ 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 *)
-let index_array_borrow_fwd (x : array u32 2) : result u32 =
- array_index_shared u32 2 x 0
+(** [array::index_array_borrow]: forward function
+ 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 *)
-let index_slice_u32_0_fwd (x : slice u32) : result u32 =
- slice_index_shared u32 x 0
+(** [array::index_slice_u32_0]: forward function
+ 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 *)
-let index_mut_slice_u32_0_fwd (x : slice u32) : result u32 =
- slice_index_shared u32 x 0
+(** [array::index_mut_slice_u32_0]: forward function
+ 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 *)
+(** [array::index_mut_slice_u32_0]: backward function 0
+ 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_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
+(** [array::index_all]: forward function
+ 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
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 ()
+(** [array::update_array]: forward function
+ 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 ()) *)
-let update_array_mut_borrow_fwd_back (x : array u32 2) : result (array u32 2) =
- array_index_mut_back u32 2 x 0 1
+ (there is a single backward function, and the forward function returns ())
+ 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 ()) *)
-let update_mut_slice_fwd_back (x : slice u32) : result (slice u32) =
- slice_index_mut_back 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
+ (there is a single backward function, and the forward function returns ())
+ 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 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
+ 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 =
+(** [array::range_all]: forward function
+ Source: 'src/array.rs', lines 205:0-205:18 *)
+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_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* _ =
- 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_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 ()
-(** [array::deref_array_borrow]: forward function *)
-let deref_array_borrow_fwd (x : array u32 2) : result u32 =
- array_index_shared u32 2 x 0
+(** [array::deref_array_borrow]: forward function
+ 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 *)
-let deref_array_mut_borrow_fwd (x : array u32 2) : result u32 =
- array_index_shared u32 2 x 0
+(** [array::deref_array_mut_borrow]: forward function
+ 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 *)
+(** [array::deref_array_mut_borrow]: backward function 0
+ 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_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 =
+(** [array::take_array_t]: forward function
+ 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 *)
-let non_copyable_array_fwd : result unit =
- let* _ = take_array_t_fwd (mk_array t_t 2 [ TA; TB ]) in Return ()
+(** [array::non_copyable_array]: forward function
+ 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 *)
-let rec sum_loop_fwd
- (s : slice u32) (sum : u32) (i : usize) :
- Tot (result u32) (decreases (sum_loop_decreases s sum i))
+(** [array::sum]: loop 0: forward function
+ 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))
=
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
-
-(** [array::sum]: forward function *)
-let sum_fwd (s : slice u32) : result u32 =
- sum_loop_fwd 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))
+ sum_loop s sum1 i2
+ else Return sum0
+
+(** [array::sum]: forward function
+ 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 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))
=
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 =
+(** [array::sum2]: forward function
+ 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_fwd 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
+ if not (i = i0) then Fail Failure else sum2_loop s s2 0 0
+
+(** [array::f0]: forward function
+ 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
+ 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 ()
+(** [array::f1]: forward function
+ 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 *)
-let f2_fwd (i : u32) : result unit =
+(** [array::f2]: forward function
+ Source: 'src/array.rs', lines 273:0-273:17 *)
+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)
-
-(** [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
-
-(** [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
+(** [array::f4]: forward function
+ 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)
+ (core_slice_index_SliceIndexRangeUsizeSliceTInst u32)) x
+ { start = y; end_ = z }
+
+(** [array::f3]: forward function
+ 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
+ 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]
+ 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 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 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
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..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::T] *)
-type t_t = | TA : t_t | TB : t_t
+(** [array::AB]
+ Source: 'src/array.rs', lines 3:0-3:11 *)
+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 9db82069..94322ead 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 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 }
+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) =
@@ -169,17 +187,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
@@ -231,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
@@ -259,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}
@@ -278,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
@@ -295,55 +389,54 @@ 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 =
+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_fwd (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
+
+// Helper
+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) =
+ if i < length v then Return (list_update v i x) else Fail Failure
// 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
@@ -358,18 +451,279 @@ 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;
+}
-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
+// [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_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_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_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_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
+ // sure code which uses it fails
+ fun _ _ -> Fail Failure
+
+// [core::slice::index::Range::get_unchecked_mut]: forward function
+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
+ // sure code which uses it fails
+ fun _ _ -> Fail Failure
+
+// [core::slice::index::Range::index]: forward function
+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_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_RangeUsize_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::private_slice_index::Range]
+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_SliceIndexRangeUsizeSliceTInst (t : Type0) :
+ core_slice_index_SliceIndex (core_ops_range_Range usize) (slice t) = {
+ sealedInst = core_slice_index_private_slice_index_SealedRangeUsizeInst;
+ output = slice 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_ops_index_IndexMutSliceTIInst (t idx : Type0)
+ (inst : core_slice_index_SliceIndex idx (slice t)) :
+ core_ops_index_IndexMut (slice t) idx = {
+ 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_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;
+ index = core_array_Array_index t idx n inst;
+}
+
+// Trait implementation: [core::array::[T; N]]
+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_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;
+}
+
+// [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_SealedUsizeInst
+ : core_slice_index_private_slice_index_Sealed usize = ()
+
+// Trait implementation: [core::slice::index::usize]
+let core_slice_index_SliceIndexUsizeSliceTInst (t : Type0) :
+ core_slice_index_SliceIndex usize (slice t) = {
+ 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;
+ 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;
+}
+
+(*** 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_SliceIndexUsizeSliceTInst a) v i ==
+ alloc_vec_Vec_index_usize 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_SliceIndexUsizeSliceTInst a) v i ==
+ alloc_vec_Vec_index_usize 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_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_SliceIndexUsizeSliceTInst a) v i x)]
+ =
+ admit()