Expressions.v 15.4 KB
Newer Older
1
(**
2
  Formalization of the base expression language for the daisy framework
3
 **)
4 5 6 7 8 9
Require Import Coq.Reals.Reals Coq.micromega.Psatz Coq.QArith.QArith
               Coq.QArith.Qreals.
Require Import Daisy.Infra.RealRationalProps Daisy.Infra.RationalSimps
               Daisy.Infra.Ltacs.
Require Export Daisy.Infra.Abbrevs Daisy.Infra.RealSimps Daisy.Infra.NatSet
        Daisy.IntervalArithQ Daisy.IntervalArith Daisy.Infra.MachineType.
10

11 12 13 14 15
(**
  Expressions will use binary operators.
  Define them first
**)
Inductive binop : Type := Plus | Sub | Mult | Div.
16

17
Definition binopEq (b1:binop) (b2:binop) :=
='s avatar
= committed
18 19 20 21 22 23
  match b1, b2 with
  | Plus, Plus => true
  | Sub,  Sub  => true
  | Mult, Mult => true
  | Div,  Div  => true
  | _,_ => false
24 25
  end.

26 27 28 29
(**
  Next define an evaluation function for binary operators on reals.
  Errors are added on the expression evaluation level later.
 **)
30
Definition evalBinop (o:binop) (v1:R) (v2:R) :=
31 32 33 34 35 36
  match o with
  | Plus => Rplus v1 v2
  | Sub => Rminus v1 v2
  | Mult => Rmult v1 v2
  | Div => Rdiv v1 v2
  end.
37

38 39
Lemma binopEq_refl b:
  binopEq b b = true.
40 41 42 43
Proof.
  case b; auto.
Qed.

44 45
Lemma binopEq_compat_eq b1 b2:
  binopEq b1 b2 = true <-> b1 = b2.
46
Proof.
47 48 49 50 51 52 53 54 55 56
  split; case b1; case b2; intros; simpl in *; congruence.
Qed.

Lemma binopEq_compat_eq_false b1 b2:
  binopEq b1 b2 = false <-> ~ (b1 = b2).
Proof.
  split; intros neq.
  - hnf; intros; subst. rewrite binopEq_refl in neq.
    congruence.
  - destruct b1; destruct b2; cbv; congruence.
57 58
Qed.

59 60 61 62 63 64
(**
   Expressions will use unary operators.
   Define them first
 **)
Inductive unop: Type := Neg | Inv.

65
Definition unopEq (o1:unop) (o2:unop) :=
='s avatar
= committed
66 67 68 69
  match o1, o2 with
  | Neg, Neg => true
  | Inv, Inv => true
  | _ , _ => false
70 71
  end.

72 73
Lemma unopEq_refl b:
  unopEq b b = true.
74 75 76 77
Proof.
  case b; auto.
Qed.

78 79
Lemma unopEq_compat_eq b1 b2:
  unopEq b1 b2 = true <-> b1 = b2.
80
Proof.
81
  split; case b1; case b2; intros; simpl in *; congruence.
82 83
Qed.

84 85
(**
   Define evaluation for unary operators on reals.
86
   Errors are added in the expression evaluation level later.
87
 **)
88
Definition evalUnop (o:unop) (v:R):=
89 90 91 92 93
  match o with
  |Neg => (- v)%R
  |Inv => (/ v)%R
  end .

94 95
Definition evalFma (v1:R) (v2:R) (v3:R):=
  Rplus v1 (Rmult v2 v3).
Nikita Zyuzin's avatar
Nikita Zyuzin committed
96

97
(**
98 99
  Define expressions parametric over some value type V.
  Will ease reasoning about different instantiations later.
100
**)
101 102
Inductive exp (V:Type): Type :=
  Var: nat -> exp V
103
| Const: mType -> V -> exp V
104
| Unop: unop -> exp V -> exp V
105
| Binop: binop -> exp V -> exp V -> exp V
106
| Fma: exp V -> exp V -> exp V -> exp V
107
| Downcast: mType -> exp V -> exp V.
108

109 110 111 112
(**
  Boolean equality function on expressions.
  Used in certificates to define the analysis result as function
**)
113
Fixpoint expEq (e1:exp Q) (e2:exp Q) :=
='s avatar
= committed
114
  match e1, e2 with
115
  | Var _ v1, Var _ v2 => (v1 =? v2)
