Module Qcert.cNRAEnv.Lang.cNRAEnvEq
Require Import String.
Require Import List.
Require Import Compare_dec.
Require Import Equivalence.
Require Import Morphisms.
Require Import Setoid.
Require Import EquivDec.
Require Import Program.
Require Import Utils.
Require Import DataRuntime.
Require Import NRARuntime.
Require Import cNRAEnv.
Require Import cNRAEnvIgnore.
Section cNRAEnvEq.
Local Open Scope string.
Local Open Scope nraenv_core_scope.
Context {
fruntime:
foreign_runtime}.
Local Hint Resolve dnrec_sort_content :
qcert.
Definition nraenv_core_eq (
op1 op2:
nraenv_core) :
Prop :=
forall
(
h:
list(
string*
string))
(
c:
list (
string*
data))
(
dn_c:
Forall (
fun d =>
data_normalized h (
snd d))
c)
(
env:
data)
(
dn_env:
data_normalized h env)
(
x:
data)
(
dn_x:
data_normalized h x),
h ⊢ₑ
op1 @ₑ
x ⊣
c;
env =
h ⊢ₑ
op2 @ₑ
x ⊣
c;
env.
Global Instance nraenv_core_equiv :
Equivalence nraenv_core_eq.
Proof.
Local Hint Resolve dnrec_sort :
qcert.
Global Instance proper_cNRAEnvID :
Proper nraenv_core_eq cNRAEnvID.
Proof.
Global Instance proper_cNRAEnvConst :
Proper (
eq ==>
nraenv_core_eq)
cNRAEnvConst.
Proof.
Global Instance proper_cNRAEnvBinop :
Proper (
binary_op_eq ==>
nraenv_core_eq ==>
nraenv_core_eq ==>
nraenv_core_eq)
cNRAEnvBinop.
Proof.
Global Instance proper_cNRAEnvUnop :
Proper (
unary_op_eq ==>
nraenv_core_eq ==>
nraenv_core_eq)
cNRAEnvUnop.
Proof.
Local Hint Resolve data_normalized_dcoll_in :
qcert.
Global Instance proper_cNRAEnvMap :
Proper (
nraenv_core_eq ==>
nraenv_core_eq ==>
nraenv_core_eq)
cNRAEnvMap.
Proof.
Global Instance proper_cNRAEnvMapProduct :
Proper (
nraenv_core_eq ==>
nraenv_core_eq ==>
nraenv_core_eq)
cNRAEnvMapProduct.
Proof.
unfold Proper,
respectful,
nraenv_core_eq;
simpl;
intros.
rewrite H0 by trivial.
case_eq (
h ⊢ₑ
y0 @ₑ
x1 ⊣
c;
env);
try reflexivity;
simpl.
destruct d;
try reflexivity;
simpl;
intros.
f_equal.
apply omap_product_ext;
intros.
apply H;
qeauto.
Qed.
Global Instance proper_cNRAEnvProduct :
Proper (
nraenv_core_eq ==>
nraenv_core_eq ==>
nraenv_core_eq)
cNRAEnvProduct.
Proof.
Global Instance proper_cNRAEnvSelect :
Proper (
nraenv_core_eq ==>
nraenv_core_eq ==>
nraenv_core_eq)
cNRAEnvSelect.
Proof.
unfold Proper,
respectful,
nraenv_core_eq;
intros;
simpl.
rewrite H0 by trivial.
case_eq (
h ⊢ₑ
y0 @ₑ
x1 ⊣
c;
env);
intros;
trivial.
destruct d;
try reflexivity;
simpl.
f_equal.
apply lift_filter_ext;
intros.
rewrite H;
qeauto.
Qed.
Global Instance proper_cNRAEnvDefault :
Proper (
nraenv_core_eq ==>
nraenv_core_eq ==>
nraenv_core_eq)
cNRAEnvDefault.
Proof.
Global Instance proper_cNRAEnvEither :
Proper (
nraenv_core_eq ==>
nraenv_core_eq ==>
nraenv_core_eq)
cNRAEnvEither.
Proof.
Global Instance proper_cNRAEnvEitherConcat :
Proper (
nraenv_core_eq ==>
nraenv_core_eq ==>
nraenv_core_eq)
cNRAEnvEitherConcat.
Proof.
Global Instance proper_cNRAEnvApp :
Proper (
nraenv_core_eq ==>
nraenv_core_eq ==>
nraenv_core_eq)
cNRAEnvApp.
Proof.
unfold Proper,
respectful,
nraenv_core_eq;
intros;
simpl.
rewrite H0 by trivial.
case_eq (
h ⊢ₑ
y0 @ₑ
x1 ⊣
c;
env);
intros;
trivial;
simpl.
qeauto.
Qed.
Global Instance proper_cNRAEnvGetConstant s :
Proper (
nraenv_core_eq) (
cNRAEnvGetConstant s).
Proof.
Global Instance proper_cNRAEnvEnv :
Proper (
nraenv_core_eq)
cNRAEnvEnv.
Proof.
Global Instance proper_cNRAEnvAppEnv :
Proper (
nraenv_core_eq ==>
nraenv_core_eq ==>
nraenv_core_eq)
cNRAEnvAppEnv.
Proof.
unfold Proper,
respectful,
nraenv_core_eq;
intros;
simpl.
rewrite H0 by trivial.
case_eq (
h ⊢ₑ
y0 @ₑ
x1 ⊣
c;
env);
intros;
simpl;
trivial.
apply H;
qeauto.
Qed.
Global Instance proper_cNRAEnvMapEnv :
Proper (
nraenv_core_eq ==>
nraenv_core_eq)
cNRAEnvMapEnv.
Proof.
Lemma nraenv_core_of_nra_proper :
Proper (
nra_eq ==>
nraenv_core_eq)
nraenv_core_of_nra.
Proof.
Notation "
X ≡ₑ
Y" := (
nraenv_core_eq X Y) (
at level 90).
Lemma nraenv_core_of_nra_proper_inv x y :
(
nraenv_core_of_nra x ≡ₑ
nraenv_core_of_nra y)%
nraenv_core ->
(
x ≡ₐ
y)%
nra.
Proof.
Lemma nra_of_nraenv_core_proper_inv x y :
(
nra_of_nraenv_core x ≡ₐ
nra_of_nraenv_core y)%
nra ->
(
x ≡ₑ
y)%
nraenv_core.
Proof.
Definition nraenv_core_always_ensures (
P:
data->
Prop) (
q:
nraenv_core) :=
forall
(
h:
list(
string*
string))
(
c:
list (
string*
data))
(
dn_c:
Forall (
fun d =>
data_normalized h (
snd d))
c)
(
env:
data)
(
dn_env:
data_normalized h env)
(
x:
data)
(
dn_x:
data_normalized h x)
(
d:
data),
h ⊢ₑ
q @ₑ
x ⊣
c;
env =
Some d ->
P d.
End cNRAEnvEq.
Notation "
X ≡ₑ
Y" := (
nraenv_core_eq X Y) (
at level 90) :
nraenv_core_scope.