2 (* Various programs computing the factorial. *)
9 let rec fact_rec (x:int) : int
12 ensures { result = fact x }
14 if x = 0 then 1 else x * fact_rec (x-1)
16 let test0 () = fact_rec 0
17 let test1 () = fact_rec 1
18 let test7 () = fact_rec 7
19 let test42 () = fact_rec 42
29 let fact_imp (x:int) : int
31 ensures { result = fact x }
36 invariant { 0 <= !y <= x }
37 invariant { !r = fact !y }
44 let test0 () = fact_imp 0
45 let test1 () = fact_imp 1
46 let test7 () = fact_imp 7
47 let test42 () = fact_imp 42