Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
What's new
7
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
AVA
FloVer
Commits
10eef967
Commit
10eef967
authored
Mar 03, 2017
by
Raphaël Monat
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
WIP: Porting the different validators to mixed-precision.
/!\ Does not compile
parent
2227936b
Changes
4
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
408 additions
and
204 deletions
+408
-204
coq/ErrorBounds.v
coq/ErrorBounds.v
+44
-19
coq/ErrorValidation.v
coq/ErrorValidation.v
+106
-77
coq/IntervalValidation.v
coq/IntervalValidation.v
+235
-84
coq/ssaPrgs.v
coq/ssaPrgs.v
+23
-24
No files found.
coq/ErrorBounds.v
View file @
10eef967
...
@@ -8,8 +8,8 @@ Require Import Daisy.Infra.Abbrevs Daisy.Infra.RationalSimps Daisy.Infra.RealSim
...
@@ -8,8 +8,8 @@ Require Import Daisy.Infra.Abbrevs Daisy.Infra.RationalSimps Daisy.Infra.RealSim
Require
Import
Daisy
.
Environments
Daisy
.
Infra
.
ExpressionAbbrevs
.
Require
Import
Daisy
.
Environments
Daisy
.
Infra
.
ExpressionAbbrevs
.
Lemma
const_abs_err_bounded
(
n
:
R
)
(
nR
:
R
)
(
nF
:
R
)
(
E1
E2
:
env
)
(
absenv
:
analysisResult
)
(
m
:
mType
)
:
Lemma
const_abs_err_bounded
(
n
:
R
)
(
nR
:
R
)
(
nF
:
R
)
(
E1
E2
:
env
)
(
absenv
:
analysisResult
)
(
m
:
mType
)
:
eval_exp
E1
(
Const
n
)
nR
M0
->
eval_exp
E1
(
Const
m
n
)
nR
M0
->
eval_exp
E2
(
Const
n
)
nF
M0
->
eval_exp
E2
(
Const
m
n
)
nF
m
->
(
Rabs
(
nR
-
nF
)
<=
Rabs
n
*
(
Q2R
(
meps
m
)))
%
R
.
(
Rabs
(
nR
-
nF
)
<=
Rabs
n
*
(
Q2R
(
meps
m
)))
%
R
.
Proof
.
Proof
.
intros
eval_real
eval_float
.
intros
eval_real
eval_float
.
...
@@ -21,8 +21,7 @@ Proof.
...
@@ -21,8 +21,7 @@ Proof.
apply
Rmult_le_compat_l
;
[
apply
Rabs_pos
|
auto
].
apply
Rmult_le_compat_l
;
[
apply
Rabs_pos
|
auto
].
simpl
(
meps
M0
)
in
*
.
simpl
(
meps
M0
)
in
*
.
apply
(
Rle_trans
_
(
Q2R
0
)
_
);
try
auto
.
apply
(
Rle_trans
_
(
Q2R
0
)
_
);
try
auto
.
apply
Qle_Rle
;
apply
inj_eps_pos
.
rewrite
Q2R0_is_0
;
lra
.
simpl
(
meps
M0
)
in
H0
;
rewrite
Q2R0_is_0
in
H0
;
auto
.
Qed
.
Qed
.
(
*
(
*
...
@@ -77,11 +76,11 @@ Proof.
...
@@ -77,11 +76,11 @@ Proof.
unfold
perturb
;
simpl
.
unfold
perturb
;
simpl
.
inversion
H7
;
subst
;
inversion
H8
;
subst
.
inversion
H7
;
subst
;
inversion
H8
;
subst
.
unfold
updEnv
;
simpl
.
unfold
updEnv
;
simpl
.
unfold
updEnv
in
H9
,
H
11
;
simpl
in
*
.
unfold
updEnv
in
H9
,
H
6
;
simpl
in
*
.
symmetry
in
H9
,
H
11
.
symmetry
in
H9
,
H
6
.
inversion
H9
;
inversion
H
11
;
subst
.
inversion
H9
;
inversion
H
6
;
subst
.
(
*
We
have
now
obtained
all
necessary
values
from
the
evaluations
-->
remove
them
for
readability
*
)
(
*
We
have
now
obtained
all
necessary
values
from
the
evaluations
-->
remove
them
for
readability
*
)
clear
plus_float
H7
H8
plus_real
e1_real
e1_float
e2_real
e2_float
H9
H
11
.
clear
plus_float
H7
H8
plus_real
e1_real
e1_float
e2_real
e2_float
H9
H
6
.
repeat
rewrite
Rmult_plus_distr_l
.
repeat
rewrite
Rmult_plus_distr_l
.
rewrite
Rmult_1_r
.
rewrite
Rmult_1_r
.
rewrite
Rsub_eq_Ropp_Rplus
.
rewrite
Rsub_eq_Ropp_Rplus
.
...
@@ -94,7 +93,7 @@ Proof.
...
@@ -94,7 +93,7 @@ Proof.
pose
proof
(
Rabs_triang
(
e2R
+
-
e2F
)
(
-
((
e1F
+
e2F
)
*
delta
))).
pose
proof
(
Rabs_triang
(
e2R
+
-
e2F
)
(
-
((
e1F
+
e2F
)
*
delta
))).
pose
proof
(
Rplus_le_compat_l
(
Rabs
(
e1R
+
-
e1F
))
_
_
H0
).
pose
proof
(
Rplus_le_compat_l
(
Rabs
(
e1R
+
-
e1F
))
_
_
H0
).
eapply
Rle_trans
.
eapply
Rle_trans
.
apply
H
6
.
apply
H
1
.
rewrite
<-
Rplus_assoc
.
rewrite
<-
Rplus_assoc
.
repeat
rewrite
<-
Rsub_eq_Ropp_Rplus
.
repeat
rewrite
<-
Rsub_eq_Ropp_Rplus
.
rewrite
Rabs_Ropp
.
rewrite
Rabs_Ropp
.
...
@@ -143,11 +142,11 @@ Proof.
...
@@ -143,11 +142,11 @@ Proof.
unfold
perturb
;
simpl
.
unfold
perturb
;
simpl
.
inversion
H7
;
subst
;
inversion
H8
;
subst
.
inversion
H7
;
subst
;
inversion
H8
;
subst
.
unfold
updEnv
;
simpl
.
unfold
updEnv
;
simpl
.
symmetry
in
H9
,
H
11
.
symmetry
in
H9
,
H
6
.
unfold
updEnv
in
H9
,
H
11
;
simpl
in
H9
,
H
11
.
unfold
updEnv
in
H9
,
H
6
;
simpl
in
H9
,
H
6
.
inversion
H9
;
inversion
H
11
;
subst
.
inversion
H9
;
inversion
H
6
;
subst
.
(
*
We
have
now
obtained
all
necessary
values
from
the
evaluations
-->
remove
them
for
readability
*
)
(
*
We
have
now
obtained
all
necessary
values
from
the
evaluations
-->
remove
them
for
readability
*
)
clear
sub_float
H7
H8
sub_real
e1_real
e1_float
e2_real
e2_float
H9
H
11
.
clear
sub_float
H7
H8
sub_real
e1_real
e1_float
e2_real
e2_float
H9
H
6
.
repeat
rewrite
Rmult_plus_distr_l
.
repeat
rewrite
Rmult_plus_distr_l
.
rewrite
Rmult_1_r
.
rewrite
Rmult_1_r
.
repeat
rewrite
Rsub_eq_Ropp_Rplus
.
repeat
rewrite
Rsub_eq_Ropp_Rplus
.
...
@@ -199,11 +198,11 @@ Proof.
...
@@ -199,11 +198,11 @@ Proof.
inversion
mult_float
;
subst
.
inversion
mult_float
;
subst
.
unfold
perturb
;
simpl
.
unfold
perturb
;
simpl
.
inversion
H7
;
subst
;
inversion
H8
;
subst
.
inversion
H7
;
subst
;
inversion
H8
;
subst
.
symmetry
in
H9
,
H
11
;
symmetry
in
H9
,
H
6
;
unfold
updEnv
in
*
;
simpl
in
*
.
unfold
updEnv
in
*
;
simpl
in
*
.
inversion
H9
;
inversion
H
11
;
subst
.
inversion
H9
;
inversion
H
6
;
subst
.
(
*
We
have
now
obtained
all
necessary
values
from
the
evaluations
-->
remove
them
for
readability
*
)
(
*
We
have
now
obtained
all
necessary
values
from
the
evaluations
-->
remove
them
for
readability
*
)
clear
mult_float
H7
H8
mult_real
e1_real
e1_float
e2_real
e2_float
H9
H
11
.
clear
mult_float
H7
H8
mult_real
e1_real
e1_float
e2_real
e2_float
H9
H
6
.
repeat
rewrite
Rmult_plus_distr_l
.
repeat
rewrite
Rmult_plus_distr_l
.
rewrite
Rmult_1_r
.
rewrite
Rmult_1_r
.
rewrite
Rsub_eq_Ropp_Rplus
.
rewrite
Rsub_eq_Ropp_Rplus
.
...
@@ -249,11 +248,11 @@ Proof.
...
@@ -249,11 +248,11 @@ Proof.
inversion
div_float
;
subst
.
inversion
div_float
;
subst
.
unfold
perturb
;
simpl
.
unfold
perturb
;
simpl
.
inversion
H7
;
subst
;
inversion
H8
;
subst
.
inversion
H7
;
subst
;
inversion
H8
;
subst
.
symmetry
in
H9
,
H
11
;
symmetry
in
H9
,
H
6
;
unfold
updEnv
in
*
;
simpl
in
*
.
unfold
updEnv
in
*
;
simpl
in
*
.
inversion
H9
;
inversion
H
11
;
subst
.
inversion
H9
;
inversion
H
6
;
subst
.
(
*
We
have
now
obtained
all
necessary
values
from
the
evaluations
-->
remove
them
for
readability
*
)
(
*
We
have
now
obtained
all
necessary
values
from
the
evaluations
-->
remove
them
for
readability
*
)
clear
div_float
H7
H8
div_real
e1_real
e1_float
e2_real
e2_float
H9
H
11
.
clear
div_float
H7
H8
div_real
e1_real
e1_float
e2_real
e2_float
H9
H
6
.
repeat
rewrite
Rmult_plus_distr_l
.
repeat
rewrite
Rmult_plus_distr_l
.
rewrite
Rmult_1_r
.
rewrite
Rmult_1_r
.
rewrite
Rsub_eq_Ropp_Rplus
.
rewrite
Rsub_eq_Ropp_Rplus
.
...
@@ -447,3 +446,29 @@ Proof.
...
@@ -447,3 +446,29 @@ Proof.
auto
.
auto
.
rewrite
Q2R0_is_0
;
auto
.
rewrite
Q2R0_is_0
;
auto
.
Qed
.
Qed
.
Lemma
round_abs_err_bounded
(
e
:
exp
R
)
(
nR
nF1
nF
:
R
)
(
E
:
env
)
(
err
:
R
)
(
machineEpsilon
m
:
mType
)
:
eval_exp
E
(
toREval
e
)
nR
M0
->
eval_exp
E
e
nF1
m
->
eval_exp
(
updEnv
1
m
nF1
E
)
(
toRExp
(
Downcast
machineEpsilon
(
Var
Q
m
1
)))
nF
machineEpsilon
->
(
Rabs
(
nR
-
nF1
)
<=
err
)
%
R
->
(
Rabs
(
nR
-
nF
)
<=
err
+
(
Rabs
nF1
)
*
Q2R
(
meps
machineEpsilon
))
%
R
.
Proof
.
intros
eval_real
eval_float
eval_float_rnd
err_bounded
.
replace
(
nR
-
nF
)
%
R
with
((
nR
-
nF1
)
+
(
nF1
-
nF
))
%
R
by
lra
.
eapply
Rle_trans
.
apply
(
Rabs_triang
(
nR
-
nF1
)
(
nF1
-
nF
)).
apply
(
Rle_trans
_
(
err
+
Rabs
(
nF1
-
nF
))
_
).
-
apply
Rplus_le_compat_r
;
assumption
.
-
apply
Rplus_le_compat_l
.
inversion
eval_float_rnd
;
subst
.
inversion
H5
;
subst
.
inversion
H7
.
unfold
perturb
;
simpl
.
replace
(
v1
-
v1
*
(
1
+
delta
))
%
R
with
(
-
(
v1
*
delta
))
%
R
by
lra
.
replace
(
Rabs
(
-
(
v1
*
delta
)))
with
(
Rabs
(
v1
*
delta
))
by
(
symmetry
;
apply
Rabs_Ropp
).
rewrite
Rabs_mult
.
apply
Rmult_le_compat_l
.
+
apply
Rabs_pos
.
+
auto
.
Qed
.
coq/ErrorValidation.v
View file @
10eef967
...
@@ -9,59 +9,70 @@
...
@@ -9,59 +9,70 @@
Require
Import
Coq
.
QArith
.
QArith
Coq
.
QArith
.
Qminmax
Coq
.
QArith
.
Qabs
Coq
.
QArith
.
Qreals
Coq
.
Lists
.
List
.
Require
Import
Coq
.
QArith
.
QArith
Coq
.
QArith
.
Qminmax
Coq
.
QArith
.
Qabs
Coq
.
QArith
.
Qreals
Coq
.
Lists
.
List
.
Require
Import
Coq
.
micromega
.
Psatz
Coq
.
Reals
.
Reals
.
Require
Import
Coq
.
micromega
.
Psatz
Coq
.
Reals
.
Reals
.
Require
Import
Daisy
.
Infra
.
Abbrevs
Daisy
.
Infra
.
RationalSimps
Daisy
.
Infra
.
RealRationalProps
Daisy
.
Infra
.
RealSimps
Daisy
.
Infra
.
Ltacs
.
Require
Import
Daisy
.
Infra
.
Abbrevs
Daisy
.
Infra
.
RationalSimps
Daisy
.
Infra
.
RealRationalProps
Daisy
.
Infra
.
RealSimps
Daisy
.
Infra
.
Ltacs
.
Require
Import
Daisy
.
Environments
Daisy
.
IntervalValidation
Daisy
.
ErrorBounds
.
Require
Import
Daisy
.
Environments
Daisy
.
IntervalValidation
Daisy
.
Typing
Daisy
.
ErrorBounds
.
(
**
Error
bound
validator
**
)
(
**
Error
bound
validator
**
)
Fixpoint
validErrorbound
(
e
:
exp
Q
)
(
absenv
:
analysisResult
)
(
dVars
:
NatSet
.
t
)
:=
Fixpoint
validErrorbound
(
e
:
exp
Q
)
(
typeMap
:
exp
Q
->
option
mType
)
(
absenv
:
analysisResult
)
(
dVars
:
NatSet
.
t
)
:=
let
(
intv
,
err
)
:=
(
absenv
e
)
in
let
(
intv
,
err
)
:=
(
absenv
e
)
in
if
(
Qleb
0
err
)
let
mopt
:=
typeMap
e
in
then
match
mopt
with
match
e
with
|
None
=>
false
|
Var
_
v
=>
|
Some
m
=>
if
(
NatSet
.
mem
v
dVars
)
if
(
Qleb
0
err
)
then
true
then
else
(
Qleb
(
maxAbs
intv
*
RationalSimps
.
machineEpsilon
)
err
)
match
e
with
|
Const
n
=>
|
Var
_
_
v
=>
Qleb
(
maxAbs
intv
*
RationalSimps
.
machineEpsilon
)
err
if
(
NatSet
.
mem
v
dVars
)
|
Unop
_
_
=>
false
then
true
|
Binop
b
e1
e2
=>
else
(
Qleb
(
maxAbs
intv
*
(
meps
m
))
err
)
if
((
validErrorbound
e1
absenv
dVars
)
&&
(
validErrorbound
e2
absenv
dVars
))
|
Const
_
n
=>
then
Qleb
(
maxAbs
intv
*
(
meps
m
))
err
let
(
ive1
,
err1
)
:=
absenv
e1
in
|
Unop
_
_
=>
false
let
(
ive2
,
err2
)
:=
absenv
e2
in
|
Binop
b
e1
e2
=>
let
errIve1
:=
widenIntv
ive1
err1
in
if
((
validErrorbound
e1
typeMap
absenv
dVars
)
&&
(
validErrorbound
e2
typeMap
absenv
dVars
))
let
errIve2
:=
widenIntv
ive2
err2
in
then
let
upperBoundE1
:=
maxAbs
ive1
in
let
(
ive1
,
err1
)
:=
absenv
e1
in
let
upperBoundE2
:=
maxAbs
ive2
in
let
(
ive2
,
err2
)
:=
absenv
e2
in
match
b
with
let
errIve1
:=
widenIntv
ive1
err1
in
|
Plus
=>
let
errIve2
:=
widenIntv
ive2
err2
in
Qleb
(
err1
+
err2
+
(
maxAbs
(
addIntv
errIve1
errIve2
))
*
machineEpsilon
)
err
let
upperBoundE1
:=
maxAbs
ive1
in
|
Sub
=>
let
upperBoundE2
:=
maxAbs
ive2
in
Qleb
(
err1
+
err2
+
(
maxAbs
(
subtractIntv
errIve1
errIve2
))
*
machineEpsilon
)
err
match
b
with
|
Mult
=>
|
Plus
=>
Qleb
((
upperBoundE1
*
err2
+
upperBoundE2
*
err1
+
err1
*
err2
)
+
(
maxAbs
(
multIntv
errIve1
errIve2
))
*
machineEpsilon
)
err
Qleb
(
err1
+
err2
+
(
maxAbs
(
addIntv
errIve1
errIve2
))
*
(
meps
m
))
err
|
Div
=>
|
Sub
=>
if
(((
Qleb
(
ivhi
errIve2
)
0
)
&&
(
negb
(
Qeq_bool
(
ivhi
errIve2
)
0
)))
||
Qleb
(
err1
+
err2
+
(
maxAbs
(
subtractIntv
errIve1
errIve2
))
*
(
meps
m
))
err
((
Qleb
0
(
ivlo
errIve2
))
&&
(
negb
(
Qeq_bool
(
ivlo
errIve2
)
0
))))
|
Mult
=>
then
Qleb
((
upperBoundE1
*
err2
+
upperBoundE2
*
err1
+
err1
*
err2
)
+
(
maxAbs
(
multIntv
errIve1
errIve2
))
*
(
meps
m
))
err
let
upperBoundInvE2
:=
maxAbs
(
invertIntv
ive2
)
in
|
Div
=>
let
minAbsIve2
:=
minAbs
(
errIve2
)
in
if
(((
Qleb
(
ivhi
errIve2
)
0
)
&&
(
negb
(
Qeq_bool
(
ivhi
errIve2
)
0
)))
||
let
errInv
:=
(
1
/
(
minAbsIve2
*
minAbsIve2
))
*
err2
in
((
Qleb
0
(
ivlo
errIve2
))
&&
(
negb
(
Qeq_bool
(
ivlo
errIve2
)
0
))))
Qleb
((
upperBoundE1
*
errInv
+
upperBoundInvE2
*
err1
+
err1
*
errInv
)
+
(
maxAbs
(
divideIntv
errIve1
errIve2
))
*
machineEpsilon
)
err
then
else
false
let
upperBoundInvE2
:=
maxAbs
(
invertIntv
ive2
)
in
end
let
minAbsIve2
:=
minAbs
(
errIve2
)
in
else
false
let
errInv
:=
(
1
/
(
minAbsIve2
*
minAbsIve2
))
*
err2
in
end
Qleb
((
upperBoundE1
*
errInv
+
upperBoundInvE2
*
err1
+
err1
*
errInv
)
+
(
maxAbs
(
divideIntv
errIve1
errIve2
))
*
(
meps
m
))
err
else
false
.
else
false
end
else
false
|
Downcast
m1
e1
=>
let
(
ive1
,
err1
)
:=
absenv
e1
in
let
rec
:=
validErrorbound
e1
typeMap
absenv
dVars
in
let
errIve1
:=
widenIntv
ive1
err1
in
andb
rec
(
Qleb
(
err1
+
maxAbs
errIve1
*
(
meps
m1
))
err
)
end
else
false
end
.
(
**
Error
bound
command
validator
**
)
(
**
Error
bound
command
validator
**
)
Fixpoint
validErrorboundCmd
(
f
:
cmd
Q
)
(
env
:
analysisResult
)
(
dVars
:
NatSet
.
t
)
{
struct
f
}
:
bool
:=
Fixpoint
validErrorboundCmd
(
f
:
cmd
Q
)
(
env
:
analysisResult
)
(
dVars
:
NatSet
.
t
)
{
struct
f
}
:
bool
:=
match
f
with
match
f
with
|
Let
x
e
g
=>
|
Let
m
x
e
g
=>
if
((
validErrorbound
e
env
dVars
)
&&
(
Qeq_bool
(
snd
(
env
e
))
(
snd
(
env
(
Var
Q
x
)))))
let
tmap
:=
typeExpression
e
in
if
((
validErrorbound
e
tmap
env
dVars
)
&&
(
Qeq_bool
(
snd
(
env
e
))
(
snd
(
env
(
Var
Q
m
x
)))))
then
validErrorboundCmd
g
env
(
NatSet
.
add
x
dVars
)
then
validErrorboundCmd
g
env
(
NatSet
.
add
x
dVars
)
else
false
else
false
|
Ret
e
=>
validErrorbound
e
env
dVars
|
Ret
e
=>
validErrorbound
e
(
typeExpression
e
)
env
dVars
end
.
end
.
(
**
(
**
...
@@ -69,46 +80,65 @@ Fixpoint validErrorboundCmd (f:cmd Q) (env:analysisResult) (dVars:NatSet.t) {str
...
@@ -69,46 +80,65 @@ Fixpoint validErrorboundCmd (f:cmd Q) (env:analysisResult) (dVars:NatSet.t) {str
This
lemma
enables
us
to
deduce
from
each
run
of
the
validator
the
invariant
This
lemma
enables
us
to
deduce
from
each
run
of
the
validator
the
invariant
that
when
it
succeeds
,
the
errors
must
be
positive
.
that
when
it
succeeds
,
the
errors
must
be
positive
.
**
)
**
)
Lemma
err_always_positive
e
(
absenv
:
analysisResult
)
iv
err
dVars
:
Lemma
err_always_positive
e
tmap
(
absenv
:
analysisResult
)
iv
err
dVars
:
validErrorbound
e
absenv
dVars
=
true
->
validErrorbound
e
tmap
absenv
dVars
=
true
->
(
iv
,
err
)
=
absenv
e
->
(
iv
,
err
)
=
absenv
e
->
(
0
<=
Q2R
err
)
%
R
.
(
0
<=
Q2R
err
)
%
R
.
Proof
.
Proof
.
destruct
e
;
intros
validErrorbound_e
absenv_e
;
destruct
e
;
intros
validErrorbound_e
absenv_e
;
unfold
validErrorbound
in
validErrorbound_e
;
unfold
validErrorbound
in
validErrorbound_e
;
rewrite
<-
absenv_e
in
validErrorbound_e
;
simpl
in
*
;
rewrite
<-
absenv_e
in
validErrorbound_e
;
simpl
in
*
.
andb_to_prop
validErrorbound_e
.
-
case_eq
(
Qleb
0
err
);
intros
;
auto
;
rewrite
H
in
validErrorbound_e
.
-
apply
Qle_bool_iff
in
L
;
apply
Qle_Rle
in
L
;
rewrite
Q2R0_is_0
in
L
;
auto
.
+
apply
Qle_bool_iff
,
Qle_Rle
in
H
;
rewrite
Q2R0_is_0
in
H
;
auto
.
-
apply
Qle_bool_iff
in
L
;
apply
Qle_Rle
in
L
;
rewrite
Q2R0_is_0
in
L
;
auto
.
+
destruct
(
tmap
(
Var
Q
m
n
));
inversion
validErrorbound_e
.
-
inversion
R
.
-
case_eq
(
Qleb
0
err
);
intros
;
auto
;
rewrite
H
in
validErrorbound_e
.
-
apply
Qle_bool_iff
in
L
;
apply
Qle_Rle
in
L
;
rewrite
Q2R0_is_0
in
L
;
auto
.
+
apply
Qle_bool_iff
,
Qle_Rle
in
H
;
rewrite
Q2R0_is_0
in
H
;
auto
.
+
destruct
(
tmap
(
Const
m
q
));
inversion
validErrorbound_e
.
-
case_eq
(
Qleb
0
err
);
intros
;
auto
;
rewrite
H
in
validErrorbound_e
.
+
apply
Qle_bool_iff
,
Qle_Rle
in
H
;
rewrite
Q2R0_is_0
in
H
;
auto
.
+
destruct
(
tmap
(
Unop
u
e
));
inversion
validErrorbound_e
.
-
case_eq
(
Qleb
0
err
);
intros
;
auto
;
rewrite
H
in
validErrorbound_e
.
+
apply
Qle_bool_iff
,
Qle_Rle
in
H
;
rewrite
Q2R0_is_0
in
H
;
auto
.
+
destruct
(
tmap
(
Binop
b
e1
e2
));
inversion
validErrorbound_e
.
-
case_eq
(
Qleb
0
err
);
intros
;
auto
;
rewrite
H
in
validErrorbound_e
.
+
apply
Qle_bool_iff
,
Qle_Rle
in
H
;
rewrite
Q2R0_is_0
in
H
;
auto
.
+
destruct
(
tmap
(
Downcast
m
e
));
inversion
validErrorbound_e
.
Qed
.
Qed
.
Lemma
validErrorboundCorrectVariable
:
Lemma
validErrorboundCorrectVariable
:
forall
E1
E2
absenv
(
v
:
nat
)
nR
nF
e
nlo
nhi
P
fVars
dVars
,
forall
E1
E2
absenv
(
v
:
nat
)
nR
nF
e
nlo
nhi
P
fVars
dVars
m
,
approxEnv
E1
absenv
fVars
dVars
E2
->
approxEnv
E1
absenv
fVars
dVars
E2
->
eval_exp
0
%
R
E1
(
toRExp
(
Var
Q
v
))
nR
->
eval_exp
E1
(
toREval
(
toRExp
(
Var
Q
m
v
)
))
nR
M0
->
eval_exp
(
Q2R
machineEpsilon
)
E2
(
toRExp
(
Var
Q
v
))
nF
->
eval_exp
E2
(
toRExp
(
Var
Q
m
v
))
nF
m
->
validIntervalbounds
(
Var
Q
v
)
absenv
P
dVars
=
true
->
validIntervalbounds
(
erasure
(
Var
Q
m
v
)
)
absenv
P
dVars
=
true
->
validErrorbound
(
Var
Q
v
)
absenv
dVars
=
true
->
validErrorbound
(
Var
Q
m
v
)
(
typeExpression
(
Var
Q
m
v
)
)
absenv
dVars
=
true
->
(
forall
v
,
(
forall
v
,
NatSet
.
mem
v
dVars
=
true
->
NatSet
.
mem
v
dVars
=
true
->
exists
r
:
R
,
exists
r
:
R
,
E1
v
=
Some
r
/
\
E1
v
=
Some
(
r
,
M0
)
/
\
(
Q2R
(
fst
(
fst
(
absenv
(
Var
Q
v
))))
<=
r
<=
Q2R
(
snd
(
fst
(
absenv
(
Var
Q
v
)))))
%
R
)
->
(
Q2R
(
fst
(
fst
(
absenv
(
Var
Q
m
v
))))
<=
r
<=
Q2R
(
snd
(
fst
(
absenv
(
Var
Q
m
v
)))))
%
R
)
->
(
forall
v
,
NatSet
.
mem
v
fVars
=
true
->
(
forall
v
,
NatSet
.
mem
v
fVars
=
true
->
exists
r
,
E1
v
=
Some
r
/
\
exists
r
,
E1
v
=
Some
(
r
,
M0
)
/
\
(
Q2R
(
fst
(
P
v
))
<=
r
<=
Q2R
(
snd
(
P
v
)))
%
R
)
->
(
Q2R
(
fst
(
P
v
))
<=
r
<=
Q2R
(
snd
(
P
v
)))
%
R
)
->
absenv
(
Var
Q
v
)
=
((
nlo
,
nhi
),
e
)
->
absenv
(
Var
Q
m
v
)
=
((
nlo
,
nhi
),
e
)
->
(
Rabs
(
nR
-
nF
)
<=
(
Q2R
e
))
%
R
.
(
Rabs
(
nR
-
nF
)
<=
(
Q2R
e
))
%
R
.
Proof
.
Proof
.
intros
E1
E2
absenv
v
nR
nF
e
nlo
nhi
P
fVars
dVars
approxCEnv
eval_real
intros
*
approxCEnv
eval_real
eval_float
bounds_valid
error_valid
dVars_sound
P_valid
absenv_var
.
eval_float
bounds_valid
error_valid
dVars_sound
P_valid
absenv_var
.
simpl
in
eval_real
;
inversion
eval_real
;
inversion
eval_float
;
subst
.
inversion
eval_real
;
inversion
eval_float
;
subst
.
rename
H2
into
E1_v
;
rename
H0
into
E1_v
;
rename
H7
into
E2_v
.
rename
H3
into
E2_v
.
(
*
assert
((
typeExpression
(
Var
Q
m
v
))
(
Var
Q
m
v
)
=
Some
m
)
as
tEv
.
*
)
(
*
unfold
typeExpression
.
unfold
expEqBool
.
*
)
(
*
case_eq
(
mTypeEqBool
m
m
&&
(
v
=?
v
));
intros
;
auto
.
*
)
(
*
apply
andb_false_iff
in
H
.
destruct
H
.
assert
(
mTypeEqBool
m
m
=
true
)
by
(
apply
EquivEqBoolEq
;
auto
).
*
)
(
*
congruence
.
*
)
(
*
assert
(
v
=?
v
=
true
)
by
(
apply
beq_nat_true_iff
;
auto
).
*
)
(
*
congruence
.
*
)
simpl
in
error_valid
.
simpl
in
error_valid
.
rewrite
absenv_var
in
error_valid
;
simpl
in
error_valid
.
rewrite
absenv_var
in
error_valid
;
simpl
in
error_valid
.
assert
(
mTypeEqBool
m
m
&&
(
v
=?
v
)
=
true
).
apply
andb_true_iff
;
split
;
[
rewrite
EquivEqBoolEq
|
apply
beq_nat_true_iff
];
auto
.
rewrite
H
in
error_valid
.
rewrite
<-
andb_lazy_alt
in
error_valid
.
rewrite
<-
andb_lazy_alt
in
error_valid
.
andb_to_prop
error_valid
.
andb_to_prop
error_valid
.
rename
L
into
error_pos
.
rename
L
into
error_pos
.
...
@@ -131,19 +161,18 @@ Proof.
...
@@ -131,19 +161,18 @@ Proof.
rewrite
x_in_union
in
*
.
rewrite
x_in_union
in
*
.
congruence
.
congruence
.
*
rewrite
x_not_bound
in
error_valid
.
*
rewrite
x_not_bound
in
error_valid
.
inversion
E1_v
;
inversion
E2_v
;
inversion
E1_v
;
inversion
E2_v
;
subst
.
subst
.
eapply
Rle_trans
;
try
eauto
.
eapply
Rle_trans
;
try
eauto
.
apply
Qle_bool_iff
in
error_valid
.
apply
Qle_bool_iff
in
error_valid
.
apply
Qle_Rle
in
error_valid
.
apply
Qle_Rle
in
error_valid
.
eapply
Rle_trans
;
eauto
.
eapply
Rle_trans
;
eauto
.
rewrite
Q2R_mult
.
rewrite
Q2R_mult
.
apply
Rmult_le_compat_r
.
apply
Rmult_le_compat_r
.
{
apply
mEps_geq_zero
.
}
{
apply
inj_eps_posR
.
}
{
rewrite
<-
maxAbs_impl_RmaxAbs
.
{
rewrite
<-
maxAbs_impl_RmaxAbs
.
apply
contained_leq_maxAbs
.
apply
contained_leq_maxAbs
.
unfold
contained
;
simpl
.
unfold
contained
;
simpl
.
pose
proof
(
validIntervalbounds_sound
(
Var
Q
x
)
A
P
(
E
:=
fun
y
:
nat
=>
if
y
=?
x
then
Some
nR
else
E1
y
)
(
vR
:=
nR
)
bounds_valid
(
fVars
:=
(
NatSet
.
add
x
fVars
)))
as
valid_bounds_prf
.
pose
proof
(
validIntervalbounds_sound
(
erasure
(
Var
Q
m
x
)
)
A
P
(
E
:=
fun
y
:
nat
=>
if
y
=?
x
then
Some
(
nR
,
M0
)
else
E1
y
)
(
vR
:=
nR
)
bounds_valid
(
fVars
:=
(
NatSet
.
add
x
fVars
)))
as
valid_bounds_prf
.
rewrite
absenv_var
in
valid_bounds_prf
;
simpl
in
valid_bounds_prf
.
rewrite
absenv_var
in
valid_bounds_prf
;
simpl
in
valid_bounds_prf
.
apply
valid_bounds_prf
;
try
auto
.
apply
valid_bounds_prf
;
try
auto
.
intros
v
v_mem_diff
.
intros
v
v_mem_diff
.
...
@@ -263,7 +292,7 @@ Proof.
...
@@ -263,7 +292,7 @@ Proof.
destruct
intv_valid
.
destruct
intv_valid
.
eapply
Rle_trans
.
eapply
Rle_trans
.
-
eapply
Rmult_le_compat_r
.
-
eapply
Rmult_le_compat_r
.
apply
mEps_geq_zero
.
apply
inj_eps_posR
.
apply
RmaxAbs
;
eauto
.
apply
RmaxAbs
;
eauto
.
-
rewrite
Q2R_mult
in
error_valid
.
-
rewrite
Q2R_mult
in
error_valid
.
rewrite
<-
maxAbs_impl_RmaxAbs
in
error_valid
;
auto
.
rewrite
<-
maxAbs_impl_RmaxAbs
in
error_valid
;
auto
.
...
@@ -324,7 +353,7 @@ Proof.
...
@@ -324,7 +353,7 @@ Proof.
rewrite
Rmult_plus_distr_l
.
rewrite
Rmult_plus_distr_l
.
rewrite
Rmult_1_r
.
rewrite
Rmult_1_r
.
apply
Rmult_le_compat_r
;
try
(
apply
Rabs_pos
).
apply
Rmult_le_compat_r
;
try
(
apply
Rabs_pos
).
apply
mEps_geq_zero
.
apply
inj_eps_posR
.
rewrite
<-
maxAbs_impl_RmaxAbs
.
rewrite
<-
maxAbs_impl_RmaxAbs
.
destruct
intv_valid
.
destruct
intv_valid
.
eapply
RmaxAbs
;
auto
.
eapply
RmaxAbs
;
auto
.
...
@@ -363,7 +392,7 @@ Proof.
...
@@ -363,7 +392,7 @@ Proof.
eapply
Rle_trans
.
eapply
Rle_trans
.
apply
Rplus_le_compat_l
.
apply
Rplus_le_compat_l
.
eapply
Rmult_le_compat_r
.
eapply
Rmult_le_compat_r
.
apply
mEps_geq_zero
.
apply
inj_eps_posR
.
Focus
2.
Focus
2.
rewrite
Qle_bool_iff
in
valid_error
.
rewrite
Qle_bool_iff
in
valid_error
.
apply
Qle_Rle
in
valid_error
.
apply
Qle_Rle
in
valid_error
.
...
@@ -447,7 +476,7 @@ Proof.
...
@@ -447,7 +476,7 @@ Proof.
eapply
Rle_trans
.
eapply
Rle_trans
.
apply
Rplus_le_compat_l
.
apply
Rplus_le_compat_l
.
eapply
Rmult_le_compat_r
.
eapply
Rmult_le_compat_r
.
apply
mEps_geq_zero
.
apply
inj_eps_posR
.
Focus
2.
Focus
2.
apply
valid_error
.
apply
valid_error
.
remember
(
subtractIntv
(
widenIntv
(
e1lo
,
e1hi
)
err1
)
(
widenIntv
(
e2lo
,
e2hi
)
err2
))
as
iv
.
remember
(
subtractIntv
(
widenIntv
(
e1lo
,
e1hi
)
err1
)
(
widenIntv
(
e2lo
,
e2hi
)
err2
))
as
iv
.
...
@@ -995,7 +1024,7 @@ Proof.
...
@@ -995,7 +1024,7 @@ Proof.
destruct
H3
.
destruct
H3
.
unfold
RmaxAbsFun
.
unfold
RmaxAbsFun
.
apply
Rmult_le_compat_r
.
apply
Rmult_le_compat_r
.
apply
mEps_geq_zero
.
apply
inj_eps_posR
.
apply
RmaxAbs
;
subst
;
simpl
in
*
.
apply
RmaxAbs
;
subst
;
simpl
in
*
.
+
rewrite
Q2R_min4
.
+
rewrite
Q2R_min4
.
repeat
rewrite
Q2R_mult
;
repeat
rewrite
Q2R_mult
;
...
@@ -1885,7 +1914,7 @@ Proof.
...
@@ -1885,7 +1914,7 @@ Proof.
{
destruct
valid_div_float
.
{
destruct
valid_div_float
.
unfold
RmaxAbsFun
.
unfold
RmaxAbsFun
.
apply
Rmult_le_compat_r
.
apply
Rmult_le_compat_r
.
apply
mEps_geq_zero
.
apply
inj_eps_posR
.
rewrite
<-
maxAbs_impl_RmaxAbs
.
rewrite
<-
maxAbs_impl_RmaxAbs
.
unfold
RmaxAbsFun
.
unfold
RmaxAbsFun
.
apply
RmaxAbs
;
subst
;
simpl
in
*
.
apply
RmaxAbs
;
subst
;
simpl
in
*
.
...
...
coq/IntervalValidation.v
View file @
10eef967
This diff is collapsed.
Click to expand it.
coq/ssaPrgs.v
View file @
10eef967
...
@@ -49,7 +49,7 @@ Proof.
...
@@ -49,7 +49,7 @@ Proof.
assert
(
NatSet
.
In
n
(
NatSet
.
singleton
n
))
as
in_n
by
(
rewrite
NatSet
.
singleton_spec
;
auto
).
assert
(
NatSet
.
In
n
(
NatSet
.
singleton
n
))
as
in_n
by
(
rewrite
NatSet
.
singleton_spec
;
auto
).
specialize
(
fVars_live
n
in_n
).
specialize
(
fVars_live
n
in_n
).
destruct
fVars_live
as
[
vR
E_def
].
destruct
fVars_live
as
[
vR
E_def
].
exists
vR
;
constructor
;
auto
.
exists
vR
;
e
constructor
;
e
auto
.
-
exists
(
perturb
(
Q2R
v
)
0
);
constructor
.
-
exists
(
perturb
(
Q2R
v
)
0
);
constructor
.
simpl
(
meps
M0
);
rewrite
Rabs_R0
;
rewrite
Q2R0_is_0
;
lra
.
simpl
(
meps
M0
);
rewrite
Rabs_R0
;
rewrite
Q2R0_is_0
;
lra
.
-
assert
(
exists
vR
,
eval_exp
(
toREvalEnv
E
)
(
toREval
(
toRExp
e
))
vR
M0
)
-
assert
(
exists
vR
,
eval_exp
(
toREvalEnv
E
)
(
toREval
(
toRExp
e
))
vR
M0
)
...
@@ -207,13 +207,12 @@ Proof.
...
@@ -207,13 +207,12 @@ Proof.
induction
e
;
intros
v
'
E1
E2
agree_on_vars
.
induction
e
;
intros
v
'
E1
E2
agree_on_vars
.
-
split
;
intros
eval_Var
.
-
split
;
intros
eval_Var
.
+
inversion
eval_Var
;
subst
.
+
inversion
eval_Var
;
subst
.
rewrite
agree_on_vars
in
H4
.
(
*
assert
(
m1
=
M0
)
by
(
apply
ifisMorePreciseM0
;
auto
);
subst
.
*
)
apply
(
Var_load
_
_
_
H1
)
.
rewrite
agree_on_vars
in
H2
.
auto
.
apply
Var_load
;
auto
.
+
inversion
eval_Var
;
subst
.
+
inversion
eval_Var
;
subst
.
rewrite
<-
agree_on_vars
in
H4
.
rewrite
<-
agree_on_vars
in
H2
.
apply
(
Var_load
_
_
_
H1
).
apply
Var_load
;
auto
.
auto
.
-
split
;
intros
eval_Const
;
inversion
eval_Const
;
subst
;
econstructor
;
auto
.
-
split
;
intros
eval_Const
;
inversion
eval_Const
;
subst
;
econstructor
;
auto
.
-
split
;
intros
eval_Unop
;
inversion
eval_Unop
;
subst
;
econstructor
;
try
auto
.
-
split
;
intros
eval_Unop
;
inversion
eval_Unop
;
subst
;
econstructor
;
try
auto
.
+
erewrite
IHe
;
eauto
.
+
erewrite
IHe
;
eauto
.
...
@@ -238,16 +237,16 @@ Proof.
...
@@ -238,16 +237,16 @@ Proof.
revert
E1
E2
vR
.
revert
E1
E2
vR
.
induction
f
;
intros
E1
E2
vR
agree_on_vars
.
induction
f
;
intros
E1
E2
vR
agree_on_vars
.
-
split
;
intros
bstep_Let
;
inversion
bstep_Let
;
subst
.
-
split
;
intros
bstep_Let
;
inversion
bstep_Let
;
subst
.
+
erewrite
shadowing_free_rewriting_exp
in
H
7
;
auto
.
+
erewrite
shadowing_free_rewriting_exp
in
H
5
;
auto
.
econstructor
;
eauto
.
econstructor
;
eauto
.
rewrite
<-
IHf
.
rewrite
<-
IHf
.
apply
H
8
.
apply
H
6
.
intros
n
'
;
unfold
updEnv
.
intros
n
'
;
unfold
updEnv
.
case_eq
(
n
'
=?
n
);
auto
.
case_eq
(
n
'
=?
n
);
auto
.
+
erewrite
<-
shadowing_free_rewriting_exp
in
H
7
;
auto
.
+
erewrite
<-
shadowing_free_rewriting_exp
in
H
5
;
auto
.
econstructor
;
eauto
.
econstructor
;
eauto
.
rewrite
IHf
.
rewrite
IHf
.
apply
H
8
.
apply
H
6
.
intros
n
'
;
unfold
updEnv
.
intros
n
'
;
unfold
updEnv
.
case_eq
(
n
'
=?
n
);
auto
.
case_eq
(
n
'
=?
n
);
auto
.
-
split
;
intros
bstep_Ret
;
inversion
bstep_Ret
;
subst
.
-
split
;
intros
bstep_Ret
;
inversion
bstep_Ret
;
subst
.
...
@@ -281,7 +280,7 @@ Proof.
...
@@ -281,7 +280,7 @@ Proof.
rewrite
valid_vars
in
*
;
congruence
.
rewrite
valid_vars
in
*
;
congruence
.
+
econstructor
.
+
econstructor
.
auto
.
auto
.
rewrite
H
;
auto
.
rewrite
H
;
auto
.
-
inversion
eval_e
;
subst
;
constructor
;
auto
.
-
inversion
eval_e
;
subst
;
constructor
;
auto
.
-
inversion
eval_e
;
subst
;
econstructor
;
eauto
.
-
inversion
eval_e
;
subst
;
econstructor
;
eauto
.
-
simpl
in
valid_vars
.
-
simpl
in
valid_vars
.
...
@@ -322,10 +321,10 @@ Proof.
...
@@ -322,10 +321,10 @@ Proof.
+
unfold
updEnv
in
eval_upd
.
simpl
in
*
.
+
unfold
updEnv
in
eval_upd
.
simpl
in
*
.
inversion
eval_upd
;
subst
.
inversion
eval_upd
;
subst
.
case_eq
(
n
=?
x
);
intros
;
try
auto
.
case_eq
(
n
=?
x
);
intros
;
try
auto
.
*
unfold
toREvalEnv
in
H4
.
rewrite
H
in
H
4
.
*
rewrite
H
in
H
2
.
inversion
H
4
;
subst
;
auto
.
inversion
H
2
;
subst
;
auto
.
*
unfold
toREvalEnv
in
H4
;
rewrite
H
in
H
4
.