summaryrefslogtreecommitdiff
path: root/tests/lean/misc
diff options
context:
space:
mode:
Diffstat (limited to 'tests/lean/misc')
-rw-r--r--tests/lean/misc/loops/Loops/Funs.lean52
-rw-r--r--tests/lean/misc/no_nested_borrows/NoNestedBorrows.lean32
-rw-r--r--tests/lean/misc/paper/Paper.lean11
3 files changed, 33 insertions, 62 deletions
diff --git a/tests/lean/misc/loops/Loops/Funs.lean b/tests/lean/misc/loops/Loops/Funs.lean
index 8b7e8a1f..55f0c87d 100644
--- a/tests/lean/misc/loops/Loops/Funs.lean
+++ b/tests/lean/misc/loops/Loops/Funs.lean
@@ -80,9 +80,10 @@ def clear_fwd_back (v : vec UInt32) : result (vec UInt32) :=
def list_mem_loop_fwd (x : UInt32) (ls : list_t UInt32) : (result Bool) :=
match ls with
| list_t.ListCons y tl =>
- if y = x then result.ret true else list_mem_loop_fwd x tl
+ if y = x
+ then result.ret true
+ else list_mem_loop_fwd x tl
| list_t.ListNil => result.ret false
-
termination_by list_mem_loop_fwd x ls => list_mem_loop_terminates x ls
decreasing_by list_mem_loop_decreases x ls
@@ -102,7 +103,6 @@ def list_nth_mut_loop_loop_fwd
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_mut_loop_loop_fwd T tl i0
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_mut_loop_loop_fwd ls i =>
list_nth_mut_loop_loop_terminates T ls i
decreasing_by list_nth_mut_loop_loop_decreases ls i
@@ -124,7 +124,6 @@ def list_nth_mut_loop_loop_back
let tl0 <- list_nth_mut_loop_loop_back T tl i0 ret0
result.ret (list_t.ListCons x tl0)
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_mut_loop_loop_back ls i ret0 =>
list_nth_mut_loop_loop_terminates T ls i
decreasing_by list_nth_mut_loop_loop_decreases ls i
@@ -146,7 +145,6 @@ def list_nth_shared_loop_loop_fwd
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_shared_loop_loop_fwd T tl i0
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_shared_loop_loop_fwd ls i =>
list_nth_shared_loop_loop_terminates T ls i
decreasing_by list_nth_shared_loop_loop_decreases ls i
@@ -160,9 +158,10 @@ def list_nth_shared_loop_fwd
def get_elem_mut_loop_fwd (x : USize) (ls : list_t USize) : (result USize) :=
match ls with
| list_t.ListCons y tl =>
- if y = x then result.ret y else get_elem_mut_loop_fwd x tl
+ if y = x
+ then result.ret y
+ else get_elem_mut_loop_fwd x tl
| list_t.ListNil => result.fail error.panic
-
termination_by get_elem_mut_loop_fwd x ls => get_elem_mut_loop_terminates x ls
decreasing_by get_elem_mut_loop_decreases x ls
@@ -185,7 +184,6 @@ def get_elem_mut_loop_back
let tl0 <- get_elem_mut_loop_back x tl ret0
result.ret (list_t.ListCons y tl0)
| list_t.ListNil => result.fail error.panic
-
termination_by get_elem_mut_loop_back x ls ret0 =>
get_elem_mut_loop_terminates x ls
decreasing_by get_elem_mut_loop_decreases x ls
@@ -206,9 +204,10 @@ def get_elem_shared_loop_fwd
(x : USize) (ls : list_t USize) : (result USize) :=
match ls with
| list_t.ListCons y tl =>
- if y = x then result.ret y else get_elem_shared_loop_fwd x tl
+ if y = x
+ then result.ret y
+ else get_elem_shared_loop_fwd x tl
| list_t.ListNil => result.fail error.panic
-
termination_by get_elem_shared_loop_fwd x ls =>
get_elem_shared_loop_terminates x ls
decreasing_by get_elem_shared_loop_decreases x ls
@@ -245,7 +244,6 @@ def list_nth_mut_loop_with_id_loop_fwd
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_mut_loop_with_id_loop_fwd T i0 tl
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_mut_loop_with_id_loop_fwd i ls =>
list_nth_mut_loop_with_id_loop_terminates T i ls
decreasing_by list_nth_mut_loop_with_id_loop_decreases i ls
@@ -270,7 +268,6 @@ def list_nth_mut_loop_with_id_loop_back
let tl0 <- list_nth_mut_loop_with_id_loop_back T i0 tl ret0
result.ret (list_t.ListCons x tl0)
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_mut_loop_with_id_loop_back i ls ret0 =>
list_nth_mut_loop_with_id_loop_terminates T i ls
decreasing_by list_nth_mut_loop_with_id_loop_decreases i ls
@@ -295,7 +292,6 @@ def list_nth_shared_loop_with_id_loop_fwd
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_shared_loop_with_id_loop_fwd T i0 tl
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_shared_loop_with_id_loop_fwd i ls =>
list_nth_shared_loop_with_id_loop_terminates T i ls
decreasing_by list_nth_shared_loop_with_id_loop_decreases i ls
@@ -323,9 +319,7 @@ def list_nth_mut_loop_pair_loop_fwd
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_mut_loop_pair_loop_fwd T tl0 tl1 i0
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_mut_loop_pair_loop_fwd ls0 ls1 i =>
list_nth_mut_loop_pair_loop_terminates T ls0 ls1 i
decreasing_by list_nth_mut_loop_pair_loop_decreases ls0 ls1 i
@@ -354,9 +348,7 @@ def list_nth_mut_loop_pair_loop_back'a
let tl00 <- list_nth_mut_loop_pair_loop_back'a T tl0 tl1 i0 ret0
result.ret (list_t.ListCons x0 tl00)
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_mut_loop_pair_loop_back'a ls0 ls1 i ret0 =>
list_nth_mut_loop_pair_loop_terminates T ls0 ls1 i
decreasing_by list_nth_mut_loop_pair_loop_decreases ls0 ls1 i
@@ -385,9 +377,7 @@ def list_nth_mut_loop_pair_loop_back'b
let tl10 <- list_nth_mut_loop_pair_loop_back'b T tl0 tl1 i0 ret0
result.ret (list_t.ListCons x1 tl10)
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_mut_loop_pair_loop_back'b ls0 ls1 i ret0 =>
list_nth_mut_loop_pair_loop_terminates T ls0 ls1 i
decreasing_by list_nth_mut_loop_pair_loop_decreases ls0 ls1 i
@@ -415,9 +405,7 @@ def list_nth_shared_loop_pair_loop_fwd
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_shared_loop_pair_loop_fwd T tl0 tl1 i0
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_shared_loop_pair_loop_fwd ls0 ls1 i =>
list_nth_shared_loop_pair_loop_terminates T ls0 ls1 i
decreasing_by list_nth_shared_loop_pair_loop_decreases ls0 ls1 i
@@ -445,9 +433,7 @@ def list_nth_mut_loop_pair_merge_loop_fwd
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_mut_loop_pair_merge_loop_fwd T tl0 tl1 i0
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_mut_loop_pair_merge_loop_fwd ls0 ls1 i =>
list_nth_mut_loop_pair_merge_loop_terminates T ls0 ls1 i
decreasing_by list_nth_mut_loop_pair_merge_loop_decreases ls0 ls1 i
@@ -479,9 +465,7 @@ def list_nth_mut_loop_pair_merge_loop_back
list_nth_mut_loop_pair_merge_loop_back T tl0 tl1 i0 ret0
result.ret (list_t.ListCons x0 tl00, list_t.ListCons x1 tl10)
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_mut_loop_pair_merge_loop_back ls0 ls1 i ret0 =>
list_nth_mut_loop_pair_merge_loop_terminates T ls0 ls1 i
decreasing_by list_nth_mut_loop_pair_merge_loop_decreases ls0 ls1 i
@@ -509,9 +493,7 @@ def list_nth_shared_loop_pair_merge_loop_fwd
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_shared_loop_pair_merge_loop_fwd T tl0 tl1 i0
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_shared_loop_pair_merge_loop_fwd ls0 ls1 i =>
list_nth_shared_loop_pair_merge_loop_terminates T ls0 ls1 i
decreasing_by list_nth_shared_loop_pair_merge_loop_decreases ls0 ls1 i
@@ -539,9 +521,7 @@ def list_nth_mut_shared_loop_pair_loop_fwd
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_mut_shared_loop_pair_loop_fwd T tl0 tl1 i0
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_mut_shared_loop_pair_loop_fwd ls0 ls1 i =>
list_nth_mut_shared_loop_pair_loop_terminates T ls0 ls1 i
decreasing_by list_nth_mut_shared_loop_pair_loop_decreases ls0 ls1 i
@@ -570,9 +550,7 @@ def list_nth_mut_shared_loop_pair_loop_back
let tl00 <- list_nth_mut_shared_loop_pair_loop_back T tl0 tl1 i0 ret0
result.ret (list_t.ListCons x0 tl00)
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_mut_shared_loop_pair_loop_back ls0 ls1 i ret0 =>
list_nth_mut_shared_loop_pair_loop_terminates T ls0 ls1 i
decreasing_by list_nth_mut_shared_loop_pair_loop_decreases ls0 ls1 i
@@ -600,9 +578,7 @@ def list_nth_mut_shared_loop_pair_merge_loop_fwd
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_mut_shared_loop_pair_merge_loop_fwd T tl0 tl1 i0
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_mut_shared_loop_pair_merge_loop_fwd ls0 ls1 i =>
list_nth_mut_shared_loop_pair_merge_loop_terminates T ls0 ls1 i
decreasing_by list_nth_mut_shared_loop_pair_merge_loop_decreases ls0 ls1 i
@@ -632,9 +608,7 @@ def list_nth_mut_shared_loop_pair_merge_loop_back
list_nth_mut_shared_loop_pair_merge_loop_back T tl0 tl1 i0 ret0
result.ret (list_t.ListCons x0 tl00)
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_mut_shared_loop_pair_merge_loop_back ls0 ls1 i ret0 =>
list_nth_mut_shared_loop_pair_merge_loop_terminates T ls0 ls1 i
decreasing_by list_nth_mut_shared_loop_pair_merge_loop_decreases ls0 ls1 i
@@ -662,9 +636,7 @@ def list_nth_shared_mut_loop_pair_loop_fwd
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_shared_mut_loop_pair_loop_fwd T tl0 tl1 i0
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_shared_mut_loop_pair_loop_fwd ls0 ls1 i =>
list_nth_shared_mut_loop_pair_loop_terminates T ls0 ls1 i
decreasing_by list_nth_shared_mut_loop_pair_loop_decreases ls0 ls1 i
@@ -693,9 +665,7 @@ def list_nth_shared_mut_loop_pair_loop_back
let tl10 <- list_nth_shared_mut_loop_pair_loop_back T tl0 tl1 i0 ret0
result.ret (list_t.ListCons x1 tl10)
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_shared_mut_loop_pair_loop_back ls0 ls1 i ret0 =>
list_nth_shared_mut_loop_pair_loop_terminates T ls0 ls1 i
decreasing_by list_nth_shared_mut_loop_pair_loop_decreases ls0 ls1 i
@@ -723,9 +693,7 @@ def list_nth_shared_mut_loop_pair_merge_loop_fwd
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_shared_mut_loop_pair_merge_loop_fwd T tl0 tl1 i0
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_shared_mut_loop_pair_merge_loop_fwd ls0 ls1 i =>
list_nth_shared_mut_loop_pair_merge_loop_terminates T ls0 ls1 i
decreasing_by list_nth_shared_mut_loop_pair_merge_loop_decreases ls0 ls1 i
@@ -755,9 +723,7 @@ def list_nth_shared_mut_loop_pair_merge_loop_back
list_nth_shared_mut_loop_pair_merge_loop_back T tl0 tl1 i0 ret0
result.ret (list_t.ListCons x1 tl10)
| list_t.ListNil => result.fail error.panic
-
| list_t.ListNil => result.fail error.panic
-
termination_by list_nth_shared_mut_loop_pair_merge_loop_back ls0 ls1 i ret0 =>
list_nth_shared_mut_loop_pair_merge_loop_terminates T ls0 ls1 i
decreasing_by list_nth_shared_mut_loop_pair_merge_loop_decreases ls0 ls1 i
diff --git a/tests/lean/misc/no_nested_borrows/NoNestedBorrows.lean b/tests/lean/misc/no_nested_borrows/NoNestedBorrows.lean
index 53093519..608aabc1 100644
--- a/tests/lean/misc/no_nested_borrows/NoNestedBorrows.lean
+++ b/tests/lean/misc/no_nested_borrows/NoNestedBorrows.lean
@@ -69,7 +69,9 @@ structure OpaqueDefs where
/- [no_nested_borrows::get_max] -/
def get_max_fwd (x : UInt32) (y : UInt32) : result UInt32 :=
- if x >= y then result.ret x else result.ret y
+ if x >= y
+ then result.ret x
+ else result.ret y
/- [no_nested_borrows::test3] -/
def test3_fwd : result Unit :=
@@ -153,11 +155,15 @@ structure OpaqueDefs where
/- [no_nested_borrows::test_unreachable] -/
def test_unreachable_fwd (b : Bool) : result Unit :=
- if b then result.fail error.panic else result.ret ()
+ if b
+ then result.fail error.panic
+ else result.ret ()
/- [no_nested_borrows::test_panic] -/
def test_panic_fwd (b : Bool) : result Unit :=
- if b then result.fail error.panic else result.ret ()
+ if b
+ then result.fail error.panic
+ else result.ret ()
/- [no_nested_borrows::test_copy_int] -/
def test_copy_int_fwd : result Unit :=
@@ -175,7 +181,6 @@ structure OpaqueDefs where
match l with
| list_t.ListCons t l0 => result.ret true
| list_t.ListNil => result.ret false
-
/- [no_nested_borrows::test_is_cons] -/
def test_is_cons_fwd : result Unit :=
@@ -183,7 +188,9 @@ structure OpaqueDefs where
let l := list_t.ListNil
let b <-
is_cons_fwd Int32 (list_t.ListCons (Int32.ofNatCore 0 (by intlit)) l)
- if not b then result.fail error.panic else result.ret ()
+ if not b
+ then result.fail error.panic
+ else result.ret ()
/- Unit test for [no_nested_borrows::test_is_cons] -/
#assert (test_is_cons_fwd = .ret ())
@@ -193,7 +200,6 @@ structure OpaqueDefs where
match l with
| list_t.ListCons hd tl => result.ret (hd, tl)
| list_t.ListNil => result.fail error.panic
-
/- [no_nested_borrows::test_split_list] -/
def test_split_list_fwd : result Unit :=
@@ -212,12 +218,16 @@ structure OpaqueDefs where
/- [no_nested_borrows::choose] -/
def choose_fwd (T : Type) (b : Bool) (x : T) (y : T) : result T :=
- if b then result.ret x else result.ret y
+ if b
+ then result.ret x
+ else result.ret y
/- [no_nested_borrows::choose] -/
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)
+ if b
+ then result.ret (ret0, y)
+ else result.ret (x, ret0)
/- [no_nested_borrows::choose_test] -/
def choose_test_fwd : result Unit :=
@@ -265,7 +275,6 @@ structure OpaqueDefs where
let i <- list_length_fwd T l1
UInt32.checked_add (UInt32.ofNatCore 1 (by intlit)) i
| list_t.ListNil => result.ret (UInt32.ofNatCore 0 (by intlit))
-
/- [no_nested_borrows::list_nth_shared] -/
def list_nth_shared_fwd (T : Type) (l : list_t T) (i : UInt32) : result T :=
@@ -278,7 +287,6 @@ structure OpaqueDefs where
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_shared_fwd T tl i0
| list_t.ListNil => result.fail error.panic
-
/- [no_nested_borrows::list_nth_mut] -/
def list_nth_mut_fwd (T : Type) (l : list_t T) (i : UInt32) : result T :=
@@ -291,7 +299,6 @@ structure OpaqueDefs where
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_mut_fwd T tl i0
| list_t.ListNil => result.fail error.panic
-
/- [no_nested_borrows::list_nth_mut] -/
def list_nth_mut_back
@@ -306,7 +313,6 @@ structure OpaqueDefs where
let tl0 <- list_nth_mut_back T tl i0 ret0
result.ret (list_t.ListCons x tl0)
| list_t.ListNil => result.fail error.panic
-
/- [no_nested_borrows::list_rev_aux] -/
def list_rev_aux_fwd
@@ -314,7 +320,6 @@ structure OpaqueDefs where
match li with
| list_t.ListCons hd tl => list_rev_aux_fwd T tl (list_t.ListCons hd lo)
| list_t.ListNil => result.ret lo
-
/- [no_nested_borrows::list_rev] -/
def list_rev_fwd_back (T : Type) (l : list_t T) : result (list_t T) :=
@@ -542,7 +547,6 @@ structure OpaqueDefs where
match l with
| list_t.ListCons i l0 => result.ret (UInt32.ofNatCore 1 (by intlit))
| list_t.ListNil => result.ret (UInt32.ofNatCore 0 (by intlit))
-
/- [no_nested_borrows::test_shared_borrow_enum2] -/
def test_shared_borrow_enum2_fwd : result UInt32 :=
diff --git a/tests/lean/misc/paper/Paper.lean b/tests/lean/misc/paper/Paper.lean
index 2d23f394..adcd1eae 100644
--- a/tests/lean/misc/paper/Paper.lean
+++ b/tests/lean/misc/paper/Paper.lean
@@ -21,12 +21,16 @@ structure OpaqueDefs where
/- [paper::choose] -/
def choose_fwd (T : Type) (b : Bool) (x : T) (y : T) : result T :=
- if b then result.ret x else result.ret y
+ if b
+ then result.ret x
+ else result.ret y
/- [paper::choose] -/
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)
+ if b
+ then result.ret (ret0, y)
+ else result.ret (x, ret0)
/- [paper::test_choose] -/
def test_choose_fwd : result Unit :=
@@ -68,7 +72,6 @@ structure OpaqueDefs where
let i0 <- UInt32.checked_sub i (UInt32.ofNatCore 1 (by intlit))
list_nth_mut_fwd T tl i0
| list_t.ListNil => result.fail error.panic
-
/- [paper::list_nth_mut] -/
def list_nth_mut_back
@@ -83,7 +86,6 @@ structure OpaqueDefs where
let tl0 <- list_nth_mut_back T tl i0 ret0
result.ret (list_t.ListCons x tl0)
| list_t.ListNil => result.fail error.panic
-
/- [paper::sum] -/
def sum_fwd (l : list_t Int32) : result Int32 :=
@@ -92,7 +94,6 @@ structure OpaqueDefs where
let i <- sum_fwd tl
Int32.checked_add x i
| list_t.ListNil => result.ret (Int32.ofNatCore 0 (by intlit))
-
/- [paper::test_nth] -/
def test_nth_fwd : result Unit :=