116 117 118 119 120 121
  | Const m1 n1, Const m2 n2 =>
    (mTypeEq m1 m2) && (Qeq_bool n1 n2)
  | Unop o1 e11, Unop o2 e22 =>
    (unopEq o1 o2) && (expEq e11 e22)
  | Binop o1 e11 e12, Binop o2 e21 e22 =>
    (binopEq o1 o2) && (expEq e11 e21) && (expEq e12 e22)
122 123
  | Fma e11 e12 e13, Fma e21 e22 e23 =>
    (expEq e11 e21) && (expEq e12 e22) && (expEq e13 e23)
124 125
  | Downcast m1 f1, Downcast m2 f2 =>
    (mTypeEq m1 m2) && (expEq f1 f2)
='s avatar
= committed
126
  | _, _ => false
127 128
  end.

129 130
Lemma expEq_refl e:
  expEq e e = true.
131
Proof.
132
  induction e; try (apply andb_true_iff; split); simpl in *; auto .
133
  - symmetry; apply beq_nat_refl.
134
  - apply mTypeEq_refl.
135 136 137
  - apply Qeq_bool_iff; lra.
  - case u; auto.
  - case b; auto.
138
  - firstorder.
139
  - apply mTypeEq_refl.
140
Qed.
141

142 143
Lemma expEq_sym e e':
  expEq e e' = expEq e' e.
144 145 146
Proof.
  revert e'.
  induction e; intros e'; destruct e'; simpl; try auto.
147
  - apply Nat.eqb_sym.
148
  - f_equal.
149
    + apply mTypeEq_sym; auto.
150 151 152 153
    + apply Qeq_bool_sym.
  - f_equal.
    + destruct u; auto.
    + apply IHe.
='s avatar
= committed
154
  - f_equal.
155
    + f_equal.
156
      * destruct b; auto.
157
      * apply IHe1.
158
    + apply IHe2.
Nikita Zyuzin's avatar
Nikita Zyuzin committed
159
  - f_equal.
160 161
    + f_equal; auto.
    + auto.
162
  - f_equal.
163
    + apply mTypeEq_sym; auto.
164 165 166
    + apply IHe.
Qed.

167 168 169 170
Lemma expEq_trans e f g:
  expEq e f = true ->
  expEq f g = true ->
  expEq e g = true.
='s avatar
= committed
171
Proof.
172
  revert e f g; induction e;
173 174 175 176 177 178
    destruct f; intros g eq1 eq2;
      destruct g; simpl in *; try congruence;
        try rewrite Nat.eqb_eq in *;
        subst; try auto.
  - andb_to_prop eq1;
      andb_to_prop eq2.
179 180
    rewrite mTypeEq_compat_eq in L, L0; subst.
    rewrite mTypeEq_refl; simpl.
181 182 183
    rewrite Qeq_bool_iff in *; lra.
  - andb_to_prop eq1;
      andb_to_prop eq2.
184 185
    rewrite unopEq_compat_eq in *; subst.
    rewrite unopEq_refl; simpl.
='s avatar
= committed
186
    eapply IHe; eauto.
187 188
  - andb_to_prop eq1;
      andb_to_prop eq2.
189 190
    rewrite binopEq_compat_eq in *; subst.
    rewrite binopEq_refl; simpl.
191 192
    apply andb_true_iff.
    split; [eapply IHe1; eauto | eapply IHe2; eauto].
Nikita Zyuzin's avatar
Nikita Zyuzin committed
193 194 195 196
  - andb_to_prop eq1;
      andb_to_prop eq2.
    rewrite andb_true_iff.
    rewrite andb_true_iff.
197
    split; [split; [eapply IHe1; eauto | eapply IHe2; eauto] | eapply IHe3; eauto].
198 199
  - andb_to_prop eq1;
      andb_to_prop eq2.
200 201
    rewrite mTypeEq_compat_eq in *; subst.
    rewrite mTypeEq_refl; simpl.
='s avatar
= committed
202 203 204
    eapply IHe; eauto.
Qed.

205 206
Fixpoint toRExp (e:exp Q) :=
  match e with
Nikita Zyuzin's avatar
Nikita Zyuzin committed
207 208 209 210
  | Var _ v => Var R v
  | Const m n => Const m (Q2R n)
  | Unop o e1 => Unop o (toRExp e1)
  | Binop o e1 e2 => Binop o (toRExp e1) (toRExp e2)
