summaryrefslogtreecommitdiff
path: root/tests/coq
diff options
context:
space:
mode:
Diffstat (limited to 'tests/coq')
-rw-r--r--tests/coq/array/Array.v421
-rw-r--r--tests/coq/array/Primitives.v137
-rw-r--r--tests/coq/betree/BetreeMain_Funs.v1052
-rw-r--r--tests/coq/betree/BetreeMain_FunsExternal_Template.v10
-rw-r--r--tests/coq/betree/BetreeMain_Types.v16
-rw-r--r--tests/coq/betree/Primitives.v137
-rw-r--r--tests/coq/hashmap/Hashmap_Funs.v503
-rw-r--r--tests/coq/hashmap/Primitives.v137
-rw-r--r--tests/coq/hashmap_on_disk/HashmapMain_Funs.v522
-rw-r--r--tests/coq/hashmap_on_disk/HashmapMain_FunsExternal_Template.v4
-rw-r--r--tests/coq/hashmap_on_disk/Primitives.v137
-rw-r--r--tests/coq/misc/Bitwise.v10
-rw-r--r--tests/coq/misc/Constants.v18
-rw-r--r--tests/coq/misc/External_Funs.v95
-rw-r--r--tests/coq/misc/External_FunsExternal_Template.v20
-rw-r--r--tests/coq/misc/Loops.v729
-rw-r--r--tests/coq/misc/Paper.v100
-rw-r--r--tests/coq/misc/PoloniusList.v34
-rw-r--r--tests/coq/misc/Primitives.v23
-rw-r--r--tests/coq/misc/_CoqProject2
-rw-r--r--tests/coq/traits/Primitives.v137
-rw-r--r--tests/coq/traits/Traits.v153
22 files changed, 1731 insertions, 2666 deletions
diff --git a/tests/coq/array/Array.v b/tests/coq/array/Array.v
index 1f2cc0e0..faa0e92c 100644
--- a/tests/coq/array/Array.v
+++ b/tests/coq/array/Array.v
@@ -12,108 +12,98 @@ Module Array.
Source: 'src/array.rs', lines 3:0-3:11 *)
Inductive AB_t := | AB_A : AB_t | AB_B : AB_t.
-(** [array::incr]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [array::incr]:
Source: 'src/array.rs', lines 8:0-8:24 *)
Definition incr (x : u32) : result u32 :=
u32_add x 1%u32.
-(** [array::array_to_shared_slice_]: forward function
+(** [array::array_to_shared_slice_]:
Source: 'src/array.rs', lines 16:0-16:53 *)
Definition array_to_shared_slice_
(T : Type) (s : array T 32%usize) : result (slice T) :=
array_to_slice T 32%usize s
.
-(** [array::array_to_mut_slice_]: forward function
+(** [array::array_to_mut_slice_]:
Source: 'src/array.rs', lines 21:0-21:58 *)
Definition array_to_mut_slice_
- (T : Type) (s : array T 32%usize) : result (slice T) :=
- array_to_slice T 32%usize s
-.
-
-(** [array::array_to_mut_slice_]: backward function 0
- Source: 'src/array.rs', lines 21:0-21:58 *)
-Definition array_to_mut_slice__back
- (T : Type) (s : array T 32%usize) (ret : slice T) :
- result (array T 32%usize)
+ (T : Type) (s : array T 32%usize) :
+ result ((slice T) * (slice T -> result (array T 32%usize)))
:=
- array_from_slice T 32%usize s ret
+ p <- array_to_slice_mut T 32%usize s;
+ let (s1, to_slice_mut_back) := p in
+ let back := fun (ret : slice T) => to_slice_mut_back ret in
+ Return (s1, back)
.
-(** [array::array_len]: forward function
+(** [array::array_len]:
Source: 'src/array.rs', lines 25:0-25:40 *)
Definition array_len (T : Type) (s : array T 32%usize) : result usize :=
- s0 <- array_to_slice T 32%usize s; let i := slice_len T s0 in Return i
+ s1 <- array_to_slice T 32%usize s; let i := slice_len T s1 in Return i
.
-(** [array::shared_array_len]: forward function
+(** [array::shared_array_len]:
Source: 'src/array.rs', lines 29:0-29:48 *)
Definition shared_array_len (T : Type) (s : array T 32%usize) : result usize :=
- s0 <- array_to_slice T 32%usize s; let i := slice_len T s0 in Return i
+ s1 <- array_to_slice T 32%usize s; let i := slice_len T s1 in Return i
.
-(** [array::shared_slice_len]: forward function
+(** [array::shared_slice_len]:
Source: 'src/array.rs', lines 33:0-33:44 *)
Definition shared_slice_len (T : Type) (s : slice T) : result usize :=
let i := slice_len T s in Return i
.
-(** [array::index_array_shared]: forward function
+(** [array::index_array_shared]:
Source: 'src/array.rs', lines 37:0-37:57 *)
Definition index_array_shared
(T : Type) (s : array T 32%usize) (i : usize) : result T :=
array_index_usize T 32%usize s i
.
-(** [array::index_array_u32]: forward function
+(** [array::index_array_u32]:
Source: 'src/array.rs', lines 44:0-44:53 *)
Definition index_array_u32 (s : array u32 32%usize) (i : usize) : result u32 :=
array_index_usize u32 32%usize s i
.
-(** [array::index_array_copy]: forward function
+(** [array::index_array_copy]:
Source: 'src/array.rs', lines 48:0-48:45 *)
Definition index_array_copy (x : array u32 32%usize) : result u32 :=
array_index_usize u32 32%usize x 0%usize
.
-(** [array::index_mut_array]: forward function
+(** [array::index_mut_array]:
Source: 'src/array.rs', lines 52:0-52:62 *)
Definition index_mut_array
- (T : Type) (s : array T 32%usize) (i : usize) : result T :=
- array_index_usize T 32%usize s i
-.
-
-(** [array::index_mut_array]: backward function 0
- Source: 'src/array.rs', lines 52:0-52:62 *)
-Definition index_mut_array_back
- (T : Type) (s : array T 32%usize) (i : usize) (ret : T) :
- result (array T 32%usize)
+ (T : Type) (s : array T 32%usize) (i : usize) :
+ result (T * (T -> result (array T 32%usize)))
:=
- array_update_usize T 32%usize s i ret
+ p <- array_index_mut_usize T 32%usize s i;
+ let (t, index_mut_back) := p in
+ let back := fun (ret : T) => index_mut_back ret in
+ Return (t, back)
.
-(** [array::index_slice]: forward function
+(** [array::index_slice]:
Source: 'src/array.rs', lines 56:0-56:46 *)
Definition index_slice (T : Type) (s : slice T) (i : usize) : result T :=
slice_index_usize T s i
.
-(** [array::index_mut_slice]: forward function
+(** [array::index_mut_slice]:
Source: 'src/array.rs', lines 60:0-60:58 *)
-Definition index_mut_slice (T : Type) (s : slice T) (i : usize) : result T :=
- slice_index_usize T s i
-.
-
-(** [array::index_mut_slice]: backward function 0
- Source: 'src/array.rs', lines 60:0-60:58 *)
-Definition index_mut_slice_back
- (T : Type) (s : slice T) (i : usize) (ret : T) : result (slice T) :=
- slice_update_usize T s i ret
+Definition index_mut_slice
+ (T : Type) (s : slice T) (i : usize) :
+ result (T * (T -> result (slice T)))
+ :=
+ p <- slice_index_mut_usize T s i;
+ let (t, index_mut_back) := p in
+ let back := fun (ret : T) => index_mut_back ret in
+ Return (t, back)
.
-(** [array::slice_subslice_shared_]: forward function
+(** [array::slice_subslice_shared_]:
Source: 'src/array.rs', lines 64:0-64:70 *)
Definition slice_subslice_shared_
(x : slice u32) (y : usize) (z : usize) : result (slice u32) :=
@@ -122,47 +112,41 @@ Definition slice_subslice_shared_
{| core_ops_range_Range_start := y; core_ops_range_Range_end_ := z |}
.
-(** [array::slice_subslice_mut_]: forward function
+(** [array::slice_subslice_mut_]:
Source: 'src/array.rs', lines 68:0-68:75 *)
Definition slice_subslice_mut_
- (x : slice u32) (y : usize) (z : usize) : result (slice u32) :=
- core_slice_index_Slice_index_mut u32 (core_ops_range_Range usize)
- (core_slice_index_SliceIndexRangeUsizeSliceTInst u32) x
- {| core_ops_range_Range_start := y; core_ops_range_Range_end_ := z |}
-.
-
-(** [array::slice_subslice_mut_]: backward function 0
- Source: 'src/array.rs', lines 68:0-68:75 *)
-Definition slice_subslice_mut__back
- (x : slice u32) (y : usize) (z : usize) (ret : slice u32) :
- result (slice u32)
+ (x : slice u32) (y : usize) (z : usize) :
+ result ((slice u32) * (slice u32 -> result (slice u32)))
:=
- core_slice_index_Slice_index_mut_back u32 (core_ops_range_Range usize)
- (core_slice_index_SliceIndexRangeUsizeSliceTInst u32) x
- {| core_ops_range_Range_start := y; core_ops_range_Range_end_ := z |} ret
+ p <-
+ core_slice_index_Slice_index_mut u32 (core_ops_range_Range usize)
+ (core_slice_index_SliceIndexRangeUsizeSliceTInst u32) x
+ {| core_ops_range_Range_start := y; core_ops_range_Range_end_ := z |};
+ let (s, index_mut_back) := p in
+ let back := fun (ret : slice u32) => index_mut_back ret in
+ Return (s, back)
.
-(** [array::array_to_slice_shared_]: forward function
+(** [array::array_to_slice_shared_]:
Source: 'src/array.rs', lines 72:0-72:54 *)
Definition array_to_slice_shared_
(x : array u32 32%usize) : result (slice u32) :=
array_to_slice u32 32%usize x
.
-(** [array::array_to_slice_mut_]: forward function
+(** [array::array_to_slice_mut_]:
Source: 'src/array.rs', lines 76:0-76:59 *)
-Definition array_to_slice_mut_ (x : array u32 32%usize) : result (slice u32) :=
- array_to_slice u32 32%usize x
-.
-
-(** [array::array_to_slice_mut_]: backward function 0
- Source: 'src/array.rs', lines 76:0-76:59 *)
-Definition array_to_slice_mut__back
- (x : array u32 32%usize) (ret : slice u32) : result (array u32 32%usize) :=
- array_from_slice u32 32%usize x ret
+Definition array_to_slice_mut_
+ (x : array u32 32%usize) :
+ result ((slice u32) * (slice u32 -> result (array u32 32%usize)))
+ :=
+ p <- array_to_slice_mut u32 32%usize x;
+ let (s, to_slice_mut_back) := p in
+ let back := fun (ret : slice u32) => to_slice_mut_back ret in
+ Return (s, back)
.
-(** [array::array_subslice_shared_]: forward function
+(** [array::array_subslice_shared_]:
Source: 'src/array.rs', lines 80:0-80:74 *)
Definition array_subslice_shared_
(x : array u32 32%usize) (y : usize) (z : usize) : result (slice u32) :=
@@ -172,41 +156,35 @@ Definition array_subslice_shared_
{| core_ops_range_Range_start := y; core_ops_range_Range_end_ := z |}
.
-(** [array::array_subslice_mut_]: forward function
+(** [array::array_subslice_mut_]:
Source: 'src/array.rs', lines 84:0-84:79 *)
Definition array_subslice_mut_
- (x : array u32 32%usize) (y : usize) (z : usize) : result (slice u32) :=
- core_array_Array_index_mut u32 (core_ops_range_Range usize) 32%usize
- (core_ops_index_IndexMutSliceTIInst u32 (core_ops_range_Range usize)
- (core_slice_index_SliceIndexRangeUsizeSliceTInst u32)) x
- {| core_ops_range_Range_start := y; core_ops_range_Range_end_ := z |}
-.
-
-(** [array::array_subslice_mut_]: backward function 0
- Source: 'src/array.rs', lines 84:0-84:79 *)
-Definition array_subslice_mut__back
- (x : array u32 32%usize) (y : usize) (z : usize) (ret : slice u32) :
- result (array u32 32%usize)
+ (x : array u32 32%usize) (y : usize) (z : usize) :
+ result ((slice u32) * (slice u32 -> result (array u32 32%usize)))
:=
- core_array_Array_index_mut_back u32 (core_ops_range_Range usize) 32%usize
- (core_ops_index_IndexMutSliceTIInst u32 (core_ops_range_Range usize)
- (core_slice_index_SliceIndexRangeUsizeSliceTInst u32)) x
- {| core_ops_range_Range_start := y; core_ops_range_Range_end_ := z |} ret
+ p <-
+ core_array_Array_index_mut u32 (core_ops_range_Range usize) 32%usize
+ (core_ops_index_IndexMutSliceTIInst u32 (core_ops_range_Range usize)
+ (core_slice_index_SliceIndexRangeUsizeSliceTInst u32)) x
+ {| core_ops_range_Range_start := y; core_ops_range_Range_end_ := z |};
+ let (s, index_mut_back) := p in
+ let back := fun (ret : slice u32) => index_mut_back ret in
+ Return (s, back)
.
-(** [array::index_slice_0]: forward function
+(** [array::index_slice_0]:
Source: 'src/array.rs', lines 88:0-88:38 *)
Definition index_slice_0 (T : Type) (s : slice T) : result T :=
slice_index_usize T s 0%usize
.
-(** [array::index_array_0]: forward function
+(** [array::index_array_0]:
Source: 'src/array.rs', lines 92:0-92:42 *)
Definition index_array_0 (T : Type) (s : array T 32%usize) : result T :=
array_index_usize T 32%usize s 0%usize
.
-(** [array::index_index_array]: forward function
+(** [array::index_index_array]:
Source: 'src/array.rs', lines 103:0-103:71 *)
Definition index_index_array
(s : array (array u32 32%usize) 32%usize) (i : usize) (j : usize) :
@@ -216,157 +194,164 @@ Definition index_index_array
array_index_usize u32 32%usize a j
.
-(** [array::update_update_array]: forward function
+(** [array::update_update_array]:
Source: 'src/array.rs', lines 114:0-114:70 *)
Definition update_update_array
(s : array (array u32 32%usize) 32%usize) (i : usize) (j : usize) :
result unit
:=
- a <- array_index_usize (array u32 32%usize) 32%usize s i;
- a0 <- array_update_usize u32 32%usize a j 0%u32;
- _ <- array_update_usize (array u32 32%usize) 32%usize s i a0;
+ p <- array_index_mut_usize (array u32 32%usize) 32%usize s i;
+ let (a, index_mut_back) := p in
+ p1 <- array_index_mut_usize u32 32%usize a j;
+ let (_, index_mut_back1) := p1 in
+ a1 <- index_mut_back1 0%u32;
+ _ <- index_mut_back a1;
Return tt
.
-(** [array::array_local_deep_copy]: forward function
+(** [array::array_local_deep_copy]:
Source: 'src/array.rs', lines 118:0-118:43 *)
Definition array_local_deep_copy (x : array u32 32%usize) : result unit :=
Return tt
.
-(** [array::take_array]: forward function
+(** [array::take_array]:
Source: 'src/array.rs', lines 122:0-122:30 *)
Definition take_array (a : array u32 2%usize) : result unit :=
Return tt.
-(** [array::take_array_borrow]: forward function
+(** [array::take_array_borrow]:
Source: 'src/array.rs', lines 123:0-123:38 *)
Definition take_array_borrow (a : array u32 2%usize) : result unit :=
Return tt
.
-(** [array::take_slice]: forward function
+(** [array::take_slice]:
Source: 'src/array.rs', lines 124:0-124:28 *)
Definition take_slice (s : slice u32) : result unit :=
Return tt.
-(** [array::take_mut_slice]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [array::take_mut_slice]:
Source: 'src/array.rs', lines 125:0-125:36 *)
Definition take_mut_slice (s : slice u32) : result (slice u32) :=
Return s.
-(** [array::const_array]: forward function
+(** [array::const_array]:
Source: 'src/array.rs', lines 127:0-127:32 *)
Definition const_array : result (array u32 2%usize) :=
Return (mk_array u32 2%usize [ 0%u32; 0%u32 ])
.
-(** [array::const_slice]: forward function
+(** [array::const_slice]:
Source: 'src/array.rs', lines 131:0-131:20 *)
Definition const_slice : result unit :=
_ <- array_to_slice u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
Return tt
.
-(** [array::take_all]: forward function
+(** [array::take_all]:
Source: 'src/array.rs', lines 141:0-141:17 *)
Definition take_all : result unit :=
_ <- take_array (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
+ _ <- take_array (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
_ <- take_array_borrow (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
s <- array_to_slice u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
_ <- take_slice s;
- s0 <- array_to_slice u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
- s1 <- take_mut_slice s0;
- _ <- array_from_slice u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]) s1;
+ p <- array_to_slice_mut u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
+ let (s1, to_slice_mut_back) := p in
+ s2 <- take_mut_slice s1;
+ _ <- to_slice_mut_back s2;
Return tt
.
-(** [array::index_array]: forward function
+(** [array::index_array]:
Source: 'src/array.rs', lines 155:0-155:38 *)
Definition index_array (x : array u32 2%usize) : result u32 :=
array_index_usize u32 2%usize x 0%usize
.
-(** [array::index_array_borrow]: forward function
+(** [array::index_array_borrow]:
Source: 'src/array.rs', lines 158:0-158:46 *)
Definition index_array_borrow (x : array u32 2%usize) : result u32 :=
array_index_usize u32 2%usize x 0%usize
.
-(** [array::index_slice_u32_0]: forward function
+(** [array::index_slice_u32_0]:
Source: 'src/array.rs', lines 162:0-162:42 *)
Definition index_slice_u32_0 (x : slice u32) : result u32 :=
slice_index_usize u32 x 0%usize
.
-(** [array::index_mut_slice_u32_0]: forward function
+(** [array::index_mut_slice_u32_0]:
Source: 'src/array.rs', lines 166:0-166:50 *)
-Definition index_mut_slice_u32_0 (x : slice u32) : result u32 :=
- slice_index_usize u32 x 0%usize
+Definition index_mut_slice_u32_0
+ (x : slice u32) : result (u32 * (slice u32)) :=
+ i <- slice_index_usize u32 x 0%usize; Return (i, x)
.
-(** [array::index_mut_slice_u32_0]: backward function 0
- Source: 'src/array.rs', lines 166:0-166:50 *)
-Definition index_mut_slice_u32_0_back (x : slice u32) : result (slice u32) :=
- _ <- slice_index_usize u32 x 0%usize; Return x
-.
-
-(** [array::index_all]: forward function
+(** [array::index_all]:
Source: 'src/array.rs', lines 170:0-170:25 *)
Definition index_all : result u32 :=
i <- index_array (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
- i0 <- index_array (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
- i1 <- u32_add i i0;
- i2 <- index_array_borrow (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
- i3 <- u32_add i1 i2;
+ i1 <- index_array (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
+ i2 <- u32_add i i1;
+ i3 <- index_array_borrow (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
+ i4 <- u32_add i2 i3;
s <- array_to_slice u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
- i4 <- index_slice_u32_0 s;
- i5 <- u32_add i3 i4;
- s0 <- array_to_slice u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
- i6 <- index_mut_slice_u32_0 s0;
- i7 <- u32_add i5 i6;
- s1 <- index_mut_slice_u32_0_back s0;
- _ <- array_from_slice u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]) s1;
- Return i7
-.
-
-(** [array::update_array]: forward function
+ i5 <- index_slice_u32_0 s;
+ i6 <- u32_add i4 i5;
+ p <- array_to_slice_mut u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
+ let (s1, to_slice_mut_back) := p in
+ p1 <- index_mut_slice_u32_0 s1;
+ let (i7, s2) := p1 in
+ i8 <- u32_add i6 i7;
+ _ <- to_slice_mut_back s2;
+ Return i8
+.
+
+(** [array::update_array]:
Source: 'src/array.rs', lines 184:0-184:36 *)
Definition update_array (x : array u32 2%usize) : result unit :=
- _ <- array_update_usize u32 2%usize x 0%usize 1%u32; Return tt
+ p <- array_index_mut_usize u32 2%usize x 0%usize;
+ let (_, index_mut_back) := p in
+ _ <- index_mut_back 1%u32;
+ Return tt
.
-(** [array::update_array_mut_borrow]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [array::update_array_mut_borrow]:
Source: 'src/array.rs', lines 187:0-187:48 *)
Definition update_array_mut_borrow
(x : array u32 2%usize) : result (array u32 2%usize) :=
- array_update_usize u32 2%usize x 0%usize 1%u32
+ p <- array_index_mut_usize u32 2%usize x 0%usize;
+ let (_, index_mut_back) := p in
+ index_mut_back 1%u32
.
-(** [array::update_mut_slice]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [array::update_mut_slice]:
Source: 'src/array.rs', lines 190:0-190:38 *)
Definition update_mut_slice (x : slice u32) : result (slice u32) :=
- slice_update_usize u32 x 0%usize 1%u32
+ p <- slice_index_mut_usize u32 x 0%usize;
+ let (_, index_mut_back) := p in
+ index_mut_back 1%u32
.
-(** [array::update_all]: forward function
+(** [array::update_all]:
Source: 'src/array.rs', lines 194:0-194:19 *)
Definition update_all : result unit :=
_ <- update_array (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
- x <- update_array_mut_borrow (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
- s <- array_to_slice u32 2%usize x;
- s0 <- update_mut_slice s;
- _ <- array_from_slice u32 2%usize x s0;
+ _ <- update_array (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
+ a <- update_array_mut_borrow (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
+ p <- array_to_slice_mut u32 2%usize a;
+ let (s, to_slice_mut_back) := p in
+ s1 <- update_mut_slice s;
+ _ <- to_slice_mut_back s1;
Return tt
.
-(** [array::range_all]: forward function
+(** [array::range_all]:
Source: 'src/array.rs', lines 205:0-205:18 *)
Definition range_all : result unit :=
- s <-
+ p <-
core_array_Array_index_mut u32 (core_ops_range_Range usize) 4%usize
(core_ops_index_IndexMutSliceTIInst u32 (core_ops_range_Range usize)
(core_slice_index_SliceIndexRangeUsizeSliceTInst u32))
@@ -375,127 +360,119 @@ Definition range_all : result unit :=
core_ops_range_Range_start := 1%usize;
core_ops_range_Range_end_ := 3%usize
|};
- s0 <- update_mut_slice s;
- _ <-
- core_array_Array_index_mut_back u32 (core_ops_range_Range usize) 4%usize
- (core_ops_index_IndexMutSliceTIInst u32 (core_ops_range_Range usize)
- (core_slice_index_SliceIndexRangeUsizeSliceTInst u32))
- (mk_array u32 4%usize [ 0%u32; 0%u32; 0%u32; 0%u32 ])
- {|
- core_ops_range_Range_start := 1%usize;
- core_ops_range_Range_end_ := 3%usize
- |} s0;
+ let (s, index_mut_back) := p in
+ s1 <- update_mut_slice s;
+ _ <- index_mut_back s1;
Return tt
.
-(** [array::deref_array_borrow]: forward function
+(** [array::deref_array_borrow]:
Source: 'src/array.rs', lines 214:0-214:46 *)
Definition deref_array_borrow (x : array u32 2%usize) : result u32 :=
array_index_usize u32 2%usize x 0%usize
.
-(** [array::deref_array_mut_borrow]: forward function
- Source: 'src/array.rs', lines 219:0-219:54 *)
-Definition deref_array_mut_borrow (x : array u32 2%usize) : result u32 :=
- array_index_usize u32 2%usize x 0%usize
-.
-
-(** [array::deref_array_mut_borrow]: backward function 0
+(** [array::deref_array_mut_borrow]:
Source: 'src/array.rs', lines 219:0-219:54 *)
-Definition deref_array_mut_borrow_back
- (x : array u32 2%usize) : result (array u32 2%usize) :=
- _ <- array_index_usize u32 2%usize x 0%usize; Return x
+Definition deref_array_mut_borrow
+ (x : array u32 2%usize) : result (u32 * (array u32 2%usize)) :=
+ i <- array_index_usize u32 2%usize x 0%usize; Return (i, x)
.
-(** [array::take_array_t]: forward function
+(** [array::take_array_t]:
Source: 'src/array.rs', lines 227:0-227:31 *)
Definition take_array_t (a : array AB_t 2%usize) : result unit :=
Return tt.
-(** [array::non_copyable_array]: forward function
+(** [array::non_copyable_array]:
Source: 'src/array.rs', lines 229:0-229:27 *)
Definition non_copyable_array : result unit :=
_ <- take_array_t (mk_array AB_t 2%usize [ AB_A; AB_B ]); Return tt
.
-(** [array::sum]: loop 0: forward function
+(** [array::sum]: loop 0:
Source: 'src/array.rs', lines 242:0-250:1 *)
Fixpoint sum_loop
- (n : nat) (s : slice u32) (sum0 : u32) (i : usize) : result u32 :=
+ (n : nat) (s : slice u32) (sum1 : u32) (i : usize) : result u32 :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
- let i0 := slice_len u32 s in
- if i s< i0
+ | S n1 =>
+ let i1 := slice_len u32 s in
+ if i s< i1
then (
- i1 <- slice_index_usize u32 s i;
- sum1 <- u32_add sum0 i1;
- i2 <- usize_add i 1%usize;
- sum_loop n0 s sum1 i2)
- else Return sum0
+ i2 <- slice_index_usize u32 s i;
+ sum3 <- u32_add sum1 i2;
+ i3 <- usize_add i 1%usize;
+ sum_loop n1 s sum3 i3)
+ else Return sum1
end
.
-(** [array::sum]: forward function
+(** [array::sum]:
Source: 'src/array.rs', lines 242:0-242:28 *)
Definition sum (n : nat) (s : slice u32) : result u32 :=
sum_loop n s 0%u32 0%usize
.
-(** [array::sum2]: loop 0: forward function
+(** [array::sum2]: loop 0:
Source: 'src/array.rs', lines 252:0-261:1 *)
Fixpoint sum2_loop
- (n : nat) (s : slice u32) (s2 : slice u32) (sum0 : u32) (i : usize) :
+ (n : nat) (s : slice u32) (s2 : slice u32) (sum1 : u32) (i : usize) :
result u32
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
- let i0 := slice_len u32 s in
- if i s< i0
+ | S n1 =>
+ let i1 := slice_len u32 s in
+ if i s< i1
then (
- i1 <- slice_index_usize u32 s i;
- i2 <- slice_index_usize u32 s2 i;
- i3 <- u32_add i1 i2;
- sum1 <- u32_add sum0 i3;
- i4 <- usize_add i 1%usize;
- sum2_loop n0 s s2 sum1 i4)
- else Return sum0
+ i2 <- slice_index_usize u32 s i;
+ i3 <- slice_index_usize u32 s2 i;
+ i4 <- u32_add i2 i3;
+ sum3 <- u32_add sum1 i4;
+ i5 <- usize_add i 1%usize;
+ sum2_loop n1 s s2 sum3 i5)
+ else Return sum1
end
.
-(** [array::sum2]: forward function
+(** [array::sum2]:
Source: 'src/array.rs', lines 252:0-252:41 *)
Definition sum2 (n : nat) (s : slice u32) (s2 : slice u32) : result u32 :=
let i := slice_len u32 s in
- let i0 := slice_len u32 s2 in
- if negb (i s= i0) then Fail_ Failure else sum2_loop n s s2 0%u32 0%usize
+ let i1 := slice_len u32 s2 in
+ if negb (i s= i1) then Fail_ Failure else sum2_loop n s s2 0%u32 0%usize
.
-(** [array::f0]: forward function
+(** [array::f0]:
Source: 'src/array.rs', lines 263:0-263:11 *)
Definition f0 : result unit :=
- s <- array_to_slice u32 2%usize (mk_array u32 2%usize [ 1%u32; 2%u32 ]);
- s0 <- slice_update_usize u32 s 0%usize 1%u32;
- _ <- array_from_slice u32 2%usize (mk_array u32 2%usize [ 1%u32; 2%u32 ]) s0;
+ p <- array_to_slice_mut u32 2%usize (mk_array u32 2%usize [ 1%u32; 2%u32 ]);
+ let (s, to_slice_mut_back) := p in
+ p1 <- slice_index_mut_usize u32 s 0%usize;
+ let (_, index_mut_back) := p1 in
+ s1 <- index_mut_back 1%u32;
+ _ <- to_slice_mut_back s1;
Return tt
.
-(** [array::f1]: forward function
+(** [array::f1]:
Source: 'src/array.rs', lines 268:0-268:11 *)
Definition f1 : result unit :=
- _ <-
- array_update_usize u32 2%usize (mk_array u32 2%usize [ 1%u32; 2%u32 ])
- 0%usize 1%u32;
+ p <-
+ array_index_mut_usize u32 2%usize (mk_array u32 2%usize [ 1%u32; 2%u32 ])
+ 0%usize;
+ let (_, index_mut_back) := p in
+ _ <- index_mut_back 1%u32;
Return tt
.
-(** [array::f2]: forward function
+(** [array::f2]:
Source: 'src/array.rs', lines 273:0-273:17 *)
Definition f2 (i : u32) : result unit :=
Return tt.
-(** [array::f4]: forward function
+(** [array::f4]:
Source: 'src/array.rs', lines 282:0-282:54 *)
Definition f4
(x : array u32 32%usize) (y : usize) (z : usize) : result (slice u32) :=
@@ -505,7 +482,7 @@ Definition f4
{| core_ops_range_Range_start := y; core_ops_range_Range_end_ := z |}
.
-(** [array::f3]: forward function
+(** [array::f3]:
Source: 'src/array.rs', lines 275:0-275:18 *)
Definition f3 (n : nat) : result u32 :=
i <-
@@ -514,8 +491,8 @@ Definition f3 (n : nat) : result u32 :=
_ <- f2 i;
let b := array_repeat u32 32%usize 0%u32 in
s <- array_to_slice u32 2%usize (mk_array u32 2%usize [ 1%u32; 2%u32 ]);
- s0 <- f4 b 16%usize 18%usize;
- sum2 n s s0
+ s1 <- f4 b 16%usize 18%usize;
+ sum2 n s s1
.
(** [array::SZ]
@@ -523,21 +500,25 @@ Definition f3 (n : nat) : result u32 :=
Definition sz_body : result usize := Return 32%usize.
Definition sz_c : usize := sz_body%global.
-(** [array::f5]: forward function
+(** [array::f5]:
Source: 'src/array.rs', lines 289:0-289:31 *)
Definition f5 (x : array u32 32%usize) : result u32 :=
array_index_usize u32 32%usize x 0%usize
.
-(** [array::ite]: forward function
+(** [array::ite]:
Source: 'src/array.rs', lines 294:0-294:12 *)
Definition ite : result unit :=
- s <- array_to_slice u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
- s0 <- array_to_slice u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
- s1 <- index_mut_slice_u32_0_back s0;
- _ <- array_from_slice u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]) s1;
- s2 <- index_mut_slice_u32_0_back s;
- _ <- array_from_slice u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]) s2;
+ p <- array_to_slice_mut u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
+ let (s, to_slice_mut_back) := p in
+ p1 <- index_mut_slice_u32_0 s;
+ let (_, s1) := p1 in
+ p2 <- array_to_slice_mut u32 2%usize (mk_array u32 2%usize [ 0%u32; 0%u32 ]);
+ let (s2, to_slice_mut_back1) := p2 in
+ p3 <- index_mut_slice_u32_0 s2;
+ let (_, s3) := p3 in
+ _ <- to_slice_mut_back1 s3;
+ _ <- to_slice_mut_back s1;
Return tt
.
diff --git a/tests/coq/array/Primitives.v b/tests/coq/array/Primitives.v
index 84280b96..990e27e4 100644
--- a/tests/coq/array/Primitives.v
+++ b/tests/coq/array/Primitives.v
@@ -67,8 +67,7 @@ Definition string := Coq.Strings.String.string.
Definition char := Coq.Strings.Ascii.ascii.
Definition char_of_byte := Coq.Strings.Ascii.ascii_of_byte.
-Definition core_mem_replace (a : Type) (x : a) (y : a) : a := x .
-Definition core_mem_replace_back (a : Type) (x : a) (y : a) : a := y .
+Definition core_mem_replace (a : Type) (x : a) (y : a) : a * a := (x, x) .
Record mut_raw_ptr (T : Type) := { mut_raw_ptr_v : T }.
Record const_raw_ptr (T : Type) := { const_raw_ptr_v : T }.
@@ -504,13 +503,15 @@ Arguments core_ops_index_Index_index {_ _}.
(* Trait declaration: [core::ops::index::IndexMut] *)
Record core_ops_index_IndexMut (Self Idx : Type) := mk_core_ops_index_IndexMut {
core_ops_index_IndexMut_indexInst : core_ops_index_Index Self Idx;
- core_ops_index_IndexMut_index_mut : Self -> Idx -> result core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output);
- core_ops_index_IndexMut_index_mut_back : Self -> Idx -> core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) -> result Self;
+ core_ops_index_IndexMut_index_mut :
+ Self ->
+ Idx ->
+ result (core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) *
+ (core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) -> result Self));
}.
Arguments mk_core_ops_index_IndexMut {_ _}.
Arguments core_ops_index_IndexMut_indexInst {_ _}.
Arguments core_ops_index_IndexMut_index_mut {_ _}.
-Arguments core_ops_index_IndexMut_index_mut_back {_ _}.
(* Trait declaration [core::ops::deref::Deref] *)
Record core_ops_deref_Deref (Self : Type) := mk_core_ops_deref_Deref {
@@ -524,13 +525,14 @@ Arguments core_ops_deref_Deref_deref {_}.
(* Trait declaration [core::ops::deref::DerefMut] *)
Record core_ops_deref_DerefMut (Self : Type) := mk_core_ops_deref_DerefMut {
core_ops_deref_DerefMut_derefInst : core_ops_deref_Deref Self;
- core_ops_deref_DerefMut_deref_mut : Self -> result core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target);
- core_ops_deref_DerefMut_deref_mut_back : Self -> core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) -> result Self;
+ core_ops_deref_DerefMut_deref_mut :
+ Self ->
+ result (core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) *
+ (core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) -> result Self));
}.
Arguments mk_core_ops_deref_DerefMut {_}.
Arguments core_ops_deref_DerefMut_derefInst {_}.
Arguments core_ops_deref_DerefMut_deref_mut {_}.
-Arguments core_ops_deref_DerefMut_deref_mut_back {_}.
Record core_ops_range_Range (T : Type) := mk_core_ops_range_Range {
core_ops_range_Range_start : T;
@@ -543,8 +545,8 @@ Arguments core_ops_range_Range_end_ {_}.
(*** [alloc] *)
Definition alloc_boxed_Box_deref (T : Type) (x : T) : result T := Return x.
-Definition alloc_boxed_Box_deref_mut (T : Type) (x : T) : result T := Return x.
-Definition alloc_boxed_Box_deref_mut_back (T : Type) (_ : T) (x : T) : result T := Return x.
+Definition alloc_boxed_Box_deref_mut (T : Type) (x : T) : result (T * (T -> result T)) :=
+ Return (x, fun x => Return x).
(* Trait instance *)
Definition alloc_boxed_Box_coreopsDerefInst (Self : Type) : core_ops_deref_Deref Self := {|
@@ -556,7 +558,6 @@ Definition alloc_boxed_Box_coreopsDerefInst (Self : Type) : core_ops_deref_Deref
Definition alloc_boxed_Box_coreopsDerefMutInst (Self : Type) : core_ops_deref_DerefMut Self := {|
core_ops_deref_DerefMut_derefInst := alloc_boxed_Box_coreopsDerefInst Self;
core_ops_deref_DerefMut_deref_mut := alloc_boxed_Box_deref_mut Self;
- core_ops_deref_DerefMut_deref_mut_back := alloc_boxed_Box_deref_mut_back Self;
|}.
@@ -584,6 +585,13 @@ Axiom array_repeat : forall (T : Type) (n : usize) (x : T), array T n.
Axiom array_index_usize : forall (T : Type) (n : usize) (x : array T n) (i : usize), result T.
Axiom array_update_usize : forall (T : Type) (n : usize) (x : array T n) (i : usize) (nx : T), result (array T n).
+Definition array_index_mut_usize (T : Type) (n : usize) (a : array T n) (i : usize) :
+ result (T * (T -> result (array T n))) :=
+ match array_index_usize T n a i with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, array_update_usize T n a i)
+ end.
+
(*** Slice *)
Definition slice T := { l: list T | Z.of_nat (length l) <= usize_max}.
@@ -591,11 +599,25 @@ Axiom slice_len : forall (T : Type) (s : slice T), usize.
Axiom slice_index_usize : forall (T : Type) (x : slice T) (i : usize), result T.
Axiom slice_update_usize : forall (T : Type) (x : slice T) (i : usize) (nx : T), result (slice T).
+Definition slice_index_mut_usize (T : Type) (s : slice T) (i : usize) :
+ result (T * (T -> result (slice T))) :=
+ match slice_index_usize T s i with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, slice_update_usize T s i)
+ end.
+
(*** Subslices *)
Axiom array_to_slice : forall (T : Type) (n : usize) (x : array T n), result (slice T).
Axiom array_from_slice : forall (T : Type) (n : usize) (x : array T n) (s : slice T), result (array T n).
+Definition array_to_slice_mut (T : Type) (n : usize) (a : array T n) :
+ result (slice T * (slice T -> result (array T n))) :=
+ match array_to_slice T n a with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, array_from_slice T n a)
+ end.
+
Axiom array_subslice: forall (T : Type) (n : usize) (x : array T n) (r : core_ops_range_Range usize), result (slice T).
Axiom array_update_subslice: forall (T : Type) (n : usize) (x : array T n) (r : core_ops_range_Range usize) (ns : slice T), result (array T n).
@@ -639,16 +661,9 @@ Definition alloc_vec_Vec_bind {A B} (v: alloc_vec_Vec A) (f: list A -> result (l
| right _ => Fail_ Failure
end.
-(* The **forward** function shouldn't be used *)
-Definition alloc_vec_Vec_push_fwd (T: Type) (v: alloc_vec_Vec T) (x: T) : unit := tt.
-
Definition alloc_vec_Vec_push (T: Type) (v: alloc_vec_Vec T) (x: T) : result (alloc_vec_Vec T) :=
alloc_vec_Vec_bind v (fun l => Return (l ++ [x])).
-(* The **forward** function shouldn't be used *)
-Definition alloc_vec_Vec_insert_fwd (T: Type) (v: alloc_vec_Vec T) (i: usize) (x: T) : result unit :=
- if to_Z i <? alloc_vec_Vec_length v then Return tt else Fail_ Failure.
-
Definition alloc_vec_Vec_insert (T: Type) (v: alloc_vec_Vec T) (i: usize) (x: T) : result (alloc_vec_Vec T) :=
alloc_vec_Vec_bind v (fun l =>
if to_Z i <? Z.of_nat (length l)
@@ -661,6 +676,14 @@ Axiom alloc_vec_Vec_index_usize : forall {T : Type} (v : alloc_vec_Vec T) (i : u
(* Helper *)
Axiom alloc_vec_Vec_update_usize : forall {T : Type} (v : alloc_vec_Vec T) (i : usize) (x : T), result (alloc_vec_Vec T).
+Definition alloc_vec_Vec_index_mut_usize {T : Type} (v: alloc_vec_Vec T) (i: usize) :
+ result (T * (T -> result (alloc_vec_Vec T))) :=
+ match alloc_vec_Vec_index_usize v i with
+ | Return x =>
+ Return (x, alloc_vec_Vec_update_usize v i)
+ | Fail_ e => Fail_ e
+ end.
+
(* Trait declaration: [core::slice::index::private_slice_index::Sealed] *)
Definition core_slice_index_private_slice_index_Sealed (self : Type) := unit.
@@ -669,25 +692,23 @@ Record core_slice_index_SliceIndex (Self T : Type) := mk_core_slice_index_SliceI
core_slice_index_SliceIndex_sealedInst : core_slice_index_private_slice_index_Sealed Self;
core_slice_index_SliceIndex_Output : Type;
core_slice_index_SliceIndex_get : Self -> T -> result (option core_slice_index_SliceIndex_Output);
- core_slice_index_SliceIndex_get_mut : Self -> T -> result (option core_slice_index_SliceIndex_Output);
- core_slice_index_SliceIndex_get_mut_back : Self -> T -> option core_slice_index_SliceIndex_Output -> result T;
+ core_slice_index_SliceIndex_get_mut :
+ Self -> T -> result (option core_slice_index_SliceIndex_Output * (option core_slice_index_SliceIndex_Output -> result T));
core_slice_index_SliceIndex_get_unchecked : Self -> const_raw_ptr T -> result (const_raw_ptr core_slice_index_SliceIndex_Output);
core_slice_index_SliceIndex_get_unchecked_mut : Self -> mut_raw_ptr T -> result (mut_raw_ptr core_slice_index_SliceIndex_Output);
core_slice_index_SliceIndex_index : Self -> T -> result core_slice_index_SliceIndex_Output;
- core_slice_index_SliceIndex_index_mut : Self -> T -> result core_slice_index_SliceIndex_Output;
- core_slice_index_SliceIndex_index_mut_back : Self -> T -> core_slice_index_SliceIndex_Output -> result T;
+ core_slice_index_SliceIndex_index_mut :
+ Self -> T -> result (core_slice_index_SliceIndex_Output * (core_slice_index_SliceIndex_Output -> result T));
}.
Arguments mk_core_slice_index_SliceIndex {_ _}.
Arguments core_slice_index_SliceIndex_sealedInst {_ _}.
Arguments core_slice_index_SliceIndex_Output {_ _}.
Arguments core_slice_index_SliceIndex_get {_ _}.
Arguments core_slice_index_SliceIndex_get_mut {_ _}.
-Arguments core_slice_index_SliceIndex_get_mut_back {_ _}.
Arguments core_slice_index_SliceIndex_get_unchecked {_ _}.
Arguments core_slice_index_SliceIndex_get_unchecked_mut {_ _}.
Arguments core_slice_index_SliceIndex_index {_ _}.
Arguments core_slice_index_SliceIndex_index_mut {_ _}.
-Arguments core_slice_index_SliceIndex_index_mut_back {_ _}.
(* [core::slice::index::[T]::index]: forward function *)
Definition core_slice_index_Slice_index
@@ -704,11 +725,9 @@ Axiom core_slice_index_RangeUsize_get : forall (T : Type) (i : core_ops_range_Ra
(* [core::slice::index::Range::get_mut]: forward function *)
Axiom core_slice_index_RangeUsize_get_mut :
- forall (T : Type), core_ops_range_Range usize -> slice T -> result (option (slice T)).
-
-(* [core::slice::index::Range::get_mut]: backward function 0 *)
-Axiom core_slice_index_RangeUsize_get_mut_back :
- forall (T : Type), core_ops_range_Range usize -> slice T -> option (slice T) -> result (slice T).
+ forall (T : Type),
+ core_ops_range_Range usize -> slice T ->
+ result (option (slice T) * (option (slice T) -> result (slice T))).
(* [core::slice::index::Range::get_unchecked]: forward function *)
Definition core_slice_index_RangeUsize_get_unchecked
@@ -732,21 +751,14 @@ Axiom core_slice_index_RangeUsize_index :
(* [core::slice::index::Range::index_mut]: forward function *)
Axiom core_slice_index_RangeUsize_index_mut :
- forall (T : Type), core_ops_range_Range usize -> slice T -> result (slice T).
-
-(* [core::slice::index::Range::index_mut]: backward function 0 *)
-Axiom core_slice_index_RangeUsize_index_mut_back :
- forall (T : Type), core_ops_range_Range usize -> slice T -> slice T -> result (slice T).
+ forall (T : Type), core_ops_range_Range usize -> slice T -> result (slice T * (slice T -> result (slice T))).
(* [core::slice::index::[T]::index_mut]: forward function *)
Axiom core_slice_index_Slice_index_mut :
forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T)),
- slice T -> Idx -> result inst.(core_slice_index_SliceIndex_Output).
-
-(* [core::slice::index::[T]::index_mut]: backward function 0 *)
-Axiom core_slice_index_Slice_index_mut_back :
- forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T)),
- slice T -> Idx -> inst.(core_slice_index_SliceIndex_Output) -> result (slice T).
+ slice T -> Idx ->
+ result (inst.(core_slice_index_SliceIndex_Output) *
+ (inst.(core_slice_index_SliceIndex_Output) -> result (slice T))).
(* [core::array::[T; N]::index]: forward function *)
Axiom core_array_Array_index :
@@ -756,12 +768,9 @@ Axiom core_array_Array_index :
(* [core::array::[T; N]::index_mut]: forward function *)
Axiom core_array_Array_index_mut :
forall (T Idx : Type) (N : usize) (inst : core_ops_index_IndexMut (slice T) Idx)
- (a : array T N) (i : Idx), result inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output).
-
-(* [core::array::[T; N]::index_mut]: backward function 0 *)
-Axiom core_array_Array_index_mut_back :
- forall (T Idx : Type) (N : usize) (inst : core_ops_index_IndexMut (slice T) Idx)
- (a : array T N) (i : Idx) (x : inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output)), result (array T N).
+ (a : array T N) (i : Idx),
+ result (inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output) *
+ (inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output) -> result (array T N))).
(* Trait implementation: [core::slice::index::private_slice_index::Range] *)
Definition core_slice_index_private_slice_index_SealedRangeUsizeInst
@@ -774,12 +783,10 @@ Definition core_slice_index_SliceIndexRangeUsizeSliceTInst (T : Type) :
core_slice_index_SliceIndex_Output := slice T;
core_slice_index_SliceIndex_get := core_slice_index_RangeUsize_get T;
core_slice_index_SliceIndex_get_mut := core_slice_index_RangeUsize_get_mut T;
- core_slice_index_SliceIndex_get_mut_back := core_slice_index_RangeUsize_get_mut_back T;
core_slice_index_SliceIndex_get_unchecked := core_slice_index_RangeUsize_get_unchecked T;
core_slice_index_SliceIndex_get_unchecked_mut := core_slice_index_RangeUsize_get_unchecked_mut T;
core_slice_index_SliceIndex_index := core_slice_index_RangeUsize_index T;
core_slice_index_SliceIndex_index_mut := core_slice_index_RangeUsize_index_mut T;
- core_slice_index_SliceIndex_index_mut_back := core_slice_index_RangeUsize_index_mut_back T;
|}.
(* Trait implementation: [core::slice::index::[T]] *)
@@ -796,7 +803,6 @@ Definition core_ops_index_IndexMutSliceTIInst (T Idx : Type)
core_ops_index_IndexMut (slice T) Idx := {|
core_ops_index_IndexMut_indexInst := core_ops_index_IndexSliceTIInst T Idx inst;
core_ops_index_IndexMut_index_mut := core_slice_index_Slice_index_mut T Idx inst;
- core_ops_index_IndexMut_index_mut_back := core_slice_index_Slice_index_mut_back T Idx inst;
|}.
(* Trait implementation: [core::array::[T; N]] *)
@@ -813,18 +819,14 @@ Definition core_ops_index_IndexMutArrayInst (T Idx : Type) (N : usize)
core_ops_index_IndexMut (array T N) Idx := {|
core_ops_index_IndexMut_indexInst := core_ops_index_IndexArrayInst T Idx N inst.(core_ops_index_IndexMut_indexInst);
core_ops_index_IndexMut_index_mut := core_array_Array_index_mut T Idx N inst;
- core_ops_index_IndexMut_index_mut_back := core_array_Array_index_mut_back T Idx N inst;
|}.
(* [core::slice::index::usize::get]: forward function *)
Axiom core_slice_index_usize_get : forall (T : Type), usize -> slice T -> result (option T).
(* [core::slice::index::usize::get_mut]: forward function *)
-Axiom core_slice_index_usize_get_mut : forall (T : Type), usize -> slice T -> result (option T).
-
-(* [core::slice::index::usize::get_mut]: backward function 0 *)
-Axiom core_slice_index_usize_get_mut_back :
- forall (T : Type), usize -> slice T -> option T -> result (slice T).
+Axiom core_slice_index_usize_get_mut :
+ forall (T : Type), usize -> slice T -> result (option T * (option T -> result (slice T))).
(* [core::slice::index::usize::get_unchecked]: forward function *)
Axiom core_slice_index_usize_get_unchecked :
@@ -838,11 +840,8 @@ Axiom core_slice_index_usize_get_unchecked_mut :
Axiom core_slice_index_usize_index : forall (T : Type), usize -> slice T -> result T.
(* [core::slice::index::usize::index_mut]: forward function *)
-Axiom core_slice_index_usize_index_mut : forall (T : Type), usize -> slice T -> result T.
-
-(* [core::slice::index::usize::index_mut]: backward function 0 *)
-Axiom core_slice_index_usize_index_mut_back :
- forall (T : Type), usize -> slice T -> T -> result (slice T).
+Axiom core_slice_index_usize_index_mut :
+ forall (T : Type), usize -> slice T -> result (T * (T -> result (slice T))).
(* Trait implementation: [core::slice::index::private_slice_index::usize] *)
Definition core_slice_index_private_slice_index_SealedUsizeInst
@@ -855,12 +854,10 @@ Definition core_slice_index_SliceIndexUsizeSliceTInst (T : Type) :
core_slice_index_SliceIndex_Output := T;
core_slice_index_SliceIndex_get := core_slice_index_usize_get T;
core_slice_index_SliceIndex_get_mut := core_slice_index_usize_get_mut T;
- core_slice_index_SliceIndex_get_mut_back := core_slice_index_usize_get_mut_back T;
core_slice_index_SliceIndex_get_unchecked := core_slice_index_usize_get_unchecked T;
core_slice_index_SliceIndex_get_unchecked_mut := core_slice_index_usize_get_unchecked_mut T;
core_slice_index_SliceIndex_index := core_slice_index_usize_index T;
core_slice_index_SliceIndex_index_mut := core_slice_index_usize_index_mut T;
- core_slice_index_SliceIndex_index_mut_back := core_slice_index_usize_index_mut_back T;
|}.
(* [alloc::vec::Vec::index]: forward function *)
@@ -869,12 +866,9 @@ Axiom alloc_vec_Vec_index : forall (T Idx : Type) (inst : core_slice_index_Slice
(* [alloc::vec::Vec::index_mut]: forward function *)
Axiom alloc_vec_Vec_index_mut : forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T))
- (Self : alloc_vec_Vec T) (i : Idx), result inst.(core_slice_index_SliceIndex_Output).
-
-(* [alloc::vec::Vec::index_mut]: backward function 0 *)
-Axiom alloc_vec_Vec_index_mut_back :
- forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T))
- (Self : alloc_vec_Vec T) (i : Idx) (x : inst.(core_slice_index_SliceIndex_Output)), result (alloc_vec_Vec T).
+ (Self : alloc_vec_Vec T) (i : Idx),
+ result (inst.(core_slice_index_SliceIndex_Output) *
+ (inst.(core_slice_index_SliceIndex_Output) -> result (alloc_vec_Vec T))).
(* Trait implementation: [alloc::vec::Vec] *)
Definition alloc_vec_Vec_coreopsindexIndexInst (T Idx : Type)
@@ -890,7 +884,6 @@ Definition alloc_vec_Vec_coreopsindexIndexMutInst (T Idx : Type)
core_ops_index_IndexMut (alloc_vec_Vec T) Idx := {|
core_ops_index_IndexMut_indexInst := alloc_vec_Vec_coreopsindexIndexInst T Idx inst;
core_ops_index_IndexMut_index_mut := alloc_vec_Vec_index_mut T Idx inst;
- core_ops_index_IndexMut_index_mut_back := alloc_vec_Vec_index_mut_back T Idx inst;
|}.
(*** Theorems *)
@@ -901,10 +894,6 @@ Axiom alloc_vec_Vec_index_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usiz
Axiom alloc_vec_Vec_index_mut_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usize) (x : a),
alloc_vec_Vec_index_mut a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i =
- alloc_vec_Vec_index_usize v i.
-
-Axiom alloc_vec_Vec_index_mut_back_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usize) (x : a),
- alloc_vec_Vec_index_mut_back a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i x =
- alloc_vec_Vec_update_usize v i x.
+ alloc_vec_Vec_index_mut_usize v i.
End Primitives.
diff --git a/tests/coq/betree/BetreeMain_Funs.v b/tests/coq/betree/BetreeMain_Funs.v
index a5dd4230..516bc7b7 100644
--- a/tests/coq/betree/BetreeMain_Funs.v
+++ b/tests/coq/betree/BetreeMain_Funs.v
@@ -12,7 +12,7 @@ Require Import BetreeMain_FunsExternal.
Include BetreeMain_FunsExternal.
Module BetreeMain_Funs.
-(** [betree_main::betree::load_internal_node]: forward function
+(** [betree_main::betree::load_internal_node]:
Source: 'src/betree.rs', lines 36:0-36:52 *)
Definition betree_load_internal_node
(id : u64) (st : state) :
@@ -21,70 +21,57 @@ Definition betree_load_internal_node
betree_utils_load_internal_node id st
.
-(** [betree_main::betree::store_internal_node]: forward function
+(** [betree_main::betree::store_internal_node]:
Source: 'src/betree.rs', lines 41:0-41:60 *)
Definition betree_store_internal_node
(id : u64) (content : betree_List_t (u64 * betree_Message_t)) (st : state) :
result (state * unit)
:=
p <- betree_utils_store_internal_node id content st;
- let (st0, _) := p in
- Return (st0, tt)
+ let (st1, _) := p in
+ Return (st1, tt)
.
-(** [betree_main::betree::load_leaf_node]: forward function
+(** [betree_main::betree::load_leaf_node]:
Source: 'src/betree.rs', lines 46:0-46:44 *)
Definition betree_load_leaf_node
(id : u64) (st : state) : result (state * (betree_List_t (u64 * u64))) :=
betree_utils_load_leaf_node id st
.
-(** [betree_main::betree::store_leaf_node]: forward function
+(** [betree_main::betree::store_leaf_node]:
Source: 'src/betree.rs', lines 51:0-51:52 *)
Definition betree_store_leaf_node
(id : u64) (content : betree_List_t (u64 * u64)) (st : state) :
result (state * unit)
:=
p <- betree_utils_store_leaf_node id content st;
- let (st0, _) := p in
- Return (st0, tt)
+ let (st1, _) := p in
+ Return (st1, tt)
.
-(** [betree_main::betree::fresh_node_id]: forward function
+(** [betree_main::betree::fresh_node_id]:
Source: 'src/betree.rs', lines 55:0-55:48 *)
-Definition betree_fresh_node_id (counter : u64) : result u64 :=
- _ <- u64_add counter 1%u64; Return counter
+Definition betree_fresh_node_id (counter : u64) : result (u64 * u64) :=
+ counter1 <- u64_add counter 1%u64; Return (counter, counter1)
.
-(** [betree_main::betree::fresh_node_id]: backward function 0
- Source: 'src/betree.rs', lines 55:0-55:48 *)
-Definition betree_fresh_node_id_back (counter : u64) : result u64 :=
- u64_add counter 1%u64
-.
-
-(** [betree_main::betree::{betree_main::betree::NodeIdCounter}::new]: forward function
+(** [betree_main::betree::{betree_main::betree::NodeIdCounter}::new]:
Source: 'src/betree.rs', lines 206:4-206:20 *)
Definition betree_NodeIdCounter_new : result betree_NodeIdCounter_t :=
Return {| betree_NodeIdCounter_next_node_id := 0%u64 |}
.
-(** [betree_main::betree::{betree_main::betree::NodeIdCounter}::fresh_id]: forward function
+(** [betree_main::betree::{betree_main::betree::NodeIdCounter}::fresh_id]:
Source: 'src/betree.rs', lines 210:4-210:36 *)
Definition betree_NodeIdCounter_fresh_id
- (self : betree_NodeIdCounter_t) : result u64 :=
- _ <- u64_add self.(betree_NodeIdCounter_next_node_id) 1%u64;
- Return self.(betree_NodeIdCounter_next_node_id)
-.
-
-(** [betree_main::betree::{betree_main::betree::NodeIdCounter}::fresh_id]: backward function 0
- Source: 'src/betree.rs', lines 210:4-210:36 *)
-Definition betree_NodeIdCounter_fresh_id_back
- (self : betree_NodeIdCounter_t) : result betree_NodeIdCounter_t :=
+ (self : betree_NodeIdCounter_t) : result (u64 * betree_NodeIdCounter_t) :=
i <- u64_add self.(betree_NodeIdCounter_next_node_id) 1%u64;
- Return {| betree_NodeIdCounter_next_node_id := i |}
+ Return (self.(betree_NodeIdCounter_next_node_id),
+ {| betree_NodeIdCounter_next_node_id := i |})
.
-(** [betree_main::betree::upsert_update]: forward function
+(** [betree_main::betree::upsert_update]:
Source: 'src/betree.rs', lines 234:0-234:70 *)
Definition betree_upsert_update
(prev : option u64) (st : betree_UpsertFunState_t) : result u64 :=
@@ -92,49 +79,49 @@ Definition betree_upsert_update
| None =>
match st with
| Betree_UpsertFunState_Add v => Return v
- | Betree_UpsertFunState_Sub i => Return 0%u64
+ | Betree_UpsertFunState_Sub _ => Return 0%u64
end
- | Some prev0 =>
+ | Some prev1 =>
match st with
| Betree_UpsertFunState_Add v =>
- margin <- u64_sub core_u64_max prev0;
- if margin s>= v then u64_add prev0 v else Return core_u64_max
+ margin <- u64_sub core_u64_max prev1;
+ if margin s>= v then u64_add prev1 v else Return core_u64_max
| Betree_UpsertFunState_Sub v =>
- if prev0 s>= v then u64_sub prev0 v else Return 0%u64
+ if prev1 s>= v then u64_sub prev1 v else Return 0%u64
end
end
.
-(** [betree_main::betree::{betree_main::betree::List<T>#1}::len]: forward function
+(** [betree_main::betree::{betree_main::betree::List<T>#1}::len]:
Source: 'src/betree.rs', lines 276:4-276:24 *)
Fixpoint betree_List_len
(T : Type) (n : nat) (self : betree_List_t T) : result u64 :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match self with
- | Betree_List_Cons t tl => i <- betree_List_len T n0 tl; u64_add 1%u64 i
+ | Betree_List_Cons _ tl => i <- betree_List_len T n1 tl; u64_add 1%u64 i
| Betree_List_Nil => Return 0%u64
end
end
.
-(** [betree_main::betree::{betree_main::betree::List<T>#1}::split_at]: forward function
+(** [betree_main::betree::{betree_main::betree::List<T>#1}::split_at]:
Source: 'src/betree.rs', lines 284:4-284:51 *)
Fixpoint betree_List_split_at
- (T : Type) (n : nat) (self : betree_List_t T) (n0 : u64) :
+ (T : Type) (n : nat) (self : betree_List_t T) (n1 : u64) :
result ((betree_List_t T) * (betree_List_t T))
:=
match n with
| O => Fail_ OutOfFuel
- | S n1 =>
- if n0 s= 0%u64
+ | S n2 =>
+ if n1 s= 0%u64
then Return (Betree_List_Nil, self)
else
match self with
| Betree_List_Cons hd tl =>
- i <- u64_sub n0 1%u64;
- p <- betree_List_split_at T n1 tl i;
+ i <- u64_sub n1 1%u64;
+ p <- betree_List_split_at T n2 tl i;
let (ls0, ls1) := p in
let l := ls0 in
Return (Betree_List_Cons hd l, ls1)
@@ -143,58 +130,46 @@ Fixpoint betree_List_split_at
end
.
-(** [betree_main::betree::{betree_main::betree::List<T>#1}::push_front]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [betree_main::betree::{betree_main::betree::List<T>#1}::push_front]:
Source: 'src/betree.rs', lines 299:4-299:34 *)
Definition betree_List_push_front
(T : Type) (self : betree_List_t T) (x : T) : result (betree_List_t T) :=
- let tl := core_mem_replace (betree_List_t T) self Betree_List_Nil in
+ let (tl, _) := core_mem_replace (betree_List_t T) self Betree_List_Nil in
let l := tl in
Return (Betree_List_Cons x l)
.
-(** [betree_main::betree::{betree_main::betree::List<T>#1}::pop_front]: forward function
+(** [betree_main::betree::{betree_main::betree::List<T>#1}::pop_front]:
Source: 'src/betree.rs', lines 306:4-306:32 *)
Definition betree_List_pop_front
- (T : Type) (self : betree_List_t T) : result T :=
- let ls := core_mem_replace (betree_List_t T) self Betree_List_Nil in
+ (T : Type) (self : betree_List_t T) : result (T * (betree_List_t T)) :=
+ let (ls, _) := core_mem_replace (betree_List_t T) self Betree_List_Nil in
match ls with
- | Betree_List_Cons x tl => Return x
+ | Betree_List_Cons x tl => Return (x, tl)
| Betree_List_Nil => Fail_ Failure
end
.
-(** [betree_main::betree::{betree_main::betree::List<T>#1}::pop_front]: backward function 0
- Source: 'src/betree.rs', lines 306:4-306:32 *)
-Definition betree_List_pop_front_back
- (T : Type) (self : betree_List_t T) : result (betree_List_t T) :=
- let ls := core_mem_replace (betree_List_t T) self Betree_List_Nil in
- match ls with
- | Betree_List_Cons x tl => Return tl
- | Betree_List_Nil => Fail_ Failure
- end
-.
-
-(** [betree_main::betree::{betree_main::betree::List<T>#1}::hd]: forward function
+(** [betree_main::betree::{betree_main::betree::List<T>#1}::hd]:
Source: 'src/betree.rs', lines 318:4-318:22 *)
Definition betree_List_hd (T : Type) (self : betree_List_t T) : result T :=
match self with
- | Betree_List_Cons hd l => Return hd
+ | Betree_List_Cons hd _ => Return hd
| Betree_List_Nil => Fail_ Failure
end
.
-(** [betree_main::betree::{betree_main::betree::List<(u64, T)>#2}::head_has_key]: forward function
+(** [betree_main::betree::{betree_main::betree::List<(u64, T)>#2}::head_has_key]:
Source: 'src/betree.rs', lines 327:4-327:44 *)
Definition betree_ListTupleU64T_head_has_key
(T : Type) (self : betree_List_t (u64 * T)) (key : u64) : result bool :=
match self with
- | Betree_List_Cons hd l => let (i, _) := hd in Return (i s= key)
+ | Betree_List_Cons hd _ => let (i, _) := hd in Return (i s= key)
| Betree_List_Nil => Return false
end
.
-(** [betree_main::betree::{betree_main::betree::List<(u64, T)>#2}::partition_at_pivot]: forward function
+(** [betree_main::betree::{betree_main::betree::List<(u64, T)>#2}::partition_at_pivot]:
Source: 'src/betree.rs', lines 339:4-339:73 *)
Fixpoint betree_ListTupleU64T_partition_at_pivot
(T : Type) (n : nat) (self : betree_List_t (u64 * T)) (pivot : u64) :
@@ -202,14 +177,14 @@ Fixpoint betree_ListTupleU64T_partition_at_pivot
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match self with
| Betree_List_Cons hd tl =>
let (i, t) := hd in
if i s>= pivot
then Return (Betree_List_Nil, Betree_List_Cons (i, t) tl)
else (
- p <- betree_ListTupleU64T_partition_at_pivot T n0 tl pivot;
+ p <- betree_ListTupleU64T_partition_at_pivot T n1 tl pivot;
let (ls0, ls1) := p in
let l := ls0 in
Return (Betree_List_Cons (i, t) l, ls1))
@@ -218,107 +193,76 @@ Fixpoint betree_ListTupleU64T_partition_at_pivot
end
.
-(** [betree_main::betree::{betree_main::betree::Leaf#3}::split]: forward function
+(** [betree_main::betree::{betree_main::betree::Leaf#3}::split]:
Source: 'src/betree.rs', lines 359:4-364:17 *)
Definition betree_Leaf_split
(n : nat) (self : betree_Leaf_t) (content : betree_List_t (u64 * u64))
(params : betree_Params_t) (node_id_cnt : betree_NodeIdCounter_t)
(st : state) :
- result (state * betree_Internal_t)
+ result (state * (betree_Internal_t * betree_NodeIdCounter_t))
:=
p <-
betree_List_split_at (u64 * u64) n content
params.(betree_Params_split_size);
let (content0, content1) := p in
- p0 <- betree_List_hd (u64 * u64) content1;
- let (pivot, _) := p0 in
- id0 <- betree_NodeIdCounter_fresh_id node_id_cnt;
- node_id_cnt0 <- betree_NodeIdCounter_fresh_id_back node_id_cnt;
- id1 <- betree_NodeIdCounter_fresh_id node_id_cnt0;
- p1 <- betree_store_leaf_node id0 content0 st;
- let (st0, _) := p1 in
- p2 <- betree_store_leaf_node id1 content1 st0;
- let (st1, _) := p2 in
- let n0 := Betree_Node_Leaf
+ p1 <- betree_List_hd (u64 * u64) content1;
+ let (pivot, _) := p1 in
+ p2 <- betree_NodeIdCounter_fresh_id node_id_cnt;
+ let (id0, nic) := p2 in
+ p3 <- betree_NodeIdCounter_fresh_id nic;
+ let (id1, nic1) := p3 in
+ p4 <- betree_store_leaf_node id0 content0 st;
+ let (st1, _) := p4 in
+ p5 <- betree_store_leaf_node id1 content1 st1;
+ let (st2, _) := p5 in
+ let n1 := Betree_Node_Leaf
{|
betree_Leaf_id := id0;
betree_Leaf_size := params.(betree_Params_split_size)
|} in
- let n1 := Betree_Node_Leaf
+ let n2 := Betree_Node_Leaf
{|
betree_Leaf_id := id1;
betree_Leaf_size := params.(betree_Params_split_size)
|} in
- Return (st1, mkbetree_Internal_t self.(betree_Leaf_id) pivot n0 n1)
+ Return (st2, (mkbetree_Internal_t self.(betree_Leaf_id) pivot n1 n2, nic1))
.
-(** [betree_main::betree::{betree_main::betree::Leaf#3}::split]: backward function 2
- Source: 'src/betree.rs', lines 359:4-364:17 *)
-Definition betree_Leaf_split_back
- (n : nat) (self : betree_Leaf_t) (content : betree_List_t (u64 * u64))
- (params : betree_Params_t) (node_id_cnt : betree_NodeIdCounter_t)
- (st : state) :
- result betree_NodeIdCounter_t
- :=
- p <-
- betree_List_split_at (u64 * u64) n content
- params.(betree_Params_split_size);
- let (content0, content1) := p in
- _ <- betree_List_hd (u64 * u64) content1;
- id0 <- betree_NodeIdCounter_fresh_id node_id_cnt;
- node_id_cnt0 <- betree_NodeIdCounter_fresh_id_back node_id_cnt;
- id1 <- betree_NodeIdCounter_fresh_id node_id_cnt0;
- p0 <- betree_store_leaf_node id0 content0 st;
- let (st0, _) := p0 in
- _ <- betree_store_leaf_node id1 content1 st0;
- betree_NodeIdCounter_fresh_id_back node_id_cnt0
-.
-
-(** [betree_main::betree::{betree_main::betree::Node#5}::lookup_first_message_for_key]: forward function
+(** [betree_main::betree::{betree_main::betree::Node#5}::lookup_first_message_for_key]:
Source: 'src/betree.rs', lines 789:4-792:34 *)
Fixpoint betree_Node_lookup_first_message_for_key
(n : nat) (key : u64) (msgs : betree_List_t (u64 * betree_Message_t)) :
- result (betree_List_t (u64 * betree_Message_t))
+ result ((betree_List_t (u64 * betree_Message_t)) * (betree_List_t (u64 *
+ betree_Message_t) -> result (betree_List_t (u64 * betree_Message_t))))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
- match msgs with
- | Betree_List_Cons x next_msgs =>
- let (i, m) := x in
- if i s>= key
- then Return (Betree_List_Cons (i, m) next_msgs)
- else betree_Node_lookup_first_message_for_key n0 key next_msgs
- | Betree_List_Nil => Return Betree_List_Nil
- end
- end
-.
-
-(** [betree_main::betree::{betree_main::betree::Node#5}::lookup_first_message_for_key]: backward function 0
- Source: 'src/betree.rs', lines 789:4-792:34 *)
-Fixpoint betree_Node_lookup_first_message_for_key_back
- (n : nat) (key : u64) (msgs : betree_List_t (u64 * betree_Message_t))
- (ret : betree_List_t (u64 * betree_Message_t)) :
- result (betree_List_t (u64 * betree_Message_t))
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match msgs with
| Betree_List_Cons x next_msgs =>
let (i, m) := x in
if i s>= key
- then Return ret
+ then
+ let back_'a :=
+ fun (ret : betree_List_t (u64 * betree_Message_t)) => Return ret in
+ Return (Betree_List_Cons (i, m) next_msgs, back_'a)
else (
- next_msgs0 <-
- betree_Node_lookup_first_message_for_key_back n0 key next_msgs ret;
- Return (Betree_List_Cons (i, m) next_msgs0))
- | Betree_List_Nil => Return ret
+ p <- betree_Node_lookup_first_message_for_key n1 key next_msgs;
+ let (l, lookup_first_message_for_key_back) := p in
+ let back_'a :=
+ fun (ret : betree_List_t (u64 * betree_Message_t)) =>
+ next_msgs1 <- lookup_first_message_for_key_back ret;
+ Return (Betree_List_Cons (i, m) next_msgs1) in
+ Return (l, back_'a))
+ | Betree_List_Nil =>
+ let back_'a :=
+ fun (ret : betree_List_t (u64 * betree_Message_t)) => Return ret in
+ Return (Betree_List_Nil, back_'a)
end
end
.
-(** [betree_main::betree::{betree_main::betree::Node#5}::lookup_in_bindings]: forward function
+(** [betree_main::betree::{betree_main::betree::Node#5}::lookup_in_bindings]:
Source: 'src/betree.rs', lines 636:4-636:80 *)
Fixpoint betree_Node_lookup_in_bindings
(n : nat) (key : u64) (bindings : betree_List_t (u64 * u64)) :
@@ -326,263 +270,146 @@ Fixpoint betree_Node_lookup_in_bindings
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match bindings with
| Betree_List_Cons hd tl =>
- let (i, i0) := hd in
+ let (i, i1) := hd in
if i s= key
- then Return (Some i0)
+ then Return (Some i1)
else
if i s> key
then Return None
- else betree_Node_lookup_in_bindings n0 key tl
+ else betree_Node_lookup_in_bindings n1 key tl
| Betree_List_Nil => Return None
end
end
.
-(** [betree_main::betree::{betree_main::betree::Node#5}::apply_upserts]: forward function
+(** [betree_main::betree::{betree_main::betree::Node#5}::apply_upserts]:
Source: 'src/betree.rs', lines 819:4-819:90 *)
Fixpoint betree_Node_apply_upserts
(n : nat) (msgs : betree_List_t (u64 * betree_Message_t)) (prev : option u64)
(key : u64) (st : state) :
- result (state * u64)
+ result (state * (u64 * (betree_List_t (u64 * betree_Message_t))))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
b <- betree_ListTupleU64T_head_has_key betree_Message_t msgs key;
if b
then (
- msg <- betree_List_pop_front (u64 * betree_Message_t) msgs;
+ p <- betree_List_pop_front (u64 * betree_Message_t) msgs;
+ let (msg, l) := p in
let (_, m) := msg in
match m with
- | Betree_Message_Insert i => Fail_ Failure
+ | Betree_Message_Insert _ => Fail_ Failure
| Betree_Message_Delete => Fail_ Failure
| Betree_Message_Upsert s =>
v <- betree_upsert_update prev s;
- msgs0 <- betree_List_pop_front_back (u64 * betree_Message_t) msgs;
- betree_Node_apply_upserts n0 msgs0 (Some v) key st
+ betree_Node_apply_upserts n1 l (Some v) key st
end)
else (
p <- core_option_Option_unwrap u64 prev st;
- let (st0, v) := p in
- _ <-
+ let (st1, v) := p in
+ l <-
betree_List_push_front (u64 * betree_Message_t) msgs (key,
Betree_Message_Insert v);
- Return (st0, v))
- end
-.
-
-(** [betree_main::betree::{betree_main::betree::Node#5}::apply_upserts]: backward function 0
- Source: 'src/betree.rs', lines 819:4-819:90 *)
-Fixpoint betree_Node_apply_upserts_back
- (n : nat) (msgs : betree_List_t (u64 * betree_Message_t)) (prev : option u64)
- (key : u64) (st : state) :
- result (betree_List_t (u64 * betree_Message_t))
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- b <- betree_ListTupleU64T_head_has_key betree_Message_t msgs key;
- if b
- then (
- msg <- betree_List_pop_front (u64 * betree_Message_t) msgs;
- let (_, m) := msg in
- match m with
- | Betree_Message_Insert i => Fail_ Failure
- | Betree_Message_Delete => Fail_ Failure
- | Betree_Message_Upsert s =>
- v <- betree_upsert_update prev s;
- msgs0 <- betree_List_pop_front_back (u64 * betree_Message_t) msgs;
- betree_Node_apply_upserts_back n0 msgs0 (Some v) key st
- end)
- else (
- p <- core_option_Option_unwrap u64 prev st;
- let (_, v) := p in
- betree_List_push_front (u64 * betree_Message_t) msgs (key,
- Betree_Message_Insert v))
+ Return (st1, (v, l)))
end
.
-(** [betree_main::betree::{betree_main::betree::Internal#4}::lookup_in_children]: forward function
+(** [betree_main::betree::{betree_main::betree::Internal#4}::lookup_in_children]:
Source: 'src/betree.rs', lines 395:4-395:63 *)
Fixpoint betree_Internal_lookup_in_children
(n : nat) (self : betree_Internal_t) (key : u64) (st : state) :
- result (state * (option u64))
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- if key s< self.(betree_Internal_pivot)
- then betree_Node_lookup n0 self.(betree_Internal_left) key st
- else betree_Node_lookup n0 self.(betree_Internal_right) key st
- end
-
-(** [betree_main::betree::{betree_main::betree::Internal#4}::lookup_in_children]: backward function 0
- Source: 'src/betree.rs', lines 395:4-395:63 *)
-with betree_Internal_lookup_in_children_back
- (n : nat) (self : betree_Internal_t) (key : u64) (st : state) :
- result betree_Internal_t
+ result (state * ((option u64) * betree_Internal_t))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
if key s< self.(betree_Internal_pivot)
then (
- n1 <- betree_Node_lookup_back n0 self.(betree_Internal_left) key st;
- Return (mkbetree_Internal_t self.(betree_Internal_id)
- self.(betree_Internal_pivot) n1 self.(betree_Internal_right)))
+ p <- betree_Node_lookup n1 self.(betree_Internal_left) key st;
+ let (st1, p1) := p in
+ let (o, n2) := p1 in
+ Return (st1, (o, mkbetree_Internal_t self.(betree_Internal_id)
+ self.(betree_Internal_pivot) n2 self.(betree_Internal_right))))
else (
- n1 <- betree_Node_lookup_back n0 self.(betree_Internal_right) key st;
- Return (mkbetree_Internal_t self.(betree_Internal_id)
- self.(betree_Internal_pivot) self.(betree_Internal_left) n1))
+ p <- betree_Node_lookup n1 self.(betree_Internal_right) key st;
+ let (st1, p1) := p in
+ let (o, n2) := p1 in
+ Return (st1, (o, mkbetree_Internal_t self.(betree_Internal_id)
+ self.(betree_Internal_pivot) self.(betree_Internal_left) n2)))
end
-(** [betree_main::betree::{betree_main::betree::Node#5}::lookup]: forward function
+(** [betree_main::betree::{betree_main::betree::Node#5}::lookup]:
Source: 'src/betree.rs', lines 709:4-709:58 *)
with betree_Node_lookup
(n : nat) (self : betree_Node_t) (key : u64) (st : state) :
- result (state * (option u64))
+ result (state * ((option u64) * betree_Node_t))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
- match self with
- | Betree_Node_Internal node =>
- p <- betree_load_internal_node node.(betree_Internal_id) st;
- let (st0, msgs) := p in
- pending <- betree_Node_lookup_first_message_for_key n0 key msgs;
- match pending with
- | Betree_List_Cons p0 l =>
- let (k, msg) := p0 in
- if k s<> key
- then (
- p1 <- betree_Internal_lookup_in_children n0 node key st0;
- let (st1, o) := p1 in
- _ <-
- betree_Node_lookup_first_message_for_key_back n0 key msgs
- (Betree_List_Cons (k, msg) l);
- Return (st1, o))
- else
- match msg with
- | Betree_Message_Insert v =>
- _ <-
- betree_Node_lookup_first_message_for_key_back n0 key msgs
- (Betree_List_Cons (k, Betree_Message_Insert v) l);
- Return (st0, Some v)
- | Betree_Message_Delete =>
- _ <-
- betree_Node_lookup_first_message_for_key_back n0 key msgs
- (Betree_List_Cons (k, Betree_Message_Delete) l);
- Return (st0, None)
- | Betree_Message_Upsert ufs =>
- p1 <- betree_Internal_lookup_in_children n0 node key st0;
- let (st1, v) := p1 in
- p2 <-
- betree_Node_apply_upserts n0 (Betree_List_Cons (k,
- Betree_Message_Upsert ufs) l) v key st1;
- let (st2, v0) := p2 in
- node0 <- betree_Internal_lookup_in_children_back n0 node key st0;
- pending0 <-
- betree_Node_apply_upserts_back n0 (Betree_List_Cons (k,
- Betree_Message_Upsert ufs) l) v key st1;
- msgs0 <-
- betree_Node_lookup_first_message_for_key_back n0 key msgs
- pending0;
- p3 <-
- betree_store_internal_node node0.(betree_Internal_id) msgs0 st2;
- let (st3, _) := p3 in
- Return (st3, Some v0)
- end
- | Betree_List_Nil =>
- p0 <- betree_Internal_lookup_in_children n0 node key st0;
- let (st1, o) := p0 in
- _ <-
- betree_Node_lookup_first_message_for_key_back n0 key msgs
- Betree_List_Nil;
- Return (st1, o)
- end
- | Betree_Node_Leaf node =>
- p <- betree_load_leaf_node node.(betree_Leaf_id) st;
- let (st0, bindings) := p in
- o <- betree_Node_lookup_in_bindings n0 key bindings;
- Return (st0, o)
- end
- end
-
-(** [betree_main::betree::{betree_main::betree::Node#5}::lookup]: backward function 0
- Source: 'src/betree.rs', lines 709:4-709:58 *)
-with betree_Node_lookup_back
- (n : nat) (self : betree_Node_t) (key : u64) (st : state) :
- result betree_Node_t
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match self with
| Betree_Node_Internal node =>
p <- betree_load_internal_node node.(betree_Internal_id) st;
- let (st0, msgs) := p in
- pending <- betree_Node_lookup_first_message_for_key n0 key msgs;
+ let (st1, msgs) := p in
+ p1 <- betree_Node_lookup_first_message_for_key n1 key msgs;
+ let (pending, lookup_first_message_for_key_back) := p1 in
match pending with
- | Betree_List_Cons p0 l =>
- let (k, msg) := p0 in
+ | Betree_List_Cons p2 l =>
+ let (k, msg) := p2 in
if k s<> key
then (
- _ <-
- betree_Node_lookup_first_message_for_key_back n0 key msgs
- (Betree_List_Cons (k, msg) l);
- node0 <- betree_Internal_lookup_in_children_back n0 node key st0;
- Return (Betree_Node_Internal node0))
+ p3 <- betree_Internal_lookup_in_children n1 node key st1;
+ let (st2, p4) := p3 in
+ let (o, i) := p4 in
+ _ <- lookup_first_message_for_key_back (Betree_List_Cons (k, msg) l);
+ Return (st2, (o, Betree_Node_Internal i)))
else
match msg with
| Betree_Message_Insert v =>
_ <-
- betree_Node_lookup_first_message_for_key_back n0 key msgs
- (Betree_List_Cons (k, Betree_Message_Insert v) l);
- Return (Betree_Node_Internal node)
+ lookup_first_message_for_key_back (Betree_List_Cons (k,
+ Betree_Message_Insert v) l);
+ Return (st1, (Some v, Betree_Node_Internal node))
| Betree_Message_Delete =>
_ <-
- betree_Node_lookup_first_message_for_key_back n0 key msgs
- (Betree_List_Cons (k, Betree_Message_Delete) l);
- Return (Betree_Node_Internal node)
+ lookup_first_message_for_key_back (Betree_List_Cons (k,
+ Betree_Message_Delete) l);
+ Return (st1, (None, Betree_Node_Internal node))
| Betree_Message_Upsert ufs =>
- p1 <- betree_Internal_lookup_in_children n0 node key st0;
- let (st1, v) := p1 in
- p2 <-
- betree_Node_apply_upserts n0 (Betree_List_Cons (k,
- Betree_Message_Upsert ufs) l) v key st1;
- let (st2, _) := p2 in
- node0 <- betree_Internal_lookup_in_children_back n0 node key st0;
- pending0 <-
- betree_Node_apply_upserts_back n0 (Betree_List_Cons (k,
- Betree_Message_Upsert ufs) l) v key st1;
- msgs0 <-
- betree_Node_lookup_first_message_for_key_back n0 key msgs
- pending0;
- _ <-
- betree_store_internal_node node0.(betree_Internal_id) msgs0 st2;
- Return (Betree_Node_Internal node0)
+ p3 <- betree_Internal_lookup_in_children n1 node key st1;
+ let (st2, p4) := p3 in
+ let (v, i) := p4 in
+ p5 <-
+ betree_Node_apply_upserts n1 (Betree_List_Cons (k,
+ Betree_Message_Upsert ufs) l) v key st2;
+ let (st3, p6) := p5 in
+ let (v1, l1) := p6 in
+ msgs1 <- lookup_first_message_for_key_back l1;
+ p7 <- betree_store_internal_node i.(betree_Internal_id) msgs1 st3;
+ let (st4, _) := p7 in
+ Return (st4, (Some v1, Betree_Node_Internal i))
end
| Betree_List_Nil =>
- _ <-
- betree_Node_lookup_first_message_for_key_back n0 key msgs
- Betree_List_Nil;
- node0 <- betree_Internal_lookup_in_children_back n0 node key st0;
- Return (Betree_Node_Internal node0)
+ p2 <- betree_Internal_lookup_in_children n1 node key st1;
+ let (st2, p3) := p2 in
+ let (o, i) := p3 in
+ _ <- lookup_first_message_for_key_back Betree_List_Nil;
+ Return (st2, (o, Betree_Node_Internal i))
end
| Betree_Node_Leaf node =>
p <- betree_load_leaf_node node.(betree_Leaf_id) st;
- let (_, bindings) := p in
- _ <- betree_Node_lookup_in_bindings n0 key bindings;
- Return (Betree_Node_Leaf node)
+ let (st1, bindings) := p in
+ o <- betree_Node_lookup_in_bindings n1 key bindings;
+ Return (st1, (o, Betree_Node_Leaf node))
end
end
.
-(** [betree_main::betree::{betree_main::betree::Node#5}::filter_messages_for_key]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [betree_main::betree::{betree_main::betree::Node#5}::filter_messages_for_key]:
Source: 'src/betree.rs', lines 674:4-674:77 *)
Fixpoint betree_Node_filter_messages_for_key
(n : nat) (key : u64) (msgs : betree_List_t (u64 * betree_Message_t)) :
@@ -590,127 +417,118 @@ Fixpoint betree_Node_filter_messages_for_key
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match msgs with
| Betree_List_Cons p l =>
let (k, m) := p in
if k s= key
then (
- msgs0 <-
- betree_List_pop_front_back (u64 * betree_Message_t) (Betree_List_Cons
- (k, m) l);
- betree_Node_filter_messages_for_key n0 key msgs0)
+ p1 <-
+ betree_List_pop_front (u64 * betree_Message_t) (Betree_List_Cons (k,
+ m) l);
+ let (_, l1) := p1 in
+ betree_Node_filter_messages_for_key n1 key l1)
else Return (Betree_List_Cons (k, m) l)
| Betree_List_Nil => Return Betree_List_Nil
end
end
.
-(** [betree_main::betree::{betree_main::betree::Node#5}::lookup_first_message_after_key]: forward function
+(** [betree_main::betree::{betree_main::betree::Node#5}::lookup_first_message_after_key]:
Source: 'src/betree.rs', lines 689:4-692:34 *)
Fixpoint betree_Node_lookup_first_message_after_key
(n : nat) (key : u64) (msgs : betree_List_t (u64 * betree_Message_t)) :
- result (betree_List_t (u64 * betree_Message_t))
+ result ((betree_List_t (u64 * betree_Message_t)) * (betree_List_t (u64 *
+ betree_Message_t) -> result (betree_List_t (u64 * betree_Message_t))))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
- match msgs with
- | Betree_List_Cons p next_msgs =>
- let (k, m) := p in
- if k s= key
- then betree_Node_lookup_first_message_after_key n0 key next_msgs
- else Return (Betree_List_Cons (k, m) next_msgs)
- | Betree_List_Nil => Return Betree_List_Nil
- end
- end
-.
-
-(** [betree_main::betree::{betree_main::betree::Node#5}::lookup_first_message_after_key]: backward function 0
- Source: 'src/betree.rs', lines 689:4-692:34 *)
-Fixpoint betree_Node_lookup_first_message_after_key_back
- (n : nat) (key : u64) (msgs : betree_List_t (u64 * betree_Message_t))
- (ret : betree_List_t (u64 * betree_Message_t)) :
- result (betree_List_t (u64 * betree_Message_t))
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match msgs with
| Betree_List_Cons p next_msgs =>
let (k, m) := p in
if k s= key
then (
- next_msgs0 <-
- betree_Node_lookup_first_message_after_key_back n0 key next_msgs ret;
- Return (Betree_List_Cons (k, m) next_msgs0))
- else Return ret
- | Betree_List_Nil => Return ret
+ p1 <- betree_Node_lookup_first_message_after_key n1 key next_msgs;
+ let (l, lookup_first_message_after_key_back) := p1 in
+ let back_'a :=
+ fun (ret : betree_List_t (u64 * betree_Message_t)) =>
+ next_msgs1 <- lookup_first_message_after_key_back ret;
+ Return (Betree_List_Cons (k, m) next_msgs1) in
+ Return (l, back_'a))
+ else
+ let back_'a :=
+ fun (ret : betree_List_t (u64 * betree_Message_t)) => Return ret in
+ Return (Betree_List_Cons (k, m) next_msgs, back_'a)
+ | Betree_List_Nil =>
+ let back_'a :=
+ fun (ret : betree_List_t (u64 * betree_Message_t)) => Return ret in
+ Return (Betree_List_Nil, back_'a)
end
end
.
-(** [betree_main::betree::{betree_main::betree::Node#5}::apply_to_internal]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [betree_main::betree::{betree_main::betree::Node#5}::apply_to_internal]:
Source: 'src/betree.rs', lines 521:4-521:89 *)
Definition betree_Node_apply_to_internal
(n : nat) (msgs : betree_List_t (u64 * betree_Message_t)) (key : u64)
(new_msg : betree_Message_t) :
result (betree_List_t (u64 * betree_Message_t))
:=
- msgs0 <- betree_Node_lookup_first_message_for_key n key msgs;
- b <- betree_ListTupleU64T_head_has_key betree_Message_t msgs0 key;
+ p <- betree_Node_lookup_first_message_for_key n key msgs;
+ let (msgs1, lookup_first_message_for_key_back) := p in
+ b <- betree_ListTupleU64T_head_has_key betree_Message_t msgs1 key;
if b
then
match new_msg with
| Betree_Message_Insert i =>
- msgs1 <- betree_Node_filter_messages_for_key n key msgs0;
- msgs2 <-
- betree_List_push_front (u64 * betree_Message_t) msgs1 (key,
+ l <- betree_Node_filter_messages_for_key n key msgs1;
+ l1 <-
+ betree_List_push_front (u64 * betree_Message_t) l (key,
Betree_Message_Insert i);
- betree_Node_lookup_first_message_for_key_back n key msgs msgs2
+ lookup_first_message_for_key_back l1
| Betree_Message_Delete =>
- msgs1 <- betree_Node_filter_messages_for_key n key msgs0;
- msgs2 <-
- betree_List_push_front (u64 * betree_Message_t) msgs1 (key,
+ l <- betree_Node_filter_messages_for_key n key msgs1;
+ l1 <-
+ betree_List_push_front (u64 * betree_Message_t) l (key,
Betree_Message_Delete);
- betree_Node_lookup_first_message_for_key_back n key msgs msgs2
+ lookup_first_message_for_key_back l1
| Betree_Message_Upsert s =>
- p <- betree_List_hd (u64 * betree_Message_t) msgs0;
- let (_, m) := p in
+ p1 <- betree_List_hd (u64 * betree_Message_t) msgs1;
+ let (_, m) := p1 in
match m with
| Betree_Message_Insert prev =>
v <- betree_upsert_update (Some prev) s;
- msgs1 <- betree_List_pop_front_back (u64 * betree_Message_t) msgs0;
- msgs2 <-
- betree_List_push_front (u64 * betree_Message_t) msgs1 (key,
+ p2 <- betree_List_pop_front (u64 * betree_Message_t) msgs1;
+ let (_, l) := p2 in
+ l1 <-
+ betree_List_push_front (u64 * betree_Message_t) l (key,
Betree_Message_Insert v);
- betree_Node_lookup_first_message_for_key_back n key msgs msgs2
+ lookup_first_message_for_key_back l1
| Betree_Message_Delete =>
+ p2 <- betree_List_pop_front (u64 * betree_Message_t) msgs1;
+ let (_, l) := p2 in
v <- betree_upsert_update None s;
- msgs1 <- betree_List_pop_front_back (u64 * betree_Message_t) msgs0;
- msgs2 <-
- betree_List_push_front (u64 * betree_Message_t) msgs1 (key,
+ l1 <-
+ betree_List_push_front (u64 * betree_Message_t) l (key,
Betree_Message_Insert v);
- betree_Node_lookup_first_message_for_key_back n key msgs msgs2
- | Betree_Message_Upsert ufs =>
- msgs1 <- betree_Node_lookup_first_message_after_key n key msgs0;
- msgs2 <-
- betree_List_push_front (u64 * betree_Message_t) msgs1 (key,
+ lookup_first_message_for_key_back l1
+ | Betree_Message_Upsert _ =>
+ p2 <- betree_Node_lookup_first_message_after_key n key msgs1;
+ let (msgs2, lookup_first_message_after_key_back) := p2 in
+ l <-
+ betree_List_push_front (u64 * betree_Message_t) msgs2 (key,
Betree_Message_Upsert s);
- msgs3 <-
- betree_Node_lookup_first_message_after_key_back n key msgs0 msgs2;
- betree_Node_lookup_first_message_for_key_back n key msgs msgs3
+ msgs3 <- lookup_first_message_after_key_back l;
+ lookup_first_message_for_key_back msgs3
end
end
else (
- msgs1 <-
- betree_List_push_front (u64 * betree_Message_t) msgs0 (key, new_msg);
- betree_Node_lookup_first_message_for_key_back n key msgs msgs1)
+ l <- betree_List_push_front (u64 * betree_Message_t) msgs1 (key, new_msg);
+ lookup_first_message_for_key_back l)
.
-(** [betree_main::betree::{betree_main::betree::Node#5}::apply_messages_to_internal]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [betree_main::betree::{betree_main::betree::Node#5}::apply_messages_to_internal]:
Source: 'src/betree.rs', lines 502:4-505:5 *)
Fixpoint betree_Node_apply_messages_to_internal
(n : nat) (msgs : betree_List_t (u64 * betree_Message_t))
@@ -719,104 +537,88 @@ Fixpoint betree_Node_apply_messages_to_internal
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match new_msgs with
| Betree_List_Cons new_msg new_msgs_tl =>
let (i, m) := new_msg in
- msgs0 <- betree_Node_apply_to_internal n0 msgs i m;
- betree_Node_apply_messages_to_internal n0 msgs0 new_msgs_tl
+ l <- betree_Node_apply_to_internal n1 msgs i m;
+ betree_Node_apply_messages_to_internal n1 l new_msgs_tl
| Betree_List_Nil => Return msgs
end
end
.
-(** [betree_main::betree::{betree_main::betree::Node#5}::lookup_mut_in_bindings]: forward function
+(** [betree_main::betree::{betree_main::betree::Node#5}::lookup_mut_in_bindings]:
Source: 'src/betree.rs', lines 653:4-656:32 *)
Fixpoint betree_Node_lookup_mut_in_bindings
(n : nat) (key : u64) (bindings : betree_List_t (u64 * u64)) :
- result (betree_List_t (u64 * u64))
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match bindings with
- | Betree_List_Cons hd tl =>
- let (i, i0) := hd in
- if i s>= key
- then Return (Betree_List_Cons (i, i0) tl)
- else betree_Node_lookup_mut_in_bindings n0 key tl
- | Betree_List_Nil => Return Betree_List_Nil
- end
- end
-.
-
-(** [betree_main::betree::{betree_main::betree::Node#5}::lookup_mut_in_bindings]: backward function 0
- Source: 'src/betree.rs', lines 653:4-656:32 *)
-Fixpoint betree_Node_lookup_mut_in_bindings_back
- (n : nat) (key : u64) (bindings : betree_List_t (u64 * u64))
- (ret : betree_List_t (u64 * u64)) :
- result (betree_List_t (u64 * u64))
+ result ((betree_List_t (u64 * u64)) * (betree_List_t (u64 * u64) -> result
+ (betree_List_t (u64 * u64))))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match bindings with
| Betree_List_Cons hd tl =>
- let (i, i0) := hd in
+ let (i, i1) := hd in
if i s>= key
- then Return ret
+ then
+ let back_'a := fun (ret : betree_List_t (u64 * u64)) => Return ret in
+ Return (Betree_List_Cons (i, i1) tl, back_'a)
else (
- tl0 <- betree_Node_lookup_mut_in_bindings_back n0 key tl ret;
- Return (Betree_List_Cons (i, i0) tl0))
- | Betree_List_Nil => Return ret
+ p <- betree_Node_lookup_mut_in_bindings n1 key tl;
+ let (l, lookup_mut_in_bindings_back) := p in
+ let back_'a :=
+ fun (ret : betree_List_t (u64 * u64)) =>
+ tl1 <- lookup_mut_in_bindings_back ret;
+ Return (Betree_List_Cons (i, i1) tl1) in
+ Return (l, back_'a))
+ | Betree_List_Nil =>
+ let back_'a := fun (ret : betree_List_t (u64 * u64)) => Return ret in
+ Return (Betree_List_Nil, back_'a)
end
end
.
-(** [betree_main::betree::{betree_main::betree::Node#5}::apply_to_leaf]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [betree_main::betree::{betree_main::betree::Node#5}::apply_to_leaf]:
Source: 'src/betree.rs', lines 460:4-460:87 *)
Definition betree_Node_apply_to_leaf
(n : nat) (bindings : betree_List_t (u64 * u64)) (key : u64)
(new_msg : betree_Message_t) :
result (betree_List_t (u64 * u64))
:=
- bindings0 <- betree_Node_lookup_mut_in_bindings n key bindings;
- b <- betree_ListTupleU64T_head_has_key u64 bindings0 key;
+ p <- betree_Node_lookup_mut_in_bindings n key bindings;
+ let (bindings1, lookup_mut_in_bindings_back) := p in
+ b <- betree_ListTupleU64T_head_has_key u64 bindings1 key;
if b
then (
- hd <- betree_List_pop_front (u64 * u64) bindings0;
+ p1 <- betree_List_pop_front (u64 * u64) bindings1;
+ let (hd, l) := p1 in
match new_msg with
| Betree_Message_Insert v =>
- bindings1 <- betree_List_pop_front_back (u64 * u64) bindings0;
- bindings2 <- betree_List_push_front (u64 * u64) bindings1 (key, v);
- betree_Node_lookup_mut_in_bindings_back n key bindings bindings2
- | Betree_Message_Delete =>
- bindings1 <- betree_List_pop_front_back (u64 * u64) bindings0;
- betree_Node_lookup_mut_in_bindings_back n key bindings bindings1
+ l1 <- betree_List_push_front (u64 * u64) l (key, v);
+ lookup_mut_in_bindings_back l1
+ | Betree_Message_Delete => lookup_mut_in_bindings_back l
| Betree_Message_Upsert s =>
let (_, i) := hd in
v <- betree_upsert_update (Some i) s;
- bindings1 <- betree_List_pop_front_back (u64 * u64) bindings0;
- bindings2 <- betree_List_push_front (u64 * u64) bindings1 (key, v);
- betree_Node_lookup_mut_in_bindings_back n key bindings bindings2
+ l1 <- betree_List_push_front (u64 * u64) l (key, v);
+ lookup_mut_in_bindings_back l1
end)
else
match new_msg with
| Betree_Message_Insert v =>
- bindings1 <- betree_List_push_front (u64 * u64) bindings0 (key, v);
- betree_Node_lookup_mut_in_bindings_back n key bindings bindings1
- | Betree_Message_Delete =>
- betree_Node_lookup_mut_in_bindings_back n key bindings bindings0
+ l <- betree_List_push_front (u64 * u64) bindings1 (key, v);
+ lookup_mut_in_bindings_back l
+ | Betree_Message_Delete => lookup_mut_in_bindings_back bindings1
| Betree_Message_Upsert s =>
v <- betree_upsert_update None s;
- bindings1 <- betree_List_push_front (u64 * u64) bindings0 (key, v);
- betree_Node_lookup_mut_in_bindings_back n key bindings bindings1
+ l <- betree_List_push_front (u64 * u64) bindings1 (key, v);
+ lookup_mut_in_bindings_back l
end
.
-(** [betree_main::betree::{betree_main::betree::Node#5}::apply_messages_to_leaf]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [betree_main::betree::{betree_main::betree::Node#5}::apply_messages_to_leaf]:
Source: 'src/betree.rs', lines 444:4-447:5 *)
Fixpoint betree_Node_apply_messages_to_leaf
(n : nat) (bindings : betree_List_t (u64 * u64))
@@ -825,404 +627,230 @@ Fixpoint betree_Node_apply_messages_to_leaf
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match new_msgs with
| Betree_List_Cons new_msg new_msgs_tl =>
let (i, m) := new_msg in
- bindings0 <- betree_Node_apply_to_leaf n0 bindings i m;
- betree_Node_apply_messages_to_leaf n0 bindings0 new_msgs_tl
+ l <- betree_Node_apply_to_leaf n1 bindings i m;
+ betree_Node_apply_messages_to_leaf n1 l new_msgs_tl
| Betree_List_Nil => Return bindings
end
end
.
-(** [betree_main::betree::{betree_main::betree::Internal#4}::flush]: forward function
+(** [betree_main::betree::{betree_main::betree::Internal#4}::flush]:
Source: 'src/betree.rs', lines 410:4-415:26 *)
Fixpoint betree_Internal_flush
(n : nat) (self : betree_Internal_t) (params : betree_Params_t)
(node_id_cnt : betree_NodeIdCounter_t)
(content : betree_List_t (u64 * betree_Message_t)) (st : state) :
- result (state * (betree_List_t (u64 * betree_Message_t)))
+ result (state * ((betree_List_t (u64 * betree_Message_t)) *
+ (betree_Internal_t * betree_NodeIdCounter_t)))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
- p <-
- betree_ListTupleU64T_partition_at_pivot betree_Message_t n0 content
- self.(betree_Internal_pivot);
- let (msgs_left, msgs_right) := p in
- len_left <- betree_List_len (u64 * betree_Message_t) n0 msgs_left;
- if len_left s>= params.(betree_Params_min_flush_size)
- then (
- p0 <-
- betree_Node_apply_messages n0 self.(betree_Internal_left) params
- node_id_cnt msgs_left st;
- let (st0, _) := p0 in
- p1 <-
- betree_Node_apply_messages_back n0 self.(betree_Internal_left) params
- node_id_cnt msgs_left st;
- let (_, node_id_cnt0) := p1 in
- len_right <- betree_List_len (u64 * betree_Message_t) n0 msgs_right;
- if len_right s>= params.(betree_Params_min_flush_size)
- then (
- p2 <-
- betree_Node_apply_messages n0 self.(betree_Internal_right) params
- node_id_cnt0 msgs_right st0;
- let (st1, _) := p2 in
- _ <-
- betree_Node_apply_messages_back n0 self.(betree_Internal_right)
- params node_id_cnt0 msgs_right st0;
- Return (st1, Betree_List_Nil))
- else Return (st0, msgs_right))
- else (
- p0 <-
- betree_Node_apply_messages n0 self.(betree_Internal_right) params
- node_id_cnt msgs_right st;
- let (st0, _) := p0 in
- _ <-
- betree_Node_apply_messages_back n0 self.(betree_Internal_right) params
- node_id_cnt msgs_right st;
- Return (st0, msgs_left))
- end
-
-(** [betree_main::betree::{betree_main::betree::Internal#4}::flush]: backward function 0
- Source: 'src/betree.rs', lines 410:4-415:26 *)
-with betree_Internal_flush_back
- (n : nat) (self : betree_Internal_t) (params : betree_Params_t)
- (node_id_cnt : betree_NodeIdCounter_t)
- (content : betree_List_t (u64 * betree_Message_t)) (st : state) :
- result (betree_Internal_t * betree_NodeIdCounter_t)
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
p <-
- betree_ListTupleU64T_partition_at_pivot betree_Message_t n0 content
+ betree_ListTupleU64T_partition_at_pivot betree_Message_t n1 content
self.(betree_Internal_pivot);
let (msgs_left, msgs_right) := p in
- len_left <- betree_List_len (u64 * betree_Message_t) n0 msgs_left;
+ len_left <- betree_List_len (u64 * betree_Message_t) n1 msgs_left;
if len_left s>= params.(betree_Params_min_flush_size)
then (
- p0 <-
- betree_Node_apply_messages n0 self.(betree_Internal_left) params
- node_id_cnt msgs_left st;
- let (st0, _) := p0 in
p1 <-
- betree_Node_apply_messages_back n0 self.(betree_Internal_left) params
+ betree_Node_apply_messages n1 self.(betree_Internal_left) params
node_id_cnt msgs_left st;
- let (n1, node_id_cnt0) := p1 in
- len_right <- betree_List_len (u64 * betree_Message_t) n0 msgs_right;
+ let (st1, p2) := p1 in
+ let (n2, node_id_cnt1) := p2 in
+ len_right <- betree_List_len (u64 * betree_Message_t) n1 msgs_right;
if len_right s>= params.(betree_Params_min_flush_size)
then (
- p2 <-
- betree_Node_apply_messages_back n0 self.(betree_Internal_right)
- params node_id_cnt0 msgs_right st0;
- let (n2, node_id_cnt1) := p2 in
- Return (mkbetree_Internal_t self.(betree_Internal_id)
- self.(betree_Internal_pivot) n1 n2, node_id_cnt1))
+ p3 <-
+ betree_Node_apply_messages n1 self.(betree_Internal_right) params
+ node_id_cnt1 msgs_right st1;
+ let (st2, p4) := p3 in
+ let (n3, node_id_cnt2) := p4 in
+ Return (st2, (Betree_List_Nil, (mkbetree_Internal_t
+ self.(betree_Internal_id) self.(betree_Internal_pivot) n2 n3,
+ node_id_cnt2))))
else
- Return (mkbetree_Internal_t self.(betree_Internal_id)
- self.(betree_Internal_pivot) n1 self.(betree_Internal_right),
- node_id_cnt0))
+ Return (st1, (msgs_right, (mkbetree_Internal_t
+ self.(betree_Internal_id) self.(betree_Internal_pivot) n2
+ self.(betree_Internal_right), node_id_cnt1))))
else (
- p0 <-
- betree_Node_apply_messages_back n0 self.(betree_Internal_right) params
+ p1 <-
+ betree_Node_apply_messages n1 self.(betree_Internal_right) params
node_id_cnt msgs_right st;
- let (n1, node_id_cnt0) := p0 in
- Return (mkbetree_Internal_t self.(betree_Internal_id)
- self.(betree_Internal_pivot) self.(betree_Internal_left) n1,
- node_id_cnt0))
+ let (st1, p2) := p1 in
+ let (n2, node_id_cnt1) := p2 in
+ Return (st1, (msgs_left, (mkbetree_Internal_t self.(betree_Internal_id)
+ self.(betree_Internal_pivot) self.(betree_Internal_left) n2,
+ node_id_cnt1))))
end
-(** [betree_main::betree::{betree_main::betree::Node#5}::apply_messages]: forward function
+(** [betree_main::betree::{betree_main::betree::Node#5}::apply_messages]:
Source: 'src/betree.rs', lines 588:4-593:5 *)
with betree_Node_apply_messages
(n : nat) (self : betree_Node_t) (params : betree_Params_t)
(node_id_cnt : betree_NodeIdCounter_t)
(msgs : betree_List_t (u64 * betree_Message_t)) (st : state) :
- result (state * unit)
+ result (state * (betree_Node_t * betree_NodeIdCounter_t))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match self with
| Betree_Node_Internal node =>
p <- betree_load_internal_node node.(betree_Internal_id) st;
- let (st0, content) := p in
- content0 <- betree_Node_apply_messages_to_internal n0 content msgs;
- num_msgs <- betree_List_len (u64 * betree_Message_t) n0 content0;
+ let (st1, content) := p in
+ l <- betree_Node_apply_messages_to_internal n1 content msgs;
+ num_msgs <- betree_List_len (u64 * betree_Message_t) n1 l;
if num_msgs s>= params.(betree_Params_min_flush_size)
then (
- p0 <- betree_Internal_flush n0 node params node_id_cnt content0 st0;
- let (st1, content1) := p0 in
- p1 <-
- betree_Internal_flush_back n0 node params node_id_cnt content0 st0;
- let (node0, _) := p1 in
- p2 <-
- betree_store_internal_node node0.(betree_Internal_id) content1 st1;
- let (st2, _) := p2 in
- Return (st2, tt))
+ p1 <- betree_Internal_flush n1 node params node_id_cnt l st1;
+ let (st2, p2) := p1 in
+ let (content1, p3) := p2 in
+ let (node1, node_id_cnt1) := p3 in
+ p4 <-
+ betree_store_internal_node node1.(betree_Internal_id) content1 st2;
+ let (st3, _) := p4 in
+ Return (st3, (Betree_Node_Internal node1, node_id_cnt1)))
else (
- p0 <-
- betree_store_internal_node node.(betree_Internal_id) content0 st0;
- let (st1, _) := p0 in
- Return (st1, tt))
- | Betree_Node_Leaf node =>
- p <- betree_load_leaf_node node.(betree_Leaf_id) st;
- let (st0, content) := p in
- content0 <- betree_Node_apply_messages_to_leaf n0 content msgs;
- len <- betree_List_len (u64 * u64) n0 content0;
- i <- u64_mul 2%u64 params.(betree_Params_split_size);
- if len s>= i
- then (
- p0 <- betree_Leaf_split n0 node content0 params node_id_cnt st0;
- let (st1, _) := p0 in
- p1 <- betree_store_leaf_node node.(betree_Leaf_id) Betree_List_Nil st1;
+ p1 <- betree_store_internal_node node.(betree_Internal_id) l st1;
let (st2, _) := p1 in
- Return (st2, tt))
- else (
- p0 <- betree_store_leaf_node node.(betree_Leaf_id) content0 st0;
- let (st1, _) := p0 in
- Return (st1, tt))
- end
- end
-
-(** [betree_main::betree::{betree_main::betree::Node#5}::apply_messages]: backward function 0
- Source: 'src/betree.rs', lines 588:4-593:5 *)
-with betree_Node_apply_messages_back
- (n : nat) (self : betree_Node_t) (params : betree_Params_t)
- (node_id_cnt : betree_NodeIdCounter_t)
- (msgs : betree_List_t (u64 * betree_Message_t)) (st : state) :
- result (betree_Node_t * betree_NodeIdCounter_t)
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match self with
- | Betree_Node_Internal node =>
- p <- betree_load_internal_node node.(betree_Internal_id) st;
- let (st0, content) := p in
- content0 <- betree_Node_apply_messages_to_internal n0 content msgs;
- num_msgs <- betree_List_len (u64 * betree_Message_t) n0 content0;
- if num_msgs s>= params.(betree_Params_min_flush_size)
- then (
- p0 <- betree_Internal_flush n0 node params node_id_cnt content0 st0;
- let (st1, content1) := p0 in
- p1 <-
- betree_Internal_flush_back n0 node params node_id_cnt content0 st0;
- let (node0, node_id_cnt0) := p1 in
- _ <-
- betree_store_internal_node node0.(betree_Internal_id) content1 st1;
- Return (Betree_Node_Internal node0, node_id_cnt0))
- else (
- _ <- betree_store_internal_node node.(betree_Internal_id) content0 st0;
- Return (Betree_Node_Internal node, node_id_cnt))
+ Return (st2, (Betree_Node_Internal node, node_id_cnt)))
| Betree_Node_Leaf node =>
p <- betree_load_leaf_node node.(betree_Leaf_id) st;
- let (st0, content) := p in
- content0 <- betree_Node_apply_messages_to_leaf n0 content msgs;
- len <- betree_List_len (u64 * u64) n0 content0;
+ let (st1, content) := p in
+ l <- betree_Node_apply_messages_to_leaf n1 content msgs;
+ len <- betree_List_len (u64 * u64) n1 l;
i <- u64_mul 2%u64 params.(betree_Params_split_size);
if len s>= i
then (
- p0 <- betree_Leaf_split n0 node content0 params node_id_cnt st0;
- let (st1, new_node) := p0 in
- _ <- betree_store_leaf_node node.(betree_Leaf_id) Betree_List_Nil st1;
- node_id_cnt0 <-
- betree_Leaf_split_back n0 node content0 params node_id_cnt st0;
- Return (Betree_Node_Internal new_node, node_id_cnt0))
+ p1 <- betree_Leaf_split n1 node l params node_id_cnt st1;
+ let (st2, p2) := p1 in
+ let (new_node, nic) := p2 in
+ p3 <- betree_store_leaf_node node.(betree_Leaf_id) Betree_List_Nil st2;
+ let (st3, _) := p3 in
+ Return (st3, (Betree_Node_Internal new_node, nic)))
else (
- _ <- betree_store_leaf_node node.(betree_Leaf_id) content0 st0;
- Return (Betree_Node_Leaf
+ p1 <- betree_store_leaf_node node.(betree_Leaf_id) l st1;
+ let (st2, _) := p1 in
+ Return (st2, (Betree_Node_Leaf
{| betree_Leaf_id := node.(betree_Leaf_id); betree_Leaf_size := len
- |}, node_id_cnt))
+ |}, node_id_cnt)))
end
end
.
-(** [betree_main::betree::{betree_main::betree::Node#5}::apply]: forward function
+(** [betree_main::betree::{betree_main::betree::Node#5}::apply]:
Source: 'src/betree.rs', lines 576:4-582:5 *)
Definition betree_Node_apply
(n : nat) (self : betree_Node_t) (params : betree_Params_t)
(node_id_cnt : betree_NodeIdCounter_t) (key : u64)
(new_msg : betree_Message_t) (st : state) :
- result (state * unit)
+ result (state * (betree_Node_t * betree_NodeIdCounter_t))
:=
let l := Betree_List_Nil in
p <-
betree_Node_apply_messages n self params node_id_cnt (Betree_List_Cons
(key, new_msg) l) st;
- let (st0, _) := p in
- _ <-
- betree_Node_apply_messages_back n self params node_id_cnt (Betree_List_Cons
- (key, new_msg) l) st;
- Return (st0, tt)
-.
-
-(** [betree_main::betree::{betree_main::betree::Node#5}::apply]: backward function 0
- Source: 'src/betree.rs', lines 576:4-582:5 *)
-Definition betree_Node_apply_back
- (n : nat) (self : betree_Node_t) (params : betree_Params_t)
- (node_id_cnt : betree_NodeIdCounter_t) (key : u64)
- (new_msg : betree_Message_t) (st : state) :
- result (betree_Node_t * betree_NodeIdCounter_t)
- :=
- let l := Betree_List_Nil in
- betree_Node_apply_messages_back n self params node_id_cnt (Betree_List_Cons
- (key, new_msg) l) st
+ let (st1, p1) := p in
+ let (self1, node_id_cnt1) := p1 in
+ Return (st1, (self1, node_id_cnt1))
.
-(** [betree_main::betree::{betree_main::betree::BeTree#6}::new]: forward function
+(** [betree_main::betree::{betree_main::betree::BeTree#6}::new]:
Source: 'src/betree.rs', lines 849:4-849:60 *)
Definition betree_BeTree_new
(min_flush_size : u64) (split_size : u64) (st : state) :
result (state * betree_BeTree_t)
:=
node_id_cnt <- betree_NodeIdCounter_new;
- id <- betree_NodeIdCounter_fresh_id node_id_cnt;
- p <- betree_store_leaf_node id Betree_List_Nil st;
- let (st0, _) := p in
- node_id_cnt0 <- betree_NodeIdCounter_fresh_id_back node_id_cnt;
- Return (st0,
+ p <- betree_NodeIdCounter_fresh_id node_id_cnt;
+ let (id, nic) := p in
+ p1 <- betree_store_leaf_node id Betree_List_Nil st;
+ let (st1, _) := p1 in
+ Return (st1,
{|
betree_BeTree_params :=
{|
betree_Params_min_flush_size := min_flush_size;
betree_Params_split_size := split_size
|};
- betree_BeTree_node_id_cnt := node_id_cnt0;
+ betree_BeTree_node_id_cnt := nic;
betree_BeTree_root :=
(Betree_Node_Leaf
{| betree_Leaf_id := id; betree_Leaf_size := 0%u64 |})
|})
.
-(** [betree_main::betree::{betree_main::betree::BeTree#6}::apply]: forward function
+(** [betree_main::betree::{betree_main::betree::BeTree#6}::apply]:
Source: 'src/betree.rs', lines 868:4-868:47 *)
Definition betree_BeTree_apply
(n : nat) (self : betree_BeTree_t) (key : u64) (msg : betree_Message_t)
(st : state) :
- result (state * unit)
+ result (state * betree_BeTree_t)
:=
p <-
betree_Node_apply n self.(betree_BeTree_root) self.(betree_BeTree_params)
self.(betree_BeTree_node_id_cnt) key msg st;
- let (st0, _) := p in
- _ <-
- betree_Node_apply_back n self.(betree_BeTree_root)
- self.(betree_BeTree_params) self.(betree_BeTree_node_id_cnt) key msg st;
- Return (st0, tt)
-.
-
-(** [betree_main::betree::{betree_main::betree::BeTree#6}::apply]: backward function 0
- Source: 'src/betree.rs', lines 868:4-868:47 *)
-Definition betree_BeTree_apply_back
- (n : nat) (self : betree_BeTree_t) (key : u64) (msg : betree_Message_t)
- (st : state) :
- result betree_BeTree_t
- :=
- p <-
- betree_Node_apply_back n self.(betree_BeTree_root)
- self.(betree_BeTree_params) self.(betree_BeTree_node_id_cnt) key msg st;
- let (n0, nic) := p in
- Return
+ let (st1, p1) := p in
+ let (n1, nic) := p1 in
+ Return (st1,
{|
betree_BeTree_params := self.(betree_BeTree_params);
betree_BeTree_node_id_cnt := nic;
- betree_BeTree_root := n0
- |}
+ betree_BeTree_root := n1
+ |})
.
-(** [betree_main::betree::{betree_main::betree::BeTree#6}::insert]: forward function
+(** [betree_main::betree::{betree_main::betree::BeTree#6}::insert]:
Source: 'src/betree.rs', lines 874:4-874:52 *)
Definition betree_BeTree_insert
(n : nat) (self : betree_BeTree_t) (key : u64) (value : u64) (st : state) :
- result (state * unit)
- :=
- p <- betree_BeTree_apply n self key (Betree_Message_Insert value) st;
- let (st0, _) := p in
- _ <- betree_BeTree_apply_back n self key (Betree_Message_Insert value) st;
- Return (st0, tt)
-.
-
-(** [betree_main::betree::{betree_main::betree::BeTree#6}::insert]: backward function 0
- Source: 'src/betree.rs', lines 874:4-874:52 *)
-Definition betree_BeTree_insert_back
- (n : nat) (self : betree_BeTree_t) (key : u64) (value : u64) (st : state) :
- result betree_BeTree_t
+ result (state * betree_BeTree_t)
:=
- betree_BeTree_apply_back n self key (Betree_Message_Insert value) st
+ betree_BeTree_apply n self key (Betree_Message_Insert value) st
.
-(** [betree_main::betree::{betree_main::betree::BeTree#6}::delete]: forward function
+(** [betree_main::betree::{betree_main::betree::BeTree#6}::delete]:
Source: 'src/betree.rs', lines 880:4-880:38 *)
Definition betree_BeTree_delete
(n : nat) (self : betree_BeTree_t) (key : u64) (st : state) :
- result (state * unit)
- :=
- p <- betree_BeTree_apply n self key Betree_Message_Delete st;
- let (st0, _) := p in
- _ <- betree_BeTree_apply_back n self key Betree_Message_Delete st;
- Return (st0, tt)
-.
-
-(** [betree_main::betree::{betree_main::betree::BeTree#6}::delete]: backward function 0
- Source: 'src/betree.rs', lines 880:4-880:38 *)
-Definition betree_BeTree_delete_back
- (n : nat) (self : betree_BeTree_t) (key : u64) (st : state) :
- result betree_BeTree_t
+ result (state * betree_BeTree_t)
:=
- betree_BeTree_apply_back n self key Betree_Message_Delete st
+ betree_BeTree_apply n self key Betree_Message_Delete st
.
-(** [betree_main::betree::{betree_main::betree::BeTree#6}::upsert]: forward function
+(** [betree_main::betree::{betree_main::betree::BeTree#6}::upsert]:
Source: 'src/betree.rs', lines 886:4-886:59 *)
Definition betree_BeTree_upsert
(n : nat) (self : betree_BeTree_t) (key : u64)
(upd : betree_UpsertFunState_t) (st : state) :
- result (state * unit)
- :=
- p <- betree_BeTree_apply n self key (Betree_Message_Upsert upd) st;
- let (st0, _) := p in
- _ <- betree_BeTree_apply_back n self key (Betree_Message_Upsert upd) st;
- Return (st0, tt)
-.
-
-(** [betree_main::betree::{betree_main::betree::BeTree#6}::upsert]: backward function 0
- Source: 'src/betree.rs', lines 886:4-886:59 *)
-Definition betree_BeTree_upsert_back
- (n : nat) (self : betree_BeTree_t) (key : u64)
- (upd : betree_UpsertFunState_t) (st : state) :
- result betree_BeTree_t
+ result (state * betree_BeTree_t)
:=
- betree_BeTree_apply_back n self key (Betree_Message_Upsert upd) st
+ betree_BeTree_apply n self key (Betree_Message_Upsert upd) st
.
-(** [betree_main::betree::{betree_main::betree::BeTree#6}::lookup]: forward function
+(** [betree_main::betree::{betree_main::betree::BeTree#6}::lookup]:
Source: 'src/betree.rs', lines 895:4-895:62 *)
Definition betree_BeTree_lookup
(n : nat) (self : betree_BeTree_t) (key : u64) (st : state) :
- result (state * (option u64))
- :=
- betree_Node_lookup n self.(betree_BeTree_root) key st
-.
-
-(** [betree_main::betree::{betree_main::betree::BeTree#6}::lookup]: backward function 0
- Source: 'src/betree.rs', lines 895:4-895:62 *)
-Definition betree_BeTree_lookup_back
- (n : nat) (self : betree_BeTree_t) (key : u64) (st : state) :
- result betree_BeTree_t
+ result (state * ((option u64) * betree_BeTree_t))
:=
- n0 <- betree_Node_lookup_back n self.(betree_BeTree_root) key st;
- Return
+ p <- betree_Node_lookup n self.(betree_BeTree_root) key st;
+ let (st1, p1) := p in
+ let (o, n1) := p1 in
+ Return (st1, (o,
{|
betree_BeTree_params := self.(betree_BeTree_params);
betree_BeTree_node_id_cnt := self.(betree_BeTree_node_id_cnt);
- betree_BeTree_root := n0
- |}
+ betree_BeTree_root := n1
+ |}))
.
-(** [betree_main::main]: forward function
+(** [betree_main::main]:
Source: 'src/betree_main.rs', lines 5:0-5:9 *)
Definition main : result unit :=
Return tt.
diff --git a/tests/coq/betree/BetreeMain_FunsExternal_Template.v b/tests/coq/betree/BetreeMain_FunsExternal_Template.v
index 36022a20..a9969448 100644
--- a/tests/coq/betree/BetreeMain_FunsExternal_Template.v
+++ b/tests/coq/betree/BetreeMain_FunsExternal_Template.v
@@ -11,13 +11,13 @@ Require Import BetreeMain_Types.
Include BetreeMain_Types.
Module BetreeMain_FunsExternal_Template.
-(** [betree_main::betree_utils::load_internal_node]: forward function
+(** [betree_main::betree_utils::load_internal_node]:
Source: 'src/betree_utils.rs', lines 98:0-98:63 *)
Axiom betree_utils_load_internal_node
: u64 -> state -> result (state * (betree_List_t (u64 * betree_Message_t)))
.
-(** [betree_main::betree_utils::store_internal_node]: forward function
+(** [betree_main::betree_utils::store_internal_node]:
Source: 'src/betree_utils.rs', lines 115:0-115:71 *)
Axiom betree_utils_store_internal_node
:
@@ -25,19 +25,19 @@ Axiom betree_utils_store_internal_node
unit)
.
-(** [betree_main::betree_utils::load_leaf_node]: forward function
+(** [betree_main::betree_utils::load_leaf_node]:
Source: 'src/betree_utils.rs', lines 132:0-132:55 *)
Axiom betree_utils_load_leaf_node
: u64 -> state -> result (state * (betree_List_t (u64 * u64)))
.
-(** [betree_main::betree_utils::store_leaf_node]: forward function
+(** [betree_main::betree_utils::store_leaf_node]:
Source: 'src/betree_utils.rs', lines 145:0-145:63 *)
Axiom betree_utils_store_leaf_node
: u64 -> betree_List_t (u64 * u64) -> state -> result (state * unit)
.
-(** [core::option::{core::option::Option<T>}::unwrap]: forward function
+(** [core::option::{core::option::Option<T>}::unwrap]:
Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/option.rs', lines 932:4-932:34 *)
Axiom core_option_Option_unwrap :
forall(T : Type), option T -> state -> result (state * T)
diff --git a/tests/coq/betree/BetreeMain_Types.v b/tests/coq/betree/BetreeMain_Types.v
index 22989256..acbc2085 100644
--- a/tests/coq/betree/BetreeMain_Types.v
+++ b/tests/coq/betree/BetreeMain_Types.v
@@ -61,31 +61,31 @@ with betree_Node_t :=
.
Definition betree_Internal_id (x : betree_Internal_t) :=
- match x with | mkbetree_Internal_t x0 _ _ _ => x0 end
+ match x with | mkbetree_Internal_t x1 _ _ _ => x1 end
.
-Notation "x1 .(betree_Internal_id)" := (betree_Internal_id x1) (at level 9).
+Notation "x2 .(betree_Internal_id)" := (betree_Internal_id x2) (at level 9).
Definition betree_Internal_pivot (x : betree_Internal_t) :=
- match x with | mkbetree_Internal_t _ x0 _ _ => x0 end
+ match x with | mkbetree_Internal_t _ x1 _ _ => x1 end
.
-Notation "x1 .(betree_Internal_pivot)" := (betree_Internal_pivot x1)
+Notation "x2 .(betree_Internal_pivot)" := (betree_Internal_pivot x2)
(at level 9)
.
Definition betree_Internal_left (x : betree_Internal_t) :=
- match x with | mkbetree_Internal_t _ _ x0 _ => x0 end
+ match x with | mkbetree_Internal_t _ _ x1 _ => x1 end
.
-Notation "x1 .(betree_Internal_left)" := (betree_Internal_left x1) (at level 9)
+Notation "x2 .(betree_Internal_left)" := (betree_Internal_left x2) (at level 9)
.
Definition betree_Internal_right (x : betree_Internal_t) :=
- match x with | mkbetree_Internal_t _ _ _ x0 => x0 end
+ match x with | mkbetree_Internal_t _ _ _ x1 => x1 end
.
-Notation "x1 .(betree_Internal_right)" := (betree_Internal_right x1)
+Notation "x2 .(betree_Internal_right)" := (betree_Internal_right x2)
(at level 9)
.
diff --git a/tests/coq/betree/Primitives.v b/tests/coq/betree/Primitives.v
index 84280b96..990e27e4 100644
--- a/tests/coq/betree/Primitives.v
+++ b/tests/coq/betree/Primitives.v
@@ -67,8 +67,7 @@ Definition string := Coq.Strings.String.string.
Definition char := Coq.Strings.Ascii.ascii.
Definition char_of_byte := Coq.Strings.Ascii.ascii_of_byte.
-Definition core_mem_replace (a : Type) (x : a) (y : a) : a := x .
-Definition core_mem_replace_back (a : Type) (x : a) (y : a) : a := y .
+Definition core_mem_replace (a : Type) (x : a) (y : a) : a * a := (x, x) .
Record mut_raw_ptr (T : Type) := { mut_raw_ptr_v : T }.
Record const_raw_ptr (T : Type) := { const_raw_ptr_v : T }.
@@ -504,13 +503,15 @@ Arguments core_ops_index_Index_index {_ _}.
(* Trait declaration: [core::ops::index::IndexMut] *)
Record core_ops_index_IndexMut (Self Idx : Type) := mk_core_ops_index_IndexMut {
core_ops_index_IndexMut_indexInst : core_ops_index_Index Self Idx;
- core_ops_index_IndexMut_index_mut : Self -> Idx -> result core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output);
- core_ops_index_IndexMut_index_mut_back : Self -> Idx -> core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) -> result Self;
+ core_ops_index_IndexMut_index_mut :
+ Self ->
+ Idx ->
+ result (core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) *
+ (core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) -> result Self));
}.
Arguments mk_core_ops_index_IndexMut {_ _}.
Arguments core_ops_index_IndexMut_indexInst {_ _}.
Arguments core_ops_index_IndexMut_index_mut {_ _}.
-Arguments core_ops_index_IndexMut_index_mut_back {_ _}.
(* Trait declaration [core::ops::deref::Deref] *)
Record core_ops_deref_Deref (Self : Type) := mk_core_ops_deref_Deref {
@@ -524,13 +525,14 @@ Arguments core_ops_deref_Deref_deref {_}.
(* Trait declaration [core::ops::deref::DerefMut] *)
Record core_ops_deref_DerefMut (Self : Type) := mk_core_ops_deref_DerefMut {
core_ops_deref_DerefMut_derefInst : core_ops_deref_Deref Self;
- core_ops_deref_DerefMut_deref_mut : Self -> result core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target);
- core_ops_deref_DerefMut_deref_mut_back : Self -> core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) -> result Self;
+ core_ops_deref_DerefMut_deref_mut :
+ Self ->
+ result (core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) *
+ (core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) -> result Self));
}.
Arguments mk_core_ops_deref_DerefMut {_}.
Arguments core_ops_deref_DerefMut_derefInst {_}.
Arguments core_ops_deref_DerefMut_deref_mut {_}.
-Arguments core_ops_deref_DerefMut_deref_mut_back {_}.
Record core_ops_range_Range (T : Type) := mk_core_ops_range_Range {
core_ops_range_Range_start : T;
@@ -543,8 +545,8 @@ Arguments core_ops_range_Range_end_ {_}.
(*** [alloc] *)
Definition alloc_boxed_Box_deref (T : Type) (x : T) : result T := Return x.
-Definition alloc_boxed_Box_deref_mut (T : Type) (x : T) : result T := Return x.
-Definition alloc_boxed_Box_deref_mut_back (T : Type) (_ : T) (x : T) : result T := Return x.
+Definition alloc_boxed_Box_deref_mut (T : Type) (x : T) : result (T * (T -> result T)) :=
+ Return (x, fun x => Return x).
(* Trait instance *)
Definition alloc_boxed_Box_coreopsDerefInst (Self : Type) : core_ops_deref_Deref Self := {|
@@ -556,7 +558,6 @@ Definition alloc_boxed_Box_coreopsDerefInst (Self : Type) : core_ops_deref_Deref
Definition alloc_boxed_Box_coreopsDerefMutInst (Self : Type) : core_ops_deref_DerefMut Self := {|
core_ops_deref_DerefMut_derefInst := alloc_boxed_Box_coreopsDerefInst Self;
core_ops_deref_DerefMut_deref_mut := alloc_boxed_Box_deref_mut Self;
- core_ops_deref_DerefMut_deref_mut_back := alloc_boxed_Box_deref_mut_back Self;
|}.
@@ -584,6 +585,13 @@ Axiom array_repeat : forall (T : Type) (n : usize) (x : T), array T n.
Axiom array_index_usize : forall (T : Type) (n : usize) (x : array T n) (i : usize), result T.
Axiom array_update_usize : forall (T : Type) (n : usize) (x : array T n) (i : usize) (nx : T), result (array T n).
+Definition array_index_mut_usize (T : Type) (n : usize) (a : array T n) (i : usize) :
+ result (T * (T -> result (array T n))) :=
+ match array_index_usize T n a i with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, array_update_usize T n a i)
+ end.
+
(*** Slice *)
Definition slice T := { l: list T | Z.of_nat (length l) <= usize_max}.
@@ -591,11 +599,25 @@ Axiom slice_len : forall (T : Type) (s : slice T), usize.
Axiom slice_index_usize : forall (T : Type) (x : slice T) (i : usize), result T.
Axiom slice_update_usize : forall (T : Type) (x : slice T) (i : usize) (nx : T), result (slice T).
+Definition slice_index_mut_usize (T : Type) (s : slice T) (i : usize) :
+ result (T * (T -> result (slice T))) :=
+ match slice_index_usize T s i with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, slice_update_usize T s i)
+ end.
+
(*** Subslices *)
Axiom array_to_slice : forall (T : Type) (n : usize) (x : array T n), result (slice T).
Axiom array_from_slice : forall (T : Type) (n : usize) (x : array T n) (s : slice T), result (array T n).
+Definition array_to_slice_mut (T : Type) (n : usize) (a : array T n) :
+ result (slice T * (slice T -> result (array T n))) :=
+ match array_to_slice T n a with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, array_from_slice T n a)
+ end.
+
Axiom array_subslice: forall (T : Type) (n : usize) (x : array T n) (r : core_ops_range_Range usize), result (slice T).
Axiom array_update_subslice: forall (T : Type) (n : usize) (x : array T n) (r : core_ops_range_Range usize) (ns : slice T), result (array T n).
@@ -639,16 +661,9 @@ Definition alloc_vec_Vec_bind {A B} (v: alloc_vec_Vec A) (f: list A -> result (l
| right _ => Fail_ Failure
end.
-(* The **forward** function shouldn't be used *)
-Definition alloc_vec_Vec_push_fwd (T: Type) (v: alloc_vec_Vec T) (x: T) : unit := tt.
-
Definition alloc_vec_Vec_push (T: Type) (v: alloc_vec_Vec T) (x: T) : result (alloc_vec_Vec T) :=
alloc_vec_Vec_bind v (fun l => Return (l ++ [x])).
-(* The **forward** function shouldn't be used *)
-Definition alloc_vec_Vec_insert_fwd (T: Type) (v: alloc_vec_Vec T) (i: usize) (x: T) : result unit :=
- if to_Z i <? alloc_vec_Vec_length v then Return tt else Fail_ Failure.
-
Definition alloc_vec_Vec_insert (T: Type) (v: alloc_vec_Vec T) (i: usize) (x: T) : result (alloc_vec_Vec T) :=
alloc_vec_Vec_bind v (fun l =>
if to_Z i <? Z.of_nat (length l)
@@ -661,6 +676,14 @@ Axiom alloc_vec_Vec_index_usize : forall {T : Type} (v : alloc_vec_Vec T) (i : u
(* Helper *)
Axiom alloc_vec_Vec_update_usize : forall {T : Type} (v : alloc_vec_Vec T) (i : usize) (x : T), result (alloc_vec_Vec T).
+Definition alloc_vec_Vec_index_mut_usize {T : Type} (v: alloc_vec_Vec T) (i: usize) :
+ result (T * (T -> result (alloc_vec_Vec T))) :=
+ match alloc_vec_Vec_index_usize v i with
+ | Return x =>
+ Return (x, alloc_vec_Vec_update_usize v i)
+ | Fail_ e => Fail_ e
+ end.
+
(* Trait declaration: [core::slice::index::private_slice_index::Sealed] *)
Definition core_slice_index_private_slice_index_Sealed (self : Type) := unit.
@@ -669,25 +692,23 @@ Record core_slice_index_SliceIndex (Self T : Type) := mk_core_slice_index_SliceI
core_slice_index_SliceIndex_sealedInst : core_slice_index_private_slice_index_Sealed Self;
core_slice_index_SliceIndex_Output : Type;
core_slice_index_SliceIndex_get : Self -> T -> result (option core_slice_index_SliceIndex_Output);
- core_slice_index_SliceIndex_get_mut : Self -> T -> result (option core_slice_index_SliceIndex_Output);
- core_slice_index_SliceIndex_get_mut_back : Self -> T -> option core_slice_index_SliceIndex_Output -> result T;
+ core_slice_index_SliceIndex_get_mut :
+ Self -> T -> result (option core_slice_index_SliceIndex_Output * (option core_slice_index_SliceIndex_Output -> result T));
core_slice_index_SliceIndex_get_unchecked : Self -> const_raw_ptr T -> result (const_raw_ptr core_slice_index_SliceIndex_Output);
core_slice_index_SliceIndex_get_unchecked_mut : Self -> mut_raw_ptr T -> result (mut_raw_ptr core_slice_index_SliceIndex_Output);
core_slice_index_SliceIndex_index : Self -> T -> result core_slice_index_SliceIndex_Output;
- core_slice_index_SliceIndex_index_mut : Self -> T -> result core_slice_index_SliceIndex_Output;
- core_slice_index_SliceIndex_index_mut_back : Self -> T -> core_slice_index_SliceIndex_Output -> result T;
+ core_slice_index_SliceIndex_index_mut :
+ Self -> T -> result (core_slice_index_SliceIndex_Output * (core_slice_index_SliceIndex_Output -> result T));
}.
Arguments mk_core_slice_index_SliceIndex {_ _}.
Arguments core_slice_index_SliceIndex_sealedInst {_ _}.
Arguments core_slice_index_SliceIndex_Output {_ _}.
Arguments core_slice_index_SliceIndex_get {_ _}.
Arguments core_slice_index_SliceIndex_get_mut {_ _}.
-Arguments core_slice_index_SliceIndex_get_mut_back {_ _}.
Arguments core_slice_index_SliceIndex_get_unchecked {_ _}.
Arguments core_slice_index_SliceIndex_get_unchecked_mut {_ _}.
Arguments core_slice_index_SliceIndex_index {_ _}.
Arguments core_slice_index_SliceIndex_index_mut {_ _}.
-Arguments core_slice_index_SliceIndex_index_mut_back {_ _}.
(* [core::slice::index::[T]::index]: forward function *)
Definition core_slice_index_Slice_index
@@ -704,11 +725,9 @@ Axiom core_slice_index_RangeUsize_get : forall (T : Type) (i : core_ops_range_Ra
(* [core::slice::index::Range::get_mut]: forward function *)
Axiom core_slice_index_RangeUsize_get_mut :
- forall (T : Type), core_ops_range_Range usize -> slice T -> result (option (slice T)).
-
-(* [core::slice::index::Range::get_mut]: backward function 0 *)
-Axiom core_slice_index_RangeUsize_get_mut_back :
- forall (T : Type), core_ops_range_Range usize -> slice T -> option (slice T) -> result (slice T).
+ forall (T : Type),
+ core_ops_range_Range usize -> slice T ->
+ result (option (slice T) * (option (slice T) -> result (slice T))).
(* [core::slice::index::Range::get_unchecked]: forward function *)
Definition core_slice_index_RangeUsize_get_unchecked
@@ -732,21 +751,14 @@ Axiom core_slice_index_RangeUsize_index :
(* [core::slice::index::Range::index_mut]: forward function *)
Axiom core_slice_index_RangeUsize_index_mut :
- forall (T : Type), core_ops_range_Range usize -> slice T -> result (slice T).
-
-(* [core::slice::index::Range::index_mut]: backward function 0 *)
-Axiom core_slice_index_RangeUsize_index_mut_back :
- forall (T : Type), core_ops_range_Range usize -> slice T -> slice T -> result (slice T).
+ forall (T : Type), core_ops_range_Range usize -> slice T -> result (slice T * (slice T -> result (slice T))).
(* [core::slice::index::[T]::index_mut]: forward function *)
Axiom core_slice_index_Slice_index_mut :
forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T)),
- slice T -> Idx -> result inst.(core_slice_index_SliceIndex_Output).
-
-(* [core::slice::index::[T]::index_mut]: backward function 0 *)
-Axiom core_slice_index_Slice_index_mut_back :
- forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T)),
- slice T -> Idx -> inst.(core_slice_index_SliceIndex_Output) -> result (slice T).
+ slice T -> Idx ->
+ result (inst.(core_slice_index_SliceIndex_Output) *
+ (inst.(core_slice_index_SliceIndex_Output) -> result (slice T))).
(* [core::array::[T; N]::index]: forward function *)
Axiom core_array_Array_index :
@@ -756,12 +768,9 @@ Axiom core_array_Array_index :
(* [core::array::[T; N]::index_mut]: forward function *)
Axiom core_array_Array_index_mut :
forall (T Idx : Type) (N : usize) (inst : core_ops_index_IndexMut (slice T) Idx)
- (a : array T N) (i : Idx), result inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output).
-
-(* [core::array::[T; N]::index_mut]: backward function 0 *)
-Axiom core_array_Array_index_mut_back :
- forall (T Idx : Type) (N : usize) (inst : core_ops_index_IndexMut (slice T) Idx)
- (a : array T N) (i : Idx) (x : inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output)), result (array T N).
+ (a : array T N) (i : Idx),
+ result (inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output) *
+ (inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output) -> result (array T N))).
(* Trait implementation: [core::slice::index::private_slice_index::Range] *)
Definition core_slice_index_private_slice_index_SealedRangeUsizeInst
@@ -774,12 +783,10 @@ Definition core_slice_index_SliceIndexRangeUsizeSliceTInst (T : Type) :
core_slice_index_SliceIndex_Output := slice T;
core_slice_index_SliceIndex_get := core_slice_index_RangeUsize_get T;
core_slice_index_SliceIndex_get_mut := core_slice_index_RangeUsize_get_mut T;
- core_slice_index_SliceIndex_get_mut_back := core_slice_index_RangeUsize_get_mut_back T;
core_slice_index_SliceIndex_get_unchecked := core_slice_index_RangeUsize_get_unchecked T;
core_slice_index_SliceIndex_get_unchecked_mut := core_slice_index_RangeUsize_get_unchecked_mut T;
core_slice_index_SliceIndex_index := core_slice_index_RangeUsize_index T;
core_slice_index_SliceIndex_index_mut := core_slice_index_RangeUsize_index_mut T;
- core_slice_index_SliceIndex_index_mut_back := core_slice_index_RangeUsize_index_mut_back T;
|}.
(* Trait implementation: [core::slice::index::[T]] *)
@@ -796,7 +803,6 @@ Definition core_ops_index_IndexMutSliceTIInst (T Idx : Type)
core_ops_index_IndexMut (slice T) Idx := {|
core_ops_index_IndexMut_indexInst := core_ops_index_IndexSliceTIInst T Idx inst;
core_ops_index_IndexMut_index_mut := core_slice_index_Slice_index_mut T Idx inst;
- core_ops_index_IndexMut_index_mut_back := core_slice_index_Slice_index_mut_back T Idx inst;
|}.
(* Trait implementation: [core::array::[T; N]] *)
@@ -813,18 +819,14 @@ Definition core_ops_index_IndexMutArrayInst (T Idx : Type) (N : usize)
core_ops_index_IndexMut (array T N) Idx := {|
core_ops_index_IndexMut_indexInst := core_ops_index_IndexArrayInst T Idx N inst.(core_ops_index_IndexMut_indexInst);
core_ops_index_IndexMut_index_mut := core_array_Array_index_mut T Idx N inst;
- core_ops_index_IndexMut_index_mut_back := core_array_Array_index_mut_back T Idx N inst;
|}.
(* [core::slice::index::usize::get]: forward function *)
Axiom core_slice_index_usize_get : forall (T : Type), usize -> slice T -> result (option T).
(* [core::slice::index::usize::get_mut]: forward function *)
-Axiom core_slice_index_usize_get_mut : forall (T : Type), usize -> slice T -> result (option T).
-
-(* [core::slice::index::usize::get_mut]: backward function 0 *)
-Axiom core_slice_index_usize_get_mut_back :
- forall (T : Type), usize -> slice T -> option T -> result (slice T).
+Axiom core_slice_index_usize_get_mut :
+ forall (T : Type), usize -> slice T -> result (option T * (option T -> result (slice T))).
(* [core::slice::index::usize::get_unchecked]: forward function *)
Axiom core_slice_index_usize_get_unchecked :
@@ -838,11 +840,8 @@ Axiom core_slice_index_usize_get_unchecked_mut :
Axiom core_slice_index_usize_index : forall (T : Type), usize -> slice T -> result T.
(* [core::slice::index::usize::index_mut]: forward function *)
-Axiom core_slice_index_usize_index_mut : forall (T : Type), usize -> slice T -> result T.
-
-(* [core::slice::index::usize::index_mut]: backward function 0 *)
-Axiom core_slice_index_usize_index_mut_back :
- forall (T : Type), usize -> slice T -> T -> result (slice T).
+Axiom core_slice_index_usize_index_mut :
+ forall (T : Type), usize -> slice T -> result (T * (T -> result (slice T))).
(* Trait implementation: [core::slice::index::private_slice_index::usize] *)
Definition core_slice_index_private_slice_index_SealedUsizeInst
@@ -855,12 +854,10 @@ Definition core_slice_index_SliceIndexUsizeSliceTInst (T : Type) :
core_slice_index_SliceIndex_Output := T;
core_slice_index_SliceIndex_get := core_slice_index_usize_get T;
core_slice_index_SliceIndex_get_mut := core_slice_index_usize_get_mut T;
- core_slice_index_SliceIndex_get_mut_back := core_slice_index_usize_get_mut_back T;
core_slice_index_SliceIndex_get_unchecked := core_slice_index_usize_get_unchecked T;
core_slice_index_SliceIndex_get_unchecked_mut := core_slice_index_usize_get_unchecked_mut T;
core_slice_index_SliceIndex_index := core_slice_index_usize_index T;
core_slice_index_SliceIndex_index_mut := core_slice_index_usize_index_mut T;
- core_slice_index_SliceIndex_index_mut_back := core_slice_index_usize_index_mut_back T;
|}.
(* [alloc::vec::Vec::index]: forward function *)
@@ -869,12 +866,9 @@ Axiom alloc_vec_Vec_index : forall (T Idx : Type) (inst : core_slice_index_Slice
(* [alloc::vec::Vec::index_mut]: forward function *)
Axiom alloc_vec_Vec_index_mut : forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T))
- (Self : alloc_vec_Vec T) (i : Idx), result inst.(core_slice_index_SliceIndex_Output).
-
-(* [alloc::vec::Vec::index_mut]: backward function 0 *)
-Axiom alloc_vec_Vec_index_mut_back :
- forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T))
- (Self : alloc_vec_Vec T) (i : Idx) (x : inst.(core_slice_index_SliceIndex_Output)), result (alloc_vec_Vec T).
+ (Self : alloc_vec_Vec T) (i : Idx),
+ result (inst.(core_slice_index_SliceIndex_Output) *
+ (inst.(core_slice_index_SliceIndex_Output) -> result (alloc_vec_Vec T))).
(* Trait implementation: [alloc::vec::Vec] *)
Definition alloc_vec_Vec_coreopsindexIndexInst (T Idx : Type)
@@ -890,7 +884,6 @@ Definition alloc_vec_Vec_coreopsindexIndexMutInst (T Idx : Type)
core_ops_index_IndexMut (alloc_vec_Vec T) Idx := {|
core_ops_index_IndexMut_indexInst := alloc_vec_Vec_coreopsindexIndexInst T Idx inst;
core_ops_index_IndexMut_index_mut := alloc_vec_Vec_index_mut T Idx inst;
- core_ops_index_IndexMut_index_mut_back := alloc_vec_Vec_index_mut_back T Idx inst;
|}.
(*** Theorems *)
@@ -901,10 +894,6 @@ Axiom alloc_vec_Vec_index_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usiz
Axiom alloc_vec_Vec_index_mut_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usize) (x : a),
alloc_vec_Vec_index_mut a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i =
- alloc_vec_Vec_index_usize v i.
-
-Axiom alloc_vec_Vec_index_mut_back_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usize) (x : a),
- alloc_vec_Vec_index_mut_back a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i x =
- alloc_vec_Vec_update_usize v i x.
+ alloc_vec_Vec_index_mut_usize v i.
End Primitives.
diff --git a/tests/coq/hashmap/Hashmap_Funs.v b/tests/coq/hashmap/Hashmap_Funs.v
index 64de44a6..5cd9fe70 100644
--- a/tests/coq/hashmap/Hashmap_Funs.v
+++ b/tests/coq/hashmap/Hashmap_Funs.v
@@ -10,39 +10,39 @@ Require Import Hashmap_Types.
Include Hashmap_Types.
Module Hashmap_Funs.
-(** [hashmap::hash_key]: forward function
+(** [hashmap::hash_key]:
Source: 'src/hashmap.rs', lines 27:0-27:32 *)
Definition hash_key (k : usize) : result usize :=
Return k.
-(** [hashmap::{hashmap::HashMap<T>}::allocate_slots]: loop 0: forward function
+(** [hashmap::{hashmap::HashMap<T>}::allocate_slots]: loop 0:
Source: 'src/hashmap.rs', lines 50:4-56:5 *)
Fixpoint hashMap_allocate_slots_loop
- (T : Type) (n : nat) (slots : alloc_vec_Vec (List_t T)) (n0 : usize) :
+ (T : Type) (n : nat) (slots : alloc_vec_Vec (List_t T)) (n1 : usize) :
result (alloc_vec_Vec (List_t T))
:=
match n with
| O => Fail_ OutOfFuel
- | S n1 =>
- if n0 s> 0%usize
+ | S n2 =>
+ if n1 s> 0%usize
then (
- slots0 <- alloc_vec_Vec_push (List_t T) slots List_Nil;
- n2 <- usize_sub n0 1%usize;
- hashMap_allocate_slots_loop T n1 slots0 n2)
+ v <- alloc_vec_Vec_push (List_t T) slots List_Nil;
+ n3 <- usize_sub n1 1%usize;
+ hashMap_allocate_slots_loop T n2 v n3)
else Return slots
end
.
-(** [hashmap::{hashmap::HashMap<T>}::allocate_slots]: forward function
+(** [hashmap::{hashmap::HashMap<T>}::allocate_slots]:
Source: 'src/hashmap.rs', lines 50:4-50:76 *)
Definition hashMap_allocate_slots
- (T : Type) (n : nat) (slots : alloc_vec_Vec (List_t T)) (n0 : usize) :
+ (T : Type) (n : nat) (slots : alloc_vec_Vec (List_t T)) (n1 : usize) :
result (alloc_vec_Vec (List_t T))
:=
- hashMap_allocate_slots_loop T n slots n0
+ hashMap_allocate_slots_loop T n slots n1
.
-(** [hashmap::{hashmap::HashMap<T>}::new_with_capacity]: forward function
+(** [hashmap::{hashmap::HashMap<T>}::new_with_capacity]:
Source: 'src/hashmap.rs', lines 59:4-63:13 *)
Definition hashMap_new_with_capacity
(T : Type) (n : nat) (capacity : usize) (max_load_dividend : usize)
@@ -52,24 +52,23 @@ Definition hashMap_new_with_capacity
let v := alloc_vec_Vec_new (List_t T) in
slots <- hashMap_allocate_slots T n v capacity;
i <- usize_mul capacity max_load_dividend;
- i0 <- usize_div i max_load_divisor;
+ i1 <- usize_div i max_load_divisor;
Return
{|
hashMap_num_entries := 0%usize;
hashMap_max_load_factor := (max_load_dividend, max_load_divisor);
- hashMap_max_load := i0;
+ hashMap_max_load := i1;
hashMap_slots := slots
|}
.
-(** [hashmap::{hashmap::HashMap<T>}::new]: forward function
+(** [hashmap::{hashmap::HashMap<T>}::new]:
Source: 'src/hashmap.rs', lines 75:4-75:24 *)
Definition hashMap_new (T : Type) (n : nat) : result (HashMap_t T) :=
hashMap_new_with_capacity T n 32%usize 4%usize 5%usize
.
-(** [hashmap::{hashmap::HashMap<T>}::clear]: loop 0: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap::{hashmap::HashMap<T>}::clear]: loop 0:
Source: 'src/hashmap.rs', lines 80:4-88:5 *)
Fixpoint hashMap_clear_loop
(T : Type) (n : nat) (slots : alloc_vec_Vec (List_t T)) (i : usize) :
@@ -77,101 +76,73 @@ Fixpoint hashMap_clear_loop
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
- let i0 := alloc_vec_Vec_len (List_t T) slots in
- if i s< i0
+ | S n1 =>
+ let i1 := alloc_vec_Vec_len (List_t T) slots in
+ if i s< i1
then (
- i1 <- usize_add i 1%usize;
- slots0 <-
- alloc_vec_Vec_index_mut_back (List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (List_t T)) slots i
- List_Nil;
- hashMap_clear_loop T n0 slots0 i1)
+ p <-
+ alloc_vec_Vec_index_mut (List_t T) usize
+ (core_slice_index_SliceIndexUsizeSliceTInst (List_t T)) slots i;
+ let (_, index_mut_back) := p in
+ i2 <- usize_add i 1%usize;
+ slots1 <- index_mut_back List_Nil;
+ hashMap_clear_loop T n1 slots1 i2)
else Return slots
end
.
-(** [hashmap::{hashmap::HashMap<T>}::clear]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap::{hashmap::HashMap<T>}::clear]:
Source: 'src/hashmap.rs', lines 80:4-80:27 *)
Definition hashMap_clear
(T : Type) (n : nat) (self : HashMap_t T) : result (HashMap_t T) :=
- v <- hashMap_clear_loop T n self.(hashMap_slots) 0%usize;
+ back <- hashMap_clear_loop T n self.(hashMap_slots) 0%usize;
Return
{|
hashMap_num_entries := 0%usize;
hashMap_max_load_factor := self.(hashMap_max_load_factor);
hashMap_max_load := self.(hashMap_max_load);
- hashMap_slots := v
+ hashMap_slots := back
|}
.
-(** [hashmap::{hashmap::HashMap<T>}::len]: forward function
+(** [hashmap::{hashmap::HashMap<T>}::len]:
Source: 'src/hashmap.rs', lines 90:4-90:30 *)
Definition hashMap_len (T : Type) (self : HashMap_t T) : result usize :=
Return self.(hashMap_num_entries)
.
-(** [hashmap::{hashmap::HashMap<T>}::insert_in_list]: loop 0: forward function
+(** [hashmap::{hashmap::HashMap<T>}::insert_in_list]: loop 0:
Source: 'src/hashmap.rs', lines 97:4-114:5 *)
Fixpoint hashMap_insert_in_list_loop
(T : Type) (n : nat) (key : usize) (value : T) (ls : List_t T) :
- result bool
+ result (bool * (List_t T))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| List_Cons ckey cvalue tl =>
if ckey s= key
- then Return false
- else hashMap_insert_in_list_loop T n0 key value tl
- | List_Nil => Return true
+ then Return (false, List_Cons ckey value tl)
+ else (
+ p <- hashMap_insert_in_list_loop T n1 key value tl;
+ let (b, back) := p in
+ Return (b, List_Cons ckey cvalue back))
+ | List_Nil => let l := List_Nil in Return (true, List_Cons key value l)
end
end
.
-(** [hashmap::{hashmap::HashMap<T>}::insert_in_list]: forward function
+(** [hashmap::{hashmap::HashMap<T>}::insert_in_list]:
Source: 'src/hashmap.rs', lines 97:4-97:71 *)
Definition hashMap_insert_in_list
(T : Type) (n : nat) (key : usize) (value : T) (ls : List_t T) :
- result bool
+ result (bool * (List_t T))
:=
hashMap_insert_in_list_loop T n key value ls
.
-(** [hashmap::{hashmap::HashMap<T>}::insert_in_list]: loop 0: backward function 0
- Source: 'src/hashmap.rs', lines 97:4-114:5 *)
-Fixpoint hashMap_insert_in_list_loop_back
- (T : Type) (n : nat) (key : usize) (value : T) (ls : List_t T) :
- result (List_t T)
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls with
- | List_Cons ckey cvalue tl =>
- if ckey s= key
- then Return (List_Cons ckey value tl)
- else (
- tl0 <- hashMap_insert_in_list_loop_back T n0 key value tl;
- Return (List_Cons ckey cvalue tl0))
- | List_Nil => let l := List_Nil in Return (List_Cons key value l)
- end
- end
-.
-
-(** [hashmap::{hashmap::HashMap<T>}::insert_in_list]: backward function 0
- Source: 'src/hashmap.rs', lines 97:4-97:71 *)
-Definition hashMap_insert_in_list_back
- (T : Type) (n : nat) (key : usize) (value : T) (ls : List_t T) :
- result (List_t T)
- :=
- hashMap_insert_in_list_loop_back T n key value ls
-.
-
-(** [hashmap::{hashmap::HashMap<T>}::insert_no_resize]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap::{hashmap::HashMap<T>}::insert_no_resize]:
Source: 'src/hashmap.rs', lines 117:4-117:54 *)
Definition hashMap_insert_no_resize
(T : Type) (n : nat) (self : HashMap_t T) (key : usize) (value : T) :
@@ -180,32 +151,26 @@ Definition hashMap_insert_no_resize
hash <- hash_key key;
let i := alloc_vec_Vec_len (List_t T) self.(hashMap_slots) in
hash_mod <- usize_rem hash i;
- l <-
+ p <-
alloc_vec_Vec_index_mut (List_t T) usize
(core_slice_index_SliceIndexUsizeSliceTInst (List_t T))
self.(hashMap_slots) hash_mod;
- inserted <- hashMap_insert_in_list T n key value l;
+ let (l, index_mut_back) := p in
+ p1 <- hashMap_insert_in_list T n key value l;
+ let (inserted, l1) := p1 in
if inserted
then (
- i0 <- usize_add self.(hashMap_num_entries) 1%usize;
- l0 <- hashMap_insert_in_list_back T n key value l;
- v <-
- alloc_vec_Vec_index_mut_back (List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (List_t T))
- self.(hashMap_slots) hash_mod l0;
+ i1 <- usize_add self.(hashMap_num_entries) 1%usize;
+ v <- index_mut_back l1;
Return
{|
- hashMap_num_entries := i0;
+ hashMap_num_entries := i1;
hashMap_max_load_factor := self.(hashMap_max_load_factor);
hashMap_max_load := self.(hashMap_max_load);
hashMap_slots := v
|})
else (
- l0 <- hashMap_insert_in_list_back T n key value l;
- v <-
- alloc_vec_Vec_index_mut_back (List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (List_t T))
- self.(hashMap_slots) hash_mod l0;
+ v <- index_mut_back l1;
Return
{|
hashMap_num_entries := self.(hashMap_num_entries);
@@ -215,8 +180,7 @@ Definition hashMap_insert_no_resize
|})
.
-(** [hashmap::{hashmap::HashMap<T>}::move_elements_from_list]: loop 0: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap::{hashmap::HashMap<T>}::move_elements_from_list]: loop 0:
Source: 'src/hashmap.rs', lines 183:4-196:5 *)
Fixpoint hashMap_move_elements_from_list_loop
(T : Type) (n : nat) (ntable : HashMap_t T) (ls : List_t T) :
@@ -224,18 +188,17 @@ Fixpoint hashMap_move_elements_from_list_loop
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| List_Cons k v tl =>
- ntable0 <- hashMap_insert_no_resize T n0 ntable k v;
- hashMap_move_elements_from_list_loop T n0 ntable0 tl
+ hm <- hashMap_insert_no_resize T n1 ntable k v;
+ hashMap_move_elements_from_list_loop T n1 hm tl
| List_Nil => Return ntable
end
end
.
-(** [hashmap::{hashmap::HashMap<T>}::move_elements_from_list]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap::{hashmap::HashMap<T>}::move_elements_from_list]:
Source: 'src/hashmap.rs', lines 183:4-183:72 *)
Definition hashMap_move_elements_from_list
(T : Type) (n : nat) (ntable : HashMap_t T) (ls : List_t T) :
@@ -244,8 +207,7 @@ Definition hashMap_move_elements_from_list
hashMap_move_elements_from_list_loop T n ntable ls
.
-(** [hashmap::{hashmap::HashMap<T>}::move_elements]: loop 0: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap::{hashmap::HashMap<T>}::move_elements]: loop 0:
Source: 'src/hashmap.rs', lines 171:4-180:5 *)
Fixpoint hashMap_move_elements_loop
(T : Type) (n : nat) (ntable : HashMap_t T)
@@ -254,108 +216,105 @@ Fixpoint hashMap_move_elements_loop
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
- let i0 := alloc_vec_Vec_len (List_t T) slots in
- if i s< i0
+ | S n1 =>
+ let i1 := alloc_vec_Vec_len (List_t T) slots in
+ if i s< i1
then (
- l <-
+ p <-
alloc_vec_Vec_index_mut (List_t T) usize
(core_slice_index_SliceIndexUsizeSliceTInst (List_t T)) slots i;
- let ls := core_mem_replace (List_t T) l List_Nil in
- ntable0 <- hashMap_move_elements_from_list T n0 ntable ls;
- i1 <- usize_add i 1%usize;
- let l0 := core_mem_replace_back (List_t T) l List_Nil in
- slots0 <-
- alloc_vec_Vec_index_mut_back (List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (List_t T)) slots i l0;
- hashMap_move_elements_loop T n0 ntable0 slots0 i1)
+ let (l, index_mut_back) := p in
+ let (ls, l1) := core_mem_replace (List_t T) l List_Nil in
+ hm <- hashMap_move_elements_from_list T n1 ntable ls;
+ i2 <- usize_add i 1%usize;
+ slots1 <- index_mut_back l1;
+ back_'a <- hashMap_move_elements_loop T n1 hm slots1 i2;
+ let (hm1, v) := back_'a in
+ Return (hm1, v))
else Return (ntable, slots)
end
.
-(** [hashmap::{hashmap::HashMap<T>}::move_elements]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap::{hashmap::HashMap<T>}::move_elements]:
Source: 'src/hashmap.rs', lines 171:4-171:95 *)
Definition hashMap_move_elements
(T : Type) (n : nat) (ntable : HashMap_t T)
(slots : alloc_vec_Vec (List_t T)) (i : usize) :
result ((HashMap_t T) * (alloc_vec_Vec (List_t T)))
:=
- hashMap_move_elements_loop T n ntable slots i
+ back_'a <- hashMap_move_elements_loop T n ntable slots i;
+ let (hm, v) := back_'a in
+ Return (hm, v)
.
-(** [hashmap::{hashmap::HashMap<T>}::try_resize]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap::{hashmap::HashMap<T>}::try_resize]:
Source: 'src/hashmap.rs', lines 140:4-140:28 *)
Definition hashMap_try_resize
(T : Type) (n : nat) (self : HashMap_t T) : result (HashMap_t T) :=
max_usize <- scalar_cast U32 Usize core_u32_max;
let capacity := alloc_vec_Vec_len (List_t T) self.(hashMap_slots) in
n1 <- usize_div max_usize 2%usize;
- let (i, i0) := self.(hashMap_max_load_factor) in
- i1 <- usize_div n1 i;
- if capacity s<= i1
+ let (i, i1) := self.(hashMap_max_load_factor) in
+ i2 <- usize_div n1 i;
+ if capacity s<= i2
then (
- i2 <- usize_mul capacity 2%usize;
- ntable <- hashMap_new_with_capacity T n i2 i i0;
+ i3 <- usize_mul capacity 2%usize;
+ ntable <- hashMap_new_with_capacity T n i3 i i1;
p <- hashMap_move_elements T n ntable self.(hashMap_slots) 0%usize;
- let (ntable0, _) := p in
+ let (ntable1, _) := p in
Return
{|
hashMap_num_entries := self.(hashMap_num_entries);
- hashMap_max_load_factor := (i, i0);
- hashMap_max_load := ntable0.(hashMap_max_load);
- hashMap_slots := ntable0.(hashMap_slots)
+ hashMap_max_load_factor := (i, i1);
+ hashMap_max_load := ntable1.(hashMap_max_load);
+ hashMap_slots := ntable1.(hashMap_slots)
|})
else
Return
{|
hashMap_num_entries := self.(hashMap_num_entries);
- hashMap_max_load_factor := (i, i0);
+ hashMap_max_load_factor := (i, i1);
hashMap_max_load := self.(hashMap_max_load);
hashMap_slots := self.(hashMap_slots)
|}
.
-(** [hashmap::{hashmap::HashMap<T>}::insert]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap::{hashmap::HashMap<T>}::insert]:
Source: 'src/hashmap.rs', lines 129:4-129:48 *)
Definition hashMap_insert
(T : Type) (n : nat) (self : HashMap_t T) (key : usize) (value : T) :
result (HashMap_t T)
:=
- self0 <- hashMap_insert_no_resize T n self key value;
- i <- hashMap_len T self0;
- if i s> self0.(hashMap_max_load)
- then hashMap_try_resize T n self0
- else Return self0
+ hm <- hashMap_insert_no_resize T n self key value;
+ i <- hashMap_len T hm;
+ if i s> hm.(hashMap_max_load) then hashMap_try_resize T n hm else Return hm
.
-(** [hashmap::{hashmap::HashMap<T>}::contains_key_in_list]: loop 0: forward function
+(** [hashmap::{hashmap::HashMap<T>}::contains_key_in_list]: loop 0:
Source: 'src/hashmap.rs', lines 206:4-219:5 *)
Fixpoint hashMap_contains_key_in_list_loop
(T : Type) (n : nat) (key : usize) (ls : List_t T) : result bool :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
- | List_Cons ckey t tl =>
+ | List_Cons ckey _ tl =>
if ckey s= key
then Return true
- else hashMap_contains_key_in_list_loop T n0 key tl
+ else hashMap_contains_key_in_list_loop T n1 key tl
| List_Nil => Return false
end
end
.
-(** [hashmap::{hashmap::HashMap<T>}::contains_key_in_list]: forward function
+(** [hashmap::{hashmap::HashMap<T>}::contains_key_in_list]:
Source: 'src/hashmap.rs', lines 206:4-206:68 *)
Definition hashMap_contains_key_in_list
(T : Type) (n : nat) (key : usize) (ls : List_t T) : result bool :=
hashMap_contains_key_in_list_loop T n key ls
.
-(** [hashmap::{hashmap::HashMap<T>}::contains_key]: forward function
+(** [hashmap::{hashmap::HashMap<T>}::contains_key]:
Source: 'src/hashmap.rs', lines 199:4-199:49 *)
Definition hashMap_contains_key
(T : Type) (n : nat) (self : HashMap_t T) (key : usize) : result bool :=
@@ -369,31 +328,31 @@ Definition hashMap_contains_key
hashMap_contains_key_in_list T n key l
.
-(** [hashmap::{hashmap::HashMap<T>}::get_in_list]: loop 0: forward function
+(** [hashmap::{hashmap::HashMap<T>}::get_in_list]: loop 0:
Source: 'src/hashmap.rs', lines 224:4-237:5 *)
Fixpoint hashMap_get_in_list_loop
(T : Type) (n : nat) (key : usize) (ls : List_t T) : result T :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| List_Cons ckey cvalue tl =>
if ckey s= key
then Return cvalue
- else hashMap_get_in_list_loop T n0 key tl
+ else hashMap_get_in_list_loop T n1 key tl
| List_Nil => Fail_ Failure
end
end
.
-(** [hashmap::{hashmap::HashMap<T>}::get_in_list]: forward function
+(** [hashmap::{hashmap::HashMap<T>}::get_in_list]:
Source: 'src/hashmap.rs', lines 224:4-224:70 *)
Definition hashMap_get_in_list
(T : Type) (n : nat) (key : usize) (ls : List_t T) : result T :=
hashMap_get_in_list_loop T n key ls
.
-(** [hashmap::{hashmap::HashMap<T>}::get]: forward function
+(** [hashmap::{hashmap::HashMap<T>}::get]:
Source: 'src/hashmap.rs', lines 239:4-239:55 *)
Definition hashMap_get
(T : Type) (n : nat) (self : HashMap_t T) (key : usize) : result T :=
@@ -407,264 +366,188 @@ Definition hashMap_get
hashMap_get_in_list T n key l
.
-(** [hashmap::{hashmap::HashMap<T>}::get_mut_in_list]: loop 0: forward function
+(** [hashmap::{hashmap::HashMap<T>}::get_mut_in_list]: loop 0:
Source: 'src/hashmap.rs', lines 245:4-254:5 *)
Fixpoint hashMap_get_mut_in_list_loop
- (T : Type) (n : nat) (ls : List_t T) (key : usize) : result T :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls with
- | List_Cons ckey cvalue tl =>
- if ckey s= key
- then Return cvalue
- else hashMap_get_mut_in_list_loop T n0 tl key
- | List_Nil => Fail_ Failure
- end
- end
-.
-
-(** [hashmap::{hashmap::HashMap<T>}::get_mut_in_list]: forward function
- Source: 'src/hashmap.rs', lines 245:4-245:86 *)
-Definition hashMap_get_mut_in_list
- (T : Type) (n : nat) (ls : List_t T) (key : usize) : result T :=
- hashMap_get_mut_in_list_loop T n ls key
-.
-
-(** [hashmap::{hashmap::HashMap<T>}::get_mut_in_list]: loop 0: backward function 0
- Source: 'src/hashmap.rs', lines 245:4-254:5 *)
-Fixpoint hashMap_get_mut_in_list_loop_back
- (T : Type) (n : nat) (ls : List_t T) (key : usize) (ret : T) :
- result (List_t T)
+ (T : Type) (n : nat) (ls : List_t T) (key : usize) :
+ result (T * (T -> result (List_t T)))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| List_Cons ckey cvalue tl =>
if ckey s= key
- then Return (List_Cons ckey ret tl)
+ then
+ let back_'a := fun (ret : T) => Return (List_Cons ckey ret tl) in
+ Return (cvalue, back_'a)
else (
- tl0 <- hashMap_get_mut_in_list_loop_back T n0 tl key ret;
- Return (List_Cons ckey cvalue tl0))
+ p <- hashMap_get_mut_in_list_loop T n1 tl key;
+ let (t, back_'a) := p in
+ let back_'a1 :=
+ fun (ret : T) =>
+ tl1 <- back_'a ret; Return (List_Cons ckey cvalue tl1) in
+ Return (t, back_'a1))
| List_Nil => Fail_ Failure
end
end
.
-(** [hashmap::{hashmap::HashMap<T>}::get_mut_in_list]: backward function 0
+(** [hashmap::{hashmap::HashMap<T>}::get_mut_in_list]:
Source: 'src/hashmap.rs', lines 245:4-245:86 *)
-Definition hashMap_get_mut_in_list_back
- (T : Type) (n : nat) (ls : List_t T) (key : usize) (ret : T) :
- result (List_t T)
+Definition hashMap_get_mut_in_list
+ (T : Type) (n : nat) (ls : List_t T) (key : usize) :
+ result (T * (T -> result (List_t T)))
:=
- hashMap_get_mut_in_list_loop_back T n ls key ret
+ p <- hashMap_get_mut_in_list_loop T n ls key;
+ let (t, back_'a) := p in
+ let back_'a1 := fun (ret : T) => back_'a ret in
+ Return (t, back_'a1)
.
-(** [hashmap::{hashmap::HashMap<T>}::get_mut]: forward function
+(** [hashmap::{hashmap::HashMap<T>}::get_mut]:
Source: 'src/hashmap.rs', lines 257:4-257:67 *)
Definition hashMap_get_mut
- (T : Type) (n : nat) (self : HashMap_t T) (key : usize) : result T :=
- hash <- hash_key key;
- let i := alloc_vec_Vec_len (List_t T) self.(hashMap_slots) in
- hash_mod <- usize_rem hash i;
- l <-
- alloc_vec_Vec_index_mut (List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (List_t T))
- self.(hashMap_slots) hash_mod;
- hashMap_get_mut_in_list T n l key
-.
-
-(** [hashmap::{hashmap::HashMap<T>}::get_mut]: backward function 0
- Source: 'src/hashmap.rs', lines 257:4-257:67 *)
-Definition hashMap_get_mut_back
- (T : Type) (n : nat) (self : HashMap_t T) (key : usize) (ret : T) :
- result (HashMap_t T)
+ (T : Type) (n : nat) (self : HashMap_t T) (key : usize) :
+ result (T * (T -> result (HashMap_t T)))
:=
hash <- hash_key key;
let i := alloc_vec_Vec_len (List_t T) self.(hashMap_slots) in
hash_mod <- usize_rem hash i;
- l <-
+ p <-
alloc_vec_Vec_index_mut (List_t T) usize
(core_slice_index_SliceIndexUsizeSliceTInst (List_t T))
self.(hashMap_slots) hash_mod;
- l0 <- hashMap_get_mut_in_list_back T n l key ret;
- v <-
- alloc_vec_Vec_index_mut_back (List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (List_t T))
- self.(hashMap_slots) hash_mod l0;
- Return
- {|
- hashMap_num_entries := self.(hashMap_num_entries);
- hashMap_max_load_factor := self.(hashMap_max_load_factor);
- hashMap_max_load := self.(hashMap_max_load);
- hashMap_slots := v
- |}
-.
-
-(** [hashmap::{hashmap::HashMap<T>}::remove_from_list]: loop 0: forward function
+ let (l, index_mut_back) := p in
+ p1 <- hashMap_get_mut_in_list T n l key;
+ let (t, get_mut_in_list_back) := p1 in
+ let back_'a :=
+ fun (ret : T) =>
+ l1 <- get_mut_in_list_back ret;
+ v <- index_mut_back l1;
+ Return
+ {|
+ hashMap_num_entries := self.(hashMap_num_entries);
+ hashMap_max_load_factor := self.(hashMap_max_load_factor);
+ hashMap_max_load := self.(hashMap_max_load);
+ hashMap_slots := v
+ |} in
+ Return (t, back_'a)
+.
+
+(** [hashmap::{hashmap::HashMap<T>}::remove_from_list]: loop 0:
Source: 'src/hashmap.rs', lines 265:4-291:5 *)
Fixpoint hashMap_remove_from_list_loop
- (T : Type) (n : nat) (key : usize) (ls : List_t T) : result (option T) :=
+ (T : Type) (n : nat) (key : usize) (ls : List_t T) :
+ result ((option T) * (List_t T))
+ :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| List_Cons ckey t tl =>
if ckey s= key
then
- let mv_ls := core_mem_replace (List_t T) (List_Cons ckey t tl) List_Nil
- in
+ let (mv_ls, _) :=
+ core_mem_replace (List_t T) (List_Cons ckey t tl) List_Nil in
match mv_ls with
- | List_Cons i cvalue tl0 => Return (Some cvalue)
+ | List_Cons _ cvalue tl1 => Return (Some cvalue, tl1)
| List_Nil => Fail_ Failure
end
- else hashMap_remove_from_list_loop T n0 key tl
- | List_Nil => Return None
+ else (
+ p <- hashMap_remove_from_list_loop T n1 key tl;
+ let (o, back) := p in
+ Return (o, List_Cons ckey t back))
+ | List_Nil => Return (None, List_Nil)
end
end
.
-(** [hashmap::{hashmap::HashMap<T>}::remove_from_list]: forward function
+(** [hashmap::{hashmap::HashMap<T>}::remove_from_list]:
Source: 'src/hashmap.rs', lines 265:4-265:69 *)
Definition hashMap_remove_from_list
- (T : Type) (n : nat) (key : usize) (ls : List_t T) : result (option T) :=
+ (T : Type) (n : nat) (key : usize) (ls : List_t T) :
+ result ((option T) * (List_t T))
+ :=
hashMap_remove_from_list_loop T n key ls
.
-(** [hashmap::{hashmap::HashMap<T>}::remove_from_list]: loop 0: backward function 1
- Source: 'src/hashmap.rs', lines 265:4-291:5 *)
-Fixpoint hashMap_remove_from_list_loop_back
- (T : Type) (n : nat) (key : usize) (ls : List_t T) : result (List_t T) :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls with
- | List_Cons ckey t tl =>
- if ckey s= key
- then
- let mv_ls := core_mem_replace (List_t T) (List_Cons ckey t tl) List_Nil
- in
- match mv_ls with
- | List_Cons i cvalue tl0 => Return tl0
- | List_Nil => Fail_ Failure
- end
- else (
- tl0 <- hashMap_remove_from_list_loop_back T n0 key tl;
- Return (List_Cons ckey t tl0))
- | List_Nil => Return List_Nil
- end
- end
-.
-
-(** [hashmap::{hashmap::HashMap<T>}::remove_from_list]: backward function 1
- Source: 'src/hashmap.rs', lines 265:4-265:69 *)
-Definition hashMap_remove_from_list_back
- (T : Type) (n : nat) (key : usize) (ls : List_t T) : result (List_t T) :=
- hashMap_remove_from_list_loop_back T n key ls
-.
-
-(** [hashmap::{hashmap::HashMap<T>}::remove]: forward function
+(** [hashmap::{hashmap::HashMap<T>}::remove]:
Source: 'src/hashmap.rs', lines 294:4-294:52 *)
Definition hashMap_remove
(T : Type) (n : nat) (self : HashMap_t T) (key : usize) :
- result (option T)
- :=
- hash <- hash_key key;
- let i := alloc_vec_Vec_len (List_t T) self.(hashMap_slots) in
- hash_mod <- usize_rem hash i;
- l <-
- alloc_vec_Vec_index_mut (List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (List_t T))
- self.(hashMap_slots) hash_mod;
- x <- hashMap_remove_from_list T n key l;
- match x with
- | None => Return None
- | Some x0 =>
- _ <- usize_sub self.(hashMap_num_entries) 1%usize; Return (Some x0)
- end
-.
-
-(** [hashmap::{hashmap::HashMap<T>}::remove]: backward function 0
- Source: 'src/hashmap.rs', lines 294:4-294:52 *)
-Definition hashMap_remove_back
- (T : Type) (n : nat) (self : HashMap_t T) (key : usize) :
- result (HashMap_t T)
+ result ((option T) * (HashMap_t T))
:=
hash <- hash_key key;
let i := alloc_vec_Vec_len (List_t T) self.(hashMap_slots) in
hash_mod <- usize_rem hash i;
- l <-
+ p <-
alloc_vec_Vec_index_mut (List_t T) usize
(core_slice_index_SliceIndexUsizeSliceTInst (List_t T))
self.(hashMap_slots) hash_mod;
- x <- hashMap_remove_from_list T n key l;
+ let (l, index_mut_back) := p in
+ p1 <- hashMap_remove_from_list T n key l;
+ let (x, l1) := p1 in
match x with
| None =>
- l0 <- hashMap_remove_from_list_back T n key l;
- v <-
- alloc_vec_Vec_index_mut_back (List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (List_t T))
- self.(hashMap_slots) hash_mod l0;
- Return
+ v <- index_mut_back l1;
+ Return (None,
{|
hashMap_num_entries := self.(hashMap_num_entries);
hashMap_max_load_factor := self.(hashMap_max_load_factor);
hashMap_max_load := self.(hashMap_max_load);
hashMap_slots := v
- |}
- | Some x0 =>
- i0 <- usize_sub self.(hashMap_num_entries) 1%usize;
- l0 <- hashMap_remove_from_list_back T n key l;
- v <-
- alloc_vec_Vec_index_mut_back (List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (List_t T))
- self.(hashMap_slots) hash_mod l0;
- Return
+ |})
+ | Some x1 =>
+ i1 <- usize_sub self.(hashMap_num_entries) 1%usize;
+ v <- index_mut_back l1;
+ Return (Some x1,
{|
- hashMap_num_entries := i0;
+ hashMap_num_entries := i1;
hashMap_max_load_factor := self.(hashMap_max_load_factor);
hashMap_max_load := self.(hashMap_max_load);
hashMap_slots := v
- |}
+ |})
end
.
-(** [hashmap::test1]: forward function
+(** [hashmap::test1]:
Source: 'src/hashmap.rs', lines 315:0-315:10 *)
Definition test1 (n : nat) : result unit :=
hm <- hashMap_new u64 n;
- hm0 <- hashMap_insert u64 n hm 0%usize 42%u64;
- hm1 <- hashMap_insert u64 n hm0 128%usize 18%u64;
- hm2 <- hashMap_insert u64 n hm1 1024%usize 138%u64;
- hm3 <- hashMap_insert u64 n hm2 1056%usize 256%u64;
- i <- hashMap_get u64 n hm3 128%usize;
+ hm1 <- hashMap_insert u64 n hm 0%usize 42%u64;
+ hm2 <- hashMap_insert u64 n hm1 128%usize 18%u64;
+ hm3 <- hashMap_insert u64 n hm2 1024%usize 138%u64;
+ hm4 <- hashMap_insert u64 n hm3 1056%usize 256%u64;
+ i <- hashMap_get u64 n hm4 128%usize;
if negb (i s= 18%u64)
then Fail_ Failure
else (
- hm4 <- hashMap_get_mut_back u64 n hm3 1024%usize 56%u64;
- i0 <- hashMap_get u64 n hm4 1024%usize;
- if negb (i0 s= 56%u64)
+ p <- hashMap_get_mut u64 n hm4 1024%usize;
+ let (_, get_mut_back) := p in
+ hm5 <- get_mut_back 56%u64;
+ i1 <- hashMap_get u64 n hm5 1024%usize;
+ if negb (i1 s= 56%u64)
then Fail_ Failure
else (
- x <- hashMap_remove u64 n hm4 1024%usize;
+ p1 <- hashMap_remove u64 n hm5 1024%usize;
+ let (x, hm6) := p1 in
match x with
| None => Fail_ Failure
- | Some x0 =>
- if negb (x0 s= 56%u64)
+ | Some x1 =>
+ if negb (x1 s= 56%u64)
then Fail_ Failure
else (
- hm5 <- hashMap_remove_back u64 n hm4 1024%usize;
- i1 <- hashMap_get u64 n hm5 0%usize;
- if negb (i1 s= 42%u64)
+ i2 <- hashMap_get u64 n hm6 0%usize;
+ if negb (i2 s= 42%u64)
then Fail_ Failure
else (
- i2 <- hashMap_get u64 n hm5 128%usize;
- if negb (i2 s= 18%u64)
+ i3 <- hashMap_get u64 n hm6 128%usize;
+ if negb (i3 s= 18%u64)
then Fail_ Failure
else (
- i3 <- hashMap_get u64 n hm5 1056%usize;
- if negb (i3 s= 256%u64) then Fail_ Failure else Return tt)))
+ i4 <- hashMap_get u64 n hm6 1056%usize;
+ if negb (i4 s= 256%u64) then Fail_ Failure else Return tt)))
end))
.
diff --git a/tests/coq/hashmap/Primitives.v b/tests/coq/hashmap/Primitives.v
index 84280b96..990e27e4 100644
--- a/tests/coq/hashmap/Primitives.v
+++ b/tests/coq/hashmap/Primitives.v
@@ -67,8 +67,7 @@ Definition string := Coq.Strings.String.string.
Definition char := Coq.Strings.Ascii.ascii.
Definition char_of_byte := Coq.Strings.Ascii.ascii_of_byte.
-Definition core_mem_replace (a : Type) (x : a) (y : a) : a := x .
-Definition core_mem_replace_back (a : Type) (x : a) (y : a) : a := y .
+Definition core_mem_replace (a : Type) (x : a) (y : a) : a * a := (x, x) .
Record mut_raw_ptr (T : Type) := { mut_raw_ptr_v : T }.
Record const_raw_ptr (T : Type) := { const_raw_ptr_v : T }.
@@ -504,13 +503,15 @@ Arguments core_ops_index_Index_index {_ _}.
(* Trait declaration: [core::ops::index::IndexMut] *)
Record core_ops_index_IndexMut (Self Idx : Type) := mk_core_ops_index_IndexMut {
core_ops_index_IndexMut_indexInst : core_ops_index_Index Self Idx;
- core_ops_index_IndexMut_index_mut : Self -> Idx -> result core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output);
- core_ops_index_IndexMut_index_mut_back : Self -> Idx -> core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) -> result Self;
+ core_ops_index_IndexMut_index_mut :
+ Self ->
+ Idx ->
+ result (core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) *
+ (core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) -> result Self));
}.
Arguments mk_core_ops_index_IndexMut {_ _}.
Arguments core_ops_index_IndexMut_indexInst {_ _}.
Arguments core_ops_index_IndexMut_index_mut {_ _}.
-Arguments core_ops_index_IndexMut_index_mut_back {_ _}.
(* Trait declaration [core::ops::deref::Deref] *)
Record core_ops_deref_Deref (Self : Type) := mk_core_ops_deref_Deref {
@@ -524,13 +525,14 @@ Arguments core_ops_deref_Deref_deref {_}.
(* Trait declaration [core::ops::deref::DerefMut] *)
Record core_ops_deref_DerefMut (Self : Type) := mk_core_ops_deref_DerefMut {
core_ops_deref_DerefMut_derefInst : core_ops_deref_Deref Self;
- core_ops_deref_DerefMut_deref_mut : Self -> result core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target);
- core_ops_deref_DerefMut_deref_mut_back : Self -> core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) -> result Self;
+ core_ops_deref_DerefMut_deref_mut :
+ Self ->
+ result (core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) *
+ (core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) -> result Self));
}.
Arguments mk_core_ops_deref_DerefMut {_}.
Arguments core_ops_deref_DerefMut_derefInst {_}.
Arguments core_ops_deref_DerefMut_deref_mut {_}.
-Arguments core_ops_deref_DerefMut_deref_mut_back {_}.
Record core_ops_range_Range (T : Type) := mk_core_ops_range_Range {
core_ops_range_Range_start : T;
@@ -543,8 +545,8 @@ Arguments core_ops_range_Range_end_ {_}.
(*** [alloc] *)
Definition alloc_boxed_Box_deref (T : Type) (x : T) : result T := Return x.
-Definition alloc_boxed_Box_deref_mut (T : Type) (x : T) : result T := Return x.
-Definition alloc_boxed_Box_deref_mut_back (T : Type) (_ : T) (x : T) : result T := Return x.
+Definition alloc_boxed_Box_deref_mut (T : Type) (x : T) : result (T * (T -> result T)) :=
+ Return (x, fun x => Return x).
(* Trait instance *)
Definition alloc_boxed_Box_coreopsDerefInst (Self : Type) : core_ops_deref_Deref Self := {|
@@ -556,7 +558,6 @@ Definition alloc_boxed_Box_coreopsDerefInst (Self : Type) : core_ops_deref_Deref
Definition alloc_boxed_Box_coreopsDerefMutInst (Self : Type) : core_ops_deref_DerefMut Self := {|
core_ops_deref_DerefMut_derefInst := alloc_boxed_Box_coreopsDerefInst Self;
core_ops_deref_DerefMut_deref_mut := alloc_boxed_Box_deref_mut Self;
- core_ops_deref_DerefMut_deref_mut_back := alloc_boxed_Box_deref_mut_back Self;
|}.
@@ -584,6 +585,13 @@ Axiom array_repeat : forall (T : Type) (n : usize) (x : T), array T n.
Axiom array_index_usize : forall (T : Type) (n : usize) (x : array T n) (i : usize), result T.
Axiom array_update_usize : forall (T : Type) (n : usize) (x : array T n) (i : usize) (nx : T), result (array T n).
+Definition array_index_mut_usize (T : Type) (n : usize) (a : array T n) (i : usize) :
+ result (T * (T -> result (array T n))) :=
+ match array_index_usize T n a i with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, array_update_usize T n a i)
+ end.
+
(*** Slice *)
Definition slice T := { l: list T | Z.of_nat (length l) <= usize_max}.
@@ -591,11 +599,25 @@ Axiom slice_len : forall (T : Type) (s : slice T), usize.
Axiom slice_index_usize : forall (T : Type) (x : slice T) (i : usize), result T.
Axiom slice_update_usize : forall (T : Type) (x : slice T) (i : usize) (nx : T), result (slice T).
+Definition slice_index_mut_usize (T : Type) (s : slice T) (i : usize) :
+ result (T * (T -> result (slice T))) :=
+ match slice_index_usize T s i with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, slice_update_usize T s i)
+ end.
+
(*** Subslices *)
Axiom array_to_slice : forall (T : Type) (n : usize) (x : array T n), result (slice T).
Axiom array_from_slice : forall (T : Type) (n : usize) (x : array T n) (s : slice T), result (array T n).
+Definition array_to_slice_mut (T : Type) (n : usize) (a : array T n) :
+ result (slice T * (slice T -> result (array T n))) :=
+ match array_to_slice T n a with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, array_from_slice T n a)
+ end.
+
Axiom array_subslice: forall (T : Type) (n : usize) (x : array T n) (r : core_ops_range_Range usize), result (slice T).
Axiom array_update_subslice: forall (T : Type) (n : usize) (x : array T n) (r : core_ops_range_Range usize) (ns : slice T), result (array T n).
@@ -639,16 +661,9 @@ Definition alloc_vec_Vec_bind {A B} (v: alloc_vec_Vec A) (f: list A -> result (l
| right _ => Fail_ Failure
end.
-(* The **forward** function shouldn't be used *)
-Definition alloc_vec_Vec_push_fwd (T: Type) (v: alloc_vec_Vec T) (x: T) : unit := tt.
-
Definition alloc_vec_Vec_push (T: Type) (v: alloc_vec_Vec T) (x: T) : result (alloc_vec_Vec T) :=
alloc_vec_Vec_bind v (fun l => Return (l ++ [x])).
-(* The **forward** function shouldn't be used *)
-Definition alloc_vec_Vec_insert_fwd (T: Type) (v: alloc_vec_Vec T) (i: usize) (x: T) : result unit :=
- if to_Z i <? alloc_vec_Vec_length v then Return tt else Fail_ Failure.
-
Definition alloc_vec_Vec_insert (T: Type) (v: alloc_vec_Vec T) (i: usize) (x: T) : result (alloc_vec_Vec T) :=
alloc_vec_Vec_bind v (fun l =>
if to_Z i <? Z.of_nat (length l)
@@ -661,6 +676,14 @@ Axiom alloc_vec_Vec_index_usize : forall {T : Type} (v : alloc_vec_Vec T) (i : u
(* Helper *)
Axiom alloc_vec_Vec_update_usize : forall {T : Type} (v : alloc_vec_Vec T) (i : usize) (x : T), result (alloc_vec_Vec T).
+Definition alloc_vec_Vec_index_mut_usize {T : Type} (v: alloc_vec_Vec T) (i: usize) :
+ result (T * (T -> result (alloc_vec_Vec T))) :=
+ match alloc_vec_Vec_index_usize v i with
+ | Return x =>
+ Return (x, alloc_vec_Vec_update_usize v i)
+ | Fail_ e => Fail_ e
+ end.
+
(* Trait declaration: [core::slice::index::private_slice_index::Sealed] *)
Definition core_slice_index_private_slice_index_Sealed (self : Type) := unit.
@@ -669,25 +692,23 @@ Record core_slice_index_SliceIndex (Self T : Type) := mk_core_slice_index_SliceI
core_slice_index_SliceIndex_sealedInst : core_slice_index_private_slice_index_Sealed Self;
core_slice_index_SliceIndex_Output : Type;
core_slice_index_SliceIndex_get : Self -> T -> result (option core_slice_index_SliceIndex_Output);
- core_slice_index_SliceIndex_get_mut : Self -> T -> result (option core_slice_index_SliceIndex_Output);
- core_slice_index_SliceIndex_get_mut_back : Self -> T -> option core_slice_index_SliceIndex_Output -> result T;
+ core_slice_index_SliceIndex_get_mut :
+ Self -> T -> result (option core_slice_index_SliceIndex_Output * (option core_slice_index_SliceIndex_Output -> result T));
core_slice_index_SliceIndex_get_unchecked : Self -> const_raw_ptr T -> result (const_raw_ptr core_slice_index_SliceIndex_Output);
core_slice_index_SliceIndex_get_unchecked_mut : Self -> mut_raw_ptr T -> result (mut_raw_ptr core_slice_index_SliceIndex_Output);
core_slice_index_SliceIndex_index : Self -> T -> result core_slice_index_SliceIndex_Output;
- core_slice_index_SliceIndex_index_mut : Self -> T -> result core_slice_index_SliceIndex_Output;
- core_slice_index_SliceIndex_index_mut_back : Self -> T -> core_slice_index_SliceIndex_Output -> result T;
+ core_slice_index_SliceIndex_index_mut :
+ Self -> T -> result (core_slice_index_SliceIndex_Output * (core_slice_index_SliceIndex_Output -> result T));
}.
Arguments mk_core_slice_index_SliceIndex {_ _}.
Arguments core_slice_index_SliceIndex_sealedInst {_ _}.
Arguments core_slice_index_SliceIndex_Output {_ _}.
Arguments core_slice_index_SliceIndex_get {_ _}.
Arguments core_slice_index_SliceIndex_get_mut {_ _}.
-Arguments core_slice_index_SliceIndex_get_mut_back {_ _}.
Arguments core_slice_index_SliceIndex_get_unchecked {_ _}.
Arguments core_slice_index_SliceIndex_get_unchecked_mut {_ _}.
Arguments core_slice_index_SliceIndex_index {_ _}.
Arguments core_slice_index_SliceIndex_index_mut {_ _}.
-Arguments core_slice_index_SliceIndex_index_mut_back {_ _}.
(* [core::slice::index::[T]::index]: forward function *)
Definition core_slice_index_Slice_index
@@ -704,11 +725,9 @@ Axiom core_slice_index_RangeUsize_get : forall (T : Type) (i : core_ops_range_Ra
(* [core::slice::index::Range::get_mut]: forward function *)
Axiom core_slice_index_RangeUsize_get_mut :
- forall (T : Type), core_ops_range_Range usize -> slice T -> result (option (slice T)).
-
-(* [core::slice::index::Range::get_mut]: backward function 0 *)
-Axiom core_slice_index_RangeUsize_get_mut_back :
- forall (T : Type), core_ops_range_Range usize -> slice T -> option (slice T) -> result (slice T).
+ forall (T : Type),
+ core_ops_range_Range usize -> slice T ->
+ result (option (slice T) * (option (slice T) -> result (slice T))).
(* [core::slice::index::Range::get_unchecked]: forward function *)
Definition core_slice_index_RangeUsize_get_unchecked
@@ -732,21 +751,14 @@ Axiom core_slice_index_RangeUsize_index :
(* [core::slice::index::Range::index_mut]: forward function *)
Axiom core_slice_index_RangeUsize_index_mut :
- forall (T : Type), core_ops_range_Range usize -> slice T -> result (slice T).
-
-(* [core::slice::index::Range::index_mut]: backward function 0 *)
-Axiom core_slice_index_RangeUsize_index_mut_back :
- forall (T : Type), core_ops_range_Range usize -> slice T -> slice T -> result (slice T).
+ forall (T : Type), core_ops_range_Range usize -> slice T -> result (slice T * (slice T -> result (slice T))).
(* [core::slice::index::[T]::index_mut]: forward function *)
Axiom core_slice_index_Slice_index_mut :
forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T)),
- slice T -> Idx -> result inst.(core_slice_index_SliceIndex_Output).
-
-(* [core::slice::index::[T]::index_mut]: backward function 0 *)
-Axiom core_slice_index_Slice_index_mut_back :
- forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T)),
- slice T -> Idx -> inst.(core_slice_index_SliceIndex_Output) -> result (slice T).
+ slice T -> Idx ->
+ result (inst.(core_slice_index_SliceIndex_Output) *
+ (inst.(core_slice_index_SliceIndex_Output) -> result (slice T))).
(* [core::array::[T; N]::index]: forward function *)
Axiom core_array_Array_index :
@@ -756,12 +768,9 @@ Axiom core_array_Array_index :
(* [core::array::[T; N]::index_mut]: forward function *)
Axiom core_array_Array_index_mut :
forall (T Idx : Type) (N : usize) (inst : core_ops_index_IndexMut (slice T) Idx)
- (a : array T N) (i : Idx), result inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output).
-
-(* [core::array::[T; N]::index_mut]: backward function 0 *)
-Axiom core_array_Array_index_mut_back :
- forall (T Idx : Type) (N : usize) (inst : core_ops_index_IndexMut (slice T) Idx)
- (a : array T N) (i : Idx) (x : inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output)), result (array T N).
+ (a : array T N) (i : Idx),
+ result (inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output) *
+ (inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output) -> result (array T N))).
(* Trait implementation: [core::slice::index::private_slice_index::Range] *)
Definition core_slice_index_private_slice_index_SealedRangeUsizeInst
@@ -774,12 +783,10 @@ Definition core_slice_index_SliceIndexRangeUsizeSliceTInst (T : Type) :
core_slice_index_SliceIndex_Output := slice T;
core_slice_index_SliceIndex_get := core_slice_index_RangeUsize_get T;
core_slice_index_SliceIndex_get_mut := core_slice_index_RangeUsize_get_mut T;
- core_slice_index_SliceIndex_get_mut_back := core_slice_index_RangeUsize_get_mut_back T;
core_slice_index_SliceIndex_get_unchecked := core_slice_index_RangeUsize_get_unchecked T;
core_slice_index_SliceIndex_get_unchecked_mut := core_slice_index_RangeUsize_get_unchecked_mut T;
core_slice_index_SliceIndex_index := core_slice_index_RangeUsize_index T;
core_slice_index_SliceIndex_index_mut := core_slice_index_RangeUsize_index_mut T;
- core_slice_index_SliceIndex_index_mut_back := core_slice_index_RangeUsize_index_mut_back T;
|}.
(* Trait implementation: [core::slice::index::[T]] *)
@@ -796,7 +803,6 @@ Definition core_ops_index_IndexMutSliceTIInst (T Idx : Type)
core_ops_index_IndexMut (slice T) Idx := {|
core_ops_index_IndexMut_indexInst := core_ops_index_IndexSliceTIInst T Idx inst;
core_ops_index_IndexMut_index_mut := core_slice_index_Slice_index_mut T Idx inst;
- core_ops_index_IndexMut_index_mut_back := core_slice_index_Slice_index_mut_back T Idx inst;
|}.
(* Trait implementation: [core::array::[T; N]] *)
@@ -813,18 +819,14 @@ Definition core_ops_index_IndexMutArrayInst (T Idx : Type) (N : usize)
core_ops_index_IndexMut (array T N) Idx := {|
core_ops_index_IndexMut_indexInst := core_ops_index_IndexArrayInst T Idx N inst.(core_ops_index_IndexMut_indexInst);
core_ops_index_IndexMut_index_mut := core_array_Array_index_mut T Idx N inst;
- core_ops_index_IndexMut_index_mut_back := core_array_Array_index_mut_back T Idx N inst;
|}.
(* [core::slice::index::usize::get]: forward function *)
Axiom core_slice_index_usize_get : forall (T : Type), usize -> slice T -> result (option T).
(* [core::slice::index::usize::get_mut]: forward function *)
-Axiom core_slice_index_usize_get_mut : forall (T : Type), usize -> slice T -> result (option T).
-
-(* [core::slice::index::usize::get_mut]: backward function 0 *)
-Axiom core_slice_index_usize_get_mut_back :
- forall (T : Type), usize -> slice T -> option T -> result (slice T).
+Axiom core_slice_index_usize_get_mut :
+ forall (T : Type), usize -> slice T -> result (option T * (option T -> result (slice T))).
(* [core::slice::index::usize::get_unchecked]: forward function *)
Axiom core_slice_index_usize_get_unchecked :
@@ -838,11 +840,8 @@ Axiom core_slice_index_usize_get_unchecked_mut :
Axiom core_slice_index_usize_index : forall (T : Type), usize -> slice T -> result T.
(* [core::slice::index::usize::index_mut]: forward function *)
-Axiom core_slice_index_usize_index_mut : forall (T : Type), usize -> slice T -> result T.
-
-(* [core::slice::index::usize::index_mut]: backward function 0 *)
-Axiom core_slice_index_usize_index_mut_back :
- forall (T : Type), usize -> slice T -> T -> result (slice T).
+Axiom core_slice_index_usize_index_mut :
+ forall (T : Type), usize -> slice T -> result (T * (T -> result (slice T))).
(* Trait implementation: [core::slice::index::private_slice_index::usize] *)
Definition core_slice_index_private_slice_index_SealedUsizeInst
@@ -855,12 +854,10 @@ Definition core_slice_index_SliceIndexUsizeSliceTInst (T : Type) :
core_slice_index_SliceIndex_Output := T;
core_slice_index_SliceIndex_get := core_slice_index_usize_get T;
core_slice_index_SliceIndex_get_mut := core_slice_index_usize_get_mut T;
- core_slice_index_SliceIndex_get_mut_back := core_slice_index_usize_get_mut_back T;
core_slice_index_SliceIndex_get_unchecked := core_slice_index_usize_get_unchecked T;
core_slice_index_SliceIndex_get_unchecked_mut := core_slice_index_usize_get_unchecked_mut T;
core_slice_index_SliceIndex_index := core_slice_index_usize_index T;
core_slice_index_SliceIndex_index_mut := core_slice_index_usize_index_mut T;
- core_slice_index_SliceIndex_index_mut_back := core_slice_index_usize_index_mut_back T;
|}.
(* [alloc::vec::Vec::index]: forward function *)
@@ -869,12 +866,9 @@ Axiom alloc_vec_Vec_index : forall (T Idx : Type) (inst : core_slice_index_Slice
(* [alloc::vec::Vec::index_mut]: forward function *)
Axiom alloc_vec_Vec_index_mut : forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T))
- (Self : alloc_vec_Vec T) (i : Idx), result inst.(core_slice_index_SliceIndex_Output).
-
-(* [alloc::vec::Vec::index_mut]: backward function 0 *)
-Axiom alloc_vec_Vec_index_mut_back :
- forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T))
- (Self : alloc_vec_Vec T) (i : Idx) (x : inst.(core_slice_index_SliceIndex_Output)), result (alloc_vec_Vec T).
+ (Self : alloc_vec_Vec T) (i : Idx),
+ result (inst.(core_slice_index_SliceIndex_Output) *
+ (inst.(core_slice_index_SliceIndex_Output) -> result (alloc_vec_Vec T))).
(* Trait implementation: [alloc::vec::Vec] *)
Definition alloc_vec_Vec_coreopsindexIndexInst (T Idx : Type)
@@ -890,7 +884,6 @@ Definition alloc_vec_Vec_coreopsindexIndexMutInst (T Idx : Type)
core_ops_index_IndexMut (alloc_vec_Vec T) Idx := {|
core_ops_index_IndexMut_indexInst := alloc_vec_Vec_coreopsindexIndexInst T Idx inst;
core_ops_index_IndexMut_index_mut := alloc_vec_Vec_index_mut T Idx inst;
- core_ops_index_IndexMut_index_mut_back := alloc_vec_Vec_index_mut_back T Idx inst;
|}.
(*** Theorems *)
@@ -901,10 +894,6 @@ Axiom alloc_vec_Vec_index_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usiz
Axiom alloc_vec_Vec_index_mut_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usize) (x : a),
alloc_vec_Vec_index_mut a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i =
- alloc_vec_Vec_index_usize v i.
-
-Axiom alloc_vec_Vec_index_mut_back_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usize) (x : a),
- alloc_vec_Vec_index_mut_back a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i x =
- alloc_vec_Vec_update_usize v i x.
+ alloc_vec_Vec_index_mut_usize v i.
End Primitives.
diff --git a/tests/coq/hashmap_on_disk/HashmapMain_Funs.v b/tests/coq/hashmap_on_disk/HashmapMain_Funs.v
index faba0afe..b74fa61a 100644
--- a/tests/coq/hashmap_on_disk/HashmapMain_Funs.v
+++ b/tests/coq/hashmap_on_disk/HashmapMain_Funs.v
@@ -12,41 +12,41 @@ Require Import HashmapMain_FunsExternal.
Include HashmapMain_FunsExternal.
Module HashmapMain_Funs.
-(** [hashmap_main::hashmap::hash_key]: forward function
+(** [hashmap_main::hashmap::hash_key]:
Source: 'src/hashmap.rs', lines 27:0-27:32 *)
Definition hashmap_hash_key (k : usize) : result usize :=
Return k.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::allocate_slots]: loop 0: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::allocate_slots]: loop 0:
Source: 'src/hashmap.rs', lines 50:4-56:5 *)
Fixpoint hashmap_HashMap_allocate_slots_loop
- (T : Type) (n : nat) (slots : alloc_vec_Vec (hashmap_List_t T)) (n0 : usize)
+ (T : Type) (n : nat) (slots : alloc_vec_Vec (hashmap_List_t T)) (n1 : usize)
:
result (alloc_vec_Vec (hashmap_List_t T))
:=
match n with
| O => Fail_ OutOfFuel
- | S n1 =>
- if n0 s> 0%usize
+ | S n2 =>
+ if n1 s> 0%usize
then (
- slots0 <- alloc_vec_Vec_push (hashmap_List_t T) slots Hashmap_List_Nil;
- n2 <- usize_sub n0 1%usize;
- hashmap_HashMap_allocate_slots_loop T n1 slots0 n2)
+ v <- alloc_vec_Vec_push (hashmap_List_t T) slots Hashmap_List_Nil;
+ n3 <- usize_sub n1 1%usize;
+ hashmap_HashMap_allocate_slots_loop T n2 v n3)
else Return slots
end
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::allocate_slots]: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::allocate_slots]:
Source: 'src/hashmap.rs', lines 50:4-50:76 *)
Definition hashmap_HashMap_allocate_slots
- (T : Type) (n : nat) (slots : alloc_vec_Vec (hashmap_List_t T)) (n0 : usize)
+ (T : Type) (n : nat) (slots : alloc_vec_Vec (hashmap_List_t T)) (n1 : usize)
:
result (alloc_vec_Vec (hashmap_List_t T))
:=
- hashmap_HashMap_allocate_slots_loop T n slots n0
+ hashmap_HashMap_allocate_slots_loop T n slots n1
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::new_with_capacity]: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::new_with_capacity]:
Source: 'src/hashmap.rs', lines 59:4-63:13 *)
Definition hashmap_HashMap_new_with_capacity
(T : Type) (n : nat) (capacity : usize) (max_load_dividend : usize)
@@ -56,25 +56,24 @@ Definition hashmap_HashMap_new_with_capacity
let v := alloc_vec_Vec_new (hashmap_List_t T) in
slots <- hashmap_HashMap_allocate_slots T n v capacity;
i <- usize_mul capacity max_load_dividend;
- i0 <- usize_div i max_load_divisor;
+ i1 <- usize_div i max_load_divisor;
Return
{|
hashmap_HashMap_num_entries := 0%usize;
hashmap_HashMap_max_load_factor := (max_load_dividend, max_load_divisor);
- hashmap_HashMap_max_load := i0;
+ hashmap_HashMap_max_load := i1;
hashmap_HashMap_slots := slots
|}
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::new]: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::new]:
Source: 'src/hashmap.rs', lines 75:4-75:24 *)
Definition hashmap_HashMap_new
(T : Type) (n : nat) : result (hashmap_HashMap_t T) :=
hashmap_HashMap_new_with_capacity T n 32%usize 4%usize 5%usize
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::clear]: loop 0: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::clear]: loop 0:
Source: 'src/hashmap.rs', lines 80:4-88:5 *)
Fixpoint hashmap_HashMap_clear_loop
(T : Type) (n : nat) (slots : alloc_vec_Vec (hashmap_List_t T)) (i : usize) :
@@ -82,105 +81,78 @@ Fixpoint hashmap_HashMap_clear_loop
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
- let i0 := alloc_vec_Vec_len (hashmap_List_t T) slots in
- if i s< i0
+ | S n1 =>
+ let i1 := alloc_vec_Vec_len (hashmap_List_t T) slots in
+ if i s< i1
then (
- i1 <- usize_add i 1%usize;
- slots0 <-
- alloc_vec_Vec_index_mut_back (hashmap_List_t T) usize
+ p <-
+ alloc_vec_Vec_index_mut (hashmap_List_t T) usize
(core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t T)) slots
- i Hashmap_List_Nil;
- hashmap_HashMap_clear_loop T n0 slots0 i1)
+ i;
+ let (_, index_mut_back) := p in
+ i2 <- usize_add i 1%usize;
+ slots1 <- index_mut_back Hashmap_List_Nil;
+ hashmap_HashMap_clear_loop T n1 slots1 i2)
else Return slots
end
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::clear]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::clear]:
Source: 'src/hashmap.rs', lines 80:4-80:27 *)
Definition hashmap_HashMap_clear
(T : Type) (n : nat) (self : hashmap_HashMap_t T) :
result (hashmap_HashMap_t T)
:=
- v <- hashmap_HashMap_clear_loop T n self.(hashmap_HashMap_slots) 0%usize;
+ back <- hashmap_HashMap_clear_loop T n self.(hashmap_HashMap_slots) 0%usize;
Return
{|
hashmap_HashMap_num_entries := 0%usize;
hashmap_HashMap_max_load_factor := self.(hashmap_HashMap_max_load_factor);
hashmap_HashMap_max_load := self.(hashmap_HashMap_max_load);
- hashmap_HashMap_slots := v
+ hashmap_HashMap_slots := back
|}
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::len]: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::len]:
Source: 'src/hashmap.rs', lines 90:4-90:30 *)
Definition hashmap_HashMap_len
(T : Type) (self : hashmap_HashMap_t T) : result usize :=
Return self.(hashmap_HashMap_num_entries)
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert_in_list]: loop 0: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert_in_list]: loop 0:
Source: 'src/hashmap.rs', lines 97:4-114:5 *)
Fixpoint hashmap_HashMap_insert_in_list_loop
(T : Type) (n : nat) (key : usize) (value : T) (ls : hashmap_List_t T) :
- result bool
+ result (bool * (hashmap_List_t T))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
- match ls with
- | Hashmap_List_Cons ckey cvalue tl =>
- if ckey s= key
- then Return false
- else hashmap_HashMap_insert_in_list_loop T n0 key value tl
- | Hashmap_List_Nil => Return true
- end
- end
-.
-
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert_in_list]: forward function
- Source: 'src/hashmap.rs', lines 97:4-97:71 *)
-Definition hashmap_HashMap_insert_in_list
- (T : Type) (n : nat) (key : usize) (value : T) (ls : hashmap_List_t T) :
- result bool
- :=
- hashmap_HashMap_insert_in_list_loop T n key value ls
-.
-
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert_in_list]: loop 0: backward function 0
- Source: 'src/hashmap.rs', lines 97:4-114:5 *)
-Fixpoint hashmap_HashMap_insert_in_list_loop_back
- (T : Type) (n : nat) (key : usize) (value : T) (ls : hashmap_List_t T) :
- result (hashmap_List_t T)
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| Hashmap_List_Cons ckey cvalue tl =>
if ckey s= key
- then Return (Hashmap_List_Cons ckey value tl)
+ then Return (false, Hashmap_List_Cons ckey value tl)
else (
- tl0 <- hashmap_HashMap_insert_in_list_loop_back T n0 key value tl;
- Return (Hashmap_List_Cons ckey cvalue tl0))
+ p <- hashmap_HashMap_insert_in_list_loop T n1 key value tl;
+ let (b, back) := p in
+ Return (b, Hashmap_List_Cons ckey cvalue back))
| Hashmap_List_Nil =>
- let l := Hashmap_List_Nil in Return (Hashmap_List_Cons key value l)
+ let l := Hashmap_List_Nil in Return (true, Hashmap_List_Cons key value l)
end
end
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert_in_list]: backward function 0
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert_in_list]:
Source: 'src/hashmap.rs', lines 97:4-97:71 *)
-Definition hashmap_HashMap_insert_in_list_back
+Definition hashmap_HashMap_insert_in_list
(T : Type) (n : nat) (key : usize) (value : T) (ls : hashmap_List_t T) :
- result (hashmap_List_t T)
+ result (bool * (hashmap_List_t T))
:=
- hashmap_HashMap_insert_in_list_loop_back T n key value ls
+ hashmap_HashMap_insert_in_list_loop T n key value ls
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert_no_resize]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert_no_resize]:
Source: 'src/hashmap.rs', lines 117:4-117:54 *)
Definition hashmap_HashMap_insert_no_resize
(T : Type) (n : nat) (self : hashmap_HashMap_t T) (key : usize) (value : T) :
@@ -189,33 +161,27 @@ Definition hashmap_HashMap_insert_no_resize
hash <- hashmap_hash_key key;
let i := alloc_vec_Vec_len (hashmap_List_t T) self.(hashmap_HashMap_slots) in
hash_mod <- usize_rem hash i;
- l <-
+ p <-
alloc_vec_Vec_index_mut (hashmap_List_t T) usize
(core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t T))
self.(hashmap_HashMap_slots) hash_mod;
- inserted <- hashmap_HashMap_insert_in_list T n key value l;
+ let (l, index_mut_back) := p in
+ p1 <- hashmap_HashMap_insert_in_list T n key value l;
+ let (inserted, l1) := p1 in
if inserted
then (
- i0 <- usize_add self.(hashmap_HashMap_num_entries) 1%usize;
- l0 <- hashmap_HashMap_insert_in_list_back T n key value l;
- v <-
- alloc_vec_Vec_index_mut_back (hashmap_List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t T))
- self.(hashmap_HashMap_slots) hash_mod l0;
+ i1 <- usize_add self.(hashmap_HashMap_num_entries) 1%usize;
+ v <- index_mut_back l1;
Return
{|
- hashmap_HashMap_num_entries := i0;
+ hashmap_HashMap_num_entries := i1;
hashmap_HashMap_max_load_factor :=
self.(hashmap_HashMap_max_load_factor);
hashmap_HashMap_max_load := self.(hashmap_HashMap_max_load);
hashmap_HashMap_slots := v
|})
else (
- l0 <- hashmap_HashMap_insert_in_list_back T n key value l;
- v <-
- alloc_vec_Vec_index_mut_back (hashmap_List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t T))
- self.(hashmap_HashMap_slots) hash_mod l0;
+ v <- index_mut_back l1;
Return
{|
hashmap_HashMap_num_entries := self.(hashmap_HashMap_num_entries);
@@ -226,8 +192,7 @@ Definition hashmap_HashMap_insert_no_resize
|})
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements_from_list]: loop 0: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements_from_list]: loop 0:
Source: 'src/hashmap.rs', lines 183:4-196:5 *)
Fixpoint hashmap_HashMap_move_elements_from_list_loop
(T : Type) (n : nat) (ntable : hashmap_HashMap_t T) (ls : hashmap_List_t T) :
@@ -235,18 +200,17 @@ Fixpoint hashmap_HashMap_move_elements_from_list_loop
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| Hashmap_List_Cons k v tl =>
- ntable0 <- hashmap_HashMap_insert_no_resize T n0 ntable k v;
- hashmap_HashMap_move_elements_from_list_loop T n0 ntable0 tl
+ hm <- hashmap_HashMap_insert_no_resize T n1 ntable k v;
+ hashmap_HashMap_move_elements_from_list_loop T n1 hm tl
| Hashmap_List_Nil => Return ntable
end
end
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements_from_list]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements_from_list]:
Source: 'src/hashmap.rs', lines 183:4-183:72 *)
Definition hashmap_HashMap_move_elements_from_list
(T : Type) (n : nat) (ntable : hashmap_HashMap_t T) (ls : hashmap_List_t T) :
@@ -255,8 +219,7 @@ Definition hashmap_HashMap_move_elements_from_list
hashmap_HashMap_move_elements_from_list_loop T n ntable ls
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements]: loop 0: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements]: loop 0:
Source: 'src/hashmap.rs', lines 171:4-180:5 *)
Fixpoint hashmap_HashMap_move_elements_loop
(T : Type) (n : nat) (ntable : hashmap_HashMap_t T)
@@ -265,40 +228,39 @@ Fixpoint hashmap_HashMap_move_elements_loop
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
- let i0 := alloc_vec_Vec_len (hashmap_List_t T) slots in
- if i s< i0
+ | S n1 =>
+ let i1 := alloc_vec_Vec_len (hashmap_List_t T) slots in
+ if i s< i1
then (
- l <-
+ p <-
alloc_vec_Vec_index_mut (hashmap_List_t T) usize
(core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t T)) slots
i;
- let ls := core_mem_replace (hashmap_List_t T) l Hashmap_List_Nil in
- ntable0 <- hashmap_HashMap_move_elements_from_list T n0 ntable ls;
- i1 <- usize_add i 1%usize;
- let l0 := core_mem_replace_back (hashmap_List_t T) l Hashmap_List_Nil in
- slots0 <-
- alloc_vec_Vec_index_mut_back (hashmap_List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t T)) slots
- i l0;
- hashmap_HashMap_move_elements_loop T n0 ntable0 slots0 i1)
+ let (l, index_mut_back) := p in
+ let (ls, l1) := core_mem_replace (hashmap_List_t T) l Hashmap_List_Nil in
+ hm <- hashmap_HashMap_move_elements_from_list T n1 ntable ls;
+ i2 <- usize_add i 1%usize;
+ slots1 <- index_mut_back l1;
+ back_'a <- hashmap_HashMap_move_elements_loop T n1 hm slots1 i2;
+ let (hm1, v) := back_'a in
+ Return (hm1, v))
else Return (ntable, slots)
end
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements]:
Source: 'src/hashmap.rs', lines 171:4-171:95 *)
Definition hashmap_HashMap_move_elements
(T : Type) (n : nat) (ntable : hashmap_HashMap_t T)
(slots : alloc_vec_Vec (hashmap_List_t T)) (i : usize) :
result ((hashmap_HashMap_t T) * (alloc_vec_Vec (hashmap_List_t T)))
:=
- hashmap_HashMap_move_elements_loop T n ntable slots i
+ back_'a <- hashmap_HashMap_move_elements_loop T n ntable slots i;
+ let (hm, v) := back_'a in
+ Return (hm, v)
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::try_resize]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::try_resize]:
Source: 'src/hashmap.rs', lines 140:4-140:28 *)
Definition hashmap_HashMap_try_resize
(T : Type) (n : nat) (self : hashmap_HashMap_t T) :
@@ -308,72 +270,71 @@ Definition hashmap_HashMap_try_resize
let capacity :=
alloc_vec_Vec_len (hashmap_List_t T) self.(hashmap_HashMap_slots) in
n1 <- usize_div max_usize 2%usize;
- let (i, i0) := self.(hashmap_HashMap_max_load_factor) in
- i1 <- usize_div n1 i;
- if capacity s<= i1
+ let (i, i1) := self.(hashmap_HashMap_max_load_factor) in
+ i2 <- usize_div n1 i;
+ if capacity s<= i2
then (
- i2 <- usize_mul capacity 2%usize;
- ntable <- hashmap_HashMap_new_with_capacity T n i2 i i0;
+ i3 <- usize_mul capacity 2%usize;
+ ntable <- hashmap_HashMap_new_with_capacity T n i3 i i1;
p <-
hashmap_HashMap_move_elements T n ntable self.(hashmap_HashMap_slots)
0%usize;
- let (ntable0, _) := p in
+ let (ntable1, _) := p in
Return
{|
hashmap_HashMap_num_entries := self.(hashmap_HashMap_num_entries);
- hashmap_HashMap_max_load_factor := (i, i0);
- hashmap_HashMap_max_load := ntable0.(hashmap_HashMap_max_load);
- hashmap_HashMap_slots := ntable0.(hashmap_HashMap_slots)
+ hashmap_HashMap_max_load_factor := (i, i1);
+ hashmap_HashMap_max_load := ntable1.(hashmap_HashMap_max_load);
+ hashmap_HashMap_slots := ntable1.(hashmap_HashMap_slots)
|})
else
Return
{|
hashmap_HashMap_num_entries := self.(hashmap_HashMap_num_entries);
- hashmap_HashMap_max_load_factor := (i, i0);
+ hashmap_HashMap_max_load_factor := (i, i1);
hashmap_HashMap_max_load := self.(hashmap_HashMap_max_load);
hashmap_HashMap_slots := self.(hashmap_HashMap_slots)
|}
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert]:
Source: 'src/hashmap.rs', lines 129:4-129:48 *)
Definition hashmap_HashMap_insert
(T : Type) (n : nat) (self : hashmap_HashMap_t T) (key : usize) (value : T) :
result (hashmap_HashMap_t T)
:=
- self0 <- hashmap_HashMap_insert_no_resize T n self key value;
- i <- hashmap_HashMap_len T self0;
- if i s> self0.(hashmap_HashMap_max_load)
- then hashmap_HashMap_try_resize T n self0
- else Return self0
+ hm <- hashmap_HashMap_insert_no_resize T n self key value;
+ i <- hashmap_HashMap_len T hm;
+ if i s> hm.(hashmap_HashMap_max_load)
+ then hashmap_HashMap_try_resize T n hm
+ else Return hm
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::contains_key_in_list]: loop 0: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::contains_key_in_list]: loop 0:
Source: 'src/hashmap.rs', lines 206:4-219:5 *)
Fixpoint hashmap_HashMap_contains_key_in_list_loop
(T : Type) (n : nat) (key : usize) (ls : hashmap_List_t T) : result bool :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
- | Hashmap_List_Cons ckey t tl =>
+ | Hashmap_List_Cons ckey _ tl =>
if ckey s= key
then Return true
- else hashmap_HashMap_contains_key_in_list_loop T n0 key tl
+ else hashmap_HashMap_contains_key_in_list_loop T n1 key tl
| Hashmap_List_Nil => Return false
end
end
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::contains_key_in_list]: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::contains_key_in_list]:
Source: 'src/hashmap.rs', lines 206:4-206:68 *)
Definition hashmap_HashMap_contains_key_in_list
(T : Type) (n : nat) (key : usize) (ls : hashmap_List_t T) : result bool :=
hashmap_HashMap_contains_key_in_list_loop T n key ls
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::contains_key]: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::contains_key]:
Source: 'src/hashmap.rs', lines 199:4-199:49 *)
Definition hashmap_HashMap_contains_key
(T : Type) (n : nat) (self : hashmap_HashMap_t T) (key : usize) :
@@ -389,31 +350,31 @@ Definition hashmap_HashMap_contains_key
hashmap_HashMap_contains_key_in_list T n key l
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_in_list]: loop 0: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_in_list]: loop 0:
Source: 'src/hashmap.rs', lines 224:4-237:5 *)
Fixpoint hashmap_HashMap_get_in_list_loop
(T : Type) (n : nat) (key : usize) (ls : hashmap_List_t T) : result T :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| Hashmap_List_Cons ckey cvalue tl =>
if ckey s= key
then Return cvalue
- else hashmap_HashMap_get_in_list_loop T n0 key tl
+ else hashmap_HashMap_get_in_list_loop T n1 key tl
| Hashmap_List_Nil => Fail_ Failure
end
end
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_in_list]: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_in_list]:
Source: 'src/hashmap.rs', lines 224:4-224:70 *)
Definition hashmap_HashMap_get_in_list
(T : Type) (n : nat) (key : usize) (ls : hashmap_List_t T) : result T :=
hashmap_HashMap_get_in_list_loop T n key ls
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get]: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get]:
Source: 'src/hashmap.rs', lines 239:4-239:55 *)
Definition hashmap_HashMap_get
(T : Type) (n : nat) (self : hashmap_HashMap_t T) (key : usize) : result T :=
@@ -427,292 +388,209 @@ Definition hashmap_HashMap_get
hashmap_HashMap_get_in_list T n key l
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_mut_in_list]: loop 0: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_mut_in_list]: loop 0:
Source: 'src/hashmap.rs', lines 245:4-254:5 *)
Fixpoint hashmap_HashMap_get_mut_in_list_loop
- (T : Type) (n : nat) (ls : hashmap_List_t T) (key : usize) : result T :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls with
- | Hashmap_List_Cons ckey cvalue tl =>
- if ckey s= key
- then Return cvalue
- else hashmap_HashMap_get_mut_in_list_loop T n0 tl key
- | Hashmap_List_Nil => Fail_ Failure
- end
- end
-.
-
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_mut_in_list]: forward function
- Source: 'src/hashmap.rs', lines 245:4-245:86 *)
-Definition hashmap_HashMap_get_mut_in_list
- (T : Type) (n : nat) (ls : hashmap_List_t T) (key : usize) : result T :=
- hashmap_HashMap_get_mut_in_list_loop T n ls key
-.
-
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_mut_in_list]: loop 0: backward function 0
- Source: 'src/hashmap.rs', lines 245:4-254:5 *)
-Fixpoint hashmap_HashMap_get_mut_in_list_loop_back
- (T : Type) (n : nat) (ls : hashmap_List_t T) (key : usize) (ret : T) :
- result (hashmap_List_t T)
+ (T : Type) (n : nat) (ls : hashmap_List_t T) (key : usize) :
+ result (T * (T -> result (hashmap_List_t T)))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| Hashmap_List_Cons ckey cvalue tl =>
if ckey s= key
- then Return (Hashmap_List_Cons ckey ret tl)
+ then
+ let back_'a := fun (ret : T) => Return (Hashmap_List_Cons ckey ret tl)
+ in
+ Return (cvalue, back_'a)
else (
- tl0 <- hashmap_HashMap_get_mut_in_list_loop_back T n0 tl key ret;
- Return (Hashmap_List_Cons ckey cvalue tl0))
+ p <- hashmap_HashMap_get_mut_in_list_loop T n1 tl key;
+ let (t, back_'a) := p in
+ let back_'a1 :=
+ fun (ret : T) =>
+ tl1 <- back_'a ret; Return (Hashmap_List_Cons ckey cvalue tl1) in
+ Return (t, back_'a1))
| Hashmap_List_Nil => Fail_ Failure
end
end
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_mut_in_list]: backward function 0
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_mut_in_list]:
Source: 'src/hashmap.rs', lines 245:4-245:86 *)
-Definition hashmap_HashMap_get_mut_in_list_back
- (T : Type) (n : nat) (ls : hashmap_List_t T) (key : usize) (ret : T) :
- result (hashmap_List_t T)
+Definition hashmap_HashMap_get_mut_in_list
+ (T : Type) (n : nat) (ls : hashmap_List_t T) (key : usize) :
+ result (T * (T -> result (hashmap_List_t T)))
:=
- hashmap_HashMap_get_mut_in_list_loop_back T n ls key ret
+ p <- hashmap_HashMap_get_mut_in_list_loop T n ls key;
+ let (t, back_'a) := p in
+ let back_'a1 := fun (ret : T) => back_'a ret in
+ Return (t, back_'a1)
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_mut]: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_mut]:
Source: 'src/hashmap.rs', lines 257:4-257:67 *)
Definition hashmap_HashMap_get_mut
- (T : Type) (n : nat) (self : hashmap_HashMap_t T) (key : usize) : result T :=
- hash <- hashmap_hash_key key;
- let i := alloc_vec_Vec_len (hashmap_List_t T) self.(hashmap_HashMap_slots) in
- hash_mod <- usize_rem hash i;
- l <-
- alloc_vec_Vec_index_mut (hashmap_List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t T))
- self.(hashmap_HashMap_slots) hash_mod;
- hashmap_HashMap_get_mut_in_list T n l key
-.
-
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_mut]: backward function 0
- Source: 'src/hashmap.rs', lines 257:4-257:67 *)
-Definition hashmap_HashMap_get_mut_back
- (T : Type) (n : nat) (self : hashmap_HashMap_t T) (key : usize) (ret : T) :
- result (hashmap_HashMap_t T)
+ (T : Type) (n : nat) (self : hashmap_HashMap_t T) (key : usize) :
+ result (T * (T -> result (hashmap_HashMap_t T)))
:=
hash <- hashmap_hash_key key;
let i := alloc_vec_Vec_len (hashmap_List_t T) self.(hashmap_HashMap_slots) in
hash_mod <- usize_rem hash i;
- l <-
+ p <-
alloc_vec_Vec_index_mut (hashmap_List_t T) usize
(core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t T))
self.(hashmap_HashMap_slots) hash_mod;
- l0 <- hashmap_HashMap_get_mut_in_list_back T n l key ret;
- v <-
- alloc_vec_Vec_index_mut_back (hashmap_List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t T))
- self.(hashmap_HashMap_slots) hash_mod l0;
- Return
- {|
- hashmap_HashMap_num_entries := self.(hashmap_HashMap_num_entries);
- hashmap_HashMap_max_load_factor := self.(hashmap_HashMap_max_load_factor);
- hashmap_HashMap_max_load := self.(hashmap_HashMap_max_load);
- hashmap_HashMap_slots := v
- |}
-.
-
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::remove_from_list]: loop 0: forward function
+ let (l, index_mut_back) := p in
+ p1 <- hashmap_HashMap_get_mut_in_list T n l key;
+ let (t, get_mut_in_list_back) := p1 in
+ let back_'a :=
+ fun (ret : T) =>
+ l1 <- get_mut_in_list_back ret;
+ v <- index_mut_back l1;
+ Return
+ {|
+ hashmap_HashMap_num_entries := self.(hashmap_HashMap_num_entries);
+ hashmap_HashMap_max_load_factor :=
+ self.(hashmap_HashMap_max_load_factor);
+ hashmap_HashMap_max_load := self.(hashmap_HashMap_max_load);
+ hashmap_HashMap_slots := v
+ |} in
+ Return (t, back_'a)
+.
+
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::remove_from_list]: loop 0:
Source: 'src/hashmap.rs', lines 265:4-291:5 *)
Fixpoint hashmap_HashMap_remove_from_list_loop
(T : Type) (n : nat) (key : usize) (ls : hashmap_List_t T) :
- result (option T)
+ result ((option T) * (hashmap_List_t T))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| Hashmap_List_Cons ckey t tl =>
if ckey s= key
then
- let mv_ls :=
+ let (mv_ls, _) :=
core_mem_replace (hashmap_List_t T) (Hashmap_List_Cons ckey t tl)
Hashmap_List_Nil in
match mv_ls with
- | Hashmap_List_Cons i cvalue tl0 => Return (Some cvalue)
+ | Hashmap_List_Cons _ cvalue tl1 => Return (Some cvalue, tl1)
| Hashmap_List_Nil => Fail_ Failure
end
- else hashmap_HashMap_remove_from_list_loop T n0 key tl
- | Hashmap_List_Nil => Return None
+ else (
+ p <- hashmap_HashMap_remove_from_list_loop T n1 key tl;
+ let (o, back) := p in
+ Return (o, Hashmap_List_Cons ckey t back))
+ | Hashmap_List_Nil => Return (None, Hashmap_List_Nil)
end
end
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::remove_from_list]: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::remove_from_list]:
Source: 'src/hashmap.rs', lines 265:4-265:69 *)
Definition hashmap_HashMap_remove_from_list
(T : Type) (n : nat) (key : usize) (ls : hashmap_List_t T) :
- result (option T)
+ result ((option T) * (hashmap_List_t T))
:=
hashmap_HashMap_remove_from_list_loop T n key ls
.
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::remove_from_list]: loop 0: backward function 1
- Source: 'src/hashmap.rs', lines 265:4-291:5 *)
-Fixpoint hashmap_HashMap_remove_from_list_loop_back
- (T : Type) (n : nat) (key : usize) (ls : hashmap_List_t T) :
- result (hashmap_List_t T)
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls with
- | Hashmap_List_Cons ckey t tl =>
- if ckey s= key
- then
- let mv_ls :=
- core_mem_replace (hashmap_List_t T) (Hashmap_List_Cons ckey t tl)
- Hashmap_List_Nil in
- match mv_ls with
- | Hashmap_List_Cons i cvalue tl0 => Return tl0
- | Hashmap_List_Nil => Fail_ Failure
- end
- else (
- tl0 <- hashmap_HashMap_remove_from_list_loop_back T n0 key tl;
- Return (Hashmap_List_Cons ckey t tl0))
- | Hashmap_List_Nil => Return Hashmap_List_Nil
- end
- end
-.
-
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::remove_from_list]: backward function 1
- Source: 'src/hashmap.rs', lines 265:4-265:69 *)
-Definition hashmap_HashMap_remove_from_list_back
- (T : Type) (n : nat) (key : usize) (ls : hashmap_List_t T) :
- result (hashmap_List_t T)
- :=
- hashmap_HashMap_remove_from_list_loop_back T n key ls
-.
-
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::remove]: forward function
+(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::remove]:
Source: 'src/hashmap.rs', lines 294:4-294:52 *)
Definition hashmap_HashMap_remove
(T : Type) (n : nat) (self : hashmap_HashMap_t T) (key : usize) :
- result (option T)
+ result ((option T) * (hashmap_HashMap_t T))
:=
hash <- hashmap_hash_key key;
let i := alloc_vec_Vec_len (hashmap_List_t T) self.(hashmap_HashMap_slots) in
hash_mod <- usize_rem hash i;
- l <-
+ p <-
alloc_vec_Vec_index_mut (hashmap_List_t T) usize
(core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t T))
self.(hashmap_HashMap_slots) hash_mod;
- x <- hashmap_HashMap_remove_from_list T n key l;
- match x with
- | None => Return None
- | Some x0 =>
- _ <- usize_sub self.(hashmap_HashMap_num_entries) 1%usize; Return (Some x0)
- end
-.
-
-(** [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::remove]: backward function 0
- Source: 'src/hashmap.rs', lines 294:4-294:52 *)
-Definition hashmap_HashMap_remove_back
- (T : Type) (n : nat) (self : hashmap_HashMap_t T) (key : usize) :
- result (hashmap_HashMap_t T)
- :=
- hash <- hashmap_hash_key key;
- let i := alloc_vec_Vec_len (hashmap_List_t T) self.(hashmap_HashMap_slots) in
- hash_mod <- usize_rem hash i;
- l <-
- alloc_vec_Vec_index_mut (hashmap_List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t T))
- self.(hashmap_HashMap_slots) hash_mod;
- x <- hashmap_HashMap_remove_from_list T n key l;
+ let (l, index_mut_back) := p in
+ p1 <- hashmap_HashMap_remove_from_list T n key l;
+ let (x, l1) := p1 in
match x with
| None =>
- l0 <- hashmap_HashMap_remove_from_list_back T n key l;
- v <-
- alloc_vec_Vec_index_mut_back (hashmap_List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t T))
- self.(hashmap_HashMap_slots) hash_mod l0;
- Return
+ v <- index_mut_back l1;
+ Return (None,
{|
hashmap_HashMap_num_entries := self.(hashmap_HashMap_num_entries);
hashmap_HashMap_max_load_factor :=
self.(hashmap_HashMap_max_load_factor);
hashmap_HashMap_max_load := self.(hashmap_HashMap_max_load);
hashmap_HashMap_slots := v
- |}
- | Some x0 =>
- i0 <- usize_sub self.(hashmap_HashMap_num_entries) 1%usize;
- l0 <- hashmap_HashMap_remove_from_list_back T n key l;
- v <-
- alloc_vec_Vec_index_mut_back (hashmap_List_t T) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (hashmap_List_t T))
- self.(hashmap_HashMap_slots) hash_mod l0;
- Return
+ |})
+ | Some x1 =>
+ i1 <- usize_sub self.(hashmap_HashMap_num_entries) 1%usize;
+ v <- index_mut_back l1;
+ Return (Some x1,
{|
- hashmap_HashMap_num_entries := i0;
+ hashmap_HashMap_num_entries := i1;
hashmap_HashMap_max_load_factor :=
self.(hashmap_HashMap_max_load_factor);
hashmap_HashMap_max_load := self.(hashmap_HashMap_max_load);
hashmap_HashMap_slots := v
- |}
+ |})
end
.
-(** [hashmap_main::hashmap::test1]: forward function
+(** [hashmap_main::hashmap::test1]:
Source: 'src/hashmap.rs', lines 315:0-315:10 *)
Definition hashmap_test1 (n : nat) : result unit :=
hm <- hashmap_HashMap_new u64 n;
- hm0 <- hashmap_HashMap_insert u64 n hm 0%usize 42%u64;
- hm1 <- hashmap_HashMap_insert u64 n hm0 128%usize 18%u64;
- hm2 <- hashmap_HashMap_insert u64 n hm1 1024%usize 138%u64;
- hm3 <- hashmap_HashMap_insert u64 n hm2 1056%usize 256%u64;
- i <- hashmap_HashMap_get u64 n hm3 128%usize;
+ hm1 <- hashmap_HashMap_insert u64 n hm 0%usize 42%u64;
+ hm2 <- hashmap_HashMap_insert u64 n hm1 128%usize 18%u64;
+ hm3 <- hashmap_HashMap_insert u64 n hm2 1024%usize 138%u64;
+ hm4 <- hashmap_HashMap_insert u64 n hm3 1056%usize 256%u64;
+ i <- hashmap_HashMap_get u64 n hm4 128%usize;
if negb (i s= 18%u64)
then Fail_ Failure
else (
- hm4 <- hashmap_HashMap_get_mut_back u64 n hm3 1024%usize 56%u64;
- i0 <- hashmap_HashMap_get u64 n hm4 1024%usize;
- if negb (i0 s= 56%u64)
+ p <- hashmap_HashMap_get_mut u64 n hm4 1024%usize;
+ let (_, get_mut_back) := p in
+ hm5 <- get_mut_back 56%u64;
+ i1 <- hashmap_HashMap_get u64 n hm5 1024%usize;
+ if negb (i1 s= 56%u64)
then Fail_ Failure
else (
- x <- hashmap_HashMap_remove u64 n hm4 1024%usize;
+ p1 <- hashmap_HashMap_remove u64 n hm5 1024%usize;
+ let (x, hm6) := p1 in
match x with
| None => Fail_ Failure
- | Some x0 =>
- if negb (x0 s= 56%u64)
+ | Some x1 =>
+ if negb (x1 s= 56%u64)
then Fail_ Failure
else (
- hm5 <- hashmap_HashMap_remove_back u64 n hm4 1024%usize;
- i1 <- hashmap_HashMap_get u64 n hm5 0%usize;
- if negb (i1 s= 42%u64)
+ i2 <- hashmap_HashMap_get u64 n hm6 0%usize;
+ if negb (i2 s= 42%u64)
then Fail_ Failure
else (
- i2 <- hashmap_HashMap_get u64 n hm5 128%usize;
- if negb (i2 s= 18%u64)
+ i3 <- hashmap_HashMap_get u64 n hm6 128%usize;
+ if negb (i3 s= 18%u64)
then Fail_ Failure
else (
- i3 <- hashmap_HashMap_get u64 n hm5 1056%usize;
- if negb (i3 s= 256%u64) then Fail_ Failure else Return tt)))
+ i4 <- hashmap_HashMap_get u64 n hm6 1056%usize;
+ if negb (i4 s= 256%u64) then Fail_ Failure else Return tt)))
end))
.
-(** [hashmap_main::insert_on_disk]: forward function
+(** [hashmap_main::insert_on_disk]:
Source: 'src/hashmap_main.rs', lines 7:0-7:43 *)
Definition insert_on_disk
(n : nat) (key : usize) (value : u64) (st : state) : result (state * unit) :=
p <- hashmap_utils_deserialize st;
- let (st0, hm) := p in
- hm0 <- hashmap_HashMap_insert u64 n hm key value;
- p0 <- hashmap_utils_serialize hm0 st0;
- let (st1, _) := p0 in
- Return (st1, tt)
+ let (st1, hm) := p in
+ hm1 <- hashmap_HashMap_insert u64 n hm key value;
+ p1 <- hashmap_utils_serialize hm1 st1;
+ let (st2, _) := p1 in
+ Return (st2, tt)
.
-(** [hashmap_main::main]: forward function
+(** [hashmap_main::main]:
Source: 'src/hashmap_main.rs', lines 16:0-16:13 *)
Definition main : result unit :=
Return tt.
diff --git a/tests/coq/hashmap_on_disk/HashmapMain_FunsExternal_Template.v b/tests/coq/hashmap_on_disk/HashmapMain_FunsExternal_Template.v
index e10d02f6..fb2e052a 100644
--- a/tests/coq/hashmap_on_disk/HashmapMain_FunsExternal_Template.v
+++ b/tests/coq/hashmap_on_disk/HashmapMain_FunsExternal_Template.v
@@ -11,13 +11,13 @@ Require Import HashmapMain_Types.
Include HashmapMain_Types.
Module HashmapMain_FunsExternal_Template.
-(** [hashmap_main::hashmap_utils::deserialize]: forward function
+(** [hashmap_main::hashmap_utils::deserialize]:
Source: 'src/hashmap_utils.rs', lines 10:0-10:43 *)
Axiom hashmap_utils_deserialize
: state -> result (state * (hashmap_HashMap_t u64))
.
-(** [hashmap_main::hashmap_utils::serialize]: forward function
+(** [hashmap_main::hashmap_utils::serialize]:
Source: 'src/hashmap_utils.rs', lines 5:0-5:42 *)
Axiom hashmap_utils_serialize
: hashmap_HashMap_t u64 -> state -> result (state * unit)
diff --git a/tests/coq/hashmap_on_disk/Primitives.v b/tests/coq/hashmap_on_disk/Primitives.v
index 84280b96..990e27e4 100644
--- a/tests/coq/hashmap_on_disk/Primitives.v
+++ b/tests/coq/hashmap_on_disk/Primitives.v
@@ -67,8 +67,7 @@ Definition string := Coq.Strings.String.string.
Definition char := Coq.Strings.Ascii.ascii.
Definition char_of_byte := Coq.Strings.Ascii.ascii_of_byte.
-Definition core_mem_replace (a : Type) (x : a) (y : a) : a := x .
-Definition core_mem_replace_back (a : Type) (x : a) (y : a) : a := y .
+Definition core_mem_replace (a : Type) (x : a) (y : a) : a * a := (x, x) .
Record mut_raw_ptr (T : Type) := { mut_raw_ptr_v : T }.
Record const_raw_ptr (T : Type) := { const_raw_ptr_v : T }.
@@ -504,13 +503,15 @@ Arguments core_ops_index_Index_index {_ _}.
(* Trait declaration: [core::ops::index::IndexMut] *)
Record core_ops_index_IndexMut (Self Idx : Type) := mk_core_ops_index_IndexMut {
core_ops_index_IndexMut_indexInst : core_ops_index_Index Self Idx;
- core_ops_index_IndexMut_index_mut : Self -> Idx -> result core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output);
- core_ops_index_IndexMut_index_mut_back : Self -> Idx -> core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) -> result Self;
+ core_ops_index_IndexMut_index_mut :
+ Self ->
+ Idx ->
+ result (core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) *
+ (core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) -> result Self));
}.
Arguments mk_core_ops_index_IndexMut {_ _}.
Arguments core_ops_index_IndexMut_indexInst {_ _}.
Arguments core_ops_index_IndexMut_index_mut {_ _}.
-Arguments core_ops_index_IndexMut_index_mut_back {_ _}.
(* Trait declaration [core::ops::deref::Deref] *)
Record core_ops_deref_Deref (Self : Type) := mk_core_ops_deref_Deref {
@@ -524,13 +525,14 @@ Arguments core_ops_deref_Deref_deref {_}.
(* Trait declaration [core::ops::deref::DerefMut] *)
Record core_ops_deref_DerefMut (Self : Type) := mk_core_ops_deref_DerefMut {
core_ops_deref_DerefMut_derefInst : core_ops_deref_Deref Self;
- core_ops_deref_DerefMut_deref_mut : Self -> result core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target);
- core_ops_deref_DerefMut_deref_mut_back : Self -> core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) -> result Self;
+ core_ops_deref_DerefMut_deref_mut :
+ Self ->
+ result (core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) *
+ (core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) -> result Self));
}.
Arguments mk_core_ops_deref_DerefMut {_}.
Arguments core_ops_deref_DerefMut_derefInst {_}.
Arguments core_ops_deref_DerefMut_deref_mut {_}.
-Arguments core_ops_deref_DerefMut_deref_mut_back {_}.
Record core_ops_range_Range (T : Type) := mk_core_ops_range_Range {
core_ops_range_Range_start : T;
@@ -543,8 +545,8 @@ Arguments core_ops_range_Range_end_ {_}.
(*** [alloc] *)
Definition alloc_boxed_Box_deref (T : Type) (x : T) : result T := Return x.
-Definition alloc_boxed_Box_deref_mut (T : Type) (x : T) : result T := Return x.
-Definition alloc_boxed_Box_deref_mut_back (T : Type) (_ : T) (x : T) : result T := Return x.
+Definition alloc_boxed_Box_deref_mut (T : Type) (x : T) : result (T * (T -> result T)) :=
+ Return (x, fun x => Return x).
(* Trait instance *)
Definition alloc_boxed_Box_coreopsDerefInst (Self : Type) : core_ops_deref_Deref Self := {|
@@ -556,7 +558,6 @@ Definition alloc_boxed_Box_coreopsDerefInst (Self : Type) : core_ops_deref_Deref
Definition alloc_boxed_Box_coreopsDerefMutInst (Self : Type) : core_ops_deref_DerefMut Self := {|
core_ops_deref_DerefMut_derefInst := alloc_boxed_Box_coreopsDerefInst Self;
core_ops_deref_DerefMut_deref_mut := alloc_boxed_Box_deref_mut Self;
- core_ops_deref_DerefMut_deref_mut_back := alloc_boxed_Box_deref_mut_back Self;
|}.
@@ -584,6 +585,13 @@ Axiom array_repeat : forall (T : Type) (n : usize) (x : T), array T n.
Axiom array_index_usize : forall (T : Type) (n : usize) (x : array T n) (i : usize), result T.
Axiom array_update_usize : forall (T : Type) (n : usize) (x : array T n) (i : usize) (nx : T), result (array T n).
+Definition array_index_mut_usize (T : Type) (n : usize) (a : array T n) (i : usize) :
+ result (T * (T -> result (array T n))) :=
+ match array_index_usize T n a i with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, array_update_usize T n a i)
+ end.
+
(*** Slice *)
Definition slice T := { l: list T | Z.of_nat (length l) <= usize_max}.
@@ -591,11 +599,25 @@ Axiom slice_len : forall (T : Type) (s : slice T), usize.
Axiom slice_index_usize : forall (T : Type) (x : slice T) (i : usize), result T.
Axiom slice_update_usize : forall (T : Type) (x : slice T) (i : usize) (nx : T), result (slice T).
+Definition slice_index_mut_usize (T : Type) (s : slice T) (i : usize) :
+ result (T * (T -> result (slice T))) :=
+ match slice_index_usize T s i with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, slice_update_usize T s i)
+ end.
+
(*** Subslices *)
Axiom array_to_slice : forall (T : Type) (n : usize) (x : array T n), result (slice T).
Axiom array_from_slice : forall (T : Type) (n : usize) (x : array T n) (s : slice T), result (array T n).
+Definition array_to_slice_mut (T : Type) (n : usize) (a : array T n) :
+ result (slice T * (slice T -> result (array T n))) :=
+ match array_to_slice T n a with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, array_from_slice T n a)
+ end.
+
Axiom array_subslice: forall (T : Type) (n : usize) (x : array T n) (r : core_ops_range_Range usize), result (slice T).
Axiom array_update_subslice: forall (T : Type) (n : usize) (x : array T n) (r : core_ops_range_Range usize) (ns : slice T), result (array T n).
@@ -639,16 +661,9 @@ Definition alloc_vec_Vec_bind {A B} (v: alloc_vec_Vec A) (f: list A -> result (l
| right _ => Fail_ Failure
end.
-(* The **forward** function shouldn't be used *)
-Definition alloc_vec_Vec_push_fwd (T: Type) (v: alloc_vec_Vec T) (x: T) : unit := tt.
-
Definition alloc_vec_Vec_push (T: Type) (v: alloc_vec_Vec T) (x: T) : result (alloc_vec_Vec T) :=
alloc_vec_Vec_bind v (fun l => Return (l ++ [x])).
-(* The **forward** function shouldn't be used *)
-Definition alloc_vec_Vec_insert_fwd (T: Type) (v: alloc_vec_Vec T) (i: usize) (x: T) : result unit :=
- if to_Z i <? alloc_vec_Vec_length v then Return tt else Fail_ Failure.
-
Definition alloc_vec_Vec_insert (T: Type) (v: alloc_vec_Vec T) (i: usize) (x: T) : result (alloc_vec_Vec T) :=
alloc_vec_Vec_bind v (fun l =>
if to_Z i <? Z.of_nat (length l)
@@ -661,6 +676,14 @@ Axiom alloc_vec_Vec_index_usize : forall {T : Type} (v : alloc_vec_Vec T) (i : u
(* Helper *)
Axiom alloc_vec_Vec_update_usize : forall {T : Type} (v : alloc_vec_Vec T) (i : usize) (x : T), result (alloc_vec_Vec T).
+Definition alloc_vec_Vec_index_mut_usize {T : Type} (v: alloc_vec_Vec T) (i: usize) :
+ result (T * (T -> result (alloc_vec_Vec T))) :=
+ match alloc_vec_Vec_index_usize v i with
+ | Return x =>
+ Return (x, alloc_vec_Vec_update_usize v i)
+ | Fail_ e => Fail_ e
+ end.
+
(* Trait declaration: [core::slice::index::private_slice_index::Sealed] *)
Definition core_slice_index_private_slice_index_Sealed (self : Type) := unit.
@@ -669,25 +692,23 @@ Record core_slice_index_SliceIndex (Self T : Type) := mk_core_slice_index_SliceI
core_slice_index_SliceIndex_sealedInst : core_slice_index_private_slice_index_Sealed Self;
core_slice_index_SliceIndex_Output : Type;
core_slice_index_SliceIndex_get : Self -> T -> result (option core_slice_index_SliceIndex_Output);
- core_slice_index_SliceIndex_get_mut : Self -> T -> result (option core_slice_index_SliceIndex_Output);
- core_slice_index_SliceIndex_get_mut_back : Self -> T -> option core_slice_index_SliceIndex_Output -> result T;
+ core_slice_index_SliceIndex_get_mut :
+ Self -> T -> result (option core_slice_index_SliceIndex_Output * (option core_slice_index_SliceIndex_Output -> result T));
core_slice_index_SliceIndex_get_unchecked : Self -> const_raw_ptr T -> result (const_raw_ptr core_slice_index_SliceIndex_Output);
core_slice_index_SliceIndex_get_unchecked_mut : Self -> mut_raw_ptr T -> result (mut_raw_ptr core_slice_index_SliceIndex_Output);
core_slice_index_SliceIndex_index : Self -> T -> result core_slice_index_SliceIndex_Output;
- core_slice_index_SliceIndex_index_mut : Self -> T -> result core_slice_index_SliceIndex_Output;
- core_slice_index_SliceIndex_index_mut_back : Self -> T -> core_slice_index_SliceIndex_Output -> result T;
+ core_slice_index_SliceIndex_index_mut :
+ Self -> T -> result (core_slice_index_SliceIndex_Output * (core_slice_index_SliceIndex_Output -> result T));
}.
Arguments mk_core_slice_index_SliceIndex {_ _}.
Arguments core_slice_index_SliceIndex_sealedInst {_ _}.
Arguments core_slice_index_SliceIndex_Output {_ _}.
Arguments core_slice_index_SliceIndex_get {_ _}.
Arguments core_slice_index_SliceIndex_get_mut {_ _}.
-Arguments core_slice_index_SliceIndex_get_mut_back {_ _}.
Arguments core_slice_index_SliceIndex_get_unchecked {_ _}.
Arguments core_slice_index_SliceIndex_get_unchecked_mut {_ _}.
Arguments core_slice_index_SliceIndex_index {_ _}.
Arguments core_slice_index_SliceIndex_index_mut {_ _}.
-Arguments core_slice_index_SliceIndex_index_mut_back {_ _}.
(* [core::slice::index::[T]::index]: forward function *)
Definition core_slice_index_Slice_index
@@ -704,11 +725,9 @@ Axiom core_slice_index_RangeUsize_get : forall (T : Type) (i : core_ops_range_Ra
(* [core::slice::index::Range::get_mut]: forward function *)
Axiom core_slice_index_RangeUsize_get_mut :
- forall (T : Type), core_ops_range_Range usize -> slice T -> result (option (slice T)).
-
-(* [core::slice::index::Range::get_mut]: backward function 0 *)
-Axiom core_slice_index_RangeUsize_get_mut_back :
- forall (T : Type), core_ops_range_Range usize -> slice T -> option (slice T) -> result (slice T).
+ forall (T : Type),
+ core_ops_range_Range usize -> slice T ->
+ result (option (slice T) * (option (slice T) -> result (slice T))).
(* [core::slice::index::Range::get_unchecked]: forward function *)
Definition core_slice_index_RangeUsize_get_unchecked
@@ -732,21 +751,14 @@ Axiom core_slice_index_RangeUsize_index :
(* [core::slice::index::Range::index_mut]: forward function *)
Axiom core_slice_index_RangeUsize_index_mut :
- forall (T : Type), core_ops_range_Range usize -> slice T -> result (slice T).
-
-(* [core::slice::index::Range::index_mut]: backward function 0 *)
-Axiom core_slice_index_RangeUsize_index_mut_back :
- forall (T : Type), core_ops_range_Range usize -> slice T -> slice T -> result (slice T).
+ forall (T : Type), core_ops_range_Range usize -> slice T -> result (slice T * (slice T -> result (slice T))).
(* [core::slice::index::[T]::index_mut]: forward function *)
Axiom core_slice_index_Slice_index_mut :
forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T)),
- slice T -> Idx -> result inst.(core_slice_index_SliceIndex_Output).
-
-(* [core::slice::index::[T]::index_mut]: backward function 0 *)
-Axiom core_slice_index_Slice_index_mut_back :
- forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T)),
- slice T -> Idx -> inst.(core_slice_index_SliceIndex_Output) -> result (slice T).
+ slice T -> Idx ->
+ result (inst.(core_slice_index_SliceIndex_Output) *
+ (inst.(core_slice_index_SliceIndex_Output) -> result (slice T))).
(* [core::array::[T; N]::index]: forward function *)
Axiom core_array_Array_index :
@@ -756,12 +768,9 @@ Axiom core_array_Array_index :
(* [core::array::[T; N]::index_mut]: forward function *)
Axiom core_array_Array_index_mut :
forall (T Idx : Type) (N : usize) (inst : core_ops_index_IndexMut (slice T) Idx)
- (a : array T N) (i : Idx), result inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output).
-
-(* [core::array::[T; N]::index_mut]: backward function 0 *)
-Axiom core_array_Array_index_mut_back :
- forall (T Idx : Type) (N : usize) (inst : core_ops_index_IndexMut (slice T) Idx)
- (a : array T N) (i : Idx) (x : inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output)), result (array T N).
+ (a : array T N) (i : Idx),
+ result (inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output) *
+ (inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output) -> result (array T N))).
(* Trait implementation: [core::slice::index::private_slice_index::Range] *)
Definition core_slice_index_private_slice_index_SealedRangeUsizeInst
@@ -774,12 +783,10 @@ Definition core_slice_index_SliceIndexRangeUsizeSliceTInst (T : Type) :
core_slice_index_SliceIndex_Output := slice T;
core_slice_index_SliceIndex_get := core_slice_index_RangeUsize_get T;
core_slice_index_SliceIndex_get_mut := core_slice_index_RangeUsize_get_mut T;
- core_slice_index_SliceIndex_get_mut_back := core_slice_index_RangeUsize_get_mut_back T;
core_slice_index_SliceIndex_get_unchecked := core_slice_index_RangeUsize_get_unchecked T;
core_slice_index_SliceIndex_get_unchecked_mut := core_slice_index_RangeUsize_get_unchecked_mut T;
core_slice_index_SliceIndex_index := core_slice_index_RangeUsize_index T;
core_slice_index_SliceIndex_index_mut := core_slice_index_RangeUsize_index_mut T;
- core_slice_index_SliceIndex_index_mut_back := core_slice_index_RangeUsize_index_mut_back T;
|}.
(* Trait implementation: [core::slice::index::[T]] *)
@@ -796,7 +803,6 @@ Definition core_ops_index_IndexMutSliceTIInst (T Idx : Type)
core_ops_index_IndexMut (slice T) Idx := {|
core_ops_index_IndexMut_indexInst := core_ops_index_IndexSliceTIInst T Idx inst;
core_ops_index_IndexMut_index_mut := core_slice_index_Slice_index_mut T Idx inst;
- core_ops_index_IndexMut_index_mut_back := core_slice_index_Slice_index_mut_back T Idx inst;
|}.
(* Trait implementation: [core::array::[T; N]] *)
@@ -813,18 +819,14 @@ Definition core_ops_index_IndexMutArrayInst (T Idx : Type) (N : usize)
core_ops_index_IndexMut (array T N) Idx := {|
core_ops_index_IndexMut_indexInst := core_ops_index_IndexArrayInst T Idx N inst.(core_ops_index_IndexMut_indexInst);
core_ops_index_IndexMut_index_mut := core_array_Array_index_mut T Idx N inst;
- core_ops_index_IndexMut_index_mut_back := core_array_Array_index_mut_back T Idx N inst;
|}.
(* [core::slice::index::usize::get]: forward function *)
Axiom core_slice_index_usize_get : forall (T : Type), usize -> slice T -> result (option T).
(* [core::slice::index::usize::get_mut]: forward function *)
-Axiom core_slice_index_usize_get_mut : forall (T : Type), usize -> slice T -> result (option T).
-
-(* [core::slice::index::usize::get_mut]: backward function 0 *)
-Axiom core_slice_index_usize_get_mut_back :
- forall (T : Type), usize -> slice T -> option T -> result (slice T).
+Axiom core_slice_index_usize_get_mut :
+ forall (T : Type), usize -> slice T -> result (option T * (option T -> result (slice T))).
(* [core::slice::index::usize::get_unchecked]: forward function *)
Axiom core_slice_index_usize_get_unchecked :
@@ -838,11 +840,8 @@ Axiom core_slice_index_usize_get_unchecked_mut :
Axiom core_slice_index_usize_index : forall (T : Type), usize -> slice T -> result T.
(* [core::slice::index::usize::index_mut]: forward function *)
-Axiom core_slice_index_usize_index_mut : forall (T : Type), usize -> slice T -> result T.
-
-(* [core::slice::index::usize::index_mut]: backward function 0 *)
-Axiom core_slice_index_usize_index_mut_back :
- forall (T : Type), usize -> slice T -> T -> result (slice T).
+Axiom core_slice_index_usize_index_mut :
+ forall (T : Type), usize -> slice T -> result (T * (T -> result (slice T))).
(* Trait implementation: [core::slice::index::private_slice_index::usize] *)
Definition core_slice_index_private_slice_index_SealedUsizeInst
@@ -855,12 +854,10 @@ Definition core_slice_index_SliceIndexUsizeSliceTInst (T : Type) :
core_slice_index_SliceIndex_Output := T;
core_slice_index_SliceIndex_get := core_slice_index_usize_get T;
core_slice_index_SliceIndex_get_mut := core_slice_index_usize_get_mut T;
- core_slice_index_SliceIndex_get_mut_back := core_slice_index_usize_get_mut_back T;
core_slice_index_SliceIndex_get_unchecked := core_slice_index_usize_get_unchecked T;
core_slice_index_SliceIndex_get_unchecked_mut := core_slice_index_usize_get_unchecked_mut T;
core_slice_index_SliceIndex_index := core_slice_index_usize_index T;
core_slice_index_SliceIndex_index_mut := core_slice_index_usize_index_mut T;
- core_slice_index_SliceIndex_index_mut_back := core_slice_index_usize_index_mut_back T;
|}.
(* [alloc::vec::Vec::index]: forward function *)
@@ -869,12 +866,9 @@ Axiom alloc_vec_Vec_index : forall (T Idx : Type) (inst : core_slice_index_Slice
(* [alloc::vec::Vec::index_mut]: forward function *)
Axiom alloc_vec_Vec_index_mut : forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T))
- (Self : alloc_vec_Vec T) (i : Idx), result inst.(core_slice_index_SliceIndex_Output).
-
-(* [alloc::vec::Vec::index_mut]: backward function 0 *)
-Axiom alloc_vec_Vec_index_mut_back :
- forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T))
- (Self : alloc_vec_Vec T) (i : Idx) (x : inst.(core_slice_index_SliceIndex_Output)), result (alloc_vec_Vec T).
+ (Self : alloc_vec_Vec T) (i : Idx),
+ result (inst.(core_slice_index_SliceIndex_Output) *
+ (inst.(core_slice_index_SliceIndex_Output) -> result (alloc_vec_Vec T))).
(* Trait implementation: [alloc::vec::Vec] *)
Definition alloc_vec_Vec_coreopsindexIndexInst (T Idx : Type)
@@ -890,7 +884,6 @@ Definition alloc_vec_Vec_coreopsindexIndexMutInst (T Idx : Type)
core_ops_index_IndexMut (alloc_vec_Vec T) Idx := {|
core_ops_index_IndexMut_indexInst := alloc_vec_Vec_coreopsindexIndexInst T Idx inst;
core_ops_index_IndexMut_index_mut := alloc_vec_Vec_index_mut T Idx inst;
- core_ops_index_IndexMut_index_mut_back := alloc_vec_Vec_index_mut_back T Idx inst;
|}.
(*** Theorems *)
@@ -901,10 +894,6 @@ Axiom alloc_vec_Vec_index_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usiz
Axiom alloc_vec_Vec_index_mut_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usize) (x : a),
alloc_vec_Vec_index_mut a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i =
- alloc_vec_Vec_index_usize v i.
-
-Axiom alloc_vec_Vec_index_mut_back_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usize) (x : a),
- alloc_vec_Vec_index_mut_back a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i x =
- alloc_vec_Vec_update_usize v i x.
+ alloc_vec_Vec_index_mut_usize v i.
End Primitives.
diff --git a/tests/coq/misc/Bitwise.v b/tests/coq/misc/Bitwise.v
index 94771b37..b04c95f2 100644
--- a/tests/coq/misc/Bitwise.v
+++ b/tests/coq/misc/Bitwise.v
@@ -8,29 +8,29 @@ Import ListNotations.
Local Open Scope Primitives_scope.
Module Bitwise.
-(** [bitwise::shift_u32]: forward function
+(** [bitwise::shift_u32]:
Source: 'src/bitwise.rs', lines 3:0-3:31 *)
Definition shift_u32 (a : u32) : result u32 :=
t <- u32_shr a 16%usize; u32_shl t 16%usize
.
-(** [bitwise::shift_i32]: forward function
+(** [bitwise::shift_i32]:
Source: 'src/bitwise.rs', lines 10:0-10:31 *)
Definition shift_i32 (a : i32) : result i32 :=
t <- i32_shr a 16%isize; i32_shl t 16%isize
.
-(** [bitwise::xor_u32]: forward function
+(** [bitwise::xor_u32]:
Source: 'src/bitwise.rs', lines 17:0-17:37 *)
Definition xor_u32 (a : u32) (b : u32) : result u32 :=
Return (u32_xor a b).
-(** [bitwise::or_u32]: forward function
+(** [bitwise::or_u32]:
Source: 'src/bitwise.rs', lines 21:0-21:36 *)
Definition or_u32 (a : u32) (b : u32) : result u32 :=
Return (u32_or a b).
-(** [bitwise::and_u32]: forward function
+(** [bitwise::and_u32]:
Source: 'src/bitwise.rs', lines 25:0-25:37 *)
Definition and_u32 (a : u32) (b : u32) : result u32 :=
Return (u32_and a b).
diff --git a/tests/coq/misc/Constants.v b/tests/coq/misc/Constants.v
index ad899f25..0f33cbd6 100644
--- a/tests/coq/misc/Constants.v
+++ b/tests/coq/misc/Constants.v
@@ -23,7 +23,7 @@ Definition x1_c : u32 := x1_body%global.
Definition x2_body : result u32 := Return 3%u32.
Definition x2_c : u32 := x2_body%global.
-(** [constants::incr]: forward function
+(** [constants::incr]:
Source: 'src/constants.rs', lines 17:0-17:32 *)
Definition incr (n : u32) : result u32 :=
u32_add n 1%u32.
@@ -33,7 +33,7 @@ Definition incr (n : u32) : result u32 :=
Definition x3_body : result u32 := incr 32%u32.
Definition x3_c : u32 := x3_body%global.
-(** [constants::mk_pair0]: forward function
+(** [constants::mk_pair0]:
Source: 'src/constants.rs', lines 23:0-23:51 *)
Definition mk_pair0 (x : u32) (y : u32) : result (u32 * u32) :=
Return (x, y).
@@ -46,7 +46,7 @@ Arguments mkPair_t { _ _ }.
Arguments pair_x { _ _ }.
Arguments pair_y { _ _ }.
-(** [constants::mk_pair1]: forward function
+(** [constants::mk_pair1]:
Source: 'src/constants.rs', lines 27:0-27:55 *)
Definition mk_pair1 (x : u32) (y : u32) : result (Pair_t u32 u32) :=
Return {| pair_x := x; pair_y := y |}
@@ -81,7 +81,7 @@ Record Wrap_t (T : Type) := mkWrap_t { wrap_value : T; }.
Arguments mkWrap_t { _ }.
Arguments wrap_value { _ }.
-(** [constants::{constants::Wrap<T>}::new]: forward function
+(** [constants::{constants::Wrap<T>}::new]:
Source: 'src/constants.rs', lines 54:4-54:41 *)
Definition wrap_new (T : Type) (value : T) : result (Wrap_t T) :=
Return {| wrap_value := value |}
@@ -92,7 +92,7 @@ Definition wrap_new (T : Type) (value : T) : result (Wrap_t T) :=
Definition y_body : result (Wrap_t i32) := wrap_new i32 2%i32.
Definition y_c : Wrap_t i32 := y_body%global.
-(** [constants::unwrap_y]: forward function
+(** [constants::unwrap_y]:
Source: 'src/constants.rs', lines 43:0-43:30 *)
Definition unwrap_y : result i32 :=
Return y_c.(wrap_value).
@@ -107,12 +107,12 @@ Definition yval_c : i32 := yval_body%global.
Definition get_z1_z1_body : result i32 := Return 3%i32.
Definition get_z1_z1_c : i32 := get_z1_z1_body%global.
-(** [constants::get_z1]: forward function
+(** [constants::get_z1]:
Source: 'src/constants.rs', lines 61:0-61:28 *)
Definition get_z1 : result i32 :=
Return get_z1_z1_c.
-(** [constants::add]: forward function
+(** [constants::add]:
Source: 'src/constants.rs', lines 66:0-66:39 *)
Definition add (a : i32) (b : i32) : result i32 :=
i32_add a b.
@@ -132,10 +132,10 @@ Definition q2_c : i32 := q2_body%global.
Definition q3_body : result i32 := add q2_c 3%i32.
Definition q3_c : i32 := q3_body%global.
-(** [constants::get_z2]: forward function
+(** [constants::get_z2]:
Source: 'src/constants.rs', lines 70:0-70:28 *)
Definition get_z2 : result i32 :=
- i <- get_z1; i0 <- add i q3_c; add q1_c i0.
+ i <- get_z1; i1 <- add i q3_c; add q1_c i1.
(** [constants::S1]
Source: 'src/constants.rs', lines 80:0-80:18 *)
diff --git a/tests/coq/misc/External_Funs.v b/tests/coq/misc/External_Funs.v
index e9d39f66..049f5d39 100644
--- a/tests/coq/misc/External_Funs.v
+++ b/tests/coq/misc/External_Funs.v
@@ -12,44 +12,23 @@ Require Import External_FunsExternal.
Include External_FunsExternal.
Module External_Funs.
-(** [external::swap]: forward function
+(** [external::swap]:
Source: 'src/external.rs', lines 6:0-6:46 *)
Definition swap
- (T : Type) (x : T) (y : T) (st : state) : result (state * unit) :=
- p <- core_mem_swap T x y st;
- let (st0, _) := p in
- p0 <- core_mem_swap_back0 T x y st st0;
- let (st1, _) := p0 in
- p1 <- core_mem_swap_back1 T x y st st1;
- let (st2, _) := p1 in
- Return (st2, tt)
+ (T : Type) (x : T) (y : T) (st : state) : result (state * (T * T)) :=
+ core_mem_swap T x y st
.
-(** [external::swap]: backward function 0
- Source: 'src/external.rs', lines 6:0-6:46 *)
-Definition swap_back
- (T : Type) (x : T) (y : T) (st : state) (st0 : state) :
- result (state * (T * T))
- :=
- p <- core_mem_swap T x y st;
- let (st1, _) := p in
- p0 <- core_mem_swap_back0 T x y st st1;
- let (st2, x0) := p0 in
- p1 <- core_mem_swap_back1 T x y st st2;
- let (_, y0) := p1 in
- Return (st0, (x0, y0))
-.
-
-(** [external::test_new_non_zero_u32]: forward function
+(** [external::test_new_non_zero_u32]:
Source: 'src/external.rs', lines 11:0-11:60 *)
Definition test_new_non_zero_u32
(x : u32) (st : state) : result (state * core_num_nonzero_NonZeroU32_t) :=
p <- core_num_nonzero_NonZeroU32_new x st;
- let (st0, o) := p in
- core_option_Option_unwrap core_num_nonzero_NonZeroU32_t o st0
+ let (st1, o) := p in
+ core_option_Option_unwrap core_num_nonzero_NonZeroU32_t o st1
.
-(** [external::test_vec]: forward function
+(** [external::test_vec]:
Source: 'src/external.rs', lines 17:0-17:17 *)
Definition test_vec : result unit :=
let v := alloc_vec_Vec_new u32 in
@@ -60,59 +39,39 @@ Definition test_vec : result unit :=
(** Unit test for [external::test_vec] *)
Check (test_vec )%return.
-(** [external::custom_swap]: forward function
+(** [external::custom_swap]:
Source: 'src/external.rs', lines 24:0-24:66 *)
Definition custom_swap
- (T : Type) (x : T) (y : T) (st : state) : result (state * T) :=
- p <- core_mem_swap T x y st;
- let (st0, _) := p in
- p0 <- core_mem_swap_back0 T x y st st0;
- let (st1, x0) := p0 in
- p1 <- core_mem_swap_back1 T x y st st1;
- let (st2, _) := p1 in
- Return (st2, x0)
-.
-
-(** [external::custom_swap]: backward function 0
- Source: 'src/external.rs', lines 24:0-24:66 *)
-Definition custom_swap_back
- (T : Type) (x : T) (y : T) (st : state) (ret : T) (st0 : state) :
- result (state * (T * T))
+ (T : Type) (x : T) (y : T) (st : state) :
+ result (state * (T * (T -> state -> result (state * (T * T)))))
:=
p <- core_mem_swap T x y st;
- let (st1, _) := p in
- p0 <- core_mem_swap_back0 T x y st st1;
- let (st2, _) := p0 in
- p1 <- core_mem_swap_back1 T x y st st2;
- let (_, y0) := p1 in
- Return (st0, (ret, y0))
+ let (st1, p1) := p in
+ let (t, t1) := p1 in
+ let back_'a := fun (ret : T) (st2 : state) => Return (st2, (ret, t1)) in
+ Return (st1, (t, back_'a))
.
-(** [external::test_custom_swap]: forward function
+(** [external::test_custom_swap]:
Source: 'src/external.rs', lines 29:0-29:59 *)
Definition test_custom_swap
- (x : u32) (y : u32) (st : state) : result (state * unit) :=
- p <- custom_swap u32 x y st; let (st0, _) := p in Return (st0, tt)
-.
-
-(** [external::test_custom_swap]: backward function 0
- Source: 'src/external.rs', lines 29:0-29:59 *)
-Definition test_custom_swap_back
- (x : u32) (y : u32) (st : state) (st0 : state) :
- result (state * (u32 * u32))
- :=
- custom_swap_back u32 x y st 1%u32 st0
+ (x : u32) (y : u32) (st : state) : result (state * (u32 * u32)) :=
+ p <- custom_swap u32 x y st;
+ let (st1, p1) := p in
+ let (_, custom_swap_back) := p1 in
+ p2 <- custom_swap_back 1%u32 st1;
+ let (_, p3) := p2 in
+ let (x1, y1) := p3 in
+ Return (st1, (x1, y1))
.
-(** [external::test_swap_non_zero]: forward function
+(** [external::test_swap_non_zero]:
Source: 'src/external.rs', lines 35:0-35:44 *)
Definition test_swap_non_zero (x : u32) (st : state) : result (state * u32) :=
p <- swap u32 x 0%u32 st;
- let (st0, _) := p in
- p0 <- swap_back u32 x 0%u32 st st0;
- let (st1, p1) := p0 in
- let (x0, _) := p1 in
- if x0 s= 0%u32 then Fail_ Failure else Return (st1, x0)
+ let (st1, p1) := p in
+ let (x1, _) := p1 in
+ if x1 s= 0%u32 then Fail_ Failure else Return (st1, x1)
.
End External_Funs.
diff --git a/tests/coq/misc/External_FunsExternal_Template.v b/tests/coq/misc/External_FunsExternal_Template.v
index 31e69c39..6773ac18 100644
--- a/tests/coq/misc/External_FunsExternal_Template.v
+++ b/tests/coq/misc/External_FunsExternal_Template.v
@@ -11,31 +11,19 @@ Require Import External_Types.
Include External_Types.
Module External_FunsExternal_Template.
-(** [core::mem::swap]: forward function
+(** [core::mem::swap]:
Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/mem/mod.rs', lines 726:0-726:42 *)
Axiom core_mem_swap :
- forall(T : Type), T -> T -> state -> result (state * unit)
+ forall(T : Type), T -> T -> state -> result (state * (T * T))
.
-(** [core::mem::swap]: backward function 0
- Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/mem/mod.rs', lines 726:0-726:42 *)
-Axiom core_mem_swap_back0 :
- forall(T : Type), T -> T -> state -> state -> result (state * T)
-.
-
-(** [core::mem::swap]: backward function 1
- Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/mem/mod.rs', lines 726:0-726:42 *)
-Axiom core_mem_swap_back1 :
- forall(T : Type), T -> T -> state -> state -> result (state * T)
-.
-
-(** [core::num::nonzero::{core::num::nonzero::NonZeroU32#14}::new]: forward function
+(** [core::num::nonzero::{core::num::nonzero::NonZeroU32#14}::new]:
Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/num/nonzero.rs', lines 79:16-79:57 *)
Axiom core_num_nonzero_NonZeroU32_new
: u32 -> state -> result (state * (option core_num_nonzero_NonZeroU32_t))
.
-(** [core::option::{core::option::Option<T>}::unwrap]: forward function
+(** [core::option::{core::option::Option<T>}::unwrap]:
Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/option.rs', lines 932:4-932:34 *)
Axiom core_option_Option_unwrap :
forall(T : Type), option T -> state -> result (state * T)
diff --git a/tests/coq/misc/Loops.v b/tests/coq/misc/Loops.v
index 83c249c1..313c2cfd 100644
--- a/tests/coq/misc/Loops.v
+++ b/tests/coq/misc/Loops.v
@@ -8,90 +8,90 @@ Import ListNotations.
Local Open Scope Primitives_scope.
Module Loops.
-(** [loops::sum]: loop 0: forward function
+(** [loops::sum]: loop 0:
Source: 'src/loops.rs', lines 4:0-14:1 *)
Fixpoint sum_loop (n : nat) (max : u32) (i : u32) (s : u32) : result u32 :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
if i s< max
- then (s0 <- u32_add s i; i0 <- u32_add i 1%u32; sum_loop n0 max i0 s0)
+ then (s1 <- u32_add s i; i1 <- u32_add i 1%u32; sum_loop n1 max i1 s1)
else u32_mul s 2%u32
end
.
-(** [loops::sum]: forward function
+(** [loops::sum]:
Source: 'src/loops.rs', lines 4:0-4:27 *)
Definition sum (n : nat) (max : u32) : result u32 :=
sum_loop n max 0%u32 0%u32
.
-(** [loops::sum_with_mut_borrows]: loop 0: forward function
+(** [loops::sum_with_mut_borrows]: loop 0:
Source: 'src/loops.rs', lines 19:0-31:1 *)
Fixpoint sum_with_mut_borrows_loop
(n : nat) (max : u32) (mi : u32) (ms : u32) : result u32 :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
if mi s< max
then (
- ms0 <- u32_add ms mi;
- mi0 <- u32_add mi 1%u32;
- sum_with_mut_borrows_loop n0 max mi0 ms0)
+ ms1 <- u32_add ms mi;
+ mi1 <- u32_add mi 1%u32;
+ sum_with_mut_borrows_loop n1 max mi1 ms1)
else u32_mul ms 2%u32
end
.
-(** [loops::sum_with_mut_borrows]: forward function
+(** [loops::sum_with_mut_borrows]:
Source: 'src/loops.rs', lines 19:0-19:44 *)
Definition sum_with_mut_borrows (n : nat) (max : u32) : result u32 :=
sum_with_mut_borrows_loop n max 0%u32 0%u32
.
-(** [loops::sum_with_shared_borrows]: loop 0: forward function
+(** [loops::sum_with_shared_borrows]: loop 0:
Source: 'src/loops.rs', lines 34:0-48:1 *)
Fixpoint sum_with_shared_borrows_loop
(n : nat) (max : u32) (i : u32) (s : u32) : result u32 :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
if i s< max
then (
- i0 <- u32_add i 1%u32;
- s0 <- u32_add s i0;
- sum_with_shared_borrows_loop n0 max i0 s0)
+ i1 <- u32_add i 1%u32;
+ s1 <- u32_add s i1;
+ sum_with_shared_borrows_loop n1 max i1 s1)
else u32_mul s 2%u32
end
.
-(** [loops::sum_with_shared_borrows]: forward function
+(** [loops::sum_with_shared_borrows]:
Source: 'src/loops.rs', lines 34:0-34:47 *)
Definition sum_with_shared_borrows (n : nat) (max : u32) : result u32 :=
sum_with_shared_borrows_loop n max 0%u32 0%u32
.
-(** [loops::clear]: loop 0: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [loops::clear]: loop 0:
Source: 'src/loops.rs', lines 52:0-58:1 *)
Fixpoint clear_loop
(n : nat) (v : alloc_vec_Vec u32) (i : usize) : result (alloc_vec_Vec u32) :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
- let i0 := alloc_vec_Vec_len u32 v in
- if i s< i0
+ | S n1 =>
+ let i1 := alloc_vec_Vec_len u32 v in
+ if i s< i1
then (
- i1 <- usize_add i 1%usize;
- v0 <-
- alloc_vec_Vec_index_mut_back u32 usize
- (core_slice_index_SliceIndexUsizeSliceTInst u32) v i 0%u32;
- clear_loop n0 v0 i1)
+ p <-
+ alloc_vec_Vec_index_mut u32 usize
+ (core_slice_index_SliceIndexUsizeSliceTInst u32) v i;
+ let (_, index_mut_back) := p in
+ i2 <- usize_add i 1%usize;
+ v1 <- index_mut_back 0%u32;
+ clear_loop n1 v1 i2)
else Return v
end
.
-(** [loops::clear]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [loops::clear]:
Source: 'src/loops.rs', lines 52:0-52:30 *)
Definition clear
(n : nat) (v : alloc_vec_Vec u32) : result (alloc_vec_Vec u32) :=
@@ -108,181 +108,146 @@ Inductive List_t (T : Type) :=
Arguments List_Cons { _ }.
Arguments List_Nil { _ }.
-(** [loops::list_mem]: loop 0: forward function
+(** [loops::list_mem]: loop 0:
Source: 'src/loops.rs', lines 66:0-75:1 *)
Fixpoint list_mem_loop (n : nat) (x : u32) (ls : List_t u32) : result bool :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
- | List_Cons y tl => if y s= x then Return true else list_mem_loop n0 x tl
+ | List_Cons y tl => if y s= x then Return true else list_mem_loop n1 x tl
| List_Nil => Return false
end
end
.
-(** [loops::list_mem]: forward function
+(** [loops::list_mem]:
Source: 'src/loops.rs', lines 66:0-66: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: forward function
+(** [loops::list_nth_mut_loop]: loop 0:
Source: 'src/loops.rs', lines 78:0-88:1 *)
Fixpoint list_nth_mut_loop_loop
- (T : Type) (n : nat) (ls : List_t T) (i : u32) : result T :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls with
- | List_Cons x tl =>
- if i s= 0%u32
- then Return x
- else (i0 <- u32_sub i 1%u32; list_nth_mut_loop_loop T n0 tl i0)
- | List_Nil => Fail_ Failure
- end
- end
-.
-
-(** [loops::list_nth_mut_loop]: forward function
- Source: 'src/loops.rs', lines 78:0-78:71 *)
-Definition list_nth_mut_loop
- (T : Type) (n : nat) (ls : List_t T) (i : u32) : result T :=
- list_nth_mut_loop_loop T n ls i
-.
-
-(** [loops::list_nth_mut_loop]: loop 0: backward function 0
- Source: 'src/loops.rs', lines 78:0-88:1 *)
-Fixpoint list_nth_mut_loop_loop_back
- (T : Type) (n : nat) (ls : List_t T) (i : u32) (ret : T) :
- result (List_t T)
+ (T : Type) (n : nat) (ls : List_t T) (i : u32) :
+ result (T * (T -> result (List_t T)))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| List_Cons x tl =>
if i s= 0%u32
- then Return (List_Cons ret tl)
+ then
+ let back := fun (ret : T) => Return (List_Cons ret tl) in
+ Return (x, back)
else (
- i0 <- u32_sub i 1%u32;
- tl0 <- list_nth_mut_loop_loop_back T n0 tl i0 ret;
- Return (List_Cons x tl0))
+ i1 <- u32_sub i 1%u32;
+ p <- list_nth_mut_loop_loop T n1 tl i1;
+ let (t, back) := p in
+ let back1 := fun (ret : T) => tl1 <- back ret; Return (List_Cons x tl1)
+ in
+ Return (t, back1))
| List_Nil => Fail_ Failure
end
end
.
-(** [loops::list_nth_mut_loop]: backward function 0
+(** [loops::list_nth_mut_loop]:
Source: 'src/loops.rs', lines 78:0-78:71 *)
-Definition list_nth_mut_loop_back
- (T : Type) (n : nat) (ls : List_t T) (i : u32) (ret : T) :
- result (List_t T)
+Definition list_nth_mut_loop
+ (T : Type) (n : nat) (ls : List_t T) (i : u32) :
+ result (T * (T -> result (List_t T)))
:=
- list_nth_mut_loop_loop_back T n ls i ret
+ p <- list_nth_mut_loop_loop T n ls i;
+ let (t, back) := p in
+ let back1 := fun (ret : T) => back ret in
+ Return (t, back1)
.
-(** [loops::list_nth_shared_loop]: loop 0: forward function
+(** [loops::list_nth_shared_loop]: loop 0:
Source: 'src/loops.rs', lines 91:0-101:1 *)
Fixpoint list_nth_shared_loop_loop
(T : Type) (n : nat) (ls : List_t T) (i : u32) : result T :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| List_Cons x tl =>
if i s= 0%u32
then Return x
- else (i0 <- u32_sub i 1%u32; list_nth_shared_loop_loop T n0 tl i0)
+ else (i1 <- u32_sub i 1%u32; list_nth_shared_loop_loop T n1 tl i1)
| List_Nil => Fail_ Failure
end
end
.
-(** [loops::list_nth_shared_loop]: forward function
+(** [loops::list_nth_shared_loop]:
Source: 'src/loops.rs', lines 91:0-91: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: forward function
+(** [loops::get_elem_mut]: loop 0:
Source: 'src/loops.rs', lines 103:0-117:1 *)
Fixpoint get_elem_mut_loop
- (n : nat) (x : usize) (ls : List_t usize) : result usize :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls with
- | List_Cons y tl => if y s= x then Return y else get_elem_mut_loop n0 x tl
- | List_Nil => Fail_ Failure
- end
- end
-.
-
-(** [loops::get_elem_mut]: forward function
- Source: 'src/loops.rs', lines 103:0-103:73 *)
-Definition get_elem_mut
- (n : nat) (slots : alloc_vec_Vec (List_t usize)) (x : usize) :
- result usize
- :=
- l <-
- alloc_vec_Vec_index_mut (List_t usize) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (List_t usize)) slots 0%usize;
- get_elem_mut_loop n x l
-.
-
-(** [loops::get_elem_mut]: loop 0: backward function 0
- Source: 'src/loops.rs', lines 103:0-117:1 *)
-Fixpoint get_elem_mut_loop_back
- (n : nat) (x : usize) (ls : List_t usize) (ret : usize) :
- result (List_t usize)
+ (n : nat) (x : usize) (ls : List_t usize) :
+ result (usize * (usize -> result (List_t usize)))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| List_Cons y tl =>
if y s= x
- then Return (List_Cons ret tl)
+ then
+ let back := fun (ret : usize) => Return (List_Cons ret tl) in
+ Return (y, back)
else (
- tl0 <- get_elem_mut_loop_back n0 x tl ret; Return (List_Cons y tl0))
+ p <- get_elem_mut_loop n1 x tl;
+ let (i, back) := p in
+ let back1 :=
+ fun (ret : usize) => tl1 <- back ret; Return (List_Cons y tl1) in
+ Return (i, back1))
| List_Nil => Fail_ Failure
end
end
.
-(** [loops::get_elem_mut]: backward function 0
+(** [loops::get_elem_mut]:
Source: 'src/loops.rs', lines 103:0-103:73 *)
-Definition get_elem_mut_back
- (n : nat) (slots : alloc_vec_Vec (List_t usize)) (x : usize) (ret : usize) :
- result (alloc_vec_Vec (List_t usize))
+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))))
:=
- l <-
+ p <-
alloc_vec_Vec_index_mut (List_t usize) usize
(core_slice_index_SliceIndexUsizeSliceTInst (List_t usize)) slots 0%usize;
- l0 <- get_elem_mut_loop_back n x l ret;
- alloc_vec_Vec_index_mut_back (List_t usize) usize
- (core_slice_index_SliceIndexUsizeSliceTInst (List_t usize)) slots 0%usize
- l0
+ let (l, index_mut_back) := p in
+ p1 <- get_elem_mut_loop n x l;
+ let (i, back) := p1 in
+ let back1 := fun (ret : usize) => l1 <- back ret; index_mut_back l1 in
+ Return (i, back1)
.
-(** [loops::get_elem_shared]: loop 0: forward function
+(** [loops::get_elem_shared]: loop 0:
Source: 'src/loops.rs', lines 119:0-133:1 *)
Fixpoint get_elem_shared_loop
(n : nat) (x : usize) (ls : List_t usize) : result usize :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| List_Cons y tl =>
- if y s= x then Return y else get_elem_shared_loop n0 x tl
+ if y s= x then Return y else get_elem_shared_loop n1 x tl
| List_Nil => Fail_ Failure
end
end
.
-(** [loops::get_elem_shared]: forward function
+(** [loops::get_elem_shared]:
Source: 'src/loops.rs', lines 119:0-119:68 *)
Definition get_elem_shared
(n : nat) (slots : alloc_vec_Vec (List_t usize)) (x : usize) :
@@ -294,123 +259,114 @@ Definition get_elem_shared
get_elem_shared_loop n x l
.
-(** [loops::id_mut]: forward function
- Source: 'src/loops.rs', lines 135:0-135:50 *)
-Definition id_mut (T : Type) (ls : List_t T) : result (List_t T) :=
- Return ls.
-
-(** [loops::id_mut]: backward function 0
+(** [loops::id_mut]:
Source: 'src/loops.rs', lines 135:0-135:50 *)
-Definition id_mut_back
- (T : Type) (ls : List_t T) (ret : List_t T) : result (List_t T) :=
- Return ret
+Definition id_mut
+ (T : Type) (ls : List_t T) :
+ result ((List_t T) * (List_t T -> result (List_t T)))
+ :=
+ let back := fun (ret : List_t T) => Return ret in Return (ls, back)
.
-(** [loops::id_shared]: forward function
+(** [loops::id_shared]:
Source: 'src/loops.rs', lines 139:0-139: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: forward function
+(** [loops::list_nth_mut_loop_with_id]: loop 0:
Source: 'src/loops.rs', lines 144:0-155:1 *)
Fixpoint list_nth_mut_loop_with_id_loop
- (T : Type) (n : nat) (i : u32) (ls : List_t T) : result T :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls with
- | List_Cons x tl =>
- if i s= 0%u32
- then Return x
- else (i0 <- u32_sub i 1%u32; list_nth_mut_loop_with_id_loop T n0 i0 tl)
- | List_Nil => Fail_ Failure
- end
- end
-.
-
-(** [loops::list_nth_mut_loop_with_id]: forward function
- Source: 'src/loops.rs', lines 144:0-144:75 *)
-Definition list_nth_mut_loop_with_id
- (T : Type) (n : nat) (ls : List_t T) (i : u32) : result T :=
- ls0 <- id_mut T ls; list_nth_mut_loop_with_id_loop T n i ls0
-.
-
-(** [loops::list_nth_mut_loop_with_id]: loop 0: backward function 0
- Source: 'src/loops.rs', lines 144:0-155:1 *)
-Fixpoint list_nth_mut_loop_with_id_loop_back
- (T : Type) (n : nat) (i : u32) (ls : List_t T) (ret : T) :
- result (List_t T)
+ (T : Type) (n : nat) (i : u32) (ls : List_t T) :
+ result (T * (T -> result (List_t T)))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| List_Cons x tl =>
if i s= 0%u32
- then Return (List_Cons ret tl)
+ then
+ let back := fun (ret : T) => Return (List_Cons ret tl) in
+ Return (x, back)
else (
- i0 <- u32_sub i 1%u32;
- tl0 <- list_nth_mut_loop_with_id_loop_back T n0 i0 tl ret;
- Return (List_Cons x tl0))
+ i1 <- u32_sub i 1%u32;
+ p <- list_nth_mut_loop_with_id_loop T n1 i1 tl;
+ let (t, back) := p in
+ let back1 := fun (ret : T) => tl1 <- back ret; Return (List_Cons x tl1)
+ in
+ Return (t, back1))
| List_Nil => Fail_ Failure
end
end
.
-(** [loops::list_nth_mut_loop_with_id]: backward function 0
+(** [loops::list_nth_mut_loop_with_id]:
Source: 'src/loops.rs', lines 144:0-144:75 *)
-Definition list_nth_mut_loop_with_id_back
- (T : Type) (n : nat) (ls : List_t T) (i : u32) (ret : T) :
- result (List_t T)
+Definition list_nth_mut_loop_with_id
+ (T : Type) (n : nat) (ls : List_t T) (i : u32) :
+ result (T * (T -> result (List_t T)))
:=
- ls0 <- id_mut T ls;
- l <- list_nth_mut_loop_with_id_loop_back T n i ls0 ret;
- id_mut_back T ls l
+ p <- id_mut T ls;
+ let (ls1, id_mut_back) := p in
+ p1 <- list_nth_mut_loop_with_id_loop T n i ls1;
+ let (t, back) := p1 in
+ let back1 := fun (ret : T) => l <- back ret; id_mut_back l in
+ Return (t, back1)
.
-(** [loops::list_nth_shared_loop_with_id]: loop 0: forward function
+(** [loops::list_nth_shared_loop_with_id]: loop 0:
Source: 'src/loops.rs', lines 158:0-169:1 *)
Fixpoint list_nth_shared_loop_with_id_loop
(T : Type) (n : nat) (i : u32) (ls : List_t T) : result T :=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls with
| List_Cons x tl =>
if i s= 0%u32
then Return x
else (
- i0 <- u32_sub i 1%u32; list_nth_shared_loop_with_id_loop T n0 i0 tl)
+ i1 <- u32_sub i 1%u32; list_nth_shared_loop_with_id_loop T n1 i1 tl)
| List_Nil => Fail_ Failure
end
end
.
-(** [loops::list_nth_shared_loop_with_id]: forward function
+(** [loops::list_nth_shared_loop_with_id]:
Source: 'src/loops.rs', lines 158:0-158:70 *)
Definition list_nth_shared_loop_with_id
(T : Type) (n : nat) (ls : List_t T) (i : u32) : result T :=
- ls0 <- id_shared T ls; list_nth_shared_loop_with_id_loop T n i ls0
+ ls1 <- id_shared T ls; list_nth_shared_loop_with_id_loop T n i ls1
.
-(** [loops::list_nth_mut_loop_pair]: loop 0: forward function
+(** [loops::list_nth_mut_loop_pair]: loop 0:
Source: 'src/loops.rs', lines 174:0-195: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)
+ result ((T * T) * (T -> result (List_t T)) * (T -> result (List_t T)))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls0 with
| List_Cons x0 tl0 =>
match ls1 with
| List_Cons x1 tl1 =>
if i s= 0%u32
- then Return (x0, x1)
+ then
+ let back_'a := fun (ret : T) => Return (List_Cons ret tl0) in
+ let back_'b := fun (ret : T) => Return (List_Cons ret tl1) in
+ Return ((x0, x1), back_'a, back_'b)
else (
- i0 <- u32_sub i 1%u32; list_nth_mut_loop_pair_loop T n0 tl0 tl1 i0)
+ i1 <- u32_sub i 1%u32;
+ t <- list_nth_mut_loop_pair_loop T n1 tl0 tl1 i1;
+ let (p, back_'a, back_'b) := t in
+ let back_'a1 :=
+ fun (ret : T) => tl01 <- back_'a ret; Return (List_Cons x0 tl01) in
+ let back_'b1 :=
+ fun (ret : T) => tl11 <- back_'b ret; Return (List_Cons x1 tl11) in
+ Return (p, back_'a1, back_'b1))
| List_Nil => Fail_ Failure
end
| List_Nil => Fail_ Failure
@@ -418,86 +374,20 @@ Fixpoint list_nth_mut_loop_pair_loop
end
.
-(** [loops::list_nth_mut_loop_pair]: forward function
+(** [loops::list_nth_mut_loop_pair]:
Source: 'src/loops.rs', lines 174:0-178:27 *)
Definition list_nth_mut_loop_pair
(T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) :
- result (T * T)
+ result ((T * T) * (T -> result (List_t T)) * (T -> result (List_t T)))
:=
- list_nth_mut_loop_pair_loop T n ls0 ls1 i
+ t <- list_nth_mut_loop_pair_loop T n ls0 ls1 i;
+ let (p, back_'a, back_'b) := t in
+ let back_'a1 := fun (ret : T) => back_'a ret in
+ let back_'b1 := fun (ret : T) => back_'b ret in
+ Return (p, back_'a1, back_'b1)
.
-(** [loops::list_nth_mut_loop_pair]: loop 0: backward function 0
- Source: 'src/loops.rs', lines 174:0-195:1 *)
-Fixpoint list_nth_mut_loop_pair_loop_back'a
- (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) (ret : T) :
- result (List_t T)
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls0 with
- | List_Cons x0 tl0 =>
- match ls1 with
- | List_Cons x1 tl1 =>
- if i s= 0%u32
- then Return (List_Cons ret tl0)
- else (
- i0 <- u32_sub i 1%u32;
- tl00 <- list_nth_mut_loop_pair_loop_back'a T n0 tl0 tl1 i0 ret;
- Return (List_Cons x0 tl00))
- | List_Nil => Fail_ Failure
- end
- | List_Nil => Fail_ Failure
- end
- end
-.
-
-(** [loops::list_nth_mut_loop_pair]: backward function 0
- Source: 'src/loops.rs', lines 174:0-178:27 *)
-Definition list_nth_mut_loop_pair_back'a
- (T : Type) (n : nat) (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 n ls0 ls1 i ret
-.
-
-(** [loops::list_nth_mut_loop_pair]: loop 0: backward function 1
- Source: 'src/loops.rs', lines 174:0-195:1 *)
-Fixpoint list_nth_mut_loop_pair_loop_back'b
- (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) (ret : T) :
- result (List_t T)
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls0 with
- | List_Cons x0 tl0 =>
- match ls1 with
- | List_Cons x1 tl1 =>
- if i s= 0%u32
- then Return (List_Cons ret tl1)
- else (
- i0 <- u32_sub i 1%u32;
- tl10 <- list_nth_mut_loop_pair_loop_back'b T n0 tl0 tl1 i0 ret;
- Return (List_Cons x1 tl10))
- | List_Nil => Fail_ Failure
- end
- | List_Nil => Fail_ Failure
- end
- end
-.
-
-(** [loops::list_nth_mut_loop_pair]: backward function 1
- Source: 'src/loops.rs', lines 174:0-178:27 *)
-Definition list_nth_mut_loop_pair_back'b
- (T : Type) (n : nat) (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 n ls0 ls1 i ret
-.
-
-(** [loops::list_nth_shared_loop_pair]: loop 0: forward function
+(** [loops::list_nth_shared_loop_pair]: loop 0:
Source: 'src/loops.rs', lines 198:0-219:1 *)
Fixpoint list_nth_shared_loop_pair_loop
(T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) :
@@ -505,7 +395,7 @@ Fixpoint list_nth_shared_loop_pair_loop
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls0 with
| List_Cons x0 tl0 =>
match ls1 with
@@ -513,7 +403,7 @@ Fixpoint list_nth_shared_loop_pair_loop
if i s= 0%u32
then Return (x0, x1)
else (
- i0 <- u32_sub i 1%u32; list_nth_shared_loop_pair_loop T n0 tl0 tl1 i0)
+ i1 <- u32_sub i 1%u32; list_nth_shared_loop_pair_loop T n1 tl0 tl1 i1)
| List_Nil => Fail_ Failure
end
| List_Nil => Fail_ Failure
@@ -521,7 +411,7 @@ Fixpoint list_nth_shared_loop_pair_loop
end
.
-(** [loops::list_nth_shared_loop_pair]: forward function
+(** [loops::list_nth_shared_loop_pair]:
Source: 'src/loops.rs', lines 198:0-202:19 *)
Definition list_nth_shared_loop_pair
(T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) :
@@ -530,24 +420,36 @@ Definition list_nth_shared_loop_pair
list_nth_shared_loop_pair_loop T n ls0 ls1 i
.
-(** [loops::list_nth_mut_loop_pair_merge]: loop 0: forward function
+(** [loops::list_nth_mut_loop_pair_merge]: loop 0:
Source: 'src/loops.rs', lines 223:0-238: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)
+ result ((T * T) * ((T * T) -> result ((List_t T) * (List_t T))))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls0 with
| List_Cons x0 tl0 =>
match ls1 with
| List_Cons x1 tl1 =>
if i s= 0%u32
- then Return (x0, x1)
+ then
+ let back_'a :=
+ fun (ret : (T * T)) =>
+ let (t, t1) := ret in Return (List_Cons t tl0, List_Cons t1 tl1)
+ in
+ Return ((x0, x1), back_'a)
else (
- i0 <- u32_sub i 1%u32;
- list_nth_mut_loop_pair_merge_loop T n0 tl0 tl1 i0)
+ i1 <- u32_sub i 1%u32;
+ p <- list_nth_mut_loop_pair_merge_loop T n1 tl0 tl1 i1;
+ let (p1, back_'a) := p in
+ let back_'a1 :=
+ fun (ret : (T * T)) =>
+ p2 <- back_'a ret;
+ let (tl01, tl11) := p2 in
+ Return (List_Cons x0 tl01, List_Cons x1 tl11) in
+ Return (p1, back_'a1))
| List_Nil => Fail_ Failure
end
| List_Nil => Fail_ Failure
@@ -555,54 +457,19 @@ Fixpoint list_nth_mut_loop_pair_merge_loop
end
.
-(** [loops::list_nth_mut_loop_pair_merge]: forward function
+(** [loops::list_nth_mut_loop_pair_merge]:
Source: 'src/loops.rs', lines 223:0-227: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)
+ result ((T * T) * ((T * T) -> result ((List_t T) * (List_t T))))
:=
- list_nth_mut_loop_pair_merge_loop T n ls0 ls1 i
+ p <- list_nth_mut_loop_pair_merge_loop T n ls0 ls1 i;
+ let (p1, back_'a) := p in
+ let back_'a1 := fun (ret : (T * T)) => back_'a ret in
+ Return (p1, back_'a1)
.
-(** [loops::list_nth_mut_loop_pair_merge]: loop 0: backward function 0
- Source: 'src/loops.rs', lines 223:0-238:1 *)
-Fixpoint list_nth_mut_loop_pair_merge_loop_back
- (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32)
- (ret : (T * T)) :
- result ((List_t T) * (List_t T))
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls0 with
- | List_Cons x0 tl0 =>
- match ls1 with
- | List_Cons x1 tl1 =>
- if i s= 0%u32
- then let (t, t0) := ret in Return (List_Cons t tl0, List_Cons t0 tl1)
- else (
- i0 <- u32_sub i 1%u32;
- p <- list_nth_mut_loop_pair_merge_loop_back T n0 tl0 tl1 i0 ret;
- let (tl00, tl10) := p in
- Return (List_Cons x0 tl00, List_Cons x1 tl10))
- | List_Nil => Fail_ Failure
- end
- | List_Nil => Fail_ Failure
- end
- end
-.
-
-(** [loops::list_nth_mut_loop_pair_merge]: backward function 0
- Source: 'src/loops.rs', lines 223:0-227:27 *)
-Definition list_nth_mut_loop_pair_merge_back
- (T : Type) (n : nat) (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 n ls0 ls1 i ret
-.
-
-(** [loops::list_nth_shared_loop_pair_merge]: loop 0: forward function
+(** [loops::list_nth_shared_loop_pair_merge]: loop 0:
Source: 'src/loops.rs', lines 241:0-256:1 *)
Fixpoint list_nth_shared_loop_pair_merge_loop
(T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) :
@@ -610,7 +477,7 @@ Fixpoint list_nth_shared_loop_pair_merge_loop
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls0 with
| List_Cons x0 tl0 =>
match ls1 with
@@ -618,8 +485,8 @@ Fixpoint list_nth_shared_loop_pair_merge_loop
if i s= 0%u32
then Return (x0, x1)
else (
- i0 <- u32_sub i 1%u32;
- list_nth_shared_loop_pair_merge_loop T n0 tl0 tl1 i0)
+ i1 <- u32_sub i 1%u32;
+ list_nth_shared_loop_pair_merge_loop T n1 tl0 tl1 i1)
| List_Nil => Fail_ Failure
end
| List_Nil => Fail_ Failure
@@ -627,7 +494,7 @@ Fixpoint list_nth_shared_loop_pair_merge_loop
end
.
-(** [loops::list_nth_shared_loop_pair_merge]: forward function
+(** [loops::list_nth_shared_loop_pair_merge]:
Source: 'src/loops.rs', lines 241:0-245:19 *)
Definition list_nth_shared_loop_pair_merge
(T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) :
@@ -636,24 +503,30 @@ Definition list_nth_shared_loop_pair_merge
list_nth_shared_loop_pair_merge_loop T n ls0 ls1 i
.
-(** [loops::list_nth_mut_shared_loop_pair]: loop 0: forward function
+(** [loops::list_nth_mut_shared_loop_pair]: loop 0:
Source: 'src/loops.rs', lines 259:0-274: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)
+ result ((T * T) * (T -> result (List_t T)))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls0 with
| List_Cons x0 tl0 =>
match ls1 with
| List_Cons x1 tl1 =>
if i s= 0%u32
- then Return (x0, x1)
+ then
+ let back_'a := fun (ret : T) => Return (List_Cons ret tl0) in
+ Return ((x0, x1), back_'a)
else (
- i0 <- u32_sub i 1%u32;
- list_nth_mut_shared_loop_pair_loop T n0 tl0 tl1 i0)
+ i1 <- u32_sub i 1%u32;
+ p <- list_nth_mut_shared_loop_pair_loop T n1 tl0 tl1 i1;
+ let (p1, back_'a) := p in
+ let back_'a1 :=
+ fun (ret : T) => tl01 <- back_'a ret; Return (List_Cons x0 tl01) in
+ Return (p1, back_'a1))
| List_Nil => Fail_ Failure
end
| List_Nil => Fail_ Failure
@@ -661,68 +534,42 @@ Fixpoint list_nth_mut_shared_loop_pair_loop
end
.
-(** [loops::list_nth_mut_shared_loop_pair]: forward function
+(** [loops::list_nth_mut_shared_loop_pair]:
Source: 'src/loops.rs', lines 259:0-263: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)
+ result ((T * T) * (T -> result (List_t T)))
:=
- list_nth_mut_shared_loop_pair_loop T n ls0 ls1 i
+ p <- list_nth_mut_shared_loop_pair_loop T n ls0 ls1 i;
+ let (p1, back_'a) := p in
+ let back_'a1 := fun (ret : T) => back_'a ret in
+ Return (p1, back_'a1)
.
-(** [loops::list_nth_mut_shared_loop_pair]: loop 0: backward function 0
- Source: 'src/loops.rs', lines 259:0-274:1 *)
-Fixpoint list_nth_mut_shared_loop_pair_loop_back
- (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) (ret : T) :
- result (List_t T)
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls0 with
- | List_Cons x0 tl0 =>
- match ls1 with
- | List_Cons x1 tl1 =>
- if i s= 0%u32
- then Return (List_Cons ret tl0)
- else (
- i0 <- u32_sub i 1%u32;
- tl00 <- list_nth_mut_shared_loop_pair_loop_back T n0 tl0 tl1 i0 ret;
- Return (List_Cons x0 tl00))
- | List_Nil => Fail_ Failure
- end
- | List_Nil => Fail_ Failure
- end
- end
-.
-
-(** [loops::list_nth_mut_shared_loop_pair]: backward function 0
- Source: 'src/loops.rs', lines 259:0-263:23 *)
-Definition list_nth_mut_shared_loop_pair_back
- (T : Type) (n : nat) (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 n ls0 ls1 i ret
-.
-
-(** [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: forward function
+(** [loops::list_nth_mut_shared_loop_pair_merge]: loop 0:
Source: 'src/loops.rs', lines 278:0-293: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)
+ result ((T * T) * (T -> result (List_t T)))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls0 with
| List_Cons x0 tl0 =>
match ls1 with
| List_Cons x1 tl1 =>
if i s= 0%u32
- then Return (x0, x1)
+ then
+ let back_'a := fun (ret : T) => Return (List_Cons ret tl0) in
+ Return ((x0, x1), back_'a)
else (
- i0 <- u32_sub i 1%u32;
- list_nth_mut_shared_loop_pair_merge_loop T n0 tl0 tl1 i0)
+ i1 <- u32_sub i 1%u32;
+ p <- list_nth_mut_shared_loop_pair_merge_loop T n1 tl0 tl1 i1;
+ let (p1, back_'a) := p in
+ let back_'a1 :=
+ fun (ret : T) => tl01 <- back_'a ret; Return (List_Cons x0 tl01) in
+ Return (p1, back_'a1))
| List_Nil => Fail_ Failure
end
| List_Nil => Fail_ Failure
@@ -730,69 +577,42 @@ Fixpoint list_nth_mut_shared_loop_pair_merge_loop
end
.
-(** [loops::list_nth_mut_shared_loop_pair_merge]: forward function
+(** [loops::list_nth_mut_shared_loop_pair_merge]:
Source: 'src/loops.rs', lines 278:0-282: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)
- :=
- list_nth_mut_shared_loop_pair_merge_loop T n ls0 ls1 i
-.
-
-(** [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: backward function 0
- Source: 'src/loops.rs', lines 278:0-293:1 *)
-Fixpoint list_nth_mut_shared_loop_pair_merge_loop_back
- (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) (ret : T) :
- result (List_t T)
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls0 with
- | List_Cons x0 tl0 =>
- match ls1 with
- | List_Cons x1 tl1 =>
- if i s= 0%u32
- then Return (List_Cons ret tl0)
- else (
- i0 <- u32_sub i 1%u32;
- tl00 <-
- list_nth_mut_shared_loop_pair_merge_loop_back T n0 tl0 tl1 i0 ret;
- Return (List_Cons x0 tl00))
- | List_Nil => Fail_ Failure
- end
- | List_Nil => Fail_ Failure
- end
- end
-.
-
-(** [loops::list_nth_mut_shared_loop_pair_merge]: backward function 0
- Source: 'src/loops.rs', lines 278:0-282:23 *)
-Definition list_nth_mut_shared_loop_pair_merge_back
- (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) (ret : T) :
- result (List_t T)
+ result ((T * T) * (T -> result (List_t T)))
:=
- list_nth_mut_shared_loop_pair_merge_loop_back T n ls0 ls1 i ret
+ p <- list_nth_mut_shared_loop_pair_merge_loop T n ls0 ls1 i;
+ let (p1, back_'a) := p in
+ let back_'a1 := fun (ret : T) => back_'a ret in
+ Return (p1, back_'a1)
.
-(** [loops::list_nth_shared_mut_loop_pair]: loop 0: forward function
+(** [loops::list_nth_shared_mut_loop_pair]: loop 0:
Source: 'src/loops.rs', lines 297:0-312: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)
+ result ((T * T) * (T -> result (List_t T)))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls0 with
| List_Cons x0 tl0 =>
match ls1 with
| List_Cons x1 tl1 =>
if i s= 0%u32
- then Return (x0, x1)
+ then
+ let back_'b := fun (ret : T) => Return (List_Cons ret tl1) in
+ Return ((x0, x1), back_'b)
else (
- i0 <- u32_sub i 1%u32;
- list_nth_shared_mut_loop_pair_loop T n0 tl0 tl1 i0)
+ i1 <- u32_sub i 1%u32;
+ p <- list_nth_shared_mut_loop_pair_loop T n1 tl0 tl1 i1;
+ let (p1, back_'b) := p in
+ let back_'b1 :=
+ fun (ret : T) => tl11 <- back_'b ret; Return (List_Cons x1 tl11) in
+ Return (p1, back_'b1))
| List_Nil => Fail_ Failure
end
| List_Nil => Fail_ Failure
@@ -800,68 +620,42 @@ Fixpoint list_nth_shared_mut_loop_pair_loop
end
.
-(** [loops::list_nth_shared_mut_loop_pair]: forward function
+(** [loops::list_nth_shared_mut_loop_pair]:
Source: 'src/loops.rs', lines 297:0-301: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)
+ result ((T * T) * (T -> result (List_t T)))
:=
- list_nth_shared_mut_loop_pair_loop T n ls0 ls1 i
-.
-
-(** [loops::list_nth_shared_mut_loop_pair]: loop 0: backward function 1
- Source: 'src/loops.rs', lines 297:0-312:1 *)
-Fixpoint list_nth_shared_mut_loop_pair_loop_back
- (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) (ret : T) :
- result (List_t T)
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls0 with
- | List_Cons x0 tl0 =>
- match ls1 with
- | List_Cons x1 tl1 =>
- if i s= 0%u32
- then Return (List_Cons ret tl1)
- else (
- i0 <- u32_sub i 1%u32;
- tl10 <- list_nth_shared_mut_loop_pair_loop_back T n0 tl0 tl1 i0 ret;
- Return (List_Cons x1 tl10))
- | List_Nil => Fail_ Failure
- end
- | List_Nil => Fail_ Failure
- end
- end
+ p <- list_nth_shared_mut_loop_pair_loop T n ls0 ls1 i;
+ let (p1, back_'b) := p in
+ let back_'b1 := fun (ret : T) => back_'b ret in
+ Return (p1, back_'b1)
.
-(** [loops::list_nth_shared_mut_loop_pair]: backward function 1
- Source: 'src/loops.rs', lines 297:0-301:23 *)
-Definition list_nth_shared_mut_loop_pair_back
- (T : Type) (n : nat) (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 n ls0 ls1 i ret
-.
-
-(** [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: forward function
+(** [loops::list_nth_shared_mut_loop_pair_merge]: loop 0:
Source: 'src/loops.rs', lines 316:0-331: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)
+ result ((T * T) * (T -> result (List_t T)))
:=
match n with
| O => Fail_ OutOfFuel
- | S n0 =>
+ | S n1 =>
match ls0 with
| List_Cons x0 tl0 =>
match ls1 with
| List_Cons x1 tl1 =>
if i s= 0%u32
- then Return (x0, x1)
+ then
+ let back_'a := fun (ret : T) => Return (List_Cons ret tl1) in
+ Return ((x0, x1), back_'a)
else (
- i0 <- u32_sub i 1%u32;
- list_nth_shared_mut_loop_pair_merge_loop T n0 tl0 tl1 i0)
+ i1 <- u32_sub i 1%u32;
+ p <- list_nth_shared_mut_loop_pair_merge_loop T n1 tl0 tl1 i1;
+ let (p1, back_'a) := p in
+ let back_'a1 :=
+ fun (ret : T) => tl11 <- back_'a ret; Return (List_Cons x1 tl11) in
+ Return (p1, back_'a1))
| List_Nil => Fail_ Failure
end
| List_Nil => Fail_ Failure
@@ -869,49 +663,16 @@ Fixpoint list_nth_shared_mut_loop_pair_merge_loop
end
.
-(** [loops::list_nth_shared_mut_loop_pair_merge]: forward function
+(** [loops::list_nth_shared_mut_loop_pair_merge]:
Source: 'src/loops.rs', lines 316:0-320: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)
- :=
- list_nth_shared_mut_loop_pair_merge_loop T n ls0 ls1 i
-.
-
-(** [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: backward function 0
- Source: 'src/loops.rs', lines 316:0-331:1 *)
-Fixpoint list_nth_shared_mut_loop_pair_merge_loop_back
- (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) (ret : T) :
- result (List_t T)
- :=
- match n with
- | O => Fail_ OutOfFuel
- | S n0 =>
- match ls0 with
- | List_Cons x0 tl0 =>
- match ls1 with
- | List_Cons x1 tl1 =>
- if i s= 0%u32
- then Return (List_Cons ret tl1)
- else (
- i0 <- u32_sub i 1%u32;
- tl10 <-
- list_nth_shared_mut_loop_pair_merge_loop_back T n0 tl0 tl1 i0 ret;
- Return (List_Cons x1 tl10))
- | List_Nil => Fail_ Failure
- end
- | List_Nil => Fail_ Failure
- end
- end
-.
-
-(** [loops::list_nth_shared_mut_loop_pair_merge]: backward function 0
- Source: 'src/loops.rs', lines 316:0-320:23 *)
-Definition list_nth_shared_mut_loop_pair_merge_back
- (T : Type) (n : nat) (ls0 : List_t T) (ls1 : List_t T) (i : u32) (ret : T) :
- result (List_t T)
+ result ((T * T) * (T -> result (List_t T)))
:=
- list_nth_shared_mut_loop_pair_merge_loop_back T n ls0 ls1 i ret
+ p <- list_nth_shared_mut_loop_pair_merge_loop T n ls0 ls1 i;
+ let (p1, back_'a) := p in
+ let back_'a1 := fun (ret : T) => back_'a ret in
+ Return (p1, back_'a1)
.
End Loops.
diff --git a/tests/coq/misc/Paper.v b/tests/coq/misc/Paper.v
index 6b110193..e46df0ce 100644
--- a/tests/coq/misc/Paper.v
+++ b/tests/coq/misc/Paper.v
@@ -8,44 +8,40 @@ Import ListNotations.
Local Open Scope Primitives_scope.
Module Paper.
-(** [paper::ref_incr]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [paper::ref_incr]:
Source: 'src/paper.rs', lines 4:0-4:28 *)
Definition ref_incr (x : i32) : result i32 :=
i32_add x 1%i32.
-(** [paper::test_incr]: forward function
+(** [paper::test_incr]:
Source: 'src/paper.rs', lines 8:0-8:18 *)
Definition test_incr : result unit :=
- x <- ref_incr 0%i32; if negb (x s= 1%i32) then Fail_ Failure else Return tt
+ i <- ref_incr 0%i32; if negb (i s= 1%i32) then Fail_ Failure else Return tt
.
(** Unit test for [paper::test_incr] *)
Check (test_incr )%return.
-(** [paper::choose]: forward function
+(** [paper::choose]:
Source: 'src/paper.rs', lines 15:0-15:70 *)
-Definition choose (T : Type) (b : bool) (x : T) (y : T) : result T :=
- if b then Return x else Return y
+Definition choose
+ (T : Type) (b : bool) (x : T) (y : T) : result (T * (T -> result (T * T))) :=
+ if b
+ then let back_'a := fun (ret : T) => Return (ret, y) in Return (x, back_'a)
+ else let back_'a := fun (ret : T) => Return (x, ret) in Return (y, back_'a)
.
-(** [paper::choose]: backward function 0
- Source: 'src/paper.rs', lines 15:0-15:70 *)
-Definition choose_back
- (T : Type) (b : bool) (x : T) (y : T) (ret : T) : result (T * T) :=
- if b then Return (ret, y) else Return (x, ret)
-.
-
-(** [paper::test_choose]: forward function
+(** [paper::test_choose]:
Source: 'src/paper.rs', lines 23:0-23:20 *)
Definition test_choose : result unit :=
- z <- choose i32 true 0%i32 0%i32;
- z0 <- i32_add z 1%i32;
- if negb (z0 s= 1%i32)
+ p <- choose i32 true 0%i32 0%i32;
+ let (z, choose_back) := p in
+ z1 <- i32_add z 1%i32;
+ if negb (z1 s= 1%i32)
then Fail_ Failure
else (
- p <- choose_back i32 true 0%i32 0%i32 z0;
- let (x, y) := p in
+ p1 <- choose_back z1;
+ let (x, y) := p1 in
if negb (x s= 1%i32)
then Fail_ Failure
else if negb (y s= 0%i32) then Fail_ Failure else Return tt)
@@ -64,35 +60,31 @@ Inductive List_t (T : Type) :=
Arguments List_Cons { _ }.
Arguments List_Nil { _ }.
-(** [paper::list_nth_mut]: forward function
- Source: 'src/paper.rs', lines 42:0-42:67 *)
-Fixpoint list_nth_mut (T : Type) (l : List_t T) (i : u32) : result T :=
- match l with
- | List_Cons x tl =>
- if i s= 0%u32
- then Return x
- else (i0 <- u32_sub i 1%u32; list_nth_mut T tl i0)
- | List_Nil => Fail_ Failure
- end
-.
-
-(** [paper::list_nth_mut]: backward function 0
+(** [paper::list_nth_mut]:
Source: 'src/paper.rs', lines 42:0-42:67 *)
-Fixpoint list_nth_mut_back
- (T : Type) (l : List_t T) (i : u32) (ret : T) : result (List_t T) :=
+Fixpoint list_nth_mut
+ (T : Type) (l : List_t T) (i : u32) :
+ result (T * (T -> result (List_t T)))
+ :=
match l with
| List_Cons x tl =>
if i s= 0%u32
- then Return (List_Cons ret tl)
+ then
+ let back_'a := fun (ret : T) => Return (List_Cons ret tl) in
+ Return (x, back_'a)
else (
- i0 <- u32_sub i 1%u32;
- tl0 <- list_nth_mut_back T tl i0 ret;
- Return (List_Cons x tl0))
+ i1 <- u32_sub i 1%u32;
+ p <- list_nth_mut T tl i1;
+ let (t, list_nth_mut_back) := p in
+ let back_'a :=
+ fun (ret : T) => tl1 <- list_nth_mut_back ret; Return (List_Cons x tl1)
+ in
+ Return (t, back_'a))
| List_Nil => Fail_ Failure
end
.
-(** [paper::sum]: forward function
+(** [paper::sum]:
Source: 'src/paper.rs', lines 57:0-57:32 *)
Fixpoint sum (l : List_t i32) : result i32 :=
match l with
@@ -101,31 +93,33 @@ Fixpoint sum (l : List_t i32) : result i32 :=
end
.
-(** [paper::test_nth]: forward function
+(** [paper::test_nth]:
Source: 'src/paper.rs', lines 68:0-68:17 *)
Definition test_nth : result unit :=
let l := List_Nil in
- let l0 := List_Cons 3%i32 l in
- let l1 := List_Cons 2%i32 l0 in
- x <- list_nth_mut i32 (List_Cons 1%i32 l1) 2%u32;
- x0 <- i32_add x 1%i32;
- l2 <- list_nth_mut_back i32 (List_Cons 1%i32 l1) 2%u32 x0;
- i <- sum l2;
+ let l1 := List_Cons 3%i32 l in
+ let l2 := List_Cons 2%i32 l1 in
+ p <- list_nth_mut i32 (List_Cons 1%i32 l2) 2%u32;
+ let (x, list_nth_mut_back) := p in
+ x1 <- i32_add x 1%i32;
+ l3 <- list_nth_mut_back x1;
+ i <- sum l3;
if negb (i s= 7%i32) then Fail_ Failure else Return tt
.
(** Unit test for [paper::test_nth] *)
Check (test_nth )%return.
-(** [paper::call_choose]: forward function
+(** [paper::call_choose]:
Source: 'src/paper.rs', lines 76:0-76:44 *)
Definition call_choose (p : (u32 * u32)) : result u32 :=
let (px, py) := p in
- pz <- choose u32 true px py;
- pz0 <- u32_add pz 1%u32;
- p0 <- choose_back u32 true px py pz0;
- let (px0, _) := p0 in
- Return px0
+ p1 <- choose u32 true px py;
+ let (pz, choose_back) := p1 in
+ pz1 <- u32_add pz 1%u32;
+ p2 <- choose_back pz1;
+ let (px1, _) := p2 in
+ Return px1
.
End Paper.
diff --git a/tests/coq/misc/PoloniusList.v b/tests/coq/misc/PoloniusList.v
index 2371b1cc..7e967855 100644
--- a/tests/coq/misc/PoloniusList.v
+++ b/tests/coq/misc/PoloniusList.v
@@ -18,26 +18,28 @@ Inductive List_t (T : Type) :=
Arguments List_Cons { _ }.
Arguments List_Nil { _ }.
-(** [polonius_list::get_list_at_x]: forward function
+(** [polonius_list::get_list_at_x]:
Source: 'src/polonius_list.rs', lines 13:0-13:76 *)
-Fixpoint get_list_at_x (ls : List_t u32) (x : u32) : result (List_t u32) :=
- match ls with
- | List_Cons hd tl =>
- if hd s= x then Return (List_Cons hd tl) else get_list_at_x tl x
- | List_Nil => Return List_Nil
- end
-.
-
-(** [polonius_list::get_list_at_x]: backward function 0
- Source: 'src/polonius_list.rs', lines 13:0-13:76 *)
-Fixpoint get_list_at_x_back
- (ls : List_t u32) (x : u32) (ret : List_t u32) : result (List_t u32) :=
+Fixpoint get_list_at_x
+ (ls : List_t u32) (x : u32) :
+ result ((List_t u32) * (List_t u32 -> result (List_t u32)))
+ :=
match ls with
| List_Cons hd tl =>
if hd s= x
- then Return ret
- else (tl0 <- get_list_at_x_back tl x ret; Return (List_Cons hd tl0))
- | List_Nil => Return ret
+ then
+ let back_'a := fun (ret : List_t u32) => Return ret in
+ Return (List_Cons hd tl, back_'a)
+ else (
+ p <- get_list_at_x tl x;
+ let (l, get_list_at_x_back) := p in
+ let back_'a :=
+ fun (ret : List_t u32) =>
+ tl1 <- get_list_at_x_back ret; Return (List_Cons hd tl1) in
+ Return (l, back_'a))
+ | List_Nil =>
+ let back_'a := fun (ret : List_t u32) => Return ret in
+ Return (List_Nil, back_'a)
end
.
diff --git a/tests/coq/misc/Primitives.v b/tests/coq/misc/Primitives.v
index c0056073..990e27e4 100644
--- a/tests/coq/misc/Primitives.v
+++ b/tests/coq/misc/Primitives.v
@@ -67,7 +67,7 @@ Definition string := Coq.Strings.String.string.
Definition char := Coq.Strings.Ascii.ascii.
Definition char_of_byte := Coq.Strings.Ascii.ascii_of_byte.
-Definition core_mem_replace (a : Type) (x : a) (y : a) : a * (a -> a) := (x, fun x => x) .
+Definition core_mem_replace (a : Type) (x : a) (y : a) : a * a := (x, x) .
Record mut_raw_ptr (T : Type) := { mut_raw_ptr_v : T }.
Record const_raw_ptr (T : Type) := { const_raw_ptr_v : T }.
@@ -585,6 +585,13 @@ Axiom array_repeat : forall (T : Type) (n : usize) (x : T), array T n.
Axiom array_index_usize : forall (T : Type) (n : usize) (x : array T n) (i : usize), result T.
Axiom array_update_usize : forall (T : Type) (n : usize) (x : array T n) (i : usize) (nx : T), result (array T n).
+Definition array_index_mut_usize (T : Type) (n : usize) (a : array T n) (i : usize) :
+ result (T * (T -> result (array T n))) :=
+ match array_index_usize T n a i with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, array_update_usize T n a i)
+ end.
+
(*** Slice *)
Definition slice T := { l: list T | Z.of_nat (length l) <= usize_max}.
@@ -592,11 +599,25 @@ Axiom slice_len : forall (T : Type) (s : slice T), usize.
Axiom slice_index_usize : forall (T : Type) (x : slice T) (i : usize), result T.
Axiom slice_update_usize : forall (T : Type) (x : slice T) (i : usize) (nx : T), result (slice T).
+Definition slice_index_mut_usize (T : Type) (s : slice T) (i : usize) :
+ result (T * (T -> result (slice T))) :=
+ match slice_index_usize T s i with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, slice_update_usize T s i)
+ end.
+
(*** Subslices *)
Axiom array_to_slice : forall (T : Type) (n : usize) (x : array T n), result (slice T).
Axiom array_from_slice : forall (T : Type) (n : usize) (x : array T n) (s : slice T), result (array T n).
+Definition array_to_slice_mut (T : Type) (n : usize) (a : array T n) :
+ result (slice T * (slice T -> result (array T n))) :=
+ match array_to_slice T n a with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, array_from_slice T n a)
+ end.
+
Axiom array_subslice: forall (T : Type) (n : usize) (x : array T n) (r : core_ops_range_Range usize), result (slice T).
Axiom array_update_subslice: forall (T : Type) (n : usize) (x : array T n) (r : core_ops_range_Range usize) (ns : slice T), result (array T n).
diff --git a/tests/coq/misc/_CoqProject b/tests/coq/misc/_CoqProject
index 869cdb4d..64cddedd 100644
--- a/tests/coq/misc/_CoqProject
+++ b/tests/coq/misc/_CoqProject
@@ -8,9 +8,9 @@ External_Types.v
Primitives.v
External_Funs.v
External_TypesExternal.v
+Paper.v
Constants.v
PoloniusList.v
-Paper.v
NoNestedBorrows.v
External_FunsExternal.v
Bitwise.v
diff --git a/tests/coq/traits/Primitives.v b/tests/coq/traits/Primitives.v
index 84280b96..990e27e4 100644
--- a/tests/coq/traits/Primitives.v
+++ b/tests/coq/traits/Primitives.v
@@ -67,8 +67,7 @@ Definition string := Coq.Strings.String.string.
Definition char := Coq.Strings.Ascii.ascii.
Definition char_of_byte := Coq.Strings.Ascii.ascii_of_byte.
-Definition core_mem_replace (a : Type) (x : a) (y : a) : a := x .
-Definition core_mem_replace_back (a : Type) (x : a) (y : a) : a := y .
+Definition core_mem_replace (a : Type) (x : a) (y : a) : a * a := (x, x) .
Record mut_raw_ptr (T : Type) := { mut_raw_ptr_v : T }.
Record const_raw_ptr (T : Type) := { const_raw_ptr_v : T }.
@@ -504,13 +503,15 @@ Arguments core_ops_index_Index_index {_ _}.
(* Trait declaration: [core::ops::index::IndexMut] *)
Record core_ops_index_IndexMut (Self Idx : Type) := mk_core_ops_index_IndexMut {
core_ops_index_IndexMut_indexInst : core_ops_index_Index Self Idx;
- core_ops_index_IndexMut_index_mut : Self -> Idx -> result core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output);
- core_ops_index_IndexMut_index_mut_back : Self -> Idx -> core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) -> result Self;
+ core_ops_index_IndexMut_index_mut :
+ Self ->
+ Idx ->
+ result (core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) *
+ (core_ops_index_IndexMut_indexInst.(core_ops_index_Index_Output) -> result Self));
}.
Arguments mk_core_ops_index_IndexMut {_ _}.
Arguments core_ops_index_IndexMut_indexInst {_ _}.
Arguments core_ops_index_IndexMut_index_mut {_ _}.
-Arguments core_ops_index_IndexMut_index_mut_back {_ _}.
(* Trait declaration [core::ops::deref::Deref] *)
Record core_ops_deref_Deref (Self : Type) := mk_core_ops_deref_Deref {
@@ -524,13 +525,14 @@ Arguments core_ops_deref_Deref_deref {_}.
(* Trait declaration [core::ops::deref::DerefMut] *)
Record core_ops_deref_DerefMut (Self : Type) := mk_core_ops_deref_DerefMut {
core_ops_deref_DerefMut_derefInst : core_ops_deref_Deref Self;
- core_ops_deref_DerefMut_deref_mut : Self -> result core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target);
- core_ops_deref_DerefMut_deref_mut_back : Self -> core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) -> result Self;
+ core_ops_deref_DerefMut_deref_mut :
+ Self ->
+ result (core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) *
+ (core_ops_deref_DerefMut_derefInst.(core_ops_deref_Deref_target) -> result Self));
}.
Arguments mk_core_ops_deref_DerefMut {_}.
Arguments core_ops_deref_DerefMut_derefInst {_}.
Arguments core_ops_deref_DerefMut_deref_mut {_}.
-Arguments core_ops_deref_DerefMut_deref_mut_back {_}.
Record core_ops_range_Range (T : Type) := mk_core_ops_range_Range {
core_ops_range_Range_start : T;
@@ -543,8 +545,8 @@ Arguments core_ops_range_Range_end_ {_}.
(*** [alloc] *)
Definition alloc_boxed_Box_deref (T : Type) (x : T) : result T := Return x.
-Definition alloc_boxed_Box_deref_mut (T : Type) (x : T) : result T := Return x.
-Definition alloc_boxed_Box_deref_mut_back (T : Type) (_ : T) (x : T) : result T := Return x.
+Definition alloc_boxed_Box_deref_mut (T : Type) (x : T) : result (T * (T -> result T)) :=
+ Return (x, fun x => Return x).
(* Trait instance *)
Definition alloc_boxed_Box_coreopsDerefInst (Self : Type) : core_ops_deref_Deref Self := {|
@@ -556,7 +558,6 @@ Definition alloc_boxed_Box_coreopsDerefInst (Self : Type) : core_ops_deref_Deref
Definition alloc_boxed_Box_coreopsDerefMutInst (Self : Type) : core_ops_deref_DerefMut Self := {|
core_ops_deref_DerefMut_derefInst := alloc_boxed_Box_coreopsDerefInst Self;
core_ops_deref_DerefMut_deref_mut := alloc_boxed_Box_deref_mut Self;
- core_ops_deref_DerefMut_deref_mut_back := alloc_boxed_Box_deref_mut_back Self;
|}.
@@ -584,6 +585,13 @@ Axiom array_repeat : forall (T : Type) (n : usize) (x : T), array T n.
Axiom array_index_usize : forall (T : Type) (n : usize) (x : array T n) (i : usize), result T.
Axiom array_update_usize : forall (T : Type) (n : usize) (x : array T n) (i : usize) (nx : T), result (array T n).
+Definition array_index_mut_usize (T : Type) (n : usize) (a : array T n) (i : usize) :
+ result (T * (T -> result (array T n))) :=
+ match array_index_usize T n a i with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, array_update_usize T n a i)
+ end.
+
(*** Slice *)
Definition slice T := { l: list T | Z.of_nat (length l) <= usize_max}.
@@ -591,11 +599,25 @@ Axiom slice_len : forall (T : Type) (s : slice T), usize.
Axiom slice_index_usize : forall (T : Type) (x : slice T) (i : usize), result T.
Axiom slice_update_usize : forall (T : Type) (x : slice T) (i : usize) (nx : T), result (slice T).
+Definition slice_index_mut_usize (T : Type) (s : slice T) (i : usize) :
+ result (T * (T -> result (slice T))) :=
+ match slice_index_usize T s i with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, slice_update_usize T s i)
+ end.
+
(*** Subslices *)
Axiom array_to_slice : forall (T : Type) (n : usize) (x : array T n), result (slice T).
Axiom array_from_slice : forall (T : Type) (n : usize) (x : array T n) (s : slice T), result (array T n).
+Definition array_to_slice_mut (T : Type) (n : usize) (a : array T n) :
+ result (slice T * (slice T -> result (array T n))) :=
+ match array_to_slice T n a with
+ | Fail_ e => Fail_ e
+ | Return x => Return (x, array_from_slice T n a)
+ end.
+
Axiom array_subslice: forall (T : Type) (n : usize) (x : array T n) (r : core_ops_range_Range usize), result (slice T).
Axiom array_update_subslice: forall (T : Type) (n : usize) (x : array T n) (r : core_ops_range_Range usize) (ns : slice T), result (array T n).
@@ -639,16 +661,9 @@ Definition alloc_vec_Vec_bind {A B} (v: alloc_vec_Vec A) (f: list A -> result (l
| right _ => Fail_ Failure
end.
-(* The **forward** function shouldn't be used *)
-Definition alloc_vec_Vec_push_fwd (T: Type) (v: alloc_vec_Vec T) (x: T) : unit := tt.
-
Definition alloc_vec_Vec_push (T: Type) (v: alloc_vec_Vec T) (x: T) : result (alloc_vec_Vec T) :=
alloc_vec_Vec_bind v (fun l => Return (l ++ [x])).
-(* The **forward** function shouldn't be used *)
-Definition alloc_vec_Vec_insert_fwd (T: Type) (v: alloc_vec_Vec T) (i: usize) (x: T) : result unit :=
- if to_Z i <? alloc_vec_Vec_length v then Return tt else Fail_ Failure.
-
Definition alloc_vec_Vec_insert (T: Type) (v: alloc_vec_Vec T) (i: usize) (x: T) : result (alloc_vec_Vec T) :=
alloc_vec_Vec_bind v (fun l =>
if to_Z i <? Z.of_nat (length l)
@@ -661,6 +676,14 @@ Axiom alloc_vec_Vec_index_usize : forall {T : Type} (v : alloc_vec_Vec T) (i : u
(* Helper *)
Axiom alloc_vec_Vec_update_usize : forall {T : Type} (v : alloc_vec_Vec T) (i : usize) (x : T), result (alloc_vec_Vec T).
+Definition alloc_vec_Vec_index_mut_usize {T : Type} (v: alloc_vec_Vec T) (i: usize) :
+ result (T * (T -> result (alloc_vec_Vec T))) :=
+ match alloc_vec_Vec_index_usize v i with
+ | Return x =>
+ Return (x, alloc_vec_Vec_update_usize v i)
+ | Fail_ e => Fail_ e
+ end.
+
(* Trait declaration: [core::slice::index::private_slice_index::Sealed] *)
Definition core_slice_index_private_slice_index_Sealed (self : Type) := unit.
@@ -669,25 +692,23 @@ Record core_slice_index_SliceIndex (Self T : Type) := mk_core_slice_index_SliceI
core_slice_index_SliceIndex_sealedInst : core_slice_index_private_slice_index_Sealed Self;
core_slice_index_SliceIndex_Output : Type;
core_slice_index_SliceIndex_get : Self -> T -> result (option core_slice_index_SliceIndex_Output);
- core_slice_index_SliceIndex_get_mut : Self -> T -> result (option core_slice_index_SliceIndex_Output);
- core_slice_index_SliceIndex_get_mut_back : Self -> T -> option core_slice_index_SliceIndex_Output -> result T;
+ core_slice_index_SliceIndex_get_mut :
+ Self -> T -> result (option core_slice_index_SliceIndex_Output * (option core_slice_index_SliceIndex_Output -> result T));
core_slice_index_SliceIndex_get_unchecked : Self -> const_raw_ptr T -> result (const_raw_ptr core_slice_index_SliceIndex_Output);
core_slice_index_SliceIndex_get_unchecked_mut : Self -> mut_raw_ptr T -> result (mut_raw_ptr core_slice_index_SliceIndex_Output);
core_slice_index_SliceIndex_index : Self -> T -> result core_slice_index_SliceIndex_Output;
- core_slice_index_SliceIndex_index_mut : Self -> T -> result core_slice_index_SliceIndex_Output;
- core_slice_index_SliceIndex_index_mut_back : Self -> T -> core_slice_index_SliceIndex_Output -> result T;
+ core_slice_index_SliceIndex_index_mut :
+ Self -> T -> result (core_slice_index_SliceIndex_Output * (core_slice_index_SliceIndex_Output -> result T));
}.
Arguments mk_core_slice_index_SliceIndex {_ _}.
Arguments core_slice_index_SliceIndex_sealedInst {_ _}.
Arguments core_slice_index_SliceIndex_Output {_ _}.
Arguments core_slice_index_SliceIndex_get {_ _}.
Arguments core_slice_index_SliceIndex_get_mut {_ _}.
-Arguments core_slice_index_SliceIndex_get_mut_back {_ _}.
Arguments core_slice_index_SliceIndex_get_unchecked {_ _}.
Arguments core_slice_index_SliceIndex_get_unchecked_mut {_ _}.
Arguments core_slice_index_SliceIndex_index {_ _}.
Arguments core_slice_index_SliceIndex_index_mut {_ _}.
-Arguments core_slice_index_SliceIndex_index_mut_back {_ _}.
(* [core::slice::index::[T]::index]: forward function *)
Definition core_slice_index_Slice_index
@@ -704,11 +725,9 @@ Axiom core_slice_index_RangeUsize_get : forall (T : Type) (i : core_ops_range_Ra
(* [core::slice::index::Range::get_mut]: forward function *)
Axiom core_slice_index_RangeUsize_get_mut :
- forall (T : Type), core_ops_range_Range usize -> slice T -> result (option (slice T)).
-
-(* [core::slice::index::Range::get_mut]: backward function 0 *)
-Axiom core_slice_index_RangeUsize_get_mut_back :
- forall (T : Type), core_ops_range_Range usize -> slice T -> option (slice T) -> result (slice T).
+ forall (T : Type),
+ core_ops_range_Range usize -> slice T ->
+ result (option (slice T) * (option (slice T) -> result (slice T))).
(* [core::slice::index::Range::get_unchecked]: forward function *)
Definition core_slice_index_RangeUsize_get_unchecked
@@ -732,21 +751,14 @@ Axiom core_slice_index_RangeUsize_index :
(* [core::slice::index::Range::index_mut]: forward function *)
Axiom core_slice_index_RangeUsize_index_mut :
- forall (T : Type), core_ops_range_Range usize -> slice T -> result (slice T).
-
-(* [core::slice::index::Range::index_mut]: backward function 0 *)
-Axiom core_slice_index_RangeUsize_index_mut_back :
- forall (T : Type), core_ops_range_Range usize -> slice T -> slice T -> result (slice T).
+ forall (T : Type), core_ops_range_Range usize -> slice T -> result (slice T * (slice T -> result (slice T))).
(* [core::slice::index::[T]::index_mut]: forward function *)
Axiom core_slice_index_Slice_index_mut :
forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T)),
- slice T -> Idx -> result inst.(core_slice_index_SliceIndex_Output).
-
-(* [core::slice::index::[T]::index_mut]: backward function 0 *)
-Axiom core_slice_index_Slice_index_mut_back :
- forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T)),
- slice T -> Idx -> inst.(core_slice_index_SliceIndex_Output) -> result (slice T).
+ slice T -> Idx ->
+ result (inst.(core_slice_index_SliceIndex_Output) *
+ (inst.(core_slice_index_SliceIndex_Output) -> result (slice T))).
(* [core::array::[T; N]::index]: forward function *)
Axiom core_array_Array_index :
@@ -756,12 +768,9 @@ Axiom core_array_Array_index :
(* [core::array::[T; N]::index_mut]: forward function *)
Axiom core_array_Array_index_mut :
forall (T Idx : Type) (N : usize) (inst : core_ops_index_IndexMut (slice T) Idx)
- (a : array T N) (i : Idx), result inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output).
-
-(* [core::array::[T; N]::index_mut]: backward function 0 *)
-Axiom core_array_Array_index_mut_back :
- forall (T Idx : Type) (N : usize) (inst : core_ops_index_IndexMut (slice T) Idx)
- (a : array T N) (i : Idx) (x : inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output)), result (array T N).
+ (a : array T N) (i : Idx),
+ result (inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output) *
+ (inst.(core_ops_index_IndexMut_indexInst).(core_ops_index_Index_Output) -> result (array T N))).
(* Trait implementation: [core::slice::index::private_slice_index::Range] *)
Definition core_slice_index_private_slice_index_SealedRangeUsizeInst
@@ -774,12 +783,10 @@ Definition core_slice_index_SliceIndexRangeUsizeSliceTInst (T : Type) :
core_slice_index_SliceIndex_Output := slice T;
core_slice_index_SliceIndex_get := core_slice_index_RangeUsize_get T;
core_slice_index_SliceIndex_get_mut := core_slice_index_RangeUsize_get_mut T;
- core_slice_index_SliceIndex_get_mut_back := core_slice_index_RangeUsize_get_mut_back T;
core_slice_index_SliceIndex_get_unchecked := core_slice_index_RangeUsize_get_unchecked T;
core_slice_index_SliceIndex_get_unchecked_mut := core_slice_index_RangeUsize_get_unchecked_mut T;
core_slice_index_SliceIndex_index := core_slice_index_RangeUsize_index T;
core_slice_index_SliceIndex_index_mut := core_slice_index_RangeUsize_index_mut T;
- core_slice_index_SliceIndex_index_mut_back := core_slice_index_RangeUsize_index_mut_back T;
|}.
(* Trait implementation: [core::slice::index::[T]] *)
@@ -796,7 +803,6 @@ Definition core_ops_index_IndexMutSliceTIInst (T Idx : Type)
core_ops_index_IndexMut (slice T) Idx := {|
core_ops_index_IndexMut_indexInst := core_ops_index_IndexSliceTIInst T Idx inst;
core_ops_index_IndexMut_index_mut := core_slice_index_Slice_index_mut T Idx inst;
- core_ops_index_IndexMut_index_mut_back := core_slice_index_Slice_index_mut_back T Idx inst;
|}.
(* Trait implementation: [core::array::[T; N]] *)
@@ -813,18 +819,14 @@ Definition core_ops_index_IndexMutArrayInst (T Idx : Type) (N : usize)
core_ops_index_IndexMut (array T N) Idx := {|
core_ops_index_IndexMut_indexInst := core_ops_index_IndexArrayInst T Idx N inst.(core_ops_index_IndexMut_indexInst);
core_ops_index_IndexMut_index_mut := core_array_Array_index_mut T Idx N inst;
- core_ops_index_IndexMut_index_mut_back := core_array_Array_index_mut_back T Idx N inst;
|}.
(* [core::slice::index::usize::get]: forward function *)
Axiom core_slice_index_usize_get : forall (T : Type), usize -> slice T -> result (option T).
(* [core::slice::index::usize::get_mut]: forward function *)
-Axiom core_slice_index_usize_get_mut : forall (T : Type), usize -> slice T -> result (option T).
-
-(* [core::slice::index::usize::get_mut]: backward function 0 *)
-Axiom core_slice_index_usize_get_mut_back :
- forall (T : Type), usize -> slice T -> option T -> result (slice T).
+Axiom core_slice_index_usize_get_mut :
+ forall (T : Type), usize -> slice T -> result (option T * (option T -> result (slice T))).
(* [core::slice::index::usize::get_unchecked]: forward function *)
Axiom core_slice_index_usize_get_unchecked :
@@ -838,11 +840,8 @@ Axiom core_slice_index_usize_get_unchecked_mut :
Axiom core_slice_index_usize_index : forall (T : Type), usize -> slice T -> result T.
(* [core::slice::index::usize::index_mut]: forward function *)
-Axiom core_slice_index_usize_index_mut : forall (T : Type), usize -> slice T -> result T.
-
-(* [core::slice::index::usize::index_mut]: backward function 0 *)
-Axiom core_slice_index_usize_index_mut_back :
- forall (T : Type), usize -> slice T -> T -> result (slice T).
+Axiom core_slice_index_usize_index_mut :
+ forall (T : Type), usize -> slice T -> result (T * (T -> result (slice T))).
(* Trait implementation: [core::slice::index::private_slice_index::usize] *)
Definition core_slice_index_private_slice_index_SealedUsizeInst
@@ -855,12 +854,10 @@ Definition core_slice_index_SliceIndexUsizeSliceTInst (T : Type) :
core_slice_index_SliceIndex_Output := T;
core_slice_index_SliceIndex_get := core_slice_index_usize_get T;
core_slice_index_SliceIndex_get_mut := core_slice_index_usize_get_mut T;
- core_slice_index_SliceIndex_get_mut_back := core_slice_index_usize_get_mut_back T;
core_slice_index_SliceIndex_get_unchecked := core_slice_index_usize_get_unchecked T;
core_slice_index_SliceIndex_get_unchecked_mut := core_slice_index_usize_get_unchecked_mut T;
core_slice_index_SliceIndex_index := core_slice_index_usize_index T;
core_slice_index_SliceIndex_index_mut := core_slice_index_usize_index_mut T;
- core_slice_index_SliceIndex_index_mut_back := core_slice_index_usize_index_mut_back T;
|}.
(* [alloc::vec::Vec::index]: forward function *)
@@ -869,12 +866,9 @@ Axiom alloc_vec_Vec_index : forall (T Idx : Type) (inst : core_slice_index_Slice
(* [alloc::vec::Vec::index_mut]: forward function *)
Axiom alloc_vec_Vec_index_mut : forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T))
- (Self : alloc_vec_Vec T) (i : Idx), result inst.(core_slice_index_SliceIndex_Output).
-
-(* [alloc::vec::Vec::index_mut]: backward function 0 *)
-Axiom alloc_vec_Vec_index_mut_back :
- forall (T Idx : Type) (inst : core_slice_index_SliceIndex Idx (slice T))
- (Self : alloc_vec_Vec T) (i : Idx) (x : inst.(core_slice_index_SliceIndex_Output)), result (alloc_vec_Vec T).
+ (Self : alloc_vec_Vec T) (i : Idx),
+ result (inst.(core_slice_index_SliceIndex_Output) *
+ (inst.(core_slice_index_SliceIndex_Output) -> result (alloc_vec_Vec T))).
(* Trait implementation: [alloc::vec::Vec] *)
Definition alloc_vec_Vec_coreopsindexIndexInst (T Idx : Type)
@@ -890,7 +884,6 @@ Definition alloc_vec_Vec_coreopsindexIndexMutInst (T Idx : Type)
core_ops_index_IndexMut (alloc_vec_Vec T) Idx := {|
core_ops_index_IndexMut_indexInst := alloc_vec_Vec_coreopsindexIndexInst T Idx inst;
core_ops_index_IndexMut_index_mut := alloc_vec_Vec_index_mut T Idx inst;
- core_ops_index_IndexMut_index_mut_back := alloc_vec_Vec_index_mut_back T Idx inst;
|}.
(*** Theorems *)
@@ -901,10 +894,6 @@ Axiom alloc_vec_Vec_index_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usiz
Axiom alloc_vec_Vec_index_mut_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usize) (x : a),
alloc_vec_Vec_index_mut a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i =
- alloc_vec_Vec_index_usize v i.
-
-Axiom alloc_vec_Vec_index_mut_back_eq : forall {a : Type} (v : alloc_vec_Vec a) (i : usize) (x : a),
- alloc_vec_Vec_index_mut_back a usize (core_slice_index_SliceIndexUsizeSliceTInst a) v i x =
- alloc_vec_Vec_update_usize v i x.
+ alloc_vec_Vec_index_mut_usize v i.
End Primitives.
diff --git a/tests/coq/traits/Traits.v b/tests/coq/traits/Traits.v
index 2448e8f3..7055e25d 100644
--- a/tests/coq/traits/Traits.v
+++ b/tests/coq/traits/Traits.v
@@ -17,7 +17,7 @@ Record BoolTrait_t (Self : Type) := mkBoolTrait_t {
Arguments mkBoolTrait_t { _ }.
Arguments BoolTrait_t_get_bool { _ }.
-(** [traits::{bool}::get_bool]: forward function
+(** [traits::{bool}::get_bool]:
Source: 'src/traits.rs', lines 12:4-12:30 *)
Definition bool_get_bool (self : bool) : result bool :=
Return self.
@@ -28,24 +28,24 @@ Definition traits_BoolTraitBoolInst : BoolTrait_t bool := {|
BoolTrait_t_get_bool := bool_get_bool;
|}.
-(** [traits::BoolTrait::ret_true]: forward function
+(** [traits::BoolTrait::ret_true]:
Source: 'src/traits.rs', lines 6:4-6:30 *)
Definition boolTrait_ret_true
{Self : Type} (self_clause : BoolTrait_t Self) (self : Self) : result bool :=
Return true
.
-(** [traits::test_bool_trait_bool]: forward function
+(** [traits::test_bool_trait_bool]:
Source: 'src/traits.rs', lines 17:0-17:44 *)
Definition test_bool_trait_bool (x : bool) : result bool :=
b <- bool_get_bool x;
if b then boolTrait_ret_true traits_BoolTraitBoolInst x else Return false
.
-(** [traits::{core::option::Option<T>#1}::get_bool]: forward function
+(** [traits::{core::option::Option<T>#1}::get_bool]:
Source: 'src/traits.rs', lines 23:4-23:30 *)
Definition option_get_bool (T : Type) (self : option T) : result bool :=
- match self with | None => Return false | Some t => Return true end
+ match self with | None => Return false | Some _ => Return true end
.
(** Trait implementation: [traits::{core::option::Option<T>#1}]
@@ -55,7 +55,7 @@ Definition traits_BoolTraitcoreoptionOptionTInst (T : Type) : BoolTrait_t
BoolTrait_t_get_bool := option_get_bool T;
|}.
-(** [traits::test_bool_trait_option]: forward function
+(** [traits::test_bool_trait_option]:
Source: 'src/traits.rs', lines 31:0-31:54 *)
Definition test_bool_trait_option (T : Type) (x : option T) : result bool :=
b <- option_get_bool T x;
@@ -64,7 +64,7 @@ Definition test_bool_trait_option (T : Type) (x : option T) : result bool :=
else Return false
.
-(** [traits::test_bool_trait]: forward function
+(** [traits::test_bool_trait]:
Source: 'src/traits.rs', lines 35:0-35:50 *)
Definition test_bool_trait
(T : Type) (boolTraitTInst : BoolTrait_t T) (x : T) : result bool :=
@@ -80,7 +80,7 @@ Record ToU64_t (Self : Type) := mkToU64_t {
Arguments mkToU64_t { _ }.
Arguments ToU64_t_to_u64 { _ }.
-(** [traits::{u64#2}::to_u64]: forward function
+(** [traits::{u64#2}::to_u64]:
Source: 'src/traits.rs', lines 44:4-44:26 *)
Definition u64_to_u64 (self : u64) : result u64 :=
Return self.
@@ -91,14 +91,14 @@ Definition traits_ToU64U64Inst : ToU64_t u64 := {|
ToU64_t_to_u64 := u64_to_u64;
|}.
-(** [traits::{(A, A)#3}::to_u64]: forward function
+(** [traits::{(A, A)#3}::to_u64]:
Source: 'src/traits.rs', lines 50:4-50:26 *)
Definition pair_to_u64
(A : Type) (toU64AInst : ToU64_t A) (self : (A * A)) : result u64 :=
- let (t, t0) := self in
+ let (t, t1) := self in
i <- toU64AInst.(ToU64_t_to_u64) t;
- i0 <- toU64AInst.(ToU64_t_to_u64) t0;
- u64_add i i0
+ i1 <- toU64AInst.(ToU64_t_to_u64) t1;
+ u64_add i i1
.
(** Trait implementation: [traits::{(A, A)#3}]
@@ -108,20 +108,20 @@ Definition traits_ToU64TupleAAInst (A : Type) (toU64AInst : ToU64_t A) :
ToU64_t_to_u64 := pair_to_u64 A toU64AInst;
|}.
-(** [traits::f]: forward function
+(** [traits::f]:
Source: 'src/traits.rs', lines 55:0-55:36 *)
Definition f (T : Type) (toU64TInst : ToU64_t T) (x : (T * T)) : result u64 :=
pair_to_u64 T toU64TInst x
.
-(** [traits::g]: forward function
+(** [traits::g]:
Source: 'src/traits.rs', lines 59:0-61:18 *)
Definition g
(T : Type) (toU64TupleTTInst : ToU64_t (T * T)) (x : (T * T)) : result u64 :=
toU64TupleTTInst.(ToU64_t_to_u64) x
.
-(** [traits::h0]: forward function
+(** [traits::h0]:
Source: 'src/traits.rs', lines 66:0-66:24 *)
Definition h0 (x : u64) : result u64 :=
u64_to_u64 x.
@@ -133,7 +133,7 @@ Record Wrapper_t (T : Type) := mkWrapper_t { wrapper_x : T; }.
Arguments mkWrapper_t { _ }.
Arguments wrapper_x { _ }.
-(** [traits::{traits::Wrapper<T>#4}::to_u64]: forward function
+(** [traits::{traits::Wrapper<T>#4}::to_u64]:
Source: 'src/traits.rs', lines 75:4-75:26 *)
Definition wrapper_to_u64
(T : Type) (toU64TInst : ToU64_t T) (self : Wrapper_t T) : result u64 :=
@@ -147,13 +147,13 @@ Definition traits_ToU64traitsWrapperTInst (T : Type) (toU64TInst : ToU64_t T) :
ToU64_t_to_u64 := wrapper_to_u64 T toU64TInst;
|}.
-(** [traits::h1]: forward function
+(** [traits::h1]:
Source: 'src/traits.rs', lines 80:0-80:33 *)
Definition h1 (x : Wrapper_t u64) : result u64 :=
wrapper_to_u64 u64 traits_ToU64U64Inst x
.
-(** [traits::h2]: forward function
+(** [traits::h2]:
Source: 'src/traits.rs', lines 84:0-84:41 *)
Definition h2
(T : Type) (toU64TInst : ToU64_t T) (x : Wrapper_t T) : result u64 :=
@@ -169,7 +169,7 @@ Record ToType_t (Self T : Type) := mkToType_t {
Arguments mkToType_t { _ _ }.
Arguments ToType_t_to_type { _ _ }.
-(** [traits::{u64#5}::to_type]: forward function
+(** [traits::{u64#5}::to_type]:
Source: 'src/traits.rs', lines 93:4-93:28 *)
Definition u64_to_type (self : u64) : result bool :=
Return (self s> 0%u64).
@@ -190,7 +190,7 @@ Record OfType_t (Self : Type) := mkOfType_t {
Arguments mkOfType_t { _ }.
Arguments OfType_t_of_type { _ }.
-(** [traits::h3]: forward function
+(** [traits::h3]:
Source: 'src/traits.rs', lines 104:0-104:50 *)
Definition h3
(T1 T2 : Type) (ofTypeT1Inst : OfType_t T1) (toTypeT2T1Inst : ToType_t T2 T1)
@@ -211,7 +211,7 @@ Arguments mkOfTypeBis_t { _ _ }.
Arguments OfTypeBis_tOfTypeBis_t_ToTypeTSelfInst { _ _ }.
Arguments OfTypeBis_t_of_type { _ _ }.
-(** [traits::h4]: forward function
+(** [traits::h4]:
Source: 'src/traits.rs', lines 118:0-118:57 *)
Definition h4
(T1 T2 : Type) (ofTypeBisT1T2Inst : OfTypeBis_t T1 T2) (toTypeT2T1Inst :
@@ -238,7 +238,7 @@ Record TestType_test_TestTrait_t (Self : Type) := mkTestType_test_TestTrait_t {
Arguments mkTestType_test_TestTrait_t { _ }.
Arguments TestType_test_TestTrait_t_test { _ }.
-(** [traits::{traits::TestType<T>#6}::test::{traits::{traits::TestType<T>#6}::test::TestType1}::test]: forward function
+(** [traits::{traits::TestType<T>#6}::test::{traits::{traits::TestType<T>#6}::test::TestType1}::test]:
Source: 'src/traits.rs', lines 139:12-139:34 *)
Definition testType_test_TestType1_test
(self : TestType_test_TestType1_t) : result bool :=
@@ -252,21 +252,21 @@ Definition traits_TestType_test_TestTraittraitstraitsTestTypeTtestTestType1Inst
TestType_test_TestTrait_t_test := testType_test_TestType1_test;
|}.
-(** [traits::{traits::TestType<T>#6}::test]: forward function
+(** [traits::{traits::TestType<T>#6}::test]:
Source: 'src/traits.rs', lines 126:4-126:36 *)
Definition testType_test
(T : Type) (toU64TInst : ToU64_t T) (self : TestType_t T) (x : T) :
result bool
:=
- x0 <- toU64TInst.(ToU64_t_to_u64) x;
- if x0 s> 0%u64 then testType_test_TestType1_test 0%u64 else Return false
+ x1 <- toU64TInst.(ToU64_t_to_u64) x;
+ if x1 s> 0%u64 then testType_test_TestType1_test 0%u64 else Return false
.
(** [traits::BoolWrapper]
Source: 'src/traits.rs', lines 150:0-150:22 *)
Definition BoolWrapper_t : Type := bool.
-(** [traits::{traits::BoolWrapper#7}::to_type]: forward function
+(** [traits::{traits::BoolWrapper#7}::to_type]:
Source: 'src/traits.rs', lines 156:4-156:25 *)
Definition boolWrapper_to_type
(T : Type) (toTypeBoolTInst : ToType_t bool T) (self : BoolWrapper_t) :
@@ -312,8 +312,7 @@ Arguments WithConstTy_t_f { _ _ }.
Definition bool_len1_body : result usize := Return 12%usize.
Definition bool_len1_c : usize := bool_len1_body%global.
-(** [traits::{bool#8}::f]: merged forward/backward function
- (there is a single backward function, and the forward function returns ())
+(** [traits::{bool#8}::f]:
Source: 'src/traits.rs', lines 180:4-180:39 *)
Definition bool_f (i : u64) (a : array u8 32%usize) : result u64 :=
Return i.
@@ -329,7 +328,7 @@ Definition traits_WithConstTyBool32Inst : WithConstTy_t bool 32%usize := {|
WithConstTy_t_f := bool_f;
|}.
-(** [traits::use_with_const_ty1]: forward function
+(** [traits::use_with_const_ty1]:
Source: 'src/traits.rs', lines 183:0-183:75 *)
Definition use_with_const_ty1
(H : Type) (LEN : usize) (withConstTyHLENInst : WithConstTy_t H LEN) :
@@ -338,7 +337,7 @@ Definition use_with_const_ty1
let i := withConstTyHLENInst.(WithConstTy_tWithConstTy_t_LEN1) in Return i
.
-(** [traits::use_with_const_ty2]: forward function
+(** [traits::use_with_const_ty2]:
Source: 'src/traits.rs', lines 187:0-187:73 *)
Definition use_with_const_ty2
(H : Type) (LEN : usize) (withConstTyHLENInst : WithConstTy_t H LEN)
@@ -348,7 +347,7 @@ Definition use_with_const_ty2
Return tt
.
-(** [traits::use_with_const_ty3]: forward function
+(** [traits::use_with_const_ty3]:
Source: 'src/traits.rs', lines 189:0-189:80 *)
Definition use_with_const_ty3
(H : Type) (LEN : usize) (withConstTyHLENInst : WithConstTy_t H LEN)
@@ -359,12 +358,12 @@ Definition use_with_const_ty3
x
.
-(** [traits::test_where1]: forward function
+(** [traits::test_where1]:
Source: 'src/traits.rs', lines 193:0-193:40 *)
Definition test_where1 (T : Type) (_x : T) : result unit :=
Return tt.
-(** [traits::test_where2]: forward function
+(** [traits::test_where2]:
Source: 'src/traits.rs', lines 194:0-194:57 *)
Definition test_where2
(T : Type) (withConstTyT32Inst : WithConstTy_t T 32%usize) (_x : u32) :
@@ -403,16 +402,25 @@ Arguments mkChildTrait_t { _ }.
Arguments ChildTrait_tChildTrait_t_ParentTrait0SelfInst { _ }.
Arguments ChildTrait_tChildTrait_t_ParentTrait1SelfInst { _ }.
-(** [traits::test_child_trait1]: forward function
- Source: 'src/traits.rs', lines 209:0-209:56 *)
+(** [traits::test_parent_trait0]:
+ Source: 'src/traits.rs', lines 208:0-208:57 *)
+Definition test_parent_trait0
+ (T : Type) (parentTrait0TInst : ParentTrait0_t T) (x : T) :
+ result parentTrait0TInst.(ParentTrait0_tParentTrait0_t_W)
+ :=
+ parentTrait0TInst.(ParentTrait0_t_get_w) x
+.
+
+(** [traits::test_child_trait1]:
+ Source: 'src/traits.rs', lines 213:0-213:56 *)
Definition test_child_trait1
(T : Type) (childTraitTInst : ChildTrait_t T) (x : T) : result string :=
childTraitTInst.(ChildTrait_tChildTrait_t_ParentTrait0SelfInst).(ParentTrait0_t_get_name)
x
.
-(** [traits::test_child_trait2]: forward function
- Source: 'src/traits.rs', lines 213:0-213:54 *)
+(** [traits::test_child_trait2]:
+ Source: 'src/traits.rs', lines 217:0-217:54 *)
Definition test_child_trait2
(T : Type) (childTraitTInst : ChildTrait_t T) (x : T) :
result
@@ -422,8 +430,8 @@ Definition test_child_trait2
x
.
-(** [traits::order1]: forward function
- Source: 'src/traits.rs', lines 219:0-219:59 *)
+(** [traits::order1]:
+ Source: 'src/traits.rs', lines 223:0-223:59 *)
Definition order1
(T U : Type) (parentTrait0TInst : ParentTrait0_t T) (parentTrait0UInst :
ParentTrait0_t U) :
@@ -433,7 +441,7 @@ Definition order1
.
(** Trait declaration: [traits::ChildTrait1]
- Source: 'src/traits.rs', lines 222:0-222:35 *)
+ Source: 'src/traits.rs', lines 226:0-226:35 *)
Record ChildTrait1_t (Self : Type) := mkChildTrait1_t {
ChildTrait1_tChildTrait1_t_ParentTrait1SelfInst : ParentTrait1_t Self;
}.
@@ -442,19 +450,19 @@ Arguments mkChildTrait1_t { _ }.
Arguments ChildTrait1_tChildTrait1_t_ParentTrait1SelfInst { _ }.
(** Trait implementation: [traits::{usize#9}]
- Source: 'src/traits.rs', lines 224:0-224:27 *)
+ Source: 'src/traits.rs', lines 228:0-228:27 *)
Definition traits_ParentTrait1UsizeInst : ParentTrait1_t usize
:= mkParentTrait1_t.
(** Trait implementation: [traits::{usize#10}]
- Source: 'src/traits.rs', lines 225:0-225:26 *)
+ Source: 'src/traits.rs', lines 229:0-229:26 *)
Definition traits_ChildTrait1UsizeInst : ChildTrait1_t usize := {|
ChildTrait1_tChildTrait1_t_ParentTrait1SelfInst :=
traits_ParentTrait1UsizeInst;
|}.
(** Trait declaration: [traits::Iterator]
- Source: 'src/traits.rs', lines 229:0-229:18 *)
+ Source: 'src/traits.rs', lines 233:0-233:18 *)
Record Iterator_t (Self : Type) := mkIterator_t {
Iterator_tIterator_t_Item : Type;
}.
@@ -463,7 +471,7 @@ Arguments mkIterator_t { _ }.
Arguments Iterator_tIterator_t_Item { _ }.
(** Trait declaration: [traits::IntoIterator]
- Source: 'src/traits.rs', lines 233:0-233:22 *)
+ Source: 'src/traits.rs', lines 237:0-237:22 *)
Record IntoIterator_t (Self : Type) := mkIntoIterator_t {
IntoIterator_tIntoIterator_t_Item : Type;
IntoIterator_tIntoIterator_t_IntoIter : Type;
@@ -480,13 +488,13 @@ Arguments IntoIterator_tIntoIterator_t_IntoIter_clause_0 { _ }.
Arguments IntoIterator_t_into_iter { _ }.
(** Trait declaration: [traits::FromResidual]
- Source: 'src/traits.rs', lines 250:0-250:21 *)
+ Source: 'src/traits.rs', lines 254:0-254:21 *)
Record FromResidual_t (Self T : Type) := mkFromResidual_t{}.
Arguments mkFromResidual_t { _ _ }.
(** Trait declaration: [traits::Try]
- Source: 'src/traits.rs', lines 246:0-246:48 *)
+ Source: 'src/traits.rs', lines 250:0-250:48 *)
Record Try_t (Self : Type) := mkTry_t {
Try_tTry_t_Residual : Type;
Try_tTry_t_FromResidualSelftraitsTrySelfResidualInst : FromResidual_t Self
@@ -498,7 +506,7 @@ Arguments Try_tTry_t_Residual { _ }.
Arguments Try_tTry_t_FromResidualSelftraitsTrySelfResidualInst { _ }.
(** Trait declaration: [traits::WithTarget]
- Source: 'src/traits.rs', lines 252:0-252:20 *)
+ Source: 'src/traits.rs', lines 256:0-256:20 *)
Record WithTarget_t (Self : Type) := mkWithTarget_t {
WithTarget_tWithTarget_t_Target : Type;
}.
@@ -507,7 +515,7 @@ Arguments mkWithTarget_t { _ }.
Arguments WithTarget_tWithTarget_t_Target { _ }.
(** Trait declaration: [traits::ParentTrait2]
- Source: 'src/traits.rs', lines 256:0-256:22 *)
+ Source: 'src/traits.rs', lines 260:0-260:22 *)
Record ParentTrait2_t (Self : Type) := mkParentTrait2_t {
ParentTrait2_tParentTrait2_t_U : Type;
ParentTrait2_tParentTrait2_t_U_clause_0 : WithTarget_t
@@ -519,7 +527,7 @@ Arguments ParentTrait2_tParentTrait2_t_U { _ }.
Arguments ParentTrait2_tParentTrait2_t_U_clause_0 { _ }.
(** Trait declaration: [traits::ChildTrait2]
- Source: 'src/traits.rs', lines 260:0-260:35 *)
+ Source: 'src/traits.rs', lines 264:0-264:35 *)
Record ChildTrait2_t (Self : Type) := mkChildTrait2_t {
ChildTrait2_tChildTrait2_t_ParentTrait2SelfInst : ParentTrait2_t Self;
ChildTrait2_t_convert :
@@ -533,25 +541,25 @@ Arguments ChildTrait2_tChildTrait2_t_ParentTrait2SelfInst { _ }.
Arguments ChildTrait2_t_convert { _ }.
(** Trait implementation: [traits::{u32#11}]
- Source: 'src/traits.rs', lines 264:0-264:23 *)
+ Source: 'src/traits.rs', lines 268:0-268:23 *)
Definition traits_WithTargetU32Inst : WithTarget_t u32 := {|
WithTarget_tWithTarget_t_Target := u32;
|}.
(** Trait implementation: [traits::{u32#12}]
- Source: 'src/traits.rs', lines 268:0-268:25 *)
+ Source: 'src/traits.rs', lines 272:0-272:25 *)
Definition traits_ParentTrait2U32Inst : ParentTrait2_t u32 := {|
ParentTrait2_tParentTrait2_t_U := u32;
ParentTrait2_tParentTrait2_t_U_clause_0 := traits_WithTargetU32Inst;
|}.
-(** [traits::{u32#13}::convert]: forward function
- Source: 'src/traits.rs', lines 273:4-273:29 *)
+(** [traits::{u32#13}::convert]:
+ Source: 'src/traits.rs', lines 277:4-277:29 *)
Definition u32_convert (x : u32) : result u32 :=
Return x.
(** Trait implementation: [traits::{u32#13}]
- Source: 'src/traits.rs', lines 272:0-272:24 *)
+ Source: 'src/traits.rs', lines 276:0-276:24 *)
Definition traits_ChildTrait2U32Inst : ChildTrait2_t u32 := {|
ChildTrait2_tChildTrait2_t_ParentTrait2SelfInst :=
traits_ParentTrait2U32Inst;
@@ -559,7 +567,7 @@ Definition traits_ChildTrait2U32Inst : ChildTrait2_t u32 := {|
|}.
(** Trait declaration: [traits::CFnOnce]
- Source: 'src/traits.rs', lines 286:0-286:23 *)
+ Source: 'src/traits.rs', lines 290:0-290:23 *)
Record CFnOnce_t (Self Args : Type) := mkCFnOnce_t {
CFnOnce_tCFnOnce_t_Output : Type;
CFnOnce_t_call_once : Self -> Args -> result CFnOnce_tCFnOnce_t_Output;
@@ -570,31 +578,48 @@ Arguments CFnOnce_tCFnOnce_t_Output { _ _ }.
Arguments CFnOnce_t_call_once { _ _ }.
(** Trait declaration: [traits::CFnMut]
- Source: 'src/traits.rs', lines 292:0-292:37 *)
+ Source: 'src/traits.rs', lines 296:0-296:37 *)
Record CFnMut_t (Self Args : Type) := mkCFnMut_t {
CFnMut_tCFnMut_t_CFnOnceSelfArgsInst : CFnOnce_t Self Args;
CFnMut_t_call_mut : Self -> Args -> result
- (CFnMut_tCFnMut_t_CFnOnceSelfArgsInst).(CFnOnce_tCFnOnce_t_Output);
- CFnMut_t_call_mut_back : Self -> Args ->
- (CFnMut_tCFnMut_t_CFnOnceSelfArgsInst).(CFnOnce_tCFnOnce_t_Output) ->
- result Self;
+ ((CFnMut_tCFnMut_t_CFnOnceSelfArgsInst).(CFnOnce_tCFnOnce_t_Output) *
+ Self);
}.
Arguments mkCFnMut_t { _ _ }.
Arguments CFnMut_tCFnMut_t_CFnOnceSelfArgsInst { _ _ }.
Arguments CFnMut_t_call_mut { _ _ }.
-Arguments CFnMut_t_call_mut_back { _ _ }.
(** Trait declaration: [traits::CFn]
- Source: 'src/traits.rs', lines 296:0-296:33 *)
+ Source: 'src/traits.rs', lines 300:0-300:33 *)
Record CFn_t (Self Args : Type) := mkCFn_t {
CFn_tCFn_t_CFnMutSelfArgsInst : CFnMut_t Self Args;
- CFn_t_call_mut : Self -> Args -> result
+ CFn_t_call : Self -> Args -> result
(CFn_tCFn_t_CFnMutSelfArgsInst).(CFnMut_tCFnMut_t_CFnOnceSelfArgsInst).(CFnOnce_tCFnOnce_t_Output);
}.
Arguments mkCFn_t { _ _ }.
Arguments CFn_tCFn_t_CFnMutSelfArgsInst { _ _ }.
-Arguments CFn_t_call_mut { _ _ }.
+Arguments CFn_t_call { _ _ }.
+
+(** Trait declaration: [traits::GetTrait]
+ Source: 'src/traits.rs', lines 304:0-304:18 *)
+Record GetTrait_t (Self : Type) := mkGetTrait_t {
+ GetTrait_tGetTrait_t_W : Type;
+ GetTrait_t_get_w : Self -> result GetTrait_tGetTrait_t_W;
+}.
+
+Arguments mkGetTrait_t { _ }.
+Arguments GetTrait_tGetTrait_t_W { _ }.
+Arguments GetTrait_t_get_w { _ }.
+
+(** [traits::test_get_trait]:
+ Source: 'src/traits.rs', lines 309:0-309:49 *)
+Definition test_get_trait
+ (T : Type) (getTraitTInst : GetTrait_t T) (x : T) :
+ result getTraitTInst.(GetTrait_tGetTrait_t_W)
+ :=
+ getTraitTInst.(GetTrait_t_get_w) x
+.
End Traits.