From a9c256fe95523842a1ff025e73f6e9ce7c2db38a Mon Sep 17 00:00:00 2001 From: Son Ho Date: Fri, 18 Aug 2023 10:44:01 +0200 Subject: Add tests which use const generics as values --- tests/lean/Array/Funs.lean | 4 ++++ 1 file changed, 4 insertions(+) (limited to 'tests/lean') diff --git a/tests/lean/Array/Funs.lean b/tests/lean/Array/Funs.lean index ad737dca..8d10c660 100644 --- a/tests/lean/Array/Funs.lean +++ b/tests/lean/Array/Funs.lean @@ -166,6 +166,10 @@ def index_index_array Array.index_shared (Array U32 (Usize.ofInt 32)) (Usize.ofInt 32) s i Array.index_shared U32 (Usize.ofInt 32) a j +/- [array::const_gen_ret]: forward function -/ +def const_gen_ret (N : Usize) : Result Usize := + Result.ret N + /- [array::update_update_array]: forward function -/ def update_update_array (s : Array (Array U32 (Usize.ofInt 32)) (Usize.ofInt 32)) (i : Usize) -- cgit v1.2.3 From 8543092569616ef6a75949a72532f7b73dc696f2 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Fri, 18 Aug 2023 12:23:03 +0200 Subject: Regenerate the array tests --- tests/lean/Array/Funs.lean | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'tests/lean') diff --git a/tests/lean/Array/Funs.lean b/tests/lean/Array/Funs.lean index 8d10c660..a42072d1 100644 --- a/tests/lean/Array/Funs.lean +++ b/tests/lean/Array/Funs.lean @@ -447,6 +447,14 @@ def f3 : Result U32 := ]) (Usize.ofInt 16) (Usize.ofInt 18) sum2 s s0 +/- [array::SZ] -/ +def sz_body : Result Usize := Result.ret (Usize.ofInt 32) +def sz_c : Usize := eval_global sz_body (by simp) + +/- [array::f5]: forward function -/ +def f5 (x : Array U32 (Usize.ofInt 32)) : Result U32 := + Array.index_shared U32 (Usize.ofInt 32) x (Usize.ofInt 0) + /- [array::ite]: forward function -/ def ite : Result Unit := do -- cgit v1.2.3 From ce8f5c8f67e41a74bfdf8f6d664ff4e45e9de850 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 7 Sep 2023 16:06:14 +0200 Subject: Regenerate the test files and fix a proof --- tests/lean/BetreeMain/Funs.lean | 9 ++------- tests/lean/Constants.lean | 6 +----- tests/lean/Hashmap/Funs.lean | 6 +----- tests/lean/HashmapMain/Funs.lean | 6 +----- 4 files changed, 5 insertions(+), 22 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/BetreeMain/Funs.lean b/tests/lean/BetreeMain/Funs.lean index 07ef08dc..6681731f 100644 --- a/tests/lean/BetreeMain/Funs.lean +++ b/tests/lean/BetreeMain/Funs.lean @@ -64,11 +64,6 @@ def betree.NodeIdCounter.fresh_id_back let i ← self.next_node_id + (U64.ofInt 1) Result.ret { next_node_id := i } -/- [core::num::u64::{9}::MAX] -/ -def core_num_u64_max_body : Result U64 := - Result.ret (U64.ofInt 18446744073709551615) -def core_num_u64_max_c : U64 := eval_global core_num_u64_max_body (by simp) - /- [betree_main::betree::upsert_update]: forward function -/ def betree.upsert_update (prev : Option U64) (st : betree.UpsertFunState) : Result U64 := @@ -81,10 +76,10 @@ def betree.upsert_update match st with | betree.UpsertFunState.Add v => do - let margin ← core_num_u64_max_c - prev0 + let margin ← core_u64_max - prev0 if margin >= v then prev0 + v - else Result.ret core_num_u64_max_c + else Result.ret core_u64_max | betree.UpsertFunState.Sub v => if prev0 >= v then prev0 - v diff --git a/tests/lean/Constants.lean b/tests/lean/Constants.lean index 51b415d6..b0cdaa90 100644 --- a/tests/lean/Constants.lean +++ b/tests/lean/Constants.lean @@ -9,12 +9,8 @@ namespace constants def x0_body : Result U32 := Result.ret (U32.ofInt 0) def x0_c : U32 := eval_global x0_body (by simp) -/- [core::num::u32::{8}::MAX] -/ -def core_num_u32_max_body : Result U32 := Result.ret (U32.ofInt 4294967295) -def core_num_u32_max_c : U32 := eval_global core_num_u32_max_body (by simp) - /- [constants::X1] -/ -def x1_body : Result U32 := Result.ret core_num_u32_max_c +def x1_body : Result U32 := Result.ret core_u32_max def x1_c : U32 := eval_global x1_body (by simp) /- [constants::X2] -/ diff --git a/tests/lean/Hashmap/Funs.lean b/tests/lean/Hashmap/Funs.lean index 30b30e0b..01c61de4 100644 --- a/tests/lean/Hashmap/Funs.lean +++ b/tests/lean/Hashmap/Funs.lean @@ -132,10 +132,6 @@ def HashMap.insert_no_resize let v ← Vec.index_mut_back (List T) self.slots hash_mod l0 Result.ret { self with slots := v } -/- [core::num::u32::{8}::MAX] -/ -def core_num_u32_max_body : Result U32 := Result.ret (U32.ofInt 4294967295) -def core_num_u32_max_c : U32 := eval_global core_num_u32_max_body (by simp) - /- [hashmap::HashMap::{0}::move_elements_from_list]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ divergent def HashMap.move_elements_from_list_loop @@ -184,7 +180,7 @@ def HashMap.move_elements (there is a single backward function, and the forward function returns ()) -/ def HashMap.try_resize (T : Type) (self : HashMap T) : Result (HashMap T) := do - let max_usize ← Scalar.cast .Usize core_num_u32_max_c + let max_usize ← Scalar.cast .Usize core_u32_max let capacity := Vec.len (List T) self.slots let n1 ← max_usize / (Usize.ofInt 2) let (i, i0) := self.max_load_factor diff --git a/tests/lean/HashmapMain/Funs.lean b/tests/lean/HashmapMain/Funs.lean index aec957ec..848b1a35 100644 --- a/tests/lean/HashmapMain/Funs.lean +++ b/tests/lean/HashmapMain/Funs.lean @@ -147,10 +147,6 @@ def hashmap.HashMap.insert_no_resize let v ← Vec.index_mut_back (hashmap.List T) self.slots hash_mod l0 Result.ret { self with slots := v } -/- [core::num::u32::{8}::MAX] -/ -def core_num_u32_max_body : Result U32 := Result.ret (U32.ofInt 4294967295) -def core_num_u32_max_c : U32 := eval_global core_num_u32_max_body (by simp) - /- [hashmap_main::hashmap::HashMap::{0}::move_elements_from_list]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ divergent def hashmap.HashMap.move_elements_from_list_loop @@ -206,7 +202,7 @@ def hashmap.HashMap.move_elements def hashmap.HashMap.try_resize (T : Type) (self : hashmap.HashMap T) : Result (hashmap.HashMap T) := do - let max_usize ← Scalar.cast .Usize core_num_u32_max_c + let max_usize ← Scalar.cast .Usize core_u32_max let capacity := Vec.len (hashmap.List T) self.slots let n1 ← max_usize / (Usize.ofInt 2) let (i, i0) := self.max_load_factor -- cgit v1.2.3 From 78a2731924aa13989998c6be4a5a6865ce5098aa Mon Sep 17 00:00:00 2001 From: Son Ho Date: Wed, 13 Sep 2023 07:33:30 +0200 Subject: Make minor modifications --- tests/lean/Hashmap/Properties.lean | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Hashmap/Properties.lean b/tests/lean/Hashmap/Properties.lean index ab95b854..6bc821d3 100644 --- a/tests/lean/Hashmap/Properties.lean +++ b/tests/lean/Hashmap/Properties.lean @@ -303,19 +303,17 @@ theorem insert_no_resize_spec {α : Type} (hm : HashMap α) (key : Usize) (value | some _ => nhm.len_s = hm.len_s) := by rw [insert_no_resize] simp only [hash_key, bind_tc_ret] -- TODO: annoying - have _ : (Vec.len (List α) hm.slots).val ≠ 0 := by checkpoint + have _ : (Vec.len (List α) hm.slots).val ≠ 0 := by intro simp_all [inv] - progress keep _ as ⟨ hash_mod, hhm ⟩ - have _ : 0 ≤ hash_mod.val := by checkpoint scalar_tac + progress as ⟨ hash_mod, hhm ⟩ + have _ : 0 ≤ hash_mod.val := by scalar_tac have _ : hash_mod.val < Vec.length hm.slots := by have : 0 < hm.slots.val.len := by simp [inv] at hinv simp [hinv] -- TODO: we want to automate that simp [*, Int.emod_lt_of_pos] - -- TODO: change the spec of Vec.index_mut to introduce a let-binding. - -- or: make progress introduce the let-binding by itself (this is clearer) progress as ⟨ l, h_leq ⟩ -- TODO: make progress use the names written in the goal progress as ⟨ inserted ⟩ -- cgit v1.2.3 From e684179ff9c582495b720c3b1310e0648ca24a58 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Fri, 6 Oct 2023 12:13:38 +0200 Subject: Generate the Traits test files for Lean --- tests/lean/Traits.lean | 1 + tests/lean/Traits/Funs.lean | 232 +++++++++++++++++++++++++++++++++++++++++++ tests/lean/Traits/Types.lean | 86 ++++++++++++++++ tests/lean/lakefile.lean | 1 + 4 files changed, 320 insertions(+) create mode 100644 tests/lean/Traits.lean create mode 100644 tests/lean/Traits/Funs.lean create mode 100644 tests/lean/Traits/Types.lean (limited to 'tests/lean') diff --git a/tests/lean/Traits.lean b/tests/lean/Traits.lean new file mode 100644 index 00000000..5e812e95 --- /dev/null +++ b/tests/lean/Traits.lean @@ -0,0 +1 @@ +import Traits.Funs diff --git a/tests/lean/Traits/Funs.lean b/tests/lean/Traits/Funs.lean new file mode 100644 index 00000000..52ff0c0a --- /dev/null +++ b/tests/lean/Traits/Funs.lean @@ -0,0 +1,232 @@ +-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS +-- [traits]: function definitions +import Base +import Traits.Types +open Primitives + +namespace traits + +/- [traits::Bool::{0}::get_bool]: forward function -/ +def Bool.get_bool (self : Bool) : Result Bool := + Result.ret self + +/- Trait implementation: [traits::Bool::{0}] -/ +def Bool.BoolTraitInst : BoolTrait Bool := { + get_bool := Bool.get_bool +} + +/- [traits::BoolTrait::ret_true]: forward function -/ +def BoolTrait.ret_true + {Self : Type} (self_clause : BoolTrait Self) (self : Self) : Result Bool := + Result.ret true + +/- [traits::test_bool_trait_bool]: forward function -/ +def test_bool_trait_bool (x : Bool) : Result Bool := + do + let b ← Bool.get_bool x + if b + then BoolTrait.ret_true Bool.BoolTraitInst x + else Result.ret false + +/- [traits::Option::{1}::get_bool]: forward function -/ +def Option.get_bool (T : Type) (self : Option T) : Result Bool := + match self with + | Option.none => Result.ret false + | Option.some t => Result.ret true + +/- Trait implementation: [traits::Option::{1}] -/ +def Option.BoolTraitInst (T : Type) : BoolTrait (Option T) := { + get_bool := Option.get_bool T +} + +/- [traits::test_bool_trait_option]: forward function -/ +def test_bool_trait_option (T : Type) (x : Option T) : Result Bool := + do + let b ← Option.get_bool T x + if b + then BoolTrait.ret_true (Option.BoolTraitInst T) x + else Result.ret false + +/- [traits::test_bool_trait]: forward function -/ +def test_bool_trait (T : Type) (inst : BoolTrait T) (x : T) : Result Bool := + inst.get_bool x + +/- [traits::u64::{2}::to_u64]: forward function -/ +def u64.to_u64 (self : U64) : Result U64 := + Result.ret self + +/- Trait implementation: [traits::u64::{2}] -/ +def u64.ToU64Inst : ToU64 U64 := { + to_u64 := u64.to_u64 +} + +/- [traits::Tuple2::{3}::to_u64]: forward function -/ +def Tuple2.to_u64 (A : Type) (inst : ToU64 A) (self : (A × A)) : Result U64 := + do + let (t, t0) := self + let i ← inst.to_u64 t + let i0 ← inst.to_u64 t0 + i + i0 + +/- Trait implementation: [traits::Tuple2::{3}] -/ +def Tuple2.ToU64Inst (A : Type) (inst : ToU64 A) : ToU64 (A × A) := { + to_u64 := Tuple2.to_u64 A inst +} + +/- [traits::f]: forward function -/ +def f (T : Type) (inst : ToU64 T) (x : (T × T)) : Result U64 := + Tuple2.to_u64 T inst x + +/- [traits::g]: forward function -/ +def g (T : Type) (inst : ToU64 (T × T)) (x : (T × T)) : Result U64 := + inst.to_u64 x + +/- [traits::h0]: forward function -/ +def h0 (x : U64) : Result U64 := + u64.to_u64 x + +/- [traits::Wrapper::{4}::to_u64]: forward function -/ +def Wrapper.to_u64 + (T : Type) (inst : ToU64 T) (self : Wrapper T) : Result U64 := + inst.to_u64 self.x + +/- Trait implementation: [traits::Wrapper::{4}] -/ +def Wrapper.ToU64Inst (T : Type) (inst : ToU64 T) : ToU64 (Wrapper T) := { + to_u64 := Wrapper.to_u64 T inst +} + +/- [traits::h1]: forward function -/ +def h1 (x : Wrapper U64) : Result U64 := + Wrapper.to_u64 U64 u64.ToU64Inst x + +/- [traits::h2]: forward function -/ +def h2 (T : Type) (inst : ToU64 T) (x : Wrapper T) : Result U64 := + Wrapper.to_u64 T inst x + +/- [traits::u64::{5}::to_type]: forward function -/ +def u64.to_type (self : U64) : Result Bool := + Result.ret (self > (U64.ofInt 0)) + +/- Trait implementation: [traits::u64::{5}] -/ +def u64.ToTypeInst : ToType U64 Bool := { + to_type := u64.to_type +} + +/- [traits::h3]: forward function -/ +def h3 + (T1 T2 : Type) (inst : OfType T1) (inst0 : ToType T2 T1) (y : T2) : + Result T1 + := + inst.of_type T2 inst0 y + +/- [traits::h4]: forward function -/ +def h4 + (T1 T2 : Type) (inst : OfTypeBis T1 T2) (inst0 : ToType T2 T1) (y : T2) : + Result T1 + := + inst.of_type y + +/- [traits::TestType::{6}::test::TestType1::{0}::test]: forward function -/ +def TestType.test.TestType1.test + (self : TestType.test.TestType1) : Result Bool := + Result.ret (self._0 > (U64.ofInt 1)) + +/- Trait implementation: [traits::TestType::{6}::test::TestType1::{0}] -/ +def TestType.test.TestType1.TestTypetestTestTraitInst : TestType.test.TestTrait + TestType.test.TestType1 := { + test := TestType.test.TestType1.test +} + +/- [traits::TestType::{6}::test]: forward function -/ +def TestType.test + (T : Type) (inst : ToU64 T) (self : TestType T) (x : T) : Result Bool := + do + let x0 ← inst.to_u64 x + if x0 > (U64.ofInt 0) + then TestType.test.TestType1.test { _0 := (U64.ofInt 0) } + else Result.ret false + +/- [traits::BoolWrapper::{7}::to_type]: forward function -/ +def BoolWrapper.to_type + (T : Type) (inst : ToType Bool T) (self : BoolWrapper) : Result T := + inst.to_type self._0 + +/- Trait implementation: [traits::BoolWrapper::{7}] -/ +def BoolWrapper.ToTypeInst (T : Type) (inst : ToType Bool T) : ToType + BoolWrapper T := { + to_type := BoolWrapper.to_type T inst +} + +/- [traits::WithConstTy::LEN2] -/ +def with_const_ty_len2_body : Result Usize := Result.ret (Usize.ofInt 32) +def with_const_ty_len2_c : Usize := + eval_global with_const_ty_len2_body (by simp) + +/- [traits::Bool::{8}::LEN1] -/ +def bool_len1_body : Result Usize := Result.ret (Usize.ofInt 12) +def bool_len1_c : Usize := eval_global bool_len1_body (by simp) + +/- [traits::Bool::{8}::f]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) -/ +def Bool.f (i : U64) (a : Array U8 (Usize.ofInt 32)) : Result U64 := + Result.ret i + +/- Trait implementation: [traits::Bool::{8}] -/ +def Bool.WithConstTyInst : WithConstTy Bool (Usize.ofInt 32) := { + LEN1 := bool_len1_c + LEN2 := with_const_ty_len2_c + V := U8 + W := U64 + W_clause_0 := u64.ToU64Inst + f := Bool.f +} + +/- [traits::use_with_const_ty1]: forward function -/ +def use_with_const_ty1 + (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) : Result Usize := + let i := inst.LEN1 + Result.ret i + +/- [traits::use_with_const_ty2]: forward function -/ +def use_with_const_ty2 + (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) (w : inst.W) : + Result Unit + := + Result.ret () + +/- [traits::use_with_const_ty3]: forward function -/ +def use_with_const_ty3 + (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) (x : inst.W) : + Result U64 + := + inst.W_clause_0.to_u64 x + +/- [traits::test_where1]: forward function -/ +def test_where1 (T : Type) (_x : T) : Result Unit := + Result.ret () + +/- [traits::test_where2]: forward function -/ +def test_where2 + (T : Type) (inst : WithConstTy T (Usize.ofInt 32)) (_x : U32) : + Result Unit + := + Result.ret () + +/- [traits::test_child_trait1]: forward function -/ +def test_child_trait1 + (T : Type) (inst : ChildTrait T) (x : T) : Result alloc.string.String := + inst.parent_clause_0.get_name x + +/- [traits::test_child_trait2]: forward function -/ +def test_child_trait2 + (T : Type) (inst : ChildTrait T) (x : T) : Result inst.parent_clause_0.W := + inst.parent_clause_0.get_w x + +/- [traits::order1]: forward function -/ +def order1 + (T U : Type) (inst : ParentTrait0 T) (inst0 : ParentTrait0 U) : + Result Unit + := + Result.ret () + +end traits diff --git a/tests/lean/Traits/Types.lean b/tests/lean/Traits/Types.lean new file mode 100644 index 00000000..b3a52346 --- /dev/null +++ b/tests/lean/Traits/Types.lean @@ -0,0 +1,86 @@ +-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS +-- [traits]: type definitions +import Base +open Primitives + +namespace traits + +/- Trait declaration: [traits::BoolTrait] -/ +structure BoolTrait (Self : Type) where + get_bool : Self → Result Bool + +/- Trait declaration: [traits::ToU64] -/ +structure ToU64 (Self : Type) where + to_u64 : Self → Result U64 + +/- [traits::Wrapper] -/ +structure Wrapper (T : Type) where + x : T + +/- Trait declaration: [traits::ToType] -/ +structure ToType (Self T : Type) where + to_type : Self → Result T + +/- Trait declaration: [traits::OfType] -/ +structure OfType (Self : Type) where + of_type : forall (T : Type) (inst : ToType T Self), T → Result Self + +/- Trait declaration: [traits::OfTypeBis] -/ +structure OfTypeBis (Self T : Type) where + parent_clause_0 :ToType T Self + of_type : T → Result Self + +/- [traits::TestType] -/ +structure TestType (T : Type) where + _0 : T + +/- [traits::TestType::{6}::test::TestType1] -/ +structure TestType.test.TestType1 where + _0 : U64 + +/- Trait declaration: [traits::TestType::{6}::test::TestTrait] -/ +structure TestType.test.TestTrait (Self : Type) where + test : Self → Result Bool + +/- [traits::BoolWrapper] -/ +structure BoolWrapper where + _0 : Bool + +/- Trait declaration: [traits::WithConstTy] -/ +structure WithConstTy (Self : Type) (LEN : Usize) where + LEN1 :Usize + LEN2 :Usize + V :Type + W :Type + W_clause_0 :ToU64 W + f : W → Array U8 LEN → Result W + +/- [alloc::string::String] -/ +axiom alloc.string.String : Type + +/- Trait declaration: [traits::ParentTrait0] -/ +structure ParentTrait0 (Self : Type) where + W :Type + get_name : Self → Result alloc.string.String + get_w : Self → Result W + +/- Trait declaration: [traits::ParentTrait1] -/ +structure ParentTrait1 (Self : Type) where + +/- Trait declaration: [traits::ChildTrait] -/ +structure ChildTrait (Self : Type) where + parent_clause_0 :ParentTrait0 Self + parent_clause_1 :ParentTrait1 Self + +/- Trait declaration: [traits::Iterator] -/ +structure Iterator (Self : Type) where + Item :Type + +/- Trait declaration: [traits::IntoIterator] -/ +structure IntoIterator (Self : Type) where + Item :Type + IntoIter :Type + IntoIter_clause_0 :Iterator IntoIter + into_iter : Self → Result IntoIter + +end traits diff --git a/tests/lean/lakefile.lean b/tests/lean/lakefile.lean index cc63c48f..1747c581 100644 --- a/tests/lean/lakefile.lean +++ b/tests/lean/lakefile.lean @@ -18,3 +18,4 @@ package «tests» {} @[default_target] lean_lib paper @[default_target] lean_lib poloniusList @[default_target] lean_lib array +@[default_target] lean_lib traits -- cgit v1.2.3 From af78286d801b26bf7a70b8815619591d48245cb8 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Fri, 6 Oct 2023 12:23:26 +0200 Subject: Slightly improve formatting of the generated code --- tests/lean/Traits/Types.lean | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Traits/Types.lean b/tests/lean/Traits/Types.lean index b3a52346..a8c12fe5 100644 --- a/tests/lean/Traits/Types.lean +++ b/tests/lean/Traits/Types.lean @@ -48,11 +48,11 @@ structure BoolWrapper where /- Trait declaration: [traits::WithConstTy] -/ structure WithConstTy (Self : Type) (LEN : Usize) where - LEN1 :Usize - LEN2 :Usize - V :Type - W :Type - W_clause_0 :ToU64 W + LEN1 : Usize + LEN2 : Usize + V : Type + W : Type + W_clause_0 : ToU64 W f : W → Array U8 LEN → Result W /- [alloc::string::String] -/ @@ -60,7 +60,7 @@ axiom alloc.string.String : Type /- Trait declaration: [traits::ParentTrait0] -/ structure ParentTrait0 (Self : Type) where - W :Type + W : Type get_name : Self → Result alloc.string.String get_w : Self → Result W @@ -74,13 +74,13 @@ structure ChildTrait (Self : Type) where /- Trait declaration: [traits::Iterator] -/ structure Iterator (Self : Type) where - Item :Type + Item : Type /- Trait declaration: [traits::IntoIterator] -/ structure IntoIterator (Self : Type) where - Item :Type - IntoIter :Type - IntoIter_clause_0 :Iterator IntoIter + Item : Type + IntoIter : Type + IntoIter_clause_0 : Iterator IntoIter into_iter : Self → Result IntoIter end traits -- cgit v1.2.3 From bb37801b3922f617302f5ffe25e8c8e7c0734b08 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Fri, 13 Oct 2023 00:40:46 +0200 Subject: Add support for array repeat --- tests/lean/Array/Funs.lean | 33 +++++++-------------------------- 1 file changed, 7 insertions(+), 26 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Array/Funs.lean b/tests/lean/Array/Funs.lean index a42072d1..d3cb29d2 100644 --- a/tests/lean/Array/Funs.lean +++ b/tests/lean/Array/Funs.lean @@ -53,16 +53,6 @@ def index_array_u32 (s : Array U32 (Usize.ofInt 32)) (i : Usize) : Result U32 := Array.index_shared U32 (Usize.ofInt 32) s i -/- [array::index_array_generic]: forward function -/ -def index_array_generic - (N : Usize) (s : Array U32 N) (i : Usize) : Result U32 := - Array.index_shared U32 N s i - -/- [array::index_array_generic_call]: forward function -/ -def index_array_generic_call - (N : Usize) (s : Array U32 N) (i : Usize) : Result U32 := - index_array_generic N s i - /- [array::index_array_copy]: forward function -/ def index_array_copy (x : Array U32 (Usize.ofInt 32)) : Result U32 := Array.index_shared U32 (Usize.ofInt 32) x (Usize.ofInt 0) @@ -166,10 +156,6 @@ def index_index_array Array.index_shared (Array U32 (Usize.ofInt 32)) (Usize.ofInt 32) s i Array.index_shared U32 (Usize.ofInt 32) a j -/- [array::const_gen_ret]: forward function -/ -def const_gen_ret (N : Usize) : Result Usize := - Result.ret N - /- [array::update_update_array]: forward function -/ def update_update_array (s : Array (Array U32 (Usize.ofInt 32)) (Usize.ofInt 32)) (i : Usize) @@ -430,21 +416,11 @@ def f3 : Result U32 := (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 1), (U32.ofInt 2) ]) (Usize.ofInt 0) let _ ← f2 i + let b := Array.repeat U32 (Usize.ofInt 32) (U32.ofInt 0) let s ← Array.to_slice_shared U32 (Usize.ofInt 2) (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 1), (U32.ofInt 2) ]) - let s0 ← - f4 - (Array.make U32 (Usize.ofInt 32) [ - (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), - (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), - (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), - (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), - (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), - (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), - (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), - (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0) - ]) (Usize.ofInt 16) (Usize.ofInt 18) + let s0 ← f4 b (Usize.ofInt 16) (Usize.ofInt 18) sum2 s s0 /- [array::SZ] -/ @@ -474,4 +450,9 @@ def ite : Result Unit := (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) s2 Result.ret () +/- [array::array]: forward function -/ +def array (LEN : Usize) : Result (Array U8 LEN) := + let a := Array.repeat U8 LEN (U8.ofInt 0) + Result.ret a + end array -- cgit v1.2.3 From 6eebc66e34561bc6985b5866d49c8314a6fbaee9 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 24 Oct 2023 17:47:39 +0200 Subject: Start taking into account non-fallible functions like core::mem::replace --- tests/lean/NoNestedBorrows.lean | 134 +++++++++++++++++++--------------------- 1 file changed, 64 insertions(+), 70 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/NoNestedBorrows.lean b/tests/lean/NoNestedBorrows.lean index 884e62c4..a90d6ea2 100644 --- a/tests/lean/NoNestedBorrows.lean +++ b/tests/lean/NoNestedBorrows.lean @@ -54,7 +54,7 @@ def div_test (x : U32) (y : U32) : Result U32 := /- [no_nested_borrows::div_test1]: forward function -/ def div_test1 (x : U32) : Result U32 := - x / (U32.ofInt 2) + x / 2#u32 /- [no_nested_borrows::rem_test]: forward function -/ def rem_test (x : U32) (y : U32) : Result U32 := @@ -67,7 +67,7 @@ def cast_test (x : U32) : Result I32 := /- [no_nested_borrows::test2]: forward function -/ def test2 : Result Unit := do - let _ ← (U32.ofInt 23) + (U32.ofInt 44) + let _ ← 23#u32 + 44#u32 Result.ret () /- Unit test for [no_nested_borrows::test2] -/ @@ -82,10 +82,10 @@ def get_max (x : U32) (y : U32) : Result U32 := /- [no_nested_borrows::test3]: forward function -/ def test3 : Result Unit := do - let x ← get_max (U32.ofInt 4) (U32.ofInt 3) - let y ← get_max (U32.ofInt 10) (U32.ofInt 11) + let x ← get_max 4#u32 3#u32 + let y ← get_max 10#u32 11#u32 let z ← x + y - if not (z = (U32.ofInt 15)) + if not (z = 15#u32) then Result.fail Error.panic else Result.ret () @@ -95,8 +95,8 @@ def test3 : Result Unit := /- [no_nested_borrows::test_neg1]: forward function -/ def test_neg1 : Result Unit := do - let y ← - (I32.ofInt 3) - if not (y = (I32.ofInt (-(3:Int)))) + let y ← - 3#i32 + if not (y = (-(3:Int))#i32) then Result.fail Error.panic else Result.ret () @@ -105,7 +105,7 @@ def test_neg1 : Result Unit := /- [no_nested_borrows::refs_test1]: forward function -/ def refs_test1 : Result Unit := - if not ((I32.ofInt 1) = (I32.ofInt 1)) + if not (1#i32 = 1#i32) then Result.fail Error.panic else Result.ret () @@ -114,16 +114,16 @@ def refs_test1 : Result Unit := /- [no_nested_borrows::refs_test2]: forward function -/ def refs_test2 : Result Unit := - if not ((I32.ofInt 2) = (I32.ofInt 2)) + if not (2#i32 = 2#i32) then Result.fail Error.panic else - if not ((I32.ofInt 0) = (I32.ofInt 0)) + if not (0#i32 = 0#i32) then Result.fail Error.panic else - if not ((I32.ofInt 2) = (I32.ofInt 2)) + if not (2#i32 = 2#i32) then Result.fail Error.panic else - if not ((I32.ofInt 2) = (I32.ofInt 2)) + if not (2#i32 = 2#i32) then Result.fail Error.panic else Result.ret () @@ -167,8 +167,8 @@ def test_panic (b : Bool) : Result Unit := /- [no_nested_borrows::test_copy_int]: forward function -/ def test_copy_int : Result Unit := do - let y ← copy_int (I32.ofInt 0) - if not ((I32.ofInt 0) = y) + let y ← copy_int 0#i32 + if not (0#i32 = y) then Result.fail Error.panic else Result.ret () @@ -185,7 +185,7 @@ def is_cons (T : Type) (l : List T) : Result Bool := def test_is_cons : Result Unit := do let l := List.Nil - let b ← is_cons I32 (List.Cons (I32.ofInt 0) l) + let b ← is_cons I32 (List.Cons 0#i32 l) if not b then Result.fail Error.panic else Result.ret () @@ -203,9 +203,9 @@ def split_list (T : Type) (l : List T) : Result (T × (List T)) := def test_split_list : Result Unit := do let l := List.Nil - let p ← split_list I32 (List.Cons (I32.ofInt 0) l) + let p ← split_list I32 (List.Cons 0#i32 l) let (hd, _) := p - if not (hd = (I32.ofInt 0)) + if not (hd = 0#i32) then Result.fail Error.panic else Result.ret () @@ -228,19 +228,18 @@ def choose_back /- [no_nested_borrows::choose_test]: forward function -/ def choose_test : Result Unit := do - let z ← choose I32 true (I32.ofInt 0) (I32.ofInt 0) - let z0 ← z + (I32.ofInt 1) - if not (z0 = (I32.ofInt 1)) + let z ← choose I32 true 0#i32 0#i32 + let z0 ← z + 1#i32 + if not (z0 = 1#i32) then Result.fail Error.panic else do - let (x, y) ← choose_back I32 true (I32.ofInt 0) (I32.ofInt 0) z0 - if not (x = (I32.ofInt 1)) + let (x, y) ← choose_back I32 true 0#i32 0#i32 z0 + if not (x = 1#i32) then Result.fail Error.panic - else - if not (y = (I32.ofInt 0)) - then Result.fail Error.panic - else Result.ret () + else if not (y = 0#i32) + then Result.fail Error.panic + else Result.ret () /- Unit test for [no_nested_borrows::choose_test] -/ #assert (choose_test == .ret ()) @@ -268,17 +267,17 @@ divergent def list_length (T : Type) (l : List T) : Result U32 := match l with | List.Cons t l1 => do let i ← list_length T l1 - (U32.ofInt 1) + i - | List.Nil => Result.ret (U32.ofInt 0) + 1#u32 + i + | List.Nil => Result.ret 0#u32 /- [no_nested_borrows::list_nth_shared]: forward function -/ divergent def list_nth_shared (T : Type) (l : List T) (i : U32) : Result T := match l with | List.Cons x tl => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret x else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 list_nth_shared T tl i0 | List.Nil => Result.fail Error.panic @@ -286,10 +285,10 @@ divergent def list_nth_shared (T : Type) (l : List T) (i : U32) : Result T := divergent def list_nth_mut (T : Type) (l : List T) (i : U32) : Result T := match l with | List.Cons x tl => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret x else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 list_nth_mut T tl i0 | List.Nil => Result.fail Error.panic @@ -298,11 +297,11 @@ divergent def list_nth_mut_back (T : Type) (l : List T) (i : U32) (ret0 : T) : Result (List T) := match l with | List.Cons x tl => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (List.Cons ret0 tl) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 let tl0 ← list_nth_mut_back T tl i0 ret0 Result.ret (List.Cons x tl0) | List.Nil => Result.fail Error.panic @@ -324,47 +323,42 @@ def list_rev (T : Type) (l : List T) : Result (List T) := def test_list_functions : Result Unit := do let l := List.Nil - let l0 := List.Cons (I32.ofInt 2) l - let l1 := List.Cons (I32.ofInt 1) l0 - let i ← list_length I32 (List.Cons (I32.ofInt 0) l1) - if not (i = (U32.ofInt 3)) + let l0 := List.Cons 2#i32 l + let l1 := List.Cons 1#i32 l0 + let i ← list_length I32 (List.Cons 0#i32 l1) + if not (i = 3#u32) then Result.fail Error.panic else do - let i0 ← - list_nth_shared I32 (List.Cons (I32.ofInt 0) l1) (U32.ofInt 0) - if not (i0 = (I32.ofInt 0)) + let i0 ← list_nth_shared I32 (List.Cons 0#i32 l1) 0#u32 + if not (i0 = 0#i32) then Result.fail Error.panic else do - let i1 ← - list_nth_shared I32 (List.Cons (I32.ofInt 0) l1) (U32.ofInt 1) - if not (i1 = (I32.ofInt 1)) + let i1 ← list_nth_shared I32 (List.Cons 0#i32 l1) 1#u32 + if not (i1 = 1#i32) then Result.fail Error.panic else do - let i2 ← - list_nth_shared I32 (List.Cons (I32.ofInt 0) l1) - (U32.ofInt 2) - if not (i2 = (I32.ofInt 2)) + let i2 ← list_nth_shared I32 (List.Cons 0#i32 l1) 2#u32 + if not (i2 = 2#i32) then Result.fail Error.panic else do let ls ← - list_nth_mut_back I32 (List.Cons (I32.ofInt 0) l1) - (U32.ofInt 1) (I32.ofInt 3) - let i3 ← list_nth_shared I32 ls (U32.ofInt 0) - if not (i3 = (I32.ofInt 0)) + list_nth_mut_back I32 (List.Cons 0#i32 l1) 1#u32 3#i32 + let i3 ← list_nth_shared I32 ls 0#u32 + if not (i3 = 0#i32) then Result.fail Error.panic else do - let i4 ← list_nth_shared I32 ls (U32.ofInt 1) - if not (i4 = (I32.ofInt 3)) + let i4 ← list_nth_shared I32 ls 1#u32 + if not (i4 = 3#i32) then Result.fail Error.panic else do - let i5 ← list_nth_shared I32 ls (U32.ofInt 2) - if not (i5 = (I32.ofInt 2)) + let i5 ← list_nth_shared I32 ls 2#u32 + if not (i5 = 2#i32) then Result.fail Error.panic else Result.ret () @@ -427,15 +421,15 @@ structure StructWithTuple (T1 T2 : Type) where /- [no_nested_borrows::new_tuple1]: forward function -/ def new_tuple1 : Result (StructWithTuple U32 U32) := - Result.ret { p := ((U32.ofInt 1), (U32.ofInt 2)) } + Result.ret { p := (1#u32, 2#u32) } /- [no_nested_borrows::new_tuple2]: forward function -/ def new_tuple2 : Result (StructWithTuple I16 I16) := - Result.ret { p := ((I16.ofInt 1), (I16.ofInt 2)) } + Result.ret { p := (1#i16, 2#i16) } /- [no_nested_borrows::new_tuple3]: forward function -/ def new_tuple3 : Result (StructWithTuple U64 I64) := - Result.ret { p := ((U64.ofInt 1), (I64.ofInt 2)) } + Result.ret { p := (1#u64, 2#i64) } /- [no_nested_borrows::StructWithPair] -/ structure StructWithPair (T1 T2 : Type) where @@ -443,31 +437,31 @@ structure StructWithPair (T1 T2 : Type) where /- [no_nested_borrows::new_pair1]: forward function -/ def new_pair1 : Result (StructWithPair U32 U32) := - Result.ret { p := { x := (U32.ofInt 1), y := (U32.ofInt 2) } } + Result.ret { p := { x := 1#u32, y := 2#u32 } } /- [no_nested_borrows::test_constants]: forward function -/ def test_constants : Result Unit := do let swt ← new_tuple1 let (i, _) := swt.p - if not (i = (U32.ofInt 1)) + if not (i = 1#u32) then Result.fail Error.panic else do let swt0 ← new_tuple2 let (i0, _) := swt0.p - if not (i0 = (I16.ofInt 1)) + if not (i0 = 1#i16) then Result.fail Error.panic else do let swt1 ← new_tuple3 let (i1, _) := swt1.p - if not (i1 = (U64.ofInt 1)) + if not (i1 = 1#u64) then Result.fail Error.panic else do let swp ← new_pair1 - if not (swp.p.x = (U32.ofInt 1)) + if not (swp.p.x = 1#u32) then Result.fail Error.panic else Result.ret () @@ -492,21 +486,21 @@ def test_mem_replace (px : U32) : Result U32 := /- [no_nested_borrows::test_shared_borrow_bool1]: forward function -/ def test_shared_borrow_bool1 (b : Bool) : Result U32 := if b - then Result.ret (U32.ofInt 0) - else Result.ret (U32.ofInt 1) + then Result.ret 0#u32 + else Result.ret 1#u32 /- [no_nested_borrows::test_shared_borrow_bool2]: forward function -/ def test_shared_borrow_bool2 : Result U32 := - Result.ret (U32.ofInt 0) + Result.ret 0#u32 /- [no_nested_borrows::test_shared_borrow_enum1]: forward function -/ def test_shared_borrow_enum1 (l : List U32) : Result U32 := match l with - | List.Cons i l0 => Result.ret (U32.ofInt 1) - | List.Nil => Result.ret (U32.ofInt 0) + | List.Cons i l0 => Result.ret 1#u32 + | List.Nil => Result.ret 0#u32 /- [no_nested_borrows::test_shared_borrow_enum2]: forward function -/ def test_shared_borrow_enum2 : Result U32 := - Result.ret (U32.ofInt 0) + Result.ret 0#u32 end no_nested_borrows -- cgit v1.2.3 From 9c230dddebb171ee1b3e0176838441163836b875 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 24 Oct 2023 18:16:53 +0200 Subject: Handle properly the builtin, non fallible functions --- tests/lean/NoNestedBorrows.lean | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/NoNestedBorrows.lean b/tests/lean/NoNestedBorrows.lean index a90d6ea2..d6d603ce 100644 --- a/tests/lean/NoNestedBorrows.lean +++ b/tests/lean/NoNestedBorrows.lean @@ -139,9 +139,9 @@ def test_list1 : Result Unit := /- [no_nested_borrows::test_box1]: forward function -/ def test_box1 : Result Unit := - let b := (I32.ofInt 1) + let b := 1#i32 let x := b - if not (x = (I32.ofInt 1)) + if not (x = 1#i32) then Result.fail Error.panic else Result.ret () @@ -316,7 +316,7 @@ divergent def list_rev_aux /- [no_nested_borrows::list_rev]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def list_rev (T : Type) (l : List T) : Result (List T) := - let li := mem.replace (List T) l List.Nil + let li := core.mem.replace (List T) l List.Nil list_rev_aux T li List.Nil /- [no_nested_borrows::test_list_functions]: forward function -/ @@ -478,10 +478,10 @@ def test_weird_borrows1 : Result Unit := /- [no_nested_borrows::test_mem_replace]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def test_mem_replace (px : U32) : Result U32 := - let y := mem.replace U32 px (U32.ofInt 1) - if not (y = (U32.ofInt 0)) + let y := core.mem.replace U32 px 1#u32 + if not (y = 0#u32) then Result.fail Error.panic - else Result.ret (U32.ofInt 2) + else Result.ret 2#u32 /- [no_nested_borrows::test_shared_borrow_bool1]: forward function -/ def test_shared_borrow_bool1 (b : Bool) : Result U32 := -- cgit v1.2.3 From 862c6f939b001e4fe0556cc73af71210e7b96ea2 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Wed, 25 Oct 2023 15:38:23 +0200 Subject: Regenerate the Lean array test --- tests/lean/Array/Funs.lean | 319 +++++++++++++++++++++------------------------ 1 file changed, 150 insertions(+), 169 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Array/Funs.lean b/tests/lean/Array/Funs.lean index d3cb29d2..899bf856 100644 --- a/tests/lean/Array/Funs.lean +++ b/tests/lean/Array/Funs.lean @@ -6,35 +6,39 @@ open Primitives namespace array +/- [array::incr]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) -/ +def incr (x : U32) : Result U32 := + x + 1#u32 + /- [array::array_to_shared_slice_]: forward function -/ def array_to_shared_slice_ - (T0 : Type) (s : Array T0 (Usize.ofInt 32)) : Result (Slice T0) := - Array.to_slice_shared T0 (Usize.ofInt 32) s + (T0 : Type) (s : Array T0 32#usize) : Result (Slice T0) := + Array.to_slice_shared T0 32#usize s /- [array::array_to_mut_slice_]: forward function -/ def array_to_mut_slice_ - (T0 : Type) (s : Array T0 (Usize.ofInt 32)) : Result (Slice T0) := - Array.to_slice_mut T0 (Usize.ofInt 32) s + (T0 : Type) (s : Array T0 32#usize) : Result (Slice T0) := + Array.to_slice_mut T0 32#usize s /- [array::array_to_mut_slice_]: backward function 0 -/ def array_to_mut_slice__back - (T0 : Type) (s : Array T0 (Usize.ofInt 32)) (ret0 : Slice T0) : - Result (Array T0 (Usize.ofInt 32)) + (T0 : Type) (s : Array T0 32#usize) (ret0 : Slice T0) : + Result (Array T0 32#usize) := - Array.to_slice_mut_back T0 (Usize.ofInt 32) s ret0 + Array.to_slice_mut_back T0 32#usize s ret0 /- [array::array_len]: forward function -/ -def array_len (T0 : Type) (s : Array T0 (Usize.ofInt 32)) : Result Usize := +def array_len (T0 : Type) (s : Array T0 32#usize) : Result Usize := do - let s0 ← Array.to_slice_shared T0 (Usize.ofInt 32) s + let s0 ← Array.to_slice_shared T0 32#usize s let i := Slice.len T0 s0 Result.ret i /- [array::shared_array_len]: forward function -/ -def shared_array_len - (T0 : Type) (s : Array T0 (Usize.ofInt 32)) : Result Usize := +def shared_array_len (T0 : Type) (s : Array T0 32#usize) : Result Usize := do - let s0 ← Array.to_slice_shared T0 (Usize.ofInt 32) s + let s0 ← Array.to_slice_shared T0 32#usize s let i := Slice.len T0 s0 Result.ret i @@ -45,29 +49,28 @@ def shared_slice_len (T0 : Type) (s : Slice T0) : Result Usize := /- [array::index_array_shared]: forward function -/ def index_array_shared - (T0 : Type) (s : Array T0 (Usize.ofInt 32)) (i : Usize) : Result T0 := - Array.index_shared T0 (Usize.ofInt 32) s i + (T0 : Type) (s : Array T0 32#usize) (i : Usize) : Result T0 := + Array.index_shared T0 32#usize s i /- [array::index_array_u32]: forward function -/ -def index_array_u32 - (s : Array U32 (Usize.ofInt 32)) (i : Usize) : Result U32 := - Array.index_shared U32 (Usize.ofInt 32) s i +def index_array_u32 (s : Array U32 32#usize) (i : Usize) : Result U32 := + Array.index_shared U32 32#usize s i /- [array::index_array_copy]: forward function -/ -def index_array_copy (x : Array U32 (Usize.ofInt 32)) : Result U32 := - Array.index_shared U32 (Usize.ofInt 32) x (Usize.ofInt 0) +def index_array_copy (x : Array U32 32#usize) : Result U32 := + Array.index_shared U32 32#usize x 0#usize /- [array::index_mut_array]: forward function -/ def index_mut_array - (T0 : Type) (s : Array T0 (Usize.ofInt 32)) (i : Usize) : Result T0 := - Array.index_mut T0 (Usize.ofInt 32) s i + (T0 : Type) (s : Array T0 32#usize) (i : Usize) : Result T0 := + Array.index_mut T0 32#usize s i /- [array::index_mut_array]: backward function 0 -/ def index_mut_array_back - (T0 : Type) (s : Array T0 (Usize.ofInt 32)) (i : Usize) (ret0 : T0) : - Result (Array T0 (Usize.ofInt 32)) + (T0 : Type) (s : Array T0 32#usize) (i : Usize) (ret0 : T0) : + Result (Array T0 32#usize) := - Array.index_mut_back T0 (Usize.ofInt 32) s i ret0 + Array.index_mut_back T0 32#usize s i ret0 /- [array::index_slice]: forward function -/ def index_slice (T0 : Type) (s : Slice T0) (i : Usize) : Result T0 := @@ -85,100 +88,103 @@ def index_mut_slice_back /- [array::slice_subslice_shared_]: forward function -/ def slice_subslice_shared_ (x : Slice U32) (y : Usize) (z : Usize) : Result (Slice U32) := - Slice.subslice_shared U32 x (Range.mk y z) + core.slice.index.Slice.index U32 (Range Usize) + (core.slice.index.Range.coresliceindexSliceIndexInst U32) x + { start := y, end_ := z } /- [array::slice_subslice_mut_]: forward function -/ def slice_subslice_mut_ (x : Slice U32) (y : Usize) (z : Usize) : Result (Slice U32) := - Slice.subslice_mut U32 x (Range.mk y z) + core.slice.index.Slice.index_mut U32 (Range Usize) + (core.slice.index.Range.coresliceindexSliceIndexInst U32) x + { start := y, end_ := z } /- [array::slice_subslice_mut_]: backward function 0 -/ def slice_subslice_mut__back (x : Slice U32) (y : Usize) (z : Usize) (ret0 : Slice U32) : Result (Slice U32) := - Slice.subslice_mut_back U32 x (Range.mk y z) ret0 + core.slice.index.Slice.index_mut_back U32 (Range Usize) + (core.slice.index.Range.coresliceindexSliceIndexInst U32) x + { start := y, end_ := z } ret0 /- [array::array_to_slice_shared_]: forward function -/ -def array_to_slice_shared_ - (x : Array U32 (Usize.ofInt 32)) : Result (Slice U32) := - Array.to_slice_shared U32 (Usize.ofInt 32) x +def array_to_slice_shared_ (x : Array U32 32#usize) : Result (Slice U32) := + Array.to_slice_shared U32 32#usize x /- [array::array_to_slice_mut_]: forward function -/ -def array_to_slice_mut_ - (x : Array U32 (Usize.ofInt 32)) : Result (Slice U32) := - Array.to_slice_mut U32 (Usize.ofInt 32) x +def array_to_slice_mut_ (x : Array U32 32#usize) : Result (Slice U32) := + Array.to_slice_mut U32 32#usize x /- [array::array_to_slice_mut_]: backward function 0 -/ def array_to_slice_mut__back - (x : Array U32 (Usize.ofInt 32)) (ret0 : Slice U32) : - Result (Array U32 (Usize.ofInt 32)) - := - Array.to_slice_mut_back U32 (Usize.ofInt 32) x ret0 + (x : Array U32 32#usize) (ret0 : Slice U32) : Result (Array U32 32#usize) := + Array.to_slice_mut_back U32 32#usize x ret0 /- [array::array_subslice_shared_]: forward function -/ def array_subslice_shared_ - (x : Array U32 (Usize.ofInt 32)) (y : Usize) (z : Usize) : - Result (Slice U32) - := - Array.subslice_shared U32 (Usize.ofInt 32) x (Range.mk y z) + (x : Array U32 32#usize) (y : Usize) (z : Usize) : Result (Slice U32) := + core.array.Array.index U32 (Range Usize) 32#usize + (core.slice.index.Slice.coreopsindexIndexInst U32 (Range Usize) + (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + { start := y, end_ := z } /- [array::array_subslice_mut_]: forward function -/ def array_subslice_mut_ - (x : Array U32 (Usize.ofInt 32)) (y : Usize) (z : Usize) : - Result (Slice U32) - := - Array.subslice_mut U32 (Usize.ofInt 32) x (Range.mk y z) + (x : Array U32 32#usize) (y : Usize) (z : Usize) : Result (Slice U32) := + core.array.Array.index_mut U32 (Range Usize) 32#usize + (core.slice.index.Slice.coreopsindexIndexMutInst U32 (Range Usize) + (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + { start := y, end_ := z } /- [array::array_subslice_mut_]: backward function 0 -/ def array_subslice_mut__back - (x : Array U32 (Usize.ofInt 32)) (y : Usize) (z : Usize) (ret0 : Slice U32) : - Result (Array U32 (Usize.ofInt 32)) + (x : Array U32 32#usize) (y : Usize) (z : Usize) (ret0 : Slice U32) : + Result (Array U32 32#usize) := - Array.subslice_mut_back U32 (Usize.ofInt 32) x (Range.mk y z) ret0 + core.array.Array.index_mut_back U32 (Range Usize) 32#usize + (core.slice.index.Slice.coreopsindexIndexMutInst U32 (Range Usize) + (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + { start := y, end_ := z } ret0 /- [array::index_slice_0]: forward function -/ def index_slice_0 (T0 : Type) (s : Slice T0) : Result T0 := - Slice.index_shared T0 s (Usize.ofInt 0) + Slice.index_shared T0 s 0#usize /- [array::index_array_0]: forward function -/ -def index_array_0 (T0 : Type) (s : Array T0 (Usize.ofInt 32)) : Result T0 := - Array.index_shared T0 (Usize.ofInt 32) s (Usize.ofInt 0) +def index_array_0 (T0 : Type) (s : Array T0 32#usize) : Result T0 := + Array.index_shared T0 32#usize s 0#usize /- [array::index_index_array]: forward function -/ def index_index_array - (s : Array (Array U32 (Usize.ofInt 32)) (Usize.ofInt 32)) (i : Usize) - (j : Usize) : + (s : Array (Array U32 32#usize) 32#usize) (i : Usize) (j : Usize) : Result U32 := do - let a ← - Array.index_shared (Array U32 (Usize.ofInt 32)) (Usize.ofInt 32) s i - Array.index_shared U32 (Usize.ofInt 32) a j + let a ← Array.index_shared (Array U32 32#usize) 32#usize s i + Array.index_shared U32 32#usize a j /- [array::update_update_array]: forward function -/ def update_update_array - (s : Array (Array U32 (Usize.ofInt 32)) (Usize.ofInt 32)) (i : Usize) - (j : Usize) : + (s : Array (Array U32 32#usize) 32#usize) (i : Usize) (j : Usize) : Result Unit := do - let a ← Array.index_mut (Array U32 (Usize.ofInt 32)) (Usize.ofInt 32) s i - let a0 ← Array.index_mut_back U32 (Usize.ofInt 32) a j (U32.ofInt 0) - let _ ← - Array.index_mut_back (Array U32 (Usize.ofInt 32)) (Usize.ofInt 32) s i a0 + let a ← Array.index_mut (Array U32 32#usize) 32#usize s i + let a0 ← Array.index_mut_back U32 32#usize a j 0#u32 + let _ ← Array.index_mut_back (Array U32 32#usize) 32#usize s i a0 Result.ret () /- [array::array_local_deep_copy]: forward function -/ -def array_local_deep_copy (x : Array U32 (Usize.ofInt 32)) : Result Unit := +def array_local_deep_copy (x : Array U32 32#usize) : Result Unit := Result.ret () /- [array::take_array]: forward function -/ -def take_array (a : Array U32 (Usize.ofInt 2)) : Result Unit := +def take_array (a : Array U32 2#usize) : Result Unit := Result.ret () /- [array::take_array_borrow]: forward function -/ -def take_array_borrow (a : Array U32 (Usize.ofInt 2)) : Result Unit := +def take_array_borrow (a : Array U32 2#usize) : Result Unit := Result.ret () /- [array::take_slice]: forward function -/ @@ -193,148 +199,133 @@ def take_mut_slice (s : Slice U32) : Result (Slice U32) := /- [array::take_all]: forward function -/ def take_all : Result Unit := do - let _ ← - take_array - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) - let _ ← - take_array_borrow - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) + let _ ← take_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let _ ← take_array_borrow (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let s ← - Array.to_slice_shared U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) + Array.to_slice_shared U32 2#usize + (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let _ ← take_slice s let s0 ← - Array.to_slice_mut U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) + Array.to_slice_mut U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let s1 ← take_mut_slice s0 let _ ← - Array.to_slice_mut_back U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) s1 + Array.to_slice_mut_back U32 2#usize + (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s1 Result.ret () /- [array::index_array]: forward function -/ -def index_array (x : Array U32 (Usize.ofInt 2)) : Result U32 := - Array.index_shared U32 (Usize.ofInt 2) x (Usize.ofInt 0) +def index_array (x : Array U32 2#usize) : Result U32 := + Array.index_shared U32 2#usize x 0#usize /- [array::index_array_borrow]: forward function -/ -def index_array_borrow (x : Array U32 (Usize.ofInt 2)) : Result U32 := - Array.index_shared U32 (Usize.ofInt 2) x (Usize.ofInt 0) +def index_array_borrow (x : Array U32 2#usize) : Result U32 := + Array.index_shared U32 2#usize x 0#usize /- [array::index_slice_u32_0]: forward function -/ def index_slice_u32_0 (x : Slice U32) : Result U32 := - Slice.index_shared U32 x (Usize.ofInt 0) + Slice.index_shared U32 x 0#usize /- [array::index_mut_slice_u32_0]: forward function -/ def index_mut_slice_u32_0 (x : Slice U32) : Result U32 := - Slice.index_shared U32 x (Usize.ofInt 0) + Slice.index_shared U32 x 0#usize /- [array::index_mut_slice_u32_0]: backward function 0 -/ def index_mut_slice_u32_0_back (x : Slice U32) : Result (Slice U32) := do - let _ ← Slice.index_shared U32 x (Usize.ofInt 0) + let _ ← Slice.index_shared U32 x 0#usize Result.ret x /- [array::index_all]: forward function -/ def index_all : Result U32 := do - let i ← - index_array - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) - let i0 ← - index_array - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) + let i ← index_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let i0 ← index_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let i1 ← i + i0 - let i2 ← - index_array_borrow - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) + let i2 ← index_array_borrow (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let i3 ← i1 + i2 let s ← - Array.to_slice_shared U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) + Array.to_slice_shared U32 2#usize + (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let i4 ← index_slice_u32_0 s let i5 ← i3 + i4 let s0 ← - Array.to_slice_mut U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) + Array.to_slice_mut U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let i6 ← index_mut_slice_u32_0 s0 let i7 ← i5 + i6 let s1 ← index_mut_slice_u32_0_back s0 let _ ← - Array.to_slice_mut_back U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) s1 + Array.to_slice_mut_back U32 2#usize + (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s1 Result.ret i7 /- [array::update_array]: forward function -/ -def update_array (x : Array U32 (Usize.ofInt 2)) : Result Unit := +def update_array (x : Array U32 2#usize) : Result Unit := do - let _ ← - Array.index_mut_back U32 (Usize.ofInt 2) x (Usize.ofInt 0) (U32.ofInt 1) + let _ ← Array.index_mut_back U32 2#usize x 0#usize 1#u32 Result.ret () /- [array::update_array_mut_borrow]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def update_array_mut_borrow - (x : Array U32 (Usize.ofInt 2)) : Result (Array U32 (Usize.ofInt 2)) := - Array.index_mut_back U32 (Usize.ofInt 2) x (Usize.ofInt 0) (U32.ofInt 1) + (x : Array U32 2#usize) : Result (Array U32 2#usize) := + Array.index_mut_back U32 2#usize x 0#usize 1#u32 /- [array::update_mut_slice]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def update_mut_slice (x : Slice U32) : Result (Slice U32) := - Slice.index_mut_back U32 x (Usize.ofInt 0) (U32.ofInt 1) + Slice.index_mut_back U32 x 0#usize 1#u32 /- [array::update_all]: forward function -/ def update_all : Result Unit := do - let _ ← - update_array - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) - let x ← - update_array_mut_borrow - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) - let s ← Array.to_slice_mut U32 (Usize.ofInt 2) x + let _ ← update_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let x ← update_array_mut_borrow (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let s ← Array.to_slice_mut U32 2#usize x let s0 ← update_mut_slice s - let _ ← Array.to_slice_mut_back U32 (Usize.ofInt 2) x s0 + let _ ← Array.to_slice_mut_back U32 2#usize x s0 Result.ret () /- [array::range_all]: forward function -/ def range_all : Result Unit := do let s ← - Array.subslice_mut U32 (Usize.ofInt 4) - (Array.make U32 (Usize.ofInt 4) [ - (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0) - ]) (Range.mk (Usize.ofInt 1) (Usize.ofInt 3)) + core.array.Array.index_mut U32 (Range Usize) 4#usize + (core.slice.index.Slice.coreopsindexIndexMutInst U32 (Range Usize) + (core.slice.index.Range.coresliceindexSliceIndexInst U32)) + (Array.make U32 4#usize [ 0#u32, 0#u32, 0#u32, 0#u32 ]) + { start := 1#usize, end_ := 3#usize } let s0 ← update_mut_slice s let _ ← - Array.subslice_mut_back U32 (Usize.ofInt 4) - (Array.make U32 (Usize.ofInt 4) [ - (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0), (U32.ofInt 0) - ]) (Range.mk (Usize.ofInt 1) (Usize.ofInt 3)) s0 + core.array.Array.index_mut_back U32 (Range Usize) 4#usize + (core.slice.index.Slice.coreopsindexIndexMutInst U32 (Range Usize) + (core.slice.index.Range.coresliceindexSliceIndexInst U32)) + (Array.make U32 4#usize [ 0#u32, 0#u32, 0#u32, 0#u32 ]) + { start := 1#usize, end_ := 3#usize } s0 Result.ret () /- [array::deref_array_borrow]: forward function -/ -def deref_array_borrow (x : Array U32 (Usize.ofInt 2)) : Result U32 := - Array.index_shared U32 (Usize.ofInt 2) x (Usize.ofInt 0) +def deref_array_borrow (x : Array U32 2#usize) : Result U32 := + Array.index_shared U32 2#usize x 0#usize /- [array::deref_array_mut_borrow]: forward function -/ -def deref_array_mut_borrow (x : Array U32 (Usize.ofInt 2)) : Result U32 := - Array.index_shared U32 (Usize.ofInt 2) x (Usize.ofInt 0) +def deref_array_mut_borrow (x : Array U32 2#usize) : Result U32 := + Array.index_shared U32 2#usize x 0#usize /- [array::deref_array_mut_borrow]: backward function 0 -/ def deref_array_mut_borrow_back - (x : Array U32 (Usize.ofInt 2)) : Result (Array U32 (Usize.ofInt 2)) := + (x : Array U32 2#usize) : Result (Array U32 2#usize) := do - let _ ← Array.index_shared U32 (Usize.ofInt 2) x (Usize.ofInt 0) + let _ ← Array.index_shared U32 2#usize x 0#usize Result.ret x /- [array::take_array_t]: forward function -/ -def take_array_t (a : Array T (Usize.ofInt 2)) : Result Unit := +def take_array_t (a : Array T 2#usize) : Result Unit := Result.ret () /- [array::non_copyable_array]: forward function -/ def non_copyable_array : Result Unit := do - let _ ← take_array_t (Array.make T (Usize.ofInt 2) [ T.A, T.B ]) + let _ ← take_array_t (Array.make T 2#usize [ T.A, T.B ]) Result.ret () /- [array::sum]: loop 0: forward function -/ @@ -345,13 +336,13 @@ divergent def sum_loop (s : Slice U32) (sum0 : U32) (i : Usize) : Result U32 := do let i1 ← Slice.index_shared U32 s i let sum1 ← sum0 + i1 - let i2 ← i + (Usize.ofInt 1) + let i2 ← i + 1#usize sum_loop s sum1 i2 else Result.ret sum0 /- [array::sum]: forward function -/ def sum (s : Slice U32) : Result U32 := - sum_loop s (U32.ofInt 0) (Usize.ofInt 0) + sum_loop s 0#u32 0#usize /- [array::sum2]: loop 0: forward function -/ divergent def sum2_loop @@ -364,7 +355,7 @@ divergent def sum2_loop let i2 ← Slice.index_shared U32 s2 i let i3 ← i1 + i2 let sum1 ← sum0 + i3 - let i4 ← i + (Usize.ofInt 1) + let i4 ← i + 1#usize sum2_loop s s2 sum1 i4 else Result.ret sum0 @@ -374,27 +365,25 @@ def sum2 (s : Slice U32) (s2 : Slice U32) : Result U32 := let i0 := Slice.len U32 s2 if not (i = i0) then Result.fail Error.panic - else sum2_loop s s2 (U32.ofInt 0) (Usize.ofInt 0) + else sum2_loop s s2 0#u32 0#usize /- [array::f0]: forward function -/ def f0 : Result Unit := do let s ← - Array.to_slice_mut U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 1), (U32.ofInt 2) ]) - let s0 ← Slice.index_mut_back U32 s (Usize.ofInt 0) (U32.ofInt 1) + Array.to_slice_mut U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) + let s0 ← Slice.index_mut_back U32 s 0#usize 1#u32 let _ ← - Array.to_slice_mut_back U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 1), (U32.ofInt 2) ]) s0 + Array.to_slice_mut_back U32 2#usize + (Array.make U32 2#usize [ 1#u32, 2#u32 ]) s0 Result.ret () /- [array::f1]: forward function -/ def f1 : Result Unit := do let _ ← - Array.index_mut_back U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 1), (U32.ofInt 2) ]) - (Usize.ofInt 0) (U32.ofInt 1) + Array.index_mut_back U32 2#usize + (Array.make U32 2#usize [ 1#u32, 2#u32 ]) 0#usize 1#u32 Result.ret () /- [array::f2]: forward function -/ @@ -402,57 +391,49 @@ def f2 (i : U32) : Result Unit := Result.ret () /- [array::f4]: forward function -/ -def f4 - (x : Array U32 (Usize.ofInt 32)) (y : Usize) (z : Usize) : - Result (Slice U32) - := - Array.subslice_shared U32 (Usize.ofInt 32) x (Range.mk y z) +def f4 (x : Array U32 32#usize) (y : Usize) (z : Usize) : Result (Slice U32) := + core.array.Array.index U32 (Range Usize) 32#usize + (core.slice.index.Slice.coreopsindexIndexInst U32 (Range Usize) + (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + { start := y, end_ := z } /- [array::f3]: forward function -/ def f3 : Result U32 := do let i ← - Array.index_shared U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 1), (U32.ofInt 2) ]) - (Usize.ofInt 0) + Array.index_shared U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) + 0#usize let _ ← f2 i - let b := Array.repeat U32 (Usize.ofInt 32) (U32.ofInt 0) + let b := Array.repeat U32 32#usize 0#u32 let s ← - Array.to_slice_shared U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 1), (U32.ofInt 2) ]) - let s0 ← f4 b (Usize.ofInt 16) (Usize.ofInt 18) + Array.to_slice_shared U32 2#usize + (Array.make U32 2#usize [ 1#u32, 2#u32 ]) + let s0 ← f4 b 16#usize 18#usize sum2 s s0 /- [array::SZ] -/ -def sz_body : Result Usize := Result.ret (Usize.ofInt 32) +def sz_body : Result Usize := Result.ret 32#usize def sz_c : Usize := eval_global sz_body (by simp) /- [array::f5]: forward function -/ -def f5 (x : Array U32 (Usize.ofInt 32)) : Result U32 := - Array.index_shared U32 (Usize.ofInt 32) x (Usize.ofInt 0) +def f5 (x : Array U32 32#usize) : Result U32 := + Array.index_shared U32 32#usize x 0#usize /- [array::ite]: forward function -/ def ite : Result Unit := do let s ← - Array.to_slice_mut U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) + Array.to_slice_mut U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let s0 ← - Array.to_slice_mut U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) + Array.to_slice_mut U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let s1 ← index_mut_slice_u32_0_back s0 let _ ← - Array.to_slice_mut_back U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) s1 + Array.to_slice_mut_back U32 2#usize + (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s1 let s2 ← index_mut_slice_u32_0_back s let _ ← - Array.to_slice_mut_back U32 (Usize.ofInt 2) - (Array.make U32 (Usize.ofInt 2) [ (U32.ofInt 0), (U32.ofInt 0) ]) s2 + Array.to_slice_mut_back U32 2#usize + (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s2 Result.ret () -/- [array::array]: forward function -/ -def array (LEN : Usize) : Result (Array U8 LEN) := - let a := Array.repeat U8 LEN (U8.ofInt 0) - Result.ret a - end array -- cgit v1.2.3 From 4e70d285b35d25c172e7bedd204ec885ef91d146 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Wed, 25 Oct 2023 18:46:44 +0200 Subject: Regenerate the hashmap files --- tests/lean/Hashmap/Funs.lean | 217 +++++++++++++++++++++++++----------------- tests/lean/Hashmap/Types.lean | 2 +- 2 files changed, 133 insertions(+), 86 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Hashmap/Funs.lean b/tests/lean/Hashmap/Funs.lean index 01c61de4..8464c432 100644 --- a/tests/lean/Hashmap/Funs.lean +++ b/tests/lean/Hashmap/Funs.lean @@ -12,18 +12,22 @@ def hash_key (k : Usize) : Result Usize := /- [hashmap::HashMap::{0}::allocate_slots]: loop 0: forward function -/ divergent def HashMap.allocate_slots_loop - (T : Type) (slots : Vec (List T)) (n : Usize) : Result (Vec (List T)) := - if n > (Usize.ofInt 0) + (T : Type) (slots : alloc.vec.Vec (List T)) (n : Usize) : + Result (alloc.vec.Vec (List T)) + := + if n > 0#usize then do - let slots0 ← Vec.push (List T) slots List.Nil - let n0 ← n - (Usize.ofInt 1) + let slots0 ← alloc.vec.Vec.push (List T) slots List.Nil + let n0 ← n - 1#usize HashMap.allocate_slots_loop T slots0 n0 else Result.ret slots /- [hashmap::HashMap::{0}::allocate_slots]: forward function -/ def HashMap.allocate_slots - (T : Type) (slots : Vec (List T)) (n : Usize) : Result (Vec (List T)) := + (T : Type) (slots : alloc.vec.Vec (List T)) (n : Usize) : + Result (alloc.vec.Vec (List T)) + := HashMap.allocate_slots_loop T slots n /- [hashmap::HashMap::{0}::new_with_capacity]: forward function -/ @@ -33,13 +37,13 @@ def HashMap.new_with_capacity Result (HashMap T) := do - let v := Vec.new (List T) + let v := alloc.vec.Vec.new (List T) let slots ← HashMap.allocate_slots T v capacity let i ← capacity * max_load_dividend let i0 ← i / max_load_divisor Result.ret { - num_entries := (Usize.ofInt 0), + num_entries := 0#usize, max_load_factor := (max_load_dividend, max_load_divisor), max_load := i0, slots := slots @@ -47,18 +51,23 @@ def HashMap.new_with_capacity /- [hashmap::HashMap::{0}::new]: forward function -/ def HashMap.new (T : Type) : Result (HashMap T) := - HashMap.new_with_capacity T (Usize.ofInt 32) (Usize.ofInt 4) (Usize.ofInt 5) + HashMap.new_with_capacity T 32#usize 4#usize 5#usize /- [hashmap::HashMap::{0}::clear]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ divergent def HashMap.clear_loop - (T : Type) (slots : Vec (List T)) (i : Usize) : Result (Vec (List T)) := - let i0 := Vec.len (List T) slots + (T : Type) (slots : alloc.vec.Vec (List T)) (i : Usize) : + Result (alloc.vec.Vec (List T)) + := + let i0 := alloc.vec.Vec.len (List T) slots if i < i0 then do - let i1 ← i + (Usize.ofInt 1) - let slots0 ← Vec.index_mut_back (List T) slots i List.Nil + let i1 ← i + 1#usize + let slots0 ← + alloc.vec.Vec.index_mut_back (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) slots + i List.Nil HashMap.clear_loop T slots0 i1 else Result.ret slots @@ -66,8 +75,8 @@ divergent def HashMap.clear_loop (there is a single backward function, and the forward function returns ()) -/ def HashMap.clear (T : Type) (self : HashMap T) : Result (HashMap T) := do - let v ← HashMap.clear_loop T self.slots (Usize.ofInt 0) - Result.ret { self with num_entries := (Usize.ofInt 0), slots := v } + let v ← HashMap.clear_loop T self.slots 0#usize + Result.ret { self with num_entries := 0#usize, slots := v } /- [hashmap::HashMap::{0}::len]: forward function -/ def HashMap.len (T : Type) (self : HashMap T) : Result Usize := @@ -115,21 +124,30 @@ def HashMap.insert_no_resize := do let hash ← hash_key key - let i := Vec.len (List T) self.slots + let i := alloc.vec.Vec.len (List T) self.slots let hash_mod ← hash % i - let l ← Vec.index_mut (List T) self.slots hash_mod + let l ← + alloc.vec.Vec.index_mut (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) + self.slots hash_mod let inserted ← HashMap.insert_in_list T key value l if inserted then do - let i0 ← self.num_entries + (Usize.ofInt 1) + let i0 ← self.num_entries + 1#usize let l0 ← HashMap.insert_in_list_back T key value l - let v ← Vec.index_mut_back (List T) self.slots hash_mod l0 + let v ← + alloc.vec.Vec.index_mut_back (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) + self.slots hash_mod l0 Result.ret { self with num_entries := i0, slots := v } else do let l0 ← HashMap.insert_in_list_back T key value l - let v ← Vec.index_mut_back (List T) self.slots hash_mod l0 + let v ← + alloc.vec.Vec.index_mut_back (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) + self.slots hash_mod l0 Result.ret { self with slots := v } /- [hashmap::HashMap::{0}::move_elements_from_list]: loop 0: merged forward/backward function @@ -152,27 +170,35 @@ def HashMap.move_elements_from_list /- [hashmap::HashMap::{0}::move_elements]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ divergent def HashMap.move_elements_loop - (T : Type) (ntable : HashMap T) (slots : Vec (List T)) (i : Usize) : - Result ((HashMap T) × (Vec (List T))) + (T : Type) (ntable : HashMap T) (slots : alloc.vec.Vec (List T)) (i : Usize) + : + Result ((HashMap T) × (alloc.vec.Vec (List T))) := - let i0 := Vec.len (List T) slots + let i0 := alloc.vec.Vec.len (List T) slots if i < i0 then do - let l ← Vec.index_mut (List T) slots i - let ls := mem.replace (List T) l List.Nil + let l ← + alloc.vec.Vec.index_mut (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) slots + i + let ls := core.mem.replace (List T) l List.Nil let ntable0 ← HashMap.move_elements_from_list T ntable ls - let i1 ← i + (Usize.ofInt 1) - let l0 := mem.replace_back (List T) l List.Nil - let slots0 ← Vec.index_mut_back (List T) slots i l0 + let i1 ← i + 1#usize + let l0 := core.mem.replace_back (List T) l List.Nil + let slots0 ← + alloc.vec.Vec.index_mut_back (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) slots + i l0 HashMap.move_elements_loop T ntable0 slots0 i1 else Result.ret (ntable, slots) /- [hashmap::HashMap::{0}::move_elements]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def HashMap.move_elements - (T : Type) (ntable : HashMap T) (slots : Vec (List T)) (i : Usize) : - Result ((HashMap T) × (Vec (List T))) + (T : Type) (ntable : HashMap T) (slots : alloc.vec.Vec (List T)) (i : Usize) + : + Result ((HashMap T) × (alloc.vec.Vec (List T))) := HashMap.move_elements_loop T ntable slots i @@ -181,17 +207,16 @@ def HashMap.move_elements def HashMap.try_resize (T : Type) (self : HashMap T) : Result (HashMap T) := do let max_usize ← Scalar.cast .Usize core_u32_max - let capacity := Vec.len (List T) self.slots - let n1 ← max_usize / (Usize.ofInt 2) + let capacity := alloc.vec.Vec.len (List T) self.slots + let n1 ← max_usize / 2#usize let (i, i0) := self.max_load_factor let i1 ← n1 / i if capacity <= i1 then do - let i2 ← capacity * (Usize.ofInt 2) + let i2 ← capacity * 2#usize let ntable ← HashMap.new_with_capacity T i2 i i0 - let (ntable0, _) ← - HashMap.move_elements T ntable self.slots (Usize.ofInt 0) + let (ntable0, _) ← HashMap.move_elements T ntable self.slots 0#usize Result.ret { ntable0 @@ -233,9 +258,12 @@ def HashMap.contains_key (T : Type) (self : HashMap T) (key : Usize) : Result Bool := do let hash ← hash_key key - let i := Vec.len (List T) self.slots + let i := alloc.vec.Vec.len (List T) self.slots let hash_mod ← hash % i - let l ← Vec.index_shared (List T) self.slots hash_mod + let l ← + alloc.vec.Vec.index (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) + self.slots hash_mod HashMap.contains_key_in_list T key l /- [hashmap::HashMap::{0}::get_in_list]: loop 0: forward function -/ @@ -256,9 +284,12 @@ def HashMap.get_in_list (T : Type) (key : Usize) (ls : List T) : Result T := def HashMap.get (T : Type) (self : HashMap T) (key : Usize) : Result T := do let hash ← hash_key key - let i := Vec.len (List T) self.slots + let i := alloc.vec.Vec.len (List T) self.slots let hash_mod ← hash % i - let l ← Vec.index_shared (List T) self.slots hash_mod + let l ← + alloc.vec.Vec.index (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) + self.slots hash_mod HashMap.get_in_list T key l /- [hashmap::HashMap::{0}::get_mut_in_list]: loop 0: forward function -/ @@ -298,9 +329,12 @@ def HashMap.get_mut_in_list_back def HashMap.get_mut (T : Type) (self : HashMap T) (key : Usize) : Result T := do let hash ← hash_key key - let i := Vec.len (List T) self.slots + let i := alloc.vec.Vec.len (List T) self.slots let hash_mod ← hash % i - let l ← Vec.index_mut (List T) self.slots hash_mod + let l ← + alloc.vec.Vec.index_mut (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) + self.slots hash_mod HashMap.get_mut_in_list T l key /- [hashmap::HashMap::{0}::get_mut]: backward function 0 -/ @@ -310,11 +344,17 @@ def HashMap.get_mut_back := do let hash ← hash_key key - let i := Vec.len (List T) self.slots + let i := alloc.vec.Vec.len (List T) self.slots let hash_mod ← hash % i - let l ← Vec.index_mut (List T) self.slots hash_mod + let l ← + alloc.vec.Vec.index_mut (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) + self.slots hash_mod let l0 ← HashMap.get_mut_in_list_back T l key ret0 - let v ← Vec.index_mut_back (List T) self.slots hash_mod l0 + let v ← + alloc.vec.Vec.index_mut_back (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) + self.slots hash_mod l0 Result.ret { self with slots := v } /- [hashmap::HashMap::{0}::remove_from_list]: loop 0: forward function -/ @@ -324,12 +364,12 @@ divergent def HashMap.remove_from_list_loop | List.Cons ckey t tl => if ckey = key then - let mv_ls := mem.replace (List T) (List.Cons ckey t tl) List.Nil + let mv_ls := core.mem.replace (List T) (List.Cons ckey t tl) List.Nil match mv_ls with - | List.Cons i cvalue tl0 => Result.ret (Option.some cvalue) + | List.Cons i cvalue tl0 => Result.ret (some cvalue) | List.Nil => Result.fail Error.panic else HashMap.remove_from_list_loop T key tl - | List.Nil => Result.ret Option.none + | List.Nil => Result.ret none /- [hashmap::HashMap::{0}::remove_from_list]: forward function -/ def HashMap.remove_from_list @@ -343,7 +383,7 @@ divergent def HashMap.remove_from_list_loop_back | List.Cons ckey t tl => if ckey = key then - let mv_ls := mem.replace (List T) (List.Cons ckey t tl) List.Nil + let mv_ls := core.mem.replace (List T) (List.Cons ckey t tl) List.Nil match mv_ls with | List.Cons i cvalue tl0 => Result.ret tl0 | List.Nil => Result.fail Error.panic @@ -363,84 +403,91 @@ def HashMap.remove (T : Type) (self : HashMap T) (key : Usize) : Result (Option T) := do let hash ← hash_key key - let i := Vec.len (List T) self.slots + let i := alloc.vec.Vec.len (List T) self.slots let hash_mod ← hash % i - let l ← Vec.index_mut (List T) self.slots hash_mod + let l ← + alloc.vec.Vec.index_mut (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) + self.slots hash_mod let x ← HashMap.remove_from_list T key l match x with - | Option.none => Result.ret Option.none - | Option.some x0 => - do - let _ ← self.num_entries - (Usize.ofInt 1) - Result.ret (Option.some x0) + | none => Result.ret none + | some x0 => do + let _ ← self.num_entries - 1#usize + Result.ret (some x0) /- [hashmap::HashMap::{0}::remove]: backward function 0 -/ def HashMap.remove_back (T : Type) (self : HashMap T) (key : Usize) : Result (HashMap T) := do let hash ← hash_key key - let i := Vec.len (List T) self.slots + let i := alloc.vec.Vec.len (List T) self.slots let hash_mod ← hash % i - let l ← Vec.index_mut (List T) self.slots hash_mod + let l ← + alloc.vec.Vec.index_mut (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) + self.slots hash_mod let x ← HashMap.remove_from_list T key l match x with - | Option.none => + | none => do let l0 ← HashMap.remove_from_list_back T key l - let v ← Vec.index_mut_back (List T) self.slots hash_mod l0 + let v ← + alloc.vec.Vec.index_mut_back (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) + self.slots hash_mod l0 Result.ret { self with slots := v } - | Option.some x0 => + | some x0 => do - let i0 ← self.num_entries - (Usize.ofInt 1) + let i0 ← self.num_entries - 1#usize let l0 ← HashMap.remove_from_list_back T key l - let v ← Vec.index_mut_back (List T) self.slots hash_mod l0 + let v ← + alloc.vec.Vec.index_mut_back (List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) + self.slots hash_mod l0 Result.ret { self with num_entries := i0, slots := v } /- [hashmap::test1]: forward function -/ def test1 : Result Unit := do let hm ← HashMap.new U64 - let hm0 ← HashMap.insert U64 hm (Usize.ofInt 0) (U64.ofInt 42) - let hm1 ← HashMap.insert U64 hm0 (Usize.ofInt 128) (U64.ofInt 18) - let hm2 ← HashMap.insert U64 hm1 (Usize.ofInt 1024) (U64.ofInt 138) - let hm3 ← HashMap.insert U64 hm2 (Usize.ofInt 1056) (U64.ofInt 256) - let i ← HashMap.get U64 hm3 (Usize.ofInt 128) - if not (i = (U64.ofInt 18)) + let hm0 ← HashMap.insert U64 hm 0#usize 42#u64 + let hm1 ← HashMap.insert U64 hm0 128#usize 18#u64 + let hm2 ← HashMap.insert U64 hm1 1024#usize 138#u64 + let hm3 ← HashMap.insert U64 hm2 1056#usize 256#u64 + let i ← HashMap.get U64 hm3 128#usize + if not (i = 18#u64) then Result.fail Error.panic else do - let hm4 ← - HashMap.get_mut_back U64 hm3 (Usize.ofInt 1024) (U64.ofInt 56) - let i0 ← HashMap.get U64 hm4 (Usize.ofInt 1024) - if not (i0 = (U64.ofInt 56)) + let hm4 ← HashMap.get_mut_back U64 hm3 1024#usize 56#u64 + let i0 ← HashMap.get U64 hm4 1024#usize + if not (i0 = 56#u64) then Result.fail Error.panic else do - let x ← HashMap.remove U64 hm4 (Usize.ofInt 1024) + let x ← HashMap.remove U64 hm4 1024#usize match x with - | Option.none => Result.fail Error.panic - | Option.some x0 => - if not (x0 = (U64.ofInt 56)) + | none => Result.fail Error.panic + | some x0 => + if not (x0 = 56#u64) then Result.fail Error.panic else do - let hm5 ← HashMap.remove_back U64 hm4 (Usize.ofInt 1024) - let i1 ← HashMap.get U64 hm5 (Usize.ofInt 0) - if not (i1 = (U64.ofInt 42)) + let hm5 ← HashMap.remove_back U64 hm4 1024#usize + let i1 ← HashMap.get U64 hm5 0#usize + if not (i1 = 42#u64) then Result.fail Error.panic else do - let i2 ← HashMap.get U64 hm5 (Usize.ofInt 128) - if not (i2 = (U64.ofInt 18)) + let i2 ← HashMap.get U64 hm5 128#usize + if not (i2 = 18#u64) then Result.fail Error.panic else do - let i3 ← HashMap.get U64 hm5 (Usize.ofInt 1056) - if not (i3 = (U64.ofInt 256)) + let i3 ← HashMap.get U64 hm5 1056#usize + if not (i3 = 256#u64) then Result.fail Error.panic else Result.ret () -/- Unit test for [hashmap::test1] -/ -#assert (test1 == .ret ()) - end hashmap diff --git a/tests/lean/Hashmap/Types.lean b/tests/lean/Hashmap/Types.lean index 6455798d..e007bce0 100644 --- a/tests/lean/Hashmap/Types.lean +++ b/tests/lean/Hashmap/Types.lean @@ -15,6 +15,6 @@ structure HashMap (T : Type) where num_entries : Usize max_load_factor : (Usize × Usize) max_load : Usize - slots : Vec (List T) + slots : alloc.vec.Vec (List T) end hashmap -- cgit v1.2.3 From c380ab1699a115edf88e9d83234a4423333e52bf Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 26 Oct 2023 14:12:09 +0200 Subject: Regenerate the array files for Lean --- tests/lean/Array/Funs.lean | 206 +++++++++++++++++++++----------------------- tests/lean/Array/Types.lean | 8 +- 2 files changed, 103 insertions(+), 111 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Array/Funs.lean b/tests/lean/Array/Funs.lean index 899bf856..32ae6248 100644 --- a/tests/lean/Array/Funs.lean +++ b/tests/lean/Array/Funs.lean @@ -13,89 +13,87 @@ def incr (x : U32) : Result U32 := /- [array::array_to_shared_slice_]: forward function -/ def array_to_shared_slice_ - (T0 : Type) (s : Array T0 32#usize) : Result (Slice T0) := - Array.to_slice_shared T0 32#usize s + (T : Type) (s : Array T 32#usize) : Result (Slice T) := + Array.to_slice T 32#usize s /- [array::array_to_mut_slice_]: forward function -/ -def array_to_mut_slice_ - (T0 : Type) (s : Array T0 32#usize) : Result (Slice T0) := - Array.to_slice_mut T0 32#usize s +def 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 -/ def array_to_mut_slice__back - (T0 : Type) (s : Array T0 32#usize) (ret0 : Slice T0) : - Result (Array T0 32#usize) + (T : Type) (s : Array T 32#usize) (ret0 : Slice T) : + Result (Array T 32#usize) := - Array.to_slice_mut_back T0 32#usize s ret0 + Array.from_slice T 32#usize s ret0 /- [array::array_len]: forward function -/ -def array_len (T0 : Type) (s : Array T0 32#usize) : Result Usize := +def array_len (T : Type) (s : Array T 32#usize) : Result Usize := do - let s0 ← Array.to_slice_shared T0 32#usize s - let i := Slice.len T0 s0 + let s0 ← Array.to_slice T 32#usize s + let i := Slice.len T s0 Result.ret i /- [array::shared_array_len]: forward function -/ -def shared_array_len (T0 : Type) (s : Array T0 32#usize) : Result Usize := +def shared_array_len (T : Type) (s : Array T 32#usize) : Result Usize := do - let s0 ← Array.to_slice_shared T0 32#usize s - let i := Slice.len T0 s0 + let s0 ← Array.to_slice T 32#usize s + let i := Slice.len T s0 Result.ret i /- [array::shared_slice_len]: forward function -/ -def shared_slice_len (T0 : Type) (s : Slice T0) : Result Usize := - let i := Slice.len T0 s +def shared_slice_len (T : Type) (s : Slice T) : Result Usize := + let i := Slice.len T s Result.ret i /- [array::index_array_shared]: forward function -/ def index_array_shared - (T0 : Type) (s : Array T0 32#usize) (i : Usize) : Result T0 := - Array.index_shared T0 32#usize s i + (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 -/ def index_array_u32 (s : Array U32 32#usize) (i : Usize) : Result U32 := - Array.index_shared U32 32#usize s i + Array.index_usize U32 32#usize s i /- [array::index_array_copy]: forward function -/ def index_array_copy (x : Array U32 32#usize) : Result U32 := - Array.index_shared U32 32#usize x 0#usize + Array.index_usize U32 32#usize x 0#usize /- [array::index_mut_array]: forward function -/ -def index_mut_array - (T0 : Type) (s : Array T0 32#usize) (i : Usize) : Result T0 := - Array.index_mut T0 32#usize s i +def 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 -/ def index_mut_array_back - (T0 : Type) (s : Array T0 32#usize) (i : Usize) (ret0 : T0) : - Result (Array T0 32#usize) + (T : Type) (s : Array T 32#usize) (i : Usize) (ret0 : T) : + Result (Array T 32#usize) := - Array.index_mut_back T0 32#usize s i ret0 + Array.update_usize T 32#usize s i ret0 /- [array::index_slice]: forward function -/ -def index_slice (T0 : Type) (s : Slice T0) (i : Usize) : Result T0 := - Slice.index_shared T0 s i +def index_slice (T : Type) (s : Slice T) (i : Usize) : Result T := + Slice.index_usize T s i /- [array::index_mut_slice]: forward function -/ -def index_mut_slice (T0 : Type) (s : Slice T0) (i : Usize) : Result T0 := - Slice.index_mut T0 s i +def 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 -/ def index_mut_slice_back - (T0 : Type) (s : Slice T0) (i : Usize) (ret0 : T0) : Result (Slice T0) := - Slice.index_mut_back T0 s i ret0 + (T : Type) (s : Slice T) (i : Usize) (ret0 : T) : Result (Slice T) := + Slice.update_usize T s i ret0 /- [array::slice_subslice_shared_]: forward function -/ def slice_subslice_shared_ (x : Slice U32) (y : Usize) (z : Usize) : Result (Slice U32) := - core.slice.index.Slice.index U32 (Range Usize) + core.slice.index.Slice.index U32 (core.ops.range.Range Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32) x { start := y, end_ := z } /- [array::slice_subslice_mut_]: forward function -/ def slice_subslice_mut_ (x : Slice U32) (y : Usize) (z : Usize) : Result (Slice U32) := - core.slice.index.Slice.index_mut U32 (Range Usize) + core.slice.index.Slice.index_mut U32 (core.ops.range.Range Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32) x { start := y, end_ := z } @@ -104,37 +102,37 @@ def slice_subslice_mut__back (x : Slice U32) (y : Usize) (z : Usize) (ret0 : Slice U32) : Result (Slice U32) := - core.slice.index.Slice.index_mut_back U32 (Range Usize) + core.slice.index.Slice.index_mut_back U32 (core.ops.range.Range Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32) x { start := y, end_ := z } ret0 /- [array::array_to_slice_shared_]: forward function -/ def array_to_slice_shared_ (x : Array U32 32#usize) : Result (Slice U32) := - Array.to_slice_shared U32 32#usize x + Array.to_slice U32 32#usize x /- [array::array_to_slice_mut_]: forward function -/ def array_to_slice_mut_ (x : Array U32 32#usize) : Result (Slice U32) := - Array.to_slice_mut U32 32#usize x + Array.to_slice U32 32#usize x /- [array::array_to_slice_mut_]: backward function 0 -/ def array_to_slice_mut__back (x : Array U32 32#usize) (ret0 : Slice U32) : Result (Array U32 32#usize) := - Array.to_slice_mut_back U32 32#usize x ret0 + Array.from_slice U32 32#usize x ret0 /- [array::array_subslice_shared_]: forward function -/ def array_subslice_shared_ (x : Array U32 32#usize) (y : Usize) (z : Usize) : Result (Slice U32) := - core.array.Array.index U32 (Range Usize) 32#usize - (core.slice.index.Slice.coreopsindexIndexInst U32 (Range Usize) - (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + core.array.Array.index U32 (core.ops.range.Range Usize) 32#usize + (core.slice.index.Slice.coreopsindexIndexInst U32 (core.ops.range.Range + Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x { start := y, end_ := z } /- [array::array_subslice_mut_]: forward function -/ def array_subslice_mut_ (x : Array U32 32#usize) (y : Usize) (z : Usize) : Result (Slice U32) := - core.array.Array.index_mut U32 (Range Usize) 32#usize - (core.slice.index.Slice.coreopsindexIndexMutInst U32 (Range Usize) - (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + core.array.Array.index_mut U32 (core.ops.range.Range Usize) 32#usize + (core.slice.index.Slice.coreopsindexIndexMutInst U32 (core.ops.range.Range + Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x { start := y, end_ := z } /- [array::array_subslice_mut_]: backward function 0 -/ @@ -142,18 +140,18 @@ def array_subslice_mut__back (x : Array U32 32#usize) (y : Usize) (z : Usize) (ret0 : Slice U32) : Result (Array U32 32#usize) := - core.array.Array.index_mut_back U32 (Range Usize) 32#usize - (core.slice.index.Slice.coreopsindexIndexMutInst U32 (Range Usize) - (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + core.array.Array.index_mut_back U32 (core.ops.range.Range Usize) 32#usize + (core.slice.index.Slice.coreopsindexIndexMutInst U32 (core.ops.range.Range + Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x { start := y, end_ := z } ret0 /- [array::index_slice_0]: forward function -/ -def index_slice_0 (T0 : Type) (s : Slice T0) : Result T0 := - Slice.index_shared T0 s 0#usize +def index_slice_0 (T : Type) (s : Slice T) : Result T := + Slice.index_usize T s 0#usize /- [array::index_array_0]: forward function -/ -def index_array_0 (T0 : Type) (s : Array T0 32#usize) : Result T0 := - Array.index_shared T0 32#usize s 0#usize +def 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 -/ def index_index_array @@ -161,8 +159,8 @@ def index_index_array Result U32 := do - let a ← Array.index_shared (Array U32 32#usize) 32#usize s i - Array.index_shared U32 32#usize a j + let a ← Array.index_usize (Array U32 32#usize) 32#usize s i + Array.index_usize U32 32#usize a j /- [array::update_update_array]: forward function -/ def update_update_array @@ -170,9 +168,9 @@ def update_update_array Result Unit := do - let a ← Array.index_mut (Array U32 32#usize) 32#usize s i - let a0 ← Array.index_mut_back U32 32#usize a j 0#u32 - let _ ← Array.index_mut_back (Array U32 32#usize) 32#usize s i a0 + let a ← Array.index_usize (Array U32 32#usize) 32#usize s i + let a0 ← Array.update_usize U32 32#usize a j 0#u32 + let _ ← Array.update_usize (Array U32 32#usize) 32#usize s i a0 Result.ret () /- [array::array_local_deep_copy]: forward function -/ @@ -202,37 +200,35 @@ def take_all : Result Unit := let _ ← take_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let _ ← take_array_borrow (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let s ← - Array.to_slice_shared U32 2#usize - (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let _ ← take_slice s let s0 ← - Array.to_slice_mut U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let s1 ← take_mut_slice s0 let _ ← - Array.to_slice_mut_back U32 2#usize - (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s1 + Array.from_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s1 Result.ret () /- [array::index_array]: forward function -/ def index_array (x : Array U32 2#usize) : Result U32 := - Array.index_shared U32 2#usize x 0#usize + Array.index_usize U32 2#usize x 0#usize /- [array::index_array_borrow]: forward function -/ def index_array_borrow (x : Array U32 2#usize) : Result U32 := - Array.index_shared U32 2#usize x 0#usize + Array.index_usize U32 2#usize x 0#usize /- [array::index_slice_u32_0]: forward function -/ def index_slice_u32_0 (x : Slice U32) : Result U32 := - Slice.index_shared U32 x 0#usize + Slice.index_usize U32 x 0#usize /- [array::index_mut_slice_u32_0]: forward function -/ def index_mut_slice_u32_0 (x : Slice U32) : Result U32 := - Slice.index_shared U32 x 0#usize + Slice.index_usize U32 x 0#usize /- [array::index_mut_slice_u32_0]: backward function 0 -/ def index_mut_slice_u32_0_back (x : Slice U32) : Result (Slice U32) := do - let _ ← Slice.index_shared U32 x 0#usize + let _ ← Slice.index_usize U32 x 0#usize Result.ret x /- [array::index_all]: forward function -/ @@ -244,60 +240,60 @@ def index_all : Result U32 := let i2 ← index_array_borrow (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let i3 ← i1 + i2 let s ← - Array.to_slice_shared U32 2#usize - (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let i4 ← index_slice_u32_0 s let i5 ← i3 + i4 let s0 ← - Array.to_slice_mut U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let i6 ← index_mut_slice_u32_0 s0 let i7 ← i5 + i6 let s1 ← index_mut_slice_u32_0_back s0 let _ ← - Array.to_slice_mut_back U32 2#usize - (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s1 + Array.from_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s1 Result.ret i7 /- [array::update_array]: forward function -/ def update_array (x : Array U32 2#usize) : Result Unit := do - let _ ← Array.index_mut_back U32 2#usize x 0#usize 1#u32 + let _ ← Array.update_usize U32 2#usize x 0#usize 1#u32 Result.ret () /- [array::update_array_mut_borrow]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def update_array_mut_borrow (x : Array U32 2#usize) : Result (Array U32 2#usize) := - Array.index_mut_back U32 2#usize x 0#usize 1#u32 + Array.update_usize U32 2#usize x 0#usize 1#u32 /- [array::update_mut_slice]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def update_mut_slice (x : Slice U32) : Result (Slice U32) := - Slice.index_mut_back U32 x 0#usize 1#u32 + Slice.update_usize U32 x 0#usize 1#u32 /- [array::update_all]: forward function -/ def update_all : Result Unit := do let _ ← update_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let x ← update_array_mut_borrow (Array.make U32 2#usize [ 0#u32, 0#u32 ]) - let s ← Array.to_slice_mut U32 2#usize x + let s ← Array.to_slice U32 2#usize x let s0 ← update_mut_slice s - let _ ← Array.to_slice_mut_back U32 2#usize x s0 + let _ ← Array.from_slice U32 2#usize x s0 Result.ret () /- [array::range_all]: forward function -/ def range_all : Result Unit := do let s ← - core.array.Array.index_mut U32 (Range Usize) 4#usize - (core.slice.index.Slice.coreopsindexIndexMutInst U32 (Range Usize) + core.array.Array.index_mut U32 (core.ops.range.Range Usize) 4#usize + (core.slice.index.Slice.coreopsindexIndexMutInst U32 + (core.ops.range.Range Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32)) (Array.make U32 4#usize [ 0#u32, 0#u32, 0#u32, 0#u32 ]) { start := 1#usize, end_ := 3#usize } let s0 ← update_mut_slice s let _ ← - core.array.Array.index_mut_back U32 (Range Usize) 4#usize - (core.slice.index.Slice.coreopsindexIndexMutInst U32 (Range Usize) + core.array.Array.index_mut_back U32 (core.ops.range.Range Usize) 4#usize + (core.slice.index.Slice.coreopsindexIndexMutInst U32 + (core.ops.range.Range Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32)) (Array.make U32 4#usize [ 0#u32, 0#u32, 0#u32, 0#u32 ]) { start := 1#usize, end_ := 3#usize } s0 @@ -305,27 +301,27 @@ def range_all : Result Unit := /- [array::deref_array_borrow]: forward function -/ def deref_array_borrow (x : Array U32 2#usize) : Result U32 := - Array.index_shared U32 2#usize x 0#usize + Array.index_usize U32 2#usize x 0#usize /- [array::deref_array_mut_borrow]: forward function -/ def deref_array_mut_borrow (x : Array U32 2#usize) : Result U32 := - Array.index_shared U32 2#usize x 0#usize + Array.index_usize U32 2#usize x 0#usize /- [array::deref_array_mut_borrow]: backward function 0 -/ def deref_array_mut_borrow_back (x : Array U32 2#usize) : Result (Array U32 2#usize) := do - let _ ← Array.index_shared U32 2#usize x 0#usize + let _ ← Array.index_usize U32 2#usize x 0#usize Result.ret x /- [array::take_array_t]: forward function -/ -def take_array_t (a : Array T 2#usize) : Result Unit := +def take_array_t (a : Array AB 2#usize) : Result Unit := Result.ret () /- [array::non_copyable_array]: forward function -/ def non_copyable_array : Result Unit := do - let _ ← take_array_t (Array.make T 2#usize [ T.A, T.B ]) + let _ ← take_array_t (Array.make AB 2#usize [ AB.A, AB.B ]) Result.ret () /- [array::sum]: loop 0: forward function -/ @@ -334,7 +330,7 @@ divergent def sum_loop (s : Slice U32) (sum0 : U32) (i : Usize) : Result U32 := if i < i0 then do - let i1 ← Slice.index_shared U32 s i + let i1 ← Slice.index_usize U32 s i let sum1 ← sum0 + i1 let i2 ← i + 1#usize sum_loop s sum1 i2 @@ -351,8 +347,8 @@ divergent def sum2_loop if i < i0 then do - let i1 ← Slice.index_shared U32 s i - let i2 ← Slice.index_shared U32 s2 i + let i1 ← Slice.index_usize U32 s i + let i2 ← Slice.index_usize U32 s2 i let i3 ← i1 + i2 let sum1 ← sum0 + i3 let i4 ← i + 1#usize @@ -371,19 +367,18 @@ def sum2 (s : Slice U32) (s2 : Slice U32) : Result U32 := def f0 : Result Unit := do let s ← - Array.to_slice_mut U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) - let s0 ← Slice.index_mut_back U32 s 0#usize 1#u32 + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) + let s0 ← Slice.update_usize U32 s 0#usize 1#u32 let _ ← - Array.to_slice_mut_back U32 2#usize - (Array.make U32 2#usize [ 1#u32, 2#u32 ]) s0 + Array.from_slice U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) s0 Result.ret () /- [array::f1]: forward function -/ def f1 : Result Unit := do let _ ← - Array.index_mut_back U32 2#usize - (Array.make U32 2#usize [ 1#u32, 2#u32 ]) 0#usize 1#u32 + Array.update_usize U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) + 0#usize 1#u32 Result.ret () /- [array::f2]: forward function -/ @@ -392,22 +387,21 @@ def f2 (i : U32) : Result Unit := /- [array::f4]: forward function -/ def f4 (x : Array U32 32#usize) (y : Usize) (z : Usize) : Result (Slice U32) := - core.array.Array.index U32 (Range Usize) 32#usize - (core.slice.index.Slice.coreopsindexIndexInst U32 (Range Usize) - (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + core.array.Array.index U32 (core.ops.range.Range Usize) 32#usize + (core.slice.index.Slice.coreopsindexIndexInst U32 (core.ops.range.Range + Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x { start := y, end_ := z } /- [array::f3]: forward function -/ def f3 : Result U32 := do let i ← - Array.index_shared U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) + Array.index_usize U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) 0#usize let _ ← f2 i let b := Array.repeat U32 32#usize 0#u32 let s ← - Array.to_slice_shared U32 2#usize - (Array.make U32 2#usize [ 1#u32, 2#u32 ]) + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) let s0 ← f4 b 16#usize 18#usize sum2 s s0 @@ -417,23 +411,21 @@ def sz_c : Usize := eval_global sz_body (by simp) /- [array::f5]: forward function -/ def f5 (x : Array U32 32#usize) : Result U32 := - Array.index_shared U32 32#usize x 0#usize + Array.index_usize U32 32#usize x 0#usize /- [array::ite]: forward function -/ def ite : Result Unit := do let s ← - Array.to_slice_mut U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let s0 ← - Array.to_slice_mut U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) let s1 ← index_mut_slice_u32_0_back s0 let _ ← - Array.to_slice_mut_back U32 2#usize - (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s1 + Array.from_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s1 let s2 ← index_mut_slice_u32_0_back s let _ ← - Array.to_slice_mut_back U32 2#usize - (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s2 + Array.from_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s2 Result.ret () end array diff --git a/tests/lean/Array/Types.lean b/tests/lean/Array/Types.lean index 72241276..60fa81ab 100644 --- a/tests/lean/Array/Types.lean +++ b/tests/lean/Array/Types.lean @@ -5,9 +5,9 @@ open Primitives namespace array -/- [array::T] -/ -inductive T := -| A : T -| B : T +/- [array::AB] -/ +inductive AB := +| A : AB +| B : AB end array -- cgit v1.2.3 From bfafe1f4d1cb69c9b921a77c7193c92b45cc21df Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 26 Oct 2023 14:45:19 +0200 Subject: Regenerate several test files for Lean --- tests/lean/Constants.lean | 29 ++++---- tests/lean/External/Funs.lean | 16 ++--- tests/lean/Loops/Funs.lean | 161 +++++++++++++++++++++++------------------- tests/lean/Paper.lean | 48 ++++++------- 4 files changed, 132 insertions(+), 122 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Constants.lean b/tests/lean/Constants.lean index b0cdaa90..2603cbbf 100644 --- a/tests/lean/Constants.lean +++ b/tests/lean/Constants.lean @@ -6,7 +6,7 @@ open Primitives namespace constants /- [constants::X0] -/ -def x0_body : Result U32 := Result.ret (U32.ofInt 0) +def x0_body : Result U32 := Result.ret 0#u32 def x0_c : U32 := eval_global x0_body (by simp) /- [constants::X1] -/ @@ -14,15 +14,15 @@ def x1_body : Result U32 := Result.ret core_u32_max def x1_c : U32 := eval_global x1_body (by simp) /- [constants::X2] -/ -def x2_body : Result U32 := Result.ret (U32.ofInt 3) +def x2_body : Result U32 := Result.ret 3#u32 def x2_c : U32 := eval_global x2_body (by simp) /- [constants::incr]: forward function -/ def incr (n : U32) : Result U32 := - n + (U32.ofInt 1) + n + 1#u32 /- [constants::X3] -/ -def x3_body : Result U32 := incr (U32.ofInt 32) +def x3_body : Result U32 := incr 32#u32 def x3_c : U32 := eval_global x3_body (by simp) /- [constants::mk_pair0]: forward function -/ @@ -39,20 +39,19 @@ def mk_pair1 (x : U32) (y : U32) : Result (Pair U32 U32) := Result.ret { x := x, y := y } /- [constants::P0] -/ -def p0_body : Result (U32 × U32) := mk_pair0 (U32.ofInt 0) (U32.ofInt 1) +def p0_body : Result (U32 × U32) := mk_pair0 0#u32 1#u32 def p0_c : (U32 × U32) := eval_global p0_body (by simp) /- [constants::P1] -/ -def p1_body : Result (Pair U32 U32) := mk_pair1 (U32.ofInt 0) (U32.ofInt 1) +def p1_body : Result (Pair U32 U32) := mk_pair1 0#u32 1#u32 def p1_c : Pair U32 U32 := eval_global p1_body (by simp) /- [constants::P2] -/ -def p2_body : Result (U32 × U32) := Result.ret ((U32.ofInt 0), (U32.ofInt 1)) +def p2_body : Result (U32 × U32) := Result.ret (0#u32, 1#u32) def p2_c : (U32 × U32) := eval_global p2_body (by simp) /- [constants::P3] -/ -def p3_body : Result (Pair U32 U32) := - Result.ret { x := (U32.ofInt 0), y := (U32.ofInt 1) } +def p3_body : Result (Pair U32 U32) := Result.ret { x := 0#u32, y := 1#u32 } def p3_c : Pair U32 U32 := eval_global p3_body (by simp) /- [constants::Wrap] -/ @@ -64,7 +63,7 @@ def Wrap.new (T : Type) (val : T) : Result (Wrap T) := Result.ret { val := val } /- [constants::Y] -/ -def y_body : Result (Wrap I32) := Wrap.new I32 (I32.ofInt 2) +def y_body : Result (Wrap I32) := Wrap.new I32 2#i32 def y_c : Wrap I32 := eval_global y_body (by simp) /- [constants::unwrap_y]: forward function -/ @@ -76,7 +75,7 @@ def yval_body : Result I32 := unwrap_y def yval_c : I32 := eval_global yval_body (by simp) /- [constants::get_z1::Z1] -/ -def get_z1_z1_body : Result I32 := Result.ret (I32.ofInt 3) +def get_z1_z1_body : Result I32 := Result.ret 3#i32 def get_z1_z1_c : I32 := eval_global get_z1_z1_body (by simp) /- [constants::get_z1]: forward function -/ @@ -88,7 +87,7 @@ def add (a : I32) (b : I32) : Result I32 := a + b /- [constants::Q1] -/ -def q1_body : Result I32 := Result.ret (I32.ofInt 5) +def q1_body : Result I32 := Result.ret 5#i32 def q1_c : I32 := eval_global q1_body (by simp) /- [constants::Q2] -/ @@ -96,7 +95,7 @@ def q2_body : Result I32 := Result.ret q1_c def q2_c : I32 := eval_global q2_body (by simp) /- [constants::Q3] -/ -def q3_body : Result I32 := add q2_c (I32.ofInt 3) +def q3_body : Result I32 := add q2_c 3#i32 def q3_c : I32 := eval_global q3_body (by simp) /- [constants::get_z2]: forward function -/ @@ -107,7 +106,7 @@ def get_z2 : Result I32 := add q1_c i0 /- [constants::S1] -/ -def s1_body : Result U32 := Result.ret (U32.ofInt 6) +def s1_body : Result U32 := Result.ret 6#u32 def s1_c : U32 := eval_global s1_body (by simp) /- [constants::S2] -/ @@ -119,7 +118,7 @@ def s3_body : Result (Pair U32 U32) := Result.ret p3_c def s3_c : Pair U32 U32 := eval_global s3_body (by simp) /- [constants::S4] -/ -def s4_body : Result (Pair U32 U32) := mk_pair1 (U32.ofInt 7) (U32.ofInt 8) +def s4_body : Result (Pair U32 U32) := mk_pair1 7#u32 8#u32 def s4_c : Pair U32 U32 := eval_global s4_body (by simp) end constants diff --git a/tests/lean/External/Funs.lean b/tests/lean/External/Funs.lean index 055d7860..55fb07be 100644 --- a/tests/lean/External/Funs.lean +++ b/tests/lean/External/Funs.lean @@ -30,14 +30,14 @@ def swap_back def test_new_non_zero_u32 (x : U32) (st : State) : Result (State × core.num.nonzero.NonZeroU32) := do - let (st0, opt) ← core.num.nonzero.NonZeroU32.new x st - core.option.Option.unwrap core.num.nonzero.NonZeroU32 opt st0 + let (st0, o) ← core.num.nonzero.NonZeroU32.new x st + core.option.Option.unwrap core.num.nonzero.NonZeroU32 o st0 /- [external::test_vec]: forward function -/ def test_vec : Result Unit := do - let v := Vec.new U32 - let _ ← Vec.push U32 v (U32.ofInt 0) + let v := alloc.vec.Vec.new U32 + let _ ← alloc.vec.Vec.push U32 v 0#u32 Result.ret () /- Unit test for [external::test_vec] -/ @@ -75,14 +75,14 @@ def test_custom_swap_back (x : U32) (y : U32) (st : State) (st0 : State) : Result (State × (U32 × U32)) := - custom_swap_back U32 x y st (U32.ofInt 1) st0 + custom_swap_back U32 x y st 1#u32 st0 /- [external::test_swap_non_zero]: forward function -/ def test_swap_non_zero (x : U32) (st : State) : Result (State × U32) := do - let (st0, _) ← swap U32 x (U32.ofInt 0) st - let (st1, (x0, _)) ← swap_back U32 x (U32.ofInt 0) st st0 - if x0 = (U32.ofInt 0) + let (st0, _) ← swap U32 x 0#u32 st + let (st1, (x0, _)) ← swap_back U32 x 0#u32 st st0 + if x0 = 0#u32 then Result.fail Error.panic else Result.ret (st1, x0) diff --git a/tests/lean/Loops/Funs.lean b/tests/lean/Loops/Funs.lean index 5fbe200f..f9c7569e 100644 --- a/tests/lean/Loops/Funs.lean +++ b/tests/lean/Loops/Funs.lean @@ -11,13 +11,13 @@ divergent def sum_loop (max : U32) (i : U32) (s : U32) : Result U32 := if i < max then do let s0 ← s + i - let i0 ← i + (U32.ofInt 1) + let i0 ← i + 1#u32 sum_loop max i0 s0 - else s * (U32.ofInt 2) + else s * 2#u32 /- [loops::sum]: forward function -/ def sum (max : U32) : Result U32 := - sum_loop max (U32.ofInt 0) (U32.ofInt 0) + sum_loop max 0#u32 0#u32 /- [loops::sum_with_mut_borrows]: loop 0: forward function -/ divergent def sum_with_mut_borrows_loop @@ -26,13 +26,13 @@ divergent def sum_with_mut_borrows_loop then do let ms0 ← ms + mi - let mi0 ← mi + (U32.ofInt 1) + let mi0 ← mi + 1#u32 sum_with_mut_borrows_loop max mi0 ms0 - else ms * (U32.ofInt 2) + else ms * 2#u32 /- [loops::sum_with_mut_borrows]: forward function -/ def sum_with_mut_borrows (max : U32) : Result U32 := - sum_with_mut_borrows_loop max (U32.ofInt 0) (U32.ofInt 0) + sum_with_mut_borrows_loop max 0#u32 0#u32 /- [loops::sum_with_shared_borrows]: loop 0: forward function -/ divergent def sum_with_shared_borrows_loop @@ -40,31 +40,34 @@ divergent def sum_with_shared_borrows_loop if i < max then do - let i0 ← i + (U32.ofInt 1) + let i0 ← i + 1#u32 let s0 ← s + i0 sum_with_shared_borrows_loop max i0 s0 - else s * (U32.ofInt 2) + else s * 2#u32 /- [loops::sum_with_shared_borrows]: forward function -/ def sum_with_shared_borrows (max : U32) : Result U32 := - sum_with_shared_borrows_loop max (U32.ofInt 0) (U32.ofInt 0) + sum_with_shared_borrows_loop max 0#u32 0#u32 /- [loops::clear]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ -divergent def clear_loop (v : Vec U32) (i : Usize) : Result (Vec U32) := - let i0 := Vec.len U32 v +divergent def clear_loop + (v : alloc.vec.Vec U32) (i : Usize) : Result (alloc.vec.Vec U32) := + let i0 := alloc.vec.Vec.len U32 v if i < i0 then do - let i1 ← i + (Usize.ofInt 1) - let v0 ← Vec.index_mut_back U32 v i (U32.ofInt 0) + let i1 ← i + 1#usize + let v0 ← + alloc.vec.Vec.index_mut_back U32 Usize + (core.slice.index.usize.coresliceindexSliceIndexInst U32) v i 0#u32 clear_loop v0 i1 else Result.ret v /- [loops::clear]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ -def clear (v : Vec U32) : Result (Vec U32) := - clear_loop v (Usize.ofInt 0) +def clear (v : alloc.vec.Vec U32) : Result (alloc.vec.Vec U32) := + clear_loop v 0#usize /- [loops::list_mem]: loop 0: forward function -/ divergent def list_mem_loop (x : U32) (ls : List U32) : Result Bool := @@ -83,10 +86,10 @@ divergent def list_nth_mut_loop_loop (T : Type) (ls : List T) (i : U32) : Result T := match ls with | List.Cons x tl => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret x else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 list_nth_mut_loop_loop T tl i0 | List.Nil => Result.fail Error.panic @@ -99,11 +102,11 @@ divergent def list_nth_mut_loop_loop_back (T : Type) (ls : List T) (i : U32) (ret0 : T) : Result (List T) := match ls with | List.Cons x tl => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (List.Cons ret0 tl) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 let tl0 ← list_nth_mut_loop_loop_back T tl i0 ret0 Result.ret (List.Cons x tl0) | List.Nil => Result.fail Error.panic @@ -118,10 +121,10 @@ 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 = (U32.ofInt 0) + if i = 0#u32 then Result.ret x else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 list_nth_shared_loop_loop T tl i0 | List.Nil => Result.fail Error.panic @@ -138,9 +141,13 @@ divergent def get_elem_mut_loop (x : Usize) (ls : List Usize) : Result Usize := | List.Nil => Result.fail Error.panic /- [loops::get_elem_mut]: forward function -/ -def get_elem_mut (slots : Vec (List Usize)) (x : Usize) : Result Usize := +def get_elem_mut + (slots : alloc.vec.Vec (List Usize)) (x : Usize) : Result Usize := do - let l ← Vec.index_mut (List Usize) slots (Usize.ofInt 0) + let l ← + alloc.vec.Vec.index_mut (List Usize) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) + slots 0#usize get_elem_mut_loop x l /- [loops::get_elem_mut]: loop 0: backward function 0 -/ @@ -158,13 +165,18 @@ divergent def get_elem_mut_loop_back /- [loops::get_elem_mut]: backward function 0 -/ def get_elem_mut_back - (slots : Vec (List Usize)) (x : Usize) (ret0 : Usize) : - Result (Vec (List Usize)) + (slots : alloc.vec.Vec (List Usize)) (x : Usize) (ret0 : Usize) : + Result (alloc.vec.Vec (List Usize)) := do - let l ← Vec.index_mut (List Usize) slots (Usize.ofInt 0) + let l ← + alloc.vec.Vec.index_mut (List Usize) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) + slots 0#usize let l0 ← get_elem_mut_loop_back x l ret0 - Vec.index_mut_back (List Usize) slots (Usize.ofInt 0) l0 + alloc.vec.Vec.index_mut_back (List Usize) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) slots + 0#usize l0 /- [loops::get_elem_shared]: loop 0: forward function -/ divergent def get_elem_shared_loop @@ -176,9 +188,13 @@ divergent def get_elem_shared_loop | List.Nil => Result.fail Error.panic /- [loops::get_elem_shared]: forward function -/ -def get_elem_shared (slots : Vec (List Usize)) (x : Usize) : Result Usize := +def get_elem_shared + (slots : alloc.vec.Vec (List Usize)) (x : Usize) : Result Usize := do - let l ← Vec.index_shared (List Usize) slots (Usize.ofInt 0) + let l ← + alloc.vec.Vec.index (List Usize) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) + slots 0#usize get_elem_shared_loop x l /- [loops::id_mut]: forward function -/ @@ -198,10 +214,10 @@ divergent def list_nth_mut_loop_with_id_loop (T : Type) (i : U32) (ls : List T) : Result T := match ls with | List.Cons x tl => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret x else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 list_nth_mut_loop_with_id_loop T i0 tl | List.Nil => Result.fail Error.panic @@ -216,11 +232,11 @@ divergent def list_nth_mut_loop_with_id_loop_back (T : Type) (i : U32) (ls : List T) (ret0 : T) : Result (List T) := match ls with | List.Cons x tl => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (List.Cons ret0 tl) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 let tl0 ← list_nth_mut_loop_with_id_loop_back T i0 tl ret0 Result.ret (List.Cons x tl0) | List.Nil => Result.fail Error.panic @@ -238,12 +254,11 @@ 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 = (U32.ofInt 0) + if i = 0#u32 then Result.ret x - else - do - let i0 ← i - (U32.ofInt 1) - list_nth_shared_loop_with_id_loop T i0 tl + else do + let i0 ← i - 1#u32 + list_nth_shared_loop_with_id_loop T i0 tl | List.Nil => Result.fail Error.panic /- [loops::list_nth_shared_loop_with_id]: forward function -/ @@ -260,12 +275,11 @@ divergent def list_nth_mut_loop_pair_loop | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (x0, x1) - else - do - let i0 ← i - (U32.ofInt 1) - list_nth_mut_loop_pair_loop T tl0 tl1 i0 + else do + let i0 ← i - 1#u32 + list_nth_mut_loop_pair_loop T tl0 tl1 i0 | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic @@ -283,11 +297,11 @@ divergent def list_nth_mut_loop_pair_loop_back'a | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (List.Cons ret0 tl0) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 let tl00 ← list_nth_mut_loop_pair_loop_back'a T tl0 tl1 i0 ret0 Result.ret (List.Cons x0 tl00) | List.Nil => Result.fail Error.panic @@ -309,11 +323,11 @@ divergent def list_nth_mut_loop_pair_loop_back'b | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (List.Cons ret0 tl1) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 let tl10 ← list_nth_mut_loop_pair_loop_back'b T tl0 tl1 i0 ret0 Result.ret (List.Cons x1 tl10) | List.Nil => Result.fail Error.panic @@ -333,12 +347,11 @@ divergent def list_nth_shared_loop_pair_loop | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (x0, x1) - else - do - let i0 ← i - (U32.ofInt 1) - list_nth_shared_loop_pair_loop T tl0 tl1 i0 + else do + let i0 ← i - 1#u32 + list_nth_shared_loop_pair_loop T tl0 tl1 i0 | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic @@ -354,11 +367,11 @@ divergent def list_nth_mut_loop_pair_merge_loop | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (x0, x1) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 list_nth_mut_loop_pair_merge_loop T tl0 tl1 i0 | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic @@ -377,12 +390,12 @@ divergent def list_nth_mut_loop_pair_merge_loop_back | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then let (t, t0) := ret0 Result.ret (List.Cons t tl0, List.Cons t0 tl1) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 let (tl00, tl10) ← list_nth_mut_loop_pair_merge_loop_back T tl0 tl1 i0 ret0 Result.ret (List.Cons x0 tl00, List.Cons x1 tl10) @@ -403,11 +416,11 @@ divergent def list_nth_shared_loop_pair_merge_loop | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (x0, x1) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 list_nth_shared_loop_pair_merge_loop T tl0 tl1 i0 | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic @@ -424,11 +437,11 @@ divergent def list_nth_mut_shared_loop_pair_loop | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (x0, x1) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 list_nth_mut_shared_loop_pair_loop T tl0 tl1 i0 | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic @@ -447,11 +460,11 @@ divergent def list_nth_mut_shared_loop_pair_loop_back | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (List.Cons ret0 tl0) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 let tl00 ← list_nth_mut_shared_loop_pair_loop_back T tl0 tl1 i0 ret0 Result.ret (List.Cons x0 tl00) @@ -472,11 +485,11 @@ divergent def list_nth_mut_shared_loop_pair_merge_loop | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (x0, x1) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 list_nth_mut_shared_loop_pair_merge_loop T tl0 tl1 i0 | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic @@ -495,11 +508,11 @@ divergent def list_nth_mut_shared_loop_pair_merge_loop_back | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (List.Cons ret0 tl0) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 let tl00 ← list_nth_mut_shared_loop_pair_merge_loop_back T tl0 tl1 i0 ret0 Result.ret (List.Cons x0 tl00) @@ -520,11 +533,11 @@ divergent def list_nth_shared_mut_loop_pair_loop | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (x0, x1) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 list_nth_shared_mut_loop_pair_loop T tl0 tl1 i0 | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic @@ -543,11 +556,11 @@ divergent def list_nth_shared_mut_loop_pair_loop_back | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (List.Cons ret0 tl1) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 let tl10 ← list_nth_shared_mut_loop_pair_loop_back T tl0 tl1 i0 ret0 Result.ret (List.Cons x1 tl10) @@ -568,11 +581,11 @@ divergent def list_nth_shared_mut_loop_pair_merge_loop | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (x0, x1) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 list_nth_shared_mut_loop_pair_merge_loop T tl0 tl1 i0 | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic @@ -591,11 +604,11 @@ divergent def list_nth_shared_mut_loop_pair_merge_loop_back | List.Cons x0 tl0 => match ls1 with | List.Cons x1 tl1 => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (List.Cons ret0 tl1) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 let tl10 ← list_nth_shared_mut_loop_pair_merge_loop_back T tl0 tl1 i0 ret0 Result.ret (List.Cons x1 tl10) diff --git a/tests/lean/Paper.lean b/tests/lean/Paper.lean index c15c5e4b..ae4dd243 100644 --- a/tests/lean/Paper.lean +++ b/tests/lean/Paper.lean @@ -8,13 +8,13 @@ namespace paper /- [paper::ref_incr]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def ref_incr (x : I32) : Result I32 := - x + (I32.ofInt 1) + x + 1#i32 /- [paper::test_incr]: forward function -/ def test_incr : Result Unit := do - let x ← ref_incr (I32.ofInt 0) - if not (x = (I32.ofInt 1)) + let x ← ref_incr 0#i32 + if not (x = 1#i32) then Result.fail Error.panic else Result.ret () @@ -37,19 +37,18 @@ def choose_back /- [paper::test_choose]: forward function -/ def test_choose : Result Unit := do - let z ← choose I32 true (I32.ofInt 0) (I32.ofInt 0) - let z0 ← z + (I32.ofInt 1) - if not (z0 = (I32.ofInt 1)) + let z ← choose I32 true 0#i32 0#i32 + let z0 ← z + 1#i32 + if not (z0 = 1#i32) then Result.fail Error.panic else do - let (x, y) ← choose_back I32 true (I32.ofInt 0) (I32.ofInt 0) z0 - if not (x = (I32.ofInt 1)) + let (x, y) ← choose_back I32 true 0#i32 0#i32 z0 + if not (x = 1#i32) then Result.fail Error.panic - else - if not (y = (I32.ofInt 0)) - then Result.fail Error.panic - else Result.ret () + else if not (y = 0#i32) + then Result.fail Error.panic + else Result.ret () /- Unit test for [paper::test_choose] -/ #assert (test_choose == .ret ()) @@ -63,10 +62,10 @@ inductive List (T : Type) := divergent def list_nth_mut (T : Type) (l : List T) (i : U32) : Result T := match l with | List.Cons x tl => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret x else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 list_nth_mut T tl i0 | List.Nil => Result.fail Error.panic @@ -75,11 +74,11 @@ divergent def list_nth_mut_back (T : Type) (l : List T) (i : U32) (ret0 : T) : Result (List T) := match l with | List.Cons x tl => - if i = (U32.ofInt 0) + if i = 0#u32 then Result.ret (List.Cons ret0 tl) else do - let i0 ← i - (U32.ofInt 1) + let i0 ← i - 1#u32 let tl0 ← list_nth_mut_back T tl i0 ret0 Result.ret (List.Cons x tl0) | List.Nil => Result.fail Error.panic @@ -90,20 +89,19 @@ divergent def sum (l : List I32) : Result I32 := | List.Cons x tl => do let i ← sum tl x + i - | List.Nil => Result.ret (I32.ofInt 0) + | List.Nil => Result.ret 0#i32 /- [paper::test_nth]: forward function -/ def test_nth : Result Unit := do let l := List.Nil - let l0 := List.Cons (I32.ofInt 3) l - let l1 := List.Cons (I32.ofInt 2) l0 - let x ← list_nth_mut I32 (List.Cons (I32.ofInt 1) l1) (U32.ofInt 2) - let x0 ← x + (I32.ofInt 1) - let l2 ← - list_nth_mut_back I32 (List.Cons (I32.ofInt 1) l1) (U32.ofInt 2) x0 + let l0 := List.Cons 3#i32 l + let l1 := List.Cons 2#i32 l0 + let x ← list_nth_mut I32 (List.Cons 1#i32 l1) 2#u32 + let x0 ← x + 1#i32 + let l2 ← list_nth_mut_back I32 (List.Cons 1#i32 l1) 2#u32 x0 let i ← sum l2 - if not (i = (I32.ofInt 7)) + if not (i = 7#i32) then Result.fail Error.panic else Result.ret () @@ -115,7 +113,7 @@ def call_choose (p : (U32 × U32)) : Result U32 := do let (px, py) := p let pz ← choose U32 true px py - let pz0 ← pz + (U32.ofInt 1) + let pz0 ← pz + 1#u32 let (px0, _) ← choose_back U32 true px py pz0 Result.ret px0 -- cgit v1.2.3 From 76e7a6e4c4ead2e48bc56118b38347b59f4f30db Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 26 Oct 2023 14:50:57 +0200 Subject: Regenerate the betree example for Lean --- tests/lean/BetreeMain/Funs.lean | 79 ++++++++++++++++++++--------------------- 1 file changed, 39 insertions(+), 40 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/BetreeMain/Funs.lean b/tests/lean/BetreeMain/Funs.lean index 6681731f..0901d449 100644 --- a/tests/lean/BetreeMain/Funs.lean +++ b/tests/lean/BetreeMain/Funs.lean @@ -40,39 +40,39 @@ def betree.store_leaf_node /- [betree_main::betree::fresh_node_id]: forward function -/ def betree.fresh_node_id (counter : U64) : Result U64 := do - let _ ← counter + (U64.ofInt 1) + let _ ← counter + 1#u64 Result.ret counter /- [betree_main::betree::fresh_node_id]: backward function 0 -/ def betree.fresh_node_id_back (counter : U64) : Result U64 := - counter + (U64.ofInt 1) + counter + 1#u64 /- [betree_main::betree::NodeIdCounter::{0}::new]: forward function -/ def betree.NodeIdCounter.new : Result betree.NodeIdCounter := - Result.ret { next_node_id := (U64.ofInt 0) } + Result.ret { next_node_id := 0#u64 } /- [betree_main::betree::NodeIdCounter::{0}::fresh_id]: forward function -/ def betree.NodeIdCounter.fresh_id (self : betree.NodeIdCounter) : Result U64 := do - let _ ← self.next_node_id + (U64.ofInt 1) + let _ ← self.next_node_id + 1#u64 Result.ret self.next_node_id /- [betree_main::betree::NodeIdCounter::{0}::fresh_id]: backward function 0 -/ def betree.NodeIdCounter.fresh_id_back (self : betree.NodeIdCounter) : Result betree.NodeIdCounter := do - let i ← self.next_node_id + (U64.ofInt 1) + let i ← self.next_node_id + 1#u64 Result.ret { next_node_id := i } /- [betree_main::betree::upsert_update]: forward function -/ def betree.upsert_update (prev : Option U64) (st : betree.UpsertFunState) : Result U64 := match prev with - | Option.none => + | none => match st with | betree.UpsertFunState.Add v => Result.ret v - | betree.UpsertFunState.Sub i => Result.ret (U64.ofInt 0) - | Option.some prev0 => + | betree.UpsertFunState.Sub i => Result.ret 0#u64 + | some prev0 => match st with | betree.UpsertFunState.Add v => do @@ -83,29 +83,28 @@ def betree.upsert_update | betree.UpsertFunState.Sub v => if prev0 >= v then prev0 - v - else Result.ret (U64.ofInt 0) + else Result.ret 0#u64 /- [betree_main::betree::List::{1}::len]: forward function -/ divergent def betree.List.len (T : Type) (self : betree.List T) : Result U64 := match self with - | betree.List.Cons t tl => - do - let i ← betree.List.len T tl - (U64.ofInt 1) + i - | betree.List.Nil => Result.ret (U64.ofInt 0) + | betree.List.Cons t tl => do + let i ← betree.List.len T tl + 1#u64 + i + | betree.List.Nil => Result.ret 0#u64 /- [betree_main::betree::List::{1}::split_at]: forward function -/ divergent def betree.List.split_at (T : Type) (self : betree.List T) (n : U64) : Result ((betree.List T) × (betree.List T)) := - if n = (U64.ofInt 0) + if n = 0#u64 then Result.ret (betree.List.Nil, self) else match self with | betree.List.Cons hd tl => do - let i ← n - (U64.ofInt 1) + let i ← n - 1#u64 let p ← betree.List.split_at T tl i let (ls0, ls1) := p let l := ls0 @@ -116,13 +115,13 @@ divergent def betree.List.split_at (there is a single backward function, and the forward function returns ()) -/ def betree.List.push_front (T : Type) (self : betree.List T) (x : T) : Result (betree.List T) := - let tl := mem.replace (betree.List T) self betree.List.Nil + let tl := core.mem.replace (betree.List T) self betree.List.Nil let l := tl Result.ret (betree.List.Cons x l) /- [betree_main::betree::List::{1}::pop_front]: forward function -/ def betree.List.pop_front (T : Type) (self : betree.List T) : Result T := - let ls := mem.replace (betree.List T) self betree.List.Nil + let ls := core.mem.replace (betree.List T) self betree.List.Nil match ls with | betree.List.Cons x tl => Result.ret x | betree.List.Nil => Result.fail Error.panic @@ -130,7 +129,7 @@ def betree.List.pop_front (T : Type) (self : betree.List T) : Result T := /- [betree_main::betree::List::{1}::pop_front]: backward function 0 -/ def betree.List.pop_front_back (T : Type) (self : betree.List T) : Result (betree.List T) := - let ls := mem.replace (betree.List T) self betree.List.Nil + let ls := core.mem.replace (betree.List T) self betree.List.Nil match ls with | betree.List.Cons x tl => Result.ret tl | betree.List.Nil => Result.fail Error.panic @@ -256,7 +255,7 @@ divergent def betree.Node.apply_upserts let v ← betree.upsert_update prev s let msgs0 ← betree.List.pop_front_back (U64 × betree.Message) msgs - betree.Node.apply_upserts msgs0 (Option.some v) key st + betree.Node.apply_upserts msgs0 (some v) key st else do let (st0, v) ← core.option.Option.unwrap U64 prev st @@ -286,7 +285,7 @@ divergent def betree.Node.apply_upserts_back let v ← betree.upsert_update prev s let msgs0 ← betree.List.pop_front_back (U64 × betree.Message) msgs - betree.Node.apply_upserts_back msgs0 (Option.some v) key st + betree.Node.apply_upserts_back msgs0 (some v) key st else do let (_, v) ← core.option.Option.unwrap U64 prev st @@ -300,12 +299,12 @@ divergent def betree.Node.lookup_in_bindings | betree.List.Cons hd tl => let (i, i0) := hd if i = key - then Result.ret (Option.some i0) + then Result.ret (some i0) else if i > key - then Result.ret Option.none + then Result.ret none else betree.Node.lookup_in_bindings key tl - | betree.List.Nil => Result.ret Option.none + | betree.List.Nil => Result.ret none /- [betree_main::betree::Internal::{4}::lookup_in_children]: forward function -/ mutual divergent def betree.Internal.lookup_in_children @@ -348,13 +347,13 @@ divergent def betree.Node.lookup if k != key then do - let (st1, opt) ← + let (st1, o) ← betree.Internal.lookup_in_children (betree.Internal.mk i i0 n n0) key st0 let _ ← betree.Node.lookup_first_message_for_key_back key msgs (betree.List.Cons (k, msg) l) - Result.ret (st1, opt) + Result.ret (st1, o) else match msg with | betree.Message.Insert v => @@ -362,13 +361,13 @@ divergent def betree.Node.lookup let _ ← betree.Node.lookup_first_message_for_key_back key msgs (betree.List.Cons (k, betree.Message.Insert v) l) - Result.ret (st0, Option.some v) + Result.ret (st0, some v) | betree.Message.Delete => do let _ ← betree.Node.lookup_first_message_for_key_back key msgs (betree.List.Cons (k, betree.Message.Delete) l) - Result.ret (st0, Option.none) + Result.ret (st0, none) | betree.Message.Upsert ufs => do let (st1, v) ← @@ -387,21 +386,21 @@ divergent def betree.Node.lookup let msgs0 ← betree.Node.lookup_first_message_for_key_back key msgs pending0 let (st3, _) ← betree.store_internal_node i1 msgs0 st2 - Result.ret (st3, Option.some v0) + Result.ret (st3, some v0) | betree.List.Nil => do - let (st1, opt) ← + let (st1, o) ← betree.Internal.lookup_in_children (betree.Internal.mk i i0 n n0) key st0 let _ ← betree.Node.lookup_first_message_for_key_back key msgs betree.List.Nil - Result.ret (st1, opt) + Result.ret (st1, o) | betree.Node.Leaf node => do let (st0, bindings) ← betree.load_leaf_node node.id st - let opt ← betree.Node.lookup_in_bindings key bindings - Result.ret (st0, opt) + let o ← betree.Node.lookup_in_bindings key bindings + Result.ret (st0, o) /- [betree_main::betree::Node::{5}::lookup]: backward function 0 -/ divergent def betree.Node.lookup_back @@ -560,7 +559,7 @@ def betree.Node.apply_to_internal match m with | betree.Message.Insert prev => do - let v ← betree.upsert_update (Option.some prev) s + let v ← betree.upsert_update (some prev) s let msgs1 ← betree.List.pop_front_back (U64 × betree.Message) msgs0 let msgs2 ← @@ -569,7 +568,7 @@ def betree.Node.apply_to_internal betree.Node.lookup_first_message_for_key_back key msgs msgs2 | betree.Message.Delete => do - let v ← betree.upsert_update Option.none s + let v ← betree.upsert_update none s let msgs1 ← betree.List.pop_front_back (U64 × betree.Message) msgs0 let msgs2 ← @@ -665,7 +664,7 @@ def betree.Node.apply_to_leaf | betree.Message.Upsert s => do let (_, i) := hd - let v ← betree.upsert_update (Option.some i) s + let v ← betree.upsert_update (some i) s let bindings1 ← betree.List.pop_front_back (U64 × U64) bindings0 let bindings2 ← betree.List.push_front (U64 × U64) bindings1 (key, v) @@ -681,7 +680,7 @@ def betree.Node.apply_to_leaf betree.Node.lookup_mut_in_bindings_back key bindings bindings0 | betree.Message.Upsert s => do - let v ← betree.upsert_update Option.none s + let v ← betree.upsert_update none s let bindings1 ← betree.List.push_front (U64 × U64) bindings0 (key, v) betree.Node.lookup_mut_in_bindings_back key bindings bindings1 @@ -808,7 +807,7 @@ divergent def betree.Node.apply_messages let (st0, content) ← betree.load_leaf_node node.id st let content0 ← betree.Node.apply_messages_to_leaf content msgs let len ← betree.List.len (U64 × U64) content0 - let i ← (U64.ofInt 2) * params.split_size + let i ← 2#u64 * params.split_size if len >= i then do @@ -858,7 +857,7 @@ divergent def betree.Node.apply_messages_back let (st0, content) ← betree.load_leaf_node node.id st let content0 ← betree.Node.apply_messages_to_leaf content msgs let len ← betree.List.len (U64 × U64) content0 - let i ← (U64.ofInt 2) * params.split_size + let i ← 2#u64 * params.split_size if len >= i then do @@ -918,7 +917,7 @@ def betree.BeTree.new params := { min_flush_size := min_flush_size, split_size := split_size }, node_id_cnt := node_id_cnt0, - root := (betree.Node.Leaf { id := id, size := (U64.ofInt 0) }) + root := (betree.Node.Leaf { id := id, size := 0#u64 }) }) /- [betree_main::betree::BeTree::{6}::apply]: forward function -/ -- cgit v1.2.3 From 7ffcb8e9c5c03f198362fd27bd42f30064541509 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 26 Oct 2023 15:06:36 +0200 Subject: Fix some issues and regenerate the HashmapMain example for Lean --- tests/lean/HashmapMain/Funs.lean | 226 +++++++++++++++++++++----------------- tests/lean/HashmapMain/Types.lean | 2 +- 2 files changed, 129 insertions(+), 99 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/HashmapMain/Funs.lean b/tests/lean/HashmapMain/Funs.lean index 848b1a35..74fa8653 100644 --- a/tests/lean/HashmapMain/Funs.lean +++ b/tests/lean/HashmapMain/Funs.lean @@ -13,21 +13,21 @@ def hashmap.hash_key (k : Usize) : Result Usize := /- [hashmap_main::hashmap::HashMap::{0}::allocate_slots]: loop 0: forward function -/ divergent def hashmap.HashMap.allocate_slots_loop - (T : Type) (slots : Vec (hashmap.List T)) (n : Usize) : - Result (Vec (hashmap.List T)) + (T : Type) (slots : alloc.vec.Vec (hashmap.List T)) (n : Usize) : + Result (alloc.vec.Vec (hashmap.List T)) := - if n > (Usize.ofInt 0) + if n > 0#usize then do - let slots0 ← Vec.push (hashmap.List T) slots hashmap.List.Nil - let n0 ← n - (Usize.ofInt 1) + let slots0 ← alloc.vec.Vec.push (hashmap.List T) slots hashmap.List.Nil + let n0 ← n - 1#usize hashmap.HashMap.allocate_slots_loop T slots0 n0 else Result.ret slots /- [hashmap_main::hashmap::HashMap::{0}::allocate_slots]: forward function -/ def hashmap.HashMap.allocate_slots - (T : Type) (slots : Vec (hashmap.List T)) (n : Usize) : - Result (Vec (hashmap.List T)) + (T : Type) (slots : alloc.vec.Vec (hashmap.List T)) (n : Usize) : + Result (alloc.vec.Vec (hashmap.List T)) := hashmap.HashMap.allocate_slots_loop T slots n @@ -38,13 +38,13 @@ def hashmap.HashMap.new_with_capacity Result (hashmap.HashMap T) := do - let v := Vec.new (hashmap.List T) + let v := alloc.vec.Vec.new (hashmap.List T) let slots ← hashmap.HashMap.allocate_slots T v capacity let i ← capacity * max_load_dividend let i0 ← i / max_load_divisor Result.ret { - num_entries := (Usize.ofInt 0), + num_entries := 0#usize, max_load_factor := (max_load_dividend, max_load_divisor), max_load := i0, slots := slots @@ -52,22 +52,23 @@ def hashmap.HashMap.new_with_capacity /- [hashmap_main::hashmap::HashMap::{0}::new]: forward function -/ def hashmap.HashMap.new (T : Type) : Result (hashmap.HashMap T) := - hashmap.HashMap.new_with_capacity T (Usize.ofInt 32) (Usize.ofInt 4) - (Usize.ofInt 5) + hashmap.HashMap.new_with_capacity T 32#usize 4#usize 5#usize /- [hashmap_main::hashmap::HashMap::{0}::clear]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ divergent def hashmap.HashMap.clear_loop - (T : Type) (slots : Vec (hashmap.List T)) (i : Usize) : - Result (Vec (hashmap.List T)) + (T : Type) (slots : alloc.vec.Vec (hashmap.List T)) (i : Usize) : + Result (alloc.vec.Vec (hashmap.List T)) := - let i0 := Vec.len (hashmap.List T) slots + let i0 := alloc.vec.Vec.len (hashmap.List T) slots if i < i0 then do - let i1 ← i + (Usize.ofInt 1) + let i1 ← i + 1#usize let slots0 ← - Vec.index_mut_back (hashmap.List T) slots i hashmap.List.Nil + alloc.vec.Vec.index_mut_back (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List + T)) slots i hashmap.List.Nil hashmap.HashMap.clear_loop T slots0 i1 else Result.ret slots @@ -76,8 +77,8 @@ divergent def hashmap.HashMap.clear_loop def hashmap.HashMap.clear (T : Type) (self : hashmap.HashMap T) : Result (hashmap.HashMap T) := do - let v ← hashmap.HashMap.clear_loop T self.slots (Usize.ofInt 0) - Result.ret { self with num_entries := (Usize.ofInt 0), slots := v } + let v ← hashmap.HashMap.clear_loop T self.slots 0#usize + Result.ret { self with num_entries := 0#usize, slots := v } /- [hashmap_main::hashmap::HashMap::{0}::len]: forward function -/ def hashmap.HashMap.len (T : Type) (self : hashmap.HashMap T) : Result Usize := @@ -130,21 +131,30 @@ def hashmap.HashMap.insert_no_resize := do let hash ← hashmap.hash_key key - let i := Vec.len (hashmap.List T) self.slots + let i := alloc.vec.Vec.len (hashmap.List T) self.slots let hash_mod ← hash % i - let l ← Vec.index_mut (hashmap.List T) self.slots hash_mod + let l ← + alloc.vec.Vec.index_mut (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + self.slots hash_mod let inserted ← hashmap.HashMap.insert_in_list T key value l if inserted then do - let i0 ← self.num_entries + (Usize.ofInt 1) + let i0 ← self.num_entries + 1#usize let l0 ← hashmap.HashMap.insert_in_list_back T key value l - let v ← Vec.index_mut_back (hashmap.List T) self.slots hash_mod l0 + let v ← + alloc.vec.Vec.index_mut_back (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List + T)) self.slots hash_mod l0 Result.ret { self with num_entries := i0, slots := v } else do let l0 ← hashmap.HashMap.insert_in_list_back T key value l - let v ← Vec.index_mut_back (hashmap.List T) self.slots hash_mod l0 + let v ← + alloc.vec.Vec.index_mut_back (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List + T)) self.slots hash_mod l0 Result.ret { self with slots := v } /- [hashmap_main::hashmap::HashMap::{0}::move_elements_from_list]: loop 0: merged forward/backward function @@ -171,29 +181,35 @@ def hashmap.HashMap.move_elements_from_list /- [hashmap_main::hashmap::HashMap::{0}::move_elements]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ divergent def hashmap.HashMap.move_elements_loop - (T : Type) (ntable : hashmap.HashMap T) (slots : Vec (hashmap.List T)) - (i : Usize) : - Result ((hashmap.HashMap T) × (Vec (hashmap.List T))) + (T : Type) (ntable : hashmap.HashMap T) + (slots : alloc.vec.Vec (hashmap.List T)) (i : Usize) : + Result ((hashmap.HashMap T) × (alloc.vec.Vec (hashmap.List T))) := - let i0 := Vec.len (hashmap.List T) slots + let i0 := alloc.vec.Vec.len (hashmap.List T) slots if i < i0 then do - let l ← Vec.index_mut (hashmap.List T) slots i - let ls := mem.replace (hashmap.List T) l hashmap.List.Nil + let l ← + alloc.vec.Vec.index_mut (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List + T)) slots i + let ls := core.mem.replace (hashmap.List T) l hashmap.List.Nil let ntable0 ← hashmap.HashMap.move_elements_from_list T ntable ls - let i1 ← i + (Usize.ofInt 1) - let l0 := mem.replace_back (hashmap.List T) l hashmap.List.Nil - let slots0 ← Vec.index_mut_back (hashmap.List T) slots i l0 + let i1 ← i + 1#usize + let l0 := core.mem.replace_back (hashmap.List T) l hashmap.List.Nil + let slots0 ← + alloc.vec.Vec.index_mut_back (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List + T)) slots i l0 hashmap.HashMap.move_elements_loop T ntable0 slots0 i1 else Result.ret (ntable, slots) /- [hashmap_main::hashmap::HashMap::{0}::move_elements]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def hashmap.HashMap.move_elements - (T : Type) (ntable : hashmap.HashMap T) (slots : Vec (hashmap.List T)) - (i : Usize) : - Result ((hashmap.HashMap T) × (Vec (hashmap.List T))) + (T : Type) (ntable : hashmap.HashMap T) + (slots : alloc.vec.Vec (hashmap.List T)) (i : Usize) : + Result ((hashmap.HashMap T) × (alloc.vec.Vec (hashmap.List T))) := hashmap.HashMap.move_elements_loop T ntable slots i @@ -203,17 +219,17 @@ def hashmap.HashMap.try_resize (T : Type) (self : hashmap.HashMap T) : Result (hashmap.HashMap T) := do let max_usize ← Scalar.cast .Usize core_u32_max - let capacity := Vec.len (hashmap.List T) self.slots - let n1 ← max_usize / (Usize.ofInt 2) + let capacity := alloc.vec.Vec.len (hashmap.List T) self.slots + let n1 ← max_usize / 2#usize let (i, i0) := self.max_load_factor let i1 ← n1 / i if capacity <= i1 then do - let i2 ← capacity * (Usize.ofInt 2) + let i2 ← capacity * 2#usize let ntable ← hashmap.HashMap.new_with_capacity T i2 i i0 let (ntable0, _) ← - hashmap.HashMap.move_elements T ntable self.slots (Usize.ofInt 0) + hashmap.HashMap.move_elements T ntable self.slots 0#usize Result.ret { ntable0 @@ -255,9 +271,12 @@ def hashmap.HashMap.contains_key (T : Type) (self : hashmap.HashMap T) (key : Usize) : Result Bool := do let hash ← hashmap.hash_key key - let i := Vec.len (hashmap.List T) self.slots + let i := alloc.vec.Vec.len (hashmap.List T) self.slots let hash_mod ← hash % i - let l ← Vec.index_shared (hashmap.List T) self.slots hash_mod + let l ← + alloc.vec.Vec.index (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + self.slots hash_mod hashmap.HashMap.contains_key_in_list T key l /- [hashmap_main::hashmap::HashMap::{0}::get_in_list]: loop 0: forward function -/ @@ -280,9 +299,12 @@ def hashmap.HashMap.get (T : Type) (self : hashmap.HashMap T) (key : Usize) : Result T := do let hash ← hashmap.hash_key key - let i := Vec.len (hashmap.List T) self.slots + let i := alloc.vec.Vec.len (hashmap.List T) self.slots let hash_mod ← hash % i - let l ← Vec.index_shared (hashmap.List T) self.slots hash_mod + let l ← + alloc.vec.Vec.index (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + self.slots hash_mod hashmap.HashMap.get_in_list T key l /- [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: loop 0: forward function -/ @@ -327,9 +349,12 @@ def hashmap.HashMap.get_mut (T : Type) (self : hashmap.HashMap T) (key : Usize) : Result T := do let hash ← hashmap.hash_key key - let i := Vec.len (hashmap.List T) self.slots + let i := alloc.vec.Vec.len (hashmap.List T) self.slots let hash_mod ← hash % i - let l ← Vec.index_mut (hashmap.List T) self.slots hash_mod + let l ← + alloc.vec.Vec.index_mut (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + self.slots hash_mod hashmap.HashMap.get_mut_in_list T l key /- [hashmap_main::hashmap::HashMap::{0}::get_mut]: backward function 0 -/ @@ -339,11 +364,17 @@ def hashmap.HashMap.get_mut_back := do let hash ← hashmap.hash_key key - let i := Vec.len (hashmap.List T) self.slots + let i := alloc.vec.Vec.len (hashmap.List T) self.slots let hash_mod ← hash % i - let l ← Vec.index_mut (hashmap.List T) self.slots hash_mod + let l ← + alloc.vec.Vec.index_mut (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + self.slots hash_mod let l0 ← hashmap.HashMap.get_mut_in_list_back T l key ret0 - let v ← Vec.index_mut_back (hashmap.List T) self.slots hash_mod l0 + let v ← + alloc.vec.Vec.index_mut_back (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + self.slots hash_mod l0 Result.ret { self with slots := v } /- [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: loop 0: forward function -/ @@ -354,13 +385,13 @@ divergent def hashmap.HashMap.remove_from_list_loop if ckey = key then let mv_ls := - mem.replace (hashmap.List T) (hashmap.List.Cons ckey t tl) + core.mem.replace (hashmap.List T) (hashmap.List.Cons ckey t tl) hashmap.List.Nil match mv_ls with - | hashmap.List.Cons i cvalue tl0 => Result.ret (Option.some cvalue) + | hashmap.List.Cons i cvalue tl0 => Result.ret (some cvalue) | hashmap.List.Nil => Result.fail Error.panic else hashmap.HashMap.remove_from_list_loop T key tl - | hashmap.List.Nil => Result.ret Option.none + | hashmap.List.Nil => Result.ret none /- [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: forward function -/ def hashmap.HashMap.remove_from_list @@ -375,7 +406,7 @@ divergent def hashmap.HashMap.remove_from_list_loop_back if ckey = key then let mv_ls := - mem.replace (hashmap.List T) (hashmap.List.Cons ckey t tl) + core.mem.replace (hashmap.List T) (hashmap.List.Cons ckey t tl) hashmap.List.Nil match mv_ls with | hashmap.List.Cons i cvalue tl0 => Result.ret tl0 @@ -396,16 +427,18 @@ def hashmap.HashMap.remove (T : Type) (self : hashmap.HashMap T) (key : Usize) : Result (Option T) := do let hash ← hashmap.hash_key key - let i := Vec.len (hashmap.List T) self.slots + let i := alloc.vec.Vec.len (hashmap.List T) self.slots let hash_mod ← hash % i - let l ← Vec.index_mut (hashmap.List T) self.slots hash_mod + let l ← + alloc.vec.Vec.index_mut (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + self.slots hash_mod let x ← hashmap.HashMap.remove_from_list T key l match x with - | Option.none => Result.ret Option.none - | Option.some x0 => - do - let _ ← self.num_entries - (Usize.ofInt 1) - Result.ret (Option.some x0) + | none => Result.ret none + | some x0 => do + let _ ← self.num_entries - 1#usize + Result.ret (some x0) /- [hashmap_main::hashmap::HashMap::{0}::remove]: backward function 0 -/ def hashmap.HashMap.remove_back @@ -414,75 +447,75 @@ def hashmap.HashMap.remove_back := do let hash ← hashmap.hash_key key - let i := Vec.len (hashmap.List T) self.slots + let i := alloc.vec.Vec.len (hashmap.List T) self.slots let hash_mod ← hash % i - let l ← Vec.index_mut (hashmap.List T) self.slots hash_mod + let l ← + alloc.vec.Vec.index_mut (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + self.slots hash_mod let x ← hashmap.HashMap.remove_from_list T key l match x with - | Option.none => + | none => do let l0 ← hashmap.HashMap.remove_from_list_back T key l - let v ← Vec.index_mut_back (hashmap.List T) self.slots hash_mod l0 + let v ← + alloc.vec.Vec.index_mut_back (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List + T)) self.slots hash_mod l0 Result.ret { self with slots := v } - | Option.some x0 => + | some x0 => do - let i0 ← self.num_entries - (Usize.ofInt 1) + let i0 ← self.num_entries - 1#usize let l0 ← hashmap.HashMap.remove_from_list_back T key l - let v ← Vec.index_mut_back (hashmap.List T) self.slots hash_mod l0 + let v ← + alloc.vec.Vec.index_mut_back (hashmap.List T) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List + T)) self.slots hash_mod l0 Result.ret { self with num_entries := i0, slots := v } /- [hashmap_main::hashmap::test1]: forward function -/ def hashmap.test1 : Result Unit := do let hm ← hashmap.HashMap.new U64 - let hm0 ← hashmap.HashMap.insert U64 hm (Usize.ofInt 0) (U64.ofInt 42) - let hm1 ← hashmap.HashMap.insert U64 hm0 (Usize.ofInt 128) (U64.ofInt 18) - let hm2 ← - hashmap.HashMap.insert U64 hm1 (Usize.ofInt 1024) (U64.ofInt 138) - let hm3 ← - hashmap.HashMap.insert U64 hm2 (Usize.ofInt 1056) (U64.ofInt 256) - let i ← hashmap.HashMap.get U64 hm3 (Usize.ofInt 128) - if not (i = (U64.ofInt 18)) + let hm0 ← hashmap.HashMap.insert U64 hm 0#usize 42#u64 + let hm1 ← hashmap.HashMap.insert U64 hm0 128#usize 18#u64 + let hm2 ← hashmap.HashMap.insert U64 hm1 1024#usize 138#u64 + let hm3 ← hashmap.HashMap.insert U64 hm2 1056#usize 256#u64 + let i ← hashmap.HashMap.get U64 hm3 128#usize + if not (i = 18#u64) then Result.fail Error.panic else do - let hm4 ← - hashmap.HashMap.get_mut_back U64 hm3 (Usize.ofInt 1024) - (U64.ofInt 56) - let i0 ← hashmap.HashMap.get U64 hm4 (Usize.ofInt 1024) - if not (i0 = (U64.ofInt 56)) + let hm4 ← hashmap.HashMap.get_mut_back U64 hm3 1024#usize 56#u64 + let i0 ← hashmap.HashMap.get U64 hm4 1024#usize + if not (i0 = 56#u64) then Result.fail Error.panic else do - let x ← hashmap.HashMap.remove U64 hm4 (Usize.ofInt 1024) + let x ← hashmap.HashMap.remove U64 hm4 1024#usize match x with - | Option.none => Result.fail Error.panic - | Option.some x0 => - if not (x0 = (U64.ofInt 56)) + | none => Result.fail Error.panic + | some x0 => + if not (x0 = 56#u64) then Result.fail Error.panic else do - let hm5 ← - hashmap.HashMap.remove_back U64 hm4 (Usize.ofInt 1024) - let i1 ← hashmap.HashMap.get U64 hm5 (Usize.ofInt 0) - if not (i1 = (U64.ofInt 42)) + let hm5 ← hashmap.HashMap.remove_back U64 hm4 1024#usize + let i1 ← hashmap.HashMap.get U64 hm5 0#usize + if not (i1 = 42#u64) then Result.fail Error.panic else do - let i2 ← hashmap.HashMap.get U64 hm5 (Usize.ofInt 128) - if not (i2 = (U64.ofInt 18)) + let i2 ← hashmap.HashMap.get U64 hm5 128#usize + if not (i2 = 18#u64) then Result.fail Error.panic else do - let i3 ← - hashmap.HashMap.get U64 hm5 (Usize.ofInt 1056) - if not (i3 = (U64.ofInt 256)) + let i3 ← hashmap.HashMap.get U64 hm5 1056#usize + if not (i3 = 256#u64) then Result.fail Error.panic else Result.ret () -/- Unit test for [hashmap_main::hashmap::test1] -/ -#assert (hashmap.test1 == .ret ()) - /- [hashmap_main::insert_on_disk]: forward function -/ def insert_on_disk (key : Usize) (value : U64) (st : State) : Result (State × Unit) := @@ -496,7 +529,4 @@ def insert_on_disk def main : Result Unit := Result.ret () -/- Unit test for [hashmap_main::main] -/ -#assert (main == .ret ()) - end hashmap_main diff --git a/tests/lean/HashmapMain/Types.lean b/tests/lean/HashmapMain/Types.lean index 2b5cbd6c..065c109b 100644 --- a/tests/lean/HashmapMain/Types.lean +++ b/tests/lean/HashmapMain/Types.lean @@ -15,7 +15,7 @@ structure hashmap.HashMap (T : Type) where num_entries : Usize max_load_factor : (Usize × Usize) max_load : Usize - slots : Vec (hashmap.List T) + slots : alloc.vec.Vec (hashmap.List T) /- The state type used in the state-error monad -/ axiom State : Type -- cgit v1.2.3 From 4f824528f5e0c0f898b20917c6c06821efb934da Mon Sep 17 00:00:00 2001 From: Son Ho Date: Fri, 27 Oct 2023 12:12:18 +0200 Subject: Regenerate some of the F* test files --- tests/lean/Constants.lean | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Constants.lean b/tests/lean/Constants.lean index 2603cbbf..bd3a07b7 100644 --- a/tests/lean/Constants.lean +++ b/tests/lean/Constants.lean @@ -56,11 +56,11 @@ def p3_c : Pair U32 U32 := eval_global p3_body (by simp) /- [constants::Wrap] -/ structure Wrap (T : Type) where - val : T + value : T /- [constants::Wrap::{0}::new]: forward function -/ -def Wrap.new (T : Type) (val : T) : Result (Wrap T) := - Result.ret { val := val } +def Wrap.new (T : Type) (value : T) : Result (Wrap T) := + Result.ret { value := value } /- [constants::Y] -/ def y_body : Result (Wrap I32) := Wrap.new I32 2#i32 @@ -68,7 +68,7 @@ def y_c : Wrap I32 := eval_global y_body (by simp) /- [constants::unwrap_y]: forward function -/ def unwrap_y : Result I32 := - Result.ret y_c.val + Result.ret y_c.value /- [constants::YVAL] -/ def yval_body : Result I32 := unwrap_y -- cgit v1.2.3 From c8fce0c24f2f5331f2f1135cc17d45192f2b30e3 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Mon, 6 Nov 2023 18:49:27 +0100 Subject: Regenerate part of the trait tests for Lean --- tests/lean/Traits/Funs.lean | 35 ++++++++++++++++++++------------- tests/lean/Traits/Types.lean | 46 +++++++++++++++++++++++++++++++++++++++++--- 2 files changed, 65 insertions(+), 16 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Traits/Funs.lean b/tests/lean/Traits/Funs.lean index 52ff0c0a..156ef1e0 100644 --- a/tests/lean/Traits/Funs.lean +++ b/tests/lean/Traits/Funs.lean @@ -31,8 +31,8 @@ def test_bool_trait_bool (x : Bool) : Result Bool := /- [traits::Option::{1}::get_bool]: forward function -/ def Option.get_bool (T : Type) (self : Option T) : Result Bool := match self with - | Option.none => Result.ret false - | Option.some t => Result.ret true + | none => Result.ret false + | some t => Result.ret true /- Trait implementation: [traits::Option::{1}] -/ def Option.BoolTraitInst (T : Type) : BoolTrait (Option T) := { @@ -105,7 +105,7 @@ def h2 (T : Type) (inst : ToU64 T) (x : Wrapper T) : Result U64 := /- [traits::u64::{5}::to_type]: forward function -/ def u64.to_type (self : U64) : Result Bool := - Result.ret (self > (U64.ofInt 0)) + Result.ret (self > 0#u64) /- Trait implementation: [traits::u64::{5}] -/ def u64.ToTypeInst : ToType U64 Bool := { @@ -129,7 +129,7 @@ def h4 /- [traits::TestType::{6}::test::TestType1::{0}::test]: forward function -/ def TestType.test.TestType1.test (self : TestType.test.TestType1) : Result Bool := - Result.ret (self._0 > (U64.ofInt 1)) + Result.ret (self._0 > 1#u64) /- Trait implementation: [traits::TestType::{6}::test::TestType1::{0}] -/ def TestType.test.TestType1.TestTypetestTestTraitInst : TestType.test.TestTrait @@ -142,8 +142,8 @@ def TestType.test (T : Type) (inst : ToU64 T) (self : TestType T) (x : T) : Result Bool := do let x0 ← inst.to_u64 x - if x0 > (U64.ofInt 0) - then TestType.test.TestType1.test { _0 := (U64.ofInt 0) } + if x0 > 0#u64 + then TestType.test.TestType1.test { _0 := 0#u64 } else Result.ret false /- [traits::BoolWrapper::{7}::to_type]: forward function -/ @@ -158,21 +158,21 @@ def BoolWrapper.ToTypeInst (T : Type) (inst : ToType Bool T) : ToType } /- [traits::WithConstTy::LEN2] -/ -def with_const_ty_len2_body : Result Usize := Result.ret (Usize.ofInt 32) +def with_const_ty_len2_body : Result Usize := Result.ret 32#usize def with_const_ty_len2_c : Usize := eval_global with_const_ty_len2_body (by simp) /- [traits::Bool::{8}::LEN1] -/ -def bool_len1_body : Result Usize := Result.ret (Usize.ofInt 12) +def bool_len1_body : Result Usize := Result.ret 12#usize def bool_len1_c : Usize := eval_global bool_len1_body (by simp) /- [traits::Bool::{8}::f]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ -def Bool.f (i : U64) (a : Array U8 (Usize.ofInt 32)) : Result U64 := +def Bool.f (i : U64) (a : Array U8 32#usize) : Result U64 := Result.ret i /- Trait implementation: [traits::Bool::{8}] -/ -def Bool.WithConstTyInst : WithConstTy Bool (Usize.ofInt 32) := { +def Bool.WithConstTyInst : WithConstTy Bool 32#usize := { LEN1 := bool_len1_c LEN2 := with_const_ty_len2_c V := U8 @@ -207,9 +207,7 @@ def test_where1 (T : Type) (_x : T) : Result Unit := /- [traits::test_where2]: forward function -/ def test_where2 - (T : Type) (inst : WithConstTy T (Usize.ofInt 32)) (_x : U32) : - Result Unit - := + (T : Type) (inst : WithConstTy T 32#usize) (_x : U32) : Result Unit := Result.ret () /- [traits::test_child_trait1]: forward function -/ @@ -229,4 +227,15 @@ def order1 := Result.ret () +/- [traits::map_option]: forward function -/ +def map_option + (T F : Type) (inst : core.ops.function.Fn F T) (x : Option T) (f0 : F) : + Result (Option T) + := + match x with + | none => Result.ret none + | some x0 => do + let t ← inst.call f0 x0 + Result.ret (some t) + end traits diff --git a/tests/lean/Traits/Types.lean b/tests/lean/Traits/Types.lean index a8c12fe5..e325da6f 100644 --- a/tests/lean/Traits/Types.lean +++ b/tests/lean/Traits/Types.lean @@ -27,7 +27,7 @@ structure OfType (Self : Type) where /- Trait declaration: [traits::OfTypeBis] -/ structure OfTypeBis (Self T : Type) where - parent_clause_0 :ToType T Self + parent_clause_0 : ToType T Self of_type : T → Result Self /- [traits::TestType] -/ @@ -69,8 +69,8 @@ structure ParentTrait1 (Self : Type) where /- Trait declaration: [traits::ChildTrait] -/ structure ChildTrait (Self : Type) where - parent_clause_0 :ParentTrait0 Self - parent_clause_1 :ParentTrait1 Self + parent_clause_0 : ParentTrait0 Self + parent_clause_1 : ParentTrait1 Self /- Trait declaration: [traits::Iterator] -/ structure Iterator (Self : Type) where @@ -83,4 +83,44 @@ structure IntoIterator (Self : Type) where IntoIter_clause_0 : Iterator IntoIter into_iter : Self → Result IntoIter +/- Trait declaration: [traits::FromResidual] -/ +structure FromResidual (Self T : Type) where + +/- Trait declaration: [traits::Try] -/ +structure Try (Self : Type) where + parent_clause_0 : FromResidual Self Residual + Residual : Type + +/- Trait declaration: [traits::CFnOnce] -/ +structure CFnOnce (Self Args : Type) where + Output : Type + call_once : Self → Args → Result Output + +/- Trait declaration: [traits::CFnMut] -/ +structure CFnMut (Self Args : Type) where + parent_clause_0 : CFnOnce Self Args + call_mut : Self → Args → Result parent_clause_0.Output + call_mut_back : Self → Args → parent_clause_0.Output → Result Self + +/- Trait declaration: [traits::CFn] -/ +structure CFn (Self Args : Type) where + parent_clause_0 : CFnMut Self Args + call_mut : Self → Args → Result parent_clause_0.parent_clause_0.Output + +/- Trait declaration: [core::ops::function::FnOnce] -/ +structure core.ops.function.FnOnce (Self Args : Type) where + Output : Type + call_once : Self → Args → Result Output + +/- Trait declaration: [core::ops::function::FnMut] -/ +structure core.ops.function.FnMut (Self Args : Type) where + parent_clause_0 : core.ops.function.FnOnce Self Args + call_mut : Self → Args → Result parent_clause_0.Output + call_mut_back : Self → Args → parent_clause_0.Output → Result Self + +/- Trait declaration: [core::ops::function::Fn] -/ +structure core.ops.function.Fn (Self Args : Type) where + parent_clause_0 : core.ops.function.FnMut Self Args + call : Self → Args → Result parent_clause_0.parent_clause_0.Output + end traits -- cgit v1.2.3 From a745e81c9949f24878f788fffd36667739c59330 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 7 Nov 2023 10:44:58 +0100 Subject: Update the extraction --- tests/lean/Traits/Funs.lean | 9 +++++++++ tests/lean/Traits/Types.lean | 4 ++++ 2 files changed, 13 insertions(+) (limited to 'tests/lean') diff --git a/tests/lean/Traits/Funs.lean b/tests/lean/Traits/Funs.lean index 156ef1e0..6a2834ff 100644 --- a/tests/lean/Traits/Funs.lean +++ b/tests/lean/Traits/Funs.lean @@ -227,6 +227,15 @@ def order1 := Result.ret () +/- Trait implementation: [traits::usize::{9}] -/ +def usize.ParentTrait1Inst : ParentTrait1 Usize := { +} + +/- Trait implementation: [traits::usize::{10}] -/ +def usize.ChildTrait1Inst : ChildTrait1 Usize := { + parent_clause_0 := usize.ParentTrait1Inst +} + /- [traits::map_option]: forward function -/ def map_option (T F : Type) (inst : core.ops.function.Fn F T) (x : Option T) (f0 : F) : diff --git a/tests/lean/Traits/Types.lean b/tests/lean/Traits/Types.lean index e325da6f..20af9cb1 100644 --- a/tests/lean/Traits/Types.lean +++ b/tests/lean/Traits/Types.lean @@ -72,6 +72,10 @@ structure ChildTrait (Self : Type) where parent_clause_0 : ParentTrait0 Self parent_clause_1 : ParentTrait1 Self +/- Trait declaration: [traits::ChildTrait1] -/ +structure ChildTrait1 (Self : Type) where + parent_clause_0 : ParentTrait1 Self + /- Trait declaration: [traits::Iterator] -/ structure Iterator (Self : Type) where Item : Type -- cgit v1.2.3 From 530a5ae56209061f091bbcafee82de07039a8124 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Wed, 8 Nov 2023 14:28:44 +0100 Subject: Update the Makefile and regenerate some tests --- tests/lean/NoNestedBorrows.lean | 12 ++++++++++++ 1 file changed, 12 insertions(+) (limited to 'tests/lean') diff --git a/tests/lean/NoNestedBorrows.lean b/tests/lean/NoNestedBorrows.lean index d6d603ce..c4a6a265 100644 --- a/tests/lean/NoNestedBorrows.lean +++ b/tests/lean/NoNestedBorrows.lean @@ -60,6 +60,18 @@ def div_test1 (x : U32) : Result U32 := def rem_test (x : U32) (y : U32) : Result U32 := x % y +/- [no_nested_borrows::mul_test]: forward function -/ +def mul_test (x : U32) (y : U32) : Result U32 := + x * y + +/- [no_nested_borrows::CONST0] -/ +def const0_body : Result Usize := 1#usize + 1#usize +def const0_c : Usize := eval_global const0_body (by simp) + +/- [no_nested_borrows::CONST1] -/ +def const1_body : Result Usize := 2#usize * 2#usize +def const1_c : Usize := eval_global const1_body (by simp) + /- [no_nested_borrows::cast_test]: forward function -/ def cast_test (x : U32) : Result I32 := Scalar.cast .I32 x -- cgit v1.2.3 From eb9ff46c69b9a95c453d64eee059916130d59846 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 9 Nov 2023 11:22:39 +0100 Subject: Regenerate some Lean tests --- tests/lean/Traits/Funs.lean | 25 +++++++++++++++++++++++++ tests/lean/Traits/Types.lean | 14 ++++++++++++++ 2 files changed, 39 insertions(+) (limited to 'tests/lean') diff --git a/tests/lean/Traits/Funs.lean b/tests/lean/Traits/Funs.lean index 6a2834ff..8d423280 100644 --- a/tests/lean/Traits/Funs.lean +++ b/tests/lean/Traits/Funs.lean @@ -247,4 +247,29 @@ def map_option let t ← inst.call f0 x0 Result.ret (some t) +/- Trait implementation: [traits::u32::{11}] -/ +def u32.WithTargetInst : WithTarget U32 := { + Target := U32 +} + +/- Trait implementation: [traits::u32::{12}] -/ +def u32.ParentTrait2Inst : ParentTrait2 U32 := { + U := U32 + U_clause_0 := u32.WithTargetInst +} + +/- [traits::u32::{13}::convert]: forward function -/ +def u32.convert (x : U32) : Result U32 := + Result.ret x + +/- Trait implementation: [traits::u32::{13}] -/ +def u32.ChildTrait2Inst : ChildTrait2 U32 := { + parent_clause_0 := u32.ParentTrait2Inst + convert := u32.convert +} + +/- [traits::incr_u32]: forward function -/ +def incr_u32 (x : U32) : Result U32 := + x + 1#u32 + end traits diff --git a/tests/lean/Traits/Types.lean b/tests/lean/Traits/Types.lean index 20af9cb1..4c5dd874 100644 --- a/tests/lean/Traits/Types.lean +++ b/tests/lean/Traits/Types.lean @@ -127,4 +127,18 @@ structure core.ops.function.Fn (Self Args : Type) where parent_clause_0 : core.ops.function.FnMut Self Args call : Self → Args → Result parent_clause_0.parent_clause_0.Output +/- Trait declaration: [traits::WithTarget] -/ +structure WithTarget (Self : Type) where + Target : Type + +/- Trait declaration: [traits::ParentTrait2] -/ +structure ParentTrait2 (Self : Type) where + U : Type + U_clause_0 : WithTarget U + +/- Trait declaration: [traits::ChildTrait2] -/ +structure ChildTrait2 (Self : Type) where + parent_clause_0 : ParentTrait2 Self + convert : parent_clause_0.U → Result parent_clause_0.U_clause_0.Target + end traits -- cgit v1.2.3 From c57dec640d4e12c3dc66969d626bbbca2eb733fd Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 9 Nov 2023 11:43:47 +0100 Subject: Modify some options and update the Makefile --- tests/lean/Array.lean | 436 +++++++++++++++++++++++++++++- tests/lean/Loops.lean | 630 ++++++++++++++++++++++++++++++++++++++++++- tests/lean/Loops/Funs.lean | 625 ------------------------------------------ tests/lean/Loops/Types.lean | 13 - tests/lean/Traits.lean | 411 +++++++++++++++++++++++++++- tests/lean/Traits/Funs.lean | 275 ------------------- tests/lean/Traits/Types.lean | 144 ---------- 7 files changed, 1474 insertions(+), 1060 deletions(-) delete mode 100644 tests/lean/Loops/Funs.lean delete mode 100644 tests/lean/Loops/Types.lean delete mode 100644 tests/lean/Traits/Funs.lean delete mode 100644 tests/lean/Traits/Types.lean (limited to 'tests/lean') diff --git a/tests/lean/Array.lean b/tests/lean/Array.lean index 277b63d9..20f02e97 100644 --- a/tests/lean/Array.lean +++ b/tests/lean/Array.lean @@ -1 +1,435 @@ -import Array.Funs +-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS +-- [array] +import Base +open Primitives + +namespace array + +/- [array::AB] -/ +inductive AB := +| A : AB +| B : AB + +/- [array::incr]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) -/ +def incr (x : U32) : Result U32 := + x + 1#u32 + +/- [array::array_to_shared_slice_]: forward function -/ +def 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 -/ +def 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 -/ +def array_to_mut_slice__back + (T : Type) (s : Array T 32#usize) (ret0 : Slice T) : + Result (Array T 32#usize) + := + Array.from_slice T 32#usize s ret0 + +/- [array::array_len]: forward function -/ +def array_len (T : Type) (s : Array T 32#usize) : Result Usize := + do + let s0 ← Array.to_slice T 32#usize s + let i := Slice.len T s0 + Result.ret i + +/- [array::shared_array_len]: forward function -/ +def shared_array_len (T : Type) (s : Array T 32#usize) : Result Usize := + do + let s0 ← Array.to_slice T 32#usize s + let i := Slice.len T s0 + Result.ret i + +/- [array::shared_slice_len]: forward function -/ +def shared_slice_len (T : Type) (s : Slice T) : Result Usize := + let i := Slice.len T s + Result.ret i + +/- [array::index_array_shared]: forward function -/ +def 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 -/ +def 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 -/ +def 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 -/ +def 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 -/ +def index_mut_array_back + (T : Type) (s : Array T 32#usize) (i : Usize) (ret0 : T) : + Result (Array T 32#usize) + := + Array.update_usize T 32#usize s i ret0 + +/- [array::index_slice]: forward function -/ +def index_slice (T : Type) (s : Slice T) (i : Usize) : Result T := + Slice.index_usize T s i + +/- [array::index_mut_slice]: forward function -/ +def 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 -/ +def index_mut_slice_back + (T : Type) (s : Slice T) (i : Usize) (ret0 : T) : Result (Slice T) := + Slice.update_usize T s i ret0 + +/- [array::slice_subslice_shared_]: forward function -/ +def slice_subslice_shared_ + (x : Slice U32) (y : Usize) (z : Usize) : Result (Slice U32) := + core.slice.index.Slice.index U32 (core.ops.range.Range Usize) + (core.slice.index.Range.coresliceindexSliceIndexInst U32) x + { start := y, end_ := z } + +/- [array::slice_subslice_mut_]: forward function -/ +def 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.Range.coresliceindexSliceIndexInst U32) x + { start := y, end_ := z } + +/- [array::slice_subslice_mut_]: backward function 0 -/ +def slice_subslice_mut__back + (x : Slice U32) (y : Usize) (z : Usize) (ret0 : Slice U32) : + Result (Slice U32) + := + core.slice.index.Slice.index_mut_back U32 (core.ops.range.Range Usize) + (core.slice.index.Range.coresliceindexSliceIndexInst U32) x + { start := y, end_ := z } ret0 + +/- [array::array_to_slice_shared_]: forward function -/ +def 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 -/ +def 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 -/ +def array_to_slice_mut__back + (x : Array U32 32#usize) (ret0 : Slice U32) : Result (Array U32 32#usize) := + Array.from_slice U32 32#usize x ret0 + +/- [array::array_subslice_shared_]: forward function -/ +def array_subslice_shared_ + (x : Array U32 32#usize) (y : Usize) (z : Usize) : Result (Slice U32) := + core.array.Array.index U32 (core.ops.range.Range Usize) 32#usize + (core.slice.index.Slice.coreopsindexIndexInst U32 (core.ops.range.Range + Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + { start := y, end_ := z } + +/- [array::array_subslice_mut_]: forward function -/ +def 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.slice.index.Slice.coreopsindexIndexMutInst U32 (core.ops.range.Range + Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + { start := y, end_ := z } + +/- [array::array_subslice_mut_]: backward function 0 -/ +def array_subslice_mut__back + (x : Array U32 32#usize) (y : Usize) (z : Usize) (ret0 : Slice U32) : + Result (Array U32 32#usize) + := + core.array.Array.index_mut_back U32 (core.ops.range.Range Usize) 32#usize + (core.slice.index.Slice.coreopsindexIndexMutInst U32 (core.ops.range.Range + Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + { start := y, end_ := z } ret0 + +/- [array::index_slice_0]: forward function -/ +def index_slice_0 (T : Type) (s : Slice T) : Result T := + Slice.index_usize T s 0#usize + +/- [array::index_array_0]: forward function -/ +def 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 -/ +def index_index_array + (s : Array (Array U32 32#usize) 32#usize) (i : Usize) (j : Usize) : + Result U32 + := + do + let a ← Array.index_usize (Array U32 32#usize) 32#usize s i + Array.index_usize U32 32#usize a j + +/- [array::update_update_array]: forward function -/ +def update_update_array + (s : Array (Array U32 32#usize) 32#usize) (i : Usize) (j : Usize) : + Result Unit + := + do + let a ← Array.index_usize (Array U32 32#usize) 32#usize s i + let a0 ← Array.update_usize U32 32#usize a j 0#u32 + let _ ← Array.update_usize (Array U32 32#usize) 32#usize s i a0 + Result.ret () + +/- [array::array_local_deep_copy]: forward function -/ +def array_local_deep_copy (x : Array U32 32#usize) : Result Unit := + Result.ret () + +/- [array::take_array]: forward function -/ +def take_array (a : Array U32 2#usize) : Result Unit := + Result.ret () + +/- [array::take_array_borrow]: forward function -/ +def take_array_borrow (a : Array U32 2#usize) : Result Unit := + Result.ret () + +/- [array::take_slice]: forward function -/ +def take_slice (s : Slice U32) : Result Unit := + Result.ret () + +/- [array::take_mut_slice]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) -/ +def take_mut_slice (s : Slice U32) : Result (Slice U32) := + Result.ret s + +/- [array::take_all]: forward function -/ +def take_all : Result Unit := + do + let _ ← take_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let _ ← take_array_borrow (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let s ← + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let _ ← take_slice s + let s0 ← + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let s1 ← take_mut_slice s0 + let _ ← + Array.from_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s1 + Result.ret () + +/- [array::index_array]: forward function -/ +def index_array (x : Array U32 2#usize) : Result U32 := + Array.index_usize U32 2#usize x 0#usize + +/- [array::index_array_borrow]: forward function -/ +def 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 -/ +def index_slice_u32_0 (x : Slice U32) : Result U32 := + Slice.index_usize U32 x 0#usize + +/- [array::index_mut_slice_u32_0]: forward function -/ +def index_mut_slice_u32_0 (x : Slice U32) : Result U32 := + Slice.index_usize U32 x 0#usize + +/- [array::index_mut_slice_u32_0]: backward function 0 -/ +def index_mut_slice_u32_0_back (x : Slice U32) : Result (Slice U32) := + do + let _ ← Slice.index_usize U32 x 0#usize + Result.ret x + +/- [array::index_all]: forward function -/ +def index_all : Result U32 := + do + let i ← index_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let i0 ← index_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let i1 ← i + i0 + let i2 ← index_array_borrow (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let i3 ← i1 + i2 + let s ← + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let i4 ← index_slice_u32_0 s + let i5 ← i3 + i4 + let s0 ← + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let i6 ← index_mut_slice_u32_0 s0 + let i7 ← i5 + i6 + let s1 ← index_mut_slice_u32_0_back s0 + let _ ← + Array.from_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s1 + Result.ret i7 + +/- [array::update_array]: forward function -/ +def update_array (x : Array U32 2#usize) : Result Unit := + do + let _ ← Array.update_usize U32 2#usize x 0#usize 1#u32 + Result.ret () + +/- [array::update_array_mut_borrow]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) -/ +def 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 + +/- [array::update_mut_slice]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) -/ +def update_mut_slice (x : Slice U32) : Result (Slice U32) := + Slice.update_usize U32 x 0#usize 1#u32 + +/- [array::update_all]: forward function -/ +def update_all : Result Unit := + do + let _ ← update_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let x ← update_array_mut_borrow (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let s ← Array.to_slice U32 2#usize x + let s0 ← update_mut_slice s + let _ ← Array.from_slice U32 2#usize x s0 + Result.ret () + +/- [array::range_all]: forward function -/ +def range_all : Result Unit := + do + let s ← + core.array.Array.index_mut U32 (core.ops.range.Range Usize) 4#usize + (core.slice.index.Slice.coreopsindexIndexMutInst U32 + (core.ops.range.Range Usize) + (core.slice.index.Range.coresliceindexSliceIndexInst U32)) + (Array.make U32 4#usize [ 0#u32, 0#u32, 0#u32, 0#u32 ]) + { start := 1#usize, end_ := 3#usize } + let s0 ← update_mut_slice s + let _ ← + core.array.Array.index_mut_back U32 (core.ops.range.Range Usize) 4#usize + (core.slice.index.Slice.coreopsindexIndexMutInst U32 + (core.ops.range.Range Usize) + (core.slice.index.Range.coresliceindexSliceIndexInst U32)) + (Array.make U32 4#usize [ 0#u32, 0#u32, 0#u32, 0#u32 ]) + { start := 1#usize, end_ := 3#usize } s0 + Result.ret () + +/- [array::deref_array_borrow]: forward function -/ +def 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 -/ +def 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 -/ +def deref_array_mut_borrow_back + (x : Array U32 2#usize) : Result (Array U32 2#usize) := + do + let _ ← Array.index_usize U32 2#usize x 0#usize + Result.ret x + +/- [array::take_array_t]: forward function -/ +def take_array_t (a : Array AB 2#usize) : Result Unit := + Result.ret () + +/- [array::non_copyable_array]: forward function -/ +def non_copyable_array : Result Unit := + do + let _ ← take_array_t (Array.make AB 2#usize [ AB.A, AB.B ]) + Result.ret () + +/- [array::sum]: loop 0: forward function -/ +divergent def sum_loop (s : Slice U32) (sum0 : U32) (i : Usize) : Result U32 := + let i0 := Slice.len U32 s + if i < i0 + then + do + let i1 ← Slice.index_usize U32 s i + let sum1 ← sum0 + i1 + let i2 ← i + 1#usize + sum_loop s sum1 i2 + else Result.ret sum0 + +/- [array::sum]: forward function -/ +def sum (s : Slice U32) : Result U32 := + sum_loop s 0#u32 0#usize + +/- [array::sum2]: loop 0: forward function -/ +divergent def sum2_loop + (s : Slice U32) (s2 : Slice U32) (sum0 : U32) (i : Usize) : Result U32 := + let i0 := Slice.len U32 s + if i < i0 + then + do + let i1 ← Slice.index_usize U32 s i + let i2 ← Slice.index_usize U32 s2 i + let i3 ← i1 + i2 + let sum1 ← sum0 + i3 + let i4 ← i + 1#usize + sum2_loop s s2 sum1 i4 + else Result.ret sum0 + +/- [array::sum2]: forward function -/ +def sum2 (s : Slice U32) (s2 : Slice U32) : Result U32 := + let i := Slice.len U32 s + let i0 := Slice.len U32 s2 + if not (i = i0) + then Result.fail Error.panic + else sum2_loop s s2 0#u32 0#usize + +/- [array::f0]: forward function -/ +def f0 : Result Unit := + do + let s ← + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) + let s0 ← Slice.update_usize U32 s 0#usize 1#u32 + let _ ← + Array.from_slice U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) s0 + Result.ret () + +/- [array::f1]: forward function -/ +def f1 : Result Unit := + do + let _ ← + Array.update_usize U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) + 0#usize 1#u32 + Result.ret () + +/- [array::f2]: forward function -/ +def f2 (i : U32) : Result Unit := + Result.ret () + +/- [array::f4]: forward function -/ +def f4 (x : Array U32 32#usize) (y : Usize) (z : Usize) : Result (Slice U32) := + core.array.Array.index U32 (core.ops.range.Range Usize) 32#usize + (core.slice.index.Slice.coreopsindexIndexInst U32 (core.ops.range.Range + Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + { start := y, end_ := z } + +/- [array::f3]: forward function -/ +def f3 : Result U32 := + do + let i ← + Array.index_usize U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) + 0#usize + let _ ← f2 i + let b := Array.repeat U32 32#usize 0#u32 + let s ← + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) + let s0 ← f4 b 16#usize 18#usize + sum2 s s0 + +/- [array::SZ] -/ +def sz_body : Result Usize := Result.ret 32#usize +def sz_c : Usize := eval_global sz_body (by simp) + +/- [array::f5]: forward function -/ +def f5 (x : Array U32 32#usize) : Result U32 := + Array.index_usize U32 32#usize x 0#usize + +/- [array::ite]: forward function -/ +def ite : Result Unit := + do + let s ← + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let s0 ← + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + let s1 ← index_mut_slice_u32_0_back s0 + let _ ← + Array.from_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s1 + let s2 ← index_mut_slice_u32_0_back s + let _ ← + Array.from_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s2 + Result.ret () + +end array diff --git a/tests/lean/Loops.lean b/tests/lean/Loops.lean index 60c73776..c6360338 100644 --- a/tests/lean/Loops.lean +++ b/tests/lean/Loops.lean @@ -1 +1,629 @@ -import Loops.Funs +-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS +-- [loops] +import Base +open Primitives + +namespace loops + +/- [loops::sum]: loop 0: forward function -/ +divergent def sum_loop (max : U32) (i : U32) (s : U32) : Result U32 := + if i < max + then do + let s0 ← s + i + let i0 ← i + 1#u32 + sum_loop max i0 s0 + else s * 2#u32 + +/- [loops::sum]: forward function -/ +def sum (max : U32) : Result U32 := + sum_loop max 0#u32 0#u32 + +/- [loops::sum_with_mut_borrows]: loop 0: forward function -/ +divergent def sum_with_mut_borrows_loop + (max : U32) (mi : U32) (ms : U32) : Result U32 := + if mi < max + then + do + let ms0 ← ms + mi + let mi0 ← mi + 1#u32 + sum_with_mut_borrows_loop max mi0 ms0 + else ms * 2#u32 + +/- [loops::sum_with_mut_borrows]: forward function -/ +def sum_with_mut_borrows (max : U32) : Result U32 := + sum_with_mut_borrows_loop max 0#u32 0#u32 + +/- [loops::sum_with_shared_borrows]: loop 0: forward function -/ +divergent def sum_with_shared_borrows_loop + (max : U32) (i : U32) (s : U32) : Result U32 := + if i < max + then + do + let i0 ← i + 1#u32 + let s0 ← s + i0 + sum_with_shared_borrows_loop max i0 s0 + else s * 2#u32 + +/- [loops::sum_with_shared_borrows]: forward function -/ +def sum_with_shared_borrows (max : U32) : Result U32 := + sum_with_shared_borrows_loop max 0#u32 0#u32 + +/- [loops::clear]: loop 0: merged forward/backward function + (there is a single backward function, and the forward function returns ()) -/ +divergent def clear_loop + (v : alloc.vec.Vec U32) (i : Usize) : Result (alloc.vec.Vec U32) := + let i0 := alloc.vec.Vec.len U32 v + if i < i0 + then + do + let i1 ← i + 1#usize + let v0 ← + alloc.vec.Vec.index_mut_back U32 Usize + (core.slice.index.usize.coresliceindexSliceIndexInst U32) v i 0#u32 + clear_loop v0 i1 + else Result.ret v + +/- [loops::clear]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) -/ +def clear (v : alloc.vec.Vec U32) : Result (alloc.vec.Vec U32) := + clear_loop v 0#usize + +/- [loops::List] -/ +inductive List (T : Type) := +| Cons : T → List T → List T +| Nil : List T + +/- [loops::list_mem]: loop 0: forward function -/ +divergent def list_mem_loop (x : U32) (ls : List U32) : Result Bool := + match ls with + | List.Cons y tl => if y = x + then Result.ret true + else list_mem_loop x tl + | List.Nil => Result.ret false + +/- [loops::list_mem]: forward function -/ +def list_mem (x : U32) (ls : List U32) : Result Bool := + list_mem_loop x ls + +/- [loops::list_nth_mut_loop]: loop 0: forward function -/ +divergent def list_nth_mut_loop_loop + (T : Type) (ls : List T) (i : U32) : Result T := + match ls with + | List.Cons x tl => + if i = 0#u32 + then Result.ret x + else do + let i0 ← i - 1#u32 + list_nth_mut_loop_loop T tl i0 + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_mut_loop]: forward function -/ +def list_nth_mut_loop (T : Type) (ls : List T) (i : U32) : Result T := + list_nth_mut_loop_loop T ls i + +/- [loops::list_nth_mut_loop]: loop 0: backward function 0 -/ +divergent def list_nth_mut_loop_loop_back + (T : Type) (ls : List T) (i : U32) (ret0 : T) : Result (List T) := + match ls with + | List.Cons x tl => + if i = 0#u32 + then Result.ret (List.Cons ret0 tl) + else + do + let i0 ← i - 1#u32 + let tl0 ← list_nth_mut_loop_loop_back T tl i0 ret0 + Result.ret (List.Cons x tl0) + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_mut_loop]: backward function 0 -/ +def list_nth_mut_loop_back + (T : Type) (ls : List T) (i : U32) (ret0 : T) : Result (List T) := + list_nth_mut_loop_loop_back T ls i ret0 + +/- [loops::list_nth_shared_loop]: loop 0: forward function -/ +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.ret x + else do + let i0 ← i - 1#u32 + list_nth_shared_loop_loop T tl i0 + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_shared_loop]: forward function -/ +def list_nth_shared_loop (T : Type) (ls : List T) (i : U32) : Result T := + list_nth_shared_loop_loop T ls i + +/- [loops::get_elem_mut]: loop 0: forward function -/ +divergent def get_elem_mut_loop (x : Usize) (ls : List Usize) : Result Usize := + match ls with + | List.Cons y tl => if y = x + then Result.ret y + else get_elem_mut_loop x tl + | List.Nil => Result.fail Error.panic + +/- [loops::get_elem_mut]: forward function -/ +def get_elem_mut + (slots : alloc.vec.Vec (List Usize)) (x : Usize) : Result Usize := + do + let l ← + alloc.vec.Vec.index_mut (List Usize) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) + slots 0#usize + get_elem_mut_loop x l + +/- [loops::get_elem_mut]: loop 0: backward function 0 -/ +divergent def get_elem_mut_loop_back + (x : Usize) (ls : List Usize) (ret0 : Usize) : Result (List Usize) := + match ls with + | List.Cons y tl => + if y = x + then Result.ret (List.Cons ret0 tl) + else + do + let tl0 ← get_elem_mut_loop_back x tl ret0 + Result.ret (List.Cons y tl0) + | List.Nil => Result.fail Error.panic + +/- [loops::get_elem_mut]: backward function 0 -/ +def get_elem_mut_back + (slots : alloc.vec.Vec (List Usize)) (x : Usize) (ret0 : Usize) : + Result (alloc.vec.Vec (List Usize)) + := + do + let l ← + alloc.vec.Vec.index_mut (List Usize) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) + slots 0#usize + let l0 ← get_elem_mut_loop_back x l ret0 + alloc.vec.Vec.index_mut_back (List Usize) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) slots + 0#usize l0 + +/- [loops::get_elem_shared]: loop 0: forward function -/ +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.ret y + else get_elem_shared_loop x tl + | List.Nil => Result.fail Error.panic + +/- [loops::get_elem_shared]: forward function -/ +def get_elem_shared + (slots : alloc.vec.Vec (List Usize)) (x : Usize) : Result Usize := + do + let l ← + alloc.vec.Vec.index (List Usize) Usize + (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) + slots 0#usize + get_elem_shared_loop x l + +/- [loops::id_mut]: forward function -/ +def id_mut (T : Type) (ls : List T) : Result (List T) := + Result.ret ls + +/- [loops::id_mut]: backward function 0 -/ +def id_mut_back (T : Type) (ls : List T) (ret0 : List T) : Result (List T) := + Result.ret ret0 + +/- [loops::id_shared]: forward function -/ +def id_shared (T : Type) (ls : List T) : Result (List T) := + Result.ret ls + +/- [loops::list_nth_mut_loop_with_id]: loop 0: forward function -/ +divergent def list_nth_mut_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.ret x + else do + let i0 ← i - 1#u32 + list_nth_mut_loop_with_id_loop T i0 tl + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_mut_loop_with_id]: forward function -/ +def list_nth_mut_loop_with_id (T : Type) (ls : List T) (i : U32) : Result T := + do + let ls0 ← id_mut T ls + list_nth_mut_loop_with_id_loop T i ls0 + +/- [loops::list_nth_mut_loop_with_id]: loop 0: backward function 0 -/ +divergent def list_nth_mut_loop_with_id_loop_back + (T : Type) (i : U32) (ls : List T) (ret0 : T) : Result (List T) := + match ls with + | List.Cons x tl => + if i = 0#u32 + then Result.ret (List.Cons ret0 tl) + else + do + let i0 ← i - 1#u32 + let tl0 ← list_nth_mut_loop_with_id_loop_back T i0 tl ret0 + Result.ret (List.Cons x tl0) + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_mut_loop_with_id]: backward function 0 -/ +def list_nth_mut_loop_with_id_back + (T : Type) (ls : List T) (i : U32) (ret0 : T) : Result (List T) := + do + let ls0 ← id_mut T ls + let l ← list_nth_mut_loop_with_id_loop_back T i ls0 ret0 + id_mut_back T ls l + +/- [loops::list_nth_shared_loop_with_id]: loop 0: forward function -/ +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.ret x + else do + let i0 ← i - 1#u32 + list_nth_shared_loop_with_id_loop T i0 tl + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_shared_loop_with_id]: forward function -/ +def list_nth_shared_loop_with_id + (T : Type) (ls : List T) (i : U32) : Result T := + do + let ls0 ← id_shared T ls + list_nth_shared_loop_with_id_loop T i ls0 + +/- [loops::list_nth_mut_loop_pair]: loop 0: forward function -/ +divergent def list_nth_mut_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.ret (x0, x1) + else do + let i0 ← i - 1#u32 + list_nth_mut_loop_pair_loop T tl0 tl1 i0 + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_mut_loop_pair]: forward function -/ +def list_nth_mut_loop_pair + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := + list_nth_mut_loop_pair_loop T ls0 ls1 i + +/- [loops::list_nth_mut_loop_pair]: loop 0: backward function 0 -/ +divergent def list_nth_mut_loop_pair_loop_back'a + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + Result (List T) + := + match ls0 with + | List.Cons x0 tl0 => + match ls1 with + | List.Cons x1 tl1 => + if i = 0#u32 + then Result.ret (List.Cons ret0 tl0) + else + do + let i0 ← i - 1#u32 + let tl00 ← list_nth_mut_loop_pair_loop_back'a T tl0 tl1 i0 ret0 + Result.ret (List.Cons x0 tl00) + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_mut_loop_pair]: backward function 0 -/ +def list_nth_mut_loop_pair_back'a + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + Result (List T) + := + list_nth_mut_loop_pair_loop_back'a T ls0 ls1 i ret0 + +/- [loops::list_nth_mut_loop_pair]: loop 0: backward function 1 -/ +divergent def list_nth_mut_loop_pair_loop_back'b + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + Result (List T) + := + match ls0 with + | List.Cons x0 tl0 => + match ls1 with + | List.Cons x1 tl1 => + if i = 0#u32 + then Result.ret (List.Cons ret0 tl1) + else + do + let i0 ← i - 1#u32 + let tl10 ← list_nth_mut_loop_pair_loop_back'b T tl0 tl1 i0 ret0 + Result.ret (List.Cons x1 tl10) + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_mut_loop_pair]: backward function 1 -/ +def list_nth_mut_loop_pair_back'b + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + Result (List T) + := + list_nth_mut_loop_pair_loop_back'b T ls0 ls1 i ret0 + +/- [loops::list_nth_shared_loop_pair]: loop 0: forward function -/ +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.ret (x0, x1) + else do + let i0 ← i - 1#u32 + list_nth_shared_loop_pair_loop T tl0 tl1 i0 + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_shared_loop_pair]: forward function -/ +def list_nth_shared_loop_pair + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := + list_nth_shared_loop_pair_loop T ls0 ls1 i + +/- [loops::list_nth_mut_loop_pair_merge]: loop 0: forward function -/ +divergent def list_nth_mut_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.ret (x0, x1) + else + do + let i0 ← i - 1#u32 + list_nth_mut_loop_pair_merge_loop T tl0 tl1 i0 + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_mut_loop_pair_merge]: forward function -/ +def list_nth_mut_loop_pair_merge + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := + list_nth_mut_loop_pair_merge_loop T ls0 ls1 i + +/- [loops::list_nth_mut_loop_pair_merge]: loop 0: backward function 0 -/ +divergent def list_nth_mut_loop_pair_merge_loop_back + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : (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 (t, t0) := ret0 + Result.ret (List.Cons t tl0, List.Cons t0 tl1) + else + do + let i0 ← i - 1#u32 + let (tl00, tl10) ← + list_nth_mut_loop_pair_merge_loop_back T tl0 tl1 i0 ret0 + Result.ret (List.Cons x0 tl00, List.Cons x1 tl10) + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_mut_loop_pair_merge]: backward function 0 -/ +def list_nth_mut_loop_pair_merge_back + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : (T × T)) : + Result ((List T) × (List T)) + := + list_nth_mut_loop_pair_merge_loop_back T ls0 ls1 i ret0 + +/- [loops::list_nth_shared_loop_pair_merge]: loop 0: forward function -/ +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.ret (x0, x1) + else + do + let i0 ← i - 1#u32 + list_nth_shared_loop_pair_merge_loop T tl0 tl1 i0 + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_shared_loop_pair_merge]: forward function -/ +def list_nth_shared_loop_pair_merge + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := + list_nth_shared_loop_pair_merge_loop T ls0 ls1 i + +/- [loops::list_nth_mut_shared_loop_pair]: loop 0: forward function -/ +divergent def list_nth_mut_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.ret (x0, x1) + else + do + let i0 ← i - 1#u32 + list_nth_mut_shared_loop_pair_loop T tl0 tl1 i0 + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_mut_shared_loop_pair]: forward function -/ +def list_nth_mut_shared_loop_pair + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := + list_nth_mut_shared_loop_pair_loop T ls0 ls1 i + +/- [loops::list_nth_mut_shared_loop_pair]: loop 0: backward function 0 -/ +divergent def list_nth_mut_shared_loop_pair_loop_back + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + Result (List T) + := + match ls0 with + | List.Cons x0 tl0 => + match ls1 with + | List.Cons x1 tl1 => + if i = 0#u32 + then Result.ret (List.Cons ret0 tl0) + else + do + let i0 ← i - 1#u32 + let tl00 ← + list_nth_mut_shared_loop_pair_loop_back T tl0 tl1 i0 ret0 + Result.ret (List.Cons x0 tl00) + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_mut_shared_loop_pair]: backward function 0 -/ +def list_nth_mut_shared_loop_pair_back + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + Result (List T) + := + list_nth_mut_shared_loop_pair_loop_back T ls0 ls1 i ret0 + +/- [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: forward function -/ +divergent def list_nth_mut_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.ret (x0, x1) + else + do + let i0 ← i - 1#u32 + list_nth_mut_shared_loop_pair_merge_loop T tl0 tl1 i0 + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_mut_shared_loop_pair_merge]: forward function -/ +def list_nth_mut_shared_loop_pair_merge + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := + list_nth_mut_shared_loop_pair_merge_loop T ls0 ls1 i + +/- [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: backward function 0 -/ +divergent def list_nth_mut_shared_loop_pair_merge_loop_back + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + Result (List T) + := + match ls0 with + | List.Cons x0 tl0 => + match ls1 with + | List.Cons x1 tl1 => + if i = 0#u32 + then Result.ret (List.Cons ret0 tl0) + else + do + let i0 ← i - 1#u32 + let tl00 ← + list_nth_mut_shared_loop_pair_merge_loop_back T tl0 tl1 i0 ret0 + Result.ret (List.Cons x0 tl00) + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_mut_shared_loop_pair_merge]: backward function 0 -/ +def list_nth_mut_shared_loop_pair_merge_back + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + Result (List T) + := + list_nth_mut_shared_loop_pair_merge_loop_back T ls0 ls1 i ret0 + +/- [loops::list_nth_shared_mut_loop_pair]: loop 0: forward function -/ +divergent def list_nth_shared_mut_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.ret (x0, x1) + else + do + let i0 ← i - 1#u32 + list_nth_shared_mut_loop_pair_loop T tl0 tl1 i0 + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_shared_mut_loop_pair]: forward function -/ +def list_nth_shared_mut_loop_pair + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := + list_nth_shared_mut_loop_pair_loop T ls0 ls1 i + +/- [loops::list_nth_shared_mut_loop_pair]: loop 0: backward function 1 -/ +divergent def list_nth_shared_mut_loop_pair_loop_back + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + Result (List T) + := + match ls0 with + | List.Cons x0 tl0 => + match ls1 with + | List.Cons x1 tl1 => + if i = 0#u32 + then Result.ret (List.Cons ret0 tl1) + else + do + let i0 ← i - 1#u32 + let tl10 ← + list_nth_shared_mut_loop_pair_loop_back T tl0 tl1 i0 ret0 + Result.ret (List.Cons x1 tl10) + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_shared_mut_loop_pair]: backward function 1 -/ +def list_nth_shared_mut_loop_pair_back + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + Result (List T) + := + list_nth_shared_mut_loop_pair_loop_back T ls0 ls1 i ret0 + +/- [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: forward function -/ +divergent def list_nth_shared_mut_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.ret (x0, x1) + else + do + let i0 ← i - 1#u32 + list_nth_shared_mut_loop_pair_merge_loop T tl0 tl1 i0 + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_shared_mut_loop_pair_merge]: forward function -/ +def list_nth_shared_mut_loop_pair_merge + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := + list_nth_shared_mut_loop_pair_merge_loop T ls0 ls1 i + +/- [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: backward function 0 -/ +divergent def list_nth_shared_mut_loop_pair_merge_loop_back + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + Result (List T) + := + match ls0 with + | List.Cons x0 tl0 => + match ls1 with + | List.Cons x1 tl1 => + if i = 0#u32 + then Result.ret (List.Cons ret0 tl1) + else + do + let i0 ← i - 1#u32 + let tl10 ← + list_nth_shared_mut_loop_pair_merge_loop_back T tl0 tl1 i0 ret0 + Result.ret (List.Cons x1 tl10) + | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail Error.panic + +/- [loops::list_nth_shared_mut_loop_pair_merge]: backward function 0 -/ +def list_nth_shared_mut_loop_pair_merge_back + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + Result (List T) + := + list_nth_shared_mut_loop_pair_merge_loop_back T ls0 ls1 i ret0 + +end loops diff --git a/tests/lean/Loops/Funs.lean b/tests/lean/Loops/Funs.lean deleted file mode 100644 index f9c7569e..00000000 --- a/tests/lean/Loops/Funs.lean +++ /dev/null @@ -1,625 +0,0 @@ --- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS --- [loops]: function definitions -import Base -import Loops.Types -open Primitives - -namespace loops - -/- [loops::sum]: loop 0: forward function -/ -divergent def sum_loop (max : U32) (i : U32) (s : U32) : Result U32 := - if i < max - then do - let s0 ← s + i - let i0 ← i + 1#u32 - sum_loop max i0 s0 - else s * 2#u32 - -/- [loops::sum]: forward function -/ -def sum (max : U32) : Result U32 := - sum_loop max 0#u32 0#u32 - -/- [loops::sum_with_mut_borrows]: loop 0: forward function -/ -divergent def sum_with_mut_borrows_loop - (max : U32) (mi : U32) (ms : U32) : Result U32 := - if mi < max - then - do - let ms0 ← ms + mi - let mi0 ← mi + 1#u32 - sum_with_mut_borrows_loop max mi0 ms0 - else ms * 2#u32 - -/- [loops::sum_with_mut_borrows]: forward function -/ -def sum_with_mut_borrows (max : U32) : Result U32 := - sum_with_mut_borrows_loop max 0#u32 0#u32 - -/- [loops::sum_with_shared_borrows]: loop 0: forward function -/ -divergent def sum_with_shared_borrows_loop - (max : U32) (i : U32) (s : U32) : Result U32 := - if i < max - then - do - let i0 ← i + 1#u32 - let s0 ← s + i0 - sum_with_shared_borrows_loop max i0 s0 - else s * 2#u32 - -/- [loops::sum_with_shared_borrows]: forward function -/ -def sum_with_shared_borrows (max : U32) : Result U32 := - sum_with_shared_borrows_loop max 0#u32 0#u32 - -/- [loops::clear]: loop 0: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ -divergent def clear_loop - (v : alloc.vec.Vec U32) (i : Usize) : Result (alloc.vec.Vec U32) := - let i0 := alloc.vec.Vec.len U32 v - if i < i0 - then - do - let i1 ← i + 1#usize - let v0 ← - alloc.vec.Vec.index_mut_back U32 Usize - (core.slice.index.usize.coresliceindexSliceIndexInst U32) v i 0#u32 - clear_loop v0 i1 - else Result.ret v - -/- [loops::clear]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ -def clear (v : alloc.vec.Vec U32) : Result (alloc.vec.Vec U32) := - clear_loop v 0#usize - -/- [loops::list_mem]: loop 0: forward function -/ -divergent def list_mem_loop (x : U32) (ls : List U32) : Result Bool := - match ls with - | List.Cons y tl => if y = x - then Result.ret true - else list_mem_loop x tl - | List.Nil => Result.ret false - -/- [loops::list_mem]: forward function -/ -def list_mem (x : U32) (ls : List U32) : Result Bool := - list_mem_loop x ls - -/- [loops::list_nth_mut_loop]: loop 0: forward function -/ -divergent def list_nth_mut_loop_loop - (T : Type) (ls : List T) (i : U32) : Result T := - match ls with - | List.Cons x tl => - if i = 0#u32 - then Result.ret x - else do - let i0 ← i - 1#u32 - list_nth_mut_loop_loop T tl i0 - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_mut_loop]: forward function -/ -def list_nth_mut_loop (T : Type) (ls : List T) (i : U32) : Result T := - list_nth_mut_loop_loop T ls i - -/- [loops::list_nth_mut_loop]: loop 0: backward function 0 -/ -divergent def list_nth_mut_loop_loop_back - (T : Type) (ls : List T) (i : U32) (ret0 : T) : Result (List T) := - match ls with - | List.Cons x tl => - if i = 0#u32 - then Result.ret (List.Cons ret0 tl) - else - do - let i0 ← i - 1#u32 - let tl0 ← list_nth_mut_loop_loop_back T tl i0 ret0 - Result.ret (List.Cons x tl0) - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_mut_loop]: backward function 0 -/ -def list_nth_mut_loop_back - (T : Type) (ls : List T) (i : U32) (ret0 : T) : Result (List T) := - list_nth_mut_loop_loop_back T ls i ret0 - -/- [loops::list_nth_shared_loop]: loop 0: forward function -/ -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.ret x - else do - let i0 ← i - 1#u32 - list_nth_shared_loop_loop T tl i0 - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_shared_loop]: forward function -/ -def list_nth_shared_loop (T : Type) (ls : List T) (i : U32) : Result T := - list_nth_shared_loop_loop T ls i - -/- [loops::get_elem_mut]: loop 0: forward function -/ -divergent def get_elem_mut_loop (x : Usize) (ls : List Usize) : Result Usize := - match ls with - | List.Cons y tl => if y = x - then Result.ret y - else get_elem_mut_loop x tl - | List.Nil => Result.fail Error.panic - -/- [loops::get_elem_mut]: forward function -/ -def get_elem_mut - (slots : alloc.vec.Vec (List Usize)) (x : Usize) : Result Usize := - do - let l ← - alloc.vec.Vec.index_mut (List Usize) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) - slots 0#usize - get_elem_mut_loop x l - -/- [loops::get_elem_mut]: loop 0: backward function 0 -/ -divergent def get_elem_mut_loop_back - (x : Usize) (ls : List Usize) (ret0 : Usize) : Result (List Usize) := - match ls with - | List.Cons y tl => - if y = x - then Result.ret (List.Cons ret0 tl) - else - do - let tl0 ← get_elem_mut_loop_back x tl ret0 - Result.ret (List.Cons y tl0) - | List.Nil => Result.fail Error.panic - -/- [loops::get_elem_mut]: backward function 0 -/ -def get_elem_mut_back - (slots : alloc.vec.Vec (List Usize)) (x : Usize) (ret0 : Usize) : - Result (alloc.vec.Vec (List Usize)) - := - do - let l ← - alloc.vec.Vec.index_mut (List Usize) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) - slots 0#usize - let l0 ← get_elem_mut_loop_back x l ret0 - alloc.vec.Vec.index_mut_back (List Usize) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) slots - 0#usize l0 - -/- [loops::get_elem_shared]: loop 0: forward function -/ -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.ret y - else get_elem_shared_loop x tl - | List.Nil => Result.fail Error.panic - -/- [loops::get_elem_shared]: forward function -/ -def get_elem_shared - (slots : alloc.vec.Vec (List Usize)) (x : Usize) : Result Usize := - do - let l ← - alloc.vec.Vec.index (List Usize) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) - slots 0#usize - get_elem_shared_loop x l - -/- [loops::id_mut]: forward function -/ -def id_mut (T : Type) (ls : List T) : Result (List T) := - Result.ret ls - -/- [loops::id_mut]: backward function 0 -/ -def id_mut_back (T : Type) (ls : List T) (ret0 : List T) : Result (List T) := - Result.ret ret0 - -/- [loops::id_shared]: forward function -/ -def id_shared (T : Type) (ls : List T) : Result (List T) := - Result.ret ls - -/- [loops::list_nth_mut_loop_with_id]: loop 0: forward function -/ -divergent def list_nth_mut_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.ret x - else do - let i0 ← i - 1#u32 - list_nth_mut_loop_with_id_loop T i0 tl - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_mut_loop_with_id]: forward function -/ -def list_nth_mut_loop_with_id (T : Type) (ls : List T) (i : U32) : Result T := - do - let ls0 ← id_mut T ls - list_nth_mut_loop_with_id_loop T i ls0 - -/- [loops::list_nth_mut_loop_with_id]: loop 0: backward function 0 -/ -divergent def list_nth_mut_loop_with_id_loop_back - (T : Type) (i : U32) (ls : List T) (ret0 : T) : Result (List T) := - match ls with - | List.Cons x tl => - if i = 0#u32 - then Result.ret (List.Cons ret0 tl) - else - do - let i0 ← i - 1#u32 - let tl0 ← list_nth_mut_loop_with_id_loop_back T i0 tl ret0 - Result.ret (List.Cons x tl0) - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_mut_loop_with_id]: backward function 0 -/ -def list_nth_mut_loop_with_id_back - (T : Type) (ls : List T) (i : U32) (ret0 : T) : Result (List T) := - do - let ls0 ← id_mut T ls - let l ← list_nth_mut_loop_with_id_loop_back T i ls0 ret0 - id_mut_back T ls l - -/- [loops::list_nth_shared_loop_with_id]: loop 0: forward function -/ -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.ret x - else do - let i0 ← i - 1#u32 - list_nth_shared_loop_with_id_loop T i0 tl - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_shared_loop_with_id]: forward function -/ -def list_nth_shared_loop_with_id - (T : Type) (ls : List T) (i : U32) : Result T := - do - let ls0 ← id_shared T ls - list_nth_shared_loop_with_id_loop T i ls0 - -/- [loops::list_nth_mut_loop_pair]: loop 0: forward function -/ -divergent def list_nth_mut_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.ret (x0, x1) - else do - let i0 ← i - 1#u32 - list_nth_mut_loop_pair_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_mut_loop_pair]: forward function -/ -def list_nth_mut_loop_pair - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := - list_nth_mut_loop_pair_loop T ls0 ls1 i - -/- [loops::list_nth_mut_loop_pair]: loop 0: backward function 0 -/ -divergent def list_nth_mut_loop_pair_loop_back'a - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : - Result (List T) - := - match ls0 with - | List.Cons x0 tl0 => - match ls1 with - | List.Cons x1 tl1 => - if i = 0#u32 - then Result.ret (List.Cons ret0 tl0) - else - do - let i0 ← i - 1#u32 - let tl00 ← list_nth_mut_loop_pair_loop_back'a T tl0 tl1 i0 ret0 - Result.ret (List.Cons x0 tl00) - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_mut_loop_pair]: backward function 0 -/ -def list_nth_mut_loop_pair_back'a - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : - Result (List T) - := - list_nth_mut_loop_pair_loop_back'a T ls0 ls1 i ret0 - -/- [loops::list_nth_mut_loop_pair]: loop 0: backward function 1 -/ -divergent def list_nth_mut_loop_pair_loop_back'b - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : - Result (List T) - := - match ls0 with - | List.Cons x0 tl0 => - match ls1 with - | List.Cons x1 tl1 => - if i = 0#u32 - then Result.ret (List.Cons ret0 tl1) - else - do - let i0 ← i - 1#u32 - let tl10 ← list_nth_mut_loop_pair_loop_back'b T tl0 tl1 i0 ret0 - Result.ret (List.Cons x1 tl10) - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_mut_loop_pair]: backward function 1 -/ -def list_nth_mut_loop_pair_back'b - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : - Result (List T) - := - list_nth_mut_loop_pair_loop_back'b T ls0 ls1 i ret0 - -/- [loops::list_nth_shared_loop_pair]: loop 0: forward function -/ -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.ret (x0, x1) - else do - let i0 ← i - 1#u32 - list_nth_shared_loop_pair_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_shared_loop_pair]: forward function -/ -def list_nth_shared_loop_pair - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := - list_nth_shared_loop_pair_loop T ls0 ls1 i - -/- [loops::list_nth_mut_loop_pair_merge]: loop 0: forward function -/ -divergent def list_nth_mut_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.ret (x0, x1) - else - do - let i0 ← i - 1#u32 - list_nth_mut_loop_pair_merge_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_mut_loop_pair_merge]: forward function -/ -def list_nth_mut_loop_pair_merge - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := - list_nth_mut_loop_pair_merge_loop T ls0 ls1 i - -/- [loops::list_nth_mut_loop_pair_merge]: loop 0: backward function 0 -/ -divergent def list_nth_mut_loop_pair_merge_loop_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : (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 (t, t0) := ret0 - Result.ret (List.Cons t tl0, List.Cons t0 tl1) - else - do - let i0 ← i - 1#u32 - let (tl00, tl10) ← - list_nth_mut_loop_pair_merge_loop_back T tl0 tl1 i0 ret0 - Result.ret (List.Cons x0 tl00, List.Cons x1 tl10) - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_mut_loop_pair_merge]: backward function 0 -/ -def list_nth_mut_loop_pair_merge_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : (T × T)) : - Result ((List T) × (List T)) - := - list_nth_mut_loop_pair_merge_loop_back T ls0 ls1 i ret0 - -/- [loops::list_nth_shared_loop_pair_merge]: loop 0: forward function -/ -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.ret (x0, x1) - else - do - let i0 ← i - 1#u32 - list_nth_shared_loop_pair_merge_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_shared_loop_pair_merge]: forward function -/ -def list_nth_shared_loop_pair_merge - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := - list_nth_shared_loop_pair_merge_loop T ls0 ls1 i - -/- [loops::list_nth_mut_shared_loop_pair]: loop 0: forward function -/ -divergent def list_nth_mut_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.ret (x0, x1) - else - do - let i0 ← i - 1#u32 - list_nth_mut_shared_loop_pair_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_mut_shared_loop_pair]: forward function -/ -def list_nth_mut_shared_loop_pair - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := - list_nth_mut_shared_loop_pair_loop T ls0 ls1 i - -/- [loops::list_nth_mut_shared_loop_pair]: loop 0: backward function 0 -/ -divergent def list_nth_mut_shared_loop_pair_loop_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : - Result (List T) - := - match ls0 with - | List.Cons x0 tl0 => - match ls1 with - | List.Cons x1 tl1 => - if i = 0#u32 - then Result.ret (List.Cons ret0 tl0) - else - do - let i0 ← i - 1#u32 - let tl00 ← - list_nth_mut_shared_loop_pair_loop_back T tl0 tl1 i0 ret0 - Result.ret (List.Cons x0 tl00) - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_mut_shared_loop_pair]: backward function 0 -/ -def list_nth_mut_shared_loop_pair_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : - Result (List T) - := - list_nth_mut_shared_loop_pair_loop_back T ls0 ls1 i ret0 - -/- [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: forward function -/ -divergent def list_nth_mut_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.ret (x0, x1) - else - do - let i0 ← i - 1#u32 - list_nth_mut_shared_loop_pair_merge_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_mut_shared_loop_pair_merge]: forward function -/ -def list_nth_mut_shared_loop_pair_merge - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := - list_nth_mut_shared_loop_pair_merge_loop T ls0 ls1 i - -/- [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: backward function 0 -/ -divergent def list_nth_mut_shared_loop_pair_merge_loop_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : - Result (List T) - := - match ls0 with - | List.Cons x0 tl0 => - match ls1 with - | List.Cons x1 tl1 => - if i = 0#u32 - then Result.ret (List.Cons ret0 tl0) - else - do - let i0 ← i - 1#u32 - let tl00 ← - list_nth_mut_shared_loop_pair_merge_loop_back T tl0 tl1 i0 ret0 - Result.ret (List.Cons x0 tl00) - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_mut_shared_loop_pair_merge]: backward function 0 -/ -def list_nth_mut_shared_loop_pair_merge_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : - Result (List T) - := - list_nth_mut_shared_loop_pair_merge_loop_back T ls0 ls1 i ret0 - -/- [loops::list_nth_shared_mut_loop_pair]: loop 0: forward function -/ -divergent def list_nth_shared_mut_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.ret (x0, x1) - else - do - let i0 ← i - 1#u32 - list_nth_shared_mut_loop_pair_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_shared_mut_loop_pair]: forward function -/ -def list_nth_shared_mut_loop_pair - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := - list_nth_shared_mut_loop_pair_loop T ls0 ls1 i - -/- [loops::list_nth_shared_mut_loop_pair]: loop 0: backward function 1 -/ -divergent def list_nth_shared_mut_loop_pair_loop_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : - Result (List T) - := - match ls0 with - | List.Cons x0 tl0 => - match ls1 with - | List.Cons x1 tl1 => - if i = 0#u32 - then Result.ret (List.Cons ret0 tl1) - else - do - let i0 ← i - 1#u32 - let tl10 ← - list_nth_shared_mut_loop_pair_loop_back T tl0 tl1 i0 ret0 - Result.ret (List.Cons x1 tl10) - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_shared_mut_loop_pair]: backward function 1 -/ -def list_nth_shared_mut_loop_pair_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : - Result (List T) - := - list_nth_shared_mut_loop_pair_loop_back T ls0 ls1 i ret0 - -/- [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: forward function -/ -divergent def list_nth_shared_mut_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.ret (x0, x1) - else - do - let i0 ← i - 1#u32 - list_nth_shared_mut_loop_pair_merge_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_shared_mut_loop_pair_merge]: forward function -/ -def list_nth_shared_mut_loop_pair_merge - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := - list_nth_shared_mut_loop_pair_merge_loop T ls0 ls1 i - -/- [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: backward function 0 -/ -divergent def list_nth_shared_mut_loop_pair_merge_loop_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : - Result (List T) - := - match ls0 with - | List.Cons x0 tl0 => - match ls1 with - | List.Cons x1 tl1 => - if i = 0#u32 - then Result.ret (List.Cons ret0 tl1) - else - do - let i0 ← i - 1#u32 - let tl10 ← - list_nth_shared_mut_loop_pair_merge_loop_back T tl0 tl1 i0 ret0 - Result.ret (List.Cons x1 tl10) - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic - -/- [loops::list_nth_shared_mut_loop_pair_merge]: backward function 0 -/ -def list_nth_shared_mut_loop_pair_merge_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : - Result (List T) - := - list_nth_shared_mut_loop_pair_merge_loop_back T ls0 ls1 i ret0 - -end loops diff --git a/tests/lean/Loops/Types.lean b/tests/lean/Loops/Types.lean deleted file mode 100644 index 018af901..00000000 --- a/tests/lean/Loops/Types.lean +++ /dev/null @@ -1,13 +0,0 @@ --- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS --- [loops]: type definitions -import Base -open Primitives - -namespace loops - -/- [loops::List] -/ -inductive List (T : Type) := -| Cons : T → List T → List T -| Nil : List T - -end loops diff --git a/tests/lean/Traits.lean b/tests/lean/Traits.lean index 5e812e95..94ae0bb0 100644 --- a/tests/lean/Traits.lean +++ b/tests/lean/Traits.lean @@ -1 +1,410 @@ -import Traits.Funs +-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS +-- [traits] +import Base +open Primitives + +namespace traits + +/- Trait declaration: [traits::BoolTrait] -/ +structure BoolTrait (Self : Type) where + get_bool : Self → Result Bool + +/- [traits::Bool::{0}::get_bool]: forward function -/ +def Bool.get_bool (self : Bool) : Result Bool := + Result.ret self + +/- Trait implementation: [traits::Bool::{0}] -/ +def Bool.BoolTraitInst : BoolTrait Bool := { + get_bool := Bool.get_bool +} + +/- [traits::BoolTrait::ret_true]: forward function -/ +def BoolTrait.ret_true + {Self : Type} (self_clause : BoolTrait Self) (self : Self) : Result Bool := + Result.ret true + +/- [traits::test_bool_trait_bool]: forward function -/ +def test_bool_trait_bool (x : Bool) : Result Bool := + do + let b ← Bool.get_bool x + if b + then BoolTrait.ret_true Bool.BoolTraitInst x + else Result.ret false + +/- [traits::Option::{1}::get_bool]: forward function -/ +def Option.get_bool (T : Type) (self : Option T) : Result Bool := + match self with + | none => Result.ret false + | some t => Result.ret true + +/- Trait implementation: [traits::Option::{1}] -/ +def Option.BoolTraitInst (T : Type) : BoolTrait (Option T) := { + get_bool := Option.get_bool T +} + +/- [traits::test_bool_trait_option]: forward function -/ +def test_bool_trait_option (T : Type) (x : Option T) : Result Bool := + do + let b ← Option.get_bool T x + if b + then BoolTrait.ret_true (Option.BoolTraitInst T) x + else Result.ret false + +/- [traits::test_bool_trait]: forward function -/ +def test_bool_trait (T : Type) (inst : BoolTrait T) (x : T) : Result Bool := + inst.get_bool x + +/- Trait declaration: [traits::ToU64] -/ +structure ToU64 (Self : Type) where + to_u64 : Self → Result U64 + +/- [traits::u64::{2}::to_u64]: forward function -/ +def u64.to_u64 (self : U64) : Result U64 := + Result.ret self + +/- Trait implementation: [traits::u64::{2}] -/ +def u64.ToU64Inst : ToU64 U64 := { + to_u64 := u64.to_u64 +} + +/- [traits::Tuple2::{3}::to_u64]: forward function -/ +def Tuple2.to_u64 (A : Type) (inst : ToU64 A) (self : (A × A)) : Result U64 := + do + let (t, t0) := self + let i ← inst.to_u64 t + let i0 ← inst.to_u64 t0 + i + i0 + +/- Trait implementation: [traits::Tuple2::{3}] -/ +def Tuple2.ToU64Inst (A : Type) (inst : ToU64 A) : ToU64 (A × A) := { + to_u64 := Tuple2.to_u64 A inst +} + +/- [traits::f]: forward function -/ +def f (T : Type) (inst : ToU64 T) (x : (T × T)) : Result U64 := + Tuple2.to_u64 T inst x + +/- [traits::g]: forward function -/ +def g (T : Type) (inst : ToU64 (T × T)) (x : (T × T)) : Result U64 := + inst.to_u64 x + +/- [traits::h0]: forward function -/ +def h0 (x : U64) : Result U64 := + u64.to_u64 x + +/- [traits::Wrapper] -/ +structure Wrapper (T : Type) where + x : T + +/- [traits::Wrapper::{4}::to_u64]: forward function -/ +def Wrapper.to_u64 + (T : Type) (inst : ToU64 T) (self : Wrapper T) : Result U64 := + inst.to_u64 self.x + +/- Trait implementation: [traits::Wrapper::{4}] -/ +def Wrapper.ToU64Inst (T : Type) (inst : ToU64 T) : ToU64 (Wrapper T) := { + to_u64 := Wrapper.to_u64 T inst +} + +/- [traits::h1]: forward function -/ +def h1 (x : Wrapper U64) : Result U64 := + Wrapper.to_u64 U64 u64.ToU64Inst x + +/- [traits::h2]: forward function -/ +def h2 (T : Type) (inst : ToU64 T) (x : Wrapper T) : Result U64 := + Wrapper.to_u64 T inst x + +/- Trait declaration: [traits::ToType] -/ +structure ToType (Self T : Type) where + to_type : Self → Result T + +/- [traits::u64::{5}::to_type]: forward function -/ +def u64.to_type (self : U64) : Result Bool := + Result.ret (self > 0#u64) + +/- Trait implementation: [traits::u64::{5}] -/ +def u64.ToTypeInst : ToType U64 Bool := { + to_type := u64.to_type +} + +/- Trait declaration: [traits::OfType] -/ +structure OfType (Self : Type) where + of_type : forall (T : Type) (inst : ToType T Self), T → Result Self + +/- [traits::h3]: forward function -/ +def h3 + (T1 T2 : Type) (inst : OfType T1) (inst0 : ToType T2 T1) (y : T2) : + Result T1 + := + inst.of_type T2 inst0 y + +/- Trait declaration: [traits::OfTypeBis] -/ +structure OfTypeBis (Self T : Type) where + parent_clause_0 : ToType T Self + of_type : T → Result Self + +/- [traits::h4]: forward function -/ +def h4 + (T1 T2 : Type) (inst : OfTypeBis T1 T2) (inst0 : ToType T2 T1) (y : T2) : + Result T1 + := + inst.of_type y + +/- [traits::TestType] -/ +structure TestType (T : Type) where + _0 : T + +/- [traits::TestType::{6}::test::TestType1] -/ +structure TestType.test.TestType1 where + _0 : U64 + +/- Trait declaration: [traits::TestType::{6}::test::TestTrait] -/ +structure TestType.test.TestTrait (Self : Type) where + test : Self → Result Bool + +/- [traits::TestType::{6}::test::TestType1::{0}::test]: forward function -/ +def TestType.test.TestType1.test + (self : TestType.test.TestType1) : Result Bool := + Result.ret (self._0 > 1#u64) + +/- Trait implementation: [traits::TestType::{6}::test::TestType1::{0}] -/ +def TestType.test.TestType1.TestTypetestTestTraitInst : TestType.test.TestTrait + TestType.test.TestType1 := { + test := TestType.test.TestType1.test +} + +/- [traits::TestType::{6}::test]: forward function -/ +def TestType.test + (T : Type) (inst : ToU64 T) (self : TestType T) (x : T) : Result Bool := + do + let x0 ← inst.to_u64 x + if x0 > 0#u64 + then TestType.test.TestType1.test { _0 := 0#u64 } + else Result.ret false + +/- [traits::BoolWrapper] -/ +structure BoolWrapper where + _0 : Bool + +/- [traits::BoolWrapper::{7}::to_type]: forward function -/ +def BoolWrapper.to_type + (T : Type) (inst : ToType Bool T) (self : BoolWrapper) : Result T := + inst.to_type self._0 + +/- Trait implementation: [traits::BoolWrapper::{7}] -/ +def BoolWrapper.ToTypeInst (T : Type) (inst : ToType Bool T) : ToType + BoolWrapper T := { + to_type := BoolWrapper.to_type T inst +} + +/- [traits::WithConstTy::LEN2] -/ +def with_const_ty_len2_body : Result Usize := Result.ret 32#usize +def with_const_ty_len2_c : Usize := + eval_global with_const_ty_len2_body (by simp) + +/- Trait declaration: [traits::WithConstTy] -/ +structure WithConstTy (Self : Type) (LEN : Usize) where + LEN1 : Usize + LEN2 : Usize + V : Type + W : Type + W_clause_0 : ToU64 W + f : W → Array U8 LEN → Result W + +/- [traits::Bool::{8}::LEN1] -/ +def bool_len1_body : Result Usize := Result.ret 12#usize +def bool_len1_c : Usize := eval_global bool_len1_body (by simp) + +/- [traits::Bool::{8}::f]: merged forward/backward function + (there is a single backward function, and the forward function returns ()) -/ +def Bool.f (i : U64) (a : Array U8 32#usize) : Result U64 := + Result.ret i + +/- Trait implementation: [traits::Bool::{8}] -/ +def Bool.WithConstTyInst : WithConstTy Bool 32#usize := { + LEN1 := bool_len1_c + LEN2 := with_const_ty_len2_c + V := U8 + W := U64 + W_clause_0 := u64.ToU64Inst + f := Bool.f +} + +/- [traits::use_with_const_ty1]: forward function -/ +def use_with_const_ty1 + (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) : Result Usize := + let i := inst.LEN1 + Result.ret i + +/- [traits::use_with_const_ty2]: forward function -/ +def use_with_const_ty2 + (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) (w : inst.W) : + Result Unit + := + Result.ret () + +/- [traits::use_with_const_ty3]: forward function -/ +def use_with_const_ty3 + (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) (x : inst.W) : + Result U64 + := + inst.W_clause_0.to_u64 x + +/- [traits::test_where1]: forward function -/ +def test_where1 (T : Type) (_x : T) : Result Unit := + Result.ret () + +/- [traits::test_where2]: forward function -/ +def test_where2 + (T : Type) (inst : WithConstTy T 32#usize) (_x : U32) : Result Unit := + Result.ret () + +/- [alloc::string::String] -/ +axiom alloc.string.String : Type + +/- Trait declaration: [traits::ParentTrait0] -/ +structure ParentTrait0 (Self : Type) where + W : Type + get_name : Self → Result alloc.string.String + get_w : Self → Result W + +/- Trait declaration: [traits::ParentTrait1] -/ +structure ParentTrait1 (Self : Type) where + +/- Trait declaration: [traits::ChildTrait] -/ +structure ChildTrait (Self : Type) where + parent_clause_0 : ParentTrait0 Self + parent_clause_1 : ParentTrait1 Self + +/- [traits::test_child_trait1]: forward function -/ +def test_child_trait1 + (T : Type) (inst : ChildTrait T) (x : T) : Result alloc.string.String := + inst.parent_clause_0.get_name x + +/- [traits::test_child_trait2]: forward function -/ +def test_child_trait2 + (T : Type) (inst : ChildTrait T) (x : T) : Result inst.parent_clause_0.W := + inst.parent_clause_0.get_w x + +/- [traits::order1]: forward function -/ +def order1 + (T U : Type) (inst : ParentTrait0 T) (inst0 : ParentTrait0 U) : + Result Unit + := + Result.ret () + +/- Trait declaration: [traits::ChildTrait1] -/ +structure ChildTrait1 (Self : Type) where + parent_clause_0 : ParentTrait1 Self + +/- Trait implementation: [traits::usize::{9}] -/ +def usize.ParentTrait1Inst : ParentTrait1 Usize := { +} + +/- Trait implementation: [traits::usize::{10}] -/ +def usize.ChildTrait1Inst : ChildTrait1 Usize := { + parent_clause_0 := usize.ParentTrait1Inst +} + +/- Trait declaration: [traits::Iterator] -/ +structure Iterator (Self : Type) where + Item : Type + +/- Trait declaration: [traits::IntoIterator] -/ +structure IntoIterator (Self : Type) where + Item : Type + IntoIter : Type + IntoIter_clause_0 : Iterator IntoIter + into_iter : Self → Result IntoIter + +/- Trait declaration: [traits::FromResidual] -/ +structure FromResidual (Self T : Type) where + +/- Trait declaration: [traits::Try] -/ +structure Try (Self : Type) where + parent_clause_0 : FromResidual Self Residual + Residual : Type + +/- Trait declaration: [traits::CFnOnce] -/ +structure CFnOnce (Self Args : Type) where + Output : Type + call_once : Self → Args → Result Output + +/- Trait declaration: [traits::CFnMut] -/ +structure CFnMut (Self Args : Type) where + parent_clause_0 : CFnOnce Self Args + call_mut : Self → Args → Result parent_clause_0.Output + call_mut_back : Self → Args → parent_clause_0.Output → Result Self + +/- Trait declaration: [traits::CFn] -/ +structure CFn (Self Args : Type) where + parent_clause_0 : CFnMut Self Args + call_mut : Self → Args → Result parent_clause_0.parent_clause_0.Output + +/- Trait declaration: [core::ops::function::FnOnce] -/ +structure core.ops.function.FnOnce (Self Args : Type) where + Output : Type + call_once : Self → Args → Result Output + +/- Trait declaration: [core::ops::function::FnMut] -/ +structure core.ops.function.FnMut (Self Args : Type) where + parent_clause_0 : core.ops.function.FnOnce Self Args + call_mut : Self → Args → Result parent_clause_0.Output + call_mut_back : Self → Args → parent_clause_0.Output → Result Self + +/- Trait declaration: [core::ops::function::Fn] -/ +structure core.ops.function.Fn (Self Args : Type) where + parent_clause_0 : core.ops.function.FnMut Self Args + call : Self → Args → Result parent_clause_0.parent_clause_0.Output + +/- [traits::map_option]: forward function -/ +def map_option + (T F : Type) (inst : core.ops.function.Fn F T) (x : Option T) (f0 : F) : + Result (Option T) + := + match x with + | none => Result.ret none + | some x0 => do + let t ← inst.call f0 x0 + Result.ret (some t) + +/- Trait declaration: [traits::WithTarget] -/ +structure WithTarget (Self : Type) where + Target : Type + +/- Trait declaration: [traits::ParentTrait2] -/ +structure ParentTrait2 (Self : Type) where + U : Type + U_clause_0 : WithTarget U + +/- Trait declaration: [traits::ChildTrait2] -/ +structure ChildTrait2 (Self : Type) where + parent_clause_0 : ParentTrait2 Self + convert : parent_clause_0.U → Result parent_clause_0.U_clause_0.Target + +/- Trait implementation: [traits::u32::{11}] -/ +def u32.WithTargetInst : WithTarget U32 := { + Target := U32 +} + +/- Trait implementation: [traits::u32::{12}] -/ +def u32.ParentTrait2Inst : ParentTrait2 U32 := { + U := U32 + U_clause_0 := u32.WithTargetInst +} + +/- [traits::u32::{13}::convert]: forward function -/ +def u32.convert (x : U32) : Result U32 := + Result.ret x + +/- Trait implementation: [traits::u32::{13}] -/ +def u32.ChildTrait2Inst : ChildTrait2 U32 := { + parent_clause_0 := u32.ParentTrait2Inst + convert := u32.convert +} + +/- [traits::incr_u32]: forward function -/ +def incr_u32 (x : U32) : Result U32 := + x + 1#u32 + +end traits diff --git a/tests/lean/Traits/Funs.lean b/tests/lean/Traits/Funs.lean deleted file mode 100644 index 8d423280..00000000 --- a/tests/lean/Traits/Funs.lean +++ /dev/null @@ -1,275 +0,0 @@ --- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS --- [traits]: function definitions -import Base -import Traits.Types -open Primitives - -namespace traits - -/- [traits::Bool::{0}::get_bool]: forward function -/ -def Bool.get_bool (self : Bool) : Result Bool := - Result.ret self - -/- Trait implementation: [traits::Bool::{0}] -/ -def Bool.BoolTraitInst : BoolTrait Bool := { - get_bool := Bool.get_bool -} - -/- [traits::BoolTrait::ret_true]: forward function -/ -def BoolTrait.ret_true - {Self : Type} (self_clause : BoolTrait Self) (self : Self) : Result Bool := - Result.ret true - -/- [traits::test_bool_trait_bool]: forward function -/ -def test_bool_trait_bool (x : Bool) : Result Bool := - do - let b ← Bool.get_bool x - if b - then BoolTrait.ret_true Bool.BoolTraitInst x - else Result.ret false - -/- [traits::Option::{1}::get_bool]: forward function -/ -def Option.get_bool (T : Type) (self : Option T) : Result Bool := - match self with - | none => Result.ret false - | some t => Result.ret true - -/- Trait implementation: [traits::Option::{1}] -/ -def Option.BoolTraitInst (T : Type) : BoolTrait (Option T) := { - get_bool := Option.get_bool T -} - -/- [traits::test_bool_trait_option]: forward function -/ -def test_bool_trait_option (T : Type) (x : Option T) : Result Bool := - do - let b ← Option.get_bool T x - if b - then BoolTrait.ret_true (Option.BoolTraitInst T) x - else Result.ret false - -/- [traits::test_bool_trait]: forward function -/ -def test_bool_trait (T : Type) (inst : BoolTrait T) (x : T) : Result Bool := - inst.get_bool x - -/- [traits::u64::{2}::to_u64]: forward function -/ -def u64.to_u64 (self : U64) : Result U64 := - Result.ret self - -/- Trait implementation: [traits::u64::{2}] -/ -def u64.ToU64Inst : ToU64 U64 := { - to_u64 := u64.to_u64 -} - -/- [traits::Tuple2::{3}::to_u64]: forward function -/ -def Tuple2.to_u64 (A : Type) (inst : ToU64 A) (self : (A × A)) : Result U64 := - do - let (t, t0) := self - let i ← inst.to_u64 t - let i0 ← inst.to_u64 t0 - i + i0 - -/- Trait implementation: [traits::Tuple2::{3}] -/ -def Tuple2.ToU64Inst (A : Type) (inst : ToU64 A) : ToU64 (A × A) := { - to_u64 := Tuple2.to_u64 A inst -} - -/- [traits::f]: forward function -/ -def f (T : Type) (inst : ToU64 T) (x : (T × T)) : Result U64 := - Tuple2.to_u64 T inst x - -/- [traits::g]: forward function -/ -def g (T : Type) (inst : ToU64 (T × T)) (x : (T × T)) : Result U64 := - inst.to_u64 x - -/- [traits::h0]: forward function -/ -def h0 (x : U64) : Result U64 := - u64.to_u64 x - -/- [traits::Wrapper::{4}::to_u64]: forward function -/ -def Wrapper.to_u64 - (T : Type) (inst : ToU64 T) (self : Wrapper T) : Result U64 := - inst.to_u64 self.x - -/- Trait implementation: [traits::Wrapper::{4}] -/ -def Wrapper.ToU64Inst (T : Type) (inst : ToU64 T) : ToU64 (Wrapper T) := { - to_u64 := Wrapper.to_u64 T inst -} - -/- [traits::h1]: forward function -/ -def h1 (x : Wrapper U64) : Result U64 := - Wrapper.to_u64 U64 u64.ToU64Inst x - -/- [traits::h2]: forward function -/ -def h2 (T : Type) (inst : ToU64 T) (x : Wrapper T) : Result U64 := - Wrapper.to_u64 T inst x - -/- [traits::u64::{5}::to_type]: forward function -/ -def u64.to_type (self : U64) : Result Bool := - Result.ret (self > 0#u64) - -/- Trait implementation: [traits::u64::{5}] -/ -def u64.ToTypeInst : ToType U64 Bool := { - to_type := u64.to_type -} - -/- [traits::h3]: forward function -/ -def h3 - (T1 T2 : Type) (inst : OfType T1) (inst0 : ToType T2 T1) (y : T2) : - Result T1 - := - inst.of_type T2 inst0 y - -/- [traits::h4]: forward function -/ -def h4 - (T1 T2 : Type) (inst : OfTypeBis T1 T2) (inst0 : ToType T2 T1) (y : T2) : - Result T1 - := - inst.of_type y - -/- [traits::TestType::{6}::test::TestType1::{0}::test]: forward function -/ -def TestType.test.TestType1.test - (self : TestType.test.TestType1) : Result Bool := - Result.ret (self._0 > 1#u64) - -/- Trait implementation: [traits::TestType::{6}::test::TestType1::{0}] -/ -def TestType.test.TestType1.TestTypetestTestTraitInst : TestType.test.TestTrait - TestType.test.TestType1 := { - test := TestType.test.TestType1.test -} - -/- [traits::TestType::{6}::test]: forward function -/ -def TestType.test - (T : Type) (inst : ToU64 T) (self : TestType T) (x : T) : Result Bool := - do - let x0 ← inst.to_u64 x - if x0 > 0#u64 - then TestType.test.TestType1.test { _0 := 0#u64 } - else Result.ret false - -/- [traits::BoolWrapper::{7}::to_type]: forward function -/ -def BoolWrapper.to_type - (T : Type) (inst : ToType Bool T) (self : BoolWrapper) : Result T := - inst.to_type self._0 - -/- Trait implementation: [traits::BoolWrapper::{7}] -/ -def BoolWrapper.ToTypeInst (T : Type) (inst : ToType Bool T) : ToType - BoolWrapper T := { - to_type := BoolWrapper.to_type T inst -} - -/- [traits::WithConstTy::LEN2] -/ -def with_const_ty_len2_body : Result Usize := Result.ret 32#usize -def with_const_ty_len2_c : Usize := - eval_global with_const_ty_len2_body (by simp) - -/- [traits::Bool::{8}::LEN1] -/ -def bool_len1_body : Result Usize := Result.ret 12#usize -def bool_len1_c : Usize := eval_global bool_len1_body (by simp) - -/- [traits::Bool::{8}::f]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ -def Bool.f (i : U64) (a : Array U8 32#usize) : Result U64 := - Result.ret i - -/- Trait implementation: [traits::Bool::{8}] -/ -def Bool.WithConstTyInst : WithConstTy Bool 32#usize := { - LEN1 := bool_len1_c - LEN2 := with_const_ty_len2_c - V := U8 - W := U64 - W_clause_0 := u64.ToU64Inst - f := Bool.f -} - -/- [traits::use_with_const_ty1]: forward function -/ -def use_with_const_ty1 - (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) : Result Usize := - let i := inst.LEN1 - Result.ret i - -/- [traits::use_with_const_ty2]: forward function -/ -def use_with_const_ty2 - (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) (w : inst.W) : - Result Unit - := - Result.ret () - -/- [traits::use_with_const_ty3]: forward function -/ -def use_with_const_ty3 - (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) (x : inst.W) : - Result U64 - := - inst.W_clause_0.to_u64 x - -/- [traits::test_where1]: forward function -/ -def test_where1 (T : Type) (_x : T) : Result Unit := - Result.ret () - -/- [traits::test_where2]: forward function -/ -def test_where2 - (T : Type) (inst : WithConstTy T 32#usize) (_x : U32) : Result Unit := - Result.ret () - -/- [traits::test_child_trait1]: forward function -/ -def test_child_trait1 - (T : Type) (inst : ChildTrait T) (x : T) : Result alloc.string.String := - inst.parent_clause_0.get_name x - -/- [traits::test_child_trait2]: forward function -/ -def test_child_trait2 - (T : Type) (inst : ChildTrait T) (x : T) : Result inst.parent_clause_0.W := - inst.parent_clause_0.get_w x - -/- [traits::order1]: forward function -/ -def order1 - (T U : Type) (inst : ParentTrait0 T) (inst0 : ParentTrait0 U) : - Result Unit - := - Result.ret () - -/- Trait implementation: [traits::usize::{9}] -/ -def usize.ParentTrait1Inst : ParentTrait1 Usize := { -} - -/- Trait implementation: [traits::usize::{10}] -/ -def usize.ChildTrait1Inst : ChildTrait1 Usize := { - parent_clause_0 := usize.ParentTrait1Inst -} - -/- [traits::map_option]: forward function -/ -def map_option - (T F : Type) (inst : core.ops.function.Fn F T) (x : Option T) (f0 : F) : - Result (Option T) - := - match x with - | none => Result.ret none - | some x0 => do - let t ← inst.call f0 x0 - Result.ret (some t) - -/- Trait implementation: [traits::u32::{11}] -/ -def u32.WithTargetInst : WithTarget U32 := { - Target := U32 -} - -/- Trait implementation: [traits::u32::{12}] -/ -def u32.ParentTrait2Inst : ParentTrait2 U32 := { - U := U32 - U_clause_0 := u32.WithTargetInst -} - -/- [traits::u32::{13}::convert]: forward function -/ -def u32.convert (x : U32) : Result U32 := - Result.ret x - -/- Trait implementation: [traits::u32::{13}] -/ -def u32.ChildTrait2Inst : ChildTrait2 U32 := { - parent_clause_0 := u32.ParentTrait2Inst - convert := u32.convert -} - -/- [traits::incr_u32]: forward function -/ -def incr_u32 (x : U32) : Result U32 := - x + 1#u32 - -end traits diff --git a/tests/lean/Traits/Types.lean b/tests/lean/Traits/Types.lean deleted file mode 100644 index 4c5dd874..00000000 --- a/tests/lean/Traits/Types.lean +++ /dev/null @@ -1,144 +0,0 @@ --- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS --- [traits]: type definitions -import Base -open Primitives - -namespace traits - -/- Trait declaration: [traits::BoolTrait] -/ -structure BoolTrait (Self : Type) where - get_bool : Self → Result Bool - -/- Trait declaration: [traits::ToU64] -/ -structure ToU64 (Self : Type) where - to_u64 : Self → Result U64 - -/- [traits::Wrapper] -/ -structure Wrapper (T : Type) where - x : T - -/- Trait declaration: [traits::ToType] -/ -structure ToType (Self T : Type) where - to_type : Self → Result T - -/- Trait declaration: [traits::OfType] -/ -structure OfType (Self : Type) where - of_type : forall (T : Type) (inst : ToType T Self), T → Result Self - -/- Trait declaration: [traits::OfTypeBis] -/ -structure OfTypeBis (Self T : Type) where - parent_clause_0 : ToType T Self - of_type : T → Result Self - -/- [traits::TestType] -/ -structure TestType (T : Type) where - _0 : T - -/- [traits::TestType::{6}::test::TestType1] -/ -structure TestType.test.TestType1 where - _0 : U64 - -/- Trait declaration: [traits::TestType::{6}::test::TestTrait] -/ -structure TestType.test.TestTrait (Self : Type) where - test : Self → Result Bool - -/- [traits::BoolWrapper] -/ -structure BoolWrapper where - _0 : Bool - -/- Trait declaration: [traits::WithConstTy] -/ -structure WithConstTy (Self : Type) (LEN : Usize) where - LEN1 : Usize - LEN2 : Usize - V : Type - W : Type - W_clause_0 : ToU64 W - f : W → Array U8 LEN → Result W - -/- [alloc::string::String] -/ -axiom alloc.string.String : Type - -/- Trait declaration: [traits::ParentTrait0] -/ -structure ParentTrait0 (Self : Type) where - W : Type - get_name : Self → Result alloc.string.String - get_w : Self → Result W - -/- Trait declaration: [traits::ParentTrait1] -/ -structure ParentTrait1 (Self : Type) where - -/- Trait declaration: [traits::ChildTrait] -/ -structure ChildTrait (Self : Type) where - parent_clause_0 : ParentTrait0 Self - parent_clause_1 : ParentTrait1 Self - -/- Trait declaration: [traits::ChildTrait1] -/ -structure ChildTrait1 (Self : Type) where - parent_clause_0 : ParentTrait1 Self - -/- Trait declaration: [traits::Iterator] -/ -structure Iterator (Self : Type) where - Item : Type - -/- Trait declaration: [traits::IntoIterator] -/ -structure IntoIterator (Self : Type) where - Item : Type - IntoIter : Type - IntoIter_clause_0 : Iterator IntoIter - into_iter : Self → Result IntoIter - -/- Trait declaration: [traits::FromResidual] -/ -structure FromResidual (Self T : Type) where - -/- Trait declaration: [traits::Try] -/ -structure Try (Self : Type) where - parent_clause_0 : FromResidual Self Residual - Residual : Type - -/- Trait declaration: [traits::CFnOnce] -/ -structure CFnOnce (Self Args : Type) where - Output : Type - call_once : Self → Args → Result Output - -/- Trait declaration: [traits::CFnMut] -/ -structure CFnMut (Self Args : Type) where - parent_clause_0 : CFnOnce Self Args - call_mut : Self → Args → Result parent_clause_0.Output - call_mut_back : Self → Args → parent_clause_0.Output → Result Self - -/- Trait declaration: [traits::CFn] -/ -structure CFn (Self Args : Type) where - parent_clause_0 : CFnMut Self Args - call_mut : Self → Args → Result parent_clause_0.parent_clause_0.Output - -/- Trait declaration: [core::ops::function::FnOnce] -/ -structure core.ops.function.FnOnce (Self Args : Type) where - Output : Type - call_once : Self → Args → Result Output - -/- Trait declaration: [core::ops::function::FnMut] -/ -structure core.ops.function.FnMut (Self Args : Type) where - parent_clause_0 : core.ops.function.FnOnce Self Args - call_mut : Self → Args → Result parent_clause_0.Output - call_mut_back : Self → Args → parent_clause_0.Output → Result Self - -/- Trait declaration: [core::ops::function::Fn] -/ -structure core.ops.function.Fn (Self Args : Type) where - parent_clause_0 : core.ops.function.FnMut Self Args - call : Self → Args → Result parent_clause_0.parent_clause_0.Output - -/- Trait declaration: [traits::WithTarget] -/ -structure WithTarget (Self : Type) where - Target : Type - -/- Trait declaration: [traits::ParentTrait2] -/ -structure ParentTrait2 (Self : Type) where - U : Type - U_clause_0 : WithTarget U - -/- Trait declaration: [traits::ChildTrait2] -/ -structure ChildTrait2 (Self : Type) where - parent_clause_0 : ParentTrait2 Self - convert : parent_clause_0.U → Result parent_clause_0.U_clause_0.Target - -end traits -- cgit v1.2.3 From 38a01551719d0cefdd4a1c21a050674154b0b087 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 9 Nov 2023 13:44:03 +0100 Subject: Regenerate the tests --- tests/lean/Traits.lean | 61 ++++++++++++++------------------------------------ 1 file changed, 17 insertions(+), 44 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Traits.lean b/tests/lean/Traits.lean index 94ae0bb0..12e7eafa 100644 --- a/tests/lean/Traits.lean +++ b/tests/lean/Traits.lean @@ -322,51 +322,8 @@ structure FromResidual (Self T : Type) where /- Trait declaration: [traits::Try] -/ structure Try (Self : Type) where - parent_clause_0 : FromResidual Self Residual Residual : Type - -/- Trait declaration: [traits::CFnOnce] -/ -structure CFnOnce (Self Args : Type) where - Output : Type - call_once : Self → Args → Result Output - -/- Trait declaration: [traits::CFnMut] -/ -structure CFnMut (Self Args : Type) where - parent_clause_0 : CFnOnce Self Args - call_mut : Self → Args → Result parent_clause_0.Output - call_mut_back : Self → Args → parent_clause_0.Output → Result Self - -/- Trait declaration: [traits::CFn] -/ -structure CFn (Self Args : Type) where - parent_clause_0 : CFnMut Self Args - call_mut : Self → Args → Result parent_clause_0.parent_clause_0.Output - -/- Trait declaration: [core::ops::function::FnOnce] -/ -structure core.ops.function.FnOnce (Self Args : Type) where - Output : Type - call_once : Self → Args → Result Output - -/- Trait declaration: [core::ops::function::FnMut] -/ -structure core.ops.function.FnMut (Self Args : Type) where - parent_clause_0 : core.ops.function.FnOnce Self Args - call_mut : Self → Args → Result parent_clause_0.Output - call_mut_back : Self → Args → parent_clause_0.Output → Result Self - -/- Trait declaration: [core::ops::function::Fn] -/ -structure core.ops.function.Fn (Self Args : Type) where - parent_clause_0 : core.ops.function.FnMut Self Args - call : Self → Args → Result parent_clause_0.parent_clause_0.Output - -/- [traits::map_option]: forward function -/ -def map_option - (T F : Type) (inst : core.ops.function.Fn F T) (x : Option T) (f0 : F) : - Result (Option T) - := - match x with - | none => Result.ret none - | some x0 => do - let t ← inst.call f0 x0 - Result.ret (some t) + parent_clause_0 : FromResidual Self Residual /- Trait declaration: [traits::WithTarget] -/ structure WithTarget (Self : Type) where @@ -407,4 +364,20 @@ def u32.ChildTrait2Inst : ChildTrait2 U32 := { def incr_u32 (x : U32) : Result U32 := x + 1#u32 +/- Trait declaration: [traits::CFnOnce] -/ +structure CFnOnce (Self Args : Type) where + Output : Type + call_once : Self → Args → Result Output + +/- Trait declaration: [traits::CFnMut] -/ +structure CFnMut (Self Args : Type) where + parent_clause_0 : CFnOnce Self Args + call_mut : Self → Args → Result parent_clause_0.Output + call_mut_back : Self → Args → parent_clause_0.Output → Result Self + +/- Trait declaration: [traits::CFn] -/ +structure CFn (Self Args : Type) where + parent_clause_0 : CFnMut Self Args + call_mut : Self → Args → Result parent_clause_0.parent_clause_0.Output + end traits -- cgit v1.2.3 From 00705bba68fed61d3b0bcde2c5fe0ecc83880870 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 9 Nov 2023 18:37:07 +0100 Subject: Update the failing proofs --- tests/lean/Hashmap/Properties.lean | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Hashmap/Properties.lean b/tests/lean/Hashmap/Properties.lean index 4db54316..e79c422d 100644 --- a/tests/lean/Hashmap/Properties.lean +++ b/tests/lean/Hashmap/Properties.lean @@ -157,7 +157,7 @@ instance : Inhabited (List α) where def slots_s_inv (s : Core.List (List α)) : Prop := ∀ (i : Int), 0 ≤ i → i < s.len → slot_t_inv s.len i (s.index i) -def slots_t_inv (s : Vec (List α)) : Prop := +def slots_t_inv (s : alloc.vec.Vec (List α)) : Prop := slots_s_inv s.v @[simp] @@ -302,13 +302,14 @@ theorem insert_no_resize_spec {α : Type} (hm : HashMap α) (key : Usize) (value | none => nhm.len_s = hm.len_s + 1 | some _ => nhm.len_s = hm.len_s) := by rw [insert_no_resize] - simp only [hash_key, bind_tc_ret] -- TODO: annoying - have _ : (Vec.len (List α) hm.slots).val ≠ 0 := by + -- Simplify. Note that this also simplifies some function calls, like array index + simp [hash_key, bind_tc_ret] + have _ : (alloc.vec.Vec.len (List α) hm.slots).val ≠ 0 := by intro simp_all [inv] progress as ⟨ hash_mod, hhm ⟩ have _ : 0 ≤ hash_mod.val := by scalar_tac - have _ : hash_mod.val < Vec.length hm.slots := by + have _ : hash_mod.val < alloc.vec.Vec.length hm.slots := by have : 0 < hm.slots.val.len := by simp [inv] at hinv simp [hinv] @@ -374,7 +375,7 @@ theorem insert_no_resize_spec {α : Type} (hm : HashMap α) (key : Usize) (value -- TODO: we want to automate this simp apply Int.emod_nonneg k.val hvnz - have _ : k_hash_mod < Vec.length hm.slots := by + have _ : k_hash_mod < alloc.vec.Vec.length hm.slots := by -- TODO: we want to automate this simp have h := Int.emod_lt_of_pos k.val hvpos -- cgit v1.2.3 From dcd34ceed0c52738b1bb8139e7130db9bad1a774 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 21 Nov 2023 10:22:51 +0100 Subject: Fix issues with the builtin names --- tests/lean/NoNestedBorrows.lean | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/NoNestedBorrows.lean b/tests/lean/NoNestedBorrows.lean index c4a6a265..79049837 100644 --- a/tests/lean/NoNestedBorrows.lean +++ b/tests/lean/NoNestedBorrows.lean @@ -151,11 +151,13 @@ def test_list1 : Result Unit := /- [no_nested_borrows::test_box1]: forward function -/ def test_box1 : Result Unit := - let b := 1#i32 - let x := b - if not (x = 1#i32) - then Result.fail Error.panic - else Result.ret () + do + let b := 0#i32 + let b0 ← alloc.boxed.Box.deref_mut_back I32 b 1#i32 + let x ← alloc.boxed.Box.deref I32 b0 + if not (x = 1#i32) + then Result.fail Error.panic + else Result.ret () /- Unit test for [no_nested_borrows::test_box1] -/ #assert (test_box1 == .ret ()) -- cgit v1.2.3 From 5e92ae6b361f9221f5c5f9a39ab4c28a36597a77 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 21 Nov 2023 11:40:59 +0100 Subject: Regenerate most of the test files --- tests/lean/Array.lean | 32 +++--- tests/lean/Constants.lean | 2 +- tests/lean/External/FunsExternal_Template.lean | 4 +- tests/lean/Hashmap/Funs.lean | 130 ++++++++++++------------- tests/lean/HashmapMain/Funs.lean | 115 +++++++++++----------- tests/lean/Loops.lean | 15 ++- 6 files changed, 145 insertions(+), 153 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Array.lean b/tests/lean/Array.lean index 20f02e97..5a4e09ab 100644 --- a/tests/lean/Array.lean +++ b/tests/lean/Array.lean @@ -91,14 +91,14 @@ def index_mut_slice_back def slice_subslice_shared_ (x : Slice U32) (y : Usize) (z : Usize) : Result (Slice U32) := core.slice.index.Slice.index U32 (core.ops.range.Range Usize) - (core.slice.index.Range.coresliceindexSliceIndexInst U32) x + (core.slice.index.SliceIndexRangeUsizeSliceTInst U32) x { start := y, end_ := z } /- [array::slice_subslice_mut_]: forward function -/ def 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.Range.coresliceindexSliceIndexInst U32) x + (core.slice.index.SliceIndexRangeUsizeSliceTInst U32) x { start := y, end_ := z } /- [array::slice_subslice_mut_]: backward function 0 -/ @@ -107,7 +107,7 @@ def slice_subslice_mut__back Result (Slice U32) := core.slice.index.Slice.index_mut_back U32 (core.ops.range.Range Usize) - (core.slice.index.Range.coresliceindexSliceIndexInst U32) x + (core.slice.index.SliceIndexRangeUsizeSliceTInst U32) x { start := y, end_ := z } ret0 /- [array::array_to_slice_shared_]: forward function -/ @@ -127,16 +127,16 @@ def array_to_slice_mut__back def array_subslice_shared_ (x : Array U32 32#usize) (y : Usize) (z : Usize) : Result (Slice U32) := core.array.Array.index U32 (core.ops.range.Range Usize) 32#usize - (core.slice.index.Slice.coreopsindexIndexInst U32 (core.ops.range.Range - Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + (core.ops.index.IndexSliceTIInst U32 (core.ops.range.Range Usize) + (core.slice.index.SliceIndexRangeUsizeSliceTInst U32)) x { start := y, end_ := z } /- [array::array_subslice_mut_]: forward function -/ def 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.slice.index.Slice.coreopsindexIndexMutInst U32 (core.ops.range.Range - Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + (core.ops.index.IndexMutSliceTIInst U32 (core.ops.range.Range Usize) + (core.slice.index.SliceIndexRangeUsizeSliceTInst U32)) x { start := y, end_ := z } /- [array::array_subslice_mut_]: backward function 0 -/ @@ -145,8 +145,8 @@ def array_subslice_mut__back Result (Array U32 32#usize) := core.array.Array.index_mut_back U32 (core.ops.range.Range Usize) 32#usize - (core.slice.index.Slice.coreopsindexIndexMutInst U32 (core.ops.range.Range - Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + (core.ops.index.IndexMutSliceTIInst U32 (core.ops.range.Range Usize) + (core.slice.index.SliceIndexRangeUsizeSliceTInst U32)) x { start := y, end_ := z } ret0 /- [array::index_slice_0]: forward function -/ @@ -288,17 +288,15 @@ def range_all : Result Unit := do let s ← core.array.Array.index_mut U32 (core.ops.range.Range Usize) 4#usize - (core.slice.index.Slice.coreopsindexIndexMutInst U32 - (core.ops.range.Range Usize) - (core.slice.index.Range.coresliceindexSliceIndexInst U32)) + (core.ops.index.IndexMutSliceTIInst U32 (core.ops.range.Range Usize) + (core.slice.index.SliceIndexRangeUsizeSliceTInst U32)) (Array.make U32 4#usize [ 0#u32, 0#u32, 0#u32, 0#u32 ]) { start := 1#usize, end_ := 3#usize } let s0 ← update_mut_slice s let _ ← core.array.Array.index_mut_back U32 (core.ops.range.Range Usize) 4#usize - (core.slice.index.Slice.coreopsindexIndexMutInst U32 - (core.ops.range.Range Usize) - (core.slice.index.Range.coresliceindexSliceIndexInst U32)) + (core.ops.index.IndexMutSliceTIInst U32 (core.ops.range.Range Usize) + (core.slice.index.SliceIndexRangeUsizeSliceTInst U32)) (Array.make U32 4#usize [ 0#u32, 0#u32, 0#u32, 0#u32 ]) { start := 1#usize, end_ := 3#usize } s0 Result.ret () @@ -392,8 +390,8 @@ def f2 (i : U32) : Result Unit := /- [array::f4]: forward function -/ def f4 (x : Array U32 32#usize) (y : Usize) (z : Usize) : Result (Slice U32) := core.array.Array.index U32 (core.ops.range.Range Usize) 32#usize - (core.slice.index.Slice.coreopsindexIndexInst U32 (core.ops.range.Range - Usize) (core.slice.index.Range.coresliceindexSliceIndexInst U32)) x + (core.ops.index.IndexSliceTIInst U32 (core.ops.range.Range Usize) + (core.slice.index.SliceIndexRangeUsizeSliceTInst U32)) x { start := y, end_ := z } /- [array::f3]: forward function -/ diff --git a/tests/lean/Constants.lean b/tests/lean/Constants.lean index bd3a07b7..62e45d76 100644 --- a/tests/lean/Constants.lean +++ b/tests/lean/Constants.lean @@ -58,7 +58,7 @@ def p3_c : Pair U32 U32 := eval_global p3_body (by simp) structure Wrap (T : Type) where value : T -/- [constants::Wrap::{0}::new]: forward function -/ +/- [constants::{constants::Wrap}::new]: forward function -/ def Wrap.new (T : Type) (value : T) : Result (Wrap T) := Result.ret { value := value } diff --git a/tests/lean/External/FunsExternal_Template.lean b/tests/lean/External/FunsExternal_Template.lean index c8bc397f..0fccef86 100644 --- a/tests/lean/External/FunsExternal_Template.lean +++ b/tests/lean/External/FunsExternal_Template.lean @@ -17,11 +17,11 @@ axiom core.mem.swap_back0 axiom core.mem.swap_back1 (T : Type) : T → T → State → State → Result (State × T) -/- [core::num::nonzero::NonZeroU32::{14}::new]: forward function -/ +/- [core::num::nonzero::{core::num::nonzero::NonZeroU32#14}::new]: forward function -/ axiom core.num.nonzero.NonZeroU32.new : U32 → State → Result (State × (Option core.num.nonzero.NonZeroU32)) -/- [core::option::Option::{0}::unwrap]: forward function -/ +/- [core::option::{core::option::Option}::unwrap]: forward function -/ axiom core.option.Option.unwrap (T : Type) : Option T → State → Result (State × T) diff --git a/tests/lean/Hashmap/Funs.lean b/tests/lean/Hashmap/Funs.lean index 8464c432..a1cd435e 100644 --- a/tests/lean/Hashmap/Funs.lean +++ b/tests/lean/Hashmap/Funs.lean @@ -10,7 +10,7 @@ namespace hashmap def hash_key (k : Usize) : Result Usize := Result.ret k -/- [hashmap::HashMap::{0}::allocate_slots]: loop 0: forward function -/ +/- [hashmap::{hashmap::HashMap}::allocate_slots]: loop 0: forward function -/ divergent def HashMap.allocate_slots_loop (T : Type) (slots : alloc.vec.Vec (List T)) (n : Usize) : Result (alloc.vec.Vec (List T)) @@ -23,14 +23,14 @@ divergent def HashMap.allocate_slots_loop HashMap.allocate_slots_loop T slots0 n0 else Result.ret slots -/- [hashmap::HashMap::{0}::allocate_slots]: forward function -/ +/- [hashmap::{hashmap::HashMap}::allocate_slots]: forward function -/ def HashMap.allocate_slots (T : Type) (slots : alloc.vec.Vec (List T)) (n : Usize) : Result (alloc.vec.Vec (List T)) := HashMap.allocate_slots_loop T slots n -/- [hashmap::HashMap::{0}::new_with_capacity]: forward function -/ +/- [hashmap::{hashmap::HashMap}::new_with_capacity]: forward function -/ def HashMap.new_with_capacity (T : Type) (capacity : Usize) (max_load_dividend : Usize) (max_load_divisor : Usize) : @@ -49,11 +49,11 @@ def HashMap.new_with_capacity slots := slots } -/- [hashmap::HashMap::{0}::new]: forward function -/ +/- [hashmap::{hashmap::HashMap}::new]: forward function -/ def HashMap.new (T : Type) : Result (HashMap T) := HashMap.new_with_capacity T 32#usize 4#usize 5#usize -/- [hashmap::HashMap::{0}::clear]: loop 0: merged forward/backward function +/- [hashmap::{hashmap::HashMap}::clear]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ divergent def HashMap.clear_loop (T : Type) (slots : alloc.vec.Vec (List T)) (i : Usize) : @@ -66,23 +66,23 @@ divergent def HashMap.clear_loop let i1 ← i + 1#usize let slots0 ← alloc.vec.Vec.index_mut_back (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) slots - i List.Nil + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) slots i + List.Nil HashMap.clear_loop T slots0 i1 else Result.ret slots -/- [hashmap::HashMap::{0}::clear]: merged forward/backward function +/- [hashmap::{hashmap::HashMap}::clear]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def HashMap.clear (T : Type) (self : HashMap T) : Result (HashMap T) := do let v ← HashMap.clear_loop T self.slots 0#usize Result.ret { self with num_entries := 0#usize, slots := v } -/- [hashmap::HashMap::{0}::len]: forward function -/ +/- [hashmap::{hashmap::HashMap}::len]: forward function -/ def HashMap.len (T : Type) (self : HashMap T) : Result Usize := Result.ret self.num_entries -/- [hashmap::HashMap::{0}::insert_in_list]: loop 0: forward function -/ +/- [hashmap::{hashmap::HashMap}::insert_in_list]: loop 0: forward function -/ divergent def HashMap.insert_in_list_loop (T : Type) (key : Usize) (value : T) (ls : List T) : Result Bool := match ls with @@ -92,12 +92,12 @@ divergent def HashMap.insert_in_list_loop else HashMap.insert_in_list_loop T key value tl | List.Nil => Result.ret true -/- [hashmap::HashMap::{0}::insert_in_list]: forward function -/ +/- [hashmap::{hashmap::HashMap}::insert_in_list]: forward function -/ def HashMap.insert_in_list (T : Type) (key : Usize) (value : T) (ls : List T) : Result Bool := HashMap.insert_in_list_loop T key value ls -/- [hashmap::HashMap::{0}::insert_in_list]: loop 0: backward function 0 -/ +/- [hashmap::{hashmap::HashMap}::insert_in_list]: loop 0: backward function 0 -/ divergent def HashMap.insert_in_list_loop_back (T : Type) (key : Usize) (value : T) (ls : List T) : Result (List T) := match ls with @@ -111,12 +111,12 @@ divergent def HashMap.insert_in_list_loop_back | List.Nil => let l := List.Nil Result.ret (List.Cons key value l) -/- [hashmap::HashMap::{0}::insert_in_list]: backward function 0 -/ +/- [hashmap::{hashmap::HashMap}::insert_in_list]: backward function 0 -/ def HashMap.insert_in_list_back (T : Type) (key : Usize) (value : T) (ls : List T) : Result (List T) := HashMap.insert_in_list_loop_back T key value ls -/- [hashmap::HashMap::{0}::insert_no_resize]: merged forward/backward function +/- [hashmap::{hashmap::HashMap}::insert_no_resize]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def HashMap.insert_no_resize (T : Type) (self : HashMap T) (key : Usize) (value : T) : @@ -128,8 +128,8 @@ def HashMap.insert_no_resize let hash_mod ← hash % i let l ← alloc.vec.Vec.index_mut (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) - self.slots hash_mod + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots + hash_mod let inserted ← HashMap.insert_in_list T key value l if inserted then @@ -138,19 +138,19 @@ def HashMap.insert_no_resize let l0 ← HashMap.insert_in_list_back T key value l let v ← alloc.vec.Vec.index_mut_back (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) - self.slots hash_mod l0 + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots + hash_mod l0 Result.ret { self with num_entries := i0, slots := v } else do let l0 ← HashMap.insert_in_list_back T key value l let v ← alloc.vec.Vec.index_mut_back (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) - self.slots hash_mod l0 + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots + hash_mod l0 Result.ret { self with slots := v } -/- [hashmap::HashMap::{0}::move_elements_from_list]: loop 0: merged forward/backward function +/- [hashmap::{hashmap::HashMap}::move_elements_from_list]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ divergent def HashMap.move_elements_from_list_loop (T : Type) (ntable : HashMap T) (ls : List T) : Result (HashMap T) := @@ -161,13 +161,13 @@ divergent def HashMap.move_elements_from_list_loop HashMap.move_elements_from_list_loop T ntable0 tl | List.Nil => Result.ret ntable -/- [hashmap::HashMap::{0}::move_elements_from_list]: merged forward/backward function +/- [hashmap::{hashmap::HashMap}::move_elements_from_list]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def HashMap.move_elements_from_list (T : Type) (ntable : HashMap T) (ls : List T) : Result (HashMap T) := HashMap.move_elements_from_list_loop T ntable ls -/- [hashmap::HashMap::{0}::move_elements]: loop 0: merged forward/backward function +/- [hashmap::{hashmap::HashMap}::move_elements]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ divergent def HashMap.move_elements_loop (T : Type) (ntable : HashMap T) (slots : alloc.vec.Vec (List T)) (i : Usize) @@ -180,20 +180,18 @@ divergent def HashMap.move_elements_loop do let l ← alloc.vec.Vec.index_mut (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) slots - i + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) slots i let ls := core.mem.replace (List T) l List.Nil let ntable0 ← HashMap.move_elements_from_list T ntable ls let i1 ← i + 1#usize let l0 := core.mem.replace_back (List T) l List.Nil let slots0 ← alloc.vec.Vec.index_mut_back (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) slots - i l0 + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) slots i l0 HashMap.move_elements_loop T ntable0 slots0 i1 else Result.ret (ntable, slots) -/- [hashmap::HashMap::{0}::move_elements]: merged forward/backward function +/- [hashmap::{hashmap::HashMap}::move_elements]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def HashMap.move_elements (T : Type) (ntable : HashMap T) (slots : alloc.vec.Vec (List T)) (i : Usize) @@ -202,7 +200,7 @@ def HashMap.move_elements := HashMap.move_elements_loop T ntable slots i -/- [hashmap::HashMap::{0}::try_resize]: merged forward/backward function +/- [hashmap::{hashmap::HashMap}::try_resize]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def HashMap.try_resize (T : Type) (self : HashMap T) : Result (HashMap T) := do @@ -225,7 +223,7 @@ def HashMap.try_resize (T : Type) (self : HashMap T) : Result (HashMap T) := } else Result.ret { self with max_load_factor := (i, i0) } -/- [hashmap::HashMap::{0}::insert]: merged forward/backward function +/- [hashmap::{hashmap::HashMap}::insert]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def HashMap.insert (T : Type) (self : HashMap T) (key : Usize) (value : T) : @@ -238,7 +236,7 @@ def HashMap.insert then HashMap.try_resize T self0 else Result.ret self0 -/- [hashmap::HashMap::{0}::contains_key_in_list]: loop 0: forward function -/ +/- [hashmap::{hashmap::HashMap}::contains_key_in_list]: loop 0: forward function -/ divergent def HashMap.contains_key_in_list_loop (T : Type) (key : Usize) (ls : List T) : Result Bool := match ls with @@ -248,12 +246,12 @@ divergent def HashMap.contains_key_in_list_loop else HashMap.contains_key_in_list_loop T key tl | List.Nil => Result.ret false -/- [hashmap::HashMap::{0}::contains_key_in_list]: forward function -/ +/- [hashmap::{hashmap::HashMap}::contains_key_in_list]: forward function -/ def HashMap.contains_key_in_list (T : Type) (key : Usize) (ls : List T) : Result Bool := HashMap.contains_key_in_list_loop T key ls -/- [hashmap::HashMap::{0}::contains_key]: forward function -/ +/- [hashmap::{hashmap::HashMap}::contains_key]: forward function -/ def HashMap.contains_key (T : Type) (self : HashMap T) (key : Usize) : Result Bool := do @@ -262,11 +260,11 @@ def HashMap.contains_key let hash_mod ← hash % i let l ← alloc.vec.Vec.index (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) - self.slots hash_mod + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots + hash_mod HashMap.contains_key_in_list T key l -/- [hashmap::HashMap::{0}::get_in_list]: loop 0: forward function -/ +/- [hashmap::{hashmap::HashMap}::get_in_list]: loop 0: forward function -/ divergent def HashMap.get_in_list_loop (T : Type) (key : Usize) (ls : List T) : Result T := match ls with @@ -276,11 +274,11 @@ divergent def HashMap.get_in_list_loop else HashMap.get_in_list_loop T key tl | List.Nil => Result.fail Error.panic -/- [hashmap::HashMap::{0}::get_in_list]: forward function -/ +/- [hashmap::{hashmap::HashMap}::get_in_list]: forward function -/ def HashMap.get_in_list (T : Type) (key : Usize) (ls : List T) : Result T := HashMap.get_in_list_loop T key ls -/- [hashmap::HashMap::{0}::get]: forward function -/ +/- [hashmap::{hashmap::HashMap}::get]: forward function -/ def HashMap.get (T : Type) (self : HashMap T) (key : Usize) : Result T := do let hash ← hash_key key @@ -288,11 +286,11 @@ def HashMap.get (T : Type) (self : HashMap T) (key : Usize) : Result T := let hash_mod ← hash % i let l ← alloc.vec.Vec.index (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) - self.slots hash_mod + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots + hash_mod HashMap.get_in_list T key l -/- [hashmap::HashMap::{0}::get_mut_in_list]: loop 0: forward function -/ +/- [hashmap::{hashmap::HashMap}::get_mut_in_list]: loop 0: forward function -/ divergent def HashMap.get_mut_in_list_loop (T : Type) (ls : List T) (key : Usize) : Result T := match ls with @@ -302,12 +300,12 @@ divergent def HashMap.get_mut_in_list_loop else HashMap.get_mut_in_list_loop T tl key | List.Nil => Result.fail Error.panic -/- [hashmap::HashMap::{0}::get_mut_in_list]: forward function -/ +/- [hashmap::{hashmap::HashMap}::get_mut_in_list]: forward function -/ def HashMap.get_mut_in_list (T : Type) (ls : List T) (key : Usize) : Result T := HashMap.get_mut_in_list_loop T ls key -/- [hashmap::HashMap::{0}::get_mut_in_list]: loop 0: backward function 0 -/ +/- [hashmap::{hashmap::HashMap}::get_mut_in_list]: loop 0: backward function 0 -/ divergent def HashMap.get_mut_in_list_loop_back (T : Type) (ls : List T) (key : Usize) (ret0 : T) : Result (List T) := match ls with @@ -320,12 +318,12 @@ divergent def HashMap.get_mut_in_list_loop_back Result.ret (List.Cons ckey cvalue tl0) | List.Nil => Result.fail Error.panic -/- [hashmap::HashMap::{0}::get_mut_in_list]: backward function 0 -/ +/- [hashmap::{hashmap::HashMap}::get_mut_in_list]: backward function 0 -/ def HashMap.get_mut_in_list_back (T : Type) (ls : List T) (key : Usize) (ret0 : T) : Result (List T) := HashMap.get_mut_in_list_loop_back T ls key ret0 -/- [hashmap::HashMap::{0}::get_mut]: forward function -/ +/- [hashmap::{hashmap::HashMap}::get_mut]: forward function -/ def HashMap.get_mut (T : Type) (self : HashMap T) (key : Usize) : Result T := do let hash ← hash_key key @@ -333,11 +331,11 @@ def HashMap.get_mut (T : Type) (self : HashMap T) (key : Usize) : Result T := let hash_mod ← hash % i let l ← alloc.vec.Vec.index_mut (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) - self.slots hash_mod + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots + hash_mod HashMap.get_mut_in_list T l key -/- [hashmap::HashMap::{0}::get_mut]: backward function 0 -/ +/- [hashmap::{hashmap::HashMap}::get_mut]: backward function 0 -/ def HashMap.get_mut_back (T : Type) (self : HashMap T) (key : Usize) (ret0 : T) : Result (HashMap T) @@ -348,16 +346,16 @@ def HashMap.get_mut_back let hash_mod ← hash % i let l ← alloc.vec.Vec.index_mut (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) - self.slots hash_mod + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots + hash_mod let l0 ← HashMap.get_mut_in_list_back T l key ret0 let v ← alloc.vec.Vec.index_mut_back (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) - self.slots hash_mod l0 + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots + hash_mod l0 Result.ret { self with slots := v } -/- [hashmap::HashMap::{0}::remove_from_list]: loop 0: forward function -/ +/- [hashmap::{hashmap::HashMap}::remove_from_list]: loop 0: forward function -/ divergent def HashMap.remove_from_list_loop (T : Type) (key : Usize) (ls : List T) : Result (Option T) := match ls with @@ -371,12 +369,12 @@ divergent def HashMap.remove_from_list_loop else HashMap.remove_from_list_loop T key tl | List.Nil => Result.ret none -/- [hashmap::HashMap::{0}::remove_from_list]: forward function -/ +/- [hashmap::{hashmap::HashMap}::remove_from_list]: forward function -/ def HashMap.remove_from_list (T : Type) (key : Usize) (ls : List T) : Result (Option T) := HashMap.remove_from_list_loop T key ls -/- [hashmap::HashMap::{0}::remove_from_list]: loop 0: backward function 1 -/ +/- [hashmap::{hashmap::HashMap}::remove_from_list]: loop 0: backward function 1 -/ divergent def HashMap.remove_from_list_loop_back (T : Type) (key : Usize) (ls : List T) : Result (List T) := match ls with @@ -393,12 +391,12 @@ divergent def HashMap.remove_from_list_loop_back Result.ret (List.Cons ckey t tl0) | List.Nil => Result.ret List.Nil -/- [hashmap::HashMap::{0}::remove_from_list]: backward function 1 -/ +/- [hashmap::{hashmap::HashMap}::remove_from_list]: backward function 1 -/ def HashMap.remove_from_list_back (T : Type) (key : Usize) (ls : List T) : Result (List T) := HashMap.remove_from_list_loop_back T key ls -/- [hashmap::HashMap::{0}::remove]: forward function -/ +/- [hashmap::{hashmap::HashMap}::remove]: forward function -/ def HashMap.remove (T : Type) (self : HashMap T) (key : Usize) : Result (Option T) := do @@ -407,8 +405,8 @@ def HashMap.remove let hash_mod ← hash % i let l ← alloc.vec.Vec.index_mut (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) - self.slots hash_mod + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots + hash_mod let x ← HashMap.remove_from_list T key l match x with | none => Result.ret none @@ -416,7 +414,7 @@ def HashMap.remove let _ ← self.num_entries - 1#usize Result.ret (some x0) -/- [hashmap::HashMap::{0}::remove]: backward function 0 -/ +/- [hashmap::{hashmap::HashMap}::remove]: backward function 0 -/ def HashMap.remove_back (T : Type) (self : HashMap T) (key : Usize) : Result (HashMap T) := do @@ -425,8 +423,8 @@ def HashMap.remove_back let hash_mod ← hash % i let l ← alloc.vec.Vec.index_mut (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) - self.slots hash_mod + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots + hash_mod let x ← HashMap.remove_from_list T key l match x with | none => @@ -434,8 +432,8 @@ def HashMap.remove_back let l0 ← HashMap.remove_from_list_back T key l let v ← alloc.vec.Vec.index_mut_back (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) - self.slots hash_mod l0 + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots + hash_mod l0 Result.ret { self with slots := v } | some x0 => do @@ -443,8 +441,8 @@ def HashMap.remove_back let l0 ← HashMap.remove_from_list_back T key l let v ← alloc.vec.Vec.index_mut_back (List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List T)) - self.slots hash_mod l0 + (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots + hash_mod l0 Result.ret { self with num_entries := i0, slots := v } /- [hashmap::test1]: forward function -/ diff --git a/tests/lean/HashmapMain/Funs.lean b/tests/lean/HashmapMain/Funs.lean index 74fa8653..5e05a399 100644 --- a/tests/lean/HashmapMain/Funs.lean +++ b/tests/lean/HashmapMain/Funs.lean @@ -11,7 +11,7 @@ namespace hashmap_main def hashmap.hash_key (k : Usize) : Result Usize := Result.ret k -/- [hashmap_main::hashmap::HashMap::{0}::allocate_slots]: loop 0: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: loop 0: forward function -/ divergent def hashmap.HashMap.allocate_slots_loop (T : Type) (slots : alloc.vec.Vec (hashmap.List T)) (n : Usize) : Result (alloc.vec.Vec (hashmap.List T)) @@ -24,14 +24,14 @@ divergent def hashmap.HashMap.allocate_slots_loop hashmap.HashMap.allocate_slots_loop T slots0 n0 else Result.ret slots -/- [hashmap_main::hashmap::HashMap::{0}::allocate_slots]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: forward function -/ def hashmap.HashMap.allocate_slots (T : Type) (slots : alloc.vec.Vec (hashmap.List T)) (n : Usize) : Result (alloc.vec.Vec (hashmap.List T)) := hashmap.HashMap.allocate_slots_loop T slots n -/- [hashmap_main::hashmap::HashMap::{0}::new_with_capacity]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::new_with_capacity]: forward function -/ def hashmap.HashMap.new_with_capacity (T : Type) (capacity : Usize) (max_load_dividend : Usize) (max_load_divisor : Usize) : @@ -50,11 +50,11 @@ def hashmap.HashMap.new_with_capacity slots := slots } -/- [hashmap_main::hashmap::HashMap::{0}::new]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::new]: forward function -/ 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::{0}::clear]: loop 0: merged forward/backward function +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::clear]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ divergent def hashmap.HashMap.clear_loop (T : Type) (slots : alloc.vec.Vec (hashmap.List T)) (i : Usize) : @@ -67,12 +67,12 @@ divergent def hashmap.HashMap.clear_loop let i1 ← i + 1#usize let slots0 ← alloc.vec.Vec.index_mut_back (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List - T)) slots i hashmap.List.Nil + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) slots i + hashmap.List.Nil hashmap.HashMap.clear_loop T slots0 i1 else Result.ret slots -/- [hashmap_main::hashmap::HashMap::{0}::clear]: merged forward/backward function +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::clear]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def hashmap.HashMap.clear (T : Type) (self : hashmap.HashMap T) : Result (hashmap.HashMap T) := @@ -80,11 +80,11 @@ def hashmap.HashMap.clear let v ← hashmap.HashMap.clear_loop T self.slots 0#usize Result.ret { self with num_entries := 0#usize, slots := v } -/- [hashmap_main::hashmap::HashMap::{0}::len]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::len]: forward function -/ def hashmap.HashMap.len (T : Type) (self : hashmap.HashMap T) : Result Usize := Result.ret self.num_entries -/- [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: loop 0: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: loop 0: forward function -/ divergent def hashmap.HashMap.insert_in_list_loop (T : Type) (key : Usize) (value : T) (ls : hashmap.List T) : Result Bool := match ls with @@ -94,12 +94,12 @@ divergent def hashmap.HashMap.insert_in_list_loop else hashmap.HashMap.insert_in_list_loop T key value tl | hashmap.List.Nil => Result.ret true -/- [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: forward function -/ def hashmap.HashMap.insert_in_list (T : Type) (key : Usize) (value : T) (ls : hashmap.List T) : Result Bool := hashmap.HashMap.insert_in_list_loop T key value ls -/- [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: loop 0: backward function 0 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: loop 0: backward function 0 -/ divergent def hashmap.HashMap.insert_in_list_loop_back (T : Type) (key : Usize) (value : T) (ls : hashmap.List T) : Result (hashmap.List T) @@ -116,14 +116,14 @@ divergent def hashmap.HashMap.insert_in_list_loop_back let l := hashmap.List.Nil Result.ret (hashmap.List.Cons key value l) -/- [hashmap_main::hashmap::HashMap::{0}::insert_in_list]: backward function 0 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: backward function 0 -/ def hashmap.HashMap.insert_in_list_back (T : Type) (key : Usize) (value : T) (ls : hashmap.List T) : Result (hashmap.List T) := hashmap.HashMap.insert_in_list_loop_back T key value ls -/- [hashmap_main::hashmap::HashMap::{0}::insert_no_resize]: merged forward/backward function +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_no_resize]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def hashmap.HashMap.insert_no_resize (T : Type) (self : hashmap.HashMap T) (key : Usize) (value : T) : @@ -135,7 +135,7 @@ def hashmap.HashMap.insert_no_resize let hash_mod ← hash % i let l ← alloc.vec.Vec.index_mut (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) self.slots hash_mod let inserted ← hashmap.HashMap.insert_in_list T key value l if inserted @@ -145,19 +145,19 @@ def hashmap.HashMap.insert_no_resize let l0 ← hashmap.HashMap.insert_in_list_back T key value l let v ← alloc.vec.Vec.index_mut_back (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List - T)) self.slots hash_mod l0 + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) + self.slots hash_mod l0 Result.ret { self with num_entries := i0, slots := v } else do let l0 ← hashmap.HashMap.insert_in_list_back T key value l let v ← alloc.vec.Vec.index_mut_back (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List - T)) self.slots hash_mod l0 + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) + self.slots hash_mod l0 Result.ret { self with slots := v } -/- [hashmap_main::hashmap::HashMap::{0}::move_elements_from_list]: loop 0: merged forward/backward function +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements_from_list]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ divergent def hashmap.HashMap.move_elements_from_list_loop (T : Type) (ntable : hashmap.HashMap T) (ls : hashmap.List T) : @@ -170,7 +170,7 @@ divergent def hashmap.HashMap.move_elements_from_list_loop hashmap.HashMap.move_elements_from_list_loop T ntable0 tl | hashmap.List.Nil => Result.ret ntable -/- [hashmap_main::hashmap::HashMap::{0}::move_elements_from_list]: merged forward/backward function +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements_from_list]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def hashmap.HashMap.move_elements_from_list (T : Type) (ntable : hashmap.HashMap T) (ls : hashmap.List T) : @@ -178,7 +178,7 @@ def hashmap.HashMap.move_elements_from_list := hashmap.HashMap.move_elements_from_list_loop T ntable ls -/- [hashmap_main::hashmap::HashMap::{0}::move_elements]: loop 0: merged forward/backward function +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements]: loop 0: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ divergent def hashmap.HashMap.move_elements_loop (T : Type) (ntable : hashmap.HashMap T) @@ -191,20 +191,19 @@ divergent def hashmap.HashMap.move_elements_loop do let l ← alloc.vec.Vec.index_mut (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List - T)) slots i + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) slots i let ls := core.mem.replace (hashmap.List T) l hashmap.List.Nil let ntable0 ← hashmap.HashMap.move_elements_from_list T ntable ls let i1 ← i + 1#usize let l0 := core.mem.replace_back (hashmap.List T) l hashmap.List.Nil let slots0 ← alloc.vec.Vec.index_mut_back (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List - T)) slots i l0 + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) slots i + l0 hashmap.HashMap.move_elements_loop T ntable0 slots0 i1 else Result.ret (ntable, slots) -/- [hashmap_main::hashmap::HashMap::{0}::move_elements]: merged forward/backward function +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def hashmap.HashMap.move_elements (T : Type) (ntable : hashmap.HashMap T) @@ -213,7 +212,7 @@ def hashmap.HashMap.move_elements := hashmap.HashMap.move_elements_loop T ntable slots i -/- [hashmap_main::hashmap::HashMap::{0}::try_resize]: merged forward/backward function +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::try_resize]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def hashmap.HashMap.try_resize (T : Type) (self : hashmap.HashMap T) : Result (hashmap.HashMap T) := @@ -238,7 +237,7 @@ def hashmap.HashMap.try_resize } else Result.ret { self with max_load_factor := (i, i0) } -/- [hashmap_main::hashmap::HashMap::{0}::insert]: merged forward/backward function +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def hashmap.HashMap.insert (T : Type) (self : hashmap.HashMap T) (key : Usize) (value : T) : @@ -251,7 +250,7 @@ def hashmap.HashMap.insert then hashmap.HashMap.try_resize T self0 else Result.ret self0 -/- [hashmap_main::hashmap::HashMap::{0}::contains_key_in_list]: loop 0: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: loop 0: forward function -/ divergent def hashmap.HashMap.contains_key_in_list_loop (T : Type) (key : Usize) (ls : hashmap.List T) : Result Bool := match ls with @@ -261,12 +260,12 @@ divergent def hashmap.HashMap.contains_key_in_list_loop else hashmap.HashMap.contains_key_in_list_loop T key tl | hashmap.List.Nil => Result.ret false -/- [hashmap_main::hashmap::HashMap::{0}::contains_key_in_list]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: forward function -/ def hashmap.HashMap.contains_key_in_list (T : Type) (key : Usize) (ls : hashmap.List T) : Result Bool := hashmap.HashMap.contains_key_in_list_loop T key ls -/- [hashmap_main::hashmap::HashMap::{0}::contains_key]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key]: forward function -/ def hashmap.HashMap.contains_key (T : Type) (self : hashmap.HashMap T) (key : Usize) : Result Bool := do @@ -275,11 +274,11 @@ def hashmap.HashMap.contains_key let hash_mod ← hash % i let l ← alloc.vec.Vec.index (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) self.slots hash_mod hashmap.HashMap.contains_key_in_list T key l -/- [hashmap_main::hashmap::HashMap::{0}::get_in_list]: loop 0: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: loop 0: forward function -/ divergent def hashmap.HashMap.get_in_list_loop (T : Type) (key : Usize) (ls : hashmap.List T) : Result T := match ls with @@ -289,12 +288,12 @@ divergent def hashmap.HashMap.get_in_list_loop else hashmap.HashMap.get_in_list_loop T key tl | hashmap.List.Nil => Result.fail Error.panic -/- [hashmap_main::hashmap::HashMap::{0}::get_in_list]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: forward function -/ def hashmap.HashMap.get_in_list (T : Type) (key : Usize) (ls : hashmap.List T) : Result T := hashmap.HashMap.get_in_list_loop T key ls -/- [hashmap_main::hashmap::HashMap::{0}::get]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get]: forward function -/ def hashmap.HashMap.get (T : Type) (self : hashmap.HashMap T) (key : Usize) : Result T := do @@ -303,11 +302,11 @@ def hashmap.HashMap.get let hash_mod ← hash % i let l ← alloc.vec.Vec.index (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) self.slots hash_mod hashmap.HashMap.get_in_list T key l -/- [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: loop 0: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: loop 0: forward function -/ divergent def hashmap.HashMap.get_mut_in_list_loop (T : Type) (ls : hashmap.List T) (key : Usize) : Result T := match ls with @@ -317,12 +316,12 @@ divergent def hashmap.HashMap.get_mut_in_list_loop else hashmap.HashMap.get_mut_in_list_loop T tl key | hashmap.List.Nil => Result.fail Error.panic -/- [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: forward function -/ def hashmap.HashMap.get_mut_in_list (T : Type) (ls : hashmap.List T) (key : Usize) : Result T := hashmap.HashMap.get_mut_in_list_loop T ls key -/- [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: loop 0: backward function 0 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: loop 0: backward function 0 -/ divergent def hashmap.HashMap.get_mut_in_list_loop_back (T : Type) (ls : hashmap.List T) (key : Usize) (ret0 : T) : Result (hashmap.List T) @@ -337,14 +336,14 @@ divergent def hashmap.HashMap.get_mut_in_list_loop_back Result.ret (hashmap.List.Cons ckey cvalue tl0) | hashmap.List.Nil => Result.fail Error.panic -/- [hashmap_main::hashmap::HashMap::{0}::get_mut_in_list]: backward function 0 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: backward function 0 -/ def hashmap.HashMap.get_mut_in_list_back (T : Type) (ls : hashmap.List T) (key : Usize) (ret0 : T) : Result (hashmap.List T) := hashmap.HashMap.get_mut_in_list_loop_back T ls key ret0 -/- [hashmap_main::hashmap::HashMap::{0}::get_mut]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut]: forward function -/ def hashmap.HashMap.get_mut (T : Type) (self : hashmap.HashMap T) (key : Usize) : Result T := do @@ -353,11 +352,11 @@ def hashmap.HashMap.get_mut let hash_mod ← hash % i let l ← alloc.vec.Vec.index_mut (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) self.slots hash_mod hashmap.HashMap.get_mut_in_list T l key -/- [hashmap_main::hashmap::HashMap::{0}::get_mut]: backward function 0 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut]: backward function 0 -/ def hashmap.HashMap.get_mut_back (T : Type) (self : hashmap.HashMap T) (key : Usize) (ret0 : T) : Result (hashmap.HashMap T) @@ -368,16 +367,16 @@ def hashmap.HashMap.get_mut_back let hash_mod ← hash % i let l ← alloc.vec.Vec.index_mut (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) self.slots hash_mod let l0 ← hashmap.HashMap.get_mut_in_list_back T l key ret0 let v ← alloc.vec.Vec.index_mut_back (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) self.slots hash_mod l0 Result.ret { self with slots := v } -/- [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: loop 0: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: loop 0: forward function -/ divergent def hashmap.HashMap.remove_from_list_loop (T : Type) (key : Usize) (ls : hashmap.List T) : Result (Option T) := match ls with @@ -393,12 +392,12 @@ divergent def hashmap.HashMap.remove_from_list_loop else hashmap.HashMap.remove_from_list_loop T key tl | hashmap.List.Nil => Result.ret none -/- [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: forward function -/ def hashmap.HashMap.remove_from_list (T : Type) (key : Usize) (ls : hashmap.List T) : Result (Option T) := hashmap.HashMap.remove_from_list_loop T key ls -/- [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: loop 0: backward function 1 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: loop 0: backward function 1 -/ divergent def hashmap.HashMap.remove_from_list_loop_back (T : Type) (key : Usize) (ls : hashmap.List T) : Result (hashmap.List T) := match ls with @@ -417,12 +416,12 @@ divergent def hashmap.HashMap.remove_from_list_loop_back Result.ret (hashmap.List.Cons ckey t tl0) | hashmap.List.Nil => Result.ret hashmap.List.Nil -/- [hashmap_main::hashmap::HashMap::{0}::remove_from_list]: backward function 1 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: backward function 1 -/ def hashmap.HashMap.remove_from_list_back (T : Type) (key : Usize) (ls : hashmap.List T) : Result (hashmap.List T) := hashmap.HashMap.remove_from_list_loop_back T key ls -/- [hashmap_main::hashmap::HashMap::{0}::remove]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove]: forward function -/ def hashmap.HashMap.remove (T : Type) (self : hashmap.HashMap T) (key : Usize) : Result (Option T) := do @@ -431,7 +430,7 @@ def hashmap.HashMap.remove let hash_mod ← hash % i let l ← alloc.vec.Vec.index_mut (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) self.slots hash_mod let x ← hashmap.HashMap.remove_from_list T key l match x with @@ -440,7 +439,7 @@ def hashmap.HashMap.remove let _ ← self.num_entries - 1#usize Result.ret (some x0) -/- [hashmap_main::hashmap::HashMap::{0}::remove]: backward function 0 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove]: backward function 0 -/ def hashmap.HashMap.remove_back (T : Type) (self : hashmap.HashMap T) (key : Usize) : Result (hashmap.HashMap T) @@ -451,7 +450,7 @@ def hashmap.HashMap.remove_back let hash_mod ← hash % i let l ← alloc.vec.Vec.index_mut (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List T)) + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) self.slots hash_mod let x ← hashmap.HashMap.remove_from_list T key l match x with @@ -460,8 +459,8 @@ def hashmap.HashMap.remove_back let l0 ← hashmap.HashMap.remove_from_list_back T key l let v ← alloc.vec.Vec.index_mut_back (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List - T)) self.slots hash_mod l0 + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) + self.slots hash_mod l0 Result.ret { self with slots := v } | some x0 => do @@ -469,8 +468,8 @@ def hashmap.HashMap.remove_back let l0 ← hashmap.HashMap.remove_from_list_back T key l let v ← alloc.vec.Vec.index_mut_back (hashmap.List T) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (hashmap.List - T)) self.slots hash_mod l0 + (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) + self.slots hash_mod l0 Result.ret { self with num_entries := i0, slots := v } /- [hashmap_main::hashmap::test1]: forward function -/ diff --git a/tests/lean/Loops.lean b/tests/lean/Loops.lean index c6360338..701dc6f7 100644 --- a/tests/lean/Loops.lean +++ b/tests/lean/Loops.lean @@ -59,7 +59,7 @@ divergent def clear_loop let i1 ← i + 1#usize let v0 ← alloc.vec.Vec.index_mut_back U32 Usize - (core.slice.index.usize.coresliceindexSliceIndexInst U32) v i 0#u32 + (core.slice.index.SliceIndexUsizeSliceTInst U32) v i 0#u32 clear_loop v0 i1 else Result.ret v @@ -150,8 +150,7 @@ def get_elem_mut do let l ← alloc.vec.Vec.index_mut (List Usize) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) - slots 0#usize + (core.slice.index.SliceIndexUsizeSliceTInst (List Usize)) slots 0#usize get_elem_mut_loop x l /- [loops::get_elem_mut]: loop 0: backward function 0 -/ @@ -175,12 +174,11 @@ def get_elem_mut_back do let l ← alloc.vec.Vec.index_mut (List Usize) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) - slots 0#usize + (core.slice.index.SliceIndexUsizeSliceTInst (List Usize)) slots 0#usize let l0 ← get_elem_mut_loop_back x l ret0 alloc.vec.Vec.index_mut_back (List Usize) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) slots - 0#usize l0 + (core.slice.index.SliceIndexUsizeSliceTInst (List Usize)) slots 0#usize + l0 /- [loops::get_elem_shared]: loop 0: forward function -/ divergent def get_elem_shared_loop @@ -197,8 +195,7 @@ def get_elem_shared do let l ← alloc.vec.Vec.index (List Usize) Usize - (core.slice.index.usize.coresliceindexSliceIndexInst (List Usize)) - slots 0#usize + (core.slice.index.SliceIndexUsizeSliceTInst (List Usize)) slots 0#usize get_elem_shared_loop x l /- [loops::id_mut]: forward function -/ -- cgit v1.2.3 From 46ab0fc047c69d14e52415bd8b76be167771cd58 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 21 Nov 2023 11:46:10 +0100 Subject: Regenerate the Traits files --- tests/lean/Traits.lean | 132 +++++++++++++++++++++++++------------------------ 1 file changed, 67 insertions(+), 65 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Traits.lean b/tests/lean/Traits.lean index 12e7eafa..51a05581 100644 --- a/tests/lean/Traits.lean +++ b/tests/lean/Traits.lean @@ -9,12 +9,12 @@ namespace traits structure BoolTrait (Self : Type) where get_bool : Self → Result Bool -/- [traits::Bool::{0}::get_bool]: forward function -/ +/- [traits::{bool}::get_bool]: forward function -/ def Bool.get_bool (self : Bool) : Result Bool := Result.ret self -/- Trait implementation: [traits::Bool::{0}] -/ -def Bool.BoolTraitInst : BoolTrait Bool := { +/- Trait implementation: [traits::{bool}] -/ +def traits.BoolTraitBoolInst : BoolTrait Bool := { get_bool := Bool.get_bool } @@ -28,17 +28,18 @@ def test_bool_trait_bool (x : Bool) : Result Bool := do let b ← Bool.get_bool x if b - then BoolTrait.ret_true Bool.BoolTraitInst x + then BoolTrait.ret_true traits.BoolTraitBoolInst x else Result.ret false -/- [traits::Option::{1}::get_bool]: forward function -/ +/- [traits::{core::option::Option#1}::get_bool]: forward function -/ def Option.get_bool (T : Type) (self : Option T) : Result Bool := match self with | none => Result.ret false | some t => Result.ret true -/- Trait implementation: [traits::Option::{1}] -/ -def Option.BoolTraitInst (T : Type) : BoolTrait (Option T) := { +/- Trait implementation: [traits::{core::option::Option#1}] -/ +def traits.BoolTraitcoreoptionOptionTInst (T : Type) : BoolTrait (Option T) + := { get_bool := Option.get_bool T } @@ -47,7 +48,7 @@ def test_bool_trait_option (T : Type) (x : Option T) : Result Bool := do let b ← Option.get_bool T x if b - then BoolTrait.ret_true (Option.BoolTraitInst T) x + then BoolTrait.ret_true (traits.BoolTraitcoreoptionOptionTInst T) x else Result.ret false /- [traits::test_bool_trait]: forward function -/ @@ -58,31 +59,31 @@ def test_bool_trait (T : Type) (inst : BoolTrait T) (x : T) : Result Bool := structure ToU64 (Self : Type) where to_u64 : Self → Result U64 -/- [traits::u64::{2}::to_u64]: forward function -/ -def u64.to_u64 (self : U64) : Result U64 := +/- [traits::{u64#2}::to_u64]: forward function -/ +def U64.to_u64 (self : U64) : Result U64 := Result.ret self -/- Trait implementation: [traits::u64::{2}] -/ -def u64.ToU64Inst : ToU64 U64 := { - to_u64 := u64.to_u64 +/- Trait implementation: [traits::{u64#2}] -/ +def traits.ToU64U64Inst : ToU64 U64 := { + to_u64 := U64.to_u64 } -/- [traits::Tuple2::{3}::to_u64]: forward function -/ -def Tuple2.to_u64 (A : Type) (inst : ToU64 A) (self : (A × A)) : Result U64 := +/- [traits::{(A, A)#3}::to_u64]: forward function -/ +def Pair.to_u64 (A : Type) (inst : ToU64 A) (self : (A × A)) : Result U64 := do let (t, t0) := self let i ← inst.to_u64 t let i0 ← inst.to_u64 t0 i + i0 -/- Trait implementation: [traits::Tuple2::{3}] -/ -def Tuple2.ToU64Inst (A : Type) (inst : ToU64 A) : ToU64 (A × A) := { - to_u64 := Tuple2.to_u64 A inst +/- Trait implementation: [traits::{(A, A)#3}] -/ +def traits.ToU64TupleAAInst (A : Type) (inst : ToU64 A) : ToU64 (A × A) := { + to_u64 := Pair.to_u64 A inst } /- [traits::f]: forward function -/ def f (T : Type) (inst : ToU64 T) (x : (T × T)) : Result U64 := - Tuple2.to_u64 T inst x + Pair.to_u64 T inst x /- [traits::g]: forward function -/ def g (T : Type) (inst : ToU64 (T × T)) (x : (T × T)) : Result U64 := @@ -90,25 +91,26 @@ def g (T : Type) (inst : ToU64 (T × T)) (x : (T × T)) : Result U64 := /- [traits::h0]: forward function -/ def h0 (x : U64) : Result U64 := - u64.to_u64 x + U64.to_u64 x /- [traits::Wrapper] -/ structure Wrapper (T : Type) where x : T -/- [traits::Wrapper::{4}::to_u64]: forward function -/ +/- [traits::{traits::Wrapper#4}::to_u64]: forward function -/ def Wrapper.to_u64 (T : Type) (inst : ToU64 T) (self : Wrapper T) : Result U64 := inst.to_u64 self.x -/- Trait implementation: [traits::Wrapper::{4}] -/ -def Wrapper.ToU64Inst (T : Type) (inst : ToU64 T) : ToU64 (Wrapper T) := { +/- Trait implementation: [traits::{traits::Wrapper#4}] -/ +def traits.ToU64traitsWrapperTInst (T : Type) (inst : ToU64 T) : ToU64 (Wrapper + T) := { to_u64 := Wrapper.to_u64 T inst } /- [traits::h1]: forward function -/ def h1 (x : Wrapper U64) : Result U64 := - Wrapper.to_u64 U64 u64.ToU64Inst x + Wrapper.to_u64 U64 traits.ToU64U64Inst x /- [traits::h2]: forward function -/ def h2 (T : Type) (inst : ToU64 T) (x : Wrapper T) : Result U64 := @@ -118,13 +120,13 @@ def h2 (T : Type) (inst : ToU64 T) (x : Wrapper T) : Result U64 := structure ToType (Self T : Type) where to_type : Self → Result T -/- [traits::u64::{5}::to_type]: forward function -/ -def u64.to_type (self : U64) : Result Bool := +/- [traits::{u64#5}::to_type]: forward function -/ +def U64.to_type (self : U64) : Result Bool := Result.ret (self > 0#u64) -/- Trait implementation: [traits::u64::{5}] -/ -def u64.ToTypeInst : ToType U64 Bool := { - to_type := u64.to_type +/- Trait implementation: [traits::{u64#5}] -/ +def traits.ToTypeU64BoolInst : ToType U64 Bool := { + to_type := U64.to_type } /- Trait declaration: [traits::OfType] -/ @@ -154,26 +156,26 @@ def h4 structure TestType (T : Type) where _0 : T -/- [traits::TestType::{6}::test::TestType1] -/ +/- [traits::{traits::TestType#6}::test::TestType1] -/ structure TestType.test.TestType1 where _0 : U64 -/- Trait declaration: [traits::TestType::{6}::test::TestTrait] -/ +/- Trait declaration: [traits::{traits::TestType#6}::test::TestTrait] -/ structure TestType.test.TestTrait (Self : Type) where test : Self → Result Bool -/- [traits::TestType::{6}::test::TestType1::{0}::test]: forward function -/ +/- [traits::{traits::TestType#6}::test::{traits::{traits::TestType#6}::test::TestType1}::test]: forward function -/ def TestType.test.TestType1.test (self : TestType.test.TestType1) : Result Bool := Result.ret (self._0 > 1#u64) -/- Trait implementation: [traits::TestType::{6}::test::TestType1::{0}] -/ -def TestType.test.TestType1.TestTypetestTestTraitInst : TestType.test.TestTrait - TestType.test.TestType1 := { +/- Trait implementation: [traits::{traits::TestType#6}::test::{traits::{traits::TestType#6}::test::TestType1}] -/ +def traits.TestType.test.TestTraittraitstraitsTestTypeTtestTestType1Inst : + TestType.test.TestTrait TestType.test.TestType1 := { test := TestType.test.TestType1.test } -/- [traits::TestType::{6}::test]: forward function -/ +/- [traits::{traits::TestType#6}::test]: forward function -/ def TestType.test (T : Type) (inst : ToU64 T) (self : TestType T) (x : T) : Result Bool := do @@ -186,14 +188,14 @@ def TestType.test structure BoolWrapper where _0 : Bool -/- [traits::BoolWrapper::{7}::to_type]: forward function -/ +/- [traits::{traits::BoolWrapper#7}::to_type]: forward function -/ def BoolWrapper.to_type (T : Type) (inst : ToType Bool T) (self : BoolWrapper) : Result T := inst.to_type self._0 -/- Trait implementation: [traits::BoolWrapper::{7}] -/ -def BoolWrapper.ToTypeInst (T : Type) (inst : ToType Bool T) : ToType - BoolWrapper T := { +/- Trait implementation: [traits::{traits::BoolWrapper#7}] -/ +def traits.ToTypetraitsBoolWrapperTInst (T : Type) (inst : ToType Bool T) : + ToType BoolWrapper T := { to_type := BoolWrapper.to_type T inst } @@ -211,22 +213,22 @@ structure WithConstTy (Self : Type) (LEN : Usize) where W_clause_0 : ToU64 W f : W → Array U8 LEN → Result W -/- [traits::Bool::{8}::LEN1] -/ +/- [traits::{bool#8}::LEN1] -/ def bool_len1_body : Result Usize := Result.ret 12#usize def bool_len1_c : Usize := eval_global bool_len1_body (by simp) -/- [traits::Bool::{8}::f]: merged forward/backward function +/- [traits::{bool#8}::f]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def Bool.f (i : U64) (a : Array U8 32#usize) : Result U64 := Result.ret i -/- Trait implementation: [traits::Bool::{8}] -/ -def Bool.WithConstTyInst : WithConstTy Bool 32#usize := { +/- Trait implementation: [traits::{bool#8}] -/ +def traits.WithConstTyBool32Inst : WithConstTy Bool 32#usize := { LEN1 := bool_len1_c LEN2 := with_const_ty_len2_c V := U8 W := U64 - W_clause_0 := u64.ToU64Inst + W_clause_0 := traits.ToU64U64Inst f := Bool.f } @@ -297,13 +299,13 @@ def order1 structure ChildTrait1 (Self : Type) where parent_clause_0 : ParentTrait1 Self -/- Trait implementation: [traits::usize::{9}] -/ -def usize.ParentTrait1Inst : ParentTrait1 Usize := { +/- Trait implementation: [traits::{usize#9}] -/ +def traits.ParentTrait1UsizeInst : ParentTrait1 Usize := { } -/- Trait implementation: [traits::usize::{10}] -/ -def usize.ChildTrait1Inst : ChildTrait1 Usize := { - parent_clause_0 := usize.ParentTrait1Inst +/- Trait implementation: [traits::{usize#10}] -/ +def traits.ChildTrait1UsizeInst : ChildTrait1 Usize := { + parent_clause_0 := traits.ParentTrait1UsizeInst } /- Trait declaration: [traits::Iterator] -/ @@ -339,31 +341,27 @@ structure ChildTrait2 (Self : Type) where parent_clause_0 : ParentTrait2 Self convert : parent_clause_0.U → Result parent_clause_0.U_clause_0.Target -/- Trait implementation: [traits::u32::{11}] -/ -def u32.WithTargetInst : WithTarget U32 := { +/- Trait implementation: [traits::{u32#11}] -/ +def traits.WithTargetU32Inst : WithTarget U32 := { Target := U32 } -/- Trait implementation: [traits::u32::{12}] -/ -def u32.ParentTrait2Inst : ParentTrait2 U32 := { +/- Trait implementation: [traits::{u32#12}] -/ +def traits.ParentTrait2U32Inst : ParentTrait2 U32 := { U := U32 - U_clause_0 := u32.WithTargetInst + U_clause_0 := traits.WithTargetU32Inst } -/- [traits::u32::{13}::convert]: forward function -/ -def u32.convert (x : U32) : Result U32 := +/- [traits::{u32#13}::convert]: forward function -/ +def U32.convert (x : U32) : Result U32 := Result.ret x -/- Trait implementation: [traits::u32::{13}] -/ -def u32.ChildTrait2Inst : ChildTrait2 U32 := { - parent_clause_0 := u32.ParentTrait2Inst - convert := u32.convert +/- Trait implementation: [traits::{u32#13}] -/ +def traits.ChildTrait2U32Inst : ChildTrait2 U32 := { + parent_clause_0 := traits.ParentTrait2U32Inst + convert := U32.convert } -/- [traits::incr_u32]: forward function -/ -def incr_u32 (x : U32) : Result U32 := - x + 1#u32 - /- Trait declaration: [traits::CFnOnce] -/ structure CFnOnce (Self Args : Type) where Output : Type @@ -380,4 +378,8 @@ structure CFn (Self Args : Type) where parent_clause_0 : CFnMut Self Args call_mut : Self → Args → Result parent_clause_0.parent_clause_0.Output +/- [traits::incr_u32]: forward function -/ +def incr_u32 (x : U32) : Result U32 := + x + 1#u32 + end traits -- cgit v1.2.3 From 753f7e72f87f5282aee60ad5ada47efeb42625e9 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 21 Nov 2023 11:50:44 +0100 Subject: Regenerate the betree files --- tests/lean/BetreeMain/Funs.lean | 114 +++++++++++------------ tests/lean/BetreeMain/FunsExternal_Template.lean | 2 +- 2 files changed, 58 insertions(+), 58 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/BetreeMain/Funs.lean b/tests/lean/BetreeMain/Funs.lean index 0901d449..441a3721 100644 --- a/tests/lean/BetreeMain/Funs.lean +++ b/tests/lean/BetreeMain/Funs.lean @@ -47,17 +47,17 @@ def betree.fresh_node_id (counter : U64) : Result U64 := def betree.fresh_node_id_back (counter : U64) : Result U64 := counter + 1#u64 -/- [betree_main::betree::NodeIdCounter::{0}::new]: forward function -/ +/- [betree_main::betree::{betree_main::betree::NodeIdCounter}::new]: forward function -/ def betree.NodeIdCounter.new : Result betree.NodeIdCounter := Result.ret { next_node_id := 0#u64 } -/- [betree_main::betree::NodeIdCounter::{0}::fresh_id]: forward function -/ +/- [betree_main::betree::{betree_main::betree::NodeIdCounter}::fresh_id]: forward function -/ def betree.NodeIdCounter.fresh_id (self : betree.NodeIdCounter) : Result U64 := do let _ ← self.next_node_id + 1#u64 Result.ret self.next_node_id -/- [betree_main::betree::NodeIdCounter::{0}::fresh_id]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::NodeIdCounter}::fresh_id]: backward function 0 -/ def betree.NodeIdCounter.fresh_id_back (self : betree.NodeIdCounter) : Result betree.NodeIdCounter := do @@ -85,7 +85,7 @@ def betree.upsert_update then prev0 - v else Result.ret 0#u64 -/- [betree_main::betree::List::{1}::len]: forward function -/ +/- [betree_main::betree::{betree_main::betree::List#1}::len]: forward function -/ divergent def betree.List.len (T : Type) (self : betree.List T) : Result U64 := match self with | betree.List.Cons t tl => do @@ -93,7 +93,7 @@ divergent def betree.List.len (T : Type) (self : betree.List T) : Result U64 := 1#u64 + i | betree.List.Nil => Result.ret 0#u64 -/- [betree_main::betree::List::{1}::split_at]: forward function -/ +/- [betree_main::betree::{betree_main::betree::List#1}::split_at]: forward function -/ divergent def betree.List.split_at (T : Type) (self : betree.List T) (n : U64) : Result ((betree.List T) × (betree.List T)) @@ -111,7 +111,7 @@ divergent def betree.List.split_at Result.ret (betree.List.Cons hd l, ls1) | betree.List.Nil => Result.fail Error.panic -/- [betree_main::betree::List::{1}::push_front]: merged forward/backward function +/- [betree_main::betree::{betree_main::betree::List#1}::push_front]: merged forward/backward function (there is a single backward function, and the forward function returns ()) -/ def betree.List.push_front (T : Type) (self : betree.List T) (x : T) : Result (betree.List T) := @@ -119,14 +119,14 @@ def betree.List.push_front let l := tl Result.ret (betree.List.Cons x l) -/- [betree_main::betree::List::{1}::pop_front]: forward function -/ +/- [betree_main::betree::{betree_main::betree::List#1}::pop_front]: forward function -/ def betree.List.pop_front (T : Type) (self : betree.List T) : Result T := let ls := core.mem.replace (betree.List T) self betree.List.Nil match ls with | betree.List.Cons x tl => Result.ret x | betree.List.Nil => Result.fail Error.panic -/- [betree_main::betree::List::{1}::pop_front]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::List#1}::pop_front]: backward function 0 -/ def betree.List.pop_front_back (T : Type) (self : betree.List T) : Result (betree.List T) := let ls := core.mem.replace (betree.List T) self betree.List.Nil @@ -134,22 +134,22 @@ def betree.List.pop_front_back | betree.List.Cons x tl => Result.ret tl | betree.List.Nil => Result.fail Error.panic -/- [betree_main::betree::List::{1}::hd]: forward function -/ +/- [betree_main::betree::{betree_main::betree::List#1}::hd]: forward function -/ def betree.List.hd (T : Type) (self : betree.List T) : Result T := match self with | betree.List.Cons hd l => Result.ret hd | betree.List.Nil => Result.fail Error.panic -/- [betree_main::betree::List::{2}::head_has_key]: forward function -/ -def betree.List.head_has_key +/- [betree_main::betree::{betree_main::betree::List<(u64, T)>#2}::head_has_key]: forward function -/ +def betree.ListTupleU64T.head_has_key (T : Type) (self : betree.List (U64 × T)) (key : U64) : Result Bool := match self with | betree.List.Cons hd l => let (i, _) := hd Result.ret (i = key) | betree.List.Nil => Result.ret false -/- [betree_main::betree::List::{2}::partition_at_pivot]: forward function -/ -divergent def betree.List.partition_at_pivot +/- [betree_main::betree::{betree_main::betree::List<(u64, T)>#2}::partition_at_pivot]: forward function -/ +divergent def betree.ListTupleU64T.partition_at_pivot (T : Type) (self : betree.List (U64 × T)) (pivot : U64) : Result ((betree.List (U64 × T)) × (betree.List (U64 × T))) := @@ -160,13 +160,13 @@ divergent def betree.List.partition_at_pivot then Result.ret (betree.List.Nil, betree.List.Cons (i, t) tl) else do - let p ← betree.List.partition_at_pivot T tl pivot + let p ← betree.ListTupleU64T.partition_at_pivot T tl pivot let (ls0, ls1) := p let l := ls0 Result.ret (betree.List.Cons (i, t) l, ls1) | betree.List.Nil => Result.ret (betree.List.Nil, betree.List.Nil) -/- [betree_main::betree::Leaf::{3}::split]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Leaf#3}::split]: forward function -/ def betree.Leaf.split (self : betree.Leaf) (content : betree.List (U64 × U64)) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) (st : State) : @@ -186,7 +186,7 @@ def betree.Leaf.split let n0 := betree.Node.Leaf { id := id1, size := params.split_size } Result.ret (st1, betree.Internal.mk self.id pivot n n0) -/- [betree_main::betree::Leaf::{3}::split]: backward function 2 -/ +/- [betree_main::betree::{betree_main::betree::Leaf#3}::split]: backward function 2 -/ def betree.Leaf.split_back (self : betree.Leaf) (content : betree.List (U64 × U64)) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) (st : State) : @@ -203,7 +203,7 @@ def betree.Leaf.split_back let _ ← betree.store_leaf_node id1 content1 st0 betree.NodeIdCounter.fresh_id_back node_id_cnt0 -/- [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]: forward function -/ divergent def betree.Node.lookup_first_message_for_key (key : U64) (msgs : betree.List (U64 × betree.Message)) : Result (betree.List (U64 × betree.Message)) @@ -216,7 +216,7 @@ divergent def betree.Node.lookup_first_message_for_key else betree.Node.lookup_first_message_for_key key next_msgs | betree.List.Nil => Result.ret betree.List.Nil -/- [betree_main::betree::Node::{5}::lookup_first_message_for_key]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::lookup_first_message_for_key]: backward function 0 -/ divergent def betree.Node.lookup_first_message_for_key_back (key : U64) (msgs : betree.List (U64 × betree.Message)) (ret0 : betree.List (U64 × betree.Message)) : @@ -234,14 +234,14 @@ divergent def betree.Node.lookup_first_message_for_key_back Result.ret (betree.List.Cons (i, m) next_msgs0) | betree.List.Nil => Result.ret ret0 -/- [betree_main::betree::Node::{5}::apply_upserts]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::apply_upserts]: forward function -/ divergent def betree.Node.apply_upserts (msgs : betree.List (U64 × betree.Message)) (prev : Option U64) (key : U64) (st : State) : Result (State × U64) := do - let b ← betree.List.head_has_key betree.Message msgs key + let b ← betree.ListTupleU64T.head_has_key betree.Message msgs key if b then do @@ -264,14 +264,14 @@ divergent def betree.Node.apply_upserts betree.Message.Insert v) Result.ret (st0, v) -/- [betree_main::betree::Node::{5}::apply_upserts]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::apply_upserts]: backward function 0 -/ divergent def betree.Node.apply_upserts_back (msgs : betree.List (U64 × betree.Message)) (prev : Option U64) (key : U64) (st : State) : Result (betree.List (U64 × betree.Message)) := do - let b ← betree.List.head_has_key betree.Message msgs key + let b ← betree.ListTupleU64T.head_has_key betree.Message msgs key if b then do @@ -292,7 +292,7 @@ divergent def betree.Node.apply_upserts_back betree.List.push_front (U64 × betree.Message) msgs (key, betree.Message.Insert v) -/- [betree_main::betree::Node::{5}::lookup_in_bindings]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::lookup_in_bindings]: forward function -/ divergent def betree.Node.lookup_in_bindings (key : U64) (bindings : betree.List (U64 × U64)) : Result (Option U64) := match bindings with @@ -306,7 +306,7 @@ divergent def betree.Node.lookup_in_bindings else betree.Node.lookup_in_bindings key tl | betree.List.Nil => Result.ret none -/- [betree_main::betree::Internal::{4}::lookup_in_children]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Internal#4}::lookup_in_children]: forward function -/ mutual divergent def betree.Internal.lookup_in_children (self : betree.Internal) (key : U64) (st : State) : Result (State × (Option U64)) @@ -316,7 +316,7 @@ mutual divergent def betree.Internal.lookup_in_children then betree.Node.lookup n key st else betree.Node.lookup n0 key st -/- [betree_main::betree::Internal::{4}::lookup_in_children]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Internal#4}::lookup_in_children]: backward function 0 -/ divergent def betree.Internal.lookup_in_children_back (self : betree.Internal) (key : U64) (st : State) : Result betree.Internal := let ⟨ i, i0, n, n0 ⟩ := self @@ -330,7 +330,7 @@ divergent def betree.Internal.lookup_in_children_back let n1 ← betree.Node.lookup_back n0 key st Result.ret (betree.Internal.mk i i0 n n1) -/- [betree_main::betree::Node::{5}::lookup]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::lookup]: forward function -/ divergent def betree.Node.lookup (self : betree.Node) (key : U64) (st : State) : Result (State × (Option U64)) @@ -402,7 +402,7 @@ divergent def betree.Node.lookup let o ← betree.Node.lookup_in_bindings key bindings Result.ret (st0, o) -/- [betree_main::betree::Node::{5}::lookup]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::lookup]: backward function 0 -/ divergent def betree.Node.lookup_back (self : betree.Node) (key : U64) (st : State) : Result betree.Node := match self with @@ -475,7 +475,7 @@ divergent def betree.Node.lookup_back end -/- [betree_main::betree::Node::{5}::filter_messages_for_key]: merged forward/backward function +/- [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 ()) -/ divergent def betree.Node.filter_messages_for_key (key : U64) (msgs : betree.List (U64 × betree.Message)) : @@ -494,7 +494,7 @@ divergent def betree.Node.filter_messages_for_key else Result.ret (betree.List.Cons (k, m) l) | betree.List.Nil => Result.ret betree.List.Nil -/- [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]: forward function -/ divergent def betree.Node.lookup_first_message_after_key (key : U64) (msgs : betree.List (U64 × betree.Message)) : Result (betree.List (U64 × betree.Message)) @@ -507,7 +507,7 @@ divergent def betree.Node.lookup_first_message_after_key else Result.ret (betree.List.Cons (k, m) next_msgs) | betree.List.Nil => Result.ret betree.List.Nil -/- [betree_main::betree::Node::{5}::lookup_first_message_after_key]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::lookup_first_message_after_key]: backward function 0 -/ divergent def betree.Node.lookup_first_message_after_key_back (key : U64) (msgs : betree.List (U64 × betree.Message)) (ret0 : betree.List (U64 × betree.Message)) : @@ -525,7 +525,7 @@ divergent def betree.Node.lookup_first_message_after_key_back else Result.ret ret0 | betree.List.Nil => Result.ret ret0 -/- [betree_main::betree::Node::{5}::apply_to_internal]: merged forward/backward function +/- [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 ()) -/ def betree.Node.apply_to_internal (msgs : betree.List (U64 × betree.Message)) (key : U64) @@ -534,7 +534,7 @@ def betree.Node.apply_to_internal := do let msgs0 ← betree.Node.lookup_first_message_for_key key msgs - let b ← betree.List.head_has_key betree.Message msgs0 key + let b ← betree.ListTupleU64T.head_has_key betree.Message msgs0 key if b then match new_msg with @@ -591,7 +591,7 @@ def betree.Node.apply_to_internal betree.List.push_front (U64 × betree.Message) msgs0 (key, new_msg) betree.Node.lookup_first_message_for_key_back key msgs msgs1 -/- [betree_main::betree::Node::{5}::apply_messages_to_internal]: merged forward/backward function +/- [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 ()) -/ divergent def betree.Node.apply_messages_to_internal (msgs : betree.List (U64 × betree.Message)) @@ -606,7 +606,7 @@ divergent def betree.Node.apply_messages_to_internal betree.Node.apply_messages_to_internal msgs0 new_msgs_tl | betree.List.Nil => Result.ret msgs -/- [betree_main::betree::Node::{5}::lookup_mut_in_bindings]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::lookup_mut_in_bindings]: forward function -/ divergent def betree.Node.lookup_mut_in_bindings (key : U64) (bindings : betree.List (U64 × U64)) : Result (betree.List (U64 × U64)) @@ -619,7 +619,7 @@ divergent def betree.Node.lookup_mut_in_bindings else betree.Node.lookup_mut_in_bindings key tl | betree.List.Nil => Result.ret betree.List.Nil -/- [betree_main::betree::Node::{5}::lookup_mut_in_bindings]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::lookup_mut_in_bindings]: backward function 0 -/ divergent def betree.Node.lookup_mut_in_bindings_back (key : U64) (bindings : betree.List (U64 × U64)) (ret0 : betree.List (U64 × U64)) : @@ -636,7 +636,7 @@ divergent def betree.Node.lookup_mut_in_bindings_back Result.ret (betree.List.Cons (i, i0) tl0) | betree.List.Nil => Result.ret ret0 -/- [betree_main::betree::Node::{5}::apply_to_leaf]: merged forward/backward function +/- [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 ()) -/ def betree.Node.apply_to_leaf (bindings : betree.List (U64 × U64)) (key : U64) (new_msg : betree.Message) @@ -645,7 +645,7 @@ def betree.Node.apply_to_leaf := do let bindings0 ← betree.Node.lookup_mut_in_bindings key bindings - let b ← betree.List.head_has_key U64 bindings0 key + let b ← betree.ListTupleU64T.head_has_key U64 bindings0 key if b then do @@ -685,7 +685,7 @@ def betree.Node.apply_to_leaf betree.List.push_front (U64 × U64) bindings0 (key, v) betree.Node.lookup_mut_in_bindings_back key bindings bindings1 -/- [betree_main::betree::Node::{5}::apply_messages_to_leaf]: merged forward/backward function +/- [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 ()) -/ divergent def betree.Node.apply_messages_to_leaf (bindings : betree.List (U64 × U64)) @@ -700,7 +700,7 @@ divergent def betree.Node.apply_messages_to_leaf betree.Node.apply_messages_to_leaf bindings0 new_msgs_tl | betree.List.Nil => Result.ret bindings -/- [betree_main::betree::Internal::{4}::flush]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Internal#4}::flush]: forward function -/ mutual divergent def betree.Internal.flush (self : betree.Internal) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) @@ -709,7 +709,7 @@ mutual divergent def betree.Internal.flush := do let ⟨ _, i, n, n0 ⟩ := self - let p ← betree.List.partition_at_pivot betree.Message content i + let p ← betree.ListTupleU64T.partition_at_pivot betree.Message content i let (msgs_left, msgs_right) := p let len_left ← betree.List.len (U64 × betree.Message) msgs_left if len_left >= params.min_flush_size @@ -738,7 +738,7 @@ mutual divergent def betree.Internal.flush betree.Node.apply_messages_back n0 params node_id_cnt msgs_right st Result.ret (st0, msgs_left) -/- [betree_main::betree::Internal::{4}::flush]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Internal#4}::flush]: backward function 0 -/ divergent def betree.Internal.flush_back (self : betree.Internal) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) @@ -747,7 +747,7 @@ divergent def betree.Internal.flush_back := do let ⟨ i, i0, n, n0 ⟩ := self - let p ← betree.List.partition_at_pivot betree.Message content i0 + let p ← betree.ListTupleU64T.partition_at_pivot betree.Message content i0 let (msgs_left, msgs_right) := p let len_left ← betree.List.len (U64 × betree.Message) msgs_left if len_left >= params.min_flush_size @@ -772,7 +772,7 @@ divergent def betree.Internal.flush_back betree.Node.apply_messages_back n0 params node_id_cnt msgs_right st Result.ret (betree.Internal.mk i i0 n n1, node_id_cnt0) -/- [betree_main::betree::Node::{5}::apply_messages]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::apply_messages]: forward function -/ divergent def betree.Node.apply_messages (self : betree.Node) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) @@ -820,7 +820,7 @@ divergent def betree.Node.apply_messages let (st1, _) ← betree.store_leaf_node node.id content0 st0 Result.ret (st1, ()) -/- [betree_main::betree::Node::{5}::apply_messages]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::apply_messages]: backward function 0 -/ divergent def betree.Node.apply_messages_back (self : betree.Node) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) @@ -874,7 +874,7 @@ divergent def betree.Node.apply_messages_back end -/- [betree_main::betree::Node::{5}::apply]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::apply]: forward function -/ def betree.Node.apply (self : betree.Node) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) (key : U64) (new_msg : betree.Message) @@ -891,7 +891,7 @@ def betree.Node.apply (key, new_msg) l) st Result.ret (st0, ()) -/- [betree_main::betree::Node::{5}::apply]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::apply]: backward function 0 -/ def betree.Node.apply_back (self : betree.Node) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) (key : U64) (new_msg : betree.Message) @@ -902,7 +902,7 @@ def betree.Node.apply_back betree.Node.apply_messages_back self params node_id_cnt (betree.List.Cons (key, new_msg) l) st -/- [betree_main::betree::BeTree::{6}::new]: forward function -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::new]: forward function -/ def betree.BeTree.new (min_flush_size : U64) (split_size : U64) (st : State) : Result (State × betree.BeTree) @@ -920,7 +920,7 @@ def betree.BeTree.new root := (betree.Node.Leaf { id := id, size := 0#u64 }) }) -/- [betree_main::betree::BeTree::{6}::apply]: forward function -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::apply]: forward function -/ def betree.BeTree.apply (self : betree.BeTree) (key : U64) (msg : betree.Message) (st : State) : Result (State × Unit) @@ -932,7 +932,7 @@ def betree.BeTree.apply betree.Node.apply_back self.root self.params self.node_id_cnt key msg st Result.ret (st0, ()) -/- [betree_main::betree::BeTree::{6}::apply]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::apply]: backward function 0 -/ def betree.BeTree.apply_back (self : betree.BeTree) (key : U64) (msg : betree.Message) (st : State) : Result betree.BeTree @@ -942,7 +942,7 @@ def betree.BeTree.apply_back betree.Node.apply_back self.root self.params self.node_id_cnt key msg st Result.ret { self with node_id_cnt := nic, root := n } -/- [betree_main::betree::BeTree::{6}::insert]: forward function -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::insert]: forward function -/ def betree.BeTree.insert (self : betree.BeTree) (key : U64) (value : U64) (st : State) : Result (State × Unit) @@ -954,14 +954,14 @@ def betree.BeTree.insert betree.BeTree.apply_back self key (betree.Message.Insert value) st Result.ret (st0, ()) -/- [betree_main::betree::BeTree::{6}::insert]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::insert]: backward function 0 -/ def betree.BeTree.insert_back (self : betree.BeTree) (key : U64) (value : U64) (st : State) : Result betree.BeTree := betree.BeTree.apply_back self key (betree.Message.Insert value) st -/- [betree_main::betree::BeTree::{6}::delete]: forward function -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::delete]: forward function -/ def betree.BeTree.delete (self : betree.BeTree) (key : U64) (st : State) : Result (State × Unit) := do @@ -969,12 +969,12 @@ def betree.BeTree.delete let _ ← betree.BeTree.apply_back self key betree.Message.Delete st Result.ret (st0, ()) -/- [betree_main::betree::BeTree::{6}::delete]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::delete]: backward function 0 -/ def betree.BeTree.delete_back (self : betree.BeTree) (key : U64) (st : State) : Result betree.BeTree := betree.BeTree.apply_back self key betree.Message.Delete st -/- [betree_main::betree::BeTree::{6}::upsert]: forward function -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::upsert]: forward function -/ def betree.BeTree.upsert (self : betree.BeTree) (key : U64) (upd : betree.UpsertFunState) (st : State) : @@ -986,7 +986,7 @@ def betree.BeTree.upsert let _ ← betree.BeTree.apply_back self key (betree.Message.Upsert upd) st Result.ret (st0, ()) -/- [betree_main::betree::BeTree::{6}::upsert]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::upsert]: backward function 0 -/ def betree.BeTree.upsert_back (self : betree.BeTree) (key : U64) (upd : betree.UpsertFunState) (st : State) : @@ -994,14 +994,14 @@ def betree.BeTree.upsert_back := betree.BeTree.apply_back self key (betree.Message.Upsert upd) st -/- [betree_main::betree::BeTree::{6}::lookup]: forward function -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::lookup]: forward function -/ def betree.BeTree.lookup (self : betree.BeTree) (key : U64) (st : State) : Result (State × (Option U64)) := betree.Node.lookup self.root key st -/- [betree_main::betree::BeTree::{6}::lookup]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::lookup]: backward function 0 -/ def betree.BeTree.lookup_back (self : betree.BeTree) (key : U64) (st : State) : Result betree.BeTree := do diff --git a/tests/lean/BetreeMain/FunsExternal_Template.lean b/tests/lean/BetreeMain/FunsExternal_Template.lean index 430d2dda..1dc3af0e 100644 --- a/tests/lean/BetreeMain/FunsExternal_Template.lean +++ b/tests/lean/BetreeMain/FunsExternal_Template.lean @@ -24,7 +24,7 @@ axiom betree_utils.load_leaf_node axiom betree_utils.store_leaf_node : U64 → betree.List (U64 × U64) → State → Result (State × Unit) -/- [core::option::Option::{0}::unwrap]: forward function -/ +/- [core::option::{core::option::Option}::unwrap]: forward function -/ axiom core.option.Option.unwrap (T : Type) : Option T → State → Result (State × T) -- cgit v1.2.3 From 137cc7335e64fcb70c254e7fd2a6fa353fb43e61 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 21 Nov 2023 14:57:38 +0100 Subject: Regenerate the files --- tests/lean/Array.lean | 189 ++++++++++++------- tests/lean/BetreeMain/Funs.lean | 168 +++++++++++------ tests/lean/BetreeMain/FunsExternal_Template.lean | 15 +- tests/lean/BetreeMain/Types.lean | 27 ++- tests/lean/Constants.lean | 84 ++++++--- tests/lean/External/Funs.lean | 27 ++- tests/lean/External/FunsExternal_Template.lean | 15 +- tests/lean/External/Types.lean | 3 +- tests/lean/Hashmap/Funs.lean | 114 +++++++---- tests/lean/Hashmap/Types.lean | 6 +- tests/lean/HashmapMain/Funs.lean | 120 ++++++++---- tests/lean/HashmapMain/FunsExternal_Template.lean | 6 +- tests/lean/HashmapMain/Types.lean | 6 +- tests/lean/Loops.lean | 186 ++++++++++++------ tests/lean/NoNestedBorrows.lean | 207 +++++++++++++------- tests/lean/Paper.lean | 33 ++-- tests/lean/PoloniusList.lean | 9 +- tests/lean/Traits.lean | 219 ++++++++++++++-------- 18 files changed, 956 insertions(+), 478 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Array.lean b/tests/lean/Array.lean index 5a4e09ab..4832f469 100644 --- a/tests/lean/Array.lean +++ b/tests/lean/Array.lean @@ -5,103 +5,122 @@ open Primitives namespace array -/- [array::AB] -/ +/- [array::AB] + Source: 'src/array.rs', lines 3:0-3:11 -/ inductive AB := | A : AB | B : AB /- [array::incr]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/array.rs', lines 8:0-8:24 -/ def incr (x : U32) : Result U32 := x + 1#u32 -/- [array::array_to_shared_slice_]: forward function -/ +/- [array::array_to_shared_slice_]: forward function + Source: 'src/array.rs', lines 16:0-16:53 -/ def 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_]: forward function + Source: 'src/array.rs', lines 21:0-21:58 -/ def 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 -/ +/- [array::array_to_mut_slice_]: backward function 0 + Source: 'src/array.rs', lines 21:0-21:58 -/ def array_to_mut_slice__back (T : Type) (s : Array T 32#usize) (ret0 : Slice T) : Result (Array T 32#usize) := Array.from_slice T 32#usize s ret0 -/- [array::array_len]: forward function -/ +/- [array::array_len]: forward function + Source: 'src/array.rs', lines 25:0-25:40 -/ def array_len (T : Type) (s : Array T 32#usize) : Result Usize := do let s0 ← Array.to_slice T 32#usize s let i := Slice.len T s0 Result.ret i -/- [array::shared_array_len]: forward function -/ +/- [array::shared_array_len]: forward function + Source: 'src/array.rs', lines 29:0-29:48 -/ def shared_array_len (T : Type) (s : Array T 32#usize) : Result Usize := do let s0 ← Array.to_slice T 32#usize s let i := Slice.len T s0 Result.ret i -/- [array::shared_slice_len]: forward function -/ +/- [array::shared_slice_len]: forward function + Source: 'src/array.rs', lines 33:0-33:44 -/ def shared_slice_len (T : Type) (s : Slice T) : Result Usize := let i := Slice.len T s Result.ret i -/- [array::index_array_shared]: forward function -/ +/- [array::index_array_shared]: forward function + Source: 'src/array.rs', lines 37:0-37:57 -/ def 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]: forward function + Source: 'src/array.rs', lines 44:0-44:53 -/ def 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]: forward function + Source: 'src/array.rs', lines 48:0-48:45 -/ def 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]: forward function + Source: 'src/array.rs', lines 52:0-52:62 -/ def 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 -/ +/- [array::index_mut_array]: backward function 0 + Source: 'src/array.rs', lines 52:0-52:62 -/ def index_mut_array_back (T : Type) (s : Array T 32#usize) (i : Usize) (ret0 : T) : Result (Array T 32#usize) := Array.update_usize T 32#usize s i ret0 -/- [array::index_slice]: forward function -/ +/- [array::index_slice]: forward function + Source: 'src/array.rs', lines 56:0-56:46 -/ def 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]: forward function + Source: 'src/array.rs', lines 60:0-60:58 -/ def 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 -/ +/- [array::index_mut_slice]: backward function 0 + Source: 'src/array.rs', lines 60:0-60:58 -/ def index_mut_slice_back (T : Type) (s : Slice T) (i : Usize) (ret0 : T) : Result (Slice T) := Slice.update_usize T s i ret0 -/- [array::slice_subslice_shared_]: forward function -/ +/- [array::slice_subslice_shared_]: forward function + Source: 'src/array.rs', lines 64:0-64:70 -/ def slice_subslice_shared_ (x : Slice U32) (y : Usize) (z : Usize) : Result (Slice U32) := core.slice.index.Slice.index U32 (core.ops.range.Range Usize) (core.slice.index.SliceIndexRangeUsizeSliceTInst U32) x { start := y, end_ := z } -/- [array::slice_subslice_mut_]: forward function -/ +/- [array::slice_subslice_mut_]: forward function + Source: 'src/array.rs', lines 68:0-68:75 -/ def 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 { start := y, end_ := z } -/- [array::slice_subslice_mut_]: backward function 0 -/ +/- [array::slice_subslice_mut_]: backward function 0 + Source: 'src/array.rs', lines 68:0-68:75 -/ def slice_subslice_mut__back (x : Slice U32) (y : Usize) (z : Usize) (ret0 : Slice U32) : Result (Slice U32) @@ -110,20 +129,24 @@ def slice_subslice_mut__back (core.slice.index.SliceIndexRangeUsizeSliceTInst U32) x { start := y, end_ := z } ret0 -/- [array::array_to_slice_shared_]: forward function -/ +/- [array::array_to_slice_shared_]: forward function + Source: 'src/array.rs', lines 72:0-72:54 -/ def 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_]: forward function + Source: 'src/array.rs', lines 76:0-76:59 -/ def 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 -/ +/- [array::array_to_slice_mut_]: backward function 0 + Source: 'src/array.rs', lines 76:0-76:59 -/ def array_to_slice_mut__back (x : Array U32 32#usize) (ret0 : Slice U32) : Result (Array U32 32#usize) := Array.from_slice U32 32#usize x ret0 -/- [array::array_subslice_shared_]: forward function -/ +/- [array::array_subslice_shared_]: forward function + Source: 'src/array.rs', lines 80:0-80:74 -/ def array_subslice_shared_ (x : Array U32 32#usize) (y : Usize) (z : Usize) : Result (Slice U32) := core.array.Array.index U32 (core.ops.range.Range Usize) 32#usize @@ -131,7 +154,8 @@ def array_subslice_shared_ (core.slice.index.SliceIndexRangeUsizeSliceTInst U32)) x { start := y, end_ := z } -/- [array::array_subslice_mut_]: forward function -/ +/- [array::array_subslice_mut_]: forward function + Source: 'src/array.rs', lines 84:0-84:79 -/ def 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 @@ -139,7 +163,8 @@ def array_subslice_mut_ (core.slice.index.SliceIndexRangeUsizeSliceTInst U32)) x { start := y, end_ := z } -/- [array::array_subslice_mut_]: backward function 0 -/ +/- [array::array_subslice_mut_]: backward function 0 + Source: 'src/array.rs', lines 84:0-84:79 -/ def array_subslice_mut__back (x : Array U32 32#usize) (y : Usize) (z : Usize) (ret0 : Slice U32) : Result (Array U32 32#usize) @@ -149,15 +174,18 @@ def array_subslice_mut__back (core.slice.index.SliceIndexRangeUsizeSliceTInst U32)) x { start := y, end_ := z } ret0 -/- [array::index_slice_0]: forward function -/ +/- [array::index_slice_0]: forward function + Source: 'src/array.rs', lines 88:0-88:38 -/ def 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]: forward function + Source: 'src/array.rs', lines 92:0-92:42 -/ def 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]: forward function + Source: 'src/array.rs', lines 103:0-103:71 -/ def index_index_array (s : Array (Array U32 32#usize) 32#usize) (i : Usize) (j : Usize) : Result U32 @@ -166,7 +194,8 @@ def index_index_array let a ← Array.index_usize (Array U32 32#usize) 32#usize s i Array.index_usize U32 32#usize a j -/- [array::update_update_array]: forward function -/ +/- [array::update_update_array]: forward function + Source: 'src/array.rs', lines 114:0-114:70 -/ def update_update_array (s : Array (Array U32 32#usize) 32#usize) (i : Usize) (j : Usize) : Result Unit @@ -177,28 +206,34 @@ def update_update_array let _ ← Array.update_usize (Array U32 32#usize) 32#usize s i a0 Result.ret () -/- [array::array_local_deep_copy]: forward function -/ +/- [array::array_local_deep_copy]: forward function + Source: 'src/array.rs', lines 118:0-118:43 -/ def array_local_deep_copy (x : Array U32 32#usize) : Result Unit := Result.ret () -/- [array::take_array]: forward function -/ +/- [array::take_array]: forward function + Source: 'src/array.rs', lines 122:0-122:30 -/ def take_array (a : Array U32 2#usize) : Result Unit := Result.ret () -/- [array::take_array_borrow]: forward function -/ +/- [array::take_array_borrow]: forward function + Source: 'src/array.rs', lines 123:0-123:38 -/ def take_array_borrow (a : Array U32 2#usize) : Result Unit := Result.ret () -/- [array::take_slice]: forward function -/ +/- [array::take_slice]: forward function + Source: 'src/array.rs', lines 124:0-124:28 -/ def take_slice (s : Slice U32) : Result Unit := Result.ret () /- [array::take_mut_slice]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/array.rs', lines 125:0-125:36 -/ def take_mut_slice (s : Slice U32) : Result (Slice U32) := Result.ret s -/- [array::take_all]: forward function -/ +/- [array::take_all]: forward function + Source: 'src/array.rs', lines 127:0-127:17 -/ def take_all : Result Unit := do let _ ← take_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) @@ -213,29 +248,35 @@ def take_all : Result Unit := Array.from_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s1 Result.ret () -/- [array::index_array]: forward function -/ +/- [array::index_array]: forward function + Source: 'src/array.rs', lines 141:0-141:38 -/ def 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]: forward function + Source: 'src/array.rs', lines 144:0-144:46 -/ def 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]: forward function + Source: 'src/array.rs', lines 148:0-148:42 -/ def 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]: forward function + Source: 'src/array.rs', lines 152:0-152:50 -/ def index_mut_slice_u32_0 (x : Slice U32) : Result U32 := Slice.index_usize U32 x 0#usize -/- [array::index_mut_slice_u32_0]: backward function 0 -/ +/- [array::index_mut_slice_u32_0]: backward function 0 + Source: 'src/array.rs', lines 152:0-152:50 -/ def index_mut_slice_u32_0_back (x : Slice U32) : Result (Slice U32) := do let _ ← Slice.index_usize U32 x 0#usize Result.ret x -/- [array::index_all]: forward function -/ +/- [array::index_all]: forward function + Source: 'src/array.rs', lines 156:0-156:25 -/ def index_all : Result U32 := do let i ← index_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) @@ -256,24 +297,28 @@ def index_all : Result U32 := Array.from_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) s1 Result.ret i7 -/- [array::update_array]: forward function -/ +/- [array::update_array]: forward function + Source: 'src/array.rs', lines 170:0-170:36 -/ def update_array (x : Array U32 2#usize) : Result Unit := do let _ ← Array.update_usize U32 2#usize x 0#usize 1#u32 Result.ret () /- [array::update_array_mut_borrow]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/array.rs', lines 173:0-173:48 -/ def 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 /- [array::update_mut_slice]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/array.rs', lines 176:0-176:38 -/ def update_mut_slice (x : Slice U32) : Result (Slice U32) := Slice.update_usize U32 x 0#usize 1#u32 -/- [array::update_all]: forward function -/ +/- [array::update_all]: forward function + Source: 'src/array.rs', lines 180:0-180:19 -/ def update_all : Result Unit := do let _ ← update_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) @@ -283,7 +328,8 @@ def update_all : Result Unit := let _ ← Array.from_slice U32 2#usize x s0 Result.ret () -/- [array::range_all]: forward function -/ +/- [array::range_all]: forward function + Source: 'src/array.rs', lines 191:0-191:18 -/ def range_all : Result Unit := do let s ← @@ -301,32 +347,38 @@ def range_all : Result Unit := { start := 1#usize, end_ := 3#usize } s0 Result.ret () -/- [array::deref_array_borrow]: forward function -/ +/- [array::deref_array_borrow]: forward function + Source: 'src/array.rs', lines 200:0-200:46 -/ def 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 -/ +/- [array::deref_array_mut_borrow]: forward function + Source: 'src/array.rs', lines 205:0-205:54 -/ def 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]: backward function 0 + Source: 'src/array.rs', lines 205:0-205:54 -/ def deref_array_mut_borrow_back (x : Array U32 2#usize) : Result (Array U32 2#usize) := do let _ ← Array.index_usize U32 2#usize x 0#usize Result.ret x -/- [array::take_array_t]: forward function -/ +/- [array::take_array_t]: forward function + Source: 'src/array.rs', lines 213:0-213:31 -/ def take_array_t (a : Array AB 2#usize) : Result Unit := Result.ret () -/- [array::non_copyable_array]: forward function -/ +/- [array::non_copyable_array]: forward function + Source: 'src/array.rs', lines 215:0-215:27 -/ def non_copyable_array : Result Unit := do let _ ← take_array_t (Array.make AB 2#usize [ AB.A, AB.B ]) Result.ret () -/- [array::sum]: loop 0: forward function -/ +/- [array::sum]: loop 0: forward function + Source: 'src/array.rs', lines 228:0-236:1 -/ divergent def sum_loop (s : Slice U32) (sum0 : U32) (i : Usize) : Result U32 := let i0 := Slice.len U32 s if i < i0 @@ -338,11 +390,13 @@ divergent def sum_loop (s : Slice U32) (sum0 : U32) (i : Usize) : Result U32 := sum_loop s sum1 i2 else Result.ret sum0 -/- [array::sum]: forward function -/ +/- [array::sum]: forward function + Source: 'src/array.rs', lines 228:0-228:28 -/ def sum (s : Slice U32) : Result U32 := sum_loop s 0#u32 0#usize -/- [array::sum2]: loop 0: forward function -/ +/- [array::sum2]: loop 0: forward function + Source: 'src/array.rs', lines 238:0-247:1 -/ divergent def sum2_loop (s : Slice U32) (s2 : Slice U32) (sum0 : U32) (i : Usize) : Result U32 := let i0 := Slice.len U32 s @@ -357,7 +411,8 @@ divergent def sum2_loop sum2_loop s s2 sum1 i4 else Result.ret sum0 -/- [array::sum2]: forward function -/ +/- [array::sum2]: forward function + Source: 'src/array.rs', lines 238:0-238:41 -/ def sum2 (s : Slice U32) (s2 : Slice U32) : Result U32 := let i := Slice.len U32 s let i0 := Slice.len U32 s2 @@ -365,7 +420,8 @@ def sum2 (s : Slice U32) (s2 : Slice U32) : Result U32 := then Result.fail Error.panic else sum2_loop s s2 0#u32 0#usize -/- [array::f0]: forward function -/ +/- [array::f0]: forward function + Source: 'src/array.rs', lines 249:0-249:11 -/ def f0 : Result Unit := do let s ← @@ -375,7 +431,8 @@ def f0 : Result Unit := Array.from_slice U32 2#usize (Array.make U32 2#usize [ 1#u32, 2#u32 ]) s0 Result.ret () -/- [array::f1]: forward function -/ +/- [array::f1]: forward function + Source: 'src/array.rs', lines 254:0-254:11 -/ def f1 : Result Unit := do let _ ← @@ -383,18 +440,21 @@ def f1 : Result Unit := 0#usize 1#u32 Result.ret () -/- [array::f2]: forward function -/ +/- [array::f2]: forward function + Source: 'src/array.rs', lines 259:0-259:17 -/ def f2 (i : U32) : Result Unit := Result.ret () -/- [array::f4]: forward function -/ +/- [array::f4]: forward function + Source: 'src/array.rs', lines 268:0-268:54 -/ def f4 (x : Array U32 32#usize) (y : Usize) (z : Usize) : Result (Slice U32) := core.array.Array.index U32 (core.ops.range.Range Usize) 32#usize (core.ops.index.IndexSliceTIInst U32 (core.ops.range.Range Usize) (core.slice.index.SliceIndexRangeUsizeSliceTInst U32)) x { start := y, end_ := z } -/- [array::f3]: forward function -/ +/- [array::f3]: forward function + Source: 'src/array.rs', lines 261:0-261:18 -/ def f3 : Result U32 := do let i ← @@ -407,15 +467,18 @@ def f3 : Result U32 := let s0 ← f4 b 16#usize 18#usize sum2 s s0 -/- [array::SZ] -/ +/- [array::SZ] + Source: 'src/array.rs', lines 272:0-272:19 -/ def sz_body : Result Usize := Result.ret 32#usize def sz_c : Usize := eval_global sz_body (by simp) -/- [array::f5]: forward function -/ +/- [array::f5]: forward function + Source: 'src/array.rs', lines 275:0-275:31 -/ def f5 (x : Array U32 32#usize) : Result U32 := Array.index_usize U32 32#usize x 0#usize -/- [array::ite]: forward function -/ +/- [array::ite]: forward function + Source: 'src/array.rs', lines 280:0-280:12 -/ def ite : Result Unit := do let s ← diff --git a/tests/lean/BetreeMain/Funs.lean b/tests/lean/BetreeMain/Funs.lean index 441a3721..45548884 100644 --- a/tests/lean/BetreeMain/Funs.lean +++ b/tests/lean/BetreeMain/Funs.lean @@ -7,14 +7,16 @@ open Primitives namespace betree_main -/- [betree_main::betree::load_internal_node]: forward function -/ +/- [betree_main::betree::load_internal_node]: forward function + Source: 'src/betree.rs', lines 36:0-36:52 -/ def betree.load_internal_node (id : U64) (st : State) : Result (State × (betree.List (U64 × betree.Message))) := betree_utils.load_internal_node id st -/- [betree_main::betree::store_internal_node]: forward function -/ +/- [betree_main::betree::store_internal_node]: forward function + Source: 'src/betree.rs', lines 41:0-41:60 -/ def betree.store_internal_node (id : U64) (content : betree.List (U64 × betree.Message)) (st : State) : Result (State × Unit) @@ -23,12 +25,14 @@ def betree.store_internal_node let (st0, _) ← betree_utils.store_internal_node id content st Result.ret (st0, ()) -/- [betree_main::betree::load_leaf_node]: forward function -/ +/- [betree_main::betree::load_leaf_node]: forward function + Source: 'src/betree.rs', lines 46:0-46:44 -/ def betree.load_leaf_node (id : U64) (st : State) : Result (State × (betree.List (U64 × U64))) := betree_utils.load_leaf_node id st -/- [betree_main::betree::store_leaf_node]: forward function -/ +/- [betree_main::betree::store_leaf_node]: forward function + Source: 'src/betree.rs', lines 51:0-51:52 -/ def betree.store_leaf_node (id : U64) (content : betree.List (U64 × U64)) (st : State) : Result (State × Unit) @@ -37,34 +41,40 @@ def betree.store_leaf_node let (st0, _) ← betree_utils.store_leaf_node id content st Result.ret (st0, ()) -/- [betree_main::betree::fresh_node_id]: forward function -/ +/- [betree_main::betree::fresh_node_id]: forward function + Source: 'src/betree.rs', lines 55:0-55:48 -/ def betree.fresh_node_id (counter : U64) : Result U64 := do let _ ← counter + 1#u64 Result.ret counter -/- [betree_main::betree::fresh_node_id]: backward function 0 -/ +/- [betree_main::betree::fresh_node_id]: backward function 0 + Source: 'src/betree.rs', lines 55:0-55:48 -/ def betree.fresh_node_id_back (counter : U64) : Result U64 := counter + 1#u64 -/- [betree_main::betree::{betree_main::betree::NodeIdCounter}::new]: forward function -/ +/- [betree_main::betree::{betree_main::betree::NodeIdCounter}::new]: forward function + Source: 'src/betree.rs', lines 206:4-206:20 -/ def betree.NodeIdCounter.new : Result betree.NodeIdCounter := Result.ret { 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]: forward function + Source: 'src/betree.rs', lines 210:4-210:36 -/ def betree.NodeIdCounter.fresh_id (self : betree.NodeIdCounter) : Result U64 := do let _ ← self.next_node_id + 1#u64 Result.ret self.next_node_id -/- [betree_main::betree::{betree_main::betree::NodeIdCounter}::fresh_id]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::NodeIdCounter}::fresh_id]: backward function 0 + Source: 'src/betree.rs', lines 210:4-210:36 -/ def betree.NodeIdCounter.fresh_id_back (self : betree.NodeIdCounter) : Result betree.NodeIdCounter := do let i ← self.next_node_id + 1#u64 Result.ret { next_node_id := i } -/- [betree_main::betree::upsert_update]: forward function -/ +/- [betree_main::betree::upsert_update]: forward function + Source: 'src/betree.rs', lines 234:0-234:70 -/ def betree.upsert_update (prev : Option U64) (st : betree.UpsertFunState) : Result U64 := match prev with @@ -85,7 +95,8 @@ def betree.upsert_update then prev0 - v else Result.ret 0#u64 -/- [betree_main::betree::{betree_main::betree::List#1}::len]: forward function -/ +/- [betree_main::betree::{betree_main::betree::List#1}::len]: forward function + Source: 'src/betree.rs', lines 276:4-276:24 -/ divergent def betree.List.len (T : Type) (self : betree.List T) : Result U64 := match self with | betree.List.Cons t tl => do @@ -93,7 +104,8 @@ divergent def betree.List.len (T : Type) (self : betree.List T) : Result U64 := 1#u64 + i | betree.List.Nil => Result.ret 0#u64 -/- [betree_main::betree::{betree_main::betree::List#1}::split_at]: forward function -/ +/- [betree_main::betree::{betree_main::betree::List#1}::split_at]: forward function + Source: 'src/betree.rs', lines 284:4-284:51 -/ divergent def betree.List.split_at (T : Type) (self : betree.List T) (n : U64) : Result ((betree.List T) × (betree.List T)) @@ -112,21 +124,24 @@ divergent def betree.List.split_at | betree.List.Nil => Result.fail Error.panic /- [betree_main::betree::{betree_main::betree::List#1}::push_front]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/betree.rs', lines 299:4-299:34 -/ def betree.List.push_front (T : Type) (self : betree.List T) (x : T) : Result (betree.List T) := let tl := core.mem.replace (betree.List T) self betree.List.Nil let l := tl Result.ret (betree.List.Cons x l) -/- [betree_main::betree::{betree_main::betree::List#1}::pop_front]: forward function -/ +/- [betree_main::betree::{betree_main::betree::List#1}::pop_front]: forward function + Source: 'src/betree.rs', lines 306:4-306:32 -/ def betree.List.pop_front (T : Type) (self : betree.List T) : Result T := let ls := core.mem.replace (betree.List T) self betree.List.Nil match ls with | betree.List.Cons x tl => Result.ret x | betree.List.Nil => Result.fail Error.panic -/- [betree_main::betree::{betree_main::betree::List#1}::pop_front]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::List#1}::pop_front]: backward function 0 + Source: 'src/betree.rs', lines 306:4-306:32 -/ def betree.List.pop_front_back (T : Type) (self : betree.List T) : Result (betree.List T) := let ls := core.mem.replace (betree.List T) self betree.List.Nil @@ -134,13 +149,15 @@ def betree.List.pop_front_back | betree.List.Cons x tl => Result.ret tl | betree.List.Nil => Result.fail Error.panic -/- [betree_main::betree::{betree_main::betree::List#1}::hd]: forward function -/ +/- [betree_main::betree::{betree_main::betree::List#1}::hd]: forward function + Source: 'src/betree.rs', lines 318:4-318:22 -/ def betree.List.hd (T : Type) (self : betree.List T) : Result T := match self with | betree.List.Cons hd l => Result.ret hd | betree.List.Nil => Result.fail Error.panic -/- [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]: forward function + Source: 'src/betree.rs', lines 327:4-327:44 -/ def betree.ListTupleU64T.head_has_key (T : Type) (self : betree.List (U64 × T)) (key : U64) : Result Bool := match self with @@ -148,7 +165,8 @@ def betree.ListTupleU64T.head_has_key Result.ret (i = key) | betree.List.Nil => Result.ret false -/- [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]: forward function + Source: 'src/betree.rs', lines 339:4-339:73 -/ divergent def betree.ListTupleU64T.partition_at_pivot (T : Type) (self : betree.List (U64 × T)) (pivot : U64) : Result ((betree.List (U64 × T)) × (betree.List (U64 × T))) @@ -166,7 +184,8 @@ divergent def betree.ListTupleU64T.partition_at_pivot Result.ret (betree.List.Cons (i, t) l, ls1) | betree.List.Nil => Result.ret (betree.List.Nil, betree.List.Nil) -/- [betree_main::betree::{betree_main::betree::Leaf#3}::split]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Leaf#3}::split]: forward function + Source: 'src/betree.rs', lines 359:4-364:17 -/ def betree.Leaf.split (self : betree.Leaf) (content : betree.List (U64 × U64)) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) (st : State) : @@ -186,7 +205,8 @@ def betree.Leaf.split let n0 := betree.Node.Leaf { id := id1, size := params.split_size } Result.ret (st1, betree.Internal.mk self.id pivot n n0) -/- [betree_main::betree::{betree_main::betree::Leaf#3}::split]: backward function 2 -/ +/- [betree_main::betree::{betree_main::betree::Leaf#3}::split]: backward function 2 + Source: 'src/betree.rs', lines 359:4-364:17 -/ def betree.Leaf.split_back (self : betree.Leaf) (content : betree.List (U64 × U64)) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) (st : State) : @@ -203,7 +223,8 @@ def betree.Leaf.split_back let _ ← 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]: forward function + Source: 'src/betree.rs', lines 789:4-792:34 -/ divergent def betree.Node.lookup_first_message_for_key (key : U64) (msgs : betree.List (U64 × betree.Message)) : Result (betree.List (U64 × betree.Message)) @@ -216,7 +237,8 @@ divergent def betree.Node.lookup_first_message_for_key else betree.Node.lookup_first_message_for_key key next_msgs | betree.List.Nil => Result.ret betree.List.Nil -/- [betree_main::betree::{betree_main::betree::Node#5}::lookup_first_message_for_key]: backward function 0 -/ +/- [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 -/ divergent def betree.Node.lookup_first_message_for_key_back (key : U64) (msgs : betree.List (U64 × betree.Message)) (ret0 : betree.List (U64 × betree.Message)) : @@ -234,7 +256,8 @@ divergent def betree.Node.lookup_first_message_for_key_back Result.ret (betree.List.Cons (i, m) next_msgs0) | betree.List.Nil => Result.ret ret0 -/- [betree_main::betree::{betree_main::betree::Node#5}::apply_upserts]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::apply_upserts]: forward function + Source: 'src/betree.rs', lines 819:4-819:90 -/ divergent def betree.Node.apply_upserts (msgs : betree.List (U64 × betree.Message)) (prev : Option U64) (key : U64) (st : State) : @@ -264,7 +287,8 @@ divergent def betree.Node.apply_upserts betree.Message.Insert v) Result.ret (st0, v) -/- [betree_main::betree::{betree_main::betree::Node#5}::apply_upserts]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::apply_upserts]: backward function 0 + Source: 'src/betree.rs', lines 819:4-819:90 -/ divergent def betree.Node.apply_upserts_back (msgs : betree.List (U64 × betree.Message)) (prev : Option U64) (key : U64) (st : State) : @@ -292,7 +316,8 @@ divergent def betree.Node.apply_upserts_back betree.List.push_front (U64 × betree.Message) msgs (key, betree.Message.Insert v) -/- [betree_main::betree::{betree_main::betree::Node#5}::lookup_in_bindings]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::lookup_in_bindings]: forward function + Source: 'src/betree.rs', lines 636:4-636:80 -/ divergent def betree.Node.lookup_in_bindings (key : U64) (bindings : betree.List (U64 × U64)) : Result (Option U64) := match bindings with @@ -306,7 +331,8 @@ divergent def betree.Node.lookup_in_bindings else betree.Node.lookup_in_bindings key tl | betree.List.Nil => Result.ret none -/- [betree_main::betree::{betree_main::betree::Internal#4}::lookup_in_children]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Internal#4}::lookup_in_children]: forward function + Source: 'src/betree.rs', lines 395:4-395:63 -/ mutual divergent def betree.Internal.lookup_in_children (self : betree.Internal) (key : U64) (st : State) : Result (State × (Option U64)) @@ -316,7 +342,8 @@ mutual divergent def betree.Internal.lookup_in_children then betree.Node.lookup n key st else betree.Node.lookup n0 key st -/- [betree_main::betree::{betree_main::betree::Internal#4}::lookup_in_children]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Internal#4}::lookup_in_children]: backward function 0 + Source: 'src/betree.rs', lines 395:4-395:63 -/ divergent def betree.Internal.lookup_in_children_back (self : betree.Internal) (key : U64) (st : State) : Result betree.Internal := let ⟨ i, i0, n, n0 ⟩ := self @@ -330,7 +357,8 @@ divergent def betree.Internal.lookup_in_children_back let n1 ← betree.Node.lookup_back n0 key st Result.ret (betree.Internal.mk i i0 n n1) -/- [betree_main::betree::{betree_main::betree::Node#5}::lookup]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::lookup]: forward function + Source: 'src/betree.rs', lines 709:4-709:58 -/ divergent def betree.Node.lookup (self : betree.Node) (key : U64) (st : State) : Result (State × (Option U64)) @@ -402,7 +430,8 @@ divergent def betree.Node.lookup let o ← betree.Node.lookup_in_bindings key bindings Result.ret (st0, o) -/- [betree_main::betree::{betree_main::betree::Node#5}::lookup]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::lookup]: backward function 0 + Source: 'src/betree.rs', lines 709:4-709:58 -/ divergent def betree.Node.lookup_back (self : betree.Node) (key : U64) (st : State) : Result betree.Node := match self with @@ -476,7 +505,8 @@ divergent def betree.Node.lookup_back 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 ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/betree.rs', lines 674:4-674:77 -/ divergent def betree.Node.filter_messages_for_key (key : U64) (msgs : betree.List (U64 × betree.Message)) : Result (betree.List (U64 × betree.Message)) @@ -494,7 +524,8 @@ divergent def betree.Node.filter_messages_for_key else Result.ret (betree.List.Cons (k, m) l) | betree.List.Nil => Result.ret betree.List.Nil -/- [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]: forward function + Source: 'src/betree.rs', lines 689:4-692:34 -/ divergent def betree.Node.lookup_first_message_after_key (key : U64) (msgs : betree.List (U64 × betree.Message)) : Result (betree.List (U64 × betree.Message)) @@ -507,7 +538,8 @@ divergent def betree.Node.lookup_first_message_after_key else Result.ret (betree.List.Cons (k, m) next_msgs) | betree.List.Nil => Result.ret betree.List.Nil -/- [betree_main::betree::{betree_main::betree::Node#5}::lookup_first_message_after_key]: backward function 0 -/ +/- [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 -/ divergent def betree.Node.lookup_first_message_after_key_back (key : U64) (msgs : betree.List (U64 × betree.Message)) (ret0 : betree.List (U64 × betree.Message)) : @@ -526,7 +558,8 @@ divergent def betree.Node.lookup_first_message_after_key_back | betree.List.Nil => Result.ret ret0 /- [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 ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/betree.rs', lines 521:4-521:89 -/ def betree.Node.apply_to_internal (msgs : betree.List (U64 × betree.Message)) (key : U64) (new_msg : betree.Message) : @@ -592,7 +625,8 @@ def betree.Node.apply_to_internal betree.Node.lookup_first_message_for_key_back key msgs msgs1 /- [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 ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/betree.rs', lines 502:4-505:5 -/ divergent def betree.Node.apply_messages_to_internal (msgs : betree.List (U64 × betree.Message)) (new_msgs : betree.List (U64 × betree.Message)) : @@ -606,7 +640,8 @@ divergent def betree.Node.apply_messages_to_internal betree.Node.apply_messages_to_internal msgs0 new_msgs_tl | betree.List.Nil => Result.ret msgs -/- [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]: forward function + Source: 'src/betree.rs', lines 653:4-656:32 -/ divergent def betree.Node.lookup_mut_in_bindings (key : U64) (bindings : betree.List (U64 × U64)) : Result (betree.List (U64 × U64)) @@ -619,7 +654,8 @@ divergent def betree.Node.lookup_mut_in_bindings else betree.Node.lookup_mut_in_bindings key tl | betree.List.Nil => Result.ret betree.List.Nil -/- [betree_main::betree::{betree_main::betree::Node#5}::lookup_mut_in_bindings]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::lookup_mut_in_bindings]: backward function 0 + Source: 'src/betree.rs', lines 653:4-656:32 -/ divergent def betree.Node.lookup_mut_in_bindings_back (key : U64) (bindings : betree.List (U64 × U64)) (ret0 : betree.List (U64 × U64)) : @@ -637,7 +673,8 @@ divergent def betree.Node.lookup_mut_in_bindings_back | betree.List.Nil => Result.ret ret0 /- [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 ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/betree.rs', lines 460:4-460:87 -/ def betree.Node.apply_to_leaf (bindings : betree.List (U64 × U64)) (key : U64) (new_msg : betree.Message) : @@ -686,7 +723,8 @@ def betree.Node.apply_to_leaf betree.Node.lookup_mut_in_bindings_back key bindings bindings1 /- [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 ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/betree.rs', lines 444:4-447:5 -/ divergent def betree.Node.apply_messages_to_leaf (bindings : betree.List (U64 × U64)) (new_msgs : betree.List (U64 × betree.Message)) : @@ -700,7 +738,8 @@ divergent def betree.Node.apply_messages_to_leaf betree.Node.apply_messages_to_leaf bindings0 new_msgs_tl | betree.List.Nil => Result.ret bindings -/- [betree_main::betree::{betree_main::betree::Internal#4}::flush]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Internal#4}::flush]: forward function + Source: 'src/betree.rs', lines 410:4-415:26 -/ mutual divergent def betree.Internal.flush (self : betree.Internal) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) @@ -738,7 +777,8 @@ mutual divergent def betree.Internal.flush betree.Node.apply_messages_back n0 params node_id_cnt msgs_right st Result.ret (st0, msgs_left) -/- [betree_main::betree::{betree_main::betree::Internal#4}::flush]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Internal#4}::flush]: backward function 0 + Source: 'src/betree.rs', lines 410:4-415:26 -/ divergent def betree.Internal.flush_back (self : betree.Internal) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) @@ -772,7 +812,8 @@ divergent def betree.Internal.flush_back betree.Node.apply_messages_back n0 params node_id_cnt msgs_right st Result.ret (betree.Internal.mk i i0 n n1, node_id_cnt0) -/- [betree_main::betree::{betree_main::betree::Node#5}::apply_messages]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::apply_messages]: forward function + Source: 'src/betree.rs', lines 588:4-593:5 -/ divergent def betree.Node.apply_messages (self : betree.Node) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) @@ -820,7 +861,8 @@ divergent def betree.Node.apply_messages let (st1, _) ← betree.store_leaf_node node.id content0 st0 Result.ret (st1, ()) -/- [betree_main::betree::{betree_main::betree::Node#5}::apply_messages]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::apply_messages]: backward function 0 + Source: 'src/betree.rs', lines 588:4-593:5 -/ divergent def betree.Node.apply_messages_back (self : betree.Node) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) @@ -874,7 +916,8 @@ divergent def betree.Node.apply_messages_back end -/- [betree_main::betree::{betree_main::betree::Node#5}::apply]: forward function -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::apply]: forward function + Source: 'src/betree.rs', lines 576:4-582:5 -/ def betree.Node.apply (self : betree.Node) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) (key : U64) (new_msg : betree.Message) @@ -891,7 +934,8 @@ def betree.Node.apply (key, new_msg) l) st Result.ret (st0, ()) -/- [betree_main::betree::{betree_main::betree::Node#5}::apply]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::Node#5}::apply]: backward function 0 + Source: 'src/betree.rs', lines 576:4-582:5 -/ def betree.Node.apply_back (self : betree.Node) (params : betree.Params) (node_id_cnt : betree.NodeIdCounter) (key : U64) (new_msg : betree.Message) @@ -902,7 +946,8 @@ def betree.Node.apply_back betree.Node.apply_messages_back self params node_id_cnt (betree.List.Cons (key, new_msg) l) st -/- [betree_main::betree::{betree_main::betree::BeTree#6}::new]: forward function -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::new]: forward function + Source: 'src/betree.rs', lines 849:4-849:60 -/ def betree.BeTree.new (min_flush_size : U64) (split_size : U64) (st : State) : Result (State × betree.BeTree) @@ -920,7 +965,8 @@ def betree.BeTree.new root := (betree.Node.Leaf { id := id, size := 0#u64 }) }) -/- [betree_main::betree::{betree_main::betree::BeTree#6}::apply]: forward function -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::apply]: forward function + Source: 'src/betree.rs', lines 868:4-868:47 -/ def betree.BeTree.apply (self : betree.BeTree) (key : U64) (msg : betree.Message) (st : State) : Result (State × Unit) @@ -932,7 +978,8 @@ def betree.BeTree.apply betree.Node.apply_back self.root self.params self.node_id_cnt key msg st Result.ret (st0, ()) -/- [betree_main::betree::{betree_main::betree::BeTree#6}::apply]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::apply]: backward function 0 + Source: 'src/betree.rs', lines 868:4-868:47 -/ def betree.BeTree.apply_back (self : betree.BeTree) (key : U64) (msg : betree.Message) (st : State) : Result betree.BeTree @@ -942,7 +989,8 @@ def betree.BeTree.apply_back betree.Node.apply_back self.root self.params self.node_id_cnt key msg st Result.ret { self with node_id_cnt := nic, root := n } -/- [betree_main::betree::{betree_main::betree::BeTree#6}::insert]: forward function -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::insert]: forward function + Source: 'src/betree.rs', lines 874:4-874:52 -/ def betree.BeTree.insert (self : betree.BeTree) (key : U64) (value : U64) (st : State) : Result (State × Unit) @@ -954,14 +1002,16 @@ def betree.BeTree.insert betree.BeTree.apply_back self key (betree.Message.Insert value) st Result.ret (st0, ()) -/- [betree_main::betree::{betree_main::betree::BeTree#6}::insert]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::insert]: backward function 0 + Source: 'src/betree.rs', lines 874:4-874:52 -/ def betree.BeTree.insert_back (self : betree.BeTree) (key : U64) (value : U64) (st : State) : Result betree.BeTree := betree.BeTree.apply_back 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]: forward function + Source: 'src/betree.rs', lines 880:4-880:38 -/ def betree.BeTree.delete (self : betree.BeTree) (key : U64) (st : State) : Result (State × Unit) := do @@ -969,12 +1019,14 @@ def betree.BeTree.delete let _ ← betree.BeTree.apply_back self key betree.Message.Delete st Result.ret (st0, ()) -/- [betree_main::betree::{betree_main::betree::BeTree#6}::delete]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::delete]: backward function 0 + Source: 'src/betree.rs', lines 880:4-880:38 -/ def betree.BeTree.delete_back (self : betree.BeTree) (key : U64) (st : State) : Result betree.BeTree := betree.BeTree.apply_back 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]: forward function + Source: 'src/betree.rs', lines 886:4-886:59 -/ def betree.BeTree.upsert (self : betree.BeTree) (key : U64) (upd : betree.UpsertFunState) (st : State) : @@ -986,7 +1038,8 @@ def betree.BeTree.upsert let _ ← betree.BeTree.apply_back self key (betree.Message.Upsert upd) st Result.ret (st0, ()) -/- [betree_main::betree::{betree_main::betree::BeTree#6}::upsert]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::upsert]: backward function 0 + Source: 'src/betree.rs', lines 886:4-886:59 -/ def betree.BeTree.upsert_back (self : betree.BeTree) (key : U64) (upd : betree.UpsertFunState) (st : State) : @@ -994,21 +1047,24 @@ def betree.BeTree.upsert_back := betree.BeTree.apply_back 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]: forward function + Source: 'src/betree.rs', lines 895:4-895:62 -/ def betree.BeTree.lookup (self : betree.BeTree) (key : U64) (st : State) : Result (State × (Option U64)) := betree.Node.lookup self.root key st -/- [betree_main::betree::{betree_main::betree::BeTree#6}::lookup]: backward function 0 -/ +/- [betree_main::betree::{betree_main::betree::BeTree#6}::lookup]: backward function 0 + Source: 'src/betree.rs', lines 895:4-895:62 -/ def betree.BeTree.lookup_back (self : betree.BeTree) (key : U64) (st : State) : Result betree.BeTree := do let n ← betree.Node.lookup_back self.root key st Result.ret { self with root := n } -/- [betree_main::main]: forward function -/ +/- [betree_main::main]: forward function + Source: 'src/betree_main.rs', lines 5:0-5:9 -/ def main : Result Unit := Result.ret () diff --git a/tests/lean/BetreeMain/FunsExternal_Template.lean b/tests/lean/BetreeMain/FunsExternal_Template.lean index 1dc3af0e..95f88873 100644 --- a/tests/lean/BetreeMain/FunsExternal_Template.lean +++ b/tests/lean/BetreeMain/FunsExternal_Template.lean @@ -6,25 +6,30 @@ import BetreeMain.Types open Primitives open betree_main -/- [betree_main::betree_utils::load_internal_node]: forward function -/ +/- [betree_main::betree_utils::load_internal_node]: forward function + Source: 'src/betree_utils.rs', lines 98:0-98:63 -/ axiom betree_utils.load_internal_node : U64 → State → Result (State × (betree.List (U64 × betree.Message))) -/- [betree_main::betree_utils::store_internal_node]: forward function -/ +/- [betree_main::betree_utils::store_internal_node]: forward function + Source: 'src/betree_utils.rs', lines 115:0-115:71 -/ axiom betree_utils.store_internal_node : U64 → betree.List (U64 × betree.Message) → State → Result (State × Unit) -/- [betree_main::betree_utils::load_leaf_node]: forward function -/ +/- [betree_main::betree_utils::load_leaf_node]: forward function + Source: 'src/betree_utils.rs', lines 132:0-132:55 -/ axiom betree_utils.load_leaf_node : U64 → State → Result (State × (betree.List (U64 × U64))) -/- [betree_main::betree_utils::store_leaf_node]: forward function -/ +/- [betree_main::betree_utils::store_leaf_node]: forward function + Source: 'src/betree_utils.rs', lines 145:0-145:63 -/ axiom betree_utils.store_leaf_node : U64 → betree.List (U64 × U64) → State → Result (State × Unit) -/- [core::option::{core::option::Option}::unwrap]: forward function -/ +/- [core::option::{core::option::Option}::unwrap]: forward function + Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/option.rs', lines 932:4-932:34 -/ axiom core.option.Option.unwrap (T : Type) : Option T → State → Result (State × T) diff --git a/tests/lean/BetreeMain/Types.lean b/tests/lean/BetreeMain/Types.lean index 2f5de6a0..6e528437 100644 --- a/tests/lean/BetreeMain/Types.lean +++ b/tests/lean/BetreeMain/Types.lean @@ -5,50 +5,59 @@ open Primitives namespace betree_main -/- [betree_main::betree::List] -/ +/- [betree_main::betree::List] + Source: 'src/betree.rs', lines 17:0-17:23 -/ inductive betree.List (T : Type) := | Cons : T → betree.List T → betree.List T | Nil : betree.List T -/- [betree_main::betree::UpsertFunState] -/ +/- [betree_main::betree::UpsertFunState] + Source: 'src/betree.rs', lines 63:0-63:23 -/ inductive betree.UpsertFunState := | Add : U64 → betree.UpsertFunState | Sub : U64 → betree.UpsertFunState -/- [betree_main::betree::Message] -/ +/- [betree_main::betree::Message] + Source: 'src/betree.rs', lines 69:0-69:23 -/ inductive betree.Message := | Insert : U64 → betree.Message | Delete : betree.Message | Upsert : betree.UpsertFunState → betree.Message -/- [betree_main::betree::Leaf] -/ +/- [betree_main::betree::Leaf] + Source: 'src/betree.rs', lines 167:0-167:11 -/ structure betree.Leaf where id : U64 size : U64 mutual -/- [betree_main::betree::Internal] -/ +/- [betree_main::betree::Internal] + Source: 'src/betree.rs', lines 156:0-156:15 -/ inductive betree.Internal := | mk : U64 → U64 → betree.Node → betree.Node → betree.Internal -/- [betree_main::betree::Node] -/ +/- [betree_main::betree::Node] + Source: 'src/betree.rs', lines 179:0-179:9 -/ inductive betree.Node := | Internal : betree.Internal → betree.Node | Leaf : betree.Leaf → betree.Node end -/- [betree_main::betree::Params] -/ +/- [betree_main::betree::Params] + Source: 'src/betree.rs', lines 187:0-187:13 -/ structure betree.Params where min_flush_size : U64 split_size : U64 -/- [betree_main::betree::NodeIdCounter] -/ +/- [betree_main::betree::NodeIdCounter] + Source: 'src/betree.rs', lines 201:0-201:20 -/ structure betree.NodeIdCounter where next_node_id : U64 -/- [betree_main::betree::BeTree] -/ +/- [betree_main::betree::BeTree] + Source: 'src/betree.rs', lines 218:0-218:17 -/ structure betree.BeTree where params : betree.Params node_id_cnt : betree.NodeIdCounter diff --git a/tests/lean/Constants.lean b/tests/lean/Constants.lean index 62e45d76..80864427 100644 --- a/tests/lean/Constants.lean +++ b/tests/lean/Constants.lean @@ -5,119 +5,147 @@ open Primitives namespace constants -/- [constants::X0] -/ +/- [constants::X0] + Source: 'src/constants.rs', lines 5:0-5:17 -/ def x0_body : Result U32 := Result.ret 0#u32 def x0_c : U32 := eval_global x0_body (by simp) -/- [constants::X1] -/ +/- [constants::X1] + Source: 'src/constants.rs', lines 7:0-7:17 -/ def x1_body : Result U32 := Result.ret core_u32_max def x1_c : U32 := eval_global x1_body (by simp) -/- [constants::X2] -/ +/- [constants::X2] + Source: 'src/constants.rs', lines 10:0-10:17 -/ def x2_body : Result U32 := Result.ret 3#u32 def x2_c : U32 := eval_global x2_body (by simp) -/- [constants::incr]: forward function -/ +/- [constants::incr]: forward function + Source: 'src/constants.rs', lines 17:0-17:32 -/ def incr (n : U32) : Result U32 := n + 1#u32 -/- [constants::X3] -/ +/- [constants::X3] + Source: 'src/constants.rs', lines 15:0-15:17 -/ def x3_body : Result U32 := incr 32#u32 def x3_c : U32 := eval_global x3_body (by simp) -/- [constants::mk_pair0]: forward function -/ +/- [constants::mk_pair0]: forward function + Source: 'src/constants.rs', lines 23:0-23:51 -/ def mk_pair0 (x : U32) (y : U32) : Result (U32 × U32) := Result.ret (x, y) -/- [constants::Pair] -/ +/- [constants::Pair] + Source: 'src/constants.rs', lines 36:0-36:23 -/ structure Pair (T1 T2 : Type) where x : T1 y : T2 -/- [constants::mk_pair1]: forward function -/ +/- [constants::mk_pair1]: forward function + Source: 'src/constants.rs', lines 27:0-27:55 -/ def mk_pair1 (x : U32) (y : U32) : Result (Pair U32 U32) := Result.ret { x := x, y := y } -/- [constants::P0] -/ +/- [constants::P0] + Source: 'src/constants.rs', lines 31:0-31:24 -/ def p0_body : Result (U32 × U32) := mk_pair0 0#u32 1#u32 def p0_c : (U32 × U32) := eval_global p0_body (by simp) -/- [constants::P1] -/ +/- [constants::P1] + Source: 'src/constants.rs', lines 32:0-32:28 -/ def p1_body : Result (Pair U32 U32) := mk_pair1 0#u32 1#u32 def p1_c : Pair U32 U32 := eval_global p1_body (by simp) -/- [constants::P2] -/ +/- [constants::P2] + Source: 'src/constants.rs', lines 33:0-33:24 -/ def p2_body : Result (U32 × U32) := Result.ret (0#u32, 1#u32) def p2_c : (U32 × U32) := eval_global p2_body (by simp) -/- [constants::P3] -/ +/- [constants::P3] + Source: 'src/constants.rs', lines 34:0-34:28 -/ def p3_body : Result (Pair U32 U32) := Result.ret { x := 0#u32, y := 1#u32 } def p3_c : Pair U32 U32 := eval_global p3_body (by simp) -/- [constants::Wrap] -/ +/- [constants::Wrap] + Source: 'src/constants.rs', lines 49:0-49:18 -/ structure Wrap (T : Type) where value : T -/- [constants::{constants::Wrap}::new]: forward function -/ +/- [constants::{constants::Wrap}::new]: forward function + Source: 'src/constants.rs', lines 54:4-54:41 -/ def Wrap.new (T : Type) (value : T) : Result (Wrap T) := Result.ret { value := value } -/- [constants::Y] -/ +/- [constants::Y] + Source: 'src/constants.rs', lines 41:0-41:22 -/ def y_body : Result (Wrap I32) := Wrap.new I32 2#i32 def y_c : Wrap I32 := eval_global y_body (by simp) -/- [constants::unwrap_y]: forward function -/ +/- [constants::unwrap_y]: forward function + Source: 'src/constants.rs', lines 43:0-43:30 -/ def unwrap_y : Result I32 := Result.ret y_c.value -/- [constants::YVAL] -/ +/- [constants::YVAL] + Source: 'src/constants.rs', lines 47:0-47:19 -/ def yval_body : Result I32 := unwrap_y def yval_c : I32 := eval_global yval_body (by simp) -/- [constants::get_z1::Z1] -/ +/- [constants::get_z1::Z1] + Source: 'src/constants.rs', lines 62:4-62:17 -/ def get_z1_z1_body : Result I32 := Result.ret 3#i32 def get_z1_z1_c : I32 := eval_global get_z1_z1_body (by simp) -/- [constants::get_z1]: forward function -/ +/- [constants::get_z1]: forward function + Source: 'src/constants.rs', lines 61:0-61:28 -/ def get_z1 : Result I32 := Result.ret get_z1_z1_c -/- [constants::add]: forward function -/ +/- [constants::add]: forward function + Source: 'src/constants.rs', lines 66:0-66:39 -/ def add (a : I32) (b : I32) : Result I32 := a + b -/- [constants::Q1] -/ +/- [constants::Q1] + Source: 'src/constants.rs', lines 74:0-74:17 -/ def q1_body : Result I32 := Result.ret 5#i32 def q1_c : I32 := eval_global q1_body (by simp) -/- [constants::Q2] -/ +/- [constants::Q2] + Source: 'src/constants.rs', lines 75:0-75:17 -/ def q2_body : Result I32 := Result.ret q1_c def q2_c : I32 := eval_global q2_body (by simp) -/- [constants::Q3] -/ +/- [constants::Q3] + Source: 'src/constants.rs', lines 76:0-76:17 -/ def q3_body : Result I32 := add q2_c 3#i32 def q3_c : I32 := eval_global q3_body (by simp) -/- [constants::get_z2]: forward function -/ +/- [constants::get_z2]: forward function + Source: 'src/constants.rs', lines 70:0-70:28 -/ def get_z2 : Result I32 := do let i ← get_z1 let i0 ← add i q3_c add q1_c i0 -/- [constants::S1] -/ +/- [constants::S1] + Source: 'src/constants.rs', lines 80:0-80:18 -/ def s1_body : Result U32 := Result.ret 6#u32 def s1_c : U32 := eval_global s1_body (by simp) -/- [constants::S2] -/ +/- [constants::S2] + Source: 'src/constants.rs', lines 81:0-81:18 -/ def s2_body : Result U32 := incr s1_c def s2_c : U32 := eval_global s2_body (by simp) -/- [constants::S3] -/ +/- [constants::S3] + Source: 'src/constants.rs', lines 82:0-82:29 -/ def s3_body : Result (Pair U32 U32) := Result.ret p3_c def s3_c : Pair U32 U32 := eval_global s3_body (by simp) -/- [constants::S4] -/ +/- [constants::S4] + Source: 'src/constants.rs', lines 83:0-83:29 -/ def s4_body : Result (Pair U32 U32) := mk_pair1 7#u32 8#u32 def s4_c : Pair U32 U32 := eval_global s4_body (by simp) diff --git a/tests/lean/External/Funs.lean b/tests/lean/External/Funs.lean index 55fb07be..e5655c7e 100644 --- a/tests/lean/External/Funs.lean +++ b/tests/lean/External/Funs.lean @@ -7,7 +7,8 @@ open Primitives namespace external -/- [external::swap]: forward function -/ +/- [external::swap]: forward function + Source: 'src/external.rs', lines 6:0-6:46 -/ def swap (T : Type) (x : T) (y : T) (st : State) : Result (State × Unit) := do let (st0, _) ← core.mem.swap T x y st @@ -15,7 +16,8 @@ def swap (T : Type) (x : T) (y : T) (st : State) : Result (State × Unit) := let (st2, _) ← core.mem.swap_back1 T x y st st1 Result.ret (st2, ()) -/- [external::swap]: backward function 0 -/ +/- [external::swap]: backward function 0 + Source: 'src/external.rs', lines 6:0-6:46 -/ def swap_back (T : Type) (x : T) (y : T) (st : State) (st0 : State) : Result (State × (T × T)) @@ -26,14 +28,16 @@ def swap_back let (_, y0) ← core.mem.swap_back1 T x y st st2 Result.ret (st0, (x0, y0)) -/- [external::test_new_non_zero_u32]: forward function -/ +/- [external::test_new_non_zero_u32]: forward function + Source: 'src/external.rs', lines 11:0-11:60 -/ def test_new_non_zero_u32 (x : U32) (st : State) : Result (State × core.num.nonzero.NonZeroU32) := do let (st0, o) ← core.num.nonzero.NonZeroU32.new x st core.option.Option.unwrap core.num.nonzero.NonZeroU32 o st0 -/- [external::test_vec]: forward function -/ +/- [external::test_vec]: forward function + Source: 'src/external.rs', lines 17:0-17:17 -/ def test_vec : Result Unit := do let v := alloc.vec.Vec.new U32 @@ -43,7 +47,8 @@ def test_vec : Result Unit := /- Unit test for [external::test_vec] -/ #assert (test_vec == .ret ()) -/- [external::custom_swap]: forward function -/ +/- [external::custom_swap]: forward function + Source: 'src/external.rs', lines 24:0-24:66 -/ def custom_swap (T : Type) (x : T) (y : T) (st : State) : Result (State × T) := do @@ -52,7 +57,8 @@ def custom_swap let (st2, _) ← core.mem.swap_back1 T x y st st1 Result.ret (st2, x0) -/- [external::custom_swap]: backward function 0 -/ +/- [external::custom_swap]: backward function 0 + Source: 'src/external.rs', lines 24:0-24:66 -/ def custom_swap_back (T : Type) (x : T) (y : T) (st : State) (ret0 : T) (st0 : State) : Result (State × (T × T)) @@ -63,21 +69,24 @@ def custom_swap_back let (_, y0) ← core.mem.swap_back1 T x y st st2 Result.ret (st0, (ret0, y0)) -/- [external::test_custom_swap]: forward function -/ +/- [external::test_custom_swap]: forward function + Source: 'src/external.rs', lines 29:0-29:59 -/ def test_custom_swap (x : U32) (y : U32) (st : State) : Result (State × Unit) := do let (st0, _) ← custom_swap U32 x y st Result.ret (st0, ()) -/- [external::test_custom_swap]: backward function 0 -/ +/- [external::test_custom_swap]: backward function 0 + Source: 'src/external.rs', lines 29:0-29:59 -/ def 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 -/- [external::test_swap_non_zero]: forward function -/ +/- [external::test_swap_non_zero]: forward function + Source: 'src/external.rs', lines 35:0-35:44 -/ def test_swap_non_zero (x : U32) (st : State) : Result (State × U32) := do let (st0, _) ← swap U32 x 0#u32 st diff --git a/tests/lean/External/FunsExternal_Template.lean b/tests/lean/External/FunsExternal_Template.lean index 0fccef86..55cd6bb5 100644 --- a/tests/lean/External/FunsExternal_Template.lean +++ b/tests/lean/External/FunsExternal_Template.lean @@ -6,22 +6,27 @@ import External.Types open Primitives open external -/- [core::mem::swap]: forward function -/ +/- [core::mem::swap]: forward function + Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/mem/mod.rs', lines 726:0-726:42 -/ axiom core.mem.swap (T : Type) : T → T → State → Result (State × Unit) -/- [core::mem::swap]: backward function 0 -/ +/- [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 (T : Type) : T → T → State → State → Result (State × T) -/- [core::mem::swap]: backward function 1 -/ +/- [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 (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]: forward function + 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)) -/- [core::option::{core::option::Option}::unwrap]: forward function -/ +/- [core::option::{core::option::Option}::unwrap]: forward function + Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/option.rs', lines 932:4-932:34 -/ axiom core.option.Option.unwrap (T : Type) : Option T → State → Result (State × T) diff --git a/tests/lean/External/Types.lean b/tests/lean/External/Types.lean index 71d70eed..40f20cda 100644 --- a/tests/lean/External/Types.lean +++ b/tests/lean/External/Types.lean @@ -5,7 +5,8 @@ open Primitives namespace external -/- [core::num::nonzero::NonZeroU32] -/ +/- [core::num::nonzero::NonZeroU32] + Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/num/nonzero.rs', lines 50:12-50:33 -/ axiom core.num.nonzero.NonZeroU32 : Type /- The state type used in the state-error monad -/ diff --git a/tests/lean/Hashmap/Funs.lean b/tests/lean/Hashmap/Funs.lean index a1cd435e..95c501f6 100644 --- a/tests/lean/Hashmap/Funs.lean +++ b/tests/lean/Hashmap/Funs.lean @@ -6,11 +6,13 @@ open Primitives namespace hashmap -/- [hashmap::hash_key]: forward function -/ +/- [hashmap::hash_key]: forward function + Source: 'src/hashmap.rs', lines 27:0-27:32 -/ def hash_key (k : Usize) : Result Usize := Result.ret k -/- [hashmap::{hashmap::HashMap}::allocate_slots]: loop 0: forward function -/ +/- [hashmap::{hashmap::HashMap}::allocate_slots]: loop 0: forward function + Source: 'src/hashmap.rs', lines 50:4-56:5 -/ divergent def HashMap.allocate_slots_loop (T : Type) (slots : alloc.vec.Vec (List T)) (n : Usize) : Result (alloc.vec.Vec (List T)) @@ -23,14 +25,16 @@ divergent def HashMap.allocate_slots_loop HashMap.allocate_slots_loop T slots0 n0 else Result.ret slots -/- [hashmap::{hashmap::HashMap}::allocate_slots]: forward function -/ +/- [hashmap::{hashmap::HashMap}::allocate_slots]: forward function + Source: 'src/hashmap.rs', lines 50:4-50:76 -/ def HashMap.allocate_slots (T : Type) (slots : alloc.vec.Vec (List T)) (n : Usize) : Result (alloc.vec.Vec (List T)) := HashMap.allocate_slots_loop T slots n -/- [hashmap::{hashmap::HashMap}::new_with_capacity]: forward function -/ +/- [hashmap::{hashmap::HashMap}::new_with_capacity]: forward function + Source: 'src/hashmap.rs', lines 59:4-63:13 -/ def HashMap.new_with_capacity (T : Type) (capacity : Usize) (max_load_dividend : Usize) (max_load_divisor : Usize) : @@ -49,12 +53,14 @@ def HashMap.new_with_capacity slots := slots } -/- [hashmap::{hashmap::HashMap}::new]: forward function -/ +/- [hashmap::{hashmap::HashMap}::new]: forward function + Source: 'src/hashmap.rs', lines 75:4-75:24 -/ def HashMap.new (T : Type) : Result (HashMap T) := HashMap.new_with_capacity T 32#usize 4#usize 5#usize /- [hashmap::{hashmap::HashMap}::clear]: loop 0: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: '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)) @@ -72,17 +78,20 @@ divergent def HashMap.clear_loop else Result.ret slots /- [hashmap::{hashmap::HashMap}::clear]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 80:4-80:27 -/ def HashMap.clear (T : Type) (self : HashMap T) : Result (HashMap T) := do let v ← HashMap.clear_loop T self.slots 0#usize Result.ret { self with num_entries := 0#usize, slots := v } -/- [hashmap::{hashmap::HashMap}::len]: forward function -/ +/- [hashmap::{hashmap::HashMap}::len]: forward function + Source: 'src/hashmap.rs', lines 90:4-90:30 -/ def HashMap.len (T : Type) (self : HashMap T) : Result Usize := Result.ret self.num_entries -/- [hashmap::{hashmap::HashMap}::insert_in_list]: loop 0: forward function -/ +/- [hashmap::{hashmap::HashMap}::insert_in_list]: loop 0: forward function + Source: '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 := match ls with @@ -92,12 +101,14 @@ divergent def HashMap.insert_in_list_loop else HashMap.insert_in_list_loop T key value tl | List.Nil => Result.ret true -/- [hashmap::{hashmap::HashMap}::insert_in_list]: forward function -/ +/- [hashmap::{hashmap::HashMap}::insert_in_list]: forward function + Source: 'src/hashmap.rs', lines 97:4-97:71 -/ def HashMap.insert_in_list (T : Type) (key : Usize) (value : T) (ls : List T) : Result Bool := HashMap.insert_in_list_loop T key value ls -/- [hashmap::{hashmap::HashMap}::insert_in_list]: loop 0: backward function 0 -/ +/- [hashmap::{hashmap::HashMap}::insert_in_list]: loop 0: backward function 0 + Source: 'src/hashmap.rs', lines 97:4-114:5 -/ divergent def HashMap.insert_in_list_loop_back (T : Type) (key : Usize) (value : T) (ls : List T) : Result (List T) := match ls with @@ -111,13 +122,15 @@ divergent def HashMap.insert_in_list_loop_back | List.Nil => let l := List.Nil Result.ret (List.Cons key value l) -/- [hashmap::{hashmap::HashMap}::insert_in_list]: backward function 0 -/ +/- [hashmap::{hashmap::HashMap}::insert_in_list]: backward function 0 + Source: 'src/hashmap.rs', lines 97:4-97:71 -/ def HashMap.insert_in_list_back (T : Type) (key : Usize) (value : T) (ls : List T) : Result (List T) := HashMap.insert_in_list_loop_back T key value ls /- [hashmap::{hashmap::HashMap}::insert_no_resize]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 117:4-117:54 -/ def HashMap.insert_no_resize (T : Type) (self : HashMap T) (key : Usize) (value : T) : Result (HashMap T) @@ -151,7 +164,8 @@ def HashMap.insert_no_resize Result.ret { self with slots := v } /- [hashmap::{hashmap::HashMap}::move_elements_from_list]: loop 0: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: '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 @@ -162,13 +176,15 @@ divergent def HashMap.move_elements_from_list_loop | List.Nil => Result.ret ntable /- [hashmap::{hashmap::HashMap}::move_elements_from_list]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: '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) := HashMap.move_elements_from_list_loop T ntable ls /- [hashmap::{hashmap::HashMap}::move_elements]: loop 0: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: '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) : @@ -192,7 +208,8 @@ divergent def HashMap.move_elements_loop else Result.ret (ntable, slots) /- [hashmap::{hashmap::HashMap}::move_elements]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 171:4-171:95 -/ def HashMap.move_elements (T : Type) (ntable : HashMap T) (slots : alloc.vec.Vec (List T)) (i : Usize) : @@ -201,7 +218,8 @@ def HashMap.move_elements HashMap.move_elements_loop T ntable slots i /- [hashmap::{hashmap::HashMap}::try_resize]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 140:4-140:28 -/ def HashMap.try_resize (T : Type) (self : HashMap T) : Result (HashMap T) := do let max_usize ← Scalar.cast .Usize core_u32_max @@ -224,7 +242,8 @@ def HashMap.try_resize (T : Type) (self : HashMap T) : Result (HashMap T) := else Result.ret { self with max_load_factor := (i, i0) } /- [hashmap::{hashmap::HashMap}::insert]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 129:4-129:48 -/ def HashMap.insert (T : Type) (self : HashMap T) (key : Usize) (value : T) : Result (HashMap T) @@ -236,7 +255,8 @@ def HashMap.insert then HashMap.try_resize T self0 else Result.ret self0 -/- [hashmap::{hashmap::HashMap}::contains_key_in_list]: loop 0: forward function -/ +/- [hashmap::{hashmap::HashMap}::contains_key_in_list]: loop 0: forward function + Source: '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 @@ -246,12 +266,14 @@ divergent def HashMap.contains_key_in_list_loop else HashMap.contains_key_in_list_loop T key tl | List.Nil => Result.ret false -/- [hashmap::{hashmap::HashMap}::contains_key_in_list]: forward function -/ +/- [hashmap::{hashmap::HashMap}::contains_key_in_list]: forward function + Source: 'src/hashmap.rs', lines 206:4-206:68 -/ def HashMap.contains_key_in_list (T : Type) (key : Usize) (ls : List T) : Result Bool := HashMap.contains_key_in_list_loop T key ls -/- [hashmap::{hashmap::HashMap}::contains_key]: forward function -/ +/- [hashmap::{hashmap::HashMap}::contains_key]: forward function + Source: 'src/hashmap.rs', lines 199:4-199:49 -/ def HashMap.contains_key (T : Type) (self : HashMap T) (key : Usize) : Result Bool := do @@ -264,7 +286,8 @@ def HashMap.contains_key hash_mod HashMap.contains_key_in_list T key l -/- [hashmap::{hashmap::HashMap}::get_in_list]: loop 0: forward function -/ +/- [hashmap::{hashmap::HashMap}::get_in_list]: loop 0: forward function + Source: '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 @@ -274,11 +297,13 @@ divergent def HashMap.get_in_list_loop else HashMap.get_in_list_loop T key tl | List.Nil => Result.fail Error.panic -/- [hashmap::{hashmap::HashMap}::get_in_list]: forward function -/ +/- [hashmap::{hashmap::HashMap}::get_in_list]: forward function + Source: 'src/hashmap.rs', lines 224:4-224:70 -/ def HashMap.get_in_list (T : Type) (key : Usize) (ls : List T) : Result T := HashMap.get_in_list_loop T key ls -/- [hashmap::{hashmap::HashMap}::get]: forward function -/ +/- [hashmap::{hashmap::HashMap}::get]: forward function + Source: 'src/hashmap.rs', lines 239:4-239:55 -/ def HashMap.get (T : Type) (self : HashMap T) (key : Usize) : Result T := do let hash ← hash_key key @@ -290,7 +315,8 @@ def HashMap.get (T : Type) (self : HashMap T) (key : Usize) : Result T := hash_mod HashMap.get_in_list T key l -/- [hashmap::{hashmap::HashMap}::get_mut_in_list]: loop 0: forward function -/ +/- [hashmap::{hashmap::HashMap}::get_mut_in_list]: loop 0: forward function + Source: '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 := match ls with @@ -300,12 +326,14 @@ divergent def HashMap.get_mut_in_list_loop else HashMap.get_mut_in_list_loop T tl key | List.Nil => Result.fail Error.panic -/- [hashmap::{hashmap::HashMap}::get_mut_in_list]: forward function -/ +/- [hashmap::{hashmap::HashMap}::get_mut_in_list]: forward function + Source: 'src/hashmap.rs', lines 245:4-245:86 -/ def HashMap.get_mut_in_list (T : Type) (ls : List T) (key : Usize) : Result T := HashMap.get_mut_in_list_loop T ls key -/- [hashmap::{hashmap::HashMap}::get_mut_in_list]: loop 0: backward function 0 -/ +/- [hashmap::{hashmap::HashMap}::get_mut_in_list]: loop 0: backward function 0 + Source: 'src/hashmap.rs', lines 245:4-254:5 -/ divergent def HashMap.get_mut_in_list_loop_back (T : Type) (ls : List T) (key : Usize) (ret0 : T) : Result (List T) := match ls with @@ -318,12 +346,14 @@ divergent def HashMap.get_mut_in_list_loop_back Result.ret (List.Cons ckey cvalue tl0) | List.Nil => Result.fail Error.panic -/- [hashmap::{hashmap::HashMap}::get_mut_in_list]: backward function 0 -/ +/- [hashmap::{hashmap::HashMap}::get_mut_in_list]: backward function 0 + Source: 'src/hashmap.rs', lines 245:4-245:86 -/ def HashMap.get_mut_in_list_back (T : Type) (ls : List T) (key : Usize) (ret0 : T) : Result (List T) := HashMap.get_mut_in_list_loop_back T ls key ret0 -/- [hashmap::{hashmap::HashMap}::get_mut]: forward function -/ +/- [hashmap::{hashmap::HashMap}::get_mut]: forward function + Source: 'src/hashmap.rs', lines 257:4-257:67 -/ def HashMap.get_mut (T : Type) (self : HashMap T) (key : Usize) : Result T := do let hash ← hash_key key @@ -335,7 +365,8 @@ def HashMap.get_mut (T : Type) (self : HashMap T) (key : Usize) : Result T := hash_mod HashMap.get_mut_in_list T l key -/- [hashmap::{hashmap::HashMap}::get_mut]: backward function 0 -/ +/- [hashmap::{hashmap::HashMap}::get_mut]: backward function 0 + Source: 'src/hashmap.rs', lines 257:4-257:67 -/ def HashMap.get_mut_back (T : Type) (self : HashMap T) (key : Usize) (ret0 : T) : Result (HashMap T) @@ -355,7 +386,8 @@ def HashMap.get_mut_back hash_mod l0 Result.ret { self with slots := v } -/- [hashmap::{hashmap::HashMap}::remove_from_list]: loop 0: forward function -/ +/- [hashmap::{hashmap::HashMap}::remove_from_list]: loop 0: forward function + Source: '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) := match ls with @@ -369,12 +401,14 @@ divergent def HashMap.remove_from_list_loop else HashMap.remove_from_list_loop T key tl | List.Nil => Result.ret none -/- [hashmap::{hashmap::HashMap}::remove_from_list]: forward function -/ +/- [hashmap::{hashmap::HashMap}::remove_from_list]: forward function + Source: 'src/hashmap.rs', lines 265:4-265:69 -/ def HashMap.remove_from_list (T : Type) (key : Usize) (ls : List T) : Result (Option T) := HashMap.remove_from_list_loop T key ls -/- [hashmap::{hashmap::HashMap}::remove_from_list]: loop 0: backward function 1 -/ +/- [hashmap::{hashmap::HashMap}::remove_from_list]: loop 0: backward function 1 + Source: 'src/hashmap.rs', lines 265:4-291:5 -/ divergent def HashMap.remove_from_list_loop_back (T : Type) (key : Usize) (ls : List T) : Result (List T) := match ls with @@ -391,12 +425,14 @@ divergent def HashMap.remove_from_list_loop_back Result.ret (List.Cons ckey t tl0) | List.Nil => Result.ret List.Nil -/- [hashmap::{hashmap::HashMap}::remove_from_list]: backward function 1 -/ +/- [hashmap::{hashmap::HashMap}::remove_from_list]: backward function 1 + Source: 'src/hashmap.rs', lines 265:4-265:69 -/ def HashMap.remove_from_list_back (T : Type) (key : Usize) (ls : List T) : Result (List T) := HashMap.remove_from_list_loop_back T key ls -/- [hashmap::{hashmap::HashMap}::remove]: forward function -/ +/- [hashmap::{hashmap::HashMap}::remove]: forward function + Source: 'src/hashmap.rs', lines 294:4-294:52 -/ def HashMap.remove (T : Type) (self : HashMap T) (key : Usize) : Result (Option T) := do @@ -414,7 +450,8 @@ def HashMap.remove let _ ← self.num_entries - 1#usize Result.ret (some x0) -/- [hashmap::{hashmap::HashMap}::remove]: backward function 0 -/ +/- [hashmap::{hashmap::HashMap}::remove]: backward function 0 + Source: 'src/hashmap.rs', lines 294:4-294:52 -/ def HashMap.remove_back (T : Type) (self : HashMap T) (key : Usize) : Result (HashMap T) := do @@ -445,7 +482,8 @@ def HashMap.remove_back hash_mod l0 Result.ret { self with num_entries := i0, slots := v } -/- [hashmap::test1]: forward function -/ +/- [hashmap::test1]: forward function + Source: 'src/hashmap.rs', lines 315:0-315:10 -/ def test1 : Result Unit := do let hm ← HashMap.new U64 diff --git a/tests/lean/Hashmap/Types.lean b/tests/lean/Hashmap/Types.lean index e007bce0..fa454123 100644 --- a/tests/lean/Hashmap/Types.lean +++ b/tests/lean/Hashmap/Types.lean @@ -5,12 +5,14 @@ open Primitives namespace hashmap -/- [hashmap::List] -/ +/- [hashmap::List] + Source: 'src/hashmap.rs', lines 19:0-19:16 -/ inductive List (T : Type) := | Cons : Usize → T → List T → List T | Nil : List T -/- [hashmap::HashMap] -/ +/- [hashmap::HashMap] + Source: 'src/hashmap.rs', lines 35:0-35:21 -/ structure HashMap (T : Type) where num_entries : Usize max_load_factor : (Usize × Usize) diff --git a/tests/lean/HashmapMain/Funs.lean b/tests/lean/HashmapMain/Funs.lean index 5e05a399..abe84bbf 100644 --- a/tests/lean/HashmapMain/Funs.lean +++ b/tests/lean/HashmapMain/Funs.lean @@ -7,11 +7,13 @@ open Primitives namespace hashmap_main -/- [hashmap_main::hashmap::hash_key]: forward function -/ +/- [hashmap_main::hashmap::hash_key]: forward function + Source: 'src/hashmap.rs', lines 27:0-27:32 -/ def hashmap.hash_key (k : Usize) : Result Usize := Result.ret k -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: loop 0: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: loop 0: forward function + Source: 'src/hashmap.rs', lines 50:4-56:5 -/ divergent def hashmap.HashMap.allocate_slots_loop (T : Type) (slots : alloc.vec.Vec (hashmap.List T)) (n : Usize) : Result (alloc.vec.Vec (hashmap.List T)) @@ -24,14 +26,16 @@ divergent def hashmap.HashMap.allocate_slots_loop hashmap.HashMap.allocate_slots_loop T slots0 n0 else Result.ret slots -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::allocate_slots]: forward function + Source: 'src/hashmap.rs', lines 50:4-50:76 -/ def hashmap.HashMap.allocate_slots (T : Type) (slots : alloc.vec.Vec (hashmap.List T)) (n : Usize) : Result (alloc.vec.Vec (hashmap.List T)) := hashmap.HashMap.allocate_slots_loop T slots n -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::new_with_capacity]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::new_with_capacity]: forward function + Source: 'src/hashmap.rs', lines 59:4-63:13 -/ def hashmap.HashMap.new_with_capacity (T : Type) (capacity : Usize) (max_load_dividend : Usize) (max_load_divisor : Usize) : @@ -50,12 +54,14 @@ def hashmap.HashMap.new_with_capacity slots := slots } -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::new]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::new]: forward function + Source: 'src/hashmap.rs', lines 75:4-75:24 -/ 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}::clear]: loop 0: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: '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)) @@ -73,18 +79,21 @@ divergent def hashmap.HashMap.clear_loop else Result.ret slots /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::clear]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 80:4-80:27 -/ def hashmap.HashMap.clear (T : Type) (self : hashmap.HashMap T) : Result (hashmap.HashMap T) := do let v ← hashmap.HashMap.clear_loop T self.slots 0#usize Result.ret { self with num_entries := 0#usize, slots := v } -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::len]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::len]: forward function + Source: 'src/hashmap.rs', lines 90:4-90:30 -/ def hashmap.HashMap.len (T : Type) (self : hashmap.HashMap T) : Result Usize := Result.ret self.num_entries -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: loop 0: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: loop 0: forward function + Source: '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 := match ls with @@ -94,12 +103,14 @@ divergent def hashmap.HashMap.insert_in_list_loop else hashmap.HashMap.insert_in_list_loop T key value tl | hashmap.List.Nil => Result.ret true -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: forward function + Source: '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.HashMap.insert_in_list_loop T key value ls -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: loop 0: backward function 0 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: loop 0: backward function 0 + Source: 'src/hashmap.rs', lines 97:4-114:5 -/ divergent def hashmap.HashMap.insert_in_list_loop_back (T : Type) (key : Usize) (value : T) (ls : hashmap.List T) : Result (hashmap.List T) @@ -116,7 +127,8 @@ divergent def hashmap.HashMap.insert_in_list_loop_back let l := hashmap.List.Nil Result.ret (hashmap.List.Cons key value l) -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: backward function 0 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_in_list]: backward function 0 + Source: 'src/hashmap.rs', lines 97:4-97:71 -/ def hashmap.HashMap.insert_in_list_back (T : Type) (key : Usize) (value : T) (ls : hashmap.List T) : Result (hashmap.List T) @@ -124,7 +136,8 @@ def hashmap.HashMap.insert_in_list_back hashmap.HashMap.insert_in_list_loop_back T key value ls /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert_no_resize]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 117:4-117:54 -/ def hashmap.HashMap.insert_no_resize (T : Type) (self : hashmap.HashMap T) (key : Usize) (value : T) : Result (hashmap.HashMap T) @@ -158,7 +171,8 @@ def hashmap.HashMap.insert_no_resize Result.ret { self with slots := v } /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements_from_list]: loop 0: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: '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) @@ -171,7 +185,8 @@ divergent def hashmap.HashMap.move_elements_from_list_loop | hashmap.List.Nil => Result.ret ntable /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements_from_list]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: '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) @@ -179,7 +194,8 @@ def hashmap.HashMap.move_elements_from_list hashmap.HashMap.move_elements_from_list_loop T ntable ls /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements]: loop 0: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: '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) : @@ -204,7 +220,8 @@ divergent def hashmap.HashMap.move_elements_loop else Result.ret (ntable, slots) /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::move_elements]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 171:4-171:95 -/ def hashmap.HashMap.move_elements (T : Type) (ntable : hashmap.HashMap T) (slots : alloc.vec.Vec (hashmap.List T)) (i : Usize) : @@ -213,7 +230,8 @@ def hashmap.HashMap.move_elements hashmap.HashMap.move_elements_loop T ntable slots i /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::try_resize]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 140:4-140:28 -/ def hashmap.HashMap.try_resize (T : Type) (self : hashmap.HashMap T) : Result (hashmap.HashMap T) := do @@ -238,7 +256,8 @@ def hashmap.HashMap.try_resize else Result.ret { self with max_load_factor := (i, i0) } /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::insert]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/hashmap.rs', lines 129:4-129:48 -/ def hashmap.HashMap.insert (T : Type) (self : hashmap.HashMap T) (key : Usize) (value : T) : Result (hashmap.HashMap T) @@ -250,7 +269,8 @@ def hashmap.HashMap.insert then hashmap.HashMap.try_resize T self0 else Result.ret self0 -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: loop 0: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: loop 0: forward function + Source: '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 @@ -260,12 +280,14 @@ divergent def hashmap.HashMap.contains_key_in_list_loop else hashmap.HashMap.contains_key_in_list_loop T key tl | hashmap.List.Nil => Result.ret false -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key_in_list]: forward function + Source: '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 := hashmap.HashMap.contains_key_in_list_loop T key ls -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::contains_key]: forward function + Source: 'src/hashmap.rs', lines 199:4-199:49 -/ def hashmap.HashMap.contains_key (T : Type) (self : hashmap.HashMap T) (key : Usize) : Result Bool := do @@ -278,7 +300,8 @@ def hashmap.HashMap.contains_key self.slots hash_mod hashmap.HashMap.contains_key_in_list T key l -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: loop 0: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: loop 0: forward function + Source: '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 @@ -288,12 +311,14 @@ divergent def hashmap.HashMap.get_in_list_loop else hashmap.HashMap.get_in_list_loop T key tl | hashmap.List.Nil => Result.fail Error.panic -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: forward function + Source: 'src/hashmap.rs', lines 224:4-224:70 -/ def hashmap.HashMap.get_in_list (T : Type) (key : Usize) (ls : hashmap.List T) : Result T := hashmap.HashMap.get_in_list_loop T key ls -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get]: forward function + Source: 'src/hashmap.rs', lines 239:4-239:55 -/ def hashmap.HashMap.get (T : Type) (self : hashmap.HashMap T) (key : Usize) : Result T := do @@ -306,7 +331,8 @@ def hashmap.HashMap.get self.slots hash_mod hashmap.HashMap.get_in_list T key l -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: loop 0: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: loop 0: forward function + Source: '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 := match ls with @@ -316,12 +342,14 @@ divergent def hashmap.HashMap.get_mut_in_list_loop else hashmap.HashMap.get_mut_in_list_loop T tl key | hashmap.List.Nil => Result.fail Error.panic -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: forward function + Source: '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 := hashmap.HashMap.get_mut_in_list_loop T ls key -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: loop 0: backward function 0 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: loop 0: backward function 0 + Source: 'src/hashmap.rs', lines 245:4-254:5 -/ divergent def hashmap.HashMap.get_mut_in_list_loop_back (T : Type) (ls : hashmap.List T) (key : Usize) (ret0 : T) : Result (hashmap.List T) @@ -336,14 +364,16 @@ divergent def hashmap.HashMap.get_mut_in_list_loop_back Result.ret (hashmap.List.Cons ckey cvalue tl0) | hashmap.List.Nil => Result.fail Error.panic -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: backward function 0 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: backward function 0 + Source: 'src/hashmap.rs', lines 245:4-245:86 -/ def hashmap.HashMap.get_mut_in_list_back (T : Type) (ls : hashmap.List T) (key : Usize) (ret0 : T) : Result (hashmap.List T) := hashmap.HashMap.get_mut_in_list_loop_back T ls key ret0 -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut]: forward function + Source: 'src/hashmap.rs', lines 257:4-257:67 -/ def hashmap.HashMap.get_mut (T : Type) (self : hashmap.HashMap T) (key : Usize) : Result T := do @@ -356,7 +386,8 @@ def hashmap.HashMap.get_mut self.slots hash_mod hashmap.HashMap.get_mut_in_list T l key -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut]: backward function 0 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut]: backward function 0 + Source: 'src/hashmap.rs', lines 257:4-257:67 -/ def hashmap.HashMap.get_mut_back (T : Type) (self : hashmap.HashMap T) (key : Usize) (ret0 : T) : Result (hashmap.HashMap T) @@ -376,7 +407,8 @@ def hashmap.HashMap.get_mut_back self.slots hash_mod l0 Result.ret { self with slots := v } -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: loop 0: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: loop 0: forward function + Source: '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) := match ls with @@ -392,12 +424,14 @@ divergent def hashmap.HashMap.remove_from_list_loop else hashmap.HashMap.remove_from_list_loop T key tl | hashmap.List.Nil => Result.ret none -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: forward function + Source: '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.HashMap.remove_from_list_loop T key ls -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: loop 0: backward function 1 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: loop 0: backward function 1 + Source: 'src/hashmap.rs', lines 265:4-291:5 -/ divergent def hashmap.HashMap.remove_from_list_loop_back (T : Type) (key : Usize) (ls : hashmap.List T) : Result (hashmap.List T) := match ls with @@ -416,12 +450,14 @@ divergent def hashmap.HashMap.remove_from_list_loop_back Result.ret (hashmap.List.Cons ckey t tl0) | hashmap.List.Nil => Result.ret hashmap.List.Nil -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: backward function 1 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove_from_list]: backward function 1 + Source: 'src/hashmap.rs', lines 265:4-265:69 -/ def hashmap.HashMap.remove_from_list_back (T : Type) (key : Usize) (ls : hashmap.List T) : Result (hashmap.List T) := hashmap.HashMap.remove_from_list_loop_back T key ls -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove]: forward function -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove]: forward function + Source: 'src/hashmap.rs', lines 294:4-294:52 -/ def hashmap.HashMap.remove (T : Type) (self : hashmap.HashMap T) (key : Usize) : Result (Option T) := do @@ -439,7 +475,8 @@ def hashmap.HashMap.remove let _ ← self.num_entries - 1#usize Result.ret (some x0) -/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove]: backward function 0 -/ +/- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::remove]: backward function 0 + Source: 'src/hashmap.rs', lines 294:4-294:52 -/ def hashmap.HashMap.remove_back (T : Type) (self : hashmap.HashMap T) (key : Usize) : Result (hashmap.HashMap T) @@ -472,7 +509,8 @@ def hashmap.HashMap.remove_back self.slots hash_mod l0 Result.ret { self with num_entries := i0, slots := v } -/- [hashmap_main::hashmap::test1]: forward function -/ +/- [hashmap_main::hashmap::test1]: forward function + Source: 'src/hashmap.rs', lines 315:0-315:10 -/ def hashmap.test1 : Result Unit := do let hm ← hashmap.HashMap.new U64 @@ -515,7 +553,8 @@ def hashmap.test1 : Result Unit := then Result.fail Error.panic else Result.ret () -/- [hashmap_main::insert_on_disk]: forward function -/ +/- [hashmap_main::insert_on_disk]: forward function + Source: 'src/hashmap_main.rs', lines 7:0-7:43 -/ def insert_on_disk (key : Usize) (value : U64) (st : State) : Result (State × Unit) := do @@ -524,7 +563,8 @@ def insert_on_disk let (st1, _) ← hashmap_utils.serialize hm0 st0 Result.ret (st1, ()) -/- [hashmap_main::main]: forward function -/ +/- [hashmap_main::main]: forward function + Source: 'src/hashmap_main.rs', lines 16:0-16:13 -/ def main : Result Unit := Result.ret () diff --git a/tests/lean/HashmapMain/FunsExternal_Template.lean b/tests/lean/HashmapMain/FunsExternal_Template.lean index f537fc8f..02ca5b0e 100644 --- a/tests/lean/HashmapMain/FunsExternal_Template.lean +++ b/tests/lean/HashmapMain/FunsExternal_Template.lean @@ -6,11 +6,13 @@ import HashmapMain.Types open Primitives open hashmap_main -/- [hashmap_main::hashmap_utils::deserialize]: forward function -/ +/- [hashmap_main::hashmap_utils::deserialize]: forward function + Source: 'src/hashmap_utils.rs', lines 10:0-10:43 -/ axiom hashmap_utils.deserialize : State → Result (State × (hashmap.HashMap U64)) -/- [hashmap_main::hashmap_utils::serialize]: forward function -/ +/- [hashmap_main::hashmap_utils::serialize]: forward function + Source: 'src/hashmap_utils.rs', lines 5:0-5:42 -/ axiom hashmap_utils.serialize : hashmap.HashMap U64 → State → Result (State × Unit) diff --git a/tests/lean/HashmapMain/Types.lean b/tests/lean/HashmapMain/Types.lean index 065c109b..f7be6719 100644 --- a/tests/lean/HashmapMain/Types.lean +++ b/tests/lean/HashmapMain/Types.lean @@ -5,12 +5,14 @@ open Primitives namespace hashmap_main -/- [hashmap_main::hashmap::List] -/ +/- [hashmap_main::hashmap::List] + Source: 'src/hashmap.rs', lines 19:0-19:16 -/ inductive hashmap.List (T : Type) := | Cons : Usize → T → hashmap.List T → hashmap.List T | Nil : hashmap.List T -/- [hashmap_main::hashmap::HashMap] -/ +/- [hashmap_main::hashmap::HashMap] + Source: 'src/hashmap.rs', lines 35:0-35:21 -/ structure hashmap.HashMap (T : Type) where num_entries : Usize max_load_factor : (Usize × Usize) diff --git a/tests/lean/Loops.lean b/tests/lean/Loops.lean index 701dc6f7..ae1d87aa 100644 --- a/tests/lean/Loops.lean +++ b/tests/lean/Loops.lean @@ -5,7 +5,8 @@ open Primitives namespace loops -/- [loops::sum]: loop 0: forward function -/ +/- [loops::sum]: loop 0: forward function + Source: 'src/loops.rs', lines 4:0-14:1 -/ divergent def sum_loop (max : U32) (i : U32) (s : U32) : Result U32 := if i < max then do @@ -14,11 +15,13 @@ divergent def sum_loop (max : U32) (i : U32) (s : U32) : Result U32 := sum_loop max i0 s0 else s * 2#u32 -/- [loops::sum]: forward function -/ +/- [loops::sum]: forward function + Source: 'src/loops.rs', lines 4:0-4:27 -/ def sum (max : U32) : Result U32 := sum_loop max 0#u32 0#u32 -/- [loops::sum_with_mut_borrows]: loop 0: forward function -/ +/- [loops::sum_with_mut_borrows]: loop 0: forward function + Source: 'src/loops.rs', lines 19:0-31:1 -/ divergent def sum_with_mut_borrows_loop (max : U32) (mi : U32) (ms : U32) : Result U32 := if mi < max @@ -29,11 +32,13 @@ divergent def sum_with_mut_borrows_loop sum_with_mut_borrows_loop max mi0 ms0 else ms * 2#u32 -/- [loops::sum_with_mut_borrows]: forward function -/ +/- [loops::sum_with_mut_borrows]: forward function + Source: 'src/loops.rs', lines 19:0-19:44 -/ def sum_with_mut_borrows (max : U32) : Result U32 := sum_with_mut_borrows_loop max 0#u32 0#u32 -/- [loops::sum_with_shared_borrows]: loop 0: forward function -/ +/- [loops::sum_with_shared_borrows]: loop 0: forward function + Source: 'src/loops.rs', lines 34:0-48:1 -/ divergent def sum_with_shared_borrows_loop (max : U32) (i : U32) (s : U32) : Result U32 := if i < max @@ -44,12 +49,14 @@ divergent def sum_with_shared_borrows_loop sum_with_shared_borrows_loop max i0 s0 else s * 2#u32 -/- [loops::sum_with_shared_borrows]: forward function -/ +/- [loops::sum_with_shared_borrows]: forward function + Source: 'src/loops.rs', lines 34:0-34:47 -/ def sum_with_shared_borrows (max : U32) : Result U32 := sum_with_shared_borrows_loop max 0#u32 0#u32 /- [loops::clear]: loop 0: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/loops.rs', lines 52:0-58:1 -/ divergent def clear_loop (v : alloc.vec.Vec U32) (i : Usize) : Result (alloc.vec.Vec U32) := let i0 := alloc.vec.Vec.len U32 v @@ -64,16 +71,19 @@ divergent def clear_loop else Result.ret v /- [loops::clear]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/loops.rs', lines 52:0-52:30 -/ def clear (v : alloc.vec.Vec U32) : Result (alloc.vec.Vec U32) := clear_loop v 0#usize -/- [loops::List] -/ +/- [loops::List] + Source: 'src/loops.rs', lines 60:0-60:16 -/ inductive List (T : Type) := | Cons : T → List T → List T | Nil : List T -/- [loops::list_mem]: loop 0: forward function -/ +/- [loops::list_mem]: loop 0: forward function + Source: 'src/loops.rs', lines 66:0-75:1 -/ divergent def list_mem_loop (x : U32) (ls : List U32) : Result Bool := match ls with | List.Cons y tl => if y = x @@ -81,11 +91,13 @@ divergent def list_mem_loop (x : U32) (ls : List U32) : Result Bool := else list_mem_loop x tl | List.Nil => Result.ret false -/- [loops::list_mem]: forward function -/ +/- [loops::list_mem]: forward function + Source: 'src/loops.rs', lines 66:0-66:52 -/ def list_mem (x : U32) (ls : List U32) : Result Bool := list_mem_loop x ls -/- [loops::list_nth_mut_loop]: loop 0: forward function -/ +/- [loops::list_nth_mut_loop]: loop 0: forward function + Source: 'src/loops.rs', lines 78:0-88:1 -/ divergent def list_nth_mut_loop_loop (T : Type) (ls : List T) (i : U32) : Result T := match ls with @@ -97,11 +109,13 @@ divergent def list_nth_mut_loop_loop list_nth_mut_loop_loop T tl i0 | List.Nil => Result.fail Error.panic -/- [loops::list_nth_mut_loop]: forward function -/ +/- [loops::list_nth_mut_loop]: forward function + Source: 'src/loops.rs', lines 78:0-78:71 -/ def list_nth_mut_loop (T : Type) (ls : List T) (i : U32) : Result T := list_nth_mut_loop_loop T ls i -/- [loops::list_nth_mut_loop]: loop 0: backward function 0 -/ +/- [loops::list_nth_mut_loop]: loop 0: backward function 0 + Source: 'src/loops.rs', lines 78:0-88:1 -/ divergent def list_nth_mut_loop_loop_back (T : Type) (ls : List T) (i : U32) (ret0 : T) : Result (List T) := match ls with @@ -115,12 +129,14 @@ divergent def list_nth_mut_loop_loop_back Result.ret (List.Cons x tl0) | List.Nil => Result.fail Error.panic -/- [loops::list_nth_mut_loop]: backward function 0 -/ +/- [loops::list_nth_mut_loop]: backward function 0 + Source: 'src/loops.rs', lines 78:0-78:71 -/ def list_nth_mut_loop_back (T : Type) (ls : List T) (i : U32) (ret0 : T) : Result (List T) := list_nth_mut_loop_loop_back T ls i ret0 -/- [loops::list_nth_shared_loop]: loop 0: forward function -/ +/- [loops::list_nth_shared_loop]: loop 0: forward function + Source: 'src/loops.rs', lines 91:0-101:1 -/ divergent def list_nth_shared_loop_loop (T : Type) (ls : List T) (i : U32) : Result T := match ls with @@ -132,11 +148,13 @@ divergent def list_nth_shared_loop_loop list_nth_shared_loop_loop T tl i0 | List.Nil => Result.fail Error.panic -/- [loops::list_nth_shared_loop]: forward function -/ +/- [loops::list_nth_shared_loop]: forward function + Source: 'src/loops.rs', lines 91:0-91:66 -/ def list_nth_shared_loop (T : Type) (ls : List T) (i : U32) : Result T := list_nth_shared_loop_loop T ls i -/- [loops::get_elem_mut]: loop 0: forward function -/ +/- [loops::get_elem_mut]: loop 0: forward function + Source: 'src/loops.rs', lines 103:0-117:1 -/ divergent def get_elem_mut_loop (x : Usize) (ls : List Usize) : Result Usize := match ls with | List.Cons y tl => if y = x @@ -144,7 +162,8 @@ divergent def get_elem_mut_loop (x : Usize) (ls : List Usize) : Result Usize := else get_elem_mut_loop x tl | List.Nil => Result.fail Error.panic -/- [loops::get_elem_mut]: forward function -/ +/- [loops::get_elem_mut]: forward function + Source: 'src/loops.rs', lines 103:0-103:73 -/ def get_elem_mut (slots : alloc.vec.Vec (List Usize)) (x : Usize) : Result Usize := do @@ -153,7 +172,8 @@ def get_elem_mut (core.slice.index.SliceIndexUsizeSliceTInst (List Usize)) slots 0#usize get_elem_mut_loop x l -/- [loops::get_elem_mut]: loop 0: backward function 0 -/ +/- [loops::get_elem_mut]: loop 0: backward function 0 + Source: 'src/loops.rs', lines 103:0-117:1 -/ divergent def get_elem_mut_loop_back (x : Usize) (ls : List Usize) (ret0 : Usize) : Result (List Usize) := match ls with @@ -166,7 +186,8 @@ divergent def get_elem_mut_loop_back Result.ret (List.Cons y tl0) | List.Nil => Result.fail Error.panic -/- [loops::get_elem_mut]: backward function 0 -/ +/- [loops::get_elem_mut]: backward function 0 + Source: 'src/loops.rs', lines 103:0-103:73 -/ def get_elem_mut_back (slots : alloc.vec.Vec (List Usize)) (x : Usize) (ret0 : Usize) : Result (alloc.vec.Vec (List Usize)) @@ -180,7 +201,8 @@ def get_elem_mut_back (core.slice.index.SliceIndexUsizeSliceTInst (List Usize)) slots 0#usize l0 -/- [loops::get_elem_shared]: loop 0: forward function -/ +/- [loops::get_elem_shared]: loop 0: forward function + Source: 'src/loops.rs', lines 119:0-133:1 -/ divergent def get_elem_shared_loop (x : Usize) (ls : List Usize) : Result Usize := match ls with @@ -189,7 +211,8 @@ divergent def get_elem_shared_loop else get_elem_shared_loop x tl | List.Nil => Result.fail Error.panic -/- [loops::get_elem_shared]: forward function -/ +/- [loops::get_elem_shared]: forward function + Source: 'src/loops.rs', lines 119:0-119:68 -/ def get_elem_shared (slots : alloc.vec.Vec (List Usize)) (x : Usize) : Result Usize := do @@ -198,19 +221,23 @@ def get_elem_shared (core.slice.index.SliceIndexUsizeSliceTInst (List Usize)) slots 0#usize get_elem_shared_loop x l -/- [loops::id_mut]: forward function -/ +/- [loops::id_mut]: forward function + Source: 'src/loops.rs', lines 135:0-135:50 -/ def id_mut (T : Type) (ls : List T) : Result (List T) := Result.ret ls -/- [loops::id_mut]: backward function 0 -/ +/- [loops::id_mut]: backward function 0 + Source: 'src/loops.rs', lines 135:0-135:50 -/ def id_mut_back (T : Type) (ls : List T) (ret0 : List T) : Result (List T) := Result.ret ret0 -/- [loops::id_shared]: forward function -/ +/- [loops::id_shared]: forward function + Source: 'src/loops.rs', lines 139:0-139:45 -/ def id_shared (T : Type) (ls : List T) : Result (List T) := Result.ret ls -/- [loops::list_nth_mut_loop_with_id]: loop 0: forward function -/ +/- [loops::list_nth_mut_loop_with_id]: loop 0: forward function + Source: 'src/loops.rs', lines 144:0-155:1 -/ divergent def list_nth_mut_loop_with_id_loop (T : Type) (i : U32) (ls : List T) : Result T := match ls with @@ -222,13 +249,15 @@ divergent def list_nth_mut_loop_with_id_loop list_nth_mut_loop_with_id_loop T i0 tl | List.Nil => Result.fail Error.panic -/- [loops::list_nth_mut_loop_with_id]: forward function -/ +/- [loops::list_nth_mut_loop_with_id]: forward function + Source: 'src/loops.rs', lines 144:0-144:75 -/ def list_nth_mut_loop_with_id (T : Type) (ls : List T) (i : U32) : Result T := do let ls0 ← id_mut T ls list_nth_mut_loop_with_id_loop T i ls0 -/- [loops::list_nth_mut_loop_with_id]: loop 0: backward function 0 -/ +/- [loops::list_nth_mut_loop_with_id]: loop 0: backward function 0 + Source: 'src/loops.rs', lines 144:0-155:1 -/ divergent def list_nth_mut_loop_with_id_loop_back (T : Type) (i : U32) (ls : List T) (ret0 : T) : Result (List T) := match ls with @@ -242,7 +271,8 @@ divergent def list_nth_mut_loop_with_id_loop_back Result.ret (List.Cons x tl0) | List.Nil => Result.fail Error.panic -/- [loops::list_nth_mut_loop_with_id]: backward function 0 -/ +/- [loops::list_nth_mut_loop_with_id]: backward function 0 + Source: 'src/loops.rs', lines 144:0-144:75 -/ def list_nth_mut_loop_with_id_back (T : Type) (ls : List T) (i : U32) (ret0 : T) : Result (List T) := do @@ -250,7 +280,8 @@ def list_nth_mut_loop_with_id_back let l ← list_nth_mut_loop_with_id_loop_back T i ls0 ret0 id_mut_back T ls l -/- [loops::list_nth_shared_loop_with_id]: loop 0: forward function -/ +/- [loops::list_nth_shared_loop_with_id]: loop 0: forward function + Source: 'src/loops.rs', lines 158:0-169:1 -/ divergent def list_nth_shared_loop_with_id_loop (T : Type) (i : U32) (ls : List T) : Result T := match ls with @@ -262,14 +293,16 @@ divergent def list_nth_shared_loop_with_id_loop list_nth_shared_loop_with_id_loop T i0 tl | List.Nil => Result.fail Error.panic -/- [loops::list_nth_shared_loop_with_id]: forward function -/ +/- [loops::list_nth_shared_loop_with_id]: forward function + Source: 'src/loops.rs', lines 158:0-158:70 -/ def list_nth_shared_loop_with_id (T : Type) (ls : List T) (i : U32) : Result T := do let ls0 ← id_shared T ls list_nth_shared_loop_with_id_loop T i ls0 -/- [loops::list_nth_mut_loop_pair]: loop 0: forward function -/ +/- [loops::list_nth_mut_loop_pair]: loop 0: forward function + Source: 'src/loops.rs', lines 174:0-195:1 -/ divergent def list_nth_mut_loop_pair_loop (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := match ls0 with @@ -284,12 +317,14 @@ divergent def list_nth_mut_loop_pair_loop | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_mut_loop_pair]: forward function -/ +/- [loops::list_nth_mut_loop_pair]: forward function + Source: 'src/loops.rs', lines 174:0-178:27 -/ def list_nth_mut_loop_pair (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := list_nth_mut_loop_pair_loop T ls0 ls1 i -/- [loops::list_nth_mut_loop_pair]: loop 0: backward function 0 -/ +/- [loops::list_nth_mut_loop_pair]: loop 0: backward function 0 + Source: 'src/loops.rs', lines 174:0-195:1 -/ divergent def list_nth_mut_loop_pair_loop_back'a (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : Result (List T) @@ -308,14 +343,16 @@ divergent def list_nth_mut_loop_pair_loop_back'a | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_mut_loop_pair]: backward function 0 -/ +/- [loops::list_nth_mut_loop_pair]: backward function 0 + Source: 'src/loops.rs', lines 174:0-178:27 -/ def list_nth_mut_loop_pair_back'a (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : Result (List T) := list_nth_mut_loop_pair_loop_back'a T ls0 ls1 i ret0 -/- [loops::list_nth_mut_loop_pair]: loop 0: backward function 1 -/ +/- [loops::list_nth_mut_loop_pair]: loop 0: backward function 1 + Source: 'src/loops.rs', lines 174:0-195:1 -/ divergent def list_nth_mut_loop_pair_loop_back'b (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : Result (List T) @@ -334,14 +371,16 @@ divergent def list_nth_mut_loop_pair_loop_back'b | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_mut_loop_pair]: backward function 1 -/ +/- [loops::list_nth_mut_loop_pair]: backward function 1 + Source: 'src/loops.rs', lines 174:0-178:27 -/ def list_nth_mut_loop_pair_back'b (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : Result (List T) := list_nth_mut_loop_pair_loop_back'b T ls0 ls1 i ret0 -/- [loops::list_nth_shared_loop_pair]: loop 0: forward function -/ +/- [loops::list_nth_shared_loop_pair]: loop 0: forward function + Source: 'src/loops.rs', lines 198:0-219: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 @@ -356,12 +395,14 @@ divergent def list_nth_shared_loop_pair_loop | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_shared_loop_pair]: forward function -/ +/- [loops::list_nth_shared_loop_pair]: forward function + Source: 'src/loops.rs', lines 198:0-202:19 -/ def list_nth_shared_loop_pair (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := list_nth_shared_loop_pair_loop T ls0 ls1 i -/- [loops::list_nth_mut_loop_pair_merge]: loop 0: forward function -/ +/- [loops::list_nth_mut_loop_pair_merge]: loop 0: forward function + Source: 'src/loops.rs', lines 223:0-238:1 -/ divergent def list_nth_mut_loop_pair_merge_loop (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := match ls0 with @@ -377,12 +418,14 @@ divergent def list_nth_mut_loop_pair_merge_loop | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_mut_loop_pair_merge]: forward function -/ +/- [loops::list_nth_mut_loop_pair_merge]: forward function + Source: 'src/loops.rs', lines 223:0-227:27 -/ def list_nth_mut_loop_pair_merge (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := list_nth_mut_loop_pair_merge_loop T ls0 ls1 i -/- [loops::list_nth_mut_loop_pair_merge]: loop 0: backward function 0 -/ +/- [loops::list_nth_mut_loop_pair_merge]: loop 0: backward function 0 + Source: 'src/loops.rs', lines 223:0-238:1 -/ divergent def list_nth_mut_loop_pair_merge_loop_back (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : (T × T)) : Result ((List T) × (List T)) @@ -403,14 +446,16 @@ divergent def list_nth_mut_loop_pair_merge_loop_back | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_mut_loop_pair_merge]: backward function 0 -/ +/- [loops::list_nth_mut_loop_pair_merge]: backward function 0 + Source: 'src/loops.rs', lines 223:0-227:27 -/ def list_nth_mut_loop_pair_merge_back (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : (T × T)) : Result ((List T) × (List T)) := list_nth_mut_loop_pair_merge_loop_back T ls0 ls1 i ret0 -/- [loops::list_nth_shared_loop_pair_merge]: loop 0: forward function -/ +/- [loops::list_nth_shared_loop_pair_merge]: loop 0: forward function + Source: 'src/loops.rs', lines 241:0-256: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 @@ -426,12 +471,14 @@ divergent def list_nth_shared_loop_pair_merge_loop | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_shared_loop_pair_merge]: forward function -/ +/- [loops::list_nth_shared_loop_pair_merge]: forward function + Source: 'src/loops.rs', lines 241:0-245:19 -/ def list_nth_shared_loop_pair_merge (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := list_nth_shared_loop_pair_merge_loop T ls0 ls1 i -/- [loops::list_nth_mut_shared_loop_pair]: loop 0: forward function -/ +/- [loops::list_nth_mut_shared_loop_pair]: loop 0: forward function + Source: 'src/loops.rs', lines 259:0-274:1 -/ divergent def list_nth_mut_shared_loop_pair_loop (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := match ls0 with @@ -447,12 +494,14 @@ divergent def list_nth_mut_shared_loop_pair_loop | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_mut_shared_loop_pair]: forward function -/ +/- [loops::list_nth_mut_shared_loop_pair]: forward function + Source: 'src/loops.rs', lines 259:0-263:23 -/ def list_nth_mut_shared_loop_pair (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := list_nth_mut_shared_loop_pair_loop T ls0 ls1 i -/- [loops::list_nth_mut_shared_loop_pair]: loop 0: backward function 0 -/ +/- [loops::list_nth_mut_shared_loop_pair]: loop 0: backward function 0 + Source: 'src/loops.rs', lines 259:0-274:1 -/ divergent def list_nth_mut_shared_loop_pair_loop_back (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : Result (List T) @@ -472,14 +521,16 @@ divergent def list_nth_mut_shared_loop_pair_loop_back | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_mut_shared_loop_pair]: backward function 0 -/ +/- [loops::list_nth_mut_shared_loop_pair]: backward function 0 + Source: 'src/loops.rs', lines 259:0-263:23 -/ def list_nth_mut_shared_loop_pair_back (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : Result (List T) := list_nth_mut_shared_loop_pair_loop_back T ls0 ls1 i ret0 -/- [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: forward function -/ +/- [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: forward function + Source: 'src/loops.rs', lines 278:0-293:1 -/ divergent def list_nth_mut_shared_loop_pair_merge_loop (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := match ls0 with @@ -495,12 +546,14 @@ divergent def list_nth_mut_shared_loop_pair_merge_loop | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_mut_shared_loop_pair_merge]: forward function -/ +/- [loops::list_nth_mut_shared_loop_pair_merge]: forward function + Source: 'src/loops.rs', lines 278:0-282:23 -/ def list_nth_mut_shared_loop_pair_merge (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := list_nth_mut_shared_loop_pair_merge_loop T ls0 ls1 i -/- [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: backward function 0 -/ +/- [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: backward function 0 + Source: 'src/loops.rs', lines 278:0-293:1 -/ divergent def list_nth_mut_shared_loop_pair_merge_loop_back (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : Result (List T) @@ -520,14 +573,16 @@ divergent def list_nth_mut_shared_loop_pair_merge_loop_back | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_mut_shared_loop_pair_merge]: backward function 0 -/ +/- [loops::list_nth_mut_shared_loop_pair_merge]: backward function 0 + Source: 'src/loops.rs', lines 278:0-282:23 -/ def list_nth_mut_shared_loop_pair_merge_back (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : Result (List T) := list_nth_mut_shared_loop_pair_merge_loop_back T ls0 ls1 i ret0 -/- [loops::list_nth_shared_mut_loop_pair]: loop 0: forward function -/ +/- [loops::list_nth_shared_mut_loop_pair]: loop 0: forward function + Source: 'src/loops.rs', lines 297:0-312:1 -/ divergent def list_nth_shared_mut_loop_pair_loop (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := match ls0 with @@ -543,12 +598,14 @@ divergent def list_nth_shared_mut_loop_pair_loop | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_shared_mut_loop_pair]: forward function -/ +/- [loops::list_nth_shared_mut_loop_pair]: forward function + Source: 'src/loops.rs', lines 297:0-301:23 -/ def list_nth_shared_mut_loop_pair (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := list_nth_shared_mut_loop_pair_loop T ls0 ls1 i -/- [loops::list_nth_shared_mut_loop_pair]: loop 0: backward function 1 -/ +/- [loops::list_nth_shared_mut_loop_pair]: loop 0: backward function 1 + Source: 'src/loops.rs', lines 297:0-312:1 -/ divergent def list_nth_shared_mut_loop_pair_loop_back (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : Result (List T) @@ -568,14 +625,16 @@ divergent def list_nth_shared_mut_loop_pair_loop_back | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_shared_mut_loop_pair]: backward function 1 -/ +/- [loops::list_nth_shared_mut_loop_pair]: backward function 1 + Source: 'src/loops.rs', lines 297:0-301:23 -/ def list_nth_shared_mut_loop_pair_back (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : Result (List T) := list_nth_shared_mut_loop_pair_loop_back T ls0 ls1 i ret0 -/- [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: forward function -/ +/- [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: forward function + Source: 'src/loops.rs', lines 316:0-331:1 -/ divergent def list_nth_shared_mut_loop_pair_merge_loop (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := match ls0 with @@ -591,12 +650,14 @@ divergent def list_nth_shared_mut_loop_pair_merge_loop | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_shared_mut_loop_pair_merge]: forward function -/ +/- [loops::list_nth_shared_mut_loop_pair_merge]: forward function + Source: 'src/loops.rs', lines 316:0-320:23 -/ def list_nth_shared_mut_loop_pair_merge (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) : Result (T × T) := list_nth_shared_mut_loop_pair_merge_loop T ls0 ls1 i -/- [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: backward function 0 -/ +/- [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: backward function 0 + Source: 'src/loops.rs', lines 316:0-331:1 -/ divergent def list_nth_shared_mut_loop_pair_merge_loop_back (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : Result (List T) @@ -616,7 +677,8 @@ divergent def list_nth_shared_mut_loop_pair_merge_loop_back | List.Nil => Result.fail Error.panic | List.Nil => Result.fail Error.panic -/- [loops::list_nth_shared_mut_loop_pair_merge]: backward function 0 -/ +/- [loops::list_nth_shared_mut_loop_pair_merge]: backward function 0 + Source: 'src/loops.rs', lines 316:0-320:23 -/ def list_nth_shared_mut_loop_pair_merge_back (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : Result (List T) diff --git a/tests/lean/NoNestedBorrows.lean b/tests/lean/NoNestedBorrows.lean index 79049837..3b1c3f9f 100644 --- a/tests/lean/NoNestedBorrows.lean +++ b/tests/lean/NoNestedBorrows.lean @@ -5,78 +5,96 @@ open Primitives namespace no_nested_borrows -/- [no_nested_borrows::Pair] -/ +/- [no_nested_borrows::Pair] + Source: 'src/no_nested_borrows.rs', lines 4:0-4:23 -/ structure Pair (T1 T2 : Type) where x : T1 y : T2 -/- [no_nested_borrows::List] -/ +/- [no_nested_borrows::List] + Source: 'src/no_nested_borrows.rs', lines 9:0-9:16 -/ inductive List (T : Type) := | Cons : T → List T → List T | Nil : List T -/- [no_nested_borrows::One] -/ +/- [no_nested_borrows::One] + Source: 'src/no_nested_borrows.rs', lines 20:0-20:16 -/ inductive One (T1 : Type) := | One : T1 → One T1 -/- [no_nested_borrows::EmptyEnum] -/ +/- [no_nested_borrows::EmptyEnum] + Source: 'src/no_nested_borrows.rs', lines 26:0-26:18 -/ inductive EmptyEnum := | Empty : EmptyEnum -/- [no_nested_borrows::Enum] -/ +/- [no_nested_borrows::Enum] + Source: 'src/no_nested_borrows.rs', lines 32:0-32:13 -/ inductive Enum := | Variant1 : Enum | Variant2 : Enum -/- [no_nested_borrows::EmptyStruct] -/ +/- [no_nested_borrows::EmptyStruct] + Source: 'src/no_nested_borrows.rs', lines 39:0-39:22 -/ structure EmptyStruct where -/- [no_nested_borrows::Sum] -/ +/- [no_nested_borrows::Sum] + Source: 'src/no_nested_borrows.rs', lines 41:0-41:20 -/ inductive Sum (T1 T2 : Type) := | Left : T1 → Sum T1 T2 | Right : T2 → Sum T1 T2 -/- [no_nested_borrows::neg_test]: forward function -/ +/- [no_nested_borrows::neg_test]: forward function + Source: 'src/no_nested_borrows.rs', lines 48:0-48:30 -/ def neg_test (x : I32) : Result I32 := - x -/- [no_nested_borrows::add_test]: forward function -/ +/- [no_nested_borrows::add_test]: forward function + Source: 'src/no_nested_borrows.rs', lines 54:0-54:38 -/ def add_test (x : U32) (y : U32) : Result U32 := x + y -/- [no_nested_borrows::subs_test]: forward function -/ +/- [no_nested_borrows::subs_test]: forward function + Source: 'src/no_nested_borrows.rs', lines 60:0-60:39 -/ def subs_test (x : U32) (y : U32) : Result U32 := x - y -/- [no_nested_borrows::div_test]: forward function -/ +/- [no_nested_borrows::div_test]: forward function + Source: 'src/no_nested_borrows.rs', lines 66:0-66:38 -/ def div_test (x : U32) (y : U32) : Result U32 := x / y -/- [no_nested_borrows::div_test1]: forward function -/ +/- [no_nested_borrows::div_test1]: forward function + Source: 'src/no_nested_borrows.rs', lines 73:0-73:31 -/ def div_test1 (x : U32) : Result U32 := x / 2#u32 -/- [no_nested_borrows::rem_test]: forward function -/ +/- [no_nested_borrows::rem_test]: forward function + Source: 'src/no_nested_borrows.rs', lines 78:0-78:38 -/ def rem_test (x : U32) (y : U32) : Result U32 := x % y -/- [no_nested_borrows::mul_test]: forward function -/ +/- [no_nested_borrows::mul_test]: forward function + Source: 'src/no_nested_borrows.rs', lines 82:0-82:38 -/ def mul_test (x : U32) (y : U32) : Result U32 := x * y -/- [no_nested_borrows::CONST0] -/ +/- [no_nested_borrows::CONST0] + Source: 'src/no_nested_borrows.rs', lines 91:0-91:23 -/ def const0_body : Result Usize := 1#usize + 1#usize def const0_c : Usize := eval_global const0_body (by simp) -/- [no_nested_borrows::CONST1] -/ +/- [no_nested_borrows::CONST1] + Source: 'src/no_nested_borrows.rs', lines 92:0-92:23 -/ def const1_body : Result Usize := 2#usize * 2#usize def const1_c : Usize := eval_global const1_body (by simp) -/- [no_nested_borrows::cast_test]: forward function -/ +/- [no_nested_borrows::cast_test]: forward function + Source: 'src/no_nested_borrows.rs', lines 94:0-94:31 -/ def cast_test (x : U32) : Result I32 := Scalar.cast .I32 x -/- [no_nested_borrows::test2]: forward function -/ +/- [no_nested_borrows::test2]: forward function + Source: 'src/no_nested_borrows.rs', lines 99:0-99:14 -/ def test2 : Result Unit := do let _ ← 23#u32 + 44#u32 @@ -85,13 +103,15 @@ def test2 : Result Unit := /- Unit test for [no_nested_borrows::test2] -/ #assert (test2 == .ret ()) -/- [no_nested_borrows::get_max]: forward function -/ +/- [no_nested_borrows::get_max]: forward function + Source: 'src/no_nested_borrows.rs', lines 111:0-111:37 -/ def get_max (x : U32) (y : U32) : Result U32 := if x >= y then Result.ret x else Result.ret y -/- [no_nested_borrows::test3]: forward function -/ +/- [no_nested_borrows::test3]: forward function + Source: 'src/no_nested_borrows.rs', lines 119:0-119:14 -/ def test3 : Result Unit := do let x ← get_max 4#u32 3#u32 @@ -104,7 +124,8 @@ def test3 : Result Unit := /- Unit test for [no_nested_borrows::test3] -/ #assert (test3 == .ret ()) -/- [no_nested_borrows::test_neg1]: forward function -/ +/- [no_nested_borrows::test_neg1]: forward function + Source: 'src/no_nested_borrows.rs', lines 126:0-126:18 -/ def test_neg1 : Result Unit := do let y ← - 3#i32 @@ -115,7 +136,8 @@ def test_neg1 : Result Unit := /- Unit test for [no_nested_borrows::test_neg1] -/ #assert (test_neg1 == .ret ()) -/- [no_nested_borrows::refs_test1]: forward function -/ +/- [no_nested_borrows::refs_test1]: forward function + Source: 'src/no_nested_borrows.rs', lines 133:0-133:19 -/ def refs_test1 : Result Unit := if not (1#i32 = 1#i32) then Result.fail Error.panic @@ -124,7 +146,8 @@ def refs_test1 : Result Unit := /- Unit test for [no_nested_borrows::refs_test1] -/ #assert (refs_test1 == .ret ()) -/- [no_nested_borrows::refs_test2]: forward function -/ +/- [no_nested_borrows::refs_test2]: forward function + Source: 'src/no_nested_borrows.rs', lines 144:0-144:19 -/ def refs_test2 : Result Unit := if not (2#i32 = 2#i32) then Result.fail Error.panic @@ -142,14 +165,16 @@ def refs_test2 : Result Unit := /- Unit test for [no_nested_borrows::refs_test2] -/ #assert (refs_test2 == .ret ()) -/- [no_nested_borrows::test_list1]: forward function -/ +/- [no_nested_borrows::test_list1]: forward function + Source: 'src/no_nested_borrows.rs', lines 160:0-160:19 -/ def test_list1 : Result Unit := Result.ret () /- Unit test for [no_nested_borrows::test_list1] -/ #assert (test_list1 == .ret ()) -/- [no_nested_borrows::test_box1]: forward function -/ +/- [no_nested_borrows::test_box1]: forward function + Source: 'src/no_nested_borrows.rs', lines 165:0-165:18 -/ def test_box1 : Result Unit := do let b := 0#i32 @@ -162,23 +187,27 @@ def test_box1 : Result Unit := /- Unit test for [no_nested_borrows::test_box1] -/ #assert (test_box1 == .ret ()) -/- [no_nested_borrows::copy_int]: forward function -/ +/- [no_nested_borrows::copy_int]: forward function + Source: 'src/no_nested_borrows.rs', lines 175:0-175:30 -/ def copy_int (x : I32) : Result I32 := Result.ret x -/- [no_nested_borrows::test_unreachable]: forward function -/ +/- [no_nested_borrows::test_unreachable]: forward function + Source: 'src/no_nested_borrows.rs', lines 181:0-181:32 -/ def test_unreachable (b : Bool) : Result Unit := if b then Result.fail Error.panic else Result.ret () -/- [no_nested_borrows::test_panic]: forward function -/ +/- [no_nested_borrows::test_panic]: forward function + Source: 'src/no_nested_borrows.rs', lines 189:0-189:26 -/ def test_panic (b : Bool) : Result Unit := if b then Result.fail Error.panic else Result.ret () -/- [no_nested_borrows::test_copy_int]: forward function -/ +/- [no_nested_borrows::test_copy_int]: forward function + Source: 'src/no_nested_borrows.rs', lines 196:0-196:22 -/ def test_copy_int : Result Unit := do let y ← copy_int 0#i32 @@ -189,13 +218,15 @@ def test_copy_int : Result Unit := /- Unit test for [no_nested_borrows::test_copy_int] -/ #assert (test_copy_int == .ret ()) -/- [no_nested_borrows::is_cons]: forward function -/ +/- [no_nested_borrows::is_cons]: forward function + Source: 'src/no_nested_borrows.rs', lines 203:0-203:38 -/ def is_cons (T : Type) (l : List T) : Result Bool := match l with | List.Cons t l0 => Result.ret true | List.Nil => Result.ret false -/- [no_nested_borrows::test_is_cons]: forward function -/ +/- [no_nested_borrows::test_is_cons]: forward function + Source: 'src/no_nested_borrows.rs', lines 210:0-210:21 -/ def test_is_cons : Result Unit := do let l := List.Nil @@ -207,13 +238,15 @@ def test_is_cons : Result Unit := /- Unit test for [no_nested_borrows::test_is_cons] -/ #assert (test_is_cons == .ret ()) -/- [no_nested_borrows::split_list]: forward function -/ +/- [no_nested_borrows::split_list]: forward function + Source: 'src/no_nested_borrows.rs', lines 216:0-216:48 -/ def split_list (T : Type) (l : List T) : Result (T × (List T)) := match l with | List.Cons hd tl => Result.ret (hd, tl) | List.Nil => Result.fail Error.panic -/- [no_nested_borrows::test_split_list]: forward function -/ +/- [no_nested_borrows::test_split_list]: forward function + Source: 'src/no_nested_borrows.rs', lines 224:0-224:24 -/ def test_split_list : Result Unit := do let l := List.Nil @@ -226,20 +259,23 @@ def test_split_list : Result Unit := /- Unit test for [no_nested_borrows::test_split_list] -/ #assert (test_split_list == .ret ()) -/- [no_nested_borrows::choose]: forward function -/ +/- [no_nested_borrows::choose]: forward function + Source: 'src/no_nested_borrows.rs', lines 231:0-231:70 -/ def choose (T : Type) (b : Bool) (x : T) (y : T) : Result T := if b then Result.ret x else Result.ret y -/- [no_nested_borrows::choose]: backward function 0 -/ +/- [no_nested_borrows::choose]: backward function 0 + Source: 'src/no_nested_borrows.rs', lines 231:0-231:70 -/ def choose_back (T : Type) (b : Bool) (x : T) (y : T) (ret0 : T) : Result (T × T) := if b then Result.ret (ret0, y) else Result.ret (x, ret0) -/- [no_nested_borrows::choose_test]: forward function -/ +/- [no_nested_borrows::choose_test]: forward function + Source: 'src/no_nested_borrows.rs', lines 239:0-239:20 -/ def choose_test : Result Unit := do let z ← choose I32 true 0#i32 0#i32 @@ -258,25 +294,29 @@ def choose_test : Result Unit := /- Unit test for [no_nested_borrows::choose_test] -/ #assert (choose_test == .ret ()) -/- [no_nested_borrows::test_char]: forward function -/ +/- [no_nested_borrows::test_char]: forward function + Source: 'src/no_nested_borrows.rs', lines 251:0-251:26 -/ def test_char : Result Char := Result.ret 'a' mutual -/- [no_nested_borrows::Tree] -/ +/- [no_nested_borrows::Tree] + Source: 'src/no_nested_borrows.rs', lines 256:0-256:16 -/ inductive Tree (T : Type) := | Leaf : T → Tree T | Node : T → NodeElem T → Tree T → Tree T -/- [no_nested_borrows::NodeElem] -/ +/- [no_nested_borrows::NodeElem] + Source: 'src/no_nested_borrows.rs', lines 261:0-261:20 -/ inductive NodeElem (T : Type) := | Cons : Tree T → NodeElem T → NodeElem T | Nil : NodeElem T end -/- [no_nested_borrows::list_length]: forward function -/ +/- [no_nested_borrows::list_length]: forward function + Source: 'src/no_nested_borrows.rs', lines 296:0-296:48 -/ divergent def list_length (T : Type) (l : List T) : Result U32 := match l with | List.Cons t l1 => do @@ -284,7 +324,8 @@ divergent def list_length (T : Type) (l : List T) : Result U32 := 1#u32 + i | List.Nil => Result.ret 0#u32 -/- [no_nested_borrows::list_nth_shared]: forward function -/ +/- [no_nested_borrows::list_nth_shared]: forward function + Source: 'src/no_nested_borrows.rs', lines 304:0-304:62 -/ divergent def list_nth_shared (T : Type) (l : List T) (i : U32) : Result T := match l with | List.Cons x tl => @@ -295,7 +336,8 @@ divergent def list_nth_shared (T : Type) (l : List T) (i : U32) : Result T := list_nth_shared T tl i0 | List.Nil => Result.fail Error.panic -/- [no_nested_borrows::list_nth_mut]: forward function -/ +/- [no_nested_borrows::list_nth_mut]: forward function + Source: 'src/no_nested_borrows.rs', lines 320:0-320:67 -/ divergent def list_nth_mut (T : Type) (l : List T) (i : U32) : Result T := match l with | List.Cons x tl => @@ -306,7 +348,8 @@ divergent def list_nth_mut (T : Type) (l : List T) (i : U32) : Result T := list_nth_mut T tl i0 | List.Nil => Result.fail Error.panic -/- [no_nested_borrows::list_nth_mut]: backward function 0 -/ +/- [no_nested_borrows::list_nth_mut]: backward function 0 + Source: 'src/no_nested_borrows.rs', lines 320:0-320:67 -/ divergent def list_nth_mut_back (T : Type) (l : List T) (i : U32) (ret0 : T) : Result (List T) := match l with @@ -320,7 +363,8 @@ divergent def list_nth_mut_back Result.ret (List.Cons x tl0) | List.Nil => Result.fail Error.panic -/- [no_nested_borrows::list_rev_aux]: forward function -/ +/- [no_nested_borrows::list_rev_aux]: forward function + Source: 'src/no_nested_borrows.rs', lines 336:0-336:63 -/ divergent def list_rev_aux (T : Type) (li : List T) (lo : List T) : Result (List T) := match li with @@ -328,12 +372,14 @@ divergent def list_rev_aux | List.Nil => Result.ret lo /- [no_nested_borrows::list_rev]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/no_nested_borrows.rs', lines 350:0-350:42 -/ def list_rev (T : Type) (l : List T) : Result (List T) := let li := core.mem.replace (List T) l List.Nil list_rev_aux T li List.Nil -/- [no_nested_borrows::test_list_functions]: forward function -/ +/- [no_nested_borrows::test_list_functions]: forward function + Source: 'src/no_nested_borrows.rs', lines 355:0-355:28 -/ def test_list_functions : Result Unit := do let l := List.Nil @@ -379,81 +425,98 @@ def test_list_functions : Result Unit := /- Unit test for [no_nested_borrows::test_list_functions] -/ #assert (test_list_functions == .ret ()) -/- [no_nested_borrows::id_mut_pair1]: forward function -/ +/- [no_nested_borrows::id_mut_pair1]: forward function + Source: 'src/no_nested_borrows.rs', lines 371:0-371:89 -/ def id_mut_pair1 (T1 T2 : Type) (x : T1) (y : T2) : Result (T1 × T2) := Result.ret (x, y) -/- [no_nested_borrows::id_mut_pair1]: backward function 0 -/ +/- [no_nested_borrows::id_mut_pair1]: backward function 0 + Source: 'src/no_nested_borrows.rs', lines 371:0-371:89 -/ def id_mut_pair1_back (T1 T2 : Type) (x : T1) (y : T2) (ret0 : (T1 × T2)) : Result (T1 × T2) := let (t, t0) := ret0 Result.ret (t, t0) -/- [no_nested_borrows::id_mut_pair2]: forward function -/ +/- [no_nested_borrows::id_mut_pair2]: forward function + Source: 'src/no_nested_borrows.rs', lines 375:0-375:88 -/ def id_mut_pair2 (T1 T2 : Type) (p : (T1 × T2)) : Result (T1 × T2) := let (t, t0) := p Result.ret (t, t0) -/- [no_nested_borrows::id_mut_pair2]: backward function 0 -/ +/- [no_nested_borrows::id_mut_pair2]: backward function 0 + Source: 'src/no_nested_borrows.rs', lines 375:0-375:88 -/ def id_mut_pair2_back (T1 T2 : Type) (p : (T1 × T2)) (ret0 : (T1 × T2)) : Result (T1 × T2) := let (t, t0) := ret0 Result.ret (t, t0) -/- [no_nested_borrows::id_mut_pair3]: forward function -/ +/- [no_nested_borrows::id_mut_pair3]: forward function + Source: 'src/no_nested_borrows.rs', lines 379:0-379:93 -/ def id_mut_pair3 (T1 T2 : Type) (x : T1) (y : T2) : Result (T1 × T2) := Result.ret (x, y) -/- [no_nested_borrows::id_mut_pair3]: backward function 0 -/ +/- [no_nested_borrows::id_mut_pair3]: backward function 0 + Source: 'src/no_nested_borrows.rs', lines 379:0-379:93 -/ def id_mut_pair3_back'a (T1 T2 : Type) (x : T1) (y : T2) (ret0 : T1) : Result T1 := Result.ret ret0 -/- [no_nested_borrows::id_mut_pair3]: backward function 1 -/ +/- [no_nested_borrows::id_mut_pair3]: backward function 1 + Source: 'src/no_nested_borrows.rs', lines 379:0-379:93 -/ def id_mut_pair3_back'b (T1 T2 : Type) (x : T1) (y : T2) (ret0 : T2) : Result T2 := Result.ret ret0 -/- [no_nested_borrows::id_mut_pair4]: forward function -/ +/- [no_nested_borrows::id_mut_pair4]: forward function + Source: 'src/no_nested_borrows.rs', lines 383:0-383:92 -/ def id_mut_pair4 (T1 T2 : Type) (p : (T1 × T2)) : Result (T1 × T2) := let (t, t0) := p Result.ret (t, t0) -/- [no_nested_borrows::id_mut_pair4]: backward function 0 -/ +/- [no_nested_borrows::id_mut_pair4]: backward function 0 + Source: 'src/no_nested_borrows.rs', lines 383:0-383:92 -/ def id_mut_pair4_back'a (T1 T2 : Type) (p : (T1 × T2)) (ret0 : T1) : Result T1 := Result.ret ret0 -/- [no_nested_borrows::id_mut_pair4]: backward function 1 -/ +/- [no_nested_borrows::id_mut_pair4]: backward function 1 + Source: 'src/no_nested_borrows.rs', lines 383:0-383:92 -/ def id_mut_pair4_back'b (T1 T2 : Type) (p : (T1 × T2)) (ret0 : T2) : Result T2 := Result.ret ret0 -/- [no_nested_borrows::StructWithTuple] -/ +/- [no_nested_borrows::StructWithTuple] + Source: 'src/no_nested_borrows.rs', lines 390:0-390:34 -/ structure StructWithTuple (T1 T2 : Type) where p : (T1 × T2) -/- [no_nested_borrows::new_tuple1]: forward function -/ +/- [no_nested_borrows::new_tuple1]: forward function + Source: 'src/no_nested_borrows.rs', lines 394:0-394:48 -/ def new_tuple1 : Result (StructWithTuple U32 U32) := Result.ret { p := (1#u32, 2#u32) } -/- [no_nested_borrows::new_tuple2]: forward function -/ +/- [no_nested_borrows::new_tuple2]: forward function + Source: 'src/no_nested_borrows.rs', lines 398:0-398:48 -/ def new_tuple2 : Result (StructWithTuple I16 I16) := Result.ret { p := (1#i16, 2#i16) } -/- [no_nested_borrows::new_tuple3]: forward function -/ +/- [no_nested_borrows::new_tuple3]: forward function + Source: 'src/no_nested_borrows.rs', lines 402:0-402:48 -/ def new_tuple3 : Result (StructWithTuple U64 I64) := Result.ret { p := (1#u64, 2#i64) } -/- [no_nested_borrows::StructWithPair] -/ +/- [no_nested_borrows::StructWithPair] + Source: 'src/no_nested_borrows.rs', lines 407:0-407:33 -/ structure StructWithPair (T1 T2 : Type) where p : Pair T1 T2 -/- [no_nested_borrows::new_pair1]: forward function -/ +/- [no_nested_borrows::new_pair1]: forward function + Source: 'src/no_nested_borrows.rs', lines 411:0-411:46 -/ def new_pair1 : Result (StructWithPair U32 U32) := Result.ret { p := { x := 1#u32, y := 2#u32 } } -/- [no_nested_borrows::test_constants]: forward function -/ +/- [no_nested_borrows::test_constants]: forward function + Source: 'src/no_nested_borrows.rs', lines 419:0-419:23 -/ def test_constants : Result Unit := do let swt ← new_tuple1 @@ -482,7 +545,8 @@ def test_constants : Result Unit := /- Unit test for [no_nested_borrows::test_constants] -/ #assert (test_constants == .ret ()) -/- [no_nested_borrows::test_weird_borrows1]: forward function -/ +/- [no_nested_borrows::test_weird_borrows1]: forward function + Source: 'src/no_nested_borrows.rs', lines 428:0-428:28 -/ def test_weird_borrows1 : Result Unit := Result.ret () @@ -490,30 +554,35 @@ def test_weird_borrows1 : Result Unit := #assert (test_weird_borrows1 == .ret ()) /- [no_nested_borrows::test_mem_replace]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/no_nested_borrows.rs', lines 438:0-438:37 -/ def test_mem_replace (px : U32) : Result U32 := let y := core.mem.replace U32 px 1#u32 if not (y = 0#u32) then Result.fail Error.panic else Result.ret 2#u32 -/- [no_nested_borrows::test_shared_borrow_bool1]: forward function -/ +/- [no_nested_borrows::test_shared_borrow_bool1]: forward function + Source: 'src/no_nested_borrows.rs', lines 445:0-445:47 -/ def test_shared_borrow_bool1 (b : Bool) : Result U32 := if b then Result.ret 0#u32 else Result.ret 1#u32 -/- [no_nested_borrows::test_shared_borrow_bool2]: forward function -/ +/- [no_nested_borrows::test_shared_borrow_bool2]: forward function + Source: 'src/no_nested_borrows.rs', lines 458:0-458:40 -/ def test_shared_borrow_bool2 : Result U32 := Result.ret 0#u32 -/- [no_nested_borrows::test_shared_borrow_enum1]: forward function -/ +/- [no_nested_borrows::test_shared_borrow_enum1]: forward function + Source: 'src/no_nested_borrows.rs', lines 473:0-473:52 -/ def test_shared_borrow_enum1 (l : List U32) : Result U32 := match l with | List.Cons i l0 => Result.ret 1#u32 | List.Nil => Result.ret 0#u32 -/- [no_nested_borrows::test_shared_borrow_enum2]: forward function -/ +/- [no_nested_borrows::test_shared_borrow_enum2]: forward function + Source: 'src/no_nested_borrows.rs', lines 485:0-485:40 -/ def test_shared_borrow_enum2 : Result U32 := Result.ret 0#u32 diff --git a/tests/lean/Paper.lean b/tests/lean/Paper.lean index ae4dd243..37e0e70e 100644 --- a/tests/lean/Paper.lean +++ b/tests/lean/Paper.lean @@ -6,11 +6,13 @@ open Primitives namespace paper /- [paper::ref_incr]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/paper.rs', lines 4:0-4:28 -/ def ref_incr (x : I32) : Result I32 := x + 1#i32 -/- [paper::test_incr]: forward function -/ +/- [paper::test_incr]: forward function + Source: 'src/paper.rs', lines 8:0-8:18 -/ def test_incr : Result Unit := do let x ← ref_incr 0#i32 @@ -21,20 +23,23 @@ def test_incr : Result Unit := /- Unit test for [paper::test_incr] -/ #assert (test_incr == .ret ()) -/- [paper::choose]: forward function -/ +/- [paper::choose]: forward function + Source: 'src/paper.rs', lines 15:0-15:70 -/ def choose (T : Type) (b : Bool) (x : T) (y : T) : Result T := if b then Result.ret x else Result.ret y -/- [paper::choose]: backward function 0 -/ +/- [paper::choose]: backward function 0 + Source: 'src/paper.rs', lines 15:0-15:70 -/ def choose_back (T : Type) (b : Bool) (x : T) (y : T) (ret0 : T) : Result (T × T) := if b then Result.ret (ret0, y) else Result.ret (x, ret0) -/- [paper::test_choose]: forward function -/ +/- [paper::test_choose]: forward function + Source: 'src/paper.rs', lines 23:0-23:20 -/ def test_choose : Result Unit := do let z ← choose I32 true 0#i32 0#i32 @@ -53,12 +58,14 @@ def test_choose : Result Unit := /- Unit test for [paper::test_choose] -/ #assert (test_choose == .ret ()) -/- [paper::List] -/ +/- [paper::List] + Source: 'src/paper.rs', lines 35:0-35:16 -/ inductive List (T : Type) := | Cons : T → List T → List T | Nil : List T -/- [paper::list_nth_mut]: forward function -/ +/- [paper::list_nth_mut]: forward function + Source: 'src/paper.rs', lines 42:0-42:67 -/ divergent def list_nth_mut (T : Type) (l : List T) (i : U32) : Result T := match l with | List.Cons x tl => @@ -69,7 +76,8 @@ divergent def list_nth_mut (T : Type) (l : List T) (i : U32) : Result T := list_nth_mut T tl i0 | List.Nil => Result.fail Error.panic -/- [paper::list_nth_mut]: backward function 0 -/ +/- [paper::list_nth_mut]: backward function 0 + Source: 'src/paper.rs', lines 42:0-42:67 -/ divergent def list_nth_mut_back (T : Type) (l : List T) (i : U32) (ret0 : T) : Result (List T) := match l with @@ -83,7 +91,8 @@ divergent def list_nth_mut_back Result.ret (List.Cons x tl0) | List.Nil => Result.fail Error.panic -/- [paper::sum]: forward function -/ +/- [paper::sum]: forward function + Source: 'src/paper.rs', lines 57:0-57:32 -/ divergent def sum (l : List I32) : Result I32 := match l with | List.Cons x tl => do @@ -91,7 +100,8 @@ divergent def sum (l : List I32) : Result I32 := x + i | List.Nil => Result.ret 0#i32 -/- [paper::test_nth]: forward function -/ +/- [paper::test_nth]: forward function + Source: 'src/paper.rs', lines 68:0-68:17 -/ def test_nth : Result Unit := do let l := List.Nil @@ -108,7 +118,8 @@ def test_nth : Result Unit := /- Unit test for [paper::test_nth] -/ #assert (test_nth == .ret ()) -/- [paper::call_choose]: forward function -/ +/- [paper::call_choose]: forward function + Source: 'src/paper.rs', lines 76:0-76:44 -/ def call_choose (p : (U32 × U32)) : Result U32 := do let (px, py) := p diff --git a/tests/lean/PoloniusList.lean b/tests/lean/PoloniusList.lean index 07f206a8..0ef71791 100644 --- a/tests/lean/PoloniusList.lean +++ b/tests/lean/PoloniusList.lean @@ -5,12 +5,14 @@ open Primitives namespace polonius_list -/- [polonius_list::List] -/ +/- [polonius_list::List] + Source: 'src/polonius_list.rs', lines 3:0-3:16 -/ inductive List (T : Type) := | Cons : T → List T → List T | Nil : List T -/- [polonius_list::get_list_at_x]: forward function -/ +/- [polonius_list::get_list_at_x]: forward function + Source: 'src/polonius_list.rs', lines 13:0-13:76 -/ divergent def get_list_at_x (ls : List U32) (x : U32) : Result (List U32) := match ls with | List.Cons hd tl => @@ -19,7 +21,8 @@ divergent def get_list_at_x (ls : List U32) (x : U32) : Result (List U32) := else get_list_at_x tl x | List.Nil => Result.ret List.Nil -/- [polonius_list::get_list_at_x]: backward function 0 -/ +/- [polonius_list::get_list_at_x]: backward function 0 + Source: 'src/polonius_list.rs', lines 13:0-13:76 -/ divergent def get_list_at_x_back (ls : List U32) (x : U32) (ret0 : List U32) : Result (List U32) := match ls with diff --git a/tests/lean/Traits.lean b/tests/lean/Traits.lean index 51a05581..f854da76 100644 --- a/tests/lean/Traits.lean +++ b/tests/lean/Traits.lean @@ -5,25 +5,30 @@ open Primitives namespace traits -/- Trait declaration: [traits::BoolTrait] -/ +/- Trait declaration: [traits::BoolTrait] + Source: 'src/traits.rs', lines 1:0-1:19 -/ structure BoolTrait (Self : Type) where get_bool : Self → Result Bool -/- [traits::{bool}::get_bool]: forward function -/ +/- [traits::{bool}::get_bool]: forward function + Source: 'src/traits.rs', lines 12:4-12:30 -/ def Bool.get_bool (self : Bool) : Result Bool := Result.ret self -/- Trait implementation: [traits::{bool}] -/ +/- Trait implementation: [traits::{bool}] + Source: 'src/traits.rs', lines 11:0-11:23 -/ def traits.BoolTraitBoolInst : BoolTrait Bool := { get_bool := Bool.get_bool } -/- [traits::BoolTrait::ret_true]: forward function -/ +/- [traits::BoolTrait::ret_true]: forward function + Source: 'src/traits.rs', lines 6:4-6:30 -/ def BoolTrait.ret_true {Self : Type} (self_clause : BoolTrait Self) (self : Self) : Result Bool := Result.ret true -/- [traits::test_bool_trait_bool]: forward function -/ +/- [traits::test_bool_trait_bool]: forward function + Source: 'src/traits.rs', lines 17:0-17:44 -/ def test_bool_trait_bool (x : Bool) : Result Bool := do let b ← Bool.get_bool x @@ -31,19 +36,22 @@ def test_bool_trait_bool (x : Bool) : Result Bool := then BoolTrait.ret_true traits.BoolTraitBoolInst x else Result.ret false -/- [traits::{core::option::Option#1}::get_bool]: forward function -/ +/- [traits::{core::option::Option#1}::get_bool]: forward function + Source: 'src/traits.rs', lines 23:4-23:30 -/ def Option.get_bool (T : Type) (self : Option T) : Result Bool := match self with | none => Result.ret false | some t => Result.ret true -/- Trait implementation: [traits::{core::option::Option#1}] -/ +/- Trait implementation: [traits::{core::option::Option#1}] + Source: 'src/traits.rs', lines 22:0-22:31 -/ def traits.BoolTraitcoreoptionOptionTInst (T : Type) : BoolTrait (Option T) := { get_bool := Option.get_bool T } -/- [traits::test_bool_trait_option]: forward function -/ +/- [traits::test_bool_trait_option]: forward function + Source: 'src/traits.rs', lines 31:0-31:54 -/ def test_bool_trait_option (T : Type) (x : Option T) : Result Bool := do let b ← Option.get_bool T x @@ -51,24 +59,29 @@ def test_bool_trait_option (T : Type) (x : Option T) : Result Bool := then BoolTrait.ret_true (traits.BoolTraitcoreoptionOptionTInst T) x else Result.ret false -/- [traits::test_bool_trait]: forward function -/ +/- [traits::test_bool_trait]: forward function + Source: 'src/traits.rs', lines 35:0-35:50 -/ def test_bool_trait (T : Type) (inst : BoolTrait T) (x : T) : Result Bool := inst.get_bool x -/- Trait declaration: [traits::ToU64] -/ +/- Trait declaration: [traits::ToU64] + Source: 'src/traits.rs', lines 39:0-39:15 -/ structure ToU64 (Self : Type) where to_u64 : Self → Result U64 -/- [traits::{u64#2}::to_u64]: forward function -/ +/- [traits::{u64#2}::to_u64]: forward function + Source: 'src/traits.rs', lines 44:4-44:26 -/ def U64.to_u64 (self : U64) : Result U64 := Result.ret self -/- Trait implementation: [traits::{u64#2}] -/ +/- Trait implementation: [traits::{u64#2}] + Source: 'src/traits.rs', lines 43:0-43:18 -/ def traits.ToU64U64Inst : ToU64 U64 := { to_u64 := U64.to_u64 } -/- [traits::{(A, A)#3}::to_u64]: forward function -/ +/- [traits::{(A, A)#3}::to_u64]: forward function + Source: 'src/traits.rs', lines 50:4-50:26 -/ def Pair.to_u64 (A : Type) (inst : ToU64 A) (self : (A × A)) : Result U64 := do let (t, t0) := self @@ -76,106 +89,128 @@ def Pair.to_u64 (A : Type) (inst : ToU64 A) (self : (A × A)) : Result U64 := let i0 ← inst.to_u64 t0 i + i0 -/- Trait implementation: [traits::{(A, A)#3}] -/ +/- Trait implementation: [traits::{(A, A)#3}] + Source: 'src/traits.rs', lines 49:0-49:31 -/ def traits.ToU64TupleAAInst (A : Type) (inst : ToU64 A) : ToU64 (A × A) := { to_u64 := Pair.to_u64 A inst } -/- [traits::f]: forward function -/ +/- [traits::f]: forward function + Source: 'src/traits.rs', lines 55:0-55:36 -/ def f (T : Type) (inst : ToU64 T) (x : (T × T)) : Result U64 := Pair.to_u64 T inst x -/- [traits::g]: forward function -/ +/- [traits::g]: forward function + Source: 'src/traits.rs', lines 59:0-61:18 -/ def g (T : Type) (inst : ToU64 (T × T)) (x : (T × T)) : Result U64 := inst.to_u64 x -/- [traits::h0]: forward function -/ +/- [traits::h0]: forward function + Source: 'src/traits.rs', lines 66:0-66:24 -/ def h0 (x : U64) : Result U64 := U64.to_u64 x -/- [traits::Wrapper] -/ +/- [traits::Wrapper] + Source: 'src/traits.rs', lines 70:0-70:21 -/ structure Wrapper (T : Type) where x : T -/- [traits::{traits::Wrapper#4}::to_u64]: forward function -/ +/- [traits::{traits::Wrapper#4}::to_u64]: forward function + Source: 'src/traits.rs', lines 75:4-75:26 -/ def Wrapper.to_u64 (T : Type) (inst : ToU64 T) (self : Wrapper T) : Result U64 := inst.to_u64 self.x -/- Trait implementation: [traits::{traits::Wrapper#4}] -/ +/- Trait implementation: [traits::{traits::Wrapper#4}] + Source: 'src/traits.rs', lines 74:0-74:35 -/ def traits.ToU64traitsWrapperTInst (T : Type) (inst : ToU64 T) : ToU64 (Wrapper T) := { to_u64 := Wrapper.to_u64 T inst } -/- [traits::h1]: forward function -/ +/- [traits::h1]: forward function + Source: 'src/traits.rs', lines 80:0-80:33 -/ def h1 (x : Wrapper U64) : Result U64 := Wrapper.to_u64 U64 traits.ToU64U64Inst x -/- [traits::h2]: forward function -/ +/- [traits::h2]: forward function + Source: 'src/traits.rs', lines 84:0-84:41 -/ def h2 (T : Type) (inst : ToU64 T) (x : Wrapper T) : Result U64 := Wrapper.to_u64 T inst x -/- Trait declaration: [traits::ToType] -/ +/- Trait declaration: [traits::ToType] + Source: 'src/traits.rs', lines 88:0-88:19 -/ structure ToType (Self T : Type) where to_type : Self → Result T -/- [traits::{u64#5}::to_type]: forward function -/ +/- [traits::{u64#5}::to_type]: forward function + Source: 'src/traits.rs', lines 93:4-93:28 -/ def U64.to_type (self : U64) : Result Bool := Result.ret (self > 0#u64) -/- Trait implementation: [traits::{u64#5}] -/ +/- Trait implementation: [traits::{u64#5}] + Source: 'src/traits.rs', lines 92:0-92:25 -/ def traits.ToTypeU64BoolInst : ToType U64 Bool := { to_type := U64.to_type } -/- Trait declaration: [traits::OfType] -/ +/- Trait declaration: [traits::OfType] + Source: 'src/traits.rs', lines 98:0-98:16 -/ structure OfType (Self : Type) where of_type : forall (T : Type) (inst : ToType T Self), T → Result Self -/- [traits::h3]: forward function -/ +/- [traits::h3]: forward function + Source: 'src/traits.rs', lines 104:0-104:50 -/ def h3 (T1 T2 : Type) (inst : OfType T1) (inst0 : ToType T2 T1) (y : T2) : Result T1 := inst.of_type T2 inst0 y -/- Trait declaration: [traits::OfTypeBis] -/ +/- Trait declaration: [traits::OfTypeBis] + Source: 'src/traits.rs', lines 109:0-109:36 -/ structure OfTypeBis (Self T : Type) where parent_clause_0 : ToType T Self of_type : T → Result Self -/- [traits::h4]: forward function -/ +/- [traits::h4]: forward function + Source: 'src/traits.rs', lines 118:0-118:57 -/ def h4 (T1 T2 : Type) (inst : OfTypeBis T1 T2) (inst0 : ToType T2 T1) (y : T2) : Result T1 := inst.of_type y -/- [traits::TestType] -/ +/- [traits::TestType] + Source: 'src/traits.rs', lines 122:0-122:22 -/ structure TestType (T : Type) where _0 : T -/- [traits::{traits::TestType#6}::test::TestType1] -/ +/- [traits::{traits::TestType#6}::test::TestType1] + Source: 'src/traits.rs', lines 127:8-127:24 -/ structure TestType.test.TestType1 where _0 : U64 -/- Trait declaration: [traits::{traits::TestType#6}::test::TestTrait] -/ +/- Trait declaration: [traits::{traits::TestType#6}::test::TestTrait] + Source: 'src/traits.rs', lines 128:8-128:23 -/ structure TestType.test.TestTrait (Self : Type) where test : Self → Result Bool -/- [traits::{traits::TestType#6}::test::{traits::{traits::TestType#6}::test::TestType1}::test]: forward function -/ +/- [traits::{traits::TestType#6}::test::{traits::{traits::TestType#6}::test::TestType1}::test]: forward function + Source: 'src/traits.rs', lines 139:12-139:34 -/ def TestType.test.TestType1.test (self : TestType.test.TestType1) : Result Bool := Result.ret (self._0 > 1#u64) -/- Trait implementation: [traits::{traits::TestType#6}::test::{traits::{traits::TestType#6}::test::TestType1}] -/ +/- Trait implementation: [traits::{traits::TestType#6}::test::{traits::{traits::TestType#6}::test::TestType1}] + Source: 'src/traits.rs', lines 138:8-138:36 -/ def traits.TestType.test.TestTraittraitstraitsTestTypeTtestTestType1Inst : TestType.test.TestTrait TestType.test.TestType1 := { test := TestType.test.TestType1.test } -/- [traits::{traits::TestType#6}::test]: forward function -/ +/- [traits::{traits::TestType#6}::test]: forward function + Source: 'src/traits.rs', lines 126:4-126:36 -/ def TestType.test (T : Type) (inst : ToU64 T) (self : TestType T) (x : T) : Result Bool := do @@ -184,27 +219,32 @@ def TestType.test then TestType.test.TestType1.test { _0 := 0#u64 } else Result.ret false -/- [traits::BoolWrapper] -/ +/- [traits::BoolWrapper] + Source: 'src/traits.rs', lines 150:0-150:22 -/ structure BoolWrapper where _0 : Bool -/- [traits::{traits::BoolWrapper#7}::to_type]: forward function -/ +/- [traits::{traits::BoolWrapper#7}::to_type]: forward function + Source: 'src/traits.rs', lines 156:4-156:25 -/ def BoolWrapper.to_type (T : Type) (inst : ToType Bool T) (self : BoolWrapper) : Result T := inst.to_type self._0 -/- Trait implementation: [traits::{traits::BoolWrapper#7}] -/ +/- Trait implementation: [traits::{traits::BoolWrapper#7}] + Source: 'src/traits.rs', lines 152:0-152:33 -/ def traits.ToTypetraitsBoolWrapperTInst (T : Type) (inst : ToType Bool T) : ToType BoolWrapper T := { to_type := BoolWrapper.to_type T inst } -/- [traits::WithConstTy::LEN2] -/ +/- [traits::WithConstTy::LEN2] + Source: 'src/traits.rs', lines 164:4-164:21 -/ def with_const_ty_len2_body : Result Usize := Result.ret 32#usize def with_const_ty_len2_c : Usize := eval_global with_const_ty_len2_body (by simp) -/- Trait declaration: [traits::WithConstTy] -/ +/- Trait declaration: [traits::WithConstTy] + Source: 'src/traits.rs', lines 161:0-161:39 -/ structure WithConstTy (Self : Type) (LEN : Usize) where LEN1 : Usize LEN2 : Usize @@ -213,16 +253,19 @@ structure WithConstTy (Self : Type) (LEN : Usize) where W_clause_0 : ToU64 W f : W → Array U8 LEN → Result W -/- [traits::{bool#8}::LEN1] -/ +/- [traits::{bool#8}::LEN1] + Source: 'src/traits.rs', lines 175:4-175:21 -/ def bool_len1_body : Result Usize := Result.ret 12#usize def bool_len1_c : Usize := eval_global bool_len1_body (by simp) /- [traits::{bool#8}::f]: merged forward/backward function - (there is a single backward function, and the forward function returns ()) -/ + (there is a single backward function, and the forward function returns ()) + Source: 'src/traits.rs', lines 180:4-180:39 -/ def Bool.f (i : U64) (a : Array U8 32#usize) : Result U64 := Result.ret i -/- Trait implementation: [traits::{bool#8}] -/ +/- Trait implementation: [traits::{bool#8}] + Source: 'src/traits.rs', lines 174:0-174:29 -/ def traits.WithConstTyBool32Inst : WithConstTy Bool 32#usize := { LEN1 := bool_len1_c LEN2 := with_const_ty_len2_c @@ -232,153 +275,183 @@ def traits.WithConstTyBool32Inst : WithConstTy Bool 32#usize := { f := Bool.f } -/- [traits::use_with_const_ty1]: forward function -/ +/- [traits::use_with_const_ty1]: forward function + Source: 'src/traits.rs', lines 183:0-183:75 -/ def use_with_const_ty1 (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) : Result Usize := let i := inst.LEN1 Result.ret i -/- [traits::use_with_const_ty2]: forward function -/ +/- [traits::use_with_const_ty2]: forward function + Source: 'src/traits.rs', lines 187:0-187:73 -/ def use_with_const_ty2 (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) (w : inst.W) : Result Unit := Result.ret () -/- [traits::use_with_const_ty3]: forward function -/ +/- [traits::use_with_const_ty3]: forward function + Source: 'src/traits.rs', lines 189:0-189:80 -/ def use_with_const_ty3 (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) (x : inst.W) : Result U64 := inst.W_clause_0.to_u64 x -/- [traits::test_where1]: forward function -/ +/- [traits::test_where1]: forward function + Source: 'src/traits.rs', lines 193:0-193:40 -/ def test_where1 (T : Type) (_x : T) : Result Unit := Result.ret () -/- [traits::test_where2]: forward function -/ +/- [traits::test_where2]: forward function + Source: 'src/traits.rs', lines 194:0-194:57 -/ def test_where2 (T : Type) (inst : WithConstTy T 32#usize) (_x : U32) : Result Unit := Result.ret () -/- [alloc::string::String] -/ +/- [alloc::string::String] + Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/alloc/src/string.rs', lines 365:0-365:17 -/ axiom alloc.string.String : Type -/- Trait declaration: [traits::ParentTrait0] -/ +/- Trait declaration: [traits::ParentTrait0] + Source: 'src/traits.rs', lines 200:0-200:22 -/ structure ParentTrait0 (Self : Type) where W : Type get_name : Self → Result alloc.string.String get_w : Self → Result W -/- Trait declaration: [traits::ParentTrait1] -/ +/- Trait declaration: [traits::ParentTrait1] + Source: 'src/traits.rs', lines 205:0-205:22 -/ structure ParentTrait1 (Self : Type) where -/- Trait declaration: [traits::ChildTrait] -/ +/- Trait declaration: [traits::ChildTrait] + Source: 'src/traits.rs', lines 206:0-206:49 -/ structure ChildTrait (Self : Type) where parent_clause_0 : ParentTrait0 Self parent_clause_1 : ParentTrait1 Self -/- [traits::test_child_trait1]: forward function -/ +/- [traits::test_child_trait1]: forward function + Source: 'src/traits.rs', lines 209:0-209:56 -/ def test_child_trait1 (T : Type) (inst : ChildTrait T) (x : T) : Result alloc.string.String := inst.parent_clause_0.get_name x -/- [traits::test_child_trait2]: forward function -/ +/- [traits::test_child_trait2]: forward function + Source: 'src/traits.rs', lines 213:0-213:54 -/ def test_child_trait2 (T : Type) (inst : ChildTrait T) (x : T) : Result inst.parent_clause_0.W := inst.parent_clause_0.get_w x -/- [traits::order1]: forward function -/ +/- [traits::order1]: forward function + Source: 'src/traits.rs', lines 219:0-219:59 -/ def order1 (T U : Type) (inst : ParentTrait0 T) (inst0 : ParentTrait0 U) : Result Unit := Result.ret () -/- Trait declaration: [traits::ChildTrait1] -/ +/- Trait declaration: [traits::ChildTrait1] + Source: 'src/traits.rs', lines 222:0-222:35 -/ structure ChildTrait1 (Self : Type) where parent_clause_0 : ParentTrait1 Self -/- Trait implementation: [traits::{usize#9}] -/ +/- Trait implementation: [traits::{usize#9}] + Source: 'src/traits.rs', lines 224:0-224:27 -/ def traits.ParentTrait1UsizeInst : ParentTrait1 Usize := { } -/- Trait implementation: [traits::{usize#10}] -/ +/- Trait implementation: [traits::{usize#10}] + Source: 'src/traits.rs', lines 225:0-225:26 -/ def traits.ChildTrait1UsizeInst : ChildTrait1 Usize := { parent_clause_0 := traits.ParentTrait1UsizeInst } -/- Trait declaration: [traits::Iterator] -/ +/- Trait declaration: [traits::Iterator] + Source: 'src/traits.rs', lines 229:0-229:18 -/ structure Iterator (Self : Type) where Item : Type -/- Trait declaration: [traits::IntoIterator] -/ +/- Trait declaration: [traits::IntoIterator] + Source: 'src/traits.rs', lines 233:0-233:22 -/ structure IntoIterator (Self : Type) where Item : Type IntoIter : Type IntoIter_clause_0 : Iterator IntoIter into_iter : Self → Result IntoIter -/- Trait declaration: [traits::FromResidual] -/ +/- Trait declaration: [traits::FromResidual] + Source: 'src/traits.rs', lines 250:0-250:21 -/ structure FromResidual (Self T : Type) where -/- Trait declaration: [traits::Try] -/ +/- Trait declaration: [traits::Try] + Source: 'src/traits.rs', lines 246:0-246:48 -/ structure Try (Self : Type) where Residual : Type parent_clause_0 : FromResidual Self Residual -/- Trait declaration: [traits::WithTarget] -/ +/- Trait declaration: [traits::WithTarget] + Source: 'src/traits.rs', lines 252:0-252:20 -/ structure WithTarget (Self : Type) where Target : Type -/- Trait declaration: [traits::ParentTrait2] -/ +/- Trait declaration: [traits::ParentTrait2] + Source: 'src/traits.rs', lines 256:0-256:22 -/ structure ParentTrait2 (Self : Type) where U : Type U_clause_0 : WithTarget U -/- Trait declaration: [traits::ChildTrait2] -/ +/- Trait declaration: [traits::ChildTrait2] + Source: 'src/traits.rs', lines 260:0-260:35 -/ structure ChildTrait2 (Self : Type) where parent_clause_0 : ParentTrait2 Self convert : parent_clause_0.U → Result parent_clause_0.U_clause_0.Target -/- Trait implementation: [traits::{u32#11}] -/ +/- Trait implementation: [traits::{u32#11}] + Source: 'src/traits.rs', lines 264:0-264:23 -/ def traits.WithTargetU32Inst : WithTarget U32 := { Target := U32 } -/- Trait implementation: [traits::{u32#12}] -/ +/- Trait implementation: [traits::{u32#12}] + Source: 'src/traits.rs', lines 268:0-268:25 -/ def traits.ParentTrait2U32Inst : ParentTrait2 U32 := { U := U32 U_clause_0 := traits.WithTargetU32Inst } -/- [traits::{u32#13}::convert]: forward function -/ +/- [traits::{u32#13}::convert]: forward function + Source: 'src/traits.rs', lines 273:4-273:29 -/ def U32.convert (x : U32) : Result U32 := Result.ret x -/- Trait implementation: [traits::{u32#13}] -/ +/- Trait implementation: [traits::{u32#13}] + Source: 'src/traits.rs', lines 272:0-272:24 -/ def traits.ChildTrait2U32Inst : ChildTrait2 U32 := { parent_clause_0 := traits.ParentTrait2U32Inst convert := U32.convert } -/- Trait declaration: [traits::CFnOnce] -/ +/- Trait declaration: [traits::CFnOnce] + Source: 'src/traits.rs', lines 286:0-286:23 -/ structure CFnOnce (Self Args : Type) where Output : Type call_once : Self → Args → Result Output -/- Trait declaration: [traits::CFnMut] -/ +/- Trait declaration: [traits::CFnMut] + Source: 'src/traits.rs', lines 292:0-292:37 -/ structure CFnMut (Self Args : Type) where parent_clause_0 : CFnOnce Self Args call_mut : Self → Args → Result parent_clause_0.Output call_mut_back : Self → Args → parent_clause_0.Output → Result Self -/- Trait declaration: [traits::CFn] -/ +/- Trait declaration: [traits::CFn] + Source: 'src/traits.rs', lines 296:0-296:33 -/ structure CFn (Self Args : Type) where parent_clause_0 : CFnMut Self Args call_mut : Self → Args → Result parent_clause_0.parent_clause_0.Output -/- [traits::incr_u32]: forward function -/ +/- [traits::incr_u32]: forward function + Source: 'src/traits.rs', lines 300:0-300:30 -/ def incr_u32 (x : U32) : Result U32 := x + 1#u32 -- cgit v1.2.3 From 184e27bce209f7a852c2adc7e0598ed75ac8452d Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 21 Nov 2023 18:58:04 +0100 Subject: Regenerate the files --- tests/lean/Traits.lean | 38 +++++++++++++++++++++----------------- 1 file changed, 21 insertions(+), 17 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Traits.lean b/tests/lean/Traits.lean index f854da76..0aa68c5e 100644 --- a/tests/lean/Traits.lean +++ b/tests/lean/Traits.lean @@ -170,7 +170,7 @@ def h3 /- Trait declaration: [traits::OfTypeBis] Source: 'src/traits.rs', lines 109:0-109:36 -/ structure OfTypeBis (Self T : Type) where - parent_clause_0 : ToType T Self + ToTypeTSelfInst : ToType T Self of_type : T → Result Self /- [traits::h4]: forward function @@ -327,20 +327,22 @@ structure ParentTrait1 (Self : Type) where /- Trait declaration: [traits::ChildTrait] Source: 'src/traits.rs', lines 206:0-206:49 -/ structure ChildTrait (Self : Type) where - parent_clause_0 : ParentTrait0 Self - parent_clause_1 : ParentTrait1 Self + ParentTrait0SelfInst : ParentTrait0 Self + ParentTrait1SelfInst : ParentTrait1 Self /- [traits::test_child_trait1]: forward function Source: 'src/traits.rs', lines 209:0-209:56 -/ def test_child_trait1 (T : Type) (inst : ChildTrait T) (x : T) : Result alloc.string.String := - inst.parent_clause_0.get_name x + inst.ParentTrait0SelfInst.get_name x /- [traits::test_child_trait2]: forward function Source: 'src/traits.rs', lines 213:0-213:54 -/ def test_child_trait2 - (T : Type) (inst : ChildTrait T) (x : T) : Result inst.parent_clause_0.W := - inst.parent_clause_0.get_w x + (T : Type) (inst : ChildTrait T) (x : T) : + Result inst.ParentTrait0SelfInst.W + := + inst.ParentTrait0SelfInst.get_w x /- [traits::order1]: forward function Source: 'src/traits.rs', lines 219:0-219:59 -/ @@ -353,7 +355,7 @@ def order1 /- Trait declaration: [traits::ChildTrait1] Source: 'src/traits.rs', lines 222:0-222:35 -/ structure ChildTrait1 (Self : Type) where - parent_clause_0 : ParentTrait1 Self + ParentTrait1SelfInst : ParentTrait1 Self /- Trait implementation: [traits::{usize#9}] Source: 'src/traits.rs', lines 224:0-224:27 -/ @@ -363,7 +365,7 @@ def traits.ParentTrait1UsizeInst : ParentTrait1 Usize := { /- Trait implementation: [traits::{usize#10}] Source: 'src/traits.rs', lines 225:0-225:26 -/ def traits.ChildTrait1UsizeInst : ChildTrait1 Usize := { - parent_clause_0 := traits.ParentTrait1UsizeInst + ParentTrait1SelfInst := traits.ParentTrait1UsizeInst } /- Trait declaration: [traits::Iterator] @@ -387,7 +389,7 @@ structure FromResidual (Self T : Type) where Source: 'src/traits.rs', lines 246:0-246:48 -/ structure Try (Self : Type) where Residual : Type - parent_clause_0 : FromResidual Self Residual + FromResidualSelftraitsTrySelfResidualInst : FromResidual Self Residual /- Trait declaration: [traits::WithTarget] Source: 'src/traits.rs', lines 252:0-252:20 -/ @@ -403,8 +405,9 @@ structure ParentTrait2 (Self : Type) where /- Trait declaration: [traits::ChildTrait2] Source: 'src/traits.rs', lines 260:0-260:35 -/ structure ChildTrait2 (Self : Type) where - parent_clause_0 : ParentTrait2 Self - convert : parent_clause_0.U → Result parent_clause_0.U_clause_0.Target + ParentTrait2SelfInst : ParentTrait2 Self + convert : ParentTrait2SelfInst.U → Result + ParentTrait2SelfInst.U_clause_0.Target /- Trait implementation: [traits::{u32#11}] Source: 'src/traits.rs', lines 264:0-264:23 -/ @@ -427,7 +430,7 @@ def U32.convert (x : U32) : Result U32 := /- Trait implementation: [traits::{u32#13}] Source: 'src/traits.rs', lines 272:0-272:24 -/ def traits.ChildTrait2U32Inst : ChildTrait2 U32 := { - parent_clause_0 := traits.ParentTrait2U32Inst + ParentTrait2SelfInst := traits.ParentTrait2U32Inst convert := U32.convert } @@ -440,15 +443,16 @@ structure CFnOnce (Self Args : Type) where /- Trait declaration: [traits::CFnMut] Source: 'src/traits.rs', lines 292:0-292:37 -/ structure CFnMut (Self Args : Type) where - parent_clause_0 : CFnOnce Self Args - call_mut : Self → Args → Result parent_clause_0.Output - call_mut_back : Self → Args → parent_clause_0.Output → Result Self + CFnOnceSelfArgsInst : CFnOnce Self Args + call_mut : Self → Args → Result CFnOnceSelfArgsInst.Output + call_mut_back : Self → Args → CFnOnceSelfArgsInst.Output → Result Self /- Trait declaration: [traits::CFn] Source: 'src/traits.rs', lines 296:0-296:33 -/ structure CFn (Self Args : Type) where - parent_clause_0 : CFnMut Self Args - call_mut : Self → Args → Result parent_clause_0.parent_clause_0.Output + CFnMutSelfArgsInst : CFnMut Self Args + call_mut : Self → Args → Result + CFnMutSelfArgsInst.CFnOnceSelfArgsInst.Output /- [traits::incr_u32]: forward function Source: 'src/traits.rs', lines 300:0-300:30 -/ -- cgit v1.2.3 From 84a505ed9f193885175308ecc837922a41176b5b Mon Sep 17 00:00:00 2001 From: Son Ho Date: Wed, 22 Nov 2023 09:11:06 +0100 Subject: Regenerate the test files --- tests/lean/Traits.lean | 104 +++++++++++++++++++++++++++++-------------------- 1 file changed, 62 insertions(+), 42 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Traits.lean b/tests/lean/Traits.lean index 0aa68c5e..9ac4736c 100644 --- a/tests/lean/Traits.lean +++ b/tests/lean/Traits.lean @@ -61,8 +61,9 @@ def test_bool_trait_option (T : Type) (x : Option T) : Result Bool := /- [traits::test_bool_trait]: forward function Source: 'src/traits.rs', lines 35:0-35:50 -/ -def test_bool_trait (T : Type) (inst : BoolTrait T) (x : T) : Result Bool := - inst.get_bool x +def test_bool_trait + (T : Type) (BoolTraitTInst : BoolTrait T) (x : T) : Result Bool := + BoolTraitTInst.get_bool x /- Trait declaration: [traits::ToU64] Source: 'src/traits.rs', lines 39:0-39:15 -/ @@ -82,28 +83,31 @@ def traits.ToU64U64Inst : ToU64 U64 := { /- [traits::{(A, A)#3}::to_u64]: forward function Source: 'src/traits.rs', lines 50:4-50:26 -/ -def Pair.to_u64 (A : Type) (inst : ToU64 A) (self : (A × A)) : Result U64 := +def Pair.to_u64 + (A : Type) (ToU64AInst : ToU64 A) (self : (A × A)) : Result U64 := do let (t, t0) := self - let i ← inst.to_u64 t - let i0 ← inst.to_u64 t0 + let i ← ToU64AInst.to_u64 t + let i0 ← ToU64AInst.to_u64 t0 i + i0 /- Trait implementation: [traits::{(A, A)#3}] Source: 'src/traits.rs', lines 49:0-49:31 -/ -def traits.ToU64TupleAAInst (A : Type) (inst : ToU64 A) : ToU64 (A × A) := { - to_u64 := Pair.to_u64 A inst +def traits.ToU64TupleAAInst (A : Type) (ToU64AInst : ToU64 A) : ToU64 (A × A) + := { + to_u64 := Pair.to_u64 A ToU64AInst } /- [traits::f]: forward function Source: 'src/traits.rs', lines 55:0-55:36 -/ -def f (T : Type) (inst : ToU64 T) (x : (T × T)) : Result U64 := - Pair.to_u64 T inst x +def f (T : Type) (ToU64TInst : ToU64 T) (x : (T × T)) : Result U64 := + Pair.to_u64 T ToU64TInst x /- [traits::g]: forward function Source: 'src/traits.rs', lines 59:0-61:18 -/ -def g (T : Type) (inst : ToU64 (T × T)) (x : (T × T)) : Result U64 := - inst.to_u64 x +def g + (T : Type) (ToU64TupleTTInst : ToU64 (T × T)) (x : (T × T)) : Result U64 := + ToU64TupleTTInst.to_u64 x /- [traits::h0]: forward function Source: 'src/traits.rs', lines 66:0-66:24 -/ @@ -118,14 +122,14 @@ structure Wrapper (T : Type) where /- [traits::{traits::Wrapper#4}::to_u64]: forward function Source: 'src/traits.rs', lines 75:4-75:26 -/ def Wrapper.to_u64 - (T : Type) (inst : ToU64 T) (self : Wrapper T) : Result U64 := - inst.to_u64 self.x + (T : Type) (ToU64TInst : ToU64 T) (self : Wrapper T) : Result U64 := + ToU64TInst.to_u64 self.x /- Trait implementation: [traits::{traits::Wrapper#4}] Source: 'src/traits.rs', lines 74:0-74:35 -/ -def traits.ToU64traitsWrapperTInst (T : Type) (inst : ToU64 T) : ToU64 (Wrapper - T) := { - to_u64 := Wrapper.to_u64 T inst +def traits.ToU64traitsWrapperTInst (T : Type) (ToU64TInst : ToU64 T) : ToU64 + (Wrapper T) := { + to_u64 := Wrapper.to_u64 T ToU64TInst } /- [traits::h1]: forward function @@ -135,8 +139,8 @@ def h1 (x : Wrapper U64) : Result U64 := /- [traits::h2]: forward function Source: 'src/traits.rs', lines 84:0-84:41 -/ -def h2 (T : Type) (inst : ToU64 T) (x : Wrapper T) : Result U64 := - Wrapper.to_u64 T inst x +def h2 (T : Type) (ToU64TInst : ToU64 T) (x : Wrapper T) : Result U64 := + Wrapper.to_u64 T ToU64TInst x /- Trait declaration: [traits::ToType] Source: 'src/traits.rs', lines 88:0-88:19 -/ @@ -157,15 +161,17 @@ def traits.ToTypeU64BoolInst : ToType U64 Bool := { /- Trait declaration: [traits::OfType] Source: 'src/traits.rs', lines 98:0-98:16 -/ structure OfType (Self : Type) where - of_type : forall (T : Type) (inst : ToType T Self), T → Result Self + of_type : forall (T : Type) (ToTypeTSelfInst : ToType T Self), T → Result + Self /- [traits::h3]: forward function Source: 'src/traits.rs', lines 104:0-104:50 -/ def h3 - (T1 T2 : Type) (inst : OfType T1) (inst0 : ToType T2 T1) (y : T2) : + (T1 T2 : Type) (OfTypeT1Inst : OfType T1) (ToTypeT2T1Inst : ToType T2 T1) + (y : T2) : Result T1 := - inst.of_type T2 inst0 y + OfTypeT1Inst.of_type T2 ToTypeT2T1Inst y /- Trait declaration: [traits::OfTypeBis] Source: 'src/traits.rs', lines 109:0-109:36 -/ @@ -176,10 +182,11 @@ structure OfTypeBis (Self T : Type) where /- [traits::h4]: forward function Source: 'src/traits.rs', lines 118:0-118:57 -/ def h4 - (T1 T2 : Type) (inst : OfTypeBis T1 T2) (inst0 : ToType T2 T1) (y : T2) : + (T1 T2 : Type) (OfTypeBisT1T2Inst : OfTypeBis T1 T2) (ToTypeT2T1Inst : ToType + T2 T1) (y : T2) : Result T1 := - inst.of_type y + OfTypeBisT1T2Inst.of_type y /- [traits::TestType] Source: 'src/traits.rs', lines 122:0-122:22 -/ @@ -212,9 +219,11 @@ def traits.TestType.test.TestTraittraitstraitsTestTypeTtestTestType1Inst : /- [traits::{traits::TestType#6}::test]: forward function Source: 'src/traits.rs', lines 126:4-126:36 -/ def TestType.test - (T : Type) (inst : ToU64 T) (self : TestType T) (x : T) : Result Bool := + (T : Type) (ToU64TInst : ToU64 T) (self : TestType T) (x : T) : + Result Bool + := do - let x0 ← inst.to_u64 x + let x0 ← ToU64TInst.to_u64 x if x0 > 0#u64 then TestType.test.TestType1.test { _0 := 0#u64 } else Result.ret false @@ -227,14 +236,16 @@ structure BoolWrapper where /- [traits::{traits::BoolWrapper#7}::to_type]: forward function Source: 'src/traits.rs', lines 156:4-156:25 -/ def BoolWrapper.to_type - (T : Type) (inst : ToType Bool T) (self : BoolWrapper) : Result T := - inst.to_type self._0 + (T : Type) (ToTypeBoolTInst : ToType Bool T) (self : BoolWrapper) : + Result T + := + ToTypeBoolTInst.to_type self._0 /- Trait implementation: [traits::{traits::BoolWrapper#7}] Source: 'src/traits.rs', lines 152:0-152:33 -/ -def traits.ToTypetraitsBoolWrapperTInst (T : Type) (inst : ToType Bool T) : - ToType BoolWrapper T := { - to_type := BoolWrapper.to_type T inst +def traits.ToTypetraitsBoolWrapperTInst (T : Type) (ToTypeBoolTInst : ToType + Bool T) : ToType BoolWrapper T := { + to_type := BoolWrapper.to_type T ToTypeBoolTInst } /- [traits::WithConstTy::LEN2] @@ -278,14 +289,17 @@ def traits.WithConstTyBool32Inst : WithConstTy Bool 32#usize := { /- [traits::use_with_const_ty1]: forward function Source: 'src/traits.rs', lines 183:0-183:75 -/ def use_with_const_ty1 - (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) : Result Usize := - let i := inst.LEN1 + (H : Type) (LEN : Usize) (WithConstTyHLENInst : WithConstTy H LEN) : + Result Usize + := + let i := WithConstTyHLENInst.LEN1 Result.ret i /- [traits::use_with_const_ty2]: forward function Source: 'src/traits.rs', lines 187:0-187:73 -/ def use_with_const_ty2 - (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) (w : inst.W) : + (H : Type) (LEN : Usize) (WithConstTyHLENInst : WithConstTy H LEN) + (w : WithConstTyHLENInst.W) : Result Unit := Result.ret () @@ -293,10 +307,11 @@ def use_with_const_ty2 /- [traits::use_with_const_ty3]: forward function Source: 'src/traits.rs', lines 189:0-189:80 -/ def use_with_const_ty3 - (H : Type) (LEN : Usize) (inst : WithConstTy H LEN) (x : inst.W) : + (H : Type) (LEN : Usize) (WithConstTyHLENInst : WithConstTy H LEN) + (x : WithConstTyHLENInst.W) : Result U64 := - inst.W_clause_0.to_u64 x + WithConstTyHLENInst.W_clause_0.to_u64 x /- [traits::test_where1]: forward function Source: 'src/traits.rs', lines 193:0-193:40 -/ @@ -306,7 +321,9 @@ def test_where1 (T : Type) (_x : T) : Result Unit := /- [traits::test_where2]: forward function Source: 'src/traits.rs', lines 194:0-194:57 -/ def test_where2 - (T : Type) (inst : WithConstTy T 32#usize) (_x : U32) : Result Unit := + (T : Type) (WithConstTyT32Inst : WithConstTy T 32#usize) (_x : U32) : + Result Unit + := Result.ret () /- [alloc::string::String] @@ -333,21 +350,24 @@ structure ChildTrait (Self : Type) where /- [traits::test_child_trait1]: forward function Source: 'src/traits.rs', lines 209:0-209:56 -/ def test_child_trait1 - (T : Type) (inst : ChildTrait T) (x : T) : Result alloc.string.String := - inst.ParentTrait0SelfInst.get_name x + (T : Type) (ChildTraitTInst : ChildTrait T) (x : T) : + Result alloc.string.String + := + ChildTraitTInst.ParentTrait0SelfInst.get_name x /- [traits::test_child_trait2]: forward function Source: 'src/traits.rs', lines 213:0-213:54 -/ def test_child_trait2 - (T : Type) (inst : ChildTrait T) (x : T) : - Result inst.ParentTrait0SelfInst.W + (T : Type) (ChildTraitTInst : ChildTrait T) (x : T) : + Result ChildTraitTInst.ParentTrait0SelfInst.W := - inst.ParentTrait0SelfInst.get_w x + ChildTraitTInst.ParentTrait0SelfInst.get_w x /- [traits::order1]: forward function Source: 'src/traits.rs', lines 219:0-219:59 -/ def order1 - (T U : Type) (inst : ParentTrait0 T) (inst0 : ParentTrait0 U) : + (T U : Type) (ParentTrait0TInst : ParentTrait0 T) (ParentTrait0UInst : + ParentTrait0 U) : Result Unit := Result.ret () -- cgit v1.2.3 From d84040e000333d6d2a212fb849a38fb73a65eb48 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Fri, 24 Nov 2023 17:41:42 +0100 Subject: Regenerate the files --- tests/lean/Array.lean | 26 +++--- tests/lean/BetreeMain/Funs.lean | 42 ++++----- tests/lean/External/Funs.lean | 8 +- tests/lean/Hashmap/Funs.lean | 40 ++++----- tests/lean/HashmapMain/Funs.lean | 38 ++++---- tests/lean/Loops.lean | 184 +++++++++++++++++++-------------------- tests/lean/NoNestedBorrows.lean | 133 ++++++++++++++-------------- tests/lean/Paper.lean | 32 +++---- tests/lean/PoloniusList.lean | 8 +- tests/lean/Traits.lean | 10 +-- 10 files changed, 255 insertions(+), 266 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Array.lean b/tests/lean/Array.lean index 4832f469..b49add96 100644 --- a/tests/lean/Array.lean +++ b/tests/lean/Array.lean @@ -31,10 +31,10 @@ def array_to_mut_slice_ (T : Type) (s : Array T 32#usize) : Result (Slice T) := /- [array::array_to_mut_slice_]: backward function 0 Source: 'src/array.rs', lines 21:0-21:58 -/ def array_to_mut_slice__back - (T : Type) (s : Array T 32#usize) (ret0 : Slice T) : + (T : Type) (s : Array T 32#usize) (ret : Slice T) : Result (Array T 32#usize) := - Array.from_slice T 32#usize s ret0 + Array.from_slice T 32#usize s ret /- [array::array_len]: forward function Source: 'src/array.rs', lines 25:0-25:40 -/ @@ -82,10 +82,10 @@ def index_mut_array (T : Type) (s : Array T 32#usize) (i : Usize) : Result T := /- [array::index_mut_array]: backward function 0 Source: 'src/array.rs', lines 52:0-52:62 -/ def index_mut_array_back - (T : Type) (s : Array T 32#usize) (i : Usize) (ret0 : T) : + (T : Type) (s : Array T 32#usize) (i : Usize) (ret : T) : Result (Array T 32#usize) := - Array.update_usize T 32#usize s i ret0 + Array.update_usize T 32#usize s i ret /- [array::index_slice]: forward function Source: 'src/array.rs', lines 56:0-56:46 -/ @@ -100,8 +100,8 @@ def index_mut_slice (T : Type) (s : Slice T) (i : Usize) : Result T := /- [array::index_mut_slice]: backward function 0 Source: 'src/array.rs', lines 60:0-60:58 -/ def index_mut_slice_back - (T : Type) (s : Slice T) (i : Usize) (ret0 : T) : Result (Slice T) := - Slice.update_usize T s i ret0 + (T : Type) (s : Slice T) (i : Usize) (ret : T) : Result (Slice T) := + Slice.update_usize T s i ret /- [array::slice_subslice_shared_]: forward function Source: 'src/array.rs', lines 64:0-64:70 -/ @@ -122,12 +122,12 @@ def slice_subslice_mut_ /- [array::slice_subslice_mut_]: backward function 0 Source: 'src/array.rs', lines 68:0-68:75 -/ def slice_subslice_mut__back - (x : Slice U32) (y : Usize) (z : Usize) (ret0 : Slice U32) : + (x : Slice U32) (y : Usize) (z : Usize) (ret : Slice U32) : Result (Slice U32) := core.slice.index.Slice.index_mut_back U32 (core.ops.range.Range Usize) (core.slice.index.SliceIndexRangeUsizeSliceTInst U32) x - { start := y, end_ := z } ret0 + { start := y, end_ := z } ret /- [array::array_to_slice_shared_]: forward function Source: 'src/array.rs', lines 72:0-72:54 -/ @@ -142,8 +142,8 @@ def array_to_slice_mut_ (x : Array U32 32#usize) : Result (Slice U32) := /- [array::array_to_slice_mut_]: backward function 0 Source: 'src/array.rs', lines 76:0-76:59 -/ def array_to_slice_mut__back - (x : Array U32 32#usize) (ret0 : Slice U32) : Result (Array U32 32#usize) := - Array.from_slice U32 32#usize x ret0 + (x : Array U32 32#usize) (ret : Slice U32) : Result (Array U32 32#usize) := + Array.from_slice U32 32#usize x ret /- [array::array_subslice_shared_]: forward function Source: 'src/array.rs', lines 80:0-80:74 -/ @@ -166,13 +166,13 @@ def array_subslice_mut_ /- [array::array_subslice_mut_]: backward function 0 Source: 'src/array.rs', lines 84:0-84:79 -/ def array_subslice_mut__back - (x : Array U32 32#usize) (y : Usize) (z : Usize) (ret0 : Slice U32) : + (x : Array U32 32#usize) (y : Usize) (z : Usize) (ret : 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 - { start := y, end_ := z } ret0 + { start := y, end_ := z } ret /- [array::index_slice_0]: forward function Source: 'src/array.rs', lines 88:0-88:38 -/ @@ -417,7 +417,7 @@ def sum2 (s : Slice U32) (s2 : Slice U32) : Result U32 := let i := Slice.len U32 s let i0 := Slice.len U32 s2 if not (i = i0) - then Result.fail Error.panic + then Result.fail .panic else sum2_loop s s2 0#u32 0#usize /- [array::f0]: forward function diff --git a/tests/lean/BetreeMain/Funs.lean b/tests/lean/BetreeMain/Funs.lean index 45548884..4c862225 100644 --- a/tests/lean/BetreeMain/Funs.lean +++ b/tests/lean/BetreeMain/Funs.lean @@ -121,7 +121,7 @@ divergent def betree.List.split_at let (ls0, ls1) := p let l := ls0 Result.ret (betree.List.Cons hd l, ls1) - | betree.List.Nil => Result.fail Error.panic + | betree.List.Nil => Result.fail .panic /- [betree_main::betree::{betree_main::betree::List#1}::push_front]: merged forward/backward function (there is a single backward function, and the forward function returns ()) @@ -138,7 +138,7 @@ def betree.List.pop_front (T : Type) (self : betree.List T) : Result T := let ls := core.mem.replace (betree.List T) self betree.List.Nil match ls with | betree.List.Cons x tl => Result.ret x - | betree.List.Nil => Result.fail Error.panic + | betree.List.Nil => Result.fail .panic /- [betree_main::betree::{betree_main::betree::List#1}::pop_front]: backward function 0 Source: 'src/betree.rs', lines 306:4-306:32 -/ @@ -147,14 +147,14 @@ def betree.List.pop_front_back let ls := core.mem.replace (betree.List T) self betree.List.Nil match ls with | betree.List.Cons x tl => Result.ret tl - | betree.List.Nil => Result.fail Error.panic + | betree.List.Nil => Result.fail .panic /- [betree_main::betree::{betree_main::betree::List#1}::hd]: forward function Source: 'src/betree.rs', lines 318:4-318:22 -/ def betree.List.hd (T : Type) (self : betree.List T) : Result T := match self with | betree.List.Cons hd l => Result.ret hd - | betree.List.Nil => Result.fail Error.panic + | betree.List.Nil => Result.fail .panic /- [betree_main::betree::{betree_main::betree::List<(u64, T)>#2}::head_has_key]: forward function Source: 'src/betree.rs', lines 327:4-327:44 -/ @@ -241,20 +241,20 @@ divergent def betree.Node.lookup_first_message_for_key Source: 'src/betree.rs', lines 789:4-792:34 -/ divergent def betree.Node.lookup_first_message_for_key_back (key : U64) (msgs : betree.List (U64 × betree.Message)) - (ret0 : betree.List (U64 × betree.Message)) : + (ret : betree.List (U64 × betree.Message)) : Result (betree.List (U64 × betree.Message)) := match msgs with | betree.List.Cons x next_msgs => let (i, m) := x if i >= key - then Result.ret ret0 + then Result.ret ret else do let next_msgs0 ← - betree.Node.lookup_first_message_for_key_back key next_msgs ret0 + betree.Node.lookup_first_message_for_key_back key next_msgs ret Result.ret (betree.List.Cons (i, m) next_msgs0) - | betree.List.Nil => Result.ret ret0 + | betree.List.Nil => Result.ret ret /- [betree_main::betree::{betree_main::betree::Node#5}::apply_upserts]: forward function Source: 'src/betree.rs', lines 819:4-819:90 -/ @@ -271,8 +271,8 @@ divergent def betree.Node.apply_upserts let msg ← betree.List.pop_front (U64 × betree.Message) msgs let (_, m) := msg match m with - | betree.Message.Insert i => Result.fail Error.panic - | betree.Message.Delete => Result.fail Error.panic + | betree.Message.Insert i => Result.fail .panic + | betree.Message.Delete => Result.fail .panic | betree.Message.Upsert s => do let v ← betree.upsert_update prev s @@ -302,8 +302,8 @@ divergent def betree.Node.apply_upserts_back let msg ← betree.List.pop_front (U64 × betree.Message) msgs let (_, m) := msg match m with - | betree.Message.Insert i => Result.fail Error.panic - | betree.Message.Delete => Result.fail Error.panic + | betree.Message.Insert i => Result.fail .panic + | betree.Message.Delete => Result.fail .panic | betree.Message.Upsert s => do let v ← betree.upsert_update prev s @@ -542,7 +542,7 @@ divergent def betree.Node.lookup_first_message_after_key Source: 'src/betree.rs', lines 689:4-692:34 -/ divergent def betree.Node.lookup_first_message_after_key_back (key : U64) (msgs : betree.List (U64 × betree.Message)) - (ret0 : betree.List (U64 × betree.Message)) : + (ret : betree.List (U64 × betree.Message)) : Result (betree.List (U64 × betree.Message)) := match msgs with @@ -552,10 +552,10 @@ divergent def betree.Node.lookup_first_message_after_key_back then do let next_msgs0 ← - betree.Node.lookup_first_message_after_key_back key next_msgs ret0 + betree.Node.lookup_first_message_after_key_back key next_msgs ret Result.ret (betree.List.Cons (k, m) next_msgs0) - else Result.ret ret0 - | betree.List.Nil => Result.ret ret0 + else Result.ret ret + | betree.List.Nil => Result.ret ret /- [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 ()) @@ -658,19 +658,19 @@ divergent def betree.Node.lookup_mut_in_bindings Source: 'src/betree.rs', lines 653:4-656:32 -/ divergent def betree.Node.lookup_mut_in_bindings_back (key : U64) (bindings : betree.List (U64 × U64)) - (ret0 : betree.List (U64 × U64)) : + (ret : betree.List (U64 × U64)) : Result (betree.List (U64 × U64)) := match bindings with | betree.List.Cons hd tl => let (i, i0) := hd if i >= key - then Result.ret ret0 + then Result.ret ret else do - let tl0 ← betree.Node.lookup_mut_in_bindings_back key tl ret0 + let tl0 ← betree.Node.lookup_mut_in_bindings_back key tl ret Result.ret (betree.List.Cons (i, i0) tl0) - | betree.List.Nil => Result.ret ret0 + | betree.List.Nil => Result.ret ret /- [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 ()) @@ -1069,6 +1069,6 @@ def main : Result Unit := Result.ret () /- Unit test for [betree_main::main] -/ -#assert (main == .ret ()) +#assert (main == Result.ret ()) end betree_main diff --git a/tests/lean/External/Funs.lean b/tests/lean/External/Funs.lean index e5655c7e..48ec6ad5 100644 --- a/tests/lean/External/Funs.lean +++ b/tests/lean/External/Funs.lean @@ -45,7 +45,7 @@ def test_vec : Result Unit := Result.ret () /- Unit test for [external::test_vec] -/ -#assert (test_vec == .ret ()) +#assert (test_vec == Result.ret ()) /- [external::custom_swap]: forward function Source: 'src/external.rs', lines 24:0-24:66 -/ @@ -60,14 +60,14 @@ def custom_swap /- [external::custom_swap]: backward function 0 Source: 'src/external.rs', lines 24:0-24:66 -/ def custom_swap_back - (T : Type) (x : T) (y : T) (st : State) (ret0 : T) (st0 : State) : + (T : Type) (x : T) (y : T) (st : State) (ret : T) (st0 : State) : Result (State × (T × T)) := do let (st1, _) ← core.mem.swap T x y st let (st2, _) ← core.mem.swap_back0 T x y st st1 let (_, y0) ← core.mem.swap_back1 T x y st st2 - Result.ret (st0, (ret0, y0)) + Result.ret (st0, (ret, y0)) /- [external::test_custom_swap]: forward function Source: 'src/external.rs', lines 29:0-29:59 -/ @@ -92,7 +92,7 @@ def test_swap_non_zero (x : U32) (st : State) : Result (State × U32) := let (st0, _) ← swap U32 x 0#u32 st let (st1, (x0, _)) ← swap_back U32 x 0#u32 st st0 if x0 = 0#u32 - then Result.fail Error.panic + then Result.fail .panic else Result.ret (st1, x0) end external diff --git a/tests/lean/Hashmap/Funs.lean b/tests/lean/Hashmap/Funs.lean index 95c501f6..e03981a2 100644 --- a/tests/lean/Hashmap/Funs.lean +++ b/tests/lean/Hashmap/Funs.lean @@ -295,7 +295,7 @@ divergent def HashMap.get_in_list_loop if ckey = key then Result.ret cvalue else HashMap.get_in_list_loop T key tl - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [hashmap::{hashmap::HashMap}::get_in_list]: forward function Source: 'src/hashmap.rs', lines 224:4-224:70 -/ @@ -324,7 +324,7 @@ divergent def HashMap.get_mut_in_list_loop if ckey = key then Result.ret cvalue else HashMap.get_mut_in_list_loop T tl key - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [hashmap::{hashmap::HashMap}::get_mut_in_list]: forward function Source: 'src/hashmap.rs', lines 245:4-245:86 -/ @@ -335,22 +335,22 @@ def HashMap.get_mut_in_list /- [hashmap::{hashmap::HashMap}::get_mut_in_list]: loop 0: backward function 0 Source: 'src/hashmap.rs', lines 245:4-254:5 -/ divergent def HashMap.get_mut_in_list_loop_back - (T : Type) (ls : List T) (key : Usize) (ret0 : T) : Result (List T) := + (T : Type) (ls : List T) (key : Usize) (ret : T) : Result (List T) := match ls with | List.Cons ckey cvalue tl => if ckey = key - then Result.ret (List.Cons ckey ret0 tl) + then Result.ret (List.Cons ckey ret tl) else do - let tl0 ← HashMap.get_mut_in_list_loop_back T tl key ret0 + let tl0 ← HashMap.get_mut_in_list_loop_back T tl key ret Result.ret (List.Cons ckey cvalue tl0) - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [hashmap::{hashmap::HashMap}::get_mut_in_list]: backward function 0 Source: 'src/hashmap.rs', lines 245:4-245:86 -/ def HashMap.get_mut_in_list_back - (T : Type) (ls : List T) (key : Usize) (ret0 : T) : Result (List T) := - HashMap.get_mut_in_list_loop_back T ls key ret0 + (T : Type) (ls : List T) (key : Usize) (ret : T) : Result (List T) := + HashMap.get_mut_in_list_loop_back T ls key ret /- [hashmap::{hashmap::HashMap}::get_mut]: forward function Source: 'src/hashmap.rs', lines 257:4-257:67 -/ @@ -368,9 +368,7 @@ def HashMap.get_mut (T : Type) (self : HashMap T) (key : Usize) : Result T := /- [hashmap::{hashmap::HashMap}::get_mut]: backward function 0 Source: 'src/hashmap.rs', lines 257:4-257:67 -/ def HashMap.get_mut_back - (T : Type) (self : HashMap T) (key : Usize) (ret0 : T) : - Result (HashMap T) - := + (T : Type) (self : HashMap T) (key : Usize) (ret : T) : Result (HashMap T) := do let hash ← hash_key key let i := alloc.vec.Vec.len (List T) self.slots @@ -379,7 +377,7 @@ def HashMap.get_mut_back alloc.vec.Vec.index_mut (List T) Usize (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots hash_mod - let l0 ← HashMap.get_mut_in_list_back T l key ret0 + let l0 ← HashMap.get_mut_in_list_back T l key ret let v ← alloc.vec.Vec.index_mut_back (List T) Usize (core.slice.index.SliceIndexUsizeSliceTInst (List T)) self.slots @@ -397,7 +395,7 @@ divergent def HashMap.remove_from_list_loop let mv_ls := core.mem.replace (List T) (List.Cons ckey t tl) List.Nil match mv_ls with | List.Cons i cvalue tl0 => Result.ret (some cvalue) - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic else HashMap.remove_from_list_loop T key tl | List.Nil => Result.ret none @@ -418,7 +416,7 @@ divergent def HashMap.remove_from_list_loop_back let mv_ls := core.mem.replace (List T) (List.Cons ckey t tl) List.Nil match mv_ls with | List.Cons i cvalue tl0 => Result.ret tl0 - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic else do let tl0 ← HashMap.remove_from_list_loop_back T key tl @@ -493,37 +491,37 @@ def test1 : Result Unit := let hm3 ← HashMap.insert U64 hm2 1056#usize 256#u64 let i ← HashMap.get U64 hm3 128#usize if not (i = 18#u64) - then Result.fail Error.panic + then Result.fail .panic else do let hm4 ← HashMap.get_mut_back U64 hm3 1024#usize 56#u64 let i0 ← HashMap.get U64 hm4 1024#usize if not (i0 = 56#u64) - then Result.fail Error.panic + then Result.fail .panic else do let x ← HashMap.remove U64 hm4 1024#usize match x with - | none => Result.fail Error.panic + | none => Result.fail .panic | some x0 => if not (x0 = 56#u64) - then Result.fail Error.panic + then Result.fail .panic else do let hm5 ← HashMap.remove_back U64 hm4 1024#usize let i1 ← HashMap.get U64 hm5 0#usize if not (i1 = 42#u64) - then Result.fail Error.panic + then Result.fail .panic else do let i2 ← HashMap.get U64 hm5 128#usize if not (i2 = 18#u64) - then Result.fail Error.panic + then Result.fail .panic else do let i3 ← HashMap.get U64 hm5 1056#usize if not (i3 = 256#u64) - then Result.fail Error.panic + then Result.fail .panic else Result.ret () end hashmap diff --git a/tests/lean/HashmapMain/Funs.lean b/tests/lean/HashmapMain/Funs.lean index abe84bbf..f87ad355 100644 --- a/tests/lean/HashmapMain/Funs.lean +++ b/tests/lean/HashmapMain/Funs.lean @@ -309,7 +309,7 @@ divergent def hashmap.HashMap.get_in_list_loop if ckey = key then Result.ret cvalue else hashmap.HashMap.get_in_list_loop T key tl - | hashmap.List.Nil => Result.fail Error.panic + | hashmap.List.Nil => Result.fail .panic /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_in_list]: forward function Source: 'src/hashmap.rs', lines 224:4-224:70 -/ @@ -340,7 +340,7 @@ divergent def hashmap.HashMap.get_mut_in_list_loop if ckey = key then Result.ret cvalue else hashmap.HashMap.get_mut_in_list_loop T tl key - | hashmap.List.Nil => Result.fail Error.panic + | hashmap.List.Nil => Result.fail .panic /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: forward function Source: 'src/hashmap.rs', lines 245:4-245:86 -/ @@ -351,26 +351,26 @@ def hashmap.HashMap.get_mut_in_list /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: loop 0: backward function 0 Source: 'src/hashmap.rs', lines 245:4-254:5 -/ divergent def hashmap.HashMap.get_mut_in_list_loop_back - (T : Type) (ls : hashmap.List T) (key : Usize) (ret0 : T) : + (T : Type) (ls : hashmap.List T) (key : Usize) (ret : T) : Result (hashmap.List T) := match ls with | hashmap.List.Cons ckey cvalue tl => if ckey = key - then Result.ret (hashmap.List.Cons ckey ret0 tl) + then Result.ret (hashmap.List.Cons ckey ret tl) else do - let tl0 ← hashmap.HashMap.get_mut_in_list_loop_back T tl key ret0 + let tl0 ← hashmap.HashMap.get_mut_in_list_loop_back T tl key ret Result.ret (hashmap.List.Cons ckey cvalue tl0) - | hashmap.List.Nil => Result.fail Error.panic + | hashmap.List.Nil => Result.fail .panic /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut_in_list]: backward function 0 Source: 'src/hashmap.rs', lines 245:4-245:86 -/ def hashmap.HashMap.get_mut_in_list_back - (T : Type) (ls : hashmap.List T) (key : Usize) (ret0 : T) : + (T : Type) (ls : hashmap.List T) (key : Usize) (ret : T) : Result (hashmap.List T) := - hashmap.HashMap.get_mut_in_list_loop_back T ls key ret0 + hashmap.HashMap.get_mut_in_list_loop_back T ls key ret /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut]: forward function Source: 'src/hashmap.rs', lines 257:4-257:67 -/ @@ -389,7 +389,7 @@ def hashmap.HashMap.get_mut /- [hashmap_main::hashmap::{hashmap_main::hashmap::HashMap}::get_mut]: backward function 0 Source: 'src/hashmap.rs', lines 257:4-257:67 -/ def hashmap.HashMap.get_mut_back - (T : Type) (self : hashmap.HashMap T) (key : Usize) (ret0 : T) : + (T : Type) (self : hashmap.HashMap T) (key : Usize) (ret : T) : Result (hashmap.HashMap T) := do @@ -400,7 +400,7 @@ def hashmap.HashMap.get_mut_back alloc.vec.Vec.index_mut (hashmap.List T) Usize (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) self.slots hash_mod - let l0 ← hashmap.HashMap.get_mut_in_list_back T l key ret0 + let l0 ← hashmap.HashMap.get_mut_in_list_back T l key ret let v ← alloc.vec.Vec.index_mut_back (hashmap.List T) Usize (core.slice.index.SliceIndexUsizeSliceTInst (hashmap.List T)) @@ -420,7 +420,7 @@ divergent def hashmap.HashMap.remove_from_list_loop hashmap.List.Nil match mv_ls with | hashmap.List.Cons i cvalue tl0 => Result.ret (some cvalue) - | hashmap.List.Nil => Result.fail Error.panic + | hashmap.List.Nil => Result.fail .panic else hashmap.HashMap.remove_from_list_loop T key tl | hashmap.List.Nil => Result.ret none @@ -443,7 +443,7 @@ divergent def hashmap.HashMap.remove_from_list_loop_back hashmap.List.Nil match mv_ls with | hashmap.List.Cons i cvalue tl0 => Result.ret tl0 - | hashmap.List.Nil => Result.fail Error.panic + | hashmap.List.Nil => Result.fail .panic else do let tl0 ← hashmap.HashMap.remove_from_list_loop_back T key tl @@ -520,37 +520,37 @@ def hashmap.test1 : Result Unit := let hm3 ← hashmap.HashMap.insert U64 hm2 1056#usize 256#u64 let i ← hashmap.HashMap.get U64 hm3 128#usize if not (i = 18#u64) - then Result.fail Error.panic + then Result.fail .panic else do let hm4 ← hashmap.HashMap.get_mut_back U64 hm3 1024#usize 56#u64 let i0 ← hashmap.HashMap.get U64 hm4 1024#usize if not (i0 = 56#u64) - then Result.fail Error.panic + then Result.fail .panic else do let x ← hashmap.HashMap.remove U64 hm4 1024#usize match x with - | none => Result.fail Error.panic + | none => Result.fail .panic | some x0 => if not (x0 = 56#u64) - then Result.fail Error.panic + then Result.fail .panic else do let hm5 ← hashmap.HashMap.remove_back U64 hm4 1024#usize let i1 ← hashmap.HashMap.get U64 hm5 0#usize if not (i1 = 42#u64) - then Result.fail Error.panic + then Result.fail .panic else do let i2 ← hashmap.HashMap.get U64 hm5 128#usize if not (i2 = 18#u64) - then Result.fail Error.panic + then Result.fail .panic else do let i3 ← hashmap.HashMap.get U64 hm5 1056#usize if not (i3 = 256#u64) - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- [hashmap_main::insert_on_disk]: forward function diff --git a/tests/lean/Loops.lean b/tests/lean/Loops.lean index ae1d87aa..08aa08a5 100644 --- a/tests/lean/Loops.lean +++ b/tests/lean/Loops.lean @@ -107,7 +107,7 @@ divergent def list_nth_mut_loop_loop else do let i0 ← i - 1#u32 list_nth_mut_loop_loop T tl i0 - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_loop]: forward function Source: 'src/loops.rs', lines 78:0-78:71 -/ @@ -117,23 +117,23 @@ def list_nth_mut_loop (T : Type) (ls : List T) (i : U32) : Result T := /- [loops::list_nth_mut_loop]: loop 0: backward function 0 Source: 'src/loops.rs', lines 78:0-88:1 -/ divergent def list_nth_mut_loop_loop_back - (T : Type) (ls : List T) (i : U32) (ret0 : T) : Result (List T) := + (T : Type) (ls : List T) (i : U32) (ret : T) : Result (List T) := match ls with | List.Cons x tl => if i = 0#u32 - then Result.ret (List.Cons ret0 tl) + then Result.ret (List.Cons ret tl) else do let i0 ← i - 1#u32 - let tl0 ← list_nth_mut_loop_loop_back T tl i0 ret0 + let tl0 ← list_nth_mut_loop_loop_back T tl i0 ret Result.ret (List.Cons x tl0) - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_loop]: backward function 0 Source: 'src/loops.rs', lines 78:0-78:71 -/ def list_nth_mut_loop_back - (T : Type) (ls : List T) (i : U32) (ret0 : T) : Result (List T) := - list_nth_mut_loop_loop_back T ls i ret0 + (T : Type) (ls : List T) (i : U32) (ret : T) : Result (List T) := + list_nth_mut_loop_loop_back T ls i ret /- [loops::list_nth_shared_loop]: loop 0: forward function Source: 'src/loops.rs', lines 91:0-101:1 -/ @@ -146,7 +146,7 @@ divergent def list_nth_shared_loop_loop else do let i0 ← i - 1#u32 list_nth_shared_loop_loop T tl i0 - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [loops::list_nth_shared_loop]: forward function Source: 'src/loops.rs', lines 91:0-91:66 -/ @@ -160,7 +160,7 @@ divergent def get_elem_mut_loop (x : Usize) (ls : List Usize) : Result Usize := | List.Cons y tl => if y = x then Result.ret y else get_elem_mut_loop x tl - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [loops::get_elem_mut]: forward function Source: 'src/loops.rs', lines 103:0-103:73 -/ @@ -175,28 +175,28 @@ def get_elem_mut /- [loops::get_elem_mut]: loop 0: backward function 0 Source: 'src/loops.rs', lines 103:0-117:1 -/ divergent def get_elem_mut_loop_back - (x : Usize) (ls : List Usize) (ret0 : Usize) : Result (List Usize) := + (x : Usize) (ls : List Usize) (ret : Usize) : Result (List Usize) := match ls with | List.Cons y tl => if y = x - then Result.ret (List.Cons ret0 tl) + then Result.ret (List.Cons ret tl) else do - let tl0 ← get_elem_mut_loop_back x tl ret0 + let tl0 ← get_elem_mut_loop_back x tl ret Result.ret (List.Cons y tl0) - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [loops::get_elem_mut]: backward function 0 Source: 'src/loops.rs', lines 103:0-103:73 -/ def get_elem_mut_back - (slots : alloc.vec.Vec (List Usize)) (x : Usize) (ret0 : Usize) : + (slots : alloc.vec.Vec (List Usize)) (x : Usize) (ret : Usize) : Result (alloc.vec.Vec (List Usize)) := do let l ← alloc.vec.Vec.index_mut (List Usize) Usize (core.slice.index.SliceIndexUsizeSliceTInst (List Usize)) slots 0#usize - let l0 ← get_elem_mut_loop_back x l ret0 + let l0 ← get_elem_mut_loop_back x l ret alloc.vec.Vec.index_mut_back (List Usize) Usize (core.slice.index.SliceIndexUsizeSliceTInst (List Usize)) slots 0#usize l0 @@ -209,7 +209,7 @@ divergent def get_elem_shared_loop | List.Cons y tl => if y = x then Result.ret y else get_elem_shared_loop x tl - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [loops::get_elem_shared]: forward function Source: 'src/loops.rs', lines 119:0-119:68 -/ @@ -228,8 +228,8 @@ def id_mut (T : Type) (ls : List T) : Result (List T) := /- [loops::id_mut]: backward function 0 Source: 'src/loops.rs', lines 135:0-135:50 -/ -def id_mut_back (T : Type) (ls : List T) (ret0 : List T) : Result (List T) := - Result.ret ret0 +def id_mut_back (T : Type) (ls : List T) (ret : List T) : Result (List T) := + Result.ret ret /- [loops::id_shared]: forward function Source: 'src/loops.rs', lines 139:0-139:45 -/ @@ -247,7 +247,7 @@ divergent def list_nth_mut_loop_with_id_loop else do let i0 ← i - 1#u32 list_nth_mut_loop_with_id_loop T i0 tl - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_loop_with_id]: forward function Source: 'src/loops.rs', lines 144:0-144:75 -/ @@ -259,25 +259,25 @@ def list_nth_mut_loop_with_id (T : Type) (ls : List T) (i : U32) : Result T := /- [loops::list_nth_mut_loop_with_id]: loop 0: backward function 0 Source: 'src/loops.rs', lines 144:0-155:1 -/ divergent def list_nth_mut_loop_with_id_loop_back - (T : Type) (i : U32) (ls : List T) (ret0 : T) : Result (List T) := + (T : Type) (i : U32) (ls : List T) (ret : T) : Result (List T) := match ls with | List.Cons x tl => if i = 0#u32 - then Result.ret (List.Cons ret0 tl) + then Result.ret (List.Cons ret tl) else do let i0 ← i - 1#u32 - let tl0 ← list_nth_mut_loop_with_id_loop_back T i0 tl ret0 + let tl0 ← list_nth_mut_loop_with_id_loop_back T i0 tl ret Result.ret (List.Cons x tl0) - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_loop_with_id]: backward function 0 Source: 'src/loops.rs', lines 144:0-144:75 -/ def list_nth_mut_loop_with_id_back - (T : Type) (ls : List T) (i : U32) (ret0 : T) : Result (List T) := + (T : Type) (ls : List T) (i : U32) (ret : T) : Result (List T) := do let ls0 ← id_mut T ls - let l ← list_nth_mut_loop_with_id_loop_back T i ls0 ret0 + let l ← list_nth_mut_loop_with_id_loop_back T i ls0 ret id_mut_back T ls l /- [loops::list_nth_shared_loop_with_id]: loop 0: forward function @@ -291,7 +291,7 @@ divergent def list_nth_shared_loop_with_id_loop else do let i0 ← i - 1#u32 list_nth_shared_loop_with_id_loop T i0 tl - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [loops::list_nth_shared_loop_with_id]: forward function Source: 'src/loops.rs', lines 158:0-158:70 -/ @@ -314,8 +314,8 @@ divergent def list_nth_mut_loop_pair_loop else do let i0 ← i - 1#u32 list_nth_mut_loop_pair_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_loop_pair]: forward function Source: 'src/loops.rs', lines 174:0-178:27 -/ @@ -326,7 +326,7 @@ def list_nth_mut_loop_pair /- [loops::list_nth_mut_loop_pair]: loop 0: backward function 0 Source: 'src/loops.rs', lines 174:0-195:1 -/ divergent def list_nth_mut_loop_pair_loop_back'a - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret : T) : Result (List T) := match ls0 with @@ -334,27 +334,27 @@ divergent def list_nth_mut_loop_pair_loop_back'a match ls1 with | List.Cons x1 tl1 => if i = 0#u32 - then Result.ret (List.Cons ret0 tl0) + then Result.ret (List.Cons ret tl0) else do let i0 ← i - 1#u32 - let tl00 ← list_nth_mut_loop_pair_loop_back'a T tl0 tl1 i0 ret0 + let tl00 ← list_nth_mut_loop_pair_loop_back'a T tl0 tl1 i0 ret Result.ret (List.Cons x0 tl00) - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_loop_pair]: backward function 0 Source: 'src/loops.rs', lines 174:0-178:27 -/ def list_nth_mut_loop_pair_back'a - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret : T) : Result (List T) := - list_nth_mut_loop_pair_loop_back'a T ls0 ls1 i ret0 + list_nth_mut_loop_pair_loop_back'a T ls0 ls1 i ret /- [loops::list_nth_mut_loop_pair]: loop 0: backward function 1 Source: 'src/loops.rs', lines 174:0-195:1 -/ divergent def list_nth_mut_loop_pair_loop_back'b - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret : T) : Result (List T) := match ls0 with @@ -362,22 +362,22 @@ divergent def list_nth_mut_loop_pair_loop_back'b match ls1 with | List.Cons x1 tl1 => if i = 0#u32 - then Result.ret (List.Cons ret0 tl1) + then Result.ret (List.Cons ret tl1) else do let i0 ← i - 1#u32 - let tl10 ← list_nth_mut_loop_pair_loop_back'b T tl0 tl1 i0 ret0 + let tl10 ← list_nth_mut_loop_pair_loop_back'b T tl0 tl1 i0 ret Result.ret (List.Cons x1 tl10) - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_loop_pair]: backward function 1 Source: 'src/loops.rs', lines 174:0-178:27 -/ def list_nth_mut_loop_pair_back'b - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret : T) : Result (List T) := - list_nth_mut_loop_pair_loop_back'b T ls0 ls1 i ret0 + list_nth_mut_loop_pair_loop_back'b T ls0 ls1 i ret /- [loops::list_nth_shared_loop_pair]: loop 0: forward function Source: 'src/loops.rs', lines 198:0-219:1 -/ @@ -392,8 +392,8 @@ divergent def list_nth_shared_loop_pair_loop else do let i0 ← i - 1#u32 list_nth_shared_loop_pair_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_shared_loop_pair]: forward function Source: 'src/loops.rs', lines 198:0-202:19 -/ @@ -415,8 +415,8 @@ divergent def list_nth_mut_loop_pair_merge_loop do let i0 ← i - 1#u32 list_nth_mut_loop_pair_merge_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_loop_pair_merge]: forward function Source: 'src/loops.rs', lines 223:0-227:27 -/ @@ -427,7 +427,7 @@ def list_nth_mut_loop_pair_merge /- [loops::list_nth_mut_loop_pair_merge]: loop 0: backward function 0 Source: 'src/loops.rs', lines 223:0-238:1 -/ divergent def list_nth_mut_loop_pair_merge_loop_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : (T × T)) : + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret : (T × T)) : Result ((List T) × (List T)) := match ls0 with @@ -435,24 +435,24 @@ divergent def list_nth_mut_loop_pair_merge_loop_back match ls1 with | List.Cons x1 tl1 => if i = 0#u32 - then let (t, t0) := ret0 + then let (t, t0) := ret Result.ret (List.Cons t tl0, List.Cons t0 tl1) else do let i0 ← i - 1#u32 let (tl00, tl10) ← - list_nth_mut_loop_pair_merge_loop_back T tl0 tl1 i0 ret0 + list_nth_mut_loop_pair_merge_loop_back T tl0 tl1 i0 ret Result.ret (List.Cons x0 tl00, List.Cons x1 tl10) - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_loop_pair_merge]: backward function 0 Source: 'src/loops.rs', lines 223:0-227:27 -/ def list_nth_mut_loop_pair_merge_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : (T × T)) : + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret : (T × T)) : Result ((List T) × (List T)) := - list_nth_mut_loop_pair_merge_loop_back T ls0 ls1 i ret0 + list_nth_mut_loop_pair_merge_loop_back T ls0 ls1 i ret /- [loops::list_nth_shared_loop_pair_merge]: loop 0: forward function Source: 'src/loops.rs', lines 241:0-256:1 -/ @@ -468,8 +468,8 @@ divergent def list_nth_shared_loop_pair_merge_loop do let i0 ← i - 1#u32 list_nth_shared_loop_pair_merge_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_shared_loop_pair_merge]: forward function Source: 'src/loops.rs', lines 241:0-245:19 -/ @@ -491,8 +491,8 @@ divergent def list_nth_mut_shared_loop_pair_loop do let i0 ← i - 1#u32 list_nth_mut_shared_loop_pair_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_shared_loop_pair]: forward function Source: 'src/loops.rs', lines 259:0-263:23 -/ @@ -503,7 +503,7 @@ def list_nth_mut_shared_loop_pair /- [loops::list_nth_mut_shared_loop_pair]: loop 0: backward function 0 Source: 'src/loops.rs', lines 259:0-274:1 -/ divergent def list_nth_mut_shared_loop_pair_loop_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret : T) : Result (List T) := match ls0 with @@ -511,23 +511,22 @@ divergent def list_nth_mut_shared_loop_pair_loop_back match ls1 with | List.Cons x1 tl1 => if i = 0#u32 - then Result.ret (List.Cons ret0 tl0) + then Result.ret (List.Cons ret tl0) else do let i0 ← i - 1#u32 - let tl00 ← - list_nth_mut_shared_loop_pair_loop_back T tl0 tl1 i0 ret0 + let tl00 ← list_nth_mut_shared_loop_pair_loop_back T tl0 tl1 i0 ret Result.ret (List.Cons x0 tl00) - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_shared_loop_pair]: backward function 0 Source: 'src/loops.rs', lines 259:0-263:23 -/ def list_nth_mut_shared_loop_pair_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret : T) : Result (List T) := - list_nth_mut_shared_loop_pair_loop_back T ls0 ls1 i ret0 + list_nth_mut_shared_loop_pair_loop_back T ls0 ls1 i ret /- [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: forward function Source: 'src/loops.rs', lines 278:0-293:1 -/ @@ -543,8 +542,8 @@ divergent def list_nth_mut_shared_loop_pair_merge_loop do let i0 ← i - 1#u32 list_nth_mut_shared_loop_pair_merge_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_shared_loop_pair_merge]: forward function Source: 'src/loops.rs', lines 278:0-282:23 -/ @@ -555,7 +554,7 @@ def list_nth_mut_shared_loop_pair_merge /- [loops::list_nth_mut_shared_loop_pair_merge]: loop 0: backward function 0 Source: 'src/loops.rs', lines 278:0-293:1 -/ divergent def list_nth_mut_shared_loop_pair_merge_loop_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret : T) : Result (List T) := match ls0 with @@ -563,23 +562,23 @@ divergent def list_nth_mut_shared_loop_pair_merge_loop_back match ls1 with | List.Cons x1 tl1 => if i = 0#u32 - then Result.ret (List.Cons ret0 tl0) + then Result.ret (List.Cons ret tl0) else do let i0 ← i - 1#u32 let tl00 ← - list_nth_mut_shared_loop_pair_merge_loop_back T tl0 tl1 i0 ret0 + list_nth_mut_shared_loop_pair_merge_loop_back T tl0 tl1 i0 ret Result.ret (List.Cons x0 tl00) - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_mut_shared_loop_pair_merge]: backward function 0 Source: 'src/loops.rs', lines 278:0-282:23 -/ def list_nth_mut_shared_loop_pair_merge_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret : T) : Result (List T) := - list_nth_mut_shared_loop_pair_merge_loop_back T ls0 ls1 i ret0 + list_nth_mut_shared_loop_pair_merge_loop_back T ls0 ls1 i ret /- [loops::list_nth_shared_mut_loop_pair]: loop 0: forward function Source: 'src/loops.rs', lines 297:0-312:1 -/ @@ -595,8 +594,8 @@ divergent def list_nth_shared_mut_loop_pair_loop do let i0 ← i - 1#u32 list_nth_shared_mut_loop_pair_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_shared_mut_loop_pair]: forward function Source: 'src/loops.rs', lines 297:0-301:23 -/ @@ -607,7 +606,7 @@ def list_nth_shared_mut_loop_pair /- [loops::list_nth_shared_mut_loop_pair]: loop 0: backward function 1 Source: 'src/loops.rs', lines 297:0-312:1 -/ divergent def list_nth_shared_mut_loop_pair_loop_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret : T) : Result (List T) := match ls0 with @@ -615,23 +614,22 @@ divergent def list_nth_shared_mut_loop_pair_loop_back match ls1 with | List.Cons x1 tl1 => if i = 0#u32 - then Result.ret (List.Cons ret0 tl1) + then Result.ret (List.Cons ret tl1) else do let i0 ← i - 1#u32 - let tl10 ← - list_nth_shared_mut_loop_pair_loop_back T tl0 tl1 i0 ret0 + let tl10 ← list_nth_shared_mut_loop_pair_loop_back T tl0 tl1 i0 ret Result.ret (List.Cons x1 tl10) - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_shared_mut_loop_pair]: backward function 1 Source: 'src/loops.rs', lines 297:0-301:23 -/ def list_nth_shared_mut_loop_pair_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret : T) : Result (List T) := - list_nth_shared_mut_loop_pair_loop_back T ls0 ls1 i ret0 + list_nth_shared_mut_loop_pair_loop_back T ls0 ls1 i ret /- [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: forward function Source: 'src/loops.rs', lines 316:0-331:1 -/ @@ -647,8 +645,8 @@ divergent def list_nth_shared_mut_loop_pair_merge_loop do let i0 ← i - 1#u32 list_nth_shared_mut_loop_pair_merge_loop T tl0 tl1 i0 - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_shared_mut_loop_pair_merge]: forward function Source: 'src/loops.rs', lines 316:0-320:23 -/ @@ -659,7 +657,7 @@ def list_nth_shared_mut_loop_pair_merge /- [loops::list_nth_shared_mut_loop_pair_merge]: loop 0: backward function 0 Source: 'src/loops.rs', lines 316:0-331:1 -/ divergent def list_nth_shared_mut_loop_pair_merge_loop_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret : T) : Result (List T) := match ls0 with @@ -667,22 +665,22 @@ divergent def list_nth_shared_mut_loop_pair_merge_loop_back match ls1 with | List.Cons x1 tl1 => if i = 0#u32 - then Result.ret (List.Cons ret0 tl1) + then Result.ret (List.Cons ret tl1) else do let i0 ← i - 1#u32 let tl10 ← - list_nth_shared_mut_loop_pair_merge_loop_back T tl0 tl1 i0 ret0 + list_nth_shared_mut_loop_pair_merge_loop_back T tl0 tl1 i0 ret Result.ret (List.Cons x1 tl10) - | List.Nil => Result.fail Error.panic - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic + | List.Nil => Result.fail .panic /- [loops::list_nth_shared_mut_loop_pair_merge]: backward function 0 Source: 'src/loops.rs', lines 316:0-320:23 -/ def list_nth_shared_mut_loop_pair_merge_back - (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret0 : T) : + (T : Type) (ls0 : List T) (ls1 : List T) (i : U32) (ret : T) : Result (List T) := - list_nth_shared_mut_loop_pair_merge_loop_back T ls0 ls1 i ret0 + list_nth_shared_mut_loop_pair_merge_loop_back T ls0 ls1 i ret end loops diff --git a/tests/lean/NoNestedBorrows.lean b/tests/lean/NoNestedBorrows.lean index 3b1c3f9f..ca66c628 100644 --- a/tests/lean/NoNestedBorrows.lean +++ b/tests/lean/NoNestedBorrows.lean @@ -101,7 +101,7 @@ def test2 : Result Unit := Result.ret () /- Unit test for [no_nested_borrows::test2] -/ -#assert (test2 == .ret ()) +#assert (test2 == Result.ret ()) /- [no_nested_borrows::get_max]: forward function Source: 'src/no_nested_borrows.rs', lines 111:0-111:37 -/ @@ -118,11 +118,11 @@ def test3 : Result Unit := let y ← get_max 10#u32 11#u32 let z ← x + y if not (z = 15#u32) - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- Unit test for [no_nested_borrows::test3] -/ -#assert (test3 == .ret ()) +#assert (test3 == Result.ret ()) /- [no_nested_borrows::test_neg1]: forward function Source: 'src/no_nested_borrows.rs', lines 126:0-126:18 -/ @@ -130,40 +130,39 @@ def test_neg1 : Result Unit := do let y ← - 3#i32 if not (y = (-(3:Int))#i32) - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- Unit test for [no_nested_borrows::test_neg1] -/ -#assert (test_neg1 == .ret ()) +#assert (test_neg1 == Result.ret ()) /- [no_nested_borrows::refs_test1]: forward function Source: 'src/no_nested_borrows.rs', lines 133:0-133:19 -/ def refs_test1 : Result Unit := if not (1#i32 = 1#i32) - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- Unit test for [no_nested_borrows::refs_test1] -/ -#assert (refs_test1 == .ret ()) +#assert (refs_test1 == Result.ret ()) /- [no_nested_borrows::refs_test2]: forward function Source: 'src/no_nested_borrows.rs', lines 144:0-144:19 -/ def refs_test2 : Result Unit := if not (2#i32 = 2#i32) - then Result.fail Error.panic + then Result.fail .panic else if not (0#i32 = 0#i32) - then Result.fail Error.panic + then Result.fail .panic else if not (2#i32 = 2#i32) - then Result.fail Error.panic - else - if not (2#i32 = 2#i32) - then Result.fail Error.panic - else Result.ret () + then Result.fail .panic + else if not (2#i32 = 2#i32) + then Result.fail .panic + else Result.ret () /- Unit test for [no_nested_borrows::refs_test2] -/ -#assert (refs_test2 == .ret ()) +#assert (refs_test2 == Result.ret ()) /- [no_nested_borrows::test_list1]: forward function Source: 'src/no_nested_borrows.rs', lines 160:0-160:19 -/ @@ -171,7 +170,7 @@ def test_list1 : Result Unit := Result.ret () /- Unit test for [no_nested_borrows::test_list1] -/ -#assert (test_list1 == .ret ()) +#assert (test_list1 == Result.ret ()) /- [no_nested_borrows::test_box1]: forward function Source: 'src/no_nested_borrows.rs', lines 165:0-165:18 -/ @@ -181,11 +180,11 @@ def test_box1 : Result Unit := let b0 ← alloc.boxed.Box.deref_mut_back I32 b 1#i32 let x ← alloc.boxed.Box.deref I32 b0 if not (x = 1#i32) - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- Unit test for [no_nested_borrows::test_box1] -/ -#assert (test_box1 == .ret ()) +#assert (test_box1 == Result.ret ()) /- [no_nested_borrows::copy_int]: forward function Source: 'src/no_nested_borrows.rs', lines 175:0-175:30 -/ @@ -196,14 +195,14 @@ def copy_int (x : I32) : Result I32 := Source: 'src/no_nested_borrows.rs', lines 181:0-181:32 -/ def test_unreachable (b : Bool) : Result Unit := if b - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- [no_nested_borrows::test_panic]: forward function Source: 'src/no_nested_borrows.rs', lines 189:0-189:26 -/ def test_panic (b : Bool) : Result Unit := if b - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- [no_nested_borrows::test_copy_int]: forward function @@ -212,11 +211,11 @@ def test_copy_int : Result Unit := do let y ← copy_int 0#i32 if not (0#i32 = y) - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- Unit test for [no_nested_borrows::test_copy_int] -/ -#assert (test_copy_int == .ret ()) +#assert (test_copy_int == Result.ret ()) /- [no_nested_borrows::is_cons]: forward function Source: 'src/no_nested_borrows.rs', lines 203:0-203:38 -/ @@ -232,18 +231,18 @@ def test_is_cons : Result Unit := let l := List.Nil let b ← is_cons I32 (List.Cons 0#i32 l) if not b - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- Unit test for [no_nested_borrows::test_is_cons] -/ -#assert (test_is_cons == .ret ()) +#assert (test_is_cons == Result.ret ()) /- [no_nested_borrows::split_list]: forward function Source: 'src/no_nested_borrows.rs', lines 216:0-216:48 -/ def split_list (T : Type) (l : List T) : Result (T × (List T)) := match l with | List.Cons hd tl => Result.ret (hd, tl) - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [no_nested_borrows::test_split_list]: forward function Source: 'src/no_nested_borrows.rs', lines 224:0-224:24 -/ @@ -253,11 +252,11 @@ def test_split_list : Result Unit := let p ← split_list I32 (List.Cons 0#i32 l) let (hd, _) := p if not (hd = 0#i32) - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- Unit test for [no_nested_borrows::test_split_list] -/ -#assert (test_split_list == .ret ()) +#assert (test_split_list == Result.ret ()) /- [no_nested_borrows::choose]: forward function Source: 'src/no_nested_borrows.rs', lines 231:0-231:70 -/ @@ -269,10 +268,10 @@ def choose (T : Type) (b : Bool) (x : T) (y : T) : Result T := /- [no_nested_borrows::choose]: backward function 0 Source: 'src/no_nested_borrows.rs', lines 231:0-231:70 -/ def choose_back - (T : Type) (b : Bool) (x : T) (y : T) (ret0 : T) : Result (T × T) := + (T : Type) (b : Bool) (x : T) (y : T) (ret : T) : Result (T × T) := if b - then Result.ret (ret0, y) - else Result.ret (x, ret0) + then Result.ret (ret, y) + else Result.ret (x, ret) /- [no_nested_borrows::choose_test]: forward function Source: 'src/no_nested_borrows.rs', lines 239:0-239:20 -/ @@ -281,18 +280,18 @@ def choose_test : Result Unit := let z ← choose I32 true 0#i32 0#i32 let z0 ← z + 1#i32 if not (z0 = 1#i32) - then Result.fail Error.panic + then Result.fail .panic else do let (x, y) ← choose_back I32 true 0#i32 0#i32 z0 if not (x = 1#i32) - then Result.fail Error.panic + then Result.fail .panic else if not (y = 0#i32) - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- Unit test for [no_nested_borrows::choose_test] -/ -#assert (choose_test == .ret ()) +#assert (choose_test == Result.ret ()) /- [no_nested_borrows::test_char]: forward function Source: 'src/no_nested_borrows.rs', lines 251:0-251:26 -/ @@ -334,7 +333,7 @@ divergent def list_nth_shared (T : Type) (l : List T) (i : U32) : Result T := else do let i0 ← i - 1#u32 list_nth_shared T tl i0 - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [no_nested_borrows::list_nth_mut]: forward function Source: 'src/no_nested_borrows.rs', lines 320:0-320:67 -/ @@ -346,22 +345,22 @@ divergent def list_nth_mut (T : Type) (l : List T) (i : U32) : Result T := else do let i0 ← i - 1#u32 list_nth_mut T tl i0 - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [no_nested_borrows::list_nth_mut]: backward function 0 Source: 'src/no_nested_borrows.rs', lines 320:0-320:67 -/ divergent def list_nth_mut_back - (T : Type) (l : List T) (i : U32) (ret0 : T) : Result (List T) := + (T : Type) (l : List T) (i : U32) (ret : T) : Result (List T) := match l with | List.Cons x tl => if i = 0#u32 - then Result.ret (List.Cons ret0 tl) + then Result.ret (List.Cons ret tl) else do let i0 ← i - 1#u32 - let tl0 ← list_nth_mut_back T tl i0 ret0 + let tl0 ← list_nth_mut_back T tl i0 ret Result.ret (List.Cons x tl0) - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [no_nested_borrows::list_rev_aux]: forward function Source: 'src/no_nested_borrows.rs', lines 336:0-336:63 -/ @@ -387,43 +386,43 @@ def test_list_functions : Result Unit := let l1 := List.Cons 1#i32 l0 let i ← list_length I32 (List.Cons 0#i32 l1) if not (i = 3#u32) - then Result.fail Error.panic + then Result.fail .panic else do let i0 ← list_nth_shared I32 (List.Cons 0#i32 l1) 0#u32 if not (i0 = 0#i32) - then Result.fail Error.panic + then Result.fail .panic else do let i1 ← list_nth_shared I32 (List.Cons 0#i32 l1) 1#u32 if not (i1 = 1#i32) - then Result.fail Error.panic + then Result.fail .panic else do let i2 ← list_nth_shared I32 (List.Cons 0#i32 l1) 2#u32 if not (i2 = 2#i32) - then Result.fail Error.panic + then Result.fail .panic else do let ls ← list_nth_mut_back I32 (List.Cons 0#i32 l1) 1#u32 3#i32 let i3 ← list_nth_shared I32 ls 0#u32 if not (i3 = 0#i32) - then Result.fail Error.panic + then Result.fail .panic else do let i4 ← list_nth_shared I32 ls 1#u32 if not (i4 = 3#i32) - then Result.fail Error.panic + then Result.fail .panic else do let i5 ← list_nth_shared I32 ls 2#u32 if not (i5 = 2#i32) - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- Unit test for [no_nested_borrows::test_list_functions] -/ -#assert (test_list_functions == .ret ()) +#assert (test_list_functions == Result.ret ()) /- [no_nested_borrows::id_mut_pair1]: forward function Source: 'src/no_nested_borrows.rs', lines 371:0-371:89 -/ @@ -433,8 +432,8 @@ def id_mut_pair1 (T1 T2 : Type) (x : T1) (y : T2) : Result (T1 × T2) := /- [no_nested_borrows::id_mut_pair1]: backward function 0 Source: 'src/no_nested_borrows.rs', lines 371:0-371:89 -/ def id_mut_pair1_back - (T1 T2 : Type) (x : T1) (y : T2) (ret0 : (T1 × T2)) : Result (T1 × T2) := - let (t, t0) := ret0 + (T1 T2 : Type) (x : T1) (y : T2) (ret : (T1 × T2)) : Result (T1 × T2) := + let (t, t0) := ret Result.ret (t, t0) /- [no_nested_borrows::id_mut_pair2]: forward function @@ -446,8 +445,8 @@ def id_mut_pair2 (T1 T2 : Type) (p : (T1 × T2)) : Result (T1 × T2) := /- [no_nested_borrows::id_mut_pair2]: backward function 0 Source: 'src/no_nested_borrows.rs', lines 375:0-375:88 -/ def id_mut_pair2_back - (T1 T2 : Type) (p : (T1 × T2)) (ret0 : (T1 × T2)) : Result (T1 × T2) := - let (t, t0) := ret0 + (T1 T2 : Type) (p : (T1 × T2)) (ret : (T1 × T2)) : Result (T1 × T2) := + let (t, t0) := ret Result.ret (t, t0) /- [no_nested_borrows::id_mut_pair3]: forward function @@ -458,14 +457,14 @@ def id_mut_pair3 (T1 T2 : Type) (x : T1) (y : T2) : Result (T1 × T2) := /- [no_nested_borrows::id_mut_pair3]: backward function 0 Source: 'src/no_nested_borrows.rs', lines 379:0-379:93 -/ def id_mut_pair3_back'a - (T1 T2 : Type) (x : T1) (y : T2) (ret0 : T1) : Result T1 := - Result.ret ret0 + (T1 T2 : Type) (x : T1) (y : T2) (ret : T1) : Result T1 := + Result.ret ret /- [no_nested_borrows::id_mut_pair3]: backward function 1 Source: 'src/no_nested_borrows.rs', lines 379:0-379:93 -/ def id_mut_pair3_back'b - (T1 T2 : Type) (x : T1) (y : T2) (ret0 : T2) : Result T2 := - Result.ret ret0 + (T1 T2 : Type) (x : T1) (y : T2) (ret : T2) : Result T2 := + Result.ret ret /- [no_nested_borrows::id_mut_pair4]: forward function Source: 'src/no_nested_borrows.rs', lines 383:0-383:92 -/ @@ -476,14 +475,14 @@ def id_mut_pair4 (T1 T2 : Type) (p : (T1 × T2)) : Result (T1 × T2) := /- [no_nested_borrows::id_mut_pair4]: backward function 0 Source: 'src/no_nested_borrows.rs', lines 383:0-383:92 -/ def id_mut_pair4_back'a - (T1 T2 : Type) (p : (T1 × T2)) (ret0 : T1) : Result T1 := - Result.ret ret0 + (T1 T2 : Type) (p : (T1 × T2)) (ret : T1) : Result T1 := + Result.ret ret /- [no_nested_borrows::id_mut_pair4]: backward function 1 Source: 'src/no_nested_borrows.rs', lines 383:0-383:92 -/ def id_mut_pair4_back'b - (T1 T2 : Type) (p : (T1 × T2)) (ret0 : T2) : Result T2 := - Result.ret ret0 + (T1 T2 : Type) (p : (T1 × T2)) (ret : T2) : Result T2 := + Result.ret ret /- [no_nested_borrows::StructWithTuple] Source: 'src/no_nested_borrows.rs', lines 390:0-390:34 -/ @@ -522,28 +521,28 @@ def test_constants : Result Unit := let swt ← new_tuple1 let (i, _) := swt.p if not (i = 1#u32) - then Result.fail Error.panic + then Result.fail .panic else do let swt0 ← new_tuple2 let (i0, _) := swt0.p if not (i0 = 1#i16) - then Result.fail Error.panic + then Result.fail .panic else do let swt1 ← new_tuple3 let (i1, _) := swt1.p if not (i1 = 1#u64) - then Result.fail Error.panic + then Result.fail .panic else do let swp ← new_pair1 if not (swp.p.x = 1#u32) - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- Unit test for [no_nested_borrows::test_constants] -/ -#assert (test_constants == .ret ()) +#assert (test_constants == Result.ret ()) /- [no_nested_borrows::test_weird_borrows1]: forward function Source: 'src/no_nested_borrows.rs', lines 428:0-428:28 -/ @@ -551,7 +550,7 @@ def test_weird_borrows1 : Result Unit := Result.ret () /- Unit test for [no_nested_borrows::test_weird_borrows1] -/ -#assert (test_weird_borrows1 == .ret ()) +#assert (test_weird_borrows1 == Result.ret ()) /- [no_nested_borrows::test_mem_replace]: merged forward/backward function (there is a single backward function, and the forward function returns ()) @@ -559,7 +558,7 @@ def test_weird_borrows1 : Result Unit := def test_mem_replace (px : U32) : Result U32 := let y := core.mem.replace U32 px 1#u32 if not (y = 0#u32) - then Result.fail Error.panic + then Result.fail .panic else Result.ret 2#u32 /- [no_nested_borrows::test_shared_borrow_bool1]: forward function diff --git a/tests/lean/Paper.lean b/tests/lean/Paper.lean index 37e0e70e..08386bb7 100644 --- a/tests/lean/Paper.lean +++ b/tests/lean/Paper.lean @@ -17,11 +17,11 @@ def test_incr : Result Unit := do let x ← ref_incr 0#i32 if not (x = 1#i32) - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- Unit test for [paper::test_incr] -/ -#assert (test_incr == .ret ()) +#assert (test_incr == Result.ret ()) /- [paper::choose]: forward function Source: 'src/paper.rs', lines 15:0-15:70 -/ @@ -33,10 +33,10 @@ def choose (T : Type) (b : Bool) (x : T) (y : T) : Result T := /- [paper::choose]: backward function 0 Source: 'src/paper.rs', lines 15:0-15:70 -/ def choose_back - (T : Type) (b : Bool) (x : T) (y : T) (ret0 : T) : Result (T × T) := + (T : Type) (b : Bool) (x : T) (y : T) (ret : T) : Result (T × T) := if b - then Result.ret (ret0, y) - else Result.ret (x, ret0) + then Result.ret (ret, y) + else Result.ret (x, ret) /- [paper::test_choose]: forward function Source: 'src/paper.rs', lines 23:0-23:20 -/ @@ -45,18 +45,18 @@ def test_choose : Result Unit := let z ← choose I32 true 0#i32 0#i32 let z0 ← z + 1#i32 if not (z0 = 1#i32) - then Result.fail Error.panic + then Result.fail .panic else do let (x, y) ← choose_back I32 true 0#i32 0#i32 z0 if not (x = 1#i32) - then Result.fail Error.panic + then Result.fail .panic else if not (y = 0#i32) - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- Unit test for [paper::test_choose] -/ -#assert (test_choose == .ret ()) +#assert (test_choose == Result.ret ()) /- [paper::List] Source: 'src/paper.rs', lines 35:0-35:16 -/ @@ -74,22 +74,22 @@ divergent def list_nth_mut (T : Type) (l : List T) (i : U32) : Result T := else do let i0 ← i - 1#u32 list_nth_mut T tl i0 - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [paper::list_nth_mut]: backward function 0 Source: 'src/paper.rs', lines 42:0-42:67 -/ divergent def list_nth_mut_back - (T : Type) (l : List T) (i : U32) (ret0 : T) : Result (List T) := + (T : Type) (l : List T) (i : U32) (ret : T) : Result (List T) := match l with | List.Cons x tl => if i = 0#u32 - then Result.ret (List.Cons ret0 tl) + then Result.ret (List.Cons ret tl) else do let i0 ← i - 1#u32 - let tl0 ← list_nth_mut_back T tl i0 ret0 + let tl0 ← list_nth_mut_back T tl i0 ret Result.ret (List.Cons x tl0) - | List.Nil => Result.fail Error.panic + | List.Nil => Result.fail .panic /- [paper::sum]: forward function Source: 'src/paper.rs', lines 57:0-57:32 -/ @@ -112,11 +112,11 @@ def test_nth : Result Unit := let l2 ← list_nth_mut_back I32 (List.Cons 1#i32 l1) 2#u32 x0 let i ← sum l2 if not (i = 7#i32) - then Result.fail Error.panic + then Result.fail .panic else Result.ret () /- Unit test for [paper::test_nth] -/ -#assert (test_nth == .ret ()) +#assert (test_nth == Result.ret ()) /- [paper::call_choose]: forward function Source: 'src/paper.rs', lines 76:0-76:44 -/ diff --git a/tests/lean/PoloniusList.lean b/tests/lean/PoloniusList.lean index 0ef71791..37f0dffb 100644 --- a/tests/lean/PoloniusList.lean +++ b/tests/lean/PoloniusList.lean @@ -24,15 +24,15 @@ divergent def get_list_at_x (ls : List U32) (x : U32) : Result (List U32) := /- [polonius_list::get_list_at_x]: backward function 0 Source: 'src/polonius_list.rs', lines 13:0-13:76 -/ divergent def get_list_at_x_back - (ls : List U32) (x : U32) (ret0 : List U32) : Result (List U32) := + (ls : List U32) (x : U32) (ret : List U32) : Result (List U32) := match ls with | List.Cons hd tl => if hd = x - then Result.ret ret0 + then Result.ret ret else do - let tl0 ← get_list_at_x_back tl x ret0 + let tl0 ← get_list_at_x_back tl x ret Result.ret (List.Cons hd tl0) - | List.Nil => Result.ret ret0 + | List.Nil => Result.ret ret end polonius_list diff --git a/tests/lean/Traits.lean b/tests/lean/Traits.lean index 9ac4736c..e7795d9c 100644 --- a/tests/lean/Traits.lean +++ b/tests/lean/Traits.lean @@ -326,15 +326,11 @@ def test_where2 := Result.ret () -/- [alloc::string::String] - Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/alloc/src/string.rs', lines 365:0-365:17 -/ -axiom alloc.string.String : Type - /- Trait declaration: [traits::ParentTrait0] Source: 'src/traits.rs', lines 200:0-200:22 -/ structure ParentTrait0 (Self : Type) where W : Type - get_name : Self → Result alloc.string.String + get_name : Self → Result String get_w : Self → Result W /- Trait declaration: [traits::ParentTrait1] @@ -350,9 +346,7 @@ structure ChildTrait (Self : Type) where /- [traits::test_child_trait1]: forward function Source: 'src/traits.rs', lines 209:0-209:56 -/ def test_child_trait1 - (T : Type) (ChildTraitTInst : ChildTrait T) (x : T) : - Result alloc.string.String - := + (T : Type) (ChildTraitTInst : ChildTrait T) (x : T) : Result String := ChildTraitTInst.ParentTrait0SelfInst.get_name x /- [traits::test_child_trait2]: forward function -- cgit v1.2.3 From bef2bd34fcb0817f1b7d16b95122bcc3c6f05c72 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Mon, 27 Nov 2023 10:29:25 +0100 Subject: Generate a dedicated file for the external types --- tests/lean/BetreeMain/Types.lean | 4 +--- tests/lean/BetreeMain/TypesExternal.lean | 7 +++++++ tests/lean/BetreeMain/TypesExternal_Template.lean | 9 +++++++++ tests/lean/External/Types.lean | 8 +------- tests/lean/External/TypesExternal.lean | 11 +++++++++++ tests/lean/External/TypesExternal_Template.lean | 13 +++++++++++++ tests/lean/HashmapMain/Types.lean | 4 +--- tests/lean/HashmapMain/TypesExternal.lean | 7 +++++++ tests/lean/HashmapMain/TypesExternal_Template.lean | 9 +++++++++ 9 files changed, 59 insertions(+), 13 deletions(-) create mode 100644 tests/lean/BetreeMain/TypesExternal.lean create mode 100644 tests/lean/BetreeMain/TypesExternal_Template.lean create mode 100644 tests/lean/External/TypesExternal.lean create mode 100644 tests/lean/External/TypesExternal_Template.lean create mode 100644 tests/lean/HashmapMain/TypesExternal.lean create mode 100644 tests/lean/HashmapMain/TypesExternal_Template.lean (limited to 'tests/lean') diff --git a/tests/lean/BetreeMain/Types.lean b/tests/lean/BetreeMain/Types.lean index 6e528437..877508f6 100644 --- a/tests/lean/BetreeMain/Types.lean +++ b/tests/lean/BetreeMain/Types.lean @@ -1,6 +1,7 @@ -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [betree_main]: type definitions import Base +import BetreeMain.TypesExternal open Primitives namespace betree_main @@ -63,7 +64,4 @@ structure betree.BeTree where node_id_cnt : betree.NodeIdCounter root : betree.Node -/- The state type used in the state-error monad -/ -axiom State : Type - end betree_main diff --git a/tests/lean/BetreeMain/TypesExternal.lean b/tests/lean/BetreeMain/TypesExternal.lean new file mode 100644 index 00000000..1701eaaf --- /dev/null +++ b/tests/lean/BetreeMain/TypesExternal.lean @@ -0,0 +1,7 @@ +-- [betree_main]: external types. +import Base +open Primitives + +/- The state type used in the state-error monad -/ +axiom State : Type + diff --git a/tests/lean/BetreeMain/TypesExternal_Template.lean b/tests/lean/BetreeMain/TypesExternal_Template.lean new file mode 100644 index 00000000..bbac7e99 --- /dev/null +++ b/tests/lean/BetreeMain/TypesExternal_Template.lean @@ -0,0 +1,9 @@ +-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS +-- [betree_main]: external types. +-- This is a template file: rename it to "TypesExternal.lean" and fill the holes. +import Base +open Primitives + +/- The state type used in the state-error monad -/ +axiom State : Type + diff --git a/tests/lean/External/Types.lean b/tests/lean/External/Types.lean index 40f20cda..961f3e8a 100644 --- a/tests/lean/External/Types.lean +++ b/tests/lean/External/Types.lean @@ -1,15 +1,9 @@ -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [external]: type definitions import Base +import External.TypesExternal open Primitives namespace external -/- [core::num::nonzero::NonZeroU32] - Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/num/nonzero.rs', lines 50:12-50:33 -/ -axiom core.num.nonzero.NonZeroU32 : Type - -/- The state type used in the state-error monad -/ -axiom State : Type - end external diff --git a/tests/lean/External/TypesExternal.lean b/tests/lean/External/TypesExternal.lean new file mode 100644 index 00000000..7c30f792 --- /dev/null +++ b/tests/lean/External/TypesExternal.lean @@ -0,0 +1,11 @@ +-- [external]: external types. +import Base +open Primitives + +/- [core::num::nonzero::NonZeroU32] + Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/num/nonzero.rs', lines 50:12-50:33 -/ +axiom core.num.nonzero.NonZeroU32 : Type + +/- The state type used in the state-error monad -/ +axiom State : Type + diff --git a/tests/lean/External/TypesExternal_Template.lean b/tests/lean/External/TypesExternal_Template.lean new file mode 100644 index 00000000..85fef236 --- /dev/null +++ b/tests/lean/External/TypesExternal_Template.lean @@ -0,0 +1,13 @@ +-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS +-- [external]: external types. +-- This is a template file: rename it to "TypesExternal.lean" and fill the holes. +import Base +open Primitives + +/- [core::num::nonzero::NonZeroU32] + Source: '/rustc/d59363ad0b6391b7fc5bbb02c9ccf9300eef3753/library/core/src/num/nonzero.rs', lines 50:12-50:33 -/ +axiom core.num.nonzero.NonZeroU32 : Type + +/- The state type used in the state-error monad -/ +axiom State : Type + diff --git a/tests/lean/HashmapMain/Types.lean b/tests/lean/HashmapMain/Types.lean index f7be6719..ae9ac999 100644 --- a/tests/lean/HashmapMain/Types.lean +++ b/tests/lean/HashmapMain/Types.lean @@ -1,6 +1,7 @@ -- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS -- [hashmap_main]: type definitions import Base +import HashmapMain.TypesExternal open Primitives namespace hashmap_main @@ -19,7 +20,4 @@ structure hashmap.HashMap (T : Type) where max_load : Usize slots : alloc.vec.Vec (hashmap.List T) -/- The state type used in the state-error monad -/ -axiom State : Type - end hashmap_main diff --git a/tests/lean/HashmapMain/TypesExternal.lean b/tests/lean/HashmapMain/TypesExternal.lean new file mode 100644 index 00000000..4e1cdbe9 --- /dev/null +++ b/tests/lean/HashmapMain/TypesExternal.lean @@ -0,0 +1,7 @@ +-- [hashmap_main]: external types. +import Base +open Primitives + +/- The state type used in the state-error monad -/ +axiom State : Type + diff --git a/tests/lean/HashmapMain/TypesExternal_Template.lean b/tests/lean/HashmapMain/TypesExternal_Template.lean new file mode 100644 index 00000000..cfa8bbb1 --- /dev/null +++ b/tests/lean/HashmapMain/TypesExternal_Template.lean @@ -0,0 +1,9 @@ +-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS +-- [hashmap_main]: external types. +-- This is a template file: rename it to "TypesExternal.lean" and fill the holes. +import Base +open Primitives + +/- The state type used in the state-error monad -/ +axiom State : Type + -- cgit v1.2.3 From 59cb4312df866ec00a1fddec62a1e660b358052d Mon Sep 17 00:00:00 2001 From: Son Ho Date: Wed, 29 Nov 2023 11:46:35 +0100 Subject: Regenerate the test files --- tests/lean/Traits.lean | 5 ----- 1 file changed, 5 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Traits.lean b/tests/lean/Traits.lean index e7795d9c..653384d6 100644 --- a/tests/lean/Traits.lean +++ b/tests/lean/Traits.lean @@ -468,9 +468,4 @@ structure CFn (Self Args : Type) where call_mut : Self → Args → Result CFnMutSelfArgsInst.CFnOnceSelfArgsInst.Output -/- [traits::incr_u32]: forward function - Source: 'src/traits.rs', lines 300:0-300:30 -/ -def incr_u32 (x : U32) : Result U32 := - x + 1#u32 - end traits -- cgit v1.2.3 From 94efdf274eb11f4f1ba9a510eb3dd6e190cfc507 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Wed, 29 Nov 2023 12:50:45 +0100 Subject: Regenerate the tests --- tests/lean/Array.lean | 71 ++++++++++++++++++++++++++++++--------------------- 1 file changed, 42 insertions(+), 29 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/Array.lean b/tests/lean/Array.lean index b49add96..25dad3cf 100644 --- a/tests/lean/Array.lean +++ b/tests/lean/Array.lean @@ -232,8 +232,21 @@ def take_slice (s : Slice U32) : Result Unit := def take_mut_slice (s : Slice U32) : Result (Slice U32) := Result.ret s +/- [array::const_array]: forward function + Source: 'src/array.rs', lines 127:0-127:32 -/ +def const_array : Result (Array U32 2#usize) := + Result.ret (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + +/- [array::const_slice]: forward function + Source: 'src/array.rs', lines 131:0-131:20 -/ +def const_slice : Result Unit := + do + let _ ← + Array.to_slice U32 2#usize (Array.make U32 2#usize [ 0#u32, 0#u32 ]) + Result.ret () + /- [array::take_all]: forward function - Source: 'src/array.rs', lines 127:0-127:17 -/ + Source: 'src/array.rs', lines 141:0-141:17 -/ def take_all : Result Unit := do let _ ← take_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) @@ -249,34 +262,34 @@ def take_all : Result Unit := Result.ret () /- [array::index_array]: forward function - Source: 'src/array.rs', lines 141:0-141:38 -/ + Source: 'src/array.rs', lines 155:0-155:38 -/ def index_array (x : Array U32 2#usize) : Result U32 := Array.index_usize U32 2#usize x 0#usize /- [array::index_array_borrow]: forward function - Source: 'src/array.rs', lines 144:0-144:46 -/ + Source: 'src/array.rs', lines 158:0-158:46 -/ def 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 - Source: 'src/array.rs', lines 148:0-148:42 -/ + Source: 'src/array.rs', lines 162:0-162:42 -/ def index_slice_u32_0 (x : Slice U32) : Result U32 := Slice.index_usize U32 x 0#usize /- [array::index_mut_slice_u32_0]: forward function - Source: 'src/array.rs', lines 152:0-152:50 -/ + Source: 'src/array.rs', lines 166:0-166:50 -/ def index_mut_slice_u32_0 (x : Slice U32) : Result U32 := Slice.index_usize U32 x 0#usize /- [array::index_mut_slice_u32_0]: backward function 0 - Source: 'src/array.rs', lines 152:0-152:50 -/ + Source: 'src/array.rs', lines 166:0-166:50 -/ def index_mut_slice_u32_0_back (x : Slice U32) : Result (Slice U32) := do let _ ← Slice.index_usize U32 x 0#usize Result.ret x /- [array::index_all]: forward function - Source: 'src/array.rs', lines 156:0-156:25 -/ + Source: 'src/array.rs', lines 170:0-170:25 -/ def index_all : Result U32 := do let i ← index_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) @@ -298,7 +311,7 @@ def index_all : Result U32 := Result.ret i7 /- [array::update_array]: forward function - Source: 'src/array.rs', lines 170:0-170:36 -/ + Source: 'src/array.rs', lines 184:0-184:36 -/ def update_array (x : Array U32 2#usize) : Result Unit := do let _ ← Array.update_usize U32 2#usize x 0#usize 1#u32 @@ -306,19 +319,19 @@ def update_array (x : Array U32 2#usize) : Result Unit := /- [array::update_array_mut_borrow]: merged forward/backward function (there is a single backward function, and the forward function returns ()) - Source: 'src/array.rs', lines 173:0-173:48 -/ + Source: 'src/array.rs', lines 187:0-187:48 -/ def 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 /- [array::update_mut_slice]: merged forward/backward function (there is a single backward function, and the forward function returns ()) - Source: 'src/array.rs', lines 176:0-176:38 -/ + Source: 'src/array.rs', lines 190:0-190:38 -/ def update_mut_slice (x : Slice U32) : Result (Slice U32) := Slice.update_usize U32 x 0#usize 1#u32 /- [array::update_all]: forward function - Source: 'src/array.rs', lines 180:0-180:19 -/ + Source: 'src/array.rs', lines 194:0-194:19 -/ def update_all : Result Unit := do let _ ← update_array (Array.make U32 2#usize [ 0#u32, 0#u32 ]) @@ -329,7 +342,7 @@ def update_all : Result Unit := Result.ret () /- [array::range_all]: forward function - Source: 'src/array.rs', lines 191:0-191:18 -/ + Source: 'src/array.rs', lines 205:0-205:18 -/ def range_all : Result Unit := do let s ← @@ -348,17 +361,17 @@ def range_all : Result Unit := Result.ret () /- [array::deref_array_borrow]: forward function - Source: 'src/array.rs', lines 200:0-200:46 -/ + Source: 'src/array.rs', lines 214:0-214:46 -/ def 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 205:0-205:54 -/ + Source: 'src/array.rs', lines 219:0-219:54 -/ def 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 - Source: 'src/array.rs', lines 205:0-205:54 -/ + Source: 'src/array.rs', lines 219:0-219:54 -/ def deref_array_mut_borrow_back (x : Array U32 2#usize) : Result (Array U32 2#usize) := do @@ -366,19 +379,19 @@ def deref_array_mut_borrow_back Result.ret x /- [array::take_array_t]: forward function - Source: 'src/array.rs', lines 213:0-213:31 -/ + Source: 'src/array.rs', lines 227:0-227:31 -/ def take_array_t (a : Array AB 2#usize) : Result Unit := Result.ret () /- [array::non_copyable_array]: forward function - Source: 'src/array.rs', lines 215:0-215:27 -/ + Source: 'src/array.rs', lines 229:0-229:27 -/ def non_copyable_array : Result Unit := do let _ ← take_array_t (Array.make AB 2#usize [ AB.A, AB.B ]) Result.ret () /- [array::sum]: loop 0: forward function - Source: 'src/array.rs', lines 228:0-236:1 -/ + Source: 'src/array.rs', lines 242:0-250:1 -/ divergent def sum_loop (s : Slice U32) (sum0 : U32) (i : Usize) : Result U32 := let i0 := Slice.len U32 s if i < i0 @@ -391,12 +404,12 @@ divergent def sum_loop (s : Slice U32) (sum0 : U32) (i : Usize) : Result U32 := else Result.ret sum0 /- [array::sum]: forward function - Source: 'src/array.rs', lines 228:0-228:28 -/ + Source: 'src/array.rs', lines 242:0-242:28 -/ def sum (s : Slice U32) : Result U32 := sum_loop s 0#u32 0#usize /- [array::sum2]: loop 0: forward function - Source: 'src/array.rs', lines 238:0-247:1 -/ + Source: 'src/array.rs', lines 252:0-261:1 -/ divergent def sum2_loop (s : Slice U32) (s2 : Slice U32) (sum0 : U32) (i : Usize) : Result U32 := let i0 := Slice.len U32 s @@ -412,7 +425,7 @@ divergent def sum2_loop else Result.ret sum0 /- [array::sum2]: forward function - Source: 'src/array.rs', lines 238:0-238:41 -/ + Source: 'src/array.rs', lines 252:0-252:41 -/ def sum2 (s : Slice U32) (s2 : Slice U32) : Result U32 := let i := Slice.len U32 s let i0 := Slice.len U32 s2 @@ -421,7 +434,7 @@ def sum2 (s : Slice U32) (s2 : Slice U32) : Result U32 := else sum2_loop s s2 0#u32 0#usize /- [array::f0]: forward function - Source: 'src/array.rs', lines 249:0-249:11 -/ + Source: 'src/array.rs', lines 263:0-263:11 -/ def f0 : Result Unit := do let s ← @@ -432,7 +445,7 @@ def f0 : Result Unit := Result.ret () /- [array::f1]: forward function - Source: 'src/array.rs', lines 254:0-254:11 -/ + Source: 'src/array.rs', lines 268:0-268:11 -/ def f1 : Result Unit := do let _ ← @@ -441,12 +454,12 @@ def f1 : Result Unit := Result.ret () /- [array::f2]: forward function - Source: 'src/array.rs', lines 259:0-259:17 -/ + Source: 'src/array.rs', lines 273:0-273:17 -/ def f2 (i : U32) : Result Unit := Result.ret () /- [array::f4]: forward function - Source: 'src/array.rs', lines 268:0-268:54 -/ + Source: 'src/array.rs', lines 282:0-282:54 -/ def f4 (x : Array U32 32#usize) (y : Usize) (z : Usize) : Result (Slice U32) := core.array.Array.index U32 (core.ops.range.Range Usize) 32#usize (core.ops.index.IndexSliceTIInst U32 (core.ops.range.Range Usize) @@ -454,7 +467,7 @@ def f4 (x : Array U32 32#usize) (y : Usize) (z : Usize) : Result (Slice U32) := { start := y, end_ := z } /- [array::f3]: forward function - Source: 'src/array.rs', lines 261:0-261:18 -/ + Source: 'src/array.rs', lines 275:0-275:18 -/ def f3 : Result U32 := do let i ← @@ -468,17 +481,17 @@ def f3 : Result U32 := sum2 s s0 /- [array::SZ] - Source: 'src/array.rs', lines 272:0-272:19 -/ + Source: 'src/array.rs', lines 286:0-286:19 -/ def sz_body : Result Usize := Result.ret 32#usize def sz_c : Usize := eval_global sz_body (by simp) /- [array::f5]: forward function - Source: 'src/array.rs', lines 275:0-275:31 -/ + Source: 'src/array.rs', lines 289:0-289:31 -/ def f5 (x : Array U32 32#usize) : Result U32 := Array.index_usize U32 32#usize x 0#usize /- [array::ite]: forward function - Source: 'src/array.rs', lines 280:0-280:12 -/ + Source: 'src/array.rs', lines 294:0-294:12 -/ def ite : Result Unit := do let s ← -- cgit v1.2.3 From 5bf73730e13e51f6dc2a46f92d2ddde152c1c5d2 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Wed, 29 Nov 2023 15:48:07 +0100 Subject: Generate the Bitwise test files --- tests/lean/Bitwise.lean | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) create mode 100644 tests/lean/Bitwise.lean (limited to 'tests/lean') diff --git a/tests/lean/Bitwise.lean b/tests/lean/Bitwise.lean new file mode 100644 index 00000000..c8538aa2 --- /dev/null +++ b/tests/lean/Bitwise.lean @@ -0,0 +1,37 @@ +-- THIS FILE WAS AUTOMATICALLY GENERATED BY AENEAS +-- [bitwise] +import Base +open Primitives + +namespace bitwise + +/- [bitwise::shift_u32]: forward function + Source: 'src/bitwise.rs', lines 3:0-3:31 -/ +def shift_u32 (a : U32) : Result U32 := + do + let t ← a >>> 16#usize + t <<< 16#usize + +/- [bitwise::shift_i32]: forward function + Source: 'src/bitwise.rs', lines 10:0-10:31 -/ +def shift_i32 (a : I32) : Result I32 := + do + let t ← a >>> 16#isize + t <<< 16#isize + +/- [bitwise::xor_u32]: forward function + Source: 'src/bitwise.rs', lines 17:0-17:37 -/ +def xor_u32 (a : U32) (b : U32) : Result U32 := + Result.ret (a ^^^ b) + +/- [bitwise::or_u32]: forward function + Source: 'src/bitwise.rs', lines 21:0-21:36 -/ +def or_u32 (a : U32) (b : U32) : Result U32 := + Result.ret (a ||| b) + +/- [bitwise::and_u32]: forward function + Source: 'src/bitwise.rs', lines 25:0-25:37 -/ +def and_u32 (a : U32) (b : U32) : Result U32 := + Result.ret (a &&& b) + +end bitwise -- cgit v1.2.3 From 60ce69b83cbd749781543bb16becb5357f0e1a0a Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 5 Dec 2023 15:00:46 +0100 Subject: Update following changes in Charon --- tests/lean/BetreeMain/Funs.lean | 30 +++--- tests/lean/NoNestedBorrows.lean | 204 ++++++++++++++++++++++++++-------------- 2 files changed, 146 insertions(+), 88 deletions(-) (limited to 'tests/lean') diff --git a/tests/lean/BetreeMain/Funs.lean b/tests/lean/BetreeMain/Funs.lean index 4c862225..0d7cb984 100644 --- a/tests/lean/BetreeMain/Funs.lean +++ b/tests/lean/BetreeMain/Funs.lean @@ -256,6 +256,21 @@ divergent def betree.Node.lookup_first_message_for_key_back Result.ret (betree.List.Cons (i, m) next_msgs0) | betree.List.Nil => Result.ret ret +/- [betree_main::betree::{betree_main::betree::Node#5}::lookup_in_bindings]: forward function + Source: 'src/betree.rs', lines 636:4-636:80 -/ +divergent def betree.Node.lookup_in_bindings + (key : U64) (bindings : betree.List (U64 × U64)) : Result (Option U64) := + match bindings with + | betree.List.Cons hd tl => + let (i, i0) := hd + if i = key + then Result.ret (some i0) + else + if i > key + then Result.ret none + else betree.Node.lookup_in_bindings key tl + | betree.List.Nil => Result.ret none + /- [betree_main::betree::{betree_main::betree::Node#5}::apply_upserts]: forward function Source: 'src/betree.rs', lines 819:4-819:90 -/ divergent def betree.Node.apply_upserts @@ -316,21 +331,6 @@ divergent def betree.Node.apply_upserts_back betree.List.push_front (U64 × betree.Message) msgs (key, betree.Message.Insert v) -/- [betree_main::betree::{betree_main::betree::Node#5}::lookup_in_bindings]: forward function - Source: 'src/betree.rs', lines 636:4-636:80 -/ -divergent def betree.Node.lookup_in_bindings - (key : U64) (bindings : betree.List (U64 × U64)) : Result (Option U64) := - match bindings with - | betree.List.Cons hd tl => - let (i, i0) := hd - if i = key - then Result.ret (some i0) - else - if i > key - then Result.ret none - else betree.Node.lookup_in_bindings key tl - | betree.List.Nil => Result.ret none - /- [betree_main::betree::{betree_main::betree::Internal#4}::lookup_in_children]: forward function Source: 'src/betree.rs', lines 395:4-395:63 -/ mutual divergent def betree.Internal.lookup_in_children diff --git a/tests/lean/NoNestedBorrows.lean b/tests/lean/NoNestedBorrows.lean index ca66c628..0c7dff8e 100644 --- a/tests/lean/NoNestedBorrows.lean +++ b/tests/lean/NoNestedBorrows.lean @@ -48,53 +48,111 @@ inductive Sum (T1 T2 : Type) := def neg_test (x : I32) : Result I32 := - x -/- [no_nested_borrows::add_test]: forward function - Source: 'src/no_nested_borrows.rs', lines 54:0-54:38 -/ -def add_test (x : U32) (y : U32) : Result U32 := +/- [no_nested_borrows::add_u32]: forward function + Source: 'src/no_nested_borrows.rs', lines 54:0-54:37 -/ +def add_u32 (x : U32) (y : U32) : Result U32 := x + y -/- [no_nested_borrows::subs_test]: forward function - Source: 'src/no_nested_borrows.rs', lines 60:0-60:39 -/ -def subs_test (x : U32) (y : U32) : Result U32 := +/- [no_nested_borrows::subs_u32]: forward function + Source: 'src/no_nested_borrows.rs', lines 60:0-60:38 -/ +def subs_u32 (x : U32) (y : U32) : Result U32 := x - y -/- [no_nested_borrows::div_test]: forward function - Source: 'src/no_nested_borrows.rs', lines 66:0-66:38 -/ -def div_test (x : U32) (y : U32) : Result U32 := +/- [no_nested_borrows::div_u32]: forward function + Source: 'src/no_nested_borrows.rs', lines 66:0-66:37 -/ +def div_u32 (x : U32) (y : U32) : Result U32 := x / y -/- [no_nested_borrows::div_test1]: forward function - Source: 'src/no_nested_borrows.rs', lines 73:0-73:31 -/ -def div_test1 (x : U32) : Result U32 := +/- [no_nested_borrows::div_u32_const]: forward function + Source: 'src/no_nested_borrows.rs', lines 73:0-73:35 -/ +def div_u32_const (x : U32) : Result U32 := x / 2#u32 -/- [no_nested_borrows::rem_test]: forward function - Source: 'src/no_nested_borrows.rs', lines 78:0-78:38 -/ -def rem_test (x : U32) (y : U32) : Result U32 := +/- [no_nested_borrows::rem_u32]: forward function + Source: 'src/no_nested_borrows.rs', lines 78:0-78:37 -/ +def rem_u32 (x : U32) (y : U32) : Result U32 := x % y -/- [no_nested_borrows::mul_test]: forward function - Source: 'src/no_nested_borrows.rs', lines 82:0-82:38 -/ -def mul_test (x : U32) (y : U32) : Result U32 := +/- [no_nested_borrows::mul_u32]: forward function + Source: 'src/no_nested_borrows.rs', lines 82:0-82:37 -/ +def mul_u32 (x : U32) (y : U32) : Result U32 := x * y +/- [no_nested_borrows::add_i32]: forward function + Source: 'src/no_nested_borrows.rs', lines 88:0-88:37 -/ +def add_i32 (x : I32) (y : I32) : Result I32 := + x + y + +/- [no_nested_borrows::subs_i32]: forward function + Source: 'src/no_nested_borrows.rs', lines 92:0-92:38 -/ +def subs_i32 (x : I32) (y : I32) : Result I32 := + x - y + +/- [no_nested_borrows::div_i32]: forward function + Source: 'src/no_nested_borrows.rs', lines 96:0-96:37 -/ +def div_i32 (x : I32) (y : I32) : Result I32 := + x / y + +/- [no_nested_borrows::div_i32_const]: forward function + Source: 'src/no_nested_borrows.rs', lines 100:0-100:35 -/ +def div_i32_const (x : I32) : Result I32 := + x / 2#i32 + +/- [no_nested_borrows::rem_i32]: forward function + Source: 'src/no_nested_borrows.rs', lines 104:0-104:37 -/ +def rem_i32 (x : I32) (y : I32) : Result I32 := + x % y + +/- [no_nested_borrows::mul_i32]: forward function + Source: 'src/no_nested_borrows.rs', lines 108:0-108:37 -/ +def mul_i32 (x : I32) (y : I32) : Result I32 := + x * y + +/- [no_nested_borrows::mix_arith_u32]: forward function + Source: 'src/no_nested_borrows.rs', lines 112:0-112:51 -/ +def mix_arith_u32 (x : U32) (y : U32) (z : U32) : Result U32 := + do + let i ← x + y + let i0 ← x / y + let i1 ← i * i0 + let i2 ← z % y + let i3 ← x - i2 + let i4 ← i1 + i3 + let i5 ← x + y + let i6 ← i5 + z + i4 % i6 + +/- [no_nested_borrows::mix_arith_i32]: forward function + Source: 'src/no_nested_borrows.rs', lines 116:0-116:51 -/ +def mix_arith_i32 (x : I32) (y : I32) (z : I32) : Result I32 := + do + let i ← x + y + let i0 ← x / y + let i1 ← i * i0 + let i2 ← z % y + let i3 ← x - i2 + let i4 ← i1 + i3 + let i5 ← x + y + let i6 ← i5 + z + i4 % i6 + /- [no_nested_borrows::CONST0] - Source: 'src/no_nested_borrows.rs', lines 91:0-91:23 -/ + Source: 'src/no_nested_borrows.rs', lines 125:0-125:23 -/ def const0_body : Result Usize := 1#usize + 1#usize def const0_c : Usize := eval_global const0_body (by simp) /- [no_nested_borrows::CONST1] - Source: 'src/no_nested_borrows.rs', lines 92:0-92:23 -/ + Source: 'src/no_nested_borrows.rs', lines 126:0-126:23 -/ def const1_body : Result Usize := 2#usize * 2#usize def const1_c : Usize := eval_global const1_body (by simp) /- [no_nested_borrows::cast_test]: forward function - Source: 'src/no_nested_borrows.rs', lines 94:0-94:31 -/ + Source: 'src/no_nested_borrows.rs', lines 128:0-128:31 -/ def cast_test (x : U32) : Result I32 := Scalar.cast .I32 x /- [no_nested_borrows::test2]: forward function - Source: 'src/no_nested_borrows.rs', lines 99:0-99:14 -/ + Source: 'src/no_nested_borrows.rs', lines 133:0-133:14 -/ def test2 : Result Unit := do let _ ← 23#u32 + 44#u32 @@ -104,14 +162,14 @@ def test2 : Result Unit := #assert (test2 == Result.ret ()) /- [no_nested_borrows::get_max]: forward function - Source: 'src/no_nested_borrows.rs', lines 111:0-111:37 -/ + Source: 'src/no_nested_borrows.rs', lines 145:0-145:37 -/ def get_max (x : U32) (y : U32) : Result U32 := if x >= y then Result.ret x else Result.ret y /- [no_nested_borrows::test3]: forward function - Source: 'src/no_nested_borrows.rs', lines 119:0-119:14 -/ + Source: 'src/no_nested_borrows.rs', lines 153:0-153:14 -/ def test3 : Result Unit := do let x ← get_max 4#u32 3#u32 @@ -125,7 +183,7 @@ def test3 : Result Unit := #assert (test3 == Result.ret ()) /- [no_nested_borrows::test_neg1]: forward function - Source: 'src/no_nested_borrows.rs', lines 126:0-126:18 -/ + Source: 'src/no_nested_borrows.rs', lines 160:0-160:18 -/ def test_neg1 : Result Unit := do let y ← - 3#i32 @@ -137,7 +195,7 @@ def test_neg1 : Result Unit := #assert (test_neg1 == Result.ret ()) /- [no_nested_borrows::refs_test1]: forward function - Source: 'src/no_nested_borrows.rs', lines 133:0-133:19 -/ + Source: 'src/no_nested_borrows.rs', lines 167:0-167:19 -/ def refs_test1 : Result Unit := if not (1#i32 = 1#i32) then Result.fail .panic @@ -147,7 +205,7 @@ def refs_test1 : Result Unit := #assert (refs_test1 == Result.ret ()) /- [no_nested_borrows::refs_test2]: forward function - Source: 'src/no_nested_borrows.rs', lines 144:0-144:19 -/ + Source: 'src/no_nested_borrows.rs', lines 178:0-178:19 -/ def refs_test2 : Result Unit := if not (2#i32 = 2#i32) then Result.fail .panic @@ -165,7 +223,7 @@ def refs_test2 : Result Unit := #assert (refs_test2 == Result.ret ()) /- [no_nested_borrows::test_list1]: forward function - Source: 'src/no_nested_borrows.rs', lines 160:0-160:19 -/ + Source: 'src/no_nested_borrows.rs', lines 194:0-194:19 -/ def test_list1 : Result Unit := Result.ret () @@ -173,7 +231,7 @@ def test_list1 : Result Unit := #assert (test_list1 == Result.ret ()) /- [no_nested_borrows::test_box1]: forward function - Source: 'src/no_nested_borrows.rs', lines 165:0-165:18 -/ + Source: 'src/no_nested_borrows.rs', lines 199:0-199:18 -/ def test_box1 : Result Unit := do let b := 0#i32 @@ -187,26 +245,26 @@ def test_box1 : Result Unit := #assert (test_box1 == Result.ret ()) /- [no_nested_borrows::copy_int]: forward function - Source: 'src/no_nested_borrows.rs', lines 175:0-175:30 -/ + Source: 'src/no_nested_borrows.rs', lines 209:0-209:30 -/ def copy_int (x : I32) : Result I32 := Result.ret x /- [no_nested_borrows::test_unreachable]: forward function - Source: 'src/no_nested_borrows.rs', lines 181:0-181:32 -/ + Source: 'src/no_nested_borrows.rs', lines 215:0-215:32 -/ def test_unreachable (b : Bool) : Result Unit := if b then Result.fail .panic else Result.ret () /- [no_nested_borrows::test_panic]: forward function - Source: 'src/no_nested_borrows.rs', lines 189:0-189:26 -/ + Source: 'src/no_nested_borrows.rs', lines 223:0-223:26 -/ def test_panic (b : Bool) : Result Unit := if b then Result.fail .panic else Result.ret () /- [no_nested_borrows::test_copy_int]: forward function - Source: 'src/no_nested_borrows.rs', lines 196:0-196:22 -/ + Source: 'src/no_nested_borrows.rs', lines 230:0-230:22 -/ def test_copy_int : Result Unit := do let y ← copy_int 0#i32 @@ -218,14 +276,14 @@ def test_copy_int : Result Unit := #assert (test_copy_int == Result.ret ()) /- [no_nested_borrows::is_cons]: forward function - Source: 'src/no_nested_borrows.rs', lines 203:0-203:38 -/ + Source: 'src/no_nested_borrows.rs', lines 237:0-237:38 -/ def is_cons (T : Type) (l : List T) : Result Bool := match l with | List.Cons t l0 => Result.ret true | List.Nil => Result.ret false /- [no_nested_borrows::test_is_cons]: forward function - Source: 'src/no_nested_borrows.rs', lines 210:0-210:21 -/ + Source: 'src/no_nested_borrows.rs', lines 244:0-244:21 -/ def test_is_cons : Result Unit := do let l := List.Nil @@ -238,14 +296,14 @@ def test_is_cons : Result Unit := #assert (test_is_cons == Result.ret ()) /- [no_nested_borrows::split_list]: forward function - Source: 'src/no_nested_borrows.rs', lines 216:0-216:48 -/ + Source: 'src/no_nested_borrows.rs', lines 250:0-250:48 -/ def split_list (T : Type) (l : List T) : Result (T × (List T)) := match l with | List.Cons hd tl => Result.ret (hd, tl) | List.Nil => Result.fail .panic /- [no_nested_borrows::test_split_list]: forward function - Source: 'src/no_nested_borrows.rs', lines 224:0-224:24 -/ + Source: 'src/no_nested_borrows.rs', lines 258:0-258:24 -/ def test_split_list : Result Unit := do let l := List.Nil @@ -259,14 +317,14 @@ def test_split_list : Result Unit := #assert (test_split_list == Result.ret ()) /- [no_nested_borrows::choose]: forward function - Source: 'src/no_nested_borrows.rs', lines 231:0-231:70 -/ + Source: 'src/no_nested_borrows.rs', lines 265:0-265:70 -/ def choose (T : Type) (b : Bool) (x : T) (y : T) : Result T := if b then Result.ret x else Result.ret y /- [no_nested_borrows::choose]: backward function 0 - Source: 'src/no_nested_borrows.rs', lines 231:0-231:70 -/ + Source: 'src/no_nested_borrows.rs', lines 265:0-265:70 -/ def choose_back (T : Type) (b : Bool) (x : T) (y : T) (ret : T) : Result (T × T) := if b @@ -274,7 +332,7 @@ def choose_back else Result.ret (x, ret) /- [no_nested_borrows::choose_test]: forward function - Source: 'src/no_nested_borrows.rs', lines 239:0-239:20 -/ + Source: 'src/no_nested_borrows.rs', lines 273:0-273:20 -/ def choose_test : Result Unit := do let z ← choose I32 true 0#i32 0#i32 @@ -294,20 +352,20 @@ def choose_test : Result Unit := #assert (choose_test == Result.ret ()) /- [no_nested_borrows::test_char]: forward function - Source: 'src/no_nested_borrows.rs', lines 251:0-251:26 -/ + Source: 'src/no_nested_borrows.rs', lines 285:0-285:26 -/ def test_char : Result Char := Result.ret 'a' mutual /- [no_nested_borrows::Tree] - Source: 'src/no_nested_borrows.rs', lines 256:0-256:16 -/ + Source: 'src/no_nested_borrows.rs', lines 290:0-290:16 -/ inductive Tree (T : Type) := | Leaf : T → Tree T | Node : T → NodeElem T → Tree T → Tree T /- [no_nested_borrows::NodeElem] - Source: 'src/no_nested_borrows.rs', lines 261:0-261:20 -/ + Source: 'src/no_nested_borrows.rs', lines 295:0-295:20 -/ inductive NodeElem (T : Type) := | Cons : Tree T → NodeElem T → NodeElem T | Nil : NodeElem T @@ -315,7 +373,7 @@ inductive NodeElem (T : Type) := end /- [no_nested_borrows::list_length]: forward function - Source: 'src/no_nested_borrows.rs', lines 296:0-296:48 -/ + Source: 'src/no_nested_borrows.rs', lines 330:0-330:48 -/ divergent def list_length (T : Type) (l : List T) : Result U32 := match l with | List.Cons t l1 => do @@ -324,7 +382,7 @@ divergent def list_length (T : Type) (l : List T) : Result U32 := | List.Nil => Result.ret 0#u32 /- [no_nested_borrows::list_nth_shared]: forward function - Source: 'src/no_nested_borrows.rs', lines 304:0-304:62 -/ + Source: 'src/no_nested_borrows.rs', lines 338:0-338:62 -/ divergent def list_nth_shared (T : Type) (l : List T) (i : U32) : Result T := match l with | List.Cons x tl => @@ -336,7 +394,7 @@ divergent def list_nth_shared (T : Type) (l : List T) (i : U32) : Result T := | List.Nil => Result.fail .panic /- [no_nested_borrows::list_nth_mut]: forward function - Source: 'src/no_nested_borrows.rs', lines 320:0-320:67 -/ + Source: 'src/no_nested_borrows.rs', lines 354:0-354:67 -/ divergent def list_nth_mut (T : Type) (l : List T) (i : U32) : Result T := match l with | List.Cons x tl => @@ -348,7 +406,7 @@ divergent def list_nth_mut (T : Type) (l : List T) (i : U32) : Result T := | List.Nil => Result.fail .panic /- [no_nested_borrows::list_nth_mut]: backward function 0 - Source: 'src/no_nested_borrows.rs', lines 320:0-320:67 -/ + Source: 'src/no_nested_borrows.rs', lines 354:0-354:67 -/ divergent def list_nth_mut_back (T : Type) (l : List T) (i : U32) (ret : T) : Result (List T) := match l with @@ -363,7 +421,7 @@ divergent def list_nth_mut_back | List.Nil => Result.fail .panic /- [no_nested_borrows::list_rev_aux]: forward function - Source: 'src/no_nested_borrows.rs', lines 336:0-336:63 -/ + Source: 'src/no_nested_borrows.rs', lines 370:0-370:63 -/ divergent def list_rev_aux (T : Type) (li : List T) (lo : List T) : Result (List T) := match li with @@ -372,13 +430,13 @@ divergent def list_rev_aux /- [no_nested_borrows::list_rev]: merged forward/backward function (there is a single backward function, and the forward function returns ()) - Source: 'src/no_nested_borrows.rs', lines 350:0-350:42 -/ + Source: 'src/no_nested_borrows.rs', lines 384:0-384:42 -/ def list_rev (T : Type) (l : List T) : Result (List T) := let li := core.mem.replace (List T) l List.Nil list_rev_aux T li List.Nil /- [no_nested_borrows::test_list_functions]: forward function - Source: 'src/no_nested_borrows.rs', lines 355:0-355:28 -/ + Source: 'src/no_nested_borrows.rs', lines 389:0-389:28 -/ def test_list_functions : Result Unit := do let l := List.Nil @@ -425,97 +483,97 @@ def test_list_functions : Result Unit := #assert (test_list_functions == Result.ret ()) /- [no_nested_borrows::id_mut_pair1]: forward function - Source: 'src/no_nested_borrows.rs', lines 371:0-371:89 -/ + Source: 'src/no_nested_borrows.rs', lines 405:0-405:89 -/ def id_mut_pair1 (T1 T2 : Type) (x : T1) (y : T2) : Result (T1 × T2) := Result.ret (x, y) /- [no_nested_borrows::id_mut_pair1]: backward function 0 - Source: 'src/no_nested_borrows.rs', lines 371:0-371:89 -/ + Source: 'src/no_nested_borrows.rs', lines 405:0-405:89 -/ def id_mut_pair1_back (T1 T2 : Type) (x : T1) (y : T2) (ret : (T1 × T2)) : Result (T1 × T2) := let (t, t0) := ret Result.ret (t, t0) /- [no_nested_borrows::id_mut_pair2]: forward function - Source: 'src/no_nested_borrows.rs', lines 375:0-375:88 -/ + Source: 'src/no_nested_borrows.rs', lines 409:0-409:88 -/ def id_mut_pair2 (T1 T2 : Type) (p : (T1 × T2)) : Result (T1 × T2) := let (t, t0) := p Result.ret (t, t0) /- [no_nested_borrows::id_mut_pair2]: backward function 0 - Source: 'src/no_nested_borrows.rs', lines 375:0-375:88 -/ + Source: 'src/no_nested_borrows.rs', lines 409:0-409:88 -/ def id_mut_pair2_back (T1 T2 : Type) (p : (T1 × T2)) (ret : (T1 × T2)) : Result (T1 × T2) := let (t, t0) := ret Result.ret (t, t0) /- [no_nested_borrows::id_mut_pair3]: forward function - Source: 'src/no_nested_borrows.rs', lines 379:0-379:93 -/ + Source: 'src/no_nested_borrows.rs', lines 413:0-413:93 -/ def id_mut_pair3 (T1 T2 : Type) (x : T1) (y : T2) : Result (T1 × T2) := Result.ret (x, y) /- [no_nested_borrows::id_mut_pair3]: backward function 0 - Source: 'src/no_nested_borrows.rs', lines 379:0-379:93 -/ + Source: 'src/no_nested_borrows.rs', lines 413:0-413:93 -/ def id_mut_pair3_back'a (T1 T2 : Type) (x : T1) (y : T2) (ret : T1) : Result T1 := Result.ret ret /- [no_nested_borrows::id_mut_pair3]: backward function 1 - Source: 'src/no_nested_borrows.rs', lines 379:0-379:93 -/ + Source: 'src/no_nested_borrows.rs', lines 413:0-413:93 -/ def id_mut_pair3_back'b (T1 T2 : Type) (x : T1) (y : T2) (ret : T2) : Result T2 := Result.ret ret /- [no_nested_borrows::id_mut_pair4]: forward function - Source: 'src/no_nested_borrows.rs', lines 383:0-383:92 -/ + Source: 'src/no_nested_borrows.rs', lines 417:0-417:92 -/ def id_mut_pair4 (T1 T2 : Type) (p : (T1 × T2)) : Result (T1 × T2) := let (t, t0) := p Result.ret (t, t0) /- [no_nested_borrows::id_mut_pair4]: backward function 0 - Source: 'src/no_nested_borrows.rs', lines 383:0-383:92 -/ + Source: 'src/no_nested_borrows.rs', lines 417:0-417:92 -/ def id_mut_pair4_back'a (T1 T2 : Type) (p : (T1 × T2)) (ret : T1) : Result T1 := Result.ret ret /- [no_nested_borrows::id_mut_pair4]: backward function 1 - Source: 'src/no_nested_borrows.rs', lines 383:0-383:92 -/ + Source: 'src/no_nested_borrows.rs', lines 417:0-417:92 -/ def id_mut_pair4_back'b (T1 T2 : Type) (p : (T1 × T2)) (ret : T2) : Result T2 := Result.ret ret /- [no_nested_borrows::StructWithTuple] - Source: 'src/no_nested_borrows.rs', lines 390:0-390:34 -/ + Source: 'src/no_nested_borrows.rs', lines 424:0-424:34 -/ structure StructWithTuple (T1 T2 : Type) where p : (T1 × T2) /- [no_nested_borrows::new_tuple1]: forward function - Source: 'src/no_nested_borrows.rs', lines 394:0-394:48 -/ + Source: 'src/no_nested_borrows.rs', lines 428:0-428:48 -/ def new_tuple1 : Result (StructWithTuple U32 U32) := Result.ret { p := (1#u32, 2#u32) } /- [no_nested_borrows::new_tuple2]: forward function - Source: 'src/no_nested_borrows.rs', lines 398:0-398:48 -/ + Source: 'src/no_nested_borrows.rs', lines 432:0-432:48 -/ def new_tuple2 : Result (StructWithTuple I16 I16) := Result.ret { p := (1#i16, 2#i16) } /- [no_nested_borrows::new_tuple3]: forward function - Source: 'src/no_nested_borrows.rs', lines 402:0-402:48 -/ + Source: 'src/no_nested_borrows.rs', lines 436:0-436:48 -/ def new_tuple3 : Result (StructWithTuple U64 I64) := Result.ret { p := (1#u64, 2#i64) } /- [no_nested_borrows::StructWithPair] - Source: 'src/no_nested_borrows.rs', lines 407:0-407:33 -/ + Source: 'src/no_nested_borrows.rs', lines 441:0-441:33 -/ structure StructWithPair (T1 T2 : Type) where p : Pair T1 T2 /- [no_nested_borrows::new_pair1]: forward function - Source: 'src/no_nested_borrows.rs', lines 411:0-411:46 -/ + Source: 'src/no_nested_borrows.rs', lines 445:0-445:46 -/ def new_pair1 : Result (StructWithPair U32 U32) := Result.ret { p := { x := 1#u32, y := 2#u32 } } /- [no_nested_borrows::test_constants]: forward function - Source: 'src/no_nested_borrows.rs', lines 419:0-419:23 -/ + Source: 'src/no_nested_borrows.rs', lines 453:0-453:23 -/ def test_constants : Result Unit := do let swt ← new_tuple1 @@ -545,7 +603,7 @@ def test_constants : Result Unit := #assert (test_constants == Result.ret ()) /- [no_nested_borrows::test_weird_borrows1]: forward function - Source: 'src/no_nested_borrows.rs', lines 428:0-428:28 -/ + Source: 'src/no_nested_borrows.rs', lines 462:0-462:28 -/ def test_weird_borrows1 : Result Unit := Result.ret () @@ -554,7 +612,7 @@ def test_weird_borrows1 : Result Unit := /- [no_nested_borrows::test_mem_replace]: merged forward/backward function (there is a single backward function, and the forward function returns ()) - Source: 'src/no_nested_borrows.rs', lines 438:0-438:37 -/ + Source: 'src/no_nested_borrows.rs', lines 472:0-472:37 -/ def test_mem_replace (px : U32) : Result U32 := let y := core.mem.replace U32 px 1#u32 if not (y = 0#u32) @@ -562,26 +620,26 @@ def test_mem_replace (px : U32) : Result U32 := else Result.ret 2#u32 /- [no_nested_borrows::test_shared_borrow_bool1]: forward function - Source: 'src/no_nested_borrows.rs', lines 445:0-445:47 -/ + Source: 'src/no_nested_borrows.rs', lines 479:0-479:47 -/ def test_shared_borrow_bool1 (b : Bool) : Result U32 := if b then Result.ret 0#u32 else Result.ret 1#u32 /- [no_nested_borrows::test_shared_borrow_bool2]: forward function - Source: 'src/no_nested_borrows.rs', lines 458:0-458:40 -/ + Source: 'src/no_nested_borrows.rs', lines 492:0-492:40 -/ def test_shared_borrow_bool2 : Result U32 := Result.ret 0#u32 /- [no_nested_borrows::test_shared_borrow_enum1]: forward function - Source: 'src/no_nested_borrows.rs', lines 473:0-473:52 -/ + Source: 'src/no_nested_borrows.rs', lines 507:0-507:52 -/ def test_shared_borrow_enum1 (l : List U32) : Result U32 := match l with | List.Cons i l0 => Result.ret 1#u32 | List.Nil => Result.ret 0#u32 /- [no_nested_borrows::test_shared_borrow_enum2]: forward function - Source: 'src/no_nested_borrows.rs', lines 485:0-485:40 -/ + Source: 'src/no_nested_borrows.rs', lines 519:0-519:40 -/ def test_shared_borrow_enum2 : Result U32 := Result.ret 0#u32 -- cgit v1.2.3