diff options
author | Aymeric Fromherz | 2024-05-31 13:09:37 +0200 |
---|---|---|
committer | Aymeric Fromherz | 2024-05-31 13:09:37 +0200 |
commit | 092dae81f5f90281b634e229102d2dff7f5c3fd7 (patch) | |
tree | a12b32fb8c41844de6644fa0c36b658811598ec3 /tests/lean | |
parent | 1ee3d0f7d4f3c83351d5989c7979be3642069e63 (diff) |
Regenerate test output
Diffstat (limited to 'tests/lean')
-rw-r--r-- | tests/lean/Arrays.lean | 53 | ||||
-rw-r--r-- | tests/lean/Demo/Demo.lean | 25 | ||||
-rw-r--r-- | tests/lean/Hashmap/Funs.lean | 148 | ||||
-rw-r--r-- | tests/lean/HashmapMain/Funs.lean | 154 | ||||
-rw-r--r-- | tests/lean/Loops.lean | 375 |
5 files changed, 719 insertions, 36 deletions
diff --git a/tests/lean/Arrays.lean b/tests/lean/Arrays.lean index 464c3ced..5ffcce51 100644 --- a/tests/lean/Arrays.lean +++ b/tests/lean/Arrays.lean @@ -345,15 +345,48 @@ def take_array_t (a : Array AB 2#usize) : Result Unit := def non_copyable_array : Result Unit := take_array_t (Array.make AB 2#usize [ AB.A, AB.B ]) +/- [arrays::sum]: loop 0: + Source: 'tests/src/arrays.rs', lines 242:0-250:1 -/ +divergent def sum_loop (s : Slice U32) (sum1 : U32) (i : Usize) : Result U32 := + let i1 := Slice.len U32 s + if i < i1 + then + do + let i2 ← Slice.index_usize U32 s i + let sum3 ← sum1 + i2 + let i3 ← i + 1#usize + sum_loop s sum3 i3 + else Result.ok sum1 + /- [arrays::sum]: Source: 'tests/src/arrays.rs', lines 242:0-242:28 -/ def sum (s : Slice U32) : Result U32 := - sorry + sum_loop s 0#u32 0#usize + +/- [arrays::sum2]: loop 0: + Source: 'tests/src/arrays.rs', lines 252:0-261:1 -/ +divergent def sum2_loop + (s : Slice U32) (s2 : Slice U32) (sum1 : U32) (i : Usize) : Result U32 := + let i1 := Slice.len U32 s + if i < i1 + then + do + let i2 ← Slice.index_usize U32 s i + let i3 ← Slice.index_usize U32 s2 i + let i4 ← i2 + i3 + let sum3 ← sum1 + i4 + let i5 ← i + 1#usize + sum2_loop s s2 sum3 i5 + else Result.ok sum1 /- [arrays::sum2]: Source: 'tests/src/arrays.rs', lines 252:0-252:41 -/ def sum2 (s : Slice U32) (s2 : Slice U32) : Result U32 := - sorry + let i := Slice.len U32 s + let i1 := Slice.len U32 s2 + if ¬ (i = i1) + then Result.fail .panic + else sum2_loop s s2 0#u32 0#usize /- [arrays::f0]: Source: 'tests/src/arrays.rs', lines 263:0-263:11 -/ @@ -427,10 +460,24 @@ def ite : Result Unit := let _ ← to_slice_mut_back s1 Result.ok () +/- [arrays::zero_slice]: loop 0: + Source: 'tests/src/arrays.rs', lines 303:0-310:1 -/ +divergent def zero_slice_loop + (a : Slice U8) (i : Usize) (len : Usize) : Result (Slice U8) := + if i < len + then + do + let (_, index_mut_back) ← Slice.index_mut_usize U8 a i + let i1 ← i + 1#usize + let a1 ← index_mut_back 0#u8 + zero_slice_loop a1 i1 len + else Result.ok a + /- [arrays::zero_slice]: Source: 'tests/src/arrays.rs', lines 303:0-303:31 -/ def zero_slice (a : Slice U8) : Result (Slice U8) := - sorry + let len := Slice.len U8 a + zero_slice_loop a 0#usize len /- [arrays::iter_mut_slice]: loop 0: Source: 'tests/src/arrays.rs', lines 312:0-318:1 -/ diff --git a/tests/lean/Demo/Demo.lean b/tests/lean/Demo/Demo.lean index 7402f010..a9b349b3 100644 --- a/tests/lean/Demo/Demo.lean +++ b/tests/lean/Demo/Demo.lean @@ -87,13 +87,36 @@ divergent def list_nth_mut Result.ok (t, back) | CList.CNil => Result.fail .panic +/- [demo::list_nth_mut1]: loop 0: + Source: 'tests/src/demo.rs', lines 69:0-78:1 -/ +divergent def list_nth_mut1_loop + (T : Type) (l : CList T) (i : U32) : + Result (T × (T → Result (CList T))) + := + match l with + | CList.CCons x tl => + if i = 0#u32 + then + let back := fun ret => Result.ok (CList.CCons ret tl) + Result.ok (x, back) + else + do + let i1 ← i - 1#u32 + let (t, back) ← list_nth_mut1_loop T tl i1 + let back1 := + fun ret => do + let tl1 ← back ret + Result.ok (CList.CCons x tl1) + Result.ok (t, back1) + | CList.CNil => Result.fail .panic + /- [demo::list_nth_mut1]: Source: 'tests/src/demo.rs', lines 69:0-69:77 -/ def list_nth_mut1 (T : Type) (l : CList T) (i : U32) : Result (T × (T → Result (CList T))) := - sorry + list_nth_mut1_loop T l i /- [demo::i32_id]: Source: 'tests/src/demo.rs', lines 80:0-80:28 -/ diff --git a/tests/lean/Hashmap/Funs.lean b/tests/lean/Hashmap/Funs.lean index a107240e..17ad26f7 100644 --- a/tests/lean/Hashmap/Funs.lean +++ b/tests/lean/Hashmap/Funs.lean @@ -57,23 +57,59 @@ def HashMap.new_with_capacity def HashMap.new (T : Type) : Result (HashMap T) := HashMap.new_with_capacity T 32#usize 4#usize 5#usize +/- [hashmap::{hashmap::HashMap<T>}::clear]: loop 0: + Source: 'tests/src/hashmap.rs', lines 80:4-88:5 -/ +divergent def HashMap.clear_loop + (T : Type) (slots : alloc.vec.Vec (List T)) (i : Usize) : + Result (alloc.vec.Vec (List T)) + := + let i1 := alloc.vec.Vec.len (List T) slots + if i < i1 + then + do + let (_, index_mut_back) ← + alloc.vec.Vec.index_mut (List T) Usize + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) slots i + let i2 ← i + 1#usize + let slots1 ← index_mut_back List.Nil + HashMap.clear_loop T slots1 i2 + else Result.ok slots + /- [hashmap::{hashmap::HashMap<T>}::clear]: Source: 'tests/src/hashmap.rs', lines 80:4-80:27 -/ def HashMap.clear (T : Type) (self : HashMap T) : Result (HashMap T) := - sorry + do + let hm ← HashMap.clear_loop T self.slots 0#usize + Result.ok { self with num_entries := 0#usize, slots := hm } /- [hashmap::{hashmap::HashMap<T>}::len]: Source: 'tests/src/hashmap.rs', lines 90:4-90:30 -/ def HashMap.len (T : Type) (self : HashMap T) : Result Usize := Result.ok self.num_entries +/- [hashmap::{hashmap::HashMap<T>}::insert_in_list]: loop 0: + Source: 'tests/src/hashmap.rs', lines 97:4-114:5 -/ +divergent def HashMap.insert_in_list_loop + (T : Type) (key : Usize) (value : T) (ls : List T) : + Result (Bool × (List T)) + := + match ls with + | List.Cons ckey cvalue tl => + if ckey = key + then Result.ok (false, List.Cons ckey value tl) + else + do + let (b, tl1) ← HashMap.insert_in_list_loop T key value tl + Result.ok (b, List.Cons ckey cvalue tl1) + | List.Nil => Result.ok (true, List.Cons key value List.Nil) + /- [hashmap::{hashmap::HashMap<T>}::insert_in_list]: Source: 'tests/src/hashmap.rs', lines 97:4-97:71 -/ def HashMap.insert_in_list (T : Type) (key : Usize) (value : T) (ls : List T) : Result (Bool × (List T)) := - sorry + HashMap.insert_in_list_loop T key value ls /- [hashmap::{hashmap::HashMap<T>}::insert_no_resize]: Source: 'tests/src/hashmap.rs', lines 117:4-117:54 -/ @@ -99,11 +135,43 @@ def HashMap.insert_no_resize let v ← index_mut_back l1 Result.ok { self with slots := v } +/- [hashmap::{hashmap::HashMap<T>}::move_elements_from_list]: loop 0: + Source: 'tests/src/hashmap.rs', lines 183:4-196:5 -/ +divergent def HashMap.move_elements_from_list_loop + (T : Type) (ntable : HashMap T) (ls : List T) : Result (HashMap T) := + match ls with + | List.Cons k v tl => + do + let ntable1 ← HashMap.insert_no_resize T ntable k v + HashMap.move_elements_from_list_loop T ntable1 tl + | List.Nil => Result.ok ntable + /- [hashmap::{hashmap::HashMap<T>}::move_elements_from_list]: Source: 'tests/src/hashmap.rs', lines 183:4-183:72 -/ def HashMap.move_elements_from_list (T : Type) (ntable : HashMap T) (ls : List T) : Result (HashMap T) := - sorry + HashMap.move_elements_from_list_loop T ntable ls + +/- [hashmap::{hashmap::HashMap<T>}::move_elements]: loop 0: + Source: 'tests/src/hashmap.rs', lines 171:4-180:5 -/ +divergent def HashMap.move_elements_loop + (T : Type) (ntable : HashMap T) (slots : alloc.vec.Vec (List T)) (i : Usize) + : + Result ((alloc.vec.Vec (List T)) × (HashMap T)) + := + let i1 := alloc.vec.Vec.len (List T) slots + if i < i1 + then + do + let (l, index_mut_back) ← + alloc.vec.Vec.index_mut (List T) Usize + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) slots i + let (ls, l1) := core.mem.replace (List T) l List.Nil + let ntable1 ← HashMap.move_elements_from_list T ntable ls + let i2 ← i + 1#usize + let slots1 ← index_mut_back l1 + HashMap.move_elements_loop T ntable1 slots1 i2 + else Result.ok (ntable, slots) /- [hashmap::{hashmap::HashMap<T>}::move_elements]: Source: 'tests/src/hashmap.rs', lines 171:4-171:95 -/ @@ -112,7 +180,7 @@ def HashMap.move_elements : Result ((HashMap T) × (alloc.vec.Vec (List T))) := - sorry + HashMap.move_elements_loop T ntable slots i /- [hashmap::{hashmap::HashMap<T>}::try_resize]: Source: 'tests/src/hashmap.rs', lines 140:4-140:28 -/ @@ -151,11 +219,22 @@ def HashMap.insert then HashMap.try_resize T self1 else Result.ok self1 +/- [hashmap::{hashmap::HashMap<T>}::contains_key_in_list]: loop 0: + Source: 'tests/src/hashmap.rs', lines 206:4-219:5 -/ +divergent def HashMap.contains_key_in_list_loop + (T : Type) (key : Usize) (ls : List T) : Result Bool := + match ls with + | List.Cons ckey _ tl => + if ckey = key + then Result.ok true + else HashMap.contains_key_in_list_loop T key tl + | List.Nil => Result.ok false + /- [hashmap::{hashmap::HashMap<T>}::contains_key_in_list]: Source: 'tests/src/hashmap.rs', lines 206:4-206:68 -/ def HashMap.contains_key_in_list (T : Type) (key : Usize) (ls : List T) : Result Bool := - sorry + HashMap.contains_key_in_list_loop T key ls /- [hashmap::{hashmap::HashMap<T>}::contains_key]: Source: 'tests/src/hashmap.rs', lines 199:4-199:49 -/ @@ -170,10 +249,21 @@ def HashMap.contains_key (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots hash_mod HashMap.contains_key_in_list T key l +/- [hashmap::{hashmap::HashMap<T>}::get_in_list]: loop 0: + Source: 'tests/src/hashmap.rs', lines 224:4-237:5 -/ +divergent def HashMap.get_in_list_loop + (T : Type) (key : Usize) (ls : List T) : Result T := + match ls with + | List.Cons ckey cvalue tl => + if ckey = key + then Result.ok cvalue + else HashMap.get_in_list_loop T key tl + | List.Nil => Result.fail .panic + /- [hashmap::{hashmap::HashMap<T>}::get_in_list]: Source: 'tests/src/hashmap.rs', lines 224:4-224:70 -/ def HashMap.get_in_list (T : Type) (key : Usize) (ls : List T) : Result T := - sorry + HashMap.get_in_list_loop T key ls /- [hashmap::{hashmap::HashMap<T>}::get]: Source: 'tests/src/hashmap.rs', lines 239:4-239:55 -/ @@ -187,13 +277,36 @@ def HashMap.get (T : Type) (self : HashMap T) (key : Usize) : Result T := (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots hash_mod HashMap.get_in_list T key l +/- [hashmap::{hashmap::HashMap<T>}::get_mut_in_list]: loop 0: + Source: 'tests/src/hashmap.rs', lines 245:4-254:5 -/ +divergent def HashMap.get_mut_in_list_loop + (T : Type) (ls : List T) (key : Usize) : + Result (T × (T → Result (List T))) + := + match ls with + | List.Cons ckey cvalue tl => + if ckey = key + then + let back := fun ret => Result.ok (List.Cons ckey ret tl) + Result.ok (cvalue, back) + else + do + let (t, back) ← HashMap.get_mut_in_list_loop T tl key + let back1 := + fun ret => + do + let tl1 ← back ret + Result.ok (List.Cons ckey cvalue tl1) + Result.ok (t, back1) + | List.Nil => Result.fail .panic + /- [hashmap::{hashmap::HashMap<T>}::get_mut_in_list]: Source: 'tests/src/hashmap.rs', lines 245:4-245:86 -/ def HashMap.get_mut_in_list (T : Type) (ls : List T) (key : Usize) : Result (T × (T → Result (List T))) := - sorry + HashMap.get_mut_in_list_loop T ls key /- [hashmap::{hashmap::HashMap<T>}::get_mut]: Source: 'tests/src/hashmap.rs', lines 257:4-257:67 -/ @@ -217,11 +330,30 @@ def HashMap.get_mut Result.ok { self with slots := v } Result.ok (t, back) +/- [hashmap::{hashmap::HashMap<T>}::remove_from_list]: loop 0: + Source: 'tests/src/hashmap.rs', lines 265:4-291:5 -/ +divergent def HashMap.remove_from_list_loop + (T : Type) (key : Usize) (ls : List T) : Result ((Option T) × (List T)) := + match ls with + | List.Cons ckey t tl => + if ckey = key + then + let (mv_ls, _) := + core.mem.replace (List T) (List.Cons ckey t tl) List.Nil + match mv_ls with + | List.Cons _ cvalue tl1 => Result.ok (some cvalue, tl1) + | List.Nil => Result.fail .panic + else + do + let (o, tl1) ← HashMap.remove_from_list_loop T key tl + Result.ok (o, List.Cons ckey t tl1) + | List.Nil => Result.ok (none, List.Nil) + /- [hashmap::{hashmap::HashMap<T>}::remove_from_list]: Source: 'tests/src/hashmap.rs', lines 265:4-265:69 -/ def HashMap.remove_from_list (T : Type) (key : Usize) (ls : List T) : Result ((Option T) × (List T)) := - sorry + HashMap.remove_from_list_loop T key ls /- [hashmap::{hashmap::HashMap<T>}::remove]: Source: 'tests/src/hashmap.rs', lines 294:4-294:52 -/ diff --git a/tests/lean/HashmapMain/Funs.lean b/tests/lean/HashmapMain/Funs.lean index d3c4ae77..56039741 100644 --- a/tests/lean/HashmapMain/Funs.lean +++ b/tests/lean/HashmapMain/Funs.lean @@ -60,24 +60,61 @@ def hashmap.HashMap.new_with_capacity def hashmap.HashMap.new (T : Type) : Result (hashmap.HashMap T) := hashmap.HashMap.new_with_capacity T 32#usize 4#usize 5#usize +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::clear]: loop 0: + Source: 'tests/src/hashmap.rs', lines 80:4-88:5 -/ +divergent def hashmap.HashMap.clear_loop + (T : Type) (slots : alloc.vec.Vec (hashmap.List T)) (i : Usize) : + Result (alloc.vec.Vec (hashmap.List T)) + := + let i1 := alloc.vec.Vec.len (hashmap.List T) slots + if i < i1 + then + do + let (_, index_mut_back) ← + alloc.vec.Vec.index_mut (hashmap.List T) Usize + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) slots i + let i2 ← i + 1#usize + let slots1 ← index_mut_back hashmap.List.Nil + hashmap.HashMap.clear_loop T slots1 i2 + else Result.ok slots + /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::clear]: Source: 'tests/src/hashmap.rs', lines 80:4-80:27 -/ def hashmap.HashMap.clear (T : Type) (self : hashmap.HashMap T) : Result (hashmap.HashMap T) := - sorry + do + let hm ← hashmap.HashMap.clear_loop T self.slots 0#usize + Result.ok { self with num_entries := 0#usize, slots := hm } /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::len]: Source: 'tests/src/hashmap.rs', lines 90:4-90:30 -/ def hashmap.HashMap.len (T : Type) (self : hashmap.HashMap T) : Result Usize := Result.ok self.num_entries +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert_in_list]: loop 0: + Source: 'tests/src/hashmap.rs', lines 97:4-114:5 -/ +divergent def hashmap.HashMap.insert_in_list_loop + (T : Type) (key : Usize) (value : T) (ls : hashmap.List T) : + Result (Bool × (hashmap.List T)) + := + match ls with + | hashmap.List.Cons ckey cvalue tl => + if ckey = key + then Result.ok (false, hashmap.List.Cons ckey value tl) + else + do + let (b, tl1) ← hashmap.HashMap.insert_in_list_loop T key value tl + Result.ok (b, hashmap.List.Cons ckey cvalue tl1) + | hashmap.List.Nil => + Result.ok (true, hashmap.List.Cons key value hashmap.List.Nil) + /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert_in_list]: Source: 'tests/src/hashmap.rs', lines 97:4-97:71 -/ def hashmap.HashMap.insert_in_list (T : Type) (key : Usize) (value : T) (ls : hashmap.List T) : Result (Bool × (hashmap.List T)) := - sorry + hashmap.HashMap.insert_in_list_loop T key value ls /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::insert_no_resize]: Source: 'tests/src/hashmap.rs', lines 117:4-117:54 -/ @@ -104,13 +141,47 @@ def hashmap.HashMap.insert_no_resize let v ← index_mut_back l1 Result.ok { self with slots := v } +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements_from_list]: loop 0: + Source: 'tests/src/hashmap.rs', lines 183:4-196:5 -/ +divergent def hashmap.HashMap.move_elements_from_list_loop + (T : Type) (ntable : hashmap.HashMap T) (ls : hashmap.List T) : + Result (hashmap.HashMap T) + := + match ls with + | hashmap.List.Cons k v tl => + do + let ntable1 ← hashmap.HashMap.insert_no_resize T ntable k v + hashmap.HashMap.move_elements_from_list_loop T ntable1 tl + | hashmap.List.Nil => Result.ok ntable + /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements_from_list]: Source: 'tests/src/hashmap.rs', lines 183:4-183:72 -/ def hashmap.HashMap.move_elements_from_list (T : Type) (ntable : hashmap.HashMap T) (ls : hashmap.List T) : Result (hashmap.HashMap T) := - sorry + hashmap.HashMap.move_elements_from_list_loop T ntable ls + +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements]: loop 0: + Source: 'tests/src/hashmap.rs', lines 171:4-180:5 -/ +divergent def hashmap.HashMap.move_elements_loop + (T : Type) (ntable : hashmap.HashMap T) + (slots : alloc.vec.Vec (hashmap.List T)) (i : Usize) : + Result ((alloc.vec.Vec (hashmap.List T)) × (hashmap.HashMap T)) + := + let i1 := alloc.vec.Vec.len (hashmap.List T) slots + if i < i1 + then + do + let (l, index_mut_back) ← + alloc.vec.Vec.index_mut (hashmap.List T) Usize + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) slots i + let (ls, l1) := core.mem.replace (hashmap.List T) l hashmap.List.Nil + let ntable1 ← hashmap.HashMap.move_elements_from_list T ntable ls + let i2 ← i + 1#usize + let slots1 ← index_mut_back l1 + hashmap.HashMap.move_elements_loop T ntable1 slots1 i2 + else Result.ok (ntable, slots) /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::move_elements]: Source: 'tests/src/hashmap.rs', lines 171:4-171:95 -/ @@ -119,7 +190,7 @@ def hashmap.HashMap.move_elements (slots : alloc.vec.Vec (hashmap.List T)) (i : Usize) : Result ((hashmap.HashMap T) × (alloc.vec.Vec (hashmap.List T))) := - sorry + hashmap.HashMap.move_elements_loop T ntable slots i /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::try_resize]: Source: 'tests/src/hashmap.rs', lines 140:4-140:28 -/ @@ -159,11 +230,22 @@ def hashmap.HashMap.insert then hashmap.HashMap.try_resize T self1 else Result.ok self1 +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::contains_key_in_list]: loop 0: + Source: 'tests/src/hashmap.rs', lines 206:4-219:5 -/ +divergent def hashmap.HashMap.contains_key_in_list_loop + (T : Type) (key : Usize) (ls : hashmap.List T) : Result Bool := + match ls with + | hashmap.List.Cons ckey _ tl => + if ckey = key + then Result.ok true + else hashmap.HashMap.contains_key_in_list_loop T key tl + | hashmap.List.Nil => Result.ok false + /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::contains_key_in_list]: Source: 'tests/src/hashmap.rs', lines 206:4-206:68 -/ def hashmap.HashMap.contains_key_in_list (T : Type) (key : Usize) (ls : hashmap.List T) : Result Bool := - sorry + hashmap.HashMap.contains_key_in_list_loop T key ls /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::contains_key]: Source: 'tests/src/hashmap.rs', lines 199:4-199:49 -/ @@ -179,11 +261,22 @@ def hashmap.HashMap.contains_key hash_mod hashmap.HashMap.contains_key_in_list T key l +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_in_list]: loop 0: + Source: 'tests/src/hashmap.rs', lines 224:4-237:5 -/ +divergent def hashmap.HashMap.get_in_list_loop + (T : Type) (key : Usize) (ls : hashmap.List T) : Result T := + match ls with + | hashmap.List.Cons ckey cvalue tl => + if ckey = key + then Result.ok cvalue + else hashmap.HashMap.get_in_list_loop T key tl + | hashmap.List.Nil => Result.fail .panic + /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_in_list]: Source: 'tests/src/hashmap.rs', lines 224:4-224:70 -/ def hashmap.HashMap.get_in_list (T : Type) (key : Usize) (ls : hashmap.List T) : Result T := - sorry + hashmap.HashMap.get_in_list_loop T key ls /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get]: Source: 'tests/src/hashmap.rs', lines 239:4-239:55 -/ @@ -199,13 +292,36 @@ def hashmap.HashMap.get hash_mod hashmap.HashMap.get_in_list T key l +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_mut_in_list]: loop 0: + Source: 'tests/src/hashmap.rs', lines 245:4-254:5 -/ +divergent def hashmap.HashMap.get_mut_in_list_loop + (T : Type) (ls : hashmap.List T) (key : Usize) : + Result (T × (T → Result (hashmap.List T))) + := + match ls with + | hashmap.List.Cons ckey cvalue tl => + if ckey = key + then + let back := fun ret => Result.ok (hashmap.List.Cons ckey ret tl) + Result.ok (cvalue, back) + else + do + let (t, back) ← hashmap.HashMap.get_mut_in_list_loop T tl key + let back1 := + fun ret => + do + let tl1 ← back ret + Result.ok (hashmap.List.Cons ckey cvalue tl1) + Result.ok (t, back1) + | hashmap.List.Nil => Result.fail .panic + /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_mut_in_list]: Source: 'tests/src/hashmap.rs', lines 245:4-245:86 -/ def hashmap.HashMap.get_mut_in_list (T : Type) (ls : hashmap.List T) (key : Usize) : Result (T × (T → Result (hashmap.List T))) := - sorry + hashmap.HashMap.get_mut_in_list_loop T ls key /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::get_mut]: Source: 'tests/src/hashmap.rs', lines 257:4-257:67 -/ @@ -230,13 +346,35 @@ def hashmap.HashMap.get_mut Result.ok { self with slots := v } Result.ok (t, back) +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::remove_from_list]: loop 0: + Source: 'tests/src/hashmap.rs', lines 265:4-291:5 -/ +divergent def hashmap.HashMap.remove_from_list_loop + (T : Type) (key : Usize) (ls : hashmap.List T) : + Result ((Option T) × (hashmap.List T)) + := + match ls with + | hashmap.List.Cons ckey t tl => + if ckey = key + then + let (mv_ls, _) := + core.mem.replace (hashmap.List T) (hashmap.List.Cons ckey t tl) + hashmap.List.Nil + match mv_ls with + | hashmap.List.Cons _ cvalue tl1 => Result.ok (some cvalue, tl1) + | hashmap.List.Nil => Result.fail .panic + else + do + let (o, tl1) ← hashmap.HashMap.remove_from_list_loop T key tl + Result.ok (o, hashmap.List.Cons ckey t tl1) + | hashmap.List.Nil => Result.ok (none, hashmap.List.Nil) + /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::remove_from_list]: Source: 'tests/src/hashmap.rs', lines 265:4-265:69 -/ def hashmap.HashMap.remove_from_list (T : Type) (key : Usize) (ls : hashmap.List T) : Result ((Option T) × (hashmap.List T)) := - sorry + hashmap.HashMap.remove_from_list_loop T key ls /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap<T>}::remove]: Source: 'tests/src/hashmap.rs', lines 294:4-294:52 -/ diff --git a/tests/lean/Loops.lean b/tests/lean/Loops.lean index 046d2240..d5bda6ab 100644 --- a/tests/lean/Loops.lean +++ b/tests/lean/Loops.lean @@ -72,10 +72,26 @@ divergent def sum_array_loop def sum_array (N : Usize) (a : Array U32 N) : Result U32 := sum_array_loop N a 0#usize 0#u32 +/- [loops::clear]: loop 0: + Source: 'tests/src/loops.rs', lines 62:0-68:1 -/ +divergent def clear_loop + (v : alloc.vec.Vec U32) (i : Usize) : Result (alloc.vec.Vec U32) := + let i1 := alloc.vec.Vec.len U32 v + if i < i1 + then + do + let (_, index_mut_back) ← + alloc.vec.Vec.index_mut U32 Usize + (core.slice.index.SliceIndexUsizeSliceTInst U32) v i + let i2 ← i + 1#usize + let v1 ← index_mut_back 0#u32 + clear_loop v1 i2 + else Result.ok v + /- [loops::clear]: Source: 'tests/src/loops.rs', lines 62:0-62:30 -/ def clear (v : alloc.vec.Vec U32) : Result (alloc.vec.Vec U32) := - sorry + clear_loop v 0#usize /- [loops::List] Source: 'tests/src/loops.rs', lines 70:0-70:16 -/ @@ -83,21 +99,86 @@ inductive List (T : Type) := | Cons : T → List T → List T | Nil : List T +/- [loops::list_mem]: loop 0: + Source: 'tests/src/loops.rs', lines 76:0-85:1 -/ +divergent def list_mem_loop (x : U32) (ls : List U32) : Result Bool := + match ls with + | List.Cons y tl => if y = x + then Result.ok true + else list_mem_loop x tl + | List.Nil => Result.ok false + /- [loops::list_mem]: Source: 'tests/src/loops.rs', lines 76:0-76:52 -/ def list_mem (x : U32) (ls : List U32) : Result Bool := - sorry + list_mem_loop x ls + +/- [loops::list_nth_mut_loop]: loop 0: + Source: 'tests/src/loops.rs', lines 88:0-98:1 -/ +divergent def list_nth_mut_loop_loop + (T : Type) (ls : List T) (i : U32) : Result (T × (T → Result (List T))) := + match ls with + | List.Cons x tl => + if i = 0#u32 + then + let back := fun ret => Result.ok (List.Cons ret tl) + Result.ok (x, back) + else + do + let i1 ← i - 1#u32 + let (t, back) ← list_nth_mut_loop_loop T tl i1 + let back1 := + fun ret => do + let tl1 ← back ret + Result.ok (List.Cons x tl1) + Result.ok (t, back1) + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_loop]: Source: 'tests/src/loops.rs', lines 88:0-88:71 -/ def list_nth_mut_loop (T : Type) (ls : List T) (i : U32) : Result (T × (T → Result (List T))) := - sorry + list_nth_mut_loop_loop T ls i + +/- [loops::list_nth_shared_loop]: loop 0: + Source: 'tests/src/loops.rs', lines 101:0-111:1 -/ +divergent def list_nth_shared_loop_loop + (T : Type) (ls : List T) (i : U32) : Result T := + match ls with + | List.Cons x tl => + if i = 0#u32 + then Result.ok x + else do + let i1 ← i - 1#u32 + list_nth_shared_loop_loop T tl i1 + | List.Nil => Result.fail .panic /- [loops::list_nth_shared_loop]: Source: 'tests/src/loops.rs', lines 101:0-101:66 -/ def list_nth_shared_loop (T : Type) (ls : List T) (i : U32) : Result T := - sorry + list_nth_shared_loop_loop T ls i + +/- [loops::get_elem_mut]: loop 0: + Source: 'tests/src/loops.rs', lines 113:0-127:1 -/ +divergent def get_elem_mut_loop + (x : Usize) (ls : List Usize) : + Result (Usize × (Usize → Result (List Usize))) + := + match ls with + | List.Cons y tl => + if y = x + then + let back := fun ret => Result.ok (List.Cons ret tl) + Result.ok (y, back) + else + do + let (i, back) ← get_elem_mut_loop x tl + let back1 := + fun ret => do + let tl1 ← back ret + Result.ok (List.Cons y tl1) + Result.ok (i, back1) + | List.Nil => Result.fail .panic /- [loops::get_elem_mut]: Source: 'tests/src/loops.rs', lines 113:0-113:73 -/ @@ -105,13 +186,35 @@ def get_elem_mut (slots : alloc.vec.Vec (List Usize)) (x : Usize) : Result (Usize × (Usize → Result (alloc.vec.Vec (List Usize)))) := - sorry + do + let (ls, index_mut_back) ← + alloc.vec.Vec.index_mut (List Usize) Usize + (core.slice.index.SliceIndexUsizeSliceTInst (List Usize)) slots 0#usize + let (i, back) ← get_elem_mut_loop x ls + let back1 := fun ret => do + let l ← back ret + index_mut_back l + Result.ok (i, back1) + +/- [loops::get_elem_shared]: loop 0: + Source: 'tests/src/loops.rs', lines 129:0-143:1 -/ +divergent def get_elem_shared_loop + (x : Usize) (ls : List Usize) : Result Usize := + match ls with + | List.Cons y tl => if y = x + then Result.ok y + else get_elem_shared_loop x tl + | List.Nil => Result.fail .panic /- [loops::get_elem_shared]: Source: 'tests/src/loops.rs', lines 129:0-129:68 -/ def get_elem_shared (slots : alloc.vec.Vec (List Usize)) (x : Usize) : Result Usize := - sorry + do + let ls ← + alloc.vec.Vec.index (List Usize) Usize + (core.slice.index.SliceIndexUsizeSliceTInst (List Usize)) slots 0#usize + get_elem_shared_loop x ls /- [loops::id_mut]: Source: 'tests/src/loops.rs', lines 145:0-145:50 -/ @@ -126,17 +229,90 @@ def id_mut def id_shared (T : Type) (ls : List T) : Result (List T) := Result.ok ls +/- [loops::list_nth_mut_loop_with_id]: loop 0: + Source: 'tests/src/loops.rs', lines 154:0-165:1 -/ +divergent def list_nth_mut_loop_with_id_loop + (T : Type) (i : U32) (ls : List T) : Result (T × (T → Result (List T))) := + match ls with + | List.Cons x tl => + if i = 0#u32 + then + let back := fun ret => Result.ok (List.Cons ret tl) + Result.ok (x, back) + else + do + let i1 ← i - 1#u32 + let (t, back) ← list_nth_mut_loop_with_id_loop T i1 tl + let back1 := + fun ret => do + let tl1 ← back ret + Result.ok (List.Cons x tl1) + Result.ok (t, back1) + | List.Nil => Result.fail .panic + /- [loops::list_nth_mut_loop_with_id]: Source: 'tests/src/loops.rs', lines 154:0-154:75 -/ def list_nth_mut_loop_with_id (T : Type) (ls : List T) (i : U32) : Result (T × (T → Result (List T))) := - sorry + do + let (ls1, id_mut_back) ← id_mut T ls + let (t, back) ← list_nth_mut_loop_with_id_loop T i ls1 + let back1 := fun ret => do + let l ← back ret + id_mut_back l + Result.ok (t, back1) + +/- [loops::list_nth_shared_loop_with_id]: loop 0: + Source: 'tests/src/loops.rs', lines 168:0-179:1 -/ +divergent def list_nth_shared_loop_with_id_loop + (T : Type) (i : U32) (ls : List T) : Result T := + match ls with + | List.Cons x tl => + if i = 0#u32 + then Result.ok x + else do + let i1 ← i - 1#u32 + list_nth_shared_loop_with_id_loop T i1 tl + | List.Nil => Result.fail .panic /- [loops::list_nth_shared_loop_with_id]: Source: 'tests/src/loops.rs', lines 168:0-168:70 -/ def list_nth_shared_loop_with_id (T : Type) (ls : List T) (i : U32) : Result T := - sorry + do + let ls1 ← id_shared T ls + list_nth_shared_loop_with_id_loop T i ls1 + +/- [loops::list_nth_mut_loop_pair]: loop 0: + Source: 'tests/src/loops.rs', lines 184:0-205:1 -/ +divergent def list_nth_mut_loop_pair_loop + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : + Result ((T × T) × (T → Result (List T)) × (T → Result (List T))) + := + match ls0 with + | List.Cons x0 tl0 => + match ls1 with + | List.Cons x1 tl1 => + if i = 0#u32 + then + let back'a := fun ret => Result.ok (List.Cons ret tl0) + let back'b := fun ret => Result.ok (List.Cons ret tl1) + Result.ok ((x0, x1), back'a, back'b) + else + do + let i1 ← i - 1#u32 + let (p, back'a, back'b) ← list_nth_mut_loop_pair_loop T tl0 tl1 i1 + let back'a1 := + fun ret => do + let tl01 ← back'a ret + Result.ok (List.Cons x0 tl01) + let back'b1 := + fun ret => do + let tl11 ← back'b ret + Result.ok (List.Cons x1 tl11) + Result.ok (p, back'a1, back'b1) + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_loop_pair]: Source: 'tests/src/loops.rs', lines 184:0-188:27 -/ @@ -144,13 +320,59 @@ def list_nth_mut_loop_pair (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result ((T × T) × (T → Result (List T)) × (T → Result (List T))) := - sorry + list_nth_mut_loop_pair_loop T ls0 ls1 i + +/- [loops::list_nth_shared_loop_pair]: loop 0: + Source: 'tests/src/loops.rs', lines 208:0-229:1 -/ +divergent def list_nth_shared_loop_pair_loop + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := + match ls0 with + | List.Cons x0 tl0 => + match ls1 with + | List.Cons x1 tl1 => + if i = 0#u32 + then Result.ok (x0, x1) + else do + let i1 ← i - 1#u32 + list_nth_shared_loop_pair_loop T tl0 tl1 i1 + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_shared_loop_pair]: Source: 'tests/src/loops.rs', lines 208:0-212:19 -/ def list_nth_shared_loop_pair (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := - sorry + list_nth_shared_loop_pair_loop T ls0 ls1 i + +/- [loops::list_nth_mut_loop_pair_merge]: loop 0: + Source: 'tests/src/loops.rs', lines 233:0-248:1 -/ +divergent def list_nth_mut_loop_pair_merge_loop + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : + Result ((T × T) × ((T × T) → Result ((List T) × (List T)))) + := + match ls0 with + | List.Cons x0 tl0 => + match ls1 with + | List.Cons x1 tl1 => + if i = 0#u32 + then + let back := + fun ret => + let (t, t1) := ret + Result.ok (List.Cons t tl0, List.Cons t1 tl1) + Result.ok ((x0, x1), back) + else + do + let i1 ← i - 1#u32 + let (p, back) ← list_nth_mut_loop_pair_merge_loop T tl0 tl1 i1 + let back1 := + fun ret => + do + let (tl01, tl11) ← back ret + Result.ok (List.Cons x0 tl01, List.Cons x1 tl11) + Result.ok (p, back1) + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_loop_pair_merge]: Source: 'tests/src/loops.rs', lines 233:0-237:27 -/ @@ -158,13 +380,56 @@ def list_nth_mut_loop_pair_merge (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result ((T × T) × ((T × T) → Result ((List T) × (List T)))) := - sorry + list_nth_mut_loop_pair_merge_loop T ls0 ls1 i + +/- [loops::list_nth_shared_loop_pair_merge]: loop 0: + Source: 'tests/src/loops.rs', lines 251:0-266:1 -/ +divergent def list_nth_shared_loop_pair_merge_loop + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := + match ls0 with + | List.Cons x0 tl0 => + match ls1 with + | List.Cons x1 tl1 => + if i = 0#u32 + then Result.ok (x0, x1) + else + do + let i1 ← i - 1#u32 + list_nth_shared_loop_pair_merge_loop T tl0 tl1 i1 + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_shared_loop_pair_merge]: Source: 'tests/src/loops.rs', lines 251:0-255:19 -/ def list_nth_shared_loop_pair_merge (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := - sorry + list_nth_shared_loop_pair_merge_loop T ls0 ls1 i + +/- [loops::list_nth_mut_shared_loop_pair]: loop 0: + Source: 'tests/src/loops.rs', lines 269:0-284:1 -/ +divergent def list_nth_mut_shared_loop_pair_loop + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : + Result ((T × T) × (T → Result (List T))) + := + match ls0 with + | List.Cons x0 tl0 => + match ls1 with + | List.Cons x1 tl1 => + if i = 0#u32 + then + let back := fun ret => Result.ok (List.Cons ret tl0) + Result.ok ((x0, x1), back) + else + do + let i1 ← i - 1#u32 + let (p, back) ← list_nth_mut_shared_loop_pair_loop T tl0 tl1 i1 + let back1 := + fun ret => do + let tl01 ← back ret + Result.ok (List.Cons x0 tl01) + Result.ok (p, back1) + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_shared_loop_pair]: Source: 'tests/src/loops.rs', lines 269:0-273:23 -/ @@ -172,7 +437,33 @@ def list_nth_mut_shared_loop_pair (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result ((T × T) × (T → Result (List T))) := - sorry + list_nth_mut_shared_loop_pair_loop T ls0 ls1 i + +/- [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: + Source: 'tests/src/loops.rs', lines 288:0-303:1 -/ +divergent def list_nth_mut_shared_loop_pair_merge_loop + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : + Result ((T × T) × (T → Result (List T))) + := + match ls0 with + | List.Cons x0 tl0 => + match ls1 with + | List.Cons x1 tl1 => + if i = 0#u32 + then + let back := fun ret => Result.ok (List.Cons ret tl0) + Result.ok ((x0, x1), back) + else + do + let i1 ← i - 1#u32 + let (p, back) ← list_nth_mut_shared_loop_pair_merge_loop T tl0 tl1 i1 + let back1 := + fun ret => do + let tl01 ← back ret + Result.ok (List.Cons x0 tl01) + Result.ok (p, back1) + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_shared_loop_pair_merge]: Source: 'tests/src/loops.rs', lines 288:0-292:23 -/ @@ -180,7 +471,33 @@ def list_nth_mut_shared_loop_pair_merge (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result ((T × T) × (T → Result (List T))) := - sorry + list_nth_mut_shared_loop_pair_merge_loop T ls0 ls1 i + +/- [loops::list_nth_shared_mut_loop_pair]: loop 0: + Source: 'tests/src/loops.rs', lines 307:0-322:1 -/ +divergent def list_nth_shared_mut_loop_pair_loop + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : + Result ((T × T) × (T → Result (List T))) + := + match ls0 with + | List.Cons x0 tl0 => + match ls1 with + | List.Cons x1 tl1 => + if i = 0#u32 + then + let back := fun ret => Result.ok (List.Cons ret tl1) + Result.ok ((x0, x1), back) + else + do + let i1 ← i - 1#u32 + let (p, back) ← list_nth_shared_mut_loop_pair_loop T tl0 tl1 i1 + let back1 := + fun ret => do + let tl11 ← back ret + Result.ok (List.Cons x1 tl11) + Result.ok (p, back1) + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_shared_mut_loop_pair]: Source: 'tests/src/loops.rs', lines 307:0-311:23 -/ @@ -188,7 +505,33 @@ def list_nth_shared_mut_loop_pair (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result ((T × T) × (T → Result (List T))) := - sorry + list_nth_shared_mut_loop_pair_loop T ls0 ls1 i + +/- [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: + Source: 'tests/src/loops.rs', lines 326:0-341:1 -/ +divergent def list_nth_shared_mut_loop_pair_merge_loop + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : + Result ((T × T) × (T → Result (List T))) + := + match ls0 with + | List.Cons x0 tl0 => + match ls1 with + | List.Cons x1 tl1 => + if i = 0#u32 + then + let back := fun ret => Result.ok (List.Cons ret tl1) + Result.ok ((x0, x1), back) + else + do + let i1 ← i - 1#u32 + let (p, back) ← list_nth_shared_mut_loop_pair_merge_loop T tl0 tl1 i1 + let back1 := + fun ret => do + let tl11 ← back ret + Result.ok (List.Cons x1 tl11) + Result.ok (p, back1) + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_shared_mut_loop_pair_merge]: Source: 'tests/src/loops.rs', lines 326:0-330:23 -/ @@ -196,7 +539,7 @@ def list_nth_shared_mut_loop_pair_merge (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result ((T × T) × (T → Result (List T))) := - sorry + list_nth_shared_mut_loop_pair_merge_loop T ls0 ls1 i /- [loops::ignore_input_mut_borrow]: loop 0: Source: 'tests/src/loops.rs', lines 345:0-349:1 -/ |