def clamp(x: Int, lo: Int, hi: Int) -> Int {
in {
lo <= hi
}
out(r) {
r >= lo and r <= hi
}
if x < lo {
return lo
}
if x > hi {
return hi
}
return x
}
Lesson 1 / clamp.vary
Prove your first function
Run the prover on a function with an in and out contract and read the summary line.
The in block says what the function needs, and the out block says what it promises. vary prove checks the promise for every input the in block allows, without running the function. The last line counts the results: one obligation here, and it is proven.
vary prove clamp.vary
Expected output
1 proven, 0 refuted, 0 unknown, 0 bound-reached, 0 unsupported