Imandra_prelude.ListThis module contains many safe functions for manipulating lists.
type 'a t = 'a listval empty : 'a listval is_empty : 'a list -> boolTest whether a list is empty
val return : 'a -> 'a listSingleton list
Partial function to access the head of the list. This function will fail when applied to the empty list. NOTE it is recommended to rely on pattern matching instead
Partial function to access the tail of the list. This function will fail when applied to the empty list NOTE it is recommended to rely on pattern matching instead
List append / concatenation. append l1 l2 returns a list composed of all elements of l1, followed by all elements of l2
val append_to_nil : 'a list -> boolval length : 'a list -> Z.tCompute the length of a list. Linear time.
val len_nonnegative : 'a list -> boolval len_zero_is_empty : 'a list -> boolMap a function over a list.
map f [] = []map f [x] = [f x]map f (x :: tail) = f x :: map f tailval for_all : ( 'a -> bool ) -> 'a list -> boolfor_all f l tests whether all elements of l satisfy the predicate f
val exists : ( 'a -> bool ) -> 'a list -> boolexists f l tests whether there is an element of l that satisfies the predicate f
val fold_left : ( 'a -> 'b -> 'a ) -> 'a -> 'b list -> 'aFold-left, with an accumulator that makes induction more challenging
val fold_right : ( 'a -> 'b -> 'b ) -> base:'b -> 'a list -> 'bFold-right, without accumulator. This is generally more friendly for induction than fold_left.
filter f l keeps only the elements of l that satisfy f.
find f l returns Some x if x is the first element of l such that f x is true. Otherwise it returns None
val mem : 'a -> 'a list -> boolmem x l returns true iff x is an element of l
val mem_assoc : 'a -> ('a * 'b) list -> booltake n l returns a list composed of the first (at most) n elements of l. If length l <= n then it returns l
drop n l returns l where the first (at most) n elements have been removed. If length l <= n then it returns []
Integer range. i -- j is the list [i; i+1; i+2; …; j-1]. Returns the empty list if i >= j.
Insert x in l, keeping l sorted.
val is_sorted : leq:( 'a -> 'a -> bool ) -> 'a list -> boolCheck whether a list is sorted, using the leq small-or-equal-than predicatet