diff options
Diffstat (limited to 'tests/coq/misc')
-rw-r--r-- | tests/coq/misc/Loops.v | 93 |
1 files changed, 58 insertions, 35 deletions
diff --git a/tests/coq/misc/Loops.v b/tests/coq/misc/Loops.v index af920d41..8260db02 100644 --- a/tests/coq/misc/Loops.v +++ b/tests/coq/misc/Loops.v @@ -70,8 +70,31 @@ Definition sum_with_shared_borrows (n : nat) (max : u32) : result u32 := sum_with_shared_borrows_loop n max 0%u32 0%u32 . +(** [loops::sum_array]: loop 0: + Source: 'src/loops.rs', lines 50:0-58:1 *) +Fixpoint sum_array_loop + (N : usize) (n : nat) (a : array u32 N) (i : usize) (s : u32) : result u32 := + match n with + | O => Fail_ OutOfFuel + | S n1 => + if i s< N + then ( + i1 <- array_index_usize u32 N a i; + s1 <- u32_add s i1; + i2 <- usize_add i 1%usize; + sum_array_loop N n1 a i2 s1) + else Return s + end +. + +(** [loops::sum_array]: + Source: 'src/loops.rs', lines 50:0-50:52 *) +Definition sum_array (N : usize) (n : nat) (a : array u32 N) : result u32 := + sum_array_loop N n a 0%usize 0%u32 +. + (** [loops::clear]: loop 0: - Source: 'src/loops.rs', lines 52:0-58:1 *) + Source: 'src/loops.rs', lines 62:0-68:1 *) Fixpoint clear_loop (n : nat) (v : alloc_vec_Vec u32) (i : usize) : result (alloc_vec_Vec u32) := match n with @@ -92,14 +115,14 @@ Fixpoint clear_loop . (** [loops::clear]: - Source: 'src/loops.rs', lines 52:0-52:30 *) + Source: 'src/loops.rs', lines 62:0-62:30 *) Definition clear (n : nat) (v : alloc_vec_Vec u32) : result (alloc_vec_Vec u32) := clear_loop n v 0%usize . (** [loops::List] - Source: 'src/loops.rs', lines 60:0-60:16 *) + Source: 'src/loops.rs', lines 70:0-70:16 *) Inductive List_t (T : Type) := | List_Cons : T -> List_t T -> List_t T | List_Nil : List_t T @@ -109,7 +132,7 @@ Arguments List_Cons { _ }. Arguments List_Nil { _ }. (** [loops::list_mem]: loop 0: - Source: 'src/loops.rs', lines 66:0-75:1 *) + Source: 'src/loops.rs', lines 76:0-85:1 *) Fixpoint list_mem_loop (n : nat) (x : u32) (ls : List_t u32) : result bool := match n with | O => Fail_ OutOfFuel @@ -122,13 +145,13 @@ Fixpoint list_mem_loop (n : nat) (x : u32) (ls : List_t u32) : result bool := . (** [loops::list_mem]: - Source: 'src/loops.rs', lines 66:0-66:52 *) + Source: 'src/loops.rs', lines 76:0-76:52 *) Definition list_mem (n : nat) (x : u32) (ls : List_t u32) : result bool := list_mem_loop n x ls . (** [loops::list_nth_mut_loop]: loop 0: - Source: 'src/loops.rs', lines 78:0-88:1 *) + Source: 'src/loops.rs', lines 88:0-98:1 *) Fixpoint list_nth_mut_loop_loop (T : Type) (n : nat) (ls : List_t T) (i : u32) : result (T * (T -> result (List_t T))) @@ -155,7 +178,7 @@ Fixpoint list_nth_mut_loop_loop . (** [loops::list_nth_mut_loop]: - Source: 'src/loops.rs', lines 78:0-78:71 *) + Source: 'src/loops.rs', lines 88:0-88:71 *) Definition list_nth_mut_loop (T : Type) (n : nat) (ls : List_t T) (i : u32) : result (T * (T -> result (List_t T))) @@ -164,7 +187,7 @@ Definition list_nth_mut_loop . (** [loops::list_nth_shared_loop]: loop 0: - Source: 'src/loops.rs', lines 91:0-101:1 *) + Source: 'src/loops.rs', lines 101:0-111:1 *) Fixpoint list_nth_shared_loop_loop (T : Type) (n : nat) (ls : List_t T) (i : u32) : result T := match n with @@ -181,14 +204,14 @@ Fixpoint list_nth_shared_loop_loop . (** [loops::list_nth_shared_loop]: - Source: 'src/loops.rs', lines 91:0-91:66 *) + Source: 'src/loops.rs', lines 101:0-101:66 *) Definition list_nth_shared_loop (T : Type) (n : nat) (ls : List_t T) (i : u32) : result T := list_nth_shared_loop_loop T n ls i . (** [loops::get_elem_mut]: loop 0: - Source: 'src/loops.rs', lines 103:0-117:1 *) + Source: 'src/loops.rs', lines 113:0-127:1 *) Fixpoint get_elem_mut_loop (n : nat) (x : usize) (ls : List_t usize) : result (usize * (usize -> result (List_t usize))) @@ -214,7 +237,7 @@ Fixpoint get_elem_mut_loop . (** [loops::get_elem_mut]: - Source: 'src/loops.rs', lines 103:0-103:73 *) + Source: 'src/loops.rs', lines 113:0-113:73 *) Definition get_elem_mut (n : nat) (slots : alloc_vec_Vec (List_t usize)) (x : usize) : result (usize * (usize -> result (alloc_vec_Vec (List_t usize)))) @@ -230,7 +253,7 @@ Definition get_elem_mut . (** [loops::get_elem_shared]: loop 0: - Source: 'src/loops.rs', lines 119:0-133:1 *) + Source: 'src/loops.rs', lines 129:0-143:1 *) Fixpoint get_elem_shared_loop (n : nat) (x : usize) (ls : List_t usize) : result usize := match n with @@ -245,7 +268,7 @@ Fixpoint get_elem_shared_loop . (** [loops::get_elem_shared]: - Source: 'src/loops.rs', lines 119:0-119:68 *) + Source: 'src/loops.rs', lines 129:0-129:68 *) Definition get_elem_shared (n : nat) (slots : alloc_vec_Vec (List_t usize)) (x : usize) : result usize @@ -257,7 +280,7 @@ Definition get_elem_shared . (** [loops::id_mut]: - Source: 'src/loops.rs', lines 135:0-135:50 *) + Source: 'src/loops.rs', lines 145:0-145:50 *) Definition id_mut (T : Type) (ls : List_t T) : result ((List_t T) * (List_t T -> result (List_t T))) @@ -266,13 +289,13 @@ Definition id_mut . (** [loops::id_shared]: - Source: 'src/loops.rs', lines 139:0-139:45 *) + Source: 'src/loops.rs', lines 149:0-149:45 *) Definition id_shared (T : Type) (ls : List_t T) : result (List_t T) := Return ls . (** [loops::list_nth_mut_loop_with_id]: loop 0: - Source: 'src/loops.rs', lines 144:0-155:1 *) + Source: 'src/loops.rs', lines 154:0-165:1 *) Fixpoint list_nth_mut_loop_with_id_loop (T : Type) (n : nat) (i : u32) (ls : List_t T) : result (T * (T -> result (List_t T))) @@ -299,7 +322,7 @@ Fixpoint list_nth_mut_loop_with_id_loop . (** [loops::list_nth_mut_loop_with_id]: - Source: 'src/loops.rs', lines 144:0-144:75 *) + Source: 'src/loops.rs', lines 154:0-154:75 *) Definition list_nth_mut_loop_with_id (T : Type) (n : nat) (ls : List_t T) (i : u32) : result (T * (T -> result (List_t T))) @@ -313,7 +336,7 @@ Definition list_nth_mut_loop_with_id . (** [loops::list_nth_shared_loop_with_id]: loop 0: - Source: 'src/loops.rs', lines 158:0-169:1 *) + Source: 'src/loops.rs', lines 168:0-179:1 *) Fixpoint list_nth_shared_loop_with_id_loop (T : Type) (n : nat) (i : u32) (ls : List_t T) : result T := match n with @@ -331,14 +354,14 @@ Fixpoint list_nth_shared_loop_with_id_loop . (** [loops::list_nth_shared_loop_with_id]: - Source: 'src/loops.rs', lines 158:0-158:70 *) + Source: 'src/loops.rs', lines 168:0-168:70 *) Definition list_nth_shared_loop_with_id (T : Type) (n : nat) (ls : List_t T) (i : u32) : result T := ls1 <- id_shared T ls; list_nth_shared_loop_with_id_loop T n i ls1 . (** [loops::list_nth_mut_loop_pair]: loop 0: - Source: 'src/loops.rs', lines 174:0-195:1 *) + Source: 'src/loops.rs', lines 184:0-205:1 *) Fixpoint list_nth_mut_loop_pair_loop (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result ((T * T) * (T -> result (List_t T)) * (T -> result (List_t T))) @@ -372,7 +395,7 @@ Fixpoint list_nth_mut_loop_pair_loop . (** [loops::list_nth_mut_loop_pair]: - Source: 'src/loops.rs', lines 174:0-178:27 *) + Source: 'src/loops.rs', lines 184:0-188:27 *) Definition list_nth_mut_loop_pair (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result ((T * T) * (T -> result (List_t T)) * (T -> result (List_t T))) @@ -383,7 +406,7 @@ Definition list_nth_mut_loop_pair . (** [loops::list_nth_shared_loop_pair]: loop 0: - Source: 'src/loops.rs', lines 198:0-219:1 *) + Source: 'src/loops.rs', lines 208:0-229:1 *) Fixpoint list_nth_shared_loop_pair_loop (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result (T * T) @@ -407,7 +430,7 @@ Fixpoint list_nth_shared_loop_pair_loop . (** [loops::list_nth_shared_loop_pair]: - Source: 'src/loops.rs', lines 198:0-202:19 *) + Source: 'src/loops.rs', lines 208:0-212:19 *) Definition list_nth_shared_loop_pair (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result (T * T) @@ -416,7 +439,7 @@ Definition list_nth_shared_loop_pair . (** [loops::list_nth_mut_loop_pair_merge]: loop 0: - Source: 'src/loops.rs', lines 223:0-238:1 *) + Source: 'src/loops.rs', lines 233:0-248:1 *) Fixpoint list_nth_mut_loop_pair_merge_loop (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result ((T * T) * ((T * T) -> result ((List_t T) * (List_t T)))) @@ -453,7 +476,7 @@ Fixpoint list_nth_mut_loop_pair_merge_loop . (** [loops::list_nth_mut_loop_pair_merge]: - Source: 'src/loops.rs', lines 223:0-227:27 *) + Source: 'src/loops.rs', lines 233:0-237:27 *) Definition list_nth_mut_loop_pair_merge (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result ((T * T) * ((T * T) -> result ((List_t T) * (List_t T)))) @@ -464,7 +487,7 @@ Definition list_nth_mut_loop_pair_merge . (** [loops::list_nth_shared_loop_pair_merge]: loop 0: - Source: 'src/loops.rs', lines 241:0-256:1 *) + Source: 'src/loops.rs', lines 251:0-266:1 *) Fixpoint list_nth_shared_loop_pair_merge_loop (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result (T * T) @@ -489,7 +512,7 @@ Fixpoint list_nth_shared_loop_pair_merge_loop . (** [loops::list_nth_shared_loop_pair_merge]: - Source: 'src/loops.rs', lines 241:0-245:19 *) + Source: 'src/loops.rs', lines 251:0-255:19 *) Definition list_nth_shared_loop_pair_merge (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result (T * T) @@ -498,7 +521,7 @@ Definition list_nth_shared_loop_pair_merge . (** [loops::list_nth_mut_shared_loop_pair]: loop 0: - Source: 'src/loops.rs', lines 259:0-274:1 *) + Source: 'src/loops.rs', lines 269:0-284:1 *) Fixpoint list_nth_mut_shared_loop_pair_loop (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result ((T * T) * (T -> result (List_t T))) @@ -529,7 +552,7 @@ Fixpoint list_nth_mut_shared_loop_pair_loop . (** [loops::list_nth_mut_shared_loop_pair]: - Source: 'src/loops.rs', lines 259:0-263:23 *) + Source: 'src/loops.rs', lines 269:0-273:23 *) Definition list_nth_mut_shared_loop_pair (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result ((T * T) * (T -> result (List_t T))) @@ -540,7 +563,7 @@ Definition list_nth_mut_shared_loop_pair . (** [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: - Source: 'src/loops.rs', lines 278:0-293:1 *) + Source: 'src/loops.rs', lines 288:0-303:1 *) Fixpoint list_nth_mut_shared_loop_pair_merge_loop (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result ((T * T) * (T -> result (List_t T))) @@ -571,7 +594,7 @@ Fixpoint list_nth_mut_shared_loop_pair_merge_loop . (** [loops::list_nth_mut_shared_loop_pair_merge]: - Source: 'src/loops.rs', lines 278:0-282:23 *) + Source: 'src/loops.rs', lines 288:0-292:23 *) Definition list_nth_mut_shared_loop_pair_merge (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result ((T * T) * (T -> result (List_t T))) @@ -582,7 +605,7 @@ Definition list_nth_mut_shared_loop_pair_merge . (** [loops::list_nth_shared_mut_loop_pair]: loop 0: - Source: 'src/loops.rs', lines 297:0-312:1 *) + Source: 'src/loops.rs', lines 307:0-322:1 *) Fixpoint list_nth_shared_mut_loop_pair_loop (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result ((T * T) * (T -> result (List_t T))) @@ -613,7 +636,7 @@ Fixpoint list_nth_shared_mut_loop_pair_loop . (** [loops::list_nth_shared_mut_loop_pair]: - Source: 'src/loops.rs', lines 297:0-301:23 *) + Source: 'src/loops.rs', lines 307:0-311:23 *) Definition list_nth_shared_mut_loop_pair (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result ((T * T) * (T -> result (List_t T))) @@ -624,7 +647,7 @@ Definition list_nth_shared_mut_loop_pair . (** [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: - Source: 'src/loops.rs', lines 316:0-331:1 *) + Source: 'src/loops.rs', lines 326:0-341:1 *) Fixpoint list_nth_shared_mut_loop_pair_merge_loop (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result ((T * T) * (T -> result (List_t T))) @@ -655,7 +678,7 @@ Fixpoint list_nth_shared_mut_loop_pair_merge_loop . (** [loops::list_nth_shared_mut_loop_pair_merge]: - Source: 'src/loops.rs', lines 316:0-320:23 *) + Source: 'src/loops.rs', lines 326:0-330:23 *) Definition list_nth_shared_mut_loop_pair_merge (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) : result ((T * T) * (T -> result (List_t T))) |