From feb60683216a6d9193d6353605560c6c80a1ab41 Mon Sep 17 00:00:00 2001 From: Son Ho Date: Tue, 7 Mar 2023 08:41:57 +0100 Subject: Make minor modifications and regenerate the Lean files --- tests/lean/misc/external/External/Funs.lean | 80 +++++++++++++-------------- tests/lean/misc/external/External/Opaque.lean | 10 ++-- tests/lean/misc/external/External/Types.lean | 2 +- 3 files changed, 46 insertions(+), 46 deletions(-) (limited to 'tests/lean/misc/external/External') diff --git a/tests/lean/misc/external/External/Funs.lean b/tests/lean/misc/external/External/Funs.lean index bb1e296d..4e1f36a1 100644 --- a/tests/lean/misc/external/External/Funs.lean +++ b/tests/lean/misc/external/External/Funs.lean @@ -8,86 +8,86 @@ section variable (opaque_defs: OpaqueDefs) /- [external::swap] -/ def swap_fwd - (T : Type) (x : T) (y : T) (st : state) : result (state × Unit) := + (T : Type) (x : T) (y : T) (st : State) : Result (State × Unit) := do - let (st0, _) <- opaque_defs.core_mem_swap_fwd T x y st - let (st1, _) <- opaque_defs.core_mem_swap_back0 T x y st st0 - let (st2, _) <- opaque_defs.core_mem_swap_back1 T x y st st1 - result.ret (st2, ()) + let (st0, _) ← opaque_defs.core_mem_swap_fwd T x y st + let (st1, _) ← opaque_defs.core_mem_swap_back0 T x y st st0 + let (st2, _) ← opaque_defs.core_mem_swap_back1 T x y st st1 + Result.ret (st2, ()) /- [external::swap] -/ def swap_back - (T : Type) (x : T) (y : T) (st : state) (st0 : state) : - result (state × (T × T)) + (T : Type) (x : T) (y : T) (st : State) (st0 : State) : + Result (State × (T × T)) := do - let (st1, _) <- opaque_defs.core_mem_swap_fwd T x y st - let (st2, x0) <- opaque_defs.core_mem_swap_back0 T x y st st1 - let (_, y0) <- opaque_defs.core_mem_swap_back1 T x y st st2 - result.ret (st0, (x0, y0)) + let (st1, _) ← opaque_defs.core_mem_swap_fwd T x y st + let (st2, x0) ← opaque_defs.core_mem_swap_back0 T x y st st1 + let (_, y0) ← opaque_defs.core_mem_swap_back1 T x y st st2 + Result.ret (st0, (x0, y0)) /- [external::test_new_non_zero_u32] -/ def test_new_non_zero_u32_fwd - (x : UInt32) (st : state) : - result (state × core_num_nonzero_non_zero_u32_t) + (x : UInt32) (st : State) : + Result (State × core_num_nonzero_non_zero_u32_t) := do - let (st0, opt) <- opaque_defs.core_num_nonzero_non_zero_u32_new_fwd x st + let (st0, opt) ← opaque_defs.core_num_nonzero_non_zero_u32_new_fwd x st opaque_defs.core_option_option_unwrap_fwd core_num_nonzero_non_zero_u32_t opt st0 /- [external::test_vec] -/ -def test_vec_fwd : result Unit := +def test_vec_fwd : Result Unit := do let v := vec_new UInt32 - let _ <- vec_push_back UInt32 v (UInt32.ofNatCore 0 (by intlit)) - result.ret () + let _ ← vec_push_back UInt32 v (UInt32.ofNatCore 0 (by intlit)) + Result.ret () /- Unit test for [external::test_vec] -/ -#assert (test_vec_fwd = .ret ()) +#assert (test_vec_fwd == .ret ()) /- [external::custom_swap] -/ def custom_swap_fwd - (T : Type) (x : T) (y : T) (st : state) : result (state × T) := + (T : Type) (x : T) (y : T) (st : State) : Result (State × T) := do - let (st0, _) <- opaque_defs.core_mem_swap_fwd T x y st - let (st1, x0) <- opaque_defs.core_mem_swap_back0 T x y st st0 - let (st2, _) <- opaque_defs.core_mem_swap_back1 T x y st st1 - result.ret (st2, x0) + let (st0, _) ← opaque_defs.core_mem_swap_fwd T x y st + let (st1, x0) ← opaque_defs.core_mem_swap_back0 T x y st st0 + let (st2, _) ← opaque_defs.core_mem_swap_back1 T x y st st1 + Result.ret (st2, x0) /- [external::custom_swap] -/ def custom_swap_back - (T : Type) (x : T) (y : T) (st : state) (ret0 : T) (st0 : state) : - result (state × (T × T)) + (T : Type) (x : T) (y : T) (st : State) (ret0 : T) (st0 : State) : + Result (State × (T × T)) := do - let (st1, _) <- opaque_defs.core_mem_swap_fwd T x y st - let (st2, _) <- opaque_defs.core_mem_swap_back0 T x y st st1 - let (_, y0) <- opaque_defs.core_mem_swap_back1 T x y st st2 - result.ret (st0, (ret0, y0)) + let (st1, _) ← opaque_defs.core_mem_swap_fwd T x y st + let (st2, _) ← opaque_defs.core_mem_swap_back0 T x y st st1 + let (_, y0) ← opaque_defs.core_mem_swap_back1 T x y st st2 + Result.ret (st0, (ret0, y0)) /- [external::test_custom_swap] -/ def test_custom_swap_fwd - (x : UInt32) (y : UInt32) (st : state) : result (state × Unit) := + (x : UInt32) (y : UInt32) (st : State) : Result (State × Unit) := do - let (st0, _) <- custom_swap_fwd UInt32 x y st - result.ret (st0, ()) + let (st0, _) ← custom_swap_fwd UInt32 x y st + Result.ret (st0, ()) /- [external::test_custom_swap] -/ def test_custom_swap_back - (x : UInt32) (y : UInt32) (st : state) (st0 : state) : - result (state × (UInt32 × UInt32)) + (x : UInt32) (y : UInt32) (st : State) (st0 : State) : + Result (State × (UInt32 × UInt32)) := custom_swap_back UInt32 x y st (UInt32.ofNatCore 1 (by intlit)) st0 /- [external::test_swap_non_zero] -/ def test_swap_non_zero_fwd - (x : UInt32) (st : state) : result (state × UInt32) := + (x : UInt32) (st : State) : Result (State × UInt32) := do - let (st0, _) <- swap_fwd UInt32 x (UInt32.ofNatCore 0 (by intlit)) st - let (st1, (x0, _)) <- + let (st0, _) ← swap_fwd UInt32 x (UInt32.ofNatCore 0 (by intlit)) st + let (st1, (x0, _)) ← swap_back UInt32 x (UInt32.ofNatCore 0 (by intlit)) st st0 - if x0 = (UInt32.ofNatCore 0 (by intlit)) - then result.fail error.panic - else result.ret (st1, x0) + if h: x0 = (UInt32.ofNatCore 0 (by intlit)) + then Result.fail Error.panic + else Result.ret (st1, x0) diff --git a/tests/lean/misc/external/External/Opaque.lean b/tests/lean/misc/external/External/Opaque.lean index 40ccc313..d3582de3 100644 --- a/tests/lean/misc/external/External/Opaque.lean +++ b/tests/lean/misc/external/External/Opaque.lean @@ -6,23 +6,23 @@ import External.Types structure OpaqueDefs where /- [core::mem::swap] -/ - core_mem_swap_fwd (T : Type) : T -> T -> state -> result (state × Unit) + core_mem_swap_fwd (T : Type) : T -> T -> State -> Result (State × Unit) /- [core::mem::swap] -/ core_mem_swap_back0 - (T : Type) : T -> T -> state -> state -> result (state × T) + (T : Type) : T -> T -> State -> State -> Result (State × T) /- [core::mem::swap] -/ core_mem_swap_back1 - (T : Type) : T -> T -> state -> state -> result (state × T) + (T : Type) : T -> T -> State -> State -> Result (State × T) /- [core::num::nonzero::NonZeroU32::{14}::new] -/ core_num_nonzero_non_zero_u32_new_fwd : - UInt32 -> state -> result (state × (Option + UInt32 -> State -> Result (State × (Option core_num_nonzero_non_zero_u32_t)) /- [core::option::Option::{0}::unwrap] -/ core_option_option_unwrap_fwd - (T : Type) : Option T -> state -> result (state × T) + (T : Type) : Option T -> State -> Result (State × T) diff --git a/tests/lean/misc/external/External/Types.lean b/tests/lean/misc/external/External/Types.lean index b6fa292b..386832f4 100644 --- a/tests/lean/misc/external/External/Types.lean +++ b/tests/lean/misc/external/External/Types.lean @@ -4,5 +4,5 @@ import Base.Primitives /- [core::num::nonzero::NonZeroU32] -/ axiom core_num_nonzero_non_zero_u32_t : Type -/- The state type used in the state-error monad -/ axiom state : Type +/- The state type used in the state-error monad -/ axiom State : Type -- cgit v1.2.3