Commit fd8844a1 by Heiko Becker

### Rework interval arithmetic to make it more understandable, still needs the multiplication result

parent 2366a153
 ... ... @@ -2,6 +2,7 @@ Infra/abbrevs.v exps.v daisy_lang.v newIntervalArith.v interval_arith.v abs_err.v simple_doppler.v
 ... ... @@ -3,41 +3,31 @@ used to verify analsysis result in the final theorem of a certificate. **) Require Import Coq.Reals.Reals. Require Import Daisy.daisy_lang Daisy.exps Daisy.Infra.abbrevs Daisy.interval_arith. Require Import Daisy.daisy_lang Daisy.exps Daisy.Infra.abbrevs Daisy.newIntervalArith. Definition abs_env:Type := exp R -> intv -> err -> Prop. (* Definition ErrFromEnv (env:abs_env) (e:exp R) := (env e). Definition IntvFromEnv (env:abs_env) (e:exp R) := fst (env e). Arguments ErrFromEnv _ _ /. Arguments IntvFromEnv _ _ /. *) (** Define absolute error of an expression as an inductive relation **) First define when given an interval and an error, when another error is sound overapproximation of the absolute error **) Definition isSoundErr (error:err) (iv:intv) (propagatedErr:err) := (error >= m_eps * Rmax (Rabs (IVlo(iv) - propagatedErr)) (Rabs (IVhi(iv) + propagatedErr)))%R. Definition isSupersetIntv (res:intv) (comp:intv) := (IVhi res >= IVhi comp)%R /\ (IVlo res <= IVlo comp)%R. Definition maxAbs (IV:intv) := Rmax (Rabs (IVlo IV)) (Rabs (IVhi IV)). Definition mult_err (e1:exp R) (val_e1:ann) (e2:exp R) (val_e2:ann) := (maxAbs (intv_add (intv_add (intv_mult (addInterval (addInterval (multInterval (getIntv val_e1) (getErr val_e2, getErr val_e2)) (intv_mult (multInterval (getIntv val_e2) (getErr val_e1, getErr val_e1))) (intv_mult (intv_mult (intv_mult (multInterval (multInterval (multInterval (getIntv val_e1) (getIntv val_e2)) (getErr val_e1, getErr val_e1)) ... ... @@ -46,16 +36,16 @@ Definition mult_err (e1:exp R) (val_e1:ann) (e2:exp R) (val_e2:ann) := Definition isSoundErrBin (op:binop) (e1:exp R) (val_e1:ann) (e2:exp R) (val_e2:ann) (val:ann):= match op with Plus => (isSupersetIntv (getIntv val) (intv_add_err (getIntv val_e1) (getErr val_e1) (getIntv val_e2) (getErr val_e2)) /\ => (isSupersetInterval (getIntv val) (addInterval (widenInterval (getIntv val_e1) (getErr val_e1)) (widenInterval (getIntv val_e2) (getErr val_e2))) /\ isSoundErr (getErr val) (getIntv val) (getErr val_e1 + getErr val_e2)%R) |Sub => (isSupersetIntv (getIntv val) (intv_sub_err (getIntv val_e1) (getErr val_e1) (getIntv val_e2) (getErr val_e2)) /\ => (isSupersetInterval (getIntv val) (substractInterval (widenInterval (getIntv val_e1) (getErr val_e1)) (widenInterval (getIntv val_e2) (getErr val_e2))) /\ isSoundErr (getErr val) (getIntv val) (getErr val_e1 - getErr val_e2)%R) |Mult => (isSupersetIntv (getIntv val) (intv_mult_err (getIntv val_e1) (getErr val_e1) (getIntv val_e2) (getErr val_e2)) /\ => (isSupersetInterval (getIntv val) (multInterval (widenInterval (getIntv val_e1) (getErr val_e1)) (widenInterval (getIntv val_e2) (getErr val_e2))) /\ isSoundErr (getErr val) (getIntv val) (mult_err e1 val_e1 e2 val_e2)) |Div => (isSupersetIntv (getIntv val) (intv_div_err (getIntv val_e1) (getErr val_e1) (getIntv val_e2) (getErr val_e2)) /\ => (isSupersetInterval (getIntv val) (intv_div_err (getIntv val_e1) (getErr val_e1) (getIntv val_e2) (getErr val_e2)) /\ isSoundErr (getErr val) (getIntv val) (mult_err e1 val_e1 e2 (((/ IVlo (getIntv val_e2))%R, (/ IVhi (getIntv val_e2))%R), getErr val_e2))) end. ... ...