Module Abs
From Coq Require Import Datatypes List.
Import List.ListNotations.
From Velus Require Import Common.
From Velus Require Import CommonList.
From Velus Require Import CommonTyping.
From Velus Require Import Operators.
From Velus Require Import Clocks.
From Velus Require Import Lustre.StaticEnv.
From Velus Require Import Lustre.LSyntax Lustre.LTyping Lustre.LOrdered.
From Velus Require Import Lustre.Denot.Cpo.
Require Import CommonDS SDfuns SD CommonList2.
Pas de réaction et pas de changement d'état en cas d'absence, soit
* f (abs.x) = abs.f(x)
* remarque : ça n'est pas vrai en signal, à cause de la construction default
Module Type ABS_INDEP
(
Import Ids :
IDS)
(
Import Op :
OPERATORS)
(
Import OpAux :
OPERATORS_AUX Ids Op)
(
Import Cks :
CLOCKS Ids Op OpAux)
(
Import Senv :
STATICENV Ids Op OpAux Cks)
(
Import Syn :
LSYNTAX Ids Op OpAux Cks Senv)
(
Import Typ :
LTYPING Ids Op OpAux Cks Senv Syn)
(
Import Lord :
LORDERED Ids Op OpAux Cks Senv Syn)
(
Import Den :
SD Ids Op OpAux Cks Senv Syn Lord).
Résultats généraux sur l'indépendance aux absences
Lemma np_of_env_abs :
forall l env,
np_of_env l (
APP_env abs_env env) <=
lift (
CONS abs) (
np_of_env l env).
Proof.
Lemma env_of_np_abs :
forall l (
np :
nprod (
length l)),
env_of_np l (
lift (
CONS abs)
np) <=
APP_env abs_env (
env_of_np l np).
Proof.
Lemma env_of_np_ext_abs :
forall l n (
np :
nprod n)
acc,
n =
length l ->
env_of_np_ext l (
lift (
CONS abs)
np) (
APP_env abs_env acc)
==
APP_env abs_env (
env_of_np_ext l np acc).
Proof.
On montre que chaque opérateur du langage a cette propriété
Lemma abs_indep_fby :
forall A (
xs ys :
DS (
sampl A)),
fby (
cons abs xs) (
cons abs ys) ==
cons abs (
fby xs ys).
Proof.
Corollary abs_indep_lift_fby :
forall A n (
xs ys : @
nprod (
DS (
sampl A))
n),
lift2 fby (
lift (
CONS abs)
xs) (
lift (
CONS abs)
ys)
==
lift (
CONS abs) (
lift2 fby xs ys).
Proof.
Lemma abs_indep_swhenv :
forall b xs cs,
swhenv b (
cons abs xs) (
cons abs cs) ==
cons abs (
swhenv b xs cs).
Proof.
Corollary abs_indep_lift_swhenv :
forall b n (
np :
nprod n)
cs,
llift (
swhenv b) (
lift (
CONS abs)
np) (
cons abs cs)
==
lift (
CONS abs) (
llift (
swhenv b)
np cs).
Proof.
Lemma abs_indep_smergev :
forall l xs np,
smergev l (
cons abs xs) (
lift (
CONS abs)
np) ==
cons abs (
smergev l xs np).
Proof.
Corollary abs_indep_lift_smergev :
forall l xs n (
np : @
nprod (
nprod n) _),
lift_nprod (
smergev l (
cons abs xs)) (
lift (
lift (
CONS abs))
np)
==
lift_nprod (
CONS abs @_
smergev l xs)
np.
Proof.
Lemma abs_indep_scasev :
forall l xs np,
scasev l (
cons abs xs) (
lift (
CONS abs)
np) ==
cons abs (
scasev l xs np).
Proof.
Corollary abs_indep_lift_scasev :
forall l xs n (
np : @
nprod (
nprod n) _),
lift_nprod (
scasev l (
cons abs xs)) (
lift (
lift (
CONS abs))
np)
==
lift_nprod (
CONS abs @_
scasev l xs)
np.
Proof.
Lemma abs_indep_scase_defv :
forall l xs ds np,
scase_defv l (
cons abs xs) (
nprod_cons (
cons abs ds) (
lift (
CONS abs)
np))
==
cons abs (
scase_defv l xs (
nprod_cons ds np)).
Proof.
Corollary abs_indep_lift_scase_defv :
forall l xs n ds (
np : @
nprod (
nprod n) _),
lift_nprod (
scase_defv l (
cons abs xs)) (
nprod_cons (
lift (
CONS abs)
ds) (
lift (
lift (
CONS abs))
np))
==
lift_nprod (
CONS abs @_
scase_defv l xs) (
nprod_cons ds np).
Proof.
Lemma abs_indep_sreset_aux :
forall f bs (
X Y :
DS_prod SI),
sreset_aux f (
cons false bs) (
APP_env abs_env X) (
APP_env abs_env Y)
==
APP_env abs_env (
sreset_aux f bs X Y).
Proof.
Lemma bss_app_abs :
forall l (
env :
DS_prod SI),
bss l (
APP_env abs_env env) ==
cons false (
bss l env).
Proof.
Lemma sbools_of_abs :
forall n (
np :
nprod n),
sbools_of (
lift (
CONS abs)
np) ==
cons false (
sbools_of np).
Proof.
Raisonnement sur les nœuds
Section Abs_indep_node.
Context {
PSyn :
list decl ->
block ->
Prop}.
Context {
Prefs :
PS.t}.
Variables
(
G : @
global PSyn Prefs)
(
envG :
Dprodi FI).
Hypothesis Hnode :
forall f envI,
envG f (
APP_env abs_env envI) <=
APP_env abs_env (
envG f envI).
Lemma lift_IH :
forall ins es envG envI env aenv,
Forall (
fun e =>
denot_exp G ins e envG (
APP_env abs_env envI)
aenv
<=
lift (
CONS abs) (
denot_exp G ins e envG envI env))
es ->
denot_exps G ins es envG (
APP_env abs_env envI)
aenv
<=
lift (
CONS abs) (
denot_exps G ins es envG envI env).
Proof.
Lemma lift_IHs :
forall ins (
ess :
list (
enumtag * _))
n envG envI env aenv,
Forall (
fun es =>
Forall (
fun e =>
denot_exp G ins e envG (
APP_env abs_env envI)
aenv
<=
lift (
CONS abs) (
denot_exp G ins e envG envI env)) (
snd es))
ess ->
denot_expss G ins ess n envG (
APP_env abs_env envI)
aenv
<=
lift (
lift (
CONS abs)) (
denot_expss G ins ess n envG envI env).
Proof.
Lemma var_abs_le :
forall ins x envI env aenv,
aenv <=
APP_env abs_env env ->
denot_var ins (
APP_env abs_env envI)
aenv x
<=
cons abs (
denot_var ins envI env x).
Proof.
Lemma abs_indep_exp :
forall Γ ins e envI env aenv,
wt_exp G Γ e ->
wl_exp G e ->
aenv <=
APP_env abs_env env ->
denot_exp G ins e envG (
APP_env abs_env envI)
aenv
<=
lift (
CONS abs) (
denot_exp G ins e envG envI env).
Proof.
intros *
Hwt Hwl Hle.
induction e using exp_ind2;
try apply Dbot.
-
rewrite 2
denot_exp_eq.
unfold sconst.
rewrite MAP_map,
bss_app_abs,
map_eq_cons;
auto.
-
rewrite 2
denot_exp_eq.
unfold sconst.
rewrite MAP_map,
bss_app_abs,
map_eq_cons;
auto.
-
rewrite 2
denot_exp_eq.
now apply var_abs_le.
-
inv Hwt.
inv Hwl.
rewrite 2 (
denot_exp_eq _ _ (
Eunop _ _ _)).
revert IHe.
gen_sub_exps.
take (
numstreams _ = _)
and rewrite it.
take (
typeof _ = _)
and rewrite it.
cbv zeta;
intros t1 t2 IHe.
eapply Ole_trans with (
sunop _ (
lift _
t1));
auto.
setoid_rewrite (
CONS_simpl abs).
now rewrite sunop_eq.
-
inv Hwt.
inv Hwl.
rewrite 2 (
denot_exp_eq _ _ (
Ebinop _ _ _ _)).
revert IHe1 IHe2.
gen_sub_exps.
do 2 (
take (
numstreams _ = _)
and rewrite it;
clear it).
do 2 (
take (
typeof _ = _)
and rewrite it;
clear it).
cbv zeta;
intros t1 t2 t3 t4 IHe1 IHe2.
eapply Ole_trans with (
sbinop _ (
lift _
t3) (
lift _
t1));
auto.
setoid_rewrite (
CONS_simpl abs).
now rewrite sbinop_eq.
-
inv Hwt.
inv Hwl.
apply Forall_impl_inside with (
P :=
wt_exp _ _)
in H,
H0;
auto.
apply Forall_impl_inside with (
P :=
wl_exp _ )
in H,
H0;
auto.
apply lift_IH in H,
H0;
revert H H0.
rewrite 2 (
denot_exp_eq _ _ (
Efby _ _ _)).
gen_sub_exps.
rewrite annots_numstreams in *.
simpl;
unfold eq_rect;
cases;
try congruence.
intros t1 t2 t3 t4 Le1 Le2.
rewrite <-
abs_indep_lift_fby;
auto.
-
inv Hwt.
inv Hwl.
apply Forall_impl_inside with (
P :=
wt_exp _ _)
in H;
auto.
apply Forall_impl_inside with (
P :=
wl_exp _ )
in H;
auto.
apply lift_IH in H;
revert H.
rewrite 2 (
denot_exp_eq _ _ (
Ewhen _ _ _ _)).
gen_sub_exps.
rewrite annots_numstreams in *.
simpl;
unfold eq_rect;
cases;
try congruence.
intros t1 t2 Le.
rewrite <-
abs_indep_lift_swhenv.
auto using var_abs_le.
-
inv Hwt.
inv Hwl.
rewrite 2 (
denot_exp_eq _ _ (
Emerge _ _ _)).
pose proof (
IH :=
lift_IHs ins es (
length tys)
envG envI env aenv).
eassert (
Le: _ <= _); [
apply IH;
simpl_Forall;
auto|
clear IH].
cbv zeta;
revert Le.
gen_sub_exps;
intros t1 t2 Le.
unfold eq_rect_r,
eq_rect,
eq_sym;
cases.
rewrite lift_lift_nprod, <-
abs_indep_lift_smergev.
auto using var_abs_le.
-
destruct d as [
des|].
{
inv Hwt.
inv Hwl.
set (
typesof des)
as tys.
apply Forall_impl_inside with (
P :=
wt_exp _ _)
in H0;
auto.
apply Forall_impl_inside with (
P :=
wl_exp _ )
in H0;
auto.
apply lift_IH in H0.
pose proof (
IH :=
lift_IHs ins es (
length tys)
envG envI env aenv).
eassert (
Le: _ <= _); [
apply IH;
simpl_Forall;
auto|
clear H IH].
rewrite 2 (
denot_exp_eq _ _ (
Ecase _ _ _ _)).
cbv zeta;
revert IHe H0 Le;
gen_sub_exps.
assert (
Hl :
list_sum (
List.map numstreams des) =
length tys)
by (
subst tys;
now rewrite length_typesof_annots,
annots_numstreams).
take (
numstreams e = 1)
and rewrite it,
Hl.
simpl (
numstreams _).
unfold eq_rect_r,
eq_rect,
eq_sym;
cases;
try congruence.
intros t1 t2 t3 t4 t5 t6 Le1 Le2 Le3.
rewrite lift_lift_nprod, <-
abs_indep_lift_scase_defv;
auto. }
{
inv Hwt.
inv Hwl.
rewrite 2 (
denot_exp_eq _ _ (
Ecase _ _ _ _)).
pose proof (
IH :=
lift_IHs ins es (
length tys)
envG envI env aenv).
eassert (
Le: _ <= _); [
apply IH;
simpl_Forall;
auto|
clear IH].
cbv zeta;
revert IHe Le;
gen_sub_exps.
take (
numstreams e = 1)
and rewrite it.
unfold eq_rect_r,
eq_rect,
eq_sym;
cases.
intros t1 t2 t3 t4 Le1 Le2.
rewrite lift_lift_nprod, <-
abs_indep_lift_scasev;
auto. }
-
inv Hwt.
inv Hwl.
apply Forall_impl_inside with (
P :=
wt_exp _ _)
in H,
H0;
auto.
apply Forall_impl_inside with (
P :=
wl_exp _ )
in H,
H0;
auto.
apply lift_IH in H,
H0;
revert H H0.
rewrite 2 (
denot_exp_eq _ _ (
Eapp _ _ _ _)).
gen_sub_exps.
take (
find_node f G = _)
and rewrite it in *.
repeat take (
Some _ =
Some _)
and inv it.
assert (
Hl :
list_sum (
List.map numstreams es) =
length (
idents (
n_in n)))
by (
now unfold idents;
rewrite length_map,
annots_numstreams in * ).
simpl;
take (
length a = _)
and rewrite it,
Hl.
unfold eq_rect;
cases;
try (
rewrite length_map in *;
tauto).
intros t1 t2 t3 t4 Le1 Le2.
rewrite 2
sreset_eq, <-
np_of_env_abs.
rewrite <-
abs_indep_sreset_aux, <-
sbools_of_abs.
apply fcont_monotonic,
fcont_le_compat3;
eauto 3
using env_of_np_abs.
eapply Ole_trans,
Hnode;
eauto using env_of_np_abs.
Qed.
Corollary abs_indep_exps :
forall Γ ins es envI env aenv,
Forall (
wt_exp G Γ)
es ->
Forall (
wl_exp G)
es ->
aenv <=
APP_env abs_env env ->
denot_exps G ins es envG (
APP_env abs_env envI)
aenv
<=
lift (
CONS abs) (
denot_exps G ins es envG envI env).
Proof.
Lemma abs_indep_block :
forall Γ ins blk envI env aenv acc aacc,
wt_block G Γ blk ->
wl_block G blk ->
aenv <=
APP_env abs_env env ->
aacc <=
APP_env abs_env acc ->
denot_block G ins blk envG (
APP_env abs_env envI)
aenv aacc
<=
APP_env abs_env (
denot_block G ins blk envG envI env acc).
Proof.
Lemma abs_le_node :
forall n envI env aenv,
wt_node G n ->
aenv <=
APP_env abs_env env ->
denot_node G n envG (
APP_env abs_env envI)
aenv
<=
APP_env abs_env (
denot_node G n envG envI env).
Proof.
End Abs_indep_node.
Theorem abs_indep_global :
forall {
PSyn Prefs} (
G : @
global PSyn Prefs),
wt_global G ->
forall f envI,
denot_global G f (
APP_env abs_env envI)
<=
APP_env abs_env (
denot_global G f envI).
Proof.
End ABS_INDEP.
Module AbsIndepFun
(
Ids :
IDS)
(
Op :
OPERATORS)
(
OpAux :
OPERATORS_AUX Ids Op)
(
Cks :
CLOCKS Ids Op OpAux)
(
Senv :
STATICENV Ids Op OpAux Cks)
(
Syn :
LSYNTAX Ids Op OpAux Cks Senv)
(
Typ :
LTYPING Ids Op OpAux Cks Senv Syn)
(
Lord :
LORDERED Ids Op OpAux Cks Senv Syn)
(
Den :
SD Ids Op OpAux Cks Senv Syn Lord)
<:
ABS_INDEP Ids Op OpAux Cks Senv Syn Typ Lord Den.
Include ABS_INDEP Ids Op OpAux Cks Senv Syn Typ Lord Den.
End AbsIndepFun.