Files
why3/examples/coma/insertion.coma
2024-08-08 11:09:46 +02:00

16 lines
402 B
Plaintext

use int.Int
use list.List
use list.SortedInt
use list.Permut
use coma.Std
use coma.List
let rec insert (x: int) (l: list int) {sorted l}
(return (r: list int) {sorted r && permut r (Cons x l)})
= unList <int> {l}
(fun (h: int) (t: list int) ->
if {x < h} (-> return {Cons x l}) .
insert {x} {t} . fun (r: list int) ->
return {Cons h r})
(return {Cons x Nil})