Approximated Cosine in Why3
This is a Why3 version of the Approximated Cosine example
Auteurs: Claude Marché
Catégories: Floating-Point Computations / Non-linear Arithmetic
Voir aussi: Approximated Cosine in C annotated in ACSL
see also the index (by topic, by tool, by reference, by year)
(* Approximated cosine Claude Marché (Inria) *) module M use real.RealInfix use real.Abs use real.Trigonometry use floating_point.Rounding use floating_point.Single val single_of_real_exact (x: real) : single ensures { value result = x } val add (x y: single) : single requires { no_overflow NearestTiesToEven ((value x) +. (value y)) } ensures { value result = round NearestTiesToEven ((value x) +. (value y))} val sub (x y: single) : single requires { no_overflow NearestTiesToEven ((value x) -. (value y)) } ensures { value result = round NearestTiesToEven ((value x) -. (value y))} val mul (x y: single) : single requires { no_overflow NearestTiesToEven ((value x) *. (value y)) } ensures { value result = round NearestTiesToEven ((value x) *. (value y))} let my_cosine (x:single) : single requires { abs (value x) <=. 0x1p-5 } ensures { abs (value result -. cos (value x)) <=. 0x1p-23 } = assert { abs (1.0 -. (value x) *. (value x) *. 0.5 -. cos (value x)) <=. 0x1p-24 }; sub (single_of_real_exact 1.0) (mul (mul x x) (single_of_real_exact 0.5)) end
download ZIP archive
Why3 Proof Results for Project "my_cosine"
Theory "my_cosine.M": fully verified
Obligations | Alt-Ergo 2.1.0 | Coq 8.11.2 | Gappa 1.3.0 | MetiTarski 2.4 | |
VC for my_cosine | --- | --- | --- | --- | |
split_goal_right | |||||
assertion | --- | 1.01 | --- | 0.14 | |
precondition | 0.01 | --- | --- | --- | |
precondition | 0.05 | --- | --- | --- | |
precondition | --- | --- | 0.00 | --- | |
postcondition | --- | --- | 0.01 | --- |