211
  | Fma e1 e2 e3 => Fma (toRExp e1) (toRExp e2) (toRExp e3)
Nikita Zyuzin's avatar
Nikita Zyuzin committed
212
  | Downcast m e1 => Downcast m (toRExp e1)
213
  end.
214

215 216
Fixpoint toREval (e:exp R) :=
  match e with
217
  | Var _ v => Var R v
218
  | Const _ n => Const M0 n
219 220
  | Unop o e1 => Unop o (toREval e1)
  | Binop o e1 e2 => Binop o (toREval e1) (toREval e2)
221
  | Fma e1 e2 e3 => Fma (toREval e1) (toREval e2) (toREval e3)
222
  | Downcast _ e1 =>   Downcast M0 (toREval e1)
223
  end.
224

225
Definition toRMap (d:nat -> option mType) (n:nat) :=
='s avatar
= committed
226 227 228
  match d n with
  | Some m => Some M0
  | None => None
229
  end.
230

231 232
Arguments toRMap _ _/.

233 234 235 236
(**
  Define a perturbation function to ease writing of basic definitions
**)
Definition perturb (r:R) (e:R) :=
237
  (r * (1 + e))%R.
Heiko Becker's avatar
Heiko Becker committed
238

239 240
Hint Unfold perturb.

241
(**
242
Define expression evaluation relation parametric by an "error" epsilon.
243 244 245
The result value expresses float computations according to the IEEE standard,
using a perturbation of the real valued computation by (1 + delta), where
|delta| <= machine epsilon.
246
**)
247
Inductive eval_exp (E:env) (Gamma: nat -> option mType) :(exp R) -> R -> mType -> Prop :=
248
| Var_load m x v:
249
    Gamma x = Some m ->
250
    E x = Some v ->
251
    eval_exp E Gamma (Var R x) v m
252
| Const_dist m n delta:
253 254
    Rle (Rabs delta) (Q2R (mTypeToQ m)) ->
    eval_exp E Gamma (Const m n) (perturb n delta) m
255
| Unop_neg m f1 v1:
256 257
    eval_exp E Gamma f1 v1 m ->
    eval_exp E Gamma (Unop Neg f1) (evalUnop Neg v1) m
258
| Unop_inv m f1 v1 delta:
259 260 261 262
    Rle (Rabs delta) (Q2R (mTypeToQ m)) ->
    eval_exp E Gamma  f1 v1 m ->
    (~ v1 = 0)%R  ->
    eval_exp E Gamma (Unop Inv f1) (perturb (evalUnop Inv v1) delta) m
263
| Downcast_dist m m1 f1 v1 delta:
264
    (* Downcast expression f1 (evaluating to machine type m1), to a machine type m, less precise than m1.*)
265
    isMorePrecise m1 m = true ->
266 267 268
    Rle (Rabs delta) (Q2R (mTypeToQ m)) ->
    eval_exp E Gamma f1 v1 m1 ->
    eval_exp E Gamma (Downcast m f1) (perturb v1 delta) m
269
| Binop_dist m1 m2 op f1 f2 v1 v2 delta:
270 271 272
    Rle (Rabs delta) (Q2R (mTypeToQ (join m1 m2))) ->
    eval_exp E Gamma f1 v1 m1 ->
    eval_exp E Gamma f2 v2 m2 ->
273
    ((op = Div) -> (~ v2 = 0)%R) ->
Nikita Zyuzin's avatar
Nikita Zyuzin committed
274
    eval_exp E Gamma (Binop op f1 f2) (perturb (evalBinop op v1 v2) delta)  (join m1 m2)
275
| Fma_dist m1 m2 m3 f1 f2 f3 v1 v2 v3 delta:
Nikita Zyuzin's avatar
Nikita Zyuzin committed
276 277 278 279
    Rle (Rabs delta) (Q2R (mTypeToQ (join3 m1 m2 m3))) ->
    eval_exp E Gamma f1 v1 m1 ->
    eval_exp E Gamma f2 v2 m2 ->
    eval_exp E Gamma f3 v3 m3 ->
280 281
    eval_exp E Gamma (Fma f1 f2 f3)
             (perturb (evalFma v1 v2 v3) delta)
Nikita Zyuzin's avatar
Nikita Zyuzin committed
282
             (join3 m1 m2 m3).
283 284 285 286

