File: threshold.mlw

package info (click to toggle)
why3 1.8.2-3
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 45,028 kB
  • sloc: xml: 185,443; ml: 111,224; ansic: 3,998; sh: 2,578; makefile: 2,568; java: 865; python: 720; javascript: 290; lisp: 205; pascal: 173
file content (33 lines) | stat: -rw-r--r-- 572 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33

module WithInt32

use int.Int
use mach.int.Int32


let f (n min max:int32) : int32
   ensures { min <= result <= max }
=
  let _x = min + max in
  if n < min then min else if n > max then max else n

end


(** same version with (signed) bit-vectors *)

module WithBV32

use int.Int
use bv.BV32
use mach.bv.BVCheck32


let f (n min max:BV32.t) : BV32.t
   ensures { ule min result /\ ule result max }
   (* ensures { BV32.t'int min <= BV32.t'int result  <= BV32.t'int max } *)
=
  let _x = u_add min max in
  if u_lt n min then min else if u_gt n max then max else n

end