diff options
Diffstat (limited to 'tests/fstar/misc')
-rw-r--r-- | tests/fstar/misc/Constants.fst | 16 | ||||
-rw-r--r-- | tests/fstar/misc/External.Funs.fst | 18 | ||||
-rw-r--r-- | tests/fstar/misc/External.Opaque.fsti | 10 | ||||
-rw-r--r-- | tests/fstar/misc/Loops.Funs.fst | 124 | ||||
-rw-r--r-- | tests/fstar/misc/NoNestedBorrows.fst | 112 | ||||
-rw-r--r-- | tests/fstar/misc/Paper.fst | 21 | ||||
-rw-r--r-- | tests/fstar/misc/PoloniusList.fst | 4 |
7 files changed, 155 insertions, 150 deletions
diff --git a/tests/fstar/misc/Constants.fst b/tests/fstar/misc/Constants.fst index bf2f0b1b..aae997fa 100644 --- a/tests/fstar/misc/Constants.fst +++ b/tests/fstar/misc/Constants.fst @@ -21,7 +21,7 @@ let x1_c : u32 = eval_global x1_body let x2_body : result u32 = Return 3 let x2_c : u32 = eval_global x2_body -(** [constants::incr] *) +(** [constants::incr]: forward function *) let incr_fwd (n : u32) : result u32 = u32_add n 1 @@ -29,14 +29,14 @@ let incr_fwd (n : u32) : result u32 = let x3_body : result u32 = incr_fwd 32 let x3_c : u32 = eval_global x3_body -(** [constants::mk_pair0] *) +(** [constants::mk_pair0]: forward function *) let mk_pair0_fwd (x : u32) (y : u32) : result (u32 & u32) = Return (x, y) (** [constants::Pair] *) type pair_t (t1 t2 : Type0) = { pair_x : t1; pair_y : t2; } -(** [constants::mk_pair1] *) +(** [constants::mk_pair1]: forward function *) let mk_pair1_fwd (x : u32) (y : u32) : result (pair_t u32 u32) = Return { pair_x = x; pair_y = y } @@ -59,7 +59,7 @@ let p3_c : pair_t u32 u32 = eval_global p3_body (** [constants::Wrap] *) type wrap_t (t : Type0) = { wrap_val : t; } -(** [constants::Wrap::{0}::new] *) +(** [constants::Wrap::{0}::new]: forward function *) let wrap_new_fwd (t : Type0) (val0 : t) : result (wrap_t t) = Return { wrap_val = val0 } @@ -67,7 +67,7 @@ let wrap_new_fwd (t : Type0) (val0 : t) : result (wrap_t t) = let y_body : result (wrap_t i32) = wrap_new_fwd i32 2 let y_c : wrap_t i32 = eval_global y_body -(** [constants::unwrap_y] *) +(** [constants::unwrap_y]: forward function *) let unwrap_y_fwd : result i32 = Return y_c.wrap_val @@ -79,11 +79,11 @@ let yval_c : i32 = eval_global yval_body let get_z1_z1_body : result i32 = Return 3 let get_z1_z1_c : i32 = eval_global get_z1_z1_body -(** [constants::get_z1] *) +(** [constants::get_z1]: forward function *) let get_z1_fwd : result i32 = Return get_z1_z1_c -(** [constants::add] *) +(** [constants::add]: forward function *) let add_fwd (a : i32) (b : i32) : result i32 = i32_add a b @@ -99,7 +99,7 @@ let q2_c : i32 = eval_global q2_body let q3_body : result i32 = add_fwd q2_c 3 let q3_c : i32 = eval_global q3_body -(** [constants::get_z2] *) +(** [constants::get_z2]: forward function *) let get_z2_fwd : result i32 = let* i = get_z1_fwd in let* i0 = add_fwd i q3_c in add_fwd q1_c i0 diff --git a/tests/fstar/misc/External.Funs.fst b/tests/fstar/misc/External.Funs.fst index f70a9fc6..f118a2cf 100644 --- a/tests/fstar/misc/External.Funs.fst +++ b/tests/fstar/misc/External.Funs.fst @@ -7,14 +7,14 @@ include External.Opaque #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" -(** [external::swap] *) +(** [external::swap]: forward function *) let swap_fwd (t : Type0) (x : t) (y : t) (st : state) : result (state & unit) = let* (st0, _) = core_mem_swap_fwd t x y st in let* (st1, _) = core_mem_swap_back0 t x y st st0 in let* (st2, _) = core_mem_swap_back1 t x y st st1 in Return (st2, ()) -(** [external::swap] *) +(** [external::swap]: backward function 0 *) let swap_back (t : Type0) (x : t) (y : t) (st : state) (st0 : state) : result (state & (t & t)) @@ -24,20 +24,20 @@ let swap_back let* (_, y0) = core_mem_swap_back1 t x y st st2 in Return (st0, (x0, y0)) -(** [external::test_new_non_zero_u32] *) +(** [external::test_new_non_zero_u32]: forward function *) let test_new_non_zero_u32_fwd (x : u32) (st : state) : result (state & core_num_nonzero_non_zero_u32_t) = let* (st0, opt) = core_num_nonzero_non_zero_u32_new_fwd x st in core_option_option_unwrap_fwd core_num_nonzero_non_zero_u32_t opt st0 -(** [external::test_vec] *) +(** [external::test_vec]: forward function *) let test_vec_fwd : result unit = let v = vec_new u32 in let* _ = vec_push_back u32 v 0 in Return () (** Unit test for [external::test_vec] *) let _ = assert_norm (test_vec_fwd = Return ()) -(** [external::custom_swap] *) +(** [external::custom_swap]: forward function *) let custom_swap_fwd (t : Type0) (x : t) (y : t) (st : state) : result (state & t) = let* (st0, _) = core_mem_swap_fwd t x y st in @@ -45,7 +45,7 @@ let custom_swap_fwd let* (st2, _) = core_mem_swap_back1 t x y st st1 in Return (st2, x0) -(** [external::custom_swap] *) +(** [external::custom_swap]: backward function 0 *) let custom_swap_back (t : Type0) (x : t) (y : t) (st : state) (ret : t) (st0 : state) : result (state & (t & t)) @@ -55,19 +55,19 @@ let custom_swap_back let* (_, y0) = core_mem_swap_back1 t x y st st2 in Return (st0, (ret, y0)) -(** [external::test_custom_swap] *) +(** [external::test_custom_swap]: forward function *) let test_custom_swap_fwd (x : u32) (y : u32) (st : state) : result (state & unit) = let* (st0, _) = custom_swap_fwd u32 x y st in Return (st0, ()) -(** [external::test_custom_swap] *) +(** [external::test_custom_swap]: backward function 0 *) let test_custom_swap_back (x : u32) (y : u32) (st : state) (st0 : state) : result (state & (u32 & u32)) = custom_swap_back u32 x y st 1 st0 -(** [external::test_swap_non_zero] *) +(** [external::test_swap_non_zero]: forward function *) let test_swap_non_zero_fwd (x : u32) (st : state) : result (state & u32) = let* (st0, _) = swap_fwd u32 x 0 st in let* (st1, (x0, _)) = swap_back u32 x 0 st st0 in diff --git a/tests/fstar/misc/External.Opaque.fsti b/tests/fstar/misc/External.Opaque.fsti index 356d5fc4..2e19f767 100644 --- a/tests/fstar/misc/External.Opaque.fsti +++ b/tests/fstar/misc/External.Opaque.fsti @@ -6,22 +6,22 @@ include External.Types #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" -(** [core::mem::swap] *) +(** [core::mem::swap]: forward function *) val core_mem_swap_fwd (t : Type0) : t -> t -> state -> result (state & unit) -(** [core::mem::swap] *) +(** [core::mem::swap]: backward function 0 *) val core_mem_swap_back0 (t : Type0) : t -> t -> state -> state -> result (state & t) -(** [core::mem::swap] *) +(** [core::mem::swap]: backward function 1 *) val core_mem_swap_back1 (t : Type0) : t -> t -> state -> state -> result (state & t) -(** [core::num::nonzero::NonZeroU32::{14}::new] *) +(** [core::num::nonzero::NonZeroU32::{14}::new]: forward function *) val core_num_nonzero_non_zero_u32_new_fwd : u32 -> state -> result (state & (option core_num_nonzero_non_zero_u32_t)) -(** [core::option::Option::{0}::unwrap] *) +(** [core::option::Option::{0}::unwrap]: forward function *) val core_option_option_unwrap_fwd (t : Type0) : option t -> state -> result (state & t) diff --git a/tests/fstar/misc/Loops.Funs.fst b/tests/fstar/misc/Loops.Funs.fst index 7fe175e5..9a80f415 100644 --- a/tests/fstar/misc/Loops.Funs.fst +++ b/tests/fstar/misc/Loops.Funs.fst @@ -7,7 +7,7 @@ include Loops.Clauses #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" -(** [loops::sum] *) +(** [loops::sum]: loop 0: forward function *) let rec sum_loop_fwd (max : u32) (i : u32) (s : u32) : Tot (result u32) (decreases (sum_loop_decreases max i s)) @@ -16,11 +16,11 @@ let rec sum_loop_fwd then let* s0 = u32_add s i in let* i0 = u32_add i 1 in sum_loop_fwd max i0 s0 else u32_mul s 2 -(** [loops::sum] *) +(** [loops::sum]: forward function *) let sum_fwd (max : u32) : result u32 = sum_loop_fwd max 0 0 -(** [loops::sum_with_mut_borrows] *) +(** [loops::sum_with_mut_borrows]: loop 0: forward function *) let rec sum_with_mut_borrows_loop_fwd (max : u32) (mi : u32) (ms : u32) : Tot (result u32) (decreases (sum_with_mut_borrows_loop_decreases max mi ms)) @@ -32,11 +32,11 @@ let rec sum_with_mut_borrows_loop_fwd sum_with_mut_borrows_loop_fwd max mi0 ms0 else u32_mul ms 2 -(** [loops::sum_with_mut_borrows] *) +(** [loops::sum_with_mut_borrows]: forward function *) let sum_with_mut_borrows_fwd (max : u32) : result u32 = sum_with_mut_borrows_loop_fwd max 0 0 -(** [loops::sum_with_shared_borrows] *) +(** [loops::sum_with_shared_borrows]: loop 0: forward function *) let rec sum_with_shared_borrows_loop_fwd (max : u32) (i : u32) (s : u32) : Tot (result u32) (decreases (sum_with_shared_borrows_loop_decreases max i s)) @@ -48,11 +48,12 @@ let rec sum_with_shared_borrows_loop_fwd sum_with_shared_borrows_loop_fwd max i0 s0 else u32_mul s 2 -(** [loops::sum_with_shared_borrows] *) +(** [loops::sum_with_shared_borrows]: forward function *) let sum_with_shared_borrows_fwd (max : u32) : result u32 = sum_with_shared_borrows_loop_fwd max 0 0 -(** [loops::clear] *) +(** [loops::clear]: loop 0: merged forward/backward function + (there is a single backward function, and the forward function returns ()) *) let rec clear_loop_fwd_back (v : vec u32) (i : usize) : Tot (result (vec u32)) (decreases (clear_loop_decreases v i)) @@ -65,11 +66,12 @@ let rec clear_loop_fwd_back clear_loop_fwd_back v0 i1 else Return v -(** [loops::clear] *) +(** [loops::clear]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) *) let clear_fwd_back (v : vec u32) : result (vec u32) = clear_loop_fwd_back v 0 -(** [loops::list_mem] *) +(** [loops::list_mem]: loop 0: forward function *) let rec list_mem_loop_fwd (x : u32) (ls : list_t u32) : Tot (result bool) (decreases (list_mem_loop_decreases x ls)) @@ -79,11 +81,11 @@ let rec list_mem_loop_fwd | ListNil -> Return false end -(** [loops::list_mem] *) +(** [loops::list_mem]: forward function *) let list_mem_fwd (x : u32) (ls : list_t u32) : result bool = list_mem_loop_fwd x ls -(** [loops::list_nth_mut_loop] *) +(** [loops::list_nth_mut_loop]: loop 0: forward function *) let rec list_nth_mut_loop_loop_fwd (t : Type0) (ls : list_t t) (i : u32) : Tot (result t) (decreases (list_nth_mut_loop_loop_decreases t ls i)) @@ -96,11 +98,11 @@ let rec list_nth_mut_loop_loop_fwd | ListNil -> Fail Failure end -(** [loops::list_nth_mut_loop] *) +(** [loops::list_nth_mut_loop]: forward function *) let list_nth_mut_loop_fwd (t : Type0) (ls : list_t t) (i : u32) : result t = list_nth_mut_loop_loop_fwd t ls i -(** [loops::list_nth_mut_loop] *) +(** [loops::list_nth_mut_loop]: loop 0: backward function 0 *) let rec list_nth_mut_loop_loop_back (t : Type0) (ls : list_t t) (i : u32) (ret : t) : Tot (result (list_t t)) (decreases (list_nth_mut_loop_loop_decreases t ls i)) @@ -116,12 +118,12 @@ let rec list_nth_mut_loop_loop_back | ListNil -> Fail Failure end -(** [loops::list_nth_mut_loop] *) +(** [loops::list_nth_mut_loop]: backward function 0 *) let list_nth_mut_loop_back (t : Type0) (ls : list_t t) (i : u32) (ret : t) : result (list_t t) = list_nth_mut_loop_loop_back t ls i ret -(** [loops::list_nth_shared_loop] *) +(** [loops::list_nth_shared_loop]: loop 0: forward function *) let rec list_nth_shared_loop_loop_fwd (t : Type0) (ls : list_t t) (i : u32) : Tot (result t) (decreases (list_nth_shared_loop_loop_decreases t ls i)) @@ -134,11 +136,11 @@ let rec list_nth_shared_loop_loop_fwd | ListNil -> Fail Failure end -(** [loops::list_nth_shared_loop] *) +(** [loops::list_nth_shared_loop]: forward function *) let list_nth_shared_loop_fwd (t : Type0) (ls : list_t t) (i : u32) : result t = list_nth_shared_loop_loop_fwd t ls i -(** [loops::get_elem_mut] *) +(** [loops::get_elem_mut]: loop 0: forward function *) let rec get_elem_mut_loop_fwd (x : usize) (ls : list_t usize) : Tot (result usize) (decreases (get_elem_mut_loop_decreases x ls)) @@ -148,12 +150,12 @@ let rec get_elem_mut_loop_fwd | ListNil -> Fail Failure end -(** [loops::get_elem_mut] *) +(** [loops::get_elem_mut]: forward function *) let get_elem_mut_fwd (slots : vec (list_t usize)) (x : usize) : result usize = let* l = vec_index_mut_fwd (list_t usize) slots 0 in get_elem_mut_loop_fwd x l -(** [loops::get_elem_mut] *) +(** [loops::get_elem_mut]: loop 0: backward function 0 *) let rec get_elem_mut_loop_back (x : usize) (ls : list_t usize) (ret : usize) : Tot (result (list_t usize)) (decreases (get_elem_mut_loop_decreases x ls)) @@ -166,7 +168,7 @@ let rec get_elem_mut_loop_back | ListNil -> Fail Failure end -(** [loops::get_elem_mut] *) +(** [loops::get_elem_mut]: backward function 0 *) let get_elem_mut_back (slots : vec (list_t usize)) (x : usize) (ret : usize) : result (vec (list_t usize)) @@ -175,7 +177,7 @@ let get_elem_mut_back let* l0 = get_elem_mut_loop_back x l ret in vec_index_mut_back (list_t usize) slots 0 l0 -(** [loops::get_elem_shared] *) +(** [loops::get_elem_shared]: loop 0: forward function *) let rec get_elem_shared_loop_fwd (x : usize) (ls : list_t usize) : Tot (result usize) (decreases (get_elem_shared_loop_decreases x ls)) @@ -185,25 +187,25 @@ let rec get_elem_shared_loop_fwd | ListNil -> Fail Failure end -(** [loops::get_elem_shared] *) +(** [loops::get_elem_shared]: forward function *) let get_elem_shared_fwd (slots : vec (list_t usize)) (x : usize) : result usize = let* l = vec_index_fwd (list_t usize) slots 0 in get_elem_shared_loop_fwd x l -(** [loops::id_mut] *) +(** [loops::id_mut]: forward function *) let id_mut_fwd (t : Type0) (ls : list_t t) : result (list_t t) = Return ls -(** [loops::id_mut] *) +(** [loops::id_mut]: backward function 0 *) let id_mut_back (t : Type0) (ls : list_t t) (ret : list_t t) : result (list_t t) = Return ret -(** [loops::id_shared] *) +(** [loops::id_shared]: forward function *) let id_shared_fwd (t : Type0) (ls : list_t t) : result (list_t t) = Return ls -(** [loops::list_nth_mut_loop_with_id] *) +(** [loops::list_nth_mut_loop_with_id]: loop 0: forward function *) let rec list_nth_mut_loop_with_id_loop_fwd (t : Type0) (i : u32) (ls : list_t t) : Tot (result t) (decreases (list_nth_mut_loop_with_id_loop_decreases t i ls)) @@ -216,12 +218,12 @@ let rec list_nth_mut_loop_with_id_loop_fwd | ListNil -> Fail Failure end -(** [loops::list_nth_mut_loop_with_id] *) +(** [loops::list_nth_mut_loop_with_id]: forward function *) let list_nth_mut_loop_with_id_fwd (t : Type0) (ls : list_t t) (i : u32) : result t = let* ls0 = id_mut_fwd t ls in list_nth_mut_loop_with_id_loop_fwd t i ls0 -(** [loops::list_nth_mut_loop_with_id] *) +(** [loops::list_nth_mut_loop_with_id]: loop 0: backward function 0 *) let rec list_nth_mut_loop_with_id_loop_back (t : Type0) (i : u32) (ls : list_t t) (ret : t) : Tot (result (list_t t)) @@ -238,14 +240,14 @@ let rec list_nth_mut_loop_with_id_loop_back | ListNil -> Fail Failure end -(** [loops::list_nth_mut_loop_with_id] *) +(** [loops::list_nth_mut_loop_with_id]: backward function 0 *) let list_nth_mut_loop_with_id_back (t : Type0) (ls : list_t t) (i : u32) (ret : t) : result (list_t t) = let* ls0 = id_mut_fwd t ls in let* l = list_nth_mut_loop_with_id_loop_back t i ls0 ret in id_mut_back t ls l -(** [loops::list_nth_shared_loop_with_id] *) +(** [loops::list_nth_shared_loop_with_id]: loop 0: forward function *) let rec list_nth_shared_loop_with_id_loop_fwd (t : Type0) (i : u32) (ls : list_t t) : Tot (result t) @@ -259,13 +261,13 @@ let rec list_nth_shared_loop_with_id_loop_fwd | ListNil -> Fail Failure end -(** [loops::list_nth_shared_loop_with_id] *) +(** [loops::list_nth_shared_loop_with_id]: forward function *) let list_nth_shared_loop_with_id_fwd (t : Type0) (ls : list_t t) (i : u32) : result t = let* ls0 = id_shared_fwd t ls in list_nth_shared_loop_with_id_loop_fwd t i ls0 -(** [loops::list_nth_mut_loop_pair] *) +(** [loops::list_nth_mut_loop_pair]: loop 0: forward function *) let rec list_nth_mut_loop_pair_loop_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : Tot (result (t & t)) @@ -284,12 +286,12 @@ let rec list_nth_mut_loop_pair_loop_fwd | ListNil -> Fail Failure end -(** [loops::list_nth_mut_loop_pair] *) +(** [loops::list_nth_mut_loop_pair]: forward function *) let list_nth_mut_loop_pair_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : result (t & t) = list_nth_mut_loop_pair_loop_fwd t ls0 ls1 i -(** [loops::list_nth_mut_loop_pair] *) +(** [loops::list_nth_mut_loop_pair]: loop 0: backward function 0 *) let rec list_nth_mut_loop_pair_loop_back'a (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) (ret : t) : Tot (result (list_t t)) @@ -310,14 +312,14 @@ let rec list_nth_mut_loop_pair_loop_back'a | ListNil -> Fail Failure end -(** [loops::list_nth_mut_loop_pair] *) +(** [loops::list_nth_mut_loop_pair]: backward function 0 *) let list_nth_mut_loop_pair_back'a (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) (ret : t) : result (list_t t) = list_nth_mut_loop_pair_loop_back'a t ls0 ls1 i ret -(** [loops::list_nth_mut_loop_pair] *) +(** [loops::list_nth_mut_loop_pair]: loop 0: backward function 1 *) let rec list_nth_mut_loop_pair_loop_back'b (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) (ret : t) : Tot (result (list_t t)) @@ -338,14 +340,14 @@ let rec list_nth_mut_loop_pair_loop_back'b | ListNil -> Fail Failure end -(** [loops::list_nth_mut_loop_pair] *) +(** [loops::list_nth_mut_loop_pair]: backward function 1 *) let list_nth_mut_loop_pair_back'b (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) (ret : t) : result (list_t t) = list_nth_mut_loop_pair_loop_back'b t ls0 ls1 i ret -(** [loops::list_nth_shared_loop_pair] *) +(** [loops::list_nth_shared_loop_pair]: loop 0: forward function *) let rec list_nth_shared_loop_pair_loop_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : Tot (result (t & t)) @@ -365,12 +367,12 @@ let rec list_nth_shared_loop_pair_loop_fwd | ListNil -> Fail Failure end -(** [loops::list_nth_shared_loop_pair] *) +(** [loops::list_nth_shared_loop_pair]: forward function *) let list_nth_shared_loop_pair_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : result (t & t) = list_nth_shared_loop_pair_loop_fwd t ls0 ls1 i -(** [loops::list_nth_mut_loop_pair_merge] *) +(** [loops::list_nth_mut_loop_pair_merge]: loop 0: forward function *) let rec list_nth_mut_loop_pair_merge_loop_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : Tot (result (t & t)) @@ -390,12 +392,12 @@ let rec list_nth_mut_loop_pair_merge_loop_fwd | ListNil -> Fail Failure end -(** [loops::list_nth_mut_loop_pair_merge] *) +(** [loops::list_nth_mut_loop_pair_merge]: forward function *) let list_nth_mut_loop_pair_merge_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : result (t & t) = list_nth_mut_loop_pair_merge_loop_fwd t ls0 ls1 i -(** [loops::list_nth_mut_loop_pair_merge] *) +(** [loops::list_nth_mut_loop_pair_merge]: loop 0: backward function 0 *) let rec list_nth_mut_loop_pair_merge_loop_back (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) (ret : (t & t)) : Tot (result ((list_t t) & (list_t t))) @@ -417,14 +419,14 @@ let rec list_nth_mut_loop_pair_merge_loop_back | ListNil -> Fail Failure end -(** [loops::list_nth_mut_loop_pair_merge] *) +(** [loops::list_nth_mut_loop_pair_merge]: backward function 0 *) let list_nth_mut_loop_pair_merge_back (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) (ret : (t & t)) : result ((list_t t) & (list_t t)) = list_nth_mut_loop_pair_merge_loop_back t ls0 ls1 i ret -(** [loops::list_nth_shared_loop_pair_merge] *) +(** [loops::list_nth_shared_loop_pair_merge]: loop 0: forward function *) let rec list_nth_shared_loop_pair_merge_loop_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : Tot (result (t & t)) @@ -444,12 +446,12 @@ let rec list_nth_shared_loop_pair_merge_loop_fwd | ListNil -> Fail Failure end -(** [loops::list_nth_shared_loop_pair_merge] *) +(** [loops::list_nth_shared_loop_pair_merge]: forward function *) let list_nth_shared_loop_pair_merge_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : result (t & t) = list_nth_shared_loop_pair_merge_loop_fwd t ls0 ls1 i -(** [loops::list_nth_mut_shared_loop_pair] *) +(** [loops::list_nth_mut_shared_loop_pair]: loop 0: forward function *) let rec list_nth_mut_shared_loop_pair_loop_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : Tot (result (t & t)) @@ -469,12 +471,12 @@ let rec list_nth_mut_shared_loop_pair_loop_fwd | ListNil -> Fail Failure end -(** [loops::list_nth_mut_shared_loop_pair] *) +(** [loops::list_nth_mut_shared_loop_pair]: forward function *) let list_nth_mut_shared_loop_pair_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : result (t & t) = list_nth_mut_shared_loop_pair_loop_fwd t ls0 ls1 i -(** [loops::list_nth_mut_shared_loop_pair] *) +(** [loops::list_nth_mut_shared_loop_pair]: loop 0: backward function 0 *) let rec list_nth_mut_shared_loop_pair_loop_back (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) (ret : t) : Tot (result (list_t t)) @@ -495,14 +497,14 @@ let rec list_nth_mut_shared_loop_pair_loop_back | ListNil -> Fail Failure end -(** [loops::list_nth_mut_shared_loop_pair] *) +(** [loops::list_nth_mut_shared_loop_pair]: backward function 0 *) let list_nth_mut_shared_loop_pair_back (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) (ret : t) : result (list_t t) = list_nth_mut_shared_loop_pair_loop_back t ls0 ls1 i ret -(** [loops::list_nth_mut_shared_loop_pair_merge] *) +(** [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: forward function *) let rec list_nth_mut_shared_loop_pair_merge_loop_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : Tot (result (t & t)) @@ -522,12 +524,12 @@ let rec list_nth_mut_shared_loop_pair_merge_loop_fwd | ListNil -> Fail Failure end -(** [loops::list_nth_mut_shared_loop_pair_merge] *) +(** [loops::list_nth_mut_shared_loop_pair_merge]: forward function *) let list_nth_mut_shared_loop_pair_merge_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : result (t & t) = list_nth_mut_shared_loop_pair_merge_loop_fwd t ls0 ls1 i -(** [loops::list_nth_mut_shared_loop_pair_merge] *) +(** [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: backward function 0 *) let rec list_nth_mut_shared_loop_pair_merge_loop_back (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) (ret : t) : Tot (result (list_t t)) @@ -549,14 +551,14 @@ let rec list_nth_mut_shared_loop_pair_merge_loop_back | ListNil -> Fail Failure end -(** [loops::list_nth_mut_shared_loop_pair_merge] *) +(** [loops::list_nth_mut_shared_loop_pair_merge]: backward function 0 *) let list_nth_mut_shared_loop_pair_merge_back (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) (ret : t) : result (list_t t) = list_nth_mut_shared_loop_pair_merge_loop_back t ls0 ls1 i ret -(** [loops::list_nth_shared_mut_loop_pair] *) +(** [loops::list_nth_shared_mut_loop_pair]: loop 0: forward function *) let rec list_nth_shared_mut_loop_pair_loop_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : Tot (result (t & t)) @@ -576,12 +578,12 @@ let rec list_nth_shared_mut_loop_pair_loop_fwd | ListNil -> Fail Failure end -(** [loops::list_nth_shared_mut_loop_pair] *) +(** [loops::list_nth_shared_mut_loop_pair]: forward function *) let list_nth_shared_mut_loop_pair_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : result (t & t) = list_nth_shared_mut_loop_pair_loop_fwd t ls0 ls1 i -(** [loops::list_nth_shared_mut_loop_pair] *) +(** [loops::list_nth_shared_mut_loop_pair]: loop 0: backward function 1 *) let rec list_nth_shared_mut_loop_pair_loop_back (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) (ret : t) : Tot (result (list_t t)) @@ -602,14 +604,14 @@ let rec list_nth_shared_mut_loop_pair_loop_back | ListNil -> Fail Failure end -(** [loops::list_nth_shared_mut_loop_pair] *) +(** [loops::list_nth_shared_mut_loop_pair]: backward function 1 *) let list_nth_shared_mut_loop_pair_back (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) (ret : t) : result (list_t t) = list_nth_shared_mut_loop_pair_loop_back t ls0 ls1 i ret -(** [loops::list_nth_shared_mut_loop_pair_merge] *) +(** [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: forward function *) let rec list_nth_shared_mut_loop_pair_merge_loop_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : Tot (result (t & t)) @@ -629,12 +631,12 @@ let rec list_nth_shared_mut_loop_pair_merge_loop_fwd | ListNil -> Fail Failure end -(** [loops::list_nth_shared_mut_loop_pair_merge] *) +(** [loops::list_nth_shared_mut_loop_pair_merge]: forward function *) let list_nth_shared_mut_loop_pair_merge_fwd (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) : result (t & t) = list_nth_shared_mut_loop_pair_merge_loop_fwd t ls0 ls1 i -(** [loops::list_nth_shared_mut_loop_pair_merge] *) +(** [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: backward function 0 *) let rec list_nth_shared_mut_loop_pair_merge_loop_back (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) (ret : t) : Tot (result (list_t t)) @@ -656,7 +658,7 @@ let rec list_nth_shared_mut_loop_pair_merge_loop_back | ListNil -> Fail Failure end -(** [loops::list_nth_shared_mut_loop_pair_merge] *) +(** [loops::list_nth_shared_mut_loop_pair_merge]: backward function 0 *) let list_nth_shared_mut_loop_pair_merge_back (t : Type0) (ls0 : list_t t) (ls1 : list_t t) (i : u32) (ret : t) : result (list_t t) diff --git a/tests/fstar/misc/NoNestedBorrows.fst b/tests/fstar/misc/NoNestedBorrows.fst index 3770ab5d..d790bfa9 100644 --- a/tests/fstar/misc/NoNestedBorrows.fst +++ b/tests/fstar/misc/NoNestedBorrows.fst @@ -30,46 +30,46 @@ type sum_t (t1 t2 : Type0) = | SumLeft : t1 -> sum_t t1 t2 | SumRight : t2 -> sum_t t1 t2 -(** [no_nested_borrows::neg_test] *) +(** [no_nested_borrows::neg_test]: forward function *) let neg_test_fwd (x : i32) : result i32 = i32_neg x -(** [no_nested_borrows::add_test] *) +(** [no_nested_borrows::add_test]: forward function *) let add_test_fwd (x : u32) (y : u32) : result u32 = u32_add x y -(** [no_nested_borrows::subs_test] *) +(** [no_nested_borrows::subs_test]: forward function *) let subs_test_fwd (x : u32) (y : u32) : result u32 = u32_sub x y -(** [no_nested_borrows::div_test] *) +(** [no_nested_borrows::div_test]: forward function *) let div_test_fwd (x : u32) (y : u32) : result u32 = u32_div x y -(** [no_nested_borrows::div_test1] *) +(** [no_nested_borrows::div_test1]: forward function *) let div_test1_fwd (x : u32) : result u32 = u32_div x 2 -(** [no_nested_borrows::rem_test] *) +(** [no_nested_borrows::rem_test]: forward function *) let rem_test_fwd (x : u32) (y : u32) : result u32 = u32_rem x y -(** [no_nested_borrows::cast_test] *) +(** [no_nested_borrows::cast_test]: forward function *) let cast_test_fwd (x : u32) : result i32 = scalar_cast U32 I32 x -(** [no_nested_borrows::test2] *) +(** [no_nested_borrows::test2]: forward function *) let test2_fwd : result unit = let* _ = u32_add 23 44 in Return () (** Unit test for [no_nested_borrows::test2] *) let _ = assert_norm (test2_fwd = Return ()) -(** [no_nested_borrows::get_max] *) +(** [no_nested_borrows::get_max]: forward function *) let get_max_fwd (x : u32) (y : u32) : result u32 = if x >= y then Return x else Return y -(** [no_nested_borrows::test3] *) +(** [no_nested_borrows::test3]: forward function *) let test3_fwd : result unit = let* x = get_max_fwd 4 3 in let* y = get_max_fwd 10 11 in @@ -79,21 +79,21 @@ let test3_fwd : result unit = (** Unit test for [no_nested_borrows::test3] *) let _ = assert_norm (test3_fwd = Return ()) -(** [no_nested_borrows::test_neg1] *) +(** [no_nested_borrows::test_neg1]: forward function *) let test_neg1_fwd : result unit = let* y = i32_neg 3 in if not (y = -3) then Fail Failure else Return () (** Unit test for [no_nested_borrows::test_neg1] *) let _ = assert_norm (test_neg1_fwd = Return ()) -(** [no_nested_borrows::refs_test1] *) +(** [no_nested_borrows::refs_test1]: forward function *) let refs_test1_fwd : result unit = if not (1 = 1) then Fail Failure else Return () (** Unit test for [no_nested_borrows::refs_test1] *) let _ = assert_norm (refs_test1_fwd = Return ()) -(** [no_nested_borrows::refs_test2] *) +(** [no_nested_borrows::refs_test2]: forward function *) let refs_test2_fwd : result unit = if not (2 = 2) then Fail Failure @@ -108,47 +108,47 @@ let refs_test2_fwd : result unit = (** Unit test for [no_nested_borrows::refs_test2] *) let _ = assert_norm (refs_test2_fwd = Return ()) -(** [no_nested_borrows::test_list1] *) +(** [no_nested_borrows::test_list1]: forward function *) let test_list1_fwd : result unit = Return () (** Unit test for [no_nested_borrows::test_list1] *) let _ = assert_norm (test_list1_fwd = Return ()) -(** [no_nested_borrows::test_box1] *) +(** [no_nested_borrows::test_box1]: forward function *) let test_box1_fwd : result unit = let b = 1 in let x = b in if not (x = 1) then Fail Failure else Return () (** Unit test for [no_nested_borrows::test_box1] *) let _ = assert_norm (test_box1_fwd = Return ()) -(** [no_nested_borrows::copy_int] *) +(** [no_nested_borrows::copy_int]: forward function *) let copy_int_fwd (x : i32) : result i32 = Return x -(** [no_nested_borrows::test_unreachable] *) +(** [no_nested_borrows::test_unreachable]: forward function *) let test_unreachable_fwd (b : bool) : result unit = if b then Fail Failure else Return () -(** [no_nested_borrows::test_panic] *) +(** [no_nested_borrows::test_panic]: forward function *) let test_panic_fwd (b : bool) : result unit = if b then Fail Failure else Return () -(** [no_nested_borrows::test_copy_int] *) +(** [no_nested_borrows::test_copy_int]: forward function *) let test_copy_int_fwd : result unit = let* y = copy_int_fwd 0 in if not (0 = y) then Fail Failure else Return () (** Unit test for [no_nested_borrows::test_copy_int] *) let _ = assert_norm (test_copy_int_fwd = Return ()) -(** [no_nested_borrows::is_cons] *) +(** [no_nested_borrows::is_cons]: forward function *) let is_cons_fwd (t : Type0) (l : list_t t) : result bool = begin match l with | ListCons x l0 -> Return true | ListNil -> Return false end -(** [no_nested_borrows::test_is_cons] *) +(** [no_nested_borrows::test_is_cons]: forward function *) let test_is_cons_fwd : result unit = let l = ListNil in let* b = is_cons_fwd i32 (ListCons 0 l) in @@ -157,14 +157,14 @@ let test_is_cons_fwd : result unit = (** Unit test for [no_nested_borrows::test_is_cons] *) let _ = assert_norm (test_is_cons_fwd = Return ()) -(** [no_nested_borrows::split_list] *) +(** [no_nested_borrows::split_list]: forward function *) let split_list_fwd (t : Type0) (l : list_t t) : result (t & (list_t t)) = begin match l with | ListCons hd tl -> Return (hd, tl) | ListNil -> Fail Failure end -(** [no_nested_borrows::test_split_list] *) +(** [no_nested_borrows::test_split_list]: forward function *) let test_split_list_fwd : result unit = let l = ListNil in let* p = split_list_fwd i32 (ListCons 0 l) in @@ -174,16 +174,16 @@ let test_split_list_fwd : result unit = (** Unit test for [no_nested_borrows::test_split_list] *) let _ = assert_norm (test_split_list_fwd = Return ()) -(** [no_nested_borrows::choose] *) +(** [no_nested_borrows::choose]: forward function *) let choose_fwd (t : Type0) (b : bool) (x : t) (y : t) : result t = if b then Return x else Return y -(** [no_nested_borrows::choose] *) +(** [no_nested_borrows::choose]: backward function 0 *) let choose_back (t : Type0) (b : bool) (x : t) (y : t) (ret : t) : result (t & t) = if b then Return (ret, y) else Return (x, ret) -(** [no_nested_borrows::choose_test] *) +(** [no_nested_borrows::choose_test]: forward function *) let choose_test_fwd : result unit = let* z = choose_fwd i32 true 0 0 in let* z0 = i32_add z 1 in @@ -198,7 +198,7 @@ let choose_test_fwd : result unit = (** Unit test for [no_nested_borrows::choose_test] *) let _ = assert_norm (choose_test_fwd = Return ()) -(** [no_nested_borrows::test_char] *) +(** [no_nested_borrows::test_char]: forward function *) let test_char_fwd : result char = Return 'a' @@ -212,14 +212,14 @@ and tree_t (t : Type0) = | TreeLeaf : t -> tree_t t | TreeNode : t -> node_elem_t t -> tree_t t -> tree_t t -(** [no_nested_borrows::list_length] *) +(** [no_nested_borrows::list_length]: forward function *) let rec list_length_fwd (t : Type0) (l : list_t t) : result u32 = begin match l with | ListCons x l1 -> let* i = list_length_fwd t l1 in u32_add 1 i | ListNil -> Return 0 end -(** [no_nested_borrows::list_nth_shared] *) +(** [no_nested_borrows::list_nth_shared]: forward function *) let rec list_nth_shared_fwd (t : Type0) (l : list_t t) (i : u32) : result t = begin match l with | ListCons x tl -> @@ -229,7 +229,7 @@ let rec list_nth_shared_fwd (t : Type0) (l : list_t t) (i : u32) : result t = | ListNil -> Fail Failure end -(** [no_nested_borrows::list_nth_mut] *) +(** [no_nested_borrows::list_nth_mut]: forward function *) let rec list_nth_mut_fwd (t : Type0) (l : list_t t) (i : u32) : result t = begin match l with | ListCons x tl -> @@ -239,7 +239,7 @@ let rec list_nth_mut_fwd (t : Type0) (l : list_t t) (i : u32) : result t = | ListNil -> Fail Failure end -(** [no_nested_borrows::list_nth_mut] *) +(** [no_nested_borrows::list_nth_mut]: backward function 0 *) let rec list_nth_mut_back (t : Type0) (l : list_t t) (i : u32) (ret : t) : result (list_t t) = begin match l with @@ -253,7 +253,7 @@ let rec list_nth_mut_back | ListNil -> Fail Failure end -(** [no_nested_borrows::list_rev_aux] *) +(** [no_nested_borrows::list_rev_aux]: forward function *) let rec list_rev_aux_fwd (t : Type0) (li : list_t t) (lo : list_t t) : result (list_t t) = begin match li with @@ -261,12 +261,13 @@ let rec list_rev_aux_fwd | ListNil -> Return lo end -(** [no_nested_borrows::list_rev] *) +(** [no_nested_borrows::list_rev]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) *) let list_rev_fwd_back (t : Type0) (l : list_t t) : result (list_t t) = let li = mem_replace_fwd (list_t t) l ListNil in list_rev_aux_fwd t li ListNil -(** [no_nested_borrows::test_list_functions] *) +(** [no_nested_borrows::test_list_functions]: forward function *) let test_list_functions_fwd : result unit = let l = ListNil in let l0 = ListCons 2 l in @@ -302,48 +303,48 @@ let test_list_functions_fwd : result unit = (** Unit test for [no_nested_borrows::test_list_functions] *) let _ = assert_norm (test_list_functions_fwd = Return ()) -(** [no_nested_borrows::id_mut_pair1] *) +(** [no_nested_borrows::id_mut_pair1]: forward function *) let id_mut_pair1_fwd (t1 t2 : Type0) (x : t1) (y : t2) : result (t1 & t2) = Return (x, y) -(** [no_nested_borrows::id_mut_pair1] *) +(** [no_nested_borrows::id_mut_pair1]: backward function 0 *) let id_mut_pair1_back (t1 t2 : Type0) (x : t1) (y : t2) (ret : (t1 & t2)) : result (t1 & t2) = let (x0, x1) = ret in Return (x0, x1) -(** [no_nested_borrows::id_mut_pair2] *) +(** [no_nested_borrows::id_mut_pair2]: forward function *) let id_mut_pair2_fwd (t1 t2 : Type0) (p : (t1 & t2)) : result (t1 & t2) = let (x, x0) = p in Return (x, x0) -(** [no_nested_borrows::id_mut_pair2] *) +(** [no_nested_borrows::id_mut_pair2]: backward function 0 *) let id_mut_pair2_back (t1 t2 : Type0) (p : (t1 & t2)) (ret : (t1 & t2)) : result (t1 & t2) = let (x, x0) = ret in Return (x, x0) -(** [no_nested_borrows::id_mut_pair3] *) +(** [no_nested_borrows::id_mut_pair3]: forward function *) let id_mut_pair3_fwd (t1 t2 : Type0) (x : t1) (y : t2) : result (t1 & t2) = Return (x, y) -(** [no_nested_borrows::id_mut_pair3] *) +(** [no_nested_borrows::id_mut_pair3]: backward function 0 *) let id_mut_pair3_back'a (t1 t2 : Type0) (x : t1) (y : t2) (ret : t1) : result t1 = Return ret -(** [no_nested_borrows::id_mut_pair3] *) +(** [no_nested_borrows::id_mut_pair3]: backward function 1 *) let id_mut_pair3_back'b (t1 t2 : Type0) (x : t1) (y : t2) (ret : t2) : result t2 = Return ret -(** [no_nested_borrows::id_mut_pair4] *) +(** [no_nested_borrows::id_mut_pair4]: forward function *) let id_mut_pair4_fwd (t1 t2 : Type0) (p : (t1 & t2)) : result (t1 & t2) = let (x, x0) = p in Return (x, x0) -(** [no_nested_borrows::id_mut_pair4] *) +(** [no_nested_borrows::id_mut_pair4]: backward function 0 *) let id_mut_pair4_back'a (t1 t2 : Type0) (p : (t1 & t2)) (ret : t1) : result t1 = Return ret -(** [no_nested_borrows::id_mut_pair4] *) +(** [no_nested_borrows::id_mut_pair4]: backward function 1 *) let id_mut_pair4_back'b (t1 t2 : Type0) (p : (t1 & t2)) (ret : t2) : result t2 = Return ret @@ -351,15 +352,15 @@ let id_mut_pair4_back'b (** [no_nested_borrows::StructWithTuple] *) type struct_with_tuple_t (t1 t2 : Type0) = { struct_with_tuple_p : (t1 & t2); } -(** [no_nested_borrows::new_tuple1] *) +(** [no_nested_borrows::new_tuple1]: forward function *) let new_tuple1_fwd : result (struct_with_tuple_t u32 u32) = Return { struct_with_tuple_p = (1, 2) } -(** [no_nested_borrows::new_tuple2] *) +(** [no_nested_borrows::new_tuple2]: forward function *) let new_tuple2_fwd : result (struct_with_tuple_t i16 i16) = Return { struct_with_tuple_p = (1, 2) } -(** [no_nested_borrows::new_tuple3] *) +(** [no_nested_borrows::new_tuple3]: forward function *) let new_tuple3_fwd : result (struct_with_tuple_t u64 i64) = Return { struct_with_tuple_p = (1, 2) } @@ -369,11 +370,11 @@ type struct_with_pair_t (t1 t2 : Type0) = struct_with_pair_p : pair_t t1 t2; } -(** [no_nested_borrows::new_pair1] *) +(** [no_nested_borrows::new_pair1]: forward function *) let new_pair1_fwd : result (struct_with_pair_t u32 u32) = Return { struct_with_pair_p = { pair_x = 1; pair_y = 2 } } -(** [no_nested_borrows::test_constants] *) +(** [no_nested_borrows::test_constants]: forward function *) let test_constants_fwd : result unit = let* swt = new_tuple1_fwd in let (i, _) = swt.struct_with_tuple_p in @@ -398,31 +399,32 @@ let test_constants_fwd : result unit = (** Unit test for [no_nested_borrows::test_constants] *) let _ = assert_norm (test_constants_fwd = Return ()) -(** [no_nested_borrows::test_weird_borrows1] *) +(** [no_nested_borrows::test_weird_borrows1]: forward function *) let test_weird_borrows1_fwd : result unit = Return () (** Unit test for [no_nested_borrows::test_weird_borrows1] *) let _ = assert_norm (test_weird_borrows1_fwd = Return ()) -(** [no_nested_borrows::test_mem_replace] *) +(** [no_nested_borrows::test_mem_replace]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) *) let test_mem_replace_fwd_back (px : u32) : result u32 = let y = mem_replace_fwd u32 px 1 in if not (y = 0) then Fail Failure else Return 2 -(** [no_nested_borrows::test_shared_borrow_bool1] *) +(** [no_nested_borrows::test_shared_borrow_bool1]: forward function *) let test_shared_borrow_bool1_fwd (b : bool) : result u32 = if b then Return 0 else Return 1 -(** [no_nested_borrows::test_shared_borrow_bool2] *) +(** [no_nested_borrows::test_shared_borrow_bool2]: forward function *) let test_shared_borrow_bool2_fwd : result u32 = Return 0 -(** [no_nested_borrows::test_shared_borrow_enum1] *) +(** [no_nested_borrows::test_shared_borrow_enum1]: forward function *) let test_shared_borrow_enum1_fwd (l : list_t u32) : result u32 = begin match l with | ListCons i l0 -> Return 1 | ListNil -> Return 0 end -(** [no_nested_borrows::test_shared_borrow_enum2] *) +(** [no_nested_borrows::test_shared_borrow_enum2]: forward function *) let test_shared_borrow_enum2_fwd : result u32 = Return 0 diff --git a/tests/fstar/misc/Paper.fst b/tests/fstar/misc/Paper.fst index 4ab31de3..e2d692c2 100644 --- a/tests/fstar/misc/Paper.fst +++ b/tests/fstar/misc/Paper.fst @@ -5,11 +5,12 @@ open Primitives #set-options "--z3rlimit 50 --fuel 1 --ifuel 1" -(** [paper::ref_incr] *) +(** [paper::ref_incr]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) *) let ref_incr_fwd_back (x : i32) : result i32 = i32_add x 1 -(** [paper::test_incr] *) +(** [paper::test_incr]: forward function *) let test_incr_fwd : result unit = let* x = ref_incr_fwd_back 0 in if not (x = 1) then Fail Failure else Return () @@ -17,16 +18,16 @@ let test_incr_fwd : result unit = (** Unit test for [paper::test_incr] *) let _ = assert_norm (test_incr_fwd = Return ()) -(** [paper::choose] *) +(** [paper::choose]: forward function *) let choose_fwd (t : Type0) (b : bool) (x : t) (y : t) : result t = if b then Return x else Return y -(** [paper::choose] *) +(** [paper::choose]: backward function 0 *) let choose_back (t : Type0) (b : bool) (x : t) (y : t) (ret : t) : result (t & t) = if b then Return (ret, y) else Return (x, ret) -(** [paper::test_choose] *) +(** [paper::test_choose]: forward function *) let test_choose_fwd : result unit = let* z = choose_fwd i32 true 0 0 in let* z0 = i32_add z 1 in @@ -46,7 +47,7 @@ type list_t (t : Type0) = | ListCons : t -> list_t t -> list_t t | ListNil : list_t t -(** [paper::list_nth_mut] *) +(** [paper::list_nth_mut]: forward function *) let rec list_nth_mut_fwd (t : Type0) (l : list_t t) (i : u32) : result t = begin match l with | ListCons x tl -> @@ -56,7 +57,7 @@ let rec list_nth_mut_fwd (t : Type0) (l : list_t t) (i : u32) : result t = | ListNil -> Fail Failure end -(** [paper::list_nth_mut] *) +(** [paper::list_nth_mut]: backward function 0 *) let rec list_nth_mut_back (t : Type0) (l : list_t t) (i : u32) (ret : t) : result (list_t t) = begin match l with @@ -70,14 +71,14 @@ let rec list_nth_mut_back | ListNil -> Fail Failure end -(** [paper::sum] *) +(** [paper::sum]: forward function *) let rec sum_fwd (l : list_t i32) : result i32 = begin match l with | ListCons x tl -> let* i = sum_fwd tl in i32_add x i | ListNil -> Return 0 end -(** [paper::test_nth] *) +(** [paper::test_nth]: forward function *) let test_nth_fwd : result unit = let l = ListNil in let l0 = ListCons 3 l in @@ -91,7 +92,7 @@ let test_nth_fwd : result unit = (** Unit test for [paper::test_nth] *) let _ = assert_norm (test_nth_fwd = Return ()) -(** [paper::call_choose] *) +(** [paper::call_choose]: forward function *) let call_choose_fwd (p : (u32 & u32)) : result u32 = let (px, py) = p in let* pz = choose_fwd u32 true px py in diff --git a/tests/fstar/misc/PoloniusList.fst b/tests/fstar/misc/PoloniusList.fst index e2144487..79c86606 100644 --- a/tests/fstar/misc/PoloniusList.fst +++ b/tests/fstar/misc/PoloniusList.fst @@ -10,7 +10,7 @@ type list_t (t : Type0) = | ListCons : t -> list_t t -> list_t t | ListNil : list_t t -(** [polonius_list::get_list_at_x] *) +(** [polonius_list::get_list_at_x]: forward function *) let rec get_list_at_x_fwd (ls : list_t u32) (x : u32) : result (list_t u32) = begin match ls with | ListCons hd tl -> @@ -18,7 +18,7 @@ let rec get_list_at_x_fwd (ls : list_t u32) (x : u32) : result (list_t u32) = | ListNil -> Return ListNil end -(** [polonius_list::get_list_at_x] *) +(** [polonius_list::get_list_at_x]: backward function 0 *) let rec get_list_at_x_back (ls : list_t u32) (x : u32) (ret : list_t u32) : result (list_t u32) = begin match ls with |