Qcert.NRAEnv.Typing.TNRAEnv
Typing for NRA
Section typ.
Context {m:basic_model}.
Context (τconstants:list (string×rtype)).
Definition nraenv_type (q:nraenv) : rtype → rtype → rtype → Prop :=
@cnraenv_type m τconstants (cnraenv_of_nraenv q).
End typ.
Notation "Op ▷ₓ A >=> B ⊣ C ; E" := (nraenv_type C Op E A B) (at level 70).
Context {m:basic_model}.
Context (τconstants:list (string×rtype)).
Definition nraenv_type (q:nraenv) : rtype → rtype → rtype → Prop :=
@cnraenv_type m τconstants (cnraenv_of_nraenv q).
End typ.
Notation "Op ▷ₓ A >=> B ⊣ C ; E" := (nraenv_type C Op E A B) (at level 70).
Type lemmas for individual algebraic expressions
Main typing soundness theorem for the NRA
Lemma typed_nraenv_yields_typed_cnraenv {τc τenv τin τout} (op:nraenv):
(op ▷ₓ τin >=> τout ⊣ τc;τenv) → cnraenv_type τc (cnraenv_of_nraenv op) τenv τin τout.
Lemma typed_cnraenv_yields_typed_nraenv {τc τenv τin τout} (op:nraenv):
cnraenv_type τc (cnraenv_of_nraenv op) τenv τin τout → (op ▷ₓ τin >=> τout ⊣ τc;τenv).
Theorem typed_cnraenv_iff_typed_nraenv {τc τenv τin τout} (op:nraenv):
(op ▷ₓ τin >=> τout ⊣ τc;τenv) ↔ cnraenv_type τc (cnraenv_of_nraenv op) τenv τin τout.
Theorem typed_nraenv_yields_typed_data {τc τenv τin τout} c (env:data) (d:data) (op:nraenv):
bindings_type c τc →
(env ▹ τenv) → (d ▹ τin) → (op ▷ₓ τin >=> τout ⊣ τc;τenv) →
(∃ x, (nraenv_eval brand_relation_brands c op env d = Some x ∧ (x ▹ τout))).
Corrolaries of the main type soudness theorem
Definition typed_nraenv_total {τc τenv τin τout} (op:nraenv) (HOpT: op ▷ₓ τin >=> τout ⊣ τc;τenv) c (env:data) (d:data):
bindings_type c τc →
(env ▹ τenv) →
(d ▹ τin) →
{ x:data | x ▹ τout }.
Definition tnraenv_eval {τc τenv τin τout} (op:nraenv) (HOpT: op ▷ₓ τin >=> τout ⊣ τc;τenv) c (env:data) (d:data):
bindings_type c τc →
(env ▹ τenv) → (d ▹ τin) → data.
End prop.
End TNRAEnv.
Notation "Op ▷ₓ A >=> B ⊣ C ; E" := (nraenv_type C Op E A B) (at level 70).
Notation "Op @▷ₓ d ⊣ C ; e" := (tnraenv_eval C Op e d) (at level 70).