From Velus Require Import Common.
From Velus Require Import Operators.
From Velus Require Import Environment.
From Velus Require Import Clocks.
From Velus Require Export IndexedStreams.
From Velus Require Import CoreExpr.CESyntax.
From Velus Require Import CoreExpr.CETyping.
From Velus Require Import CoreExpr.CESemantics.
From Velus Require Import CoreExpr.CEIsFree.
Import List.
Properties of Core Expressions
Module Type CEPROPERTIES
(
Ids :
IDS)
(
Op :
OPERATORS)
(
OpAux :
OPERATORS_AUX Op)
(
Import Syn :
CESYNTAX Op)
(
Import Str :
INDEXEDSTREAMS Op OpAux)
(
Import Sem :
CESEMANTICS Ids Op OpAux Syn Str)
(
Import Typ :
CETYPING Ids Op Syn)
(
Import IsF :
CEISFREE Ids Op Syn).
Lemma sem_var_instant_switch_env:
forall R R'
x v,
Env.find x R =
Env.find x R' ->
sem_var_instant R x v <->
sem_var_instant R'
x v.
Proof.
Lemma sem_exp_instant_switch_env:
forall b R R'
e v,
(
forall x,
Is_free_in_exp x e ->
Env.find x R =
Env.find x R') ->
sem_exp_instant b R e v <->
sem_exp_instant b R'
e v.
Proof.
Lemma sem_exps_instant_switch_env:
forall b R R'
es vs,
(
forall x,
Exists (
Is_free_in_exp x)
es ->
Env.find x R =
Env.find x R') ->
sem_exps_instant b R es vs <->
sem_exps_instant b R'
es vs.
Proof.
induction es as [|
e es IH].
now split;
inversion 1;
subst;
auto.
intros vs HH.
destruct vs.
now split;
inversion 1.
repeat rewrite sem_exps_instant_cons.
rewrite IH;
auto.
now rewrite sem_exp_instant_switch_env with (
R':=
R');
auto.
Qed.
Lemma sem_cexp_instant_switch_env:
forall b R R'
e v,
(
forall x,
Is_free_in_cexp x e ->
Env.find x R =
Env.find x R') ->
sem_cexp_instant b R e v <->
sem_cexp_instant b R'
e v.
Proof.
Lemma sem_clock_instant_switch_env:
forall b R R'
ck v,
(
forall x,
Is_free_in_clock x ck ->
Env.find x R =
Env.find x R') ->
sem_clock_instant b R ck v <->
sem_clock_instant b R'
ck v.
Proof.
Lemma sem_aexp_instant_switch_env:
forall b R R'
ck e v,
(
forall x,
Is_free_in_clock x ck \/
Is_free_in_exp x e ->
Env.find x R =
Env.find x R') ->
sem_aexp_instant b R ck e v <->
sem_aexp_instant b R'
ck e v.
Proof.
Lemma sem_caexp_instant_switch_env:
forall b R R'
ck e v,
(
forall x,
Is_free_in_clock x ck \/
Is_free_in_cexp x e ->
Env.find x R =
Env.find x R') ->
sem_caexp_instant b R ck e v <->
sem_caexp_instant b R'
ck e v.
Proof.
Ltac solve_switch_env_obligation :=
match goal with
| [
Henv:
Env.refines ?
R ?
env1 ?
env2 |-
forall x, ?
P ->
Env.find x ?
env2 =
Env.find x ?
Env1] =>
let y :=
fresh "
y"
in
let H :=
fresh "
H"
in
intros y H;
try match type of H with _ \/
_ =>
destruct H end;
(
apply Env.refines_orel_find with (
x0:=
y)
in Henv;
auto;
symmetry;
apply orel_eq,
Henv)
| [
Henv:
Env.refines ?
R ?
env1 ?
env2 |-
Env.find ?
x ?
env2 =
Env.find ?
x ?
Env1] =>
apply Env.refines_orel_find with (
x0:=
x)
in Henv;
auto;
symmetry;
apply orel_eq,
Henv
end.
Well-typed expressions and free variables
Lemma Is_free_in_wt_exp:
forall (
xs :
list (
ident * (
Op.type *
clock)))
x e,
Is_free_in_exp x e ->
wt_exp (
idty xs)
e ->
InMembers x xs.
Proof.
induction e;
inversion_clear 1;
inversion_clear 1;
eauto using idty_InMembers.
take (
_ \/
_)
and destruct it;
auto.
Qed.
Lemma Is_free_in_wt_clock:
forall (
xs :
list (
ident * (
Op.type *
clock)))
x ck,
Is_free_in_clock x ck ->
wt_clock (
idty xs)
ck ->
InMembers x xs.
Proof.
induction ck;
inversion_clear 1;
inversion_clear 1;
eauto using idty_InMembers.
Qed.
Lemma Is_free_in_wt_aexps:
forall (
xs :
list (
ident * (
Op.type *
clock)))
x ck es,
Is_free_in_aexps x ck es ->
Forall (
wt_exp (
idty xs))
es ->
wt_clock (
idty xs)
ck ->
InMembers x xs.
Proof.
Lemma Is_free_in_wt_cexp:
forall (
xs :
list (
ident * (
Op.type *
clock)))
x e,
Is_free_in_cexp x e ->
wt_cexp (
idty xs)
e ->
InMembers x xs.
Proof.
Lemma Is_free_in_wt_aexp:
forall (
xs :
list (
ident * (
Op.type *
clock)))
x ck e,
Is_free_in_aexp x ck e ->
wt_exp (
idty xs)
e ->
wt_clock (
idty xs)
ck ->
InMembers x xs.
Proof.
Lemma Is_free_in_wt_caexp:
forall (
xs :
list (
ident * (
Op.type *
clock)))
x ck e,
Is_free_in_caexp x ck e ->
wt_cexp (
idty xs)
e ->
wt_clock (
idty xs)
ck ->
InMembers x xs.
Proof.
End CEPROPERTIES.
Module CEProperties
(
Ids :
IDS)
(
Op :
OPERATORS)
(
OpAux :
OPERATORS_AUX Op)
(
Import Syn :
CESYNTAX Op)
(
Str :
INDEXEDSTREAMS Op OpAux)
(
Import Sem :
CESEMANTICS Ids Op OpAux Syn Str)
(
Import Typ :
CETYPING Ids Op Syn)
(
Import IsF :
CEISFREE Ids Op Syn)
<:
CEPROPERTIES Ids Op OpAux Syn Str Sem Typ IsF.
Include CEPROPERTIES Ids Op OpAux Syn Str Sem Typ IsF.
End CEProperties.