Qcert.Translation.TCAMPtoNRA
Auxiliary definitions and lemmas for the types corresponding to the encoding of input/output(s) of Patterns in the NRA
Context {m:basic_model}.
Definition pat_context_type tconst tbind tpid : rtype :=
Rec Closed (("PBIND",tbind) :: ("PCONST",tconst) :: ("PDATA",tpid) :: nil) (eq_refl _).
Definition pat_wrap_a1_type tconst tbind tpid : rtype :=
Rec Closed (("PBIND",tbind) :: ("PCONST",tconst) :: ("a1",tpid) :: nil) (eq_refl _).
Lemma ATpat_match {n τin τout} :
n ▷ τin >=> τout →
pat_match n ▷ τin >=> Coll τout.
Lemma ATpat_match_inv {n τin τout} :
pat_match n ▷ τin >=> τout →
∃ τout', τout = Coll τout' ∧ n ▷ τin >=> τout'.
Lemma ATpat_match_invcoll {n τin τout} :
pat_match n ▷ τin >=> Coll τout →
n ▷ τin >=> τout .
Auxiliary lemmas specific to some of the NRA expressions used in
the translation
Lemma ATdot {p s τin τ pf τout k}:
p ▷ τin >=> Rec k τ pf →
tdot τ s = Some τout →
AUnop (ADot s) p ▷ τin >=> τout.
Lemma ATdot_inv {p s τin τout}:
AUnop (ADot s) p ▷ τin >=> τout →
∃ τ pf k,
p ▷ τin >=> Rec k τ pf ∧
tdot τ s = Some τout.
Lemma ATpat_data τc τ τin :
pat_data ▷ pat_context_type τc τ τin >=> τin.
Lemma ATunnest_two (s1 s2:string) (op:nra) τin τ₁ pf1 τs τrem pf2 :
op ▷ τin >=> (Coll (Rec Closed τ₁ pf1)) →
tdot τ₁ s1 = Some (Coll τs) →
τrem = (rremove (rec_concat_sort τ₁ ((s2,τs)::nil)) s1) →
unnest_two s1 s2 op ▷
τin >=> Coll (Rec Closed τrem pf2).
Lemma Coll_proj1 τ :
proj1_sig (Coll τ) = Coll₀ (proj1_sig τ).
Lemma ATunnest_two_inv {s1 s2:string} {op:nra} {τin τout} :
unnest_two s1 s2 op ▷ τin >=> Coll τout →
∃ τ₁ pf1 τs pf2,
op ▷ τin >=> (Coll (Rec Closed τ₁ pf1)) ∧
tdot τ₁ s1 = Some (Coll τs) ∧
τout = Rec Closed (rremove (rec_concat_sort τ₁ ((s2,τs)::nil)) s1) pf2.
Main lemma for the type preservation of the translation.
Lemma nra_of_pat_type_preserve' τc Γ pf p τin τout :
pat_type (rec_sort τc) Γ p τin τout →
nra_of_pat p ▷ (pat_context_type (Rec Closed (rec_sort τc) rec_sort_pf) (Rec Closed Γ pf) τin) >=> Coll τout.
Lemma nra_of_pat_type_preserve τc Γ pf p τin τout :
pat_type τc Γ p τin τout →
nra_of_pat p ▷ (pat_context_type (Rec Closed (rec_sort τc) rec_sort_pf) (Rec Closed Γ pf) τin) >=> Coll τout.
pat_type (rec_sort τc) Γ p τin τout →
nra_of_pat p ▷ (pat_context_type (Rec Closed (rec_sort τc) rec_sort_pf) (Rec Closed Γ pf) τin) >=> Coll τout.
Lemma nra_of_pat_type_preserve τc Γ pf p τin τout :
pat_type τc Γ p τin τout →
nra_of_pat p ▷ (pat_context_type (Rec Closed (rec_sort τc) rec_sort_pf) (Rec Closed Γ pf) τin) >=> Coll τout.
Some corollaries of the main Lemma
Lemma nra_of_pat_nra_of_pat_top p c τc τin τout :
bindings_type c τc →
nra_of_pat p ▷ (pat_context_type (Rec Closed (rec_sort τc) rec_sort_pf) (Rec Closed nil eq_refl) τin) >=> Coll τout →
nra_of_pat_top c p ▷ τin >=> Coll τout.
Theorem nra_of_pat_top_type_preserve p c τc τin τout :
bindings_type c τc →
pat_type τc nil p τin τout →
nra_of_pat_top c p ▷ τin >=> Coll τout.
Section dedicated to the reverse direction for type preservation
Lemma ATaid_inv {τin τout} :
AID ▷ τin >=> τout → τin = τout.
Lemma UIP_refl_dec
{A:Type}
(dec:∀ x y:A, {x = y} + {x ≠ y})
{x:A}
(p1:x = x) : p1 = eq_refl x.
Lemma nra_of_pat_type_form_output_weak p τin τout :
nra_of_pat p ▷ τin >=> τout →
∃ τout',τout = Coll τout'.
Theorem nra_of_pat_type_form_output p τin τout :
nra_of_pat p ▷ τin >=> τout →
{τout' | τout = Coll τout'}.
Lemma nra_of_pat_top_type_form_output_weak p c τin τout :
nra_of_pat_top c p ▷ τin >=> τout →
∃ τout', τout = Coll τout'.
Theorem nra_of_pat_top_type_form_output p c τin τout :
nra_of_pat_top c p ▷ τin >=> τout →
{τout' | τout = Coll τout'}.
Theorem 7.4: Pattern<->NRA.
Final iff Theorem of type preservation for the translation from Patterns to NRA