2 (* Sorting a list of integers using insertion sort *)
7 val predicate le elt elt
9 clone relations.TotalPreOrder with
10 type t = elt, predicate rel = le, axiom .
11 clone export list.Sorted with
12 type t = elt, predicate le = le, goal Transitive.Trans
17 let rec insert (x: elt) (l: list elt) : list elt
19 ensures { sorted result }
20 ensures { permut (Cons x l) result }
24 | Cons y r -> if le x y then Cons x l else Cons y (insert x r)
27 let rec insertion_sort (l: list elt) : list elt
28 ensures { sorted result }
29 ensures { permut l result }
33 | Cons x r -> insert x (insertion_sort r)