From efba91b5cc65d83c3f4d8a0d282eeda520abe82a Mon Sep 17 00:00:00 2001 From: Son Ho Date: Thu, 5 Jan 2023 23:11:26 +0100 Subject: Add more loop examples and fix issues --- tests/fstar/misc/Loops.Clauses.fst | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'tests/fstar/misc/Loops.Clauses.fst') diff --git a/tests/fstar/misc/Loops.Clauses.fst b/tests/fstar/misc/Loops.Clauses.fst index 9cf5db1f..e673d4ff 100644 --- a/tests/fstar/misc/Loops.Clauses.fst +++ b/tests/fstar/misc/Loops.Clauses.fst @@ -19,6 +19,14 @@ unfold let sum_with_shared_borrows_decreases (max : u32) (i : u32) (s : u32) : nat = if max >= i then max - i else 0 +(** [loops::clear]: decreases clause *) +unfold let clear_decreases (v : vec u32) (i : usize) : nat = + if i <= List.Tot.length v then List.Tot.length v - i else 0 + +(** [loops::list_mem]: decreases clause *) +unfold let list_mem_decreases (i : u32) (ls : list_t u32) : list_t u32 = + ls + (** [loops::list_nth_mut_loop]: decreases clause *) unfold let list_nth_mut_loop_decreases (t : Type0) (ls : list_t t) (i : u32) : nat = @@ -29,6 +37,18 @@ unfold let list_nth_shared_loop_decreases (t : Type0) (ls : list_t t) (i : u32) : list_t t = ls +(** [loops::list_nth_mut_loop_with_id]: decreases clause *) +unfold +let list_nth_mut_loop_with_id_decreases (t : Type0) (i : u32) (ls : list_t t) : + list_t t = + ls + +(** [loops::list_nth_shared_loop_with_id]: decreases clause *) +unfold +let list_nth_shared_loop_with_id_decreases (t : Type0) (l : list_t t) + (i : u32) (ls : list_t t) : list_t t = + ls + (** [loops::list_nth_mut_loop_pair]: decreases clause *) unfold let list_nth_mut_loop_pair_decreases (t : Type0) (l : list_t t) (l0 : list_t t) -- cgit v1.2.3