I would like to use Leon to verify a spec without knowing the concrete implementations in advance. For example, suppose I have a sort function, as well as the definition of what a sorted list looks like:
def sort (list: List[BigInt]): List[BigInt] = {
...
} ensuring {
res => res.content == list.content && isSorted(res)
}
def isSorted (list: List[BigInt]): Boolean = {
list match {
case Nil() => true
case Cons(_, Nil()) => true
case Cons(x1, Cons(x2, xs)) => x1 <= x2 && isSorted(list.tail)
}
}
Ideally, I should be able to prove lemmas such as sort(sort(list)) == sort(list)
based on the post-condition of sort
alone. Otherwise, I cannot claim that a Leon proof that works for insertion sort also works for quick sort (and in practice it seldom does). Is it possible for Leon to reason based on the pre- and post-conditions without looking into the implementation?
Thank you!