Hint Constructors eval_exp.

(**
287
  Show some simpler (more general) rule lemmata
288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303
**)
Lemma Const_dist' m n delta v m' E Gamma:
  Rle (Rabs delta) (Q2R (mTypeToQ m)) ->
  v = perturb n delta ->
  m' = m ->
  eval_exp E Gamma (Const m n) v m'.
Proof.
  intros; subst; auto.
Qed.

Hint Resolve Const_dist'.

Lemma Unop_neg' m f1 v1 v m' E Gamma:
  eval_exp E Gamma f1 v1 m ->
  v = evalUnop Neg v1 ->
  m' = m ->
304
  eval_exp E Gamma (Unop Neg f1) v m'.
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349
Proof.
  intros; subst; auto.
Qed.

Hint Resolve Unop_neg'.

Lemma Unop_inv' m f1 v1 delta v m' E Gamma:
  Rle (Rabs delta) (Q2R (mTypeToQ m)) ->
  eval_exp E Gamma  f1 v1 m ->
  (~ v1 = 0)%R  ->
  v = perturb (evalUnop Inv v1) delta ->
  m' = m ->
  eval_exp E Gamma (Unop Inv f1) v m'.
Proof.
  intros; subst; auto.
Qed.

Hint Resolve Unop_inv'.

Lemma Downcast_dist' m m1 f1 v1 delta v m' E Gamma:
  isMorePrecise m1 m = true ->
  Rle (Rabs delta) (Q2R (mTypeToQ m)) ->
  eval_exp E Gamma f1 v1 m1 ->
  v = (perturb v1 delta) ->
  m' = m ->
  eval_exp E Gamma (Downcast m f1) v m'.
Proof.
  intros; subst; eauto.
Qed.

Hint Resolve Downcast_dist'.

