5 This double loop program is actually O(n).
6 We show it by introducing a variable t which counts the number of times
7 the body of the inner loop is executed.
15 ensures { 0 <= result }
17 let hull (a: array int) (b: array int) =
19 let t = ref 0 in (* WCET *)
21 invariant { 0 <= !j <= i <= n /\ i = !j + !t }
22 while !j > 0 && b[!j-1] > a[i] do
23 invariant { 0 <= !j <= i /\ i = !j + !t } variant { !j }
30 assert { 0 <= !t <= n }