Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Why3
why3
Commits
a6391c21
Commit
a6391c21
authored
Dec 20, 2010
by
MARCHE Claude
Browse files
my cosine in logic, proved
parent
2579fe40
Changes
2
Hide whitespace changes
Inline
Side-by-side
examples/my_cosine.why
View file @
a6391c21
...
...
@@ -11,11 +11,33 @@ use import floating_point.Single
lemma MethodError: forall x:real. abs x <= 0x1p-5 ->
abs (1.0 - x * x * 0.5 - cos x) <= 0x1p-24
abs (1.0 - 0.5 * (x * x) - cos x) <= 0x1p-24
(* this one is proved in Coq + interval tactics *)
(* computation in single precision *)
lemma TotalErrorFullyExpanded:
forall x:single. abs (value x) <= 0x1p-5 ->
(* total error as hypothesis, for Gappa *)
abs (1.0 - 0.5 * (value x * value x) - cos (value x)) <= 0x1p-24 ->
forall x2 x2o2 cos_x: real.
x2 = round NearestTiesToEven (value x * value x) ->
x2o2 = round NearestTiesToEven (0.5 * x2) ->
cos_x = round NearestTiesToEven (1.0 - x2o2) ->
abs (cos_x - cos (value x)) <= 0x1p-23
(* fully expanded version, proved by gappa *)
lemma TotalErrorExpanded:
forall x:single. abs (value x) <= 0x1p-5 ->
let x2 = round NearestTiesToEven (value x * value x) in
let x2o2 = round NearestTiesToEven (0.5 * x2) in
let cos_x = round NearestTiesToEven (1.0 - x2o2) in
abs (cos_x - cos (value x)) <= 0x1p-23
(* same as above but with let, proved by SMT solvers *)
(* the same as above, under the form of a logic function *)
logic round_single (m:mode) (x:real) : single
axiom RoundSingle: forall m:mode, x:real.
...
...
@@ -28,7 +50,8 @@ logic cos_single (x:single) : single =
lemma TotalError: forall x:single. abs (value x) <= 0x1p-5 ->
let cos_x = cos_single x in
abs (value cos_x - cos (value x)) <= 0x1p-24
abs (value cos_x - cos (value x)) <= 0x1p-23
(* proved by SMT solvers from TotalErrorExpanded *)
end
...
...
examples/programs/my_cosine/project.db
View file @
a6391c21
No preview for this file type
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment