summaryrefslogtreecommitdiff
path: root/contrib/dp/test_gappa.v
blob: eb65a59d68bd2831ea9e7ebd14ed04e7b2dce637 (plain)
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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
Require Export Gappa_tactic.
Require Export Reals.

Open Scope Z_scope.
Open Scope R_scope.

Lemma test_base10 : 
  forall x y:R,
  0 <= x <= 4 -> 
  0 <= x * (24 * powerRZ 10 (-1)) <= 10.
Proof.
  gappa.
Qed.

(*
@rnd = float< ieee_32, zr >;
a = rnd(a_); b = rnd(b_);
{ a in [3.2,3.3] /\ b in [1.4,1.9] ->
  rnd(a - b) - (a - b) in [0,0] }
*)

Definition rnd := gappa_rounding (rounding_float roundZR 43 (120)).

Lemma test_float3 :
  forall a_ b_ a b : R,
  a = rnd a_ ->
  b = rnd b_ ->
  52 / 16 <= a <= 53 / 16 ->
  22 / 16 <= b <= 30 / 16 ->
  0 <= rnd (a - b) - (a - b) <= 0.
Proof.
  unfold rnd.
  gappa.
Qed.

Lemma test_float2 :
  forall x y:R,
  0 <= x <= 1 ->
  0 <= y <= 1 ->
  0 <= gappa_rounding (rounding_float roundNE 53 (1074)) (x+y) <= 2. 
Proof.
  gappa.
Qed.

Lemma test_float1 :
  forall x y:R,
  0 <= gappa_rounding (rounding_fixed roundDN (0)) x -
           gappa_rounding (rounding_fixed roundDN (0)) y <= 0 ->
  Rabs (x - y) <= 1.
Proof.
  gappa.
Qed.

Lemma test1 : 
  forall x y:R,
  0 <= x <= 1 -> 
  0 <= -y <= 1 ->  
  0 <= x  * (-y) <= 1.
Proof.
  gappa.
Qed.

Lemma test2 : 
  forall x y:R,
  3/4 <= x <= 3 -> 
  0 <= sqrt x <= 1775 * (powerRZ 2 (-10)).
Proof.
  gappa.
Qed.

Lemma test3 : 
  forall x y z:R,
  0 <= x - y <= 3 -> 
  -2 <= y - z <= 4 ->
  -2 <= x - z <= 7.
Proof.
  gappa.
Qed.

Lemma test4 : 
  forall x1 x2 y1 y2 : R,
  1 <= Rabs y1 <= 1000 ->
  1 <= Rabs y2 <= 1000 ->
  - powerRZ 2 (-53) <= (x1 - y1) / y1 <= powerRZ 2 (-53) ->
  - powerRZ 2 (-53) <= (x2 - y2) / y2 <= powerRZ 2 (-53) ->
  - powerRZ 2 (-51) <= (x1 * x2 - y1 * y2) / (y1 * y2) <= powerRZ 2 (-51).
Proof.
  gappa.
Qed.