mirror of
https://github.com/kmc7468/cs220.git
synced 2025-12-14 22:18:46 +00:00
assignment 1~5: fixes
- assignment05/pascal.mlw: lowered the difficulty (one more invariant given) - assignment02, 03: minor fixes & divide into sub-problems
This commit is contained in:
22
assets/why3/assignment05/binary_search.mlw
Normal file
22
assets/why3/assignment05/binary_search.mlw
Normal file
@@ -0,0 +1,22 @@
|
||||
(* Binary search
|
||||
|
||||
A classical example. Searches a sorted array for a given value v.
|
||||
Consult <https://gitlab.inria.fr/why3/why3/-/blob/master/examples/binary_search.mlw>.
|
||||
*)
|
||||
|
||||
module BinarySearch
|
||||
|
||||
use int.Int
|
||||
use int.ComputerDivision
|
||||
use ref.Ref
|
||||
use array.Array
|
||||
|
||||
let binary_search (a : array int) (v : int) : int
|
||||
requires { forall i1 i2 : int. 0 <= i1 < i2 < length a -> a[i1] <= a[i2] }
|
||||
ensures { 0 <= result <= length a }
|
||||
ensures { forall i: int. 0 <= i < result -> a[i] < v }
|
||||
ensures { forall i: int. result <= i < length a -> v <= a[i] }
|
||||
=
|
||||
(* IMPORTANT: DON'T MODIFY THE ABOVE LINES *)
|
||||
0 (* TODO *)
|
||||
end
|
||||
Reference in New Issue
Block a user