Lemma Binop_dist' m1 m2 op f1 f2 v1 v2 delta v m' E Gamma:
  Rle (Rabs delta) (Q2R (mTypeToQ m')) ->
  eval_exp E Gamma f1 v1 m1 ->
  eval_exp E Gamma f2 v2 m2 ->
  ((op = Div) -> (~ v2 = 0)%R) ->
  v = perturb (evalBinop op v1 v2) delta ->
  m' = join m1 m2 ->
  eval_exp E Gamma (Binop op f1 f2) v m'.
Proof.
  intros; subst; auto.
Qed.

Hint Resolve Binop_dist'.
350

351
Lemma Fma_dist' m1 m2 m3 f1 f2 f3 v1 v2 v3 delta v m' E Gamma:
Nikita Zyuzin's avatar
Nikita Zyuzin committed
352 353 354 355
  Rle (Rabs delta) (Q2R (mTypeToQ m')) ->
  eval_exp E Gamma f1 v1 m1 ->
  eval_exp E Gamma f2 v2 m2 ->
  eval_exp E Gamma f3 v3 m3 ->
356
  v = perturb (evalFma v1 v2 v3) delta ->
Nikita Zyuzin's avatar
Nikita Zyuzin committed
357
  m' = join3 m1 m2 m3 ->
358
  eval_exp E Gamma (Fma f1 f2 f3) v m'.
Nikita Zyuzin's avatar
Nikita Zyuzin committed
359 360 361 362
Proof.
  intros; subst; auto.
Qed.

363
Hint Resolve Fma_dist'.
Nikita Zyuzin's avatar
Nikita Zyuzin committed
364

365 366 367 368 369
(**
  Define the set of "used" variables of an expression to be the set of variables
  occuring in it
**)
Fixpoint usedVars (V:Type) (e:exp V) :NatSet.t :=
370 371
  match e with
  | Var _ x => NatSet.singleton x
372 373
  | Unop u e1 => usedVars e1
  | Binop b e1 e2 => NatSet.union (usedVars e1) (usedVars e2)
374
  | Fma e1 e2 e3 => NatSet.union (usedVars e1) (NatSet.union (usedVars e2) (usedVars e3))
375
  | Downcast _ e1 => usedVars e1
376 377
  | _ => NatSet.empty
  end.
378

379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397
Lemma toRMap_eval_M0 f v E Gamma m:
  eval_exp E (toRMap Gamma) (toREval f) v m -> m = M0.
Proof.
  revert v E Gamma m.
  induction f; intros * eval_f; inversion eval_f; subst;
  repeat
    match goal with
    | H: context[toRMap _ _] |- _ => unfold toRMap in H
    | H: context[match ?Gamma ?v with | _ => _ end ] |- _ => destruct (Gamma v) eqn:?
    | H: Some ?m1 = Some ?m2 |- _ => inversion H; try auto
    | H: None = Some ?m |- _ => inversion H
    end; try auto.
  - eapply IHf; eauto.
  - eapply IHf; eauto.
  - assert (m1 = M0)
      by (eapply IHf1; eauto).
    assert (m2 = M0)
      by (eapply IHf2; eauto);
      subst; auto.
Nikita Zyuzin's avatar
Nikita Zyuzin committed
398 399 400 401 402 403 404
  - assert (m1 = M0)
      by (eapply IHf1; eauto).
    assert (m2 = M0)
      by (eapply IHf2; eauto).
    assert (m3 = M0)
      by (eapply IHf3; eauto);
      subst; auto.
405 406
Qed.

407
(**
408
  If |delta| <= 0 then perturb v delta is exactly v.
409
**)
410
Lemma delta_0_deterministic (v:R) (delta:R):
Heiko Becker's avatar
Heiko Becker committed
411 412 413 414
  (Rabs delta <= 0)%R ->
  perturb v delta = v.
Proof.
  intros abs_0; apply Rabs_0_impl_eq in abs_0; subst.
415
  unfold perturb. lra.
Heiko Becker's avatar
Heiko Becker committed
416 417
Qed.

418
(**
419
Evaluation with 0 as machine epsilon is deterministic
420
**)
421
Lemma meps_0_deterministic (f:exp R) (E:env) Gamma:
422
  forall v1 v2,
423 424
  eval_exp E (toRMap Gamma) (toREval f) v1 M0 ->
  eval_exp E (toRMap Gamma) (toREval f) v2 M0 ->
425 426
  v1 = v2.
Proof.
427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442
  induction f;
    intros v1 v2 ev1 ev2.
  - inversion ev1; inversion ev2; subst.
    rewrite H1 in H6.
    inversion H6; auto.
  - inversion ev1; inversion ev2; subst.
    simpl in *.
    rewrite Q2R0_is_0 in *;
    repeat (rewrite delta_0_deterministic; try auto).
  - inversion ev1; inversion ev2; subst; try congruence.
    + rewrite (IHf v0 v3); eauto.
    + rewrite (IHf v0 v3); eauto.
      simpl in *.
      rewrite Q2R0_is_0 in *;
        repeat (rewrite delta_0_deterministic; try auto).
  - inversion ev1; inversion ev2; subst.
443 444 445 446 447
    assert (m0 = M0) by (eapply toRMap_eval_M0; eauto).
    assert (m3 = M0) by (eapply toRMap_eval_M0; eauto).
    assert (m1 = M0) by (eapply toRMap_eval_M0; eauto).
    assert (m2 = M0) by (eapply toRMap_eval_M0; eauto).
    subst.
448 449 450 451 452
    rewrite (IHf1 v0 v4); try auto.
    rewrite (IHf2 v3 v5); try auto.
    simpl in *.
    rewrite Q2R0_is_0 in *.
    repeat (rewrite delta_0_deterministic; try auto).
Nikita Zyuzin's avatar
Nikita Zyuzin committed
453 454 455 456 457 458 459 460 461 462 463 464 465 466
  - inversion ev1; inversion ev2; subst.
    assert (m0 = M0) by (eapply toRMap_eval_M0; eauto).
    assert (m1 = M0) by (eapply toRMap_eval_M0; eauto).
    assert (m2 = M0) by (eapply toRMap_eval_M0; eauto).
    assert (m3 = M0) by (eapply toRMap_eval_M0; eauto).
    assert (m4 = M0) by (eapply toRMap_eval_M0; eauto).
    assert (m5 = M0) by (eapply toRMap_eval_M0; eauto).
    subst.
    rewrite (IHf1 v0 v5); try auto.
    rewrite (IHf2 v3 v6); try auto.
    rewrite (IHf3 v4 v7); try auto.
    simpl in *.
    rewrite Q2R0_is_0 in *.
    repeat (rewrite delta_0_deterministic; try auto).
467 468 469 470 471 472 473
  - inversion ev1; inversion ev2; subst.
    apply M0_least_precision in H1;
      apply M0_least_precision in H7; subst.
    rewrite (IHf v0 v3); try auto.
    simpl in *.
    rewrite Q2R0_is_0 in *.
    repeat (rewrite delta_0_deterministic; try auto).
474 475
Qed.

476 477 478 479
(**
Helping lemma. Needed in soundness proof.
For each evaluation of using an arbitrary epsilon, we can replace it by
evaluating the subexpressions and then binding the result values to different
480
variables in the Environment.
481
 **)
482
Lemma binary_unfolding b f1 f2 E v1 v2 m1 m2 Gamma delta:
483
  (b = Div -> ~(v2 = 0 )%R) ->
484
  (Rabs delta <= Q2R (mTypeToQ (join m1 m2)))%R ->
485 486
  eval_exp E Gamma f1 v1 m1 ->
  eval_exp E Gamma f2 v2 m2 ->
487
  eval_exp E Gamma (Binop b f1 f2) (perturb (evalBinop b v1 v2) delta) (join m1 m2) ->
488 489
  eval_exp (updEnv 2 v2 (updEnv 1 v1 emptyEnv))
           (updDefVars 2 m2 (updDefVars 1 m1 Gamma))
490
             (Binop b (Var R 1) (Var R 2)) (perturb (evalBinop b v1 v2) delta) (join m1 m2).
491
Proof.
492 493
  intros no_div_zero eval_f1 eval_f2 eval_float.
  econstructor; try auto.
494 495
Qed.

Heiko Becker's avatar
Heiko Becker committed
496 497 498 499 500 501 502 503 504 505 506 507 508
Lemma eval_eq_env e:
  forall E1 E2 Gamma v m,
    (forall x, E1 x = E2 x) ->
    eval_exp E1 Gamma e v m ->
    eval_exp E2 Gamma e v m.
Proof.
  induction e; intros;
    (match_pat (eval_exp _ _ _ _ _) (fun H => inversion H; subst; simpl in *));
    try eauto.
  eapply Var_load; auto.
  rewrite <- (H n); auto.
Qed.

509
(*
510 511 512
(**
Analogous lemma for unary expressions.
**)
513 514
Lemma unary_unfolding (e:exp R) (eps:R) (E:env) (v:R):
  (eval_exp eps E (Unop Inv e) v <->
515
   exists v1,
516 517
     eval_exp eps E e v1 /\
     eval_exp eps (updEnv 1 v1 E) (Unop Inv (Var R 1)) v).
518 519 520 521 522 523 524 525 526
Proof.
  split.
  - intros eval_un.
    inversion eval_un; subst.
    exists v1.
    repeat split; try auto.
    constructor; try auto.
    constructor; auto.
  - intros exists_val.
527 528
    destruct exists_val as [v1 [eval_f1 eval_e_E]].
    inversion eval_e_E; subst.
529 530 531
    inversion H1; subst.
    unfold updEnv in *; simpl in *.
    constructor; auto.
532
    inversion H3; subst; auto.
533
Qed. *)
534

535
(*   Using the parametric expressions, define boolean expressions for conditionals *)
536
(* **)
537 538 539
(* Inductive bexp (V:Type) : Type := *)
(*   leq: exp V -> exp V -> bexp V *)
(* | less: exp V -> exp V -> bexp V. *)
540

541
(**
542
  Define evaluation of boolean expressions
543
 **)
544 545 546 547 548 549 550 551 552 553 554 555 556
(* Inductive bval (E:env): (bexp R) -> Prop -> Prop := *)
(*   leq_eval (f1:exp R) (f2:exp R) (v1:R) (v2:R): *)
(*     eval_exp E f1 v1 -> *)
(*     eval_exp E f2 v2 -> *)
(*     bval E (leq f1 f2) (Rle v1 v2) *)
(* |less_eval (f1:exp R) (f2:exp R) (v1:R) (v2:R): *)
(*     eval_exp E f1 v1 -> *)
(*     eval_exp E f2 v2 -> *)
(*     bval E (less f1 f2) (Rlt v1 v2). *)
(* (** *)
(*  Simplify arithmetic later by making > >= only abbreviations *)
(* **) *)
(* Definition gr := fun (V:Type) (f1: exp V) (f2: exp V) => less f2 f1. *)
Nikita Zyuzin's avatar
Nikita Zyuzin committed
557
(* Definition greq := fun (V:Type) (f1:exp V) (f2: exp V) => leq f2 f1. *)