Module EITyping
From Coq Require Import List.
Import List.ListNotations.
Open Scope list_scope.
From Coq Require Import Recdef.
From Velus Require Import Common.
From Velus Require Import CommonProgram.
From Velus Require Import Operators.
From Velus Require Import Clocks.
From Velus Require Import Environment.
From Velus Require Import CoreExpr.CESyntax.
From Velus Require Import CoreExpr.CETyping.
From Velus Require Import NLustre.NLSyntax.
From Velus Require Import NLustre.NLTyping.
From Velus Require Import NLustre.NLOrdered.
From Velus Require Import NLustre.ExprInlining.EI.
Module Type EITYPING
(
Import Ids :
IDS)
(
Import Op :
OPERATORS)
(
Import OpAux :
OPERATORS_AUX Ids Op)
(
Import Cks :
CLOCKS Ids Op OpAux)
(
Import CESyn :
CESYNTAX Ids Op OpAux Cks)
(
Import CETyp :
CETYPING Ids Op OpAux Cks CESyn)
(
Import Syn :
NLSYNTAX Ids Op OpAux Cks CESyn)
(
Import Ord :
NLORDERED Ids Op OpAux Cks CESyn Syn)
(
Import Typ :
NLTYPING Ids Op OpAux Cks CESyn Syn Ord CETyp)
(
Import EI :
EI Ids Op OpAux Cks CESyn Syn).
Lemma inlinable_wt G Γ :
forall vars eqs,
NoDupMembers Γ ->
Forall (
wt_equation G Γ)
eqs ->
Forall (
fun '(
x,
e) =>
wt_cexp G.(
types) Γ
e
/\
forall ty islast,
In (
x, (
ty,
islast)) Γ ->
typeofc e =
ty) (
inlinable vars eqs).
Proof.
intros *
Nd Wt.
unfold inlinable.
simpl_Forall.
simpl_In.
simpl_Forall.
clear Hf.
cases.
inv Hf0.
inv Wt.
take (
wt_rhs _ _ _ _)
and inv it.
simpl in *.
split;
auto.
intros *
Hin.
eapply NoDupMembers_det in H2;
eauto.
now inv H2.
Qed.
Section inline_typeof.
Variable (
G :
global) (Γ :
list (
ident * (
type *
bool))).
Variable (
x :
ident).
Section inline_exp.
Variable (
xe :
exp).
Hypothesis Wt2 :
forall ty islast,
In (
x, (
ty,
islast)) Γ ->
typeof xe =
ty.
Lemma inline_in_exp_typeof :
forall e,
wt_exp G.(
types) Γ
e ->
typeof (
inline_in_exp x xe e) =
typeof e.
Proof.
induction e;
intros *
Wt;
inv Wt;
simpl;
auto.
cases_eqn Eq;
auto.
rewrite equiv_decb_equiv in Eq.
inv Eq;
eauto.
Qed.
End inline_exp.
Section inline_cexp.
Variable (
xe :
cexp).
Hypothesis Wt2 :
forall ty islast,
In (
x, (
ty,
islast)) Γ ->
typeofc xe =
ty.
Lemma try_inline_in_exp_typeof :
forall e,
wt_exp G.(
types) Γ
e ->
typeof (
try_inline_in_exp x xe e) =
typeof e.
Proof.
Lemma inline_in_cexp_typeofc :
forall e,
wt_cexp G.(
types) Γ
e ->
typeofc (
inline_in_cexp x xe e) =
typeofc e.
Proof.
End inline_cexp.
End inline_typeof.
Section inline.
Variable (
G :
global) (Γ :
list (
ident * (
type *
bool))).
Variable (
x :
ident).
Section inline_exp.
Variable (
xe :
exp).
Hypothesis Wt1 :
wt_exp G.(
types) Γ
xe.
Hypothesis Wt2 :
forall ty islast,
In (
x, (
ty,
islast)) Γ ->
typeof xe =
ty.
Lemma inline_in_exp_wt :
forall e,
wt_exp G.(
types) Γ
e ->
wt_exp G.(
types) Γ (
inline_in_exp x xe e).
Proof.
induction e;
simpl;
auto;
intros *
Wt;
inv Wt.
-
cases;
eauto with nltyping.
-
eauto with nltyping.
-
constructor;
auto.
erewrite inline_in_exp_typeof;
eauto.
-
constructor;
auto.
erewrite 2
inline_in_exp_typeof;
eauto.
Qed.
End inline_exp.
Section inline_cexp.
Variable (
xe :
cexp).
Hypothesis Wt1 :
wt_cexp G.(
types) Γ
xe.
Hypothesis Wt2 :
forall ty islast,
In (
x, (
ty,
islast)) Γ ->
typeofc xe =
ty.
Lemma try_inline_in_exp_wt :
forall e,
wt_exp G.(
types) Γ
e ->
wt_exp G.(
types) Γ (
try_inline_in_exp x xe e).
Proof.
Lemma inline_in_cexp_wt :
forall ce,
wt_cexp G.(
types) Γ
ce ->
wt_cexp G.(
types) Γ (
inline_in_cexp x xe ce).
Proof.
Lemma inline_in_equation_wt :
forall equ,
wt_equation G Γ
equ ->
wt_equation G Γ (
inline_in_equation x xe equ).
Proof.
End inline_cexp.
End inline.
Lemma exp_inlining_node_wt :
forall G n,
wt_node G n ->
wt_node (
exp_inlining G) (
exp_inlining_node n).
Proof.
Theorem exp_inlining_wt :
forall G,
wt_global G ->
wt_global (
exp_inlining G).
Proof.
End EITYPING.
Module EITypingFun
(
Ids :
IDS)
(
Op :
OPERATORS)
(
OpAux :
OPERATORS_AUX Ids Op)
(
Cks :
CLOCKS Ids Op OpAux)
(
CESyn :
CESYNTAX Ids Op OpAux Cks)
(
CETyp :
CETYPING Ids Op OpAux Cks CESyn)
(
Syn :
NLSYNTAX Ids Op OpAux Cks CESyn)
(
Ord :
NLORDERED Ids Op OpAux Cks CESyn Syn)
(
Typ :
NLTYPING Ids Op OpAux Cks CESyn Syn Ord CETyp)
(
EI :
EI Ids Op OpAux Cks CESyn Syn)
<:
EITYPING Ids Op OpAux Cks CESyn CETyp Syn Ord Typ EI.
Include EITYPING Ids Op OpAux Cks CESyn CETyp Syn Ord Typ EI.
End EITypingFun.