1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "basic_2/static/ssta.ma".
16 include "basic_2/computation/cprs.ma".
17 include "basic_2/equivalence/cpcs.ma".
19 (* LOCAL ENVIRONMENT REFINEMENT FOR STRATIFIED STATIC TYPE ASSIGNMENT *******)
21 (* Note: this is not transitive *)
22 inductive lsubss (h:sh) (g:sd h): relation lenv ≝
23 | lsubss_atom: lsubss h g (⋆) (⋆)
24 | lsubss_pair: ∀I,L1,L2,V. lsubss h g L1 L2 →
25 lsubss h g (L1. ⓑ{I} V) (L2. ⓑ{I} V)
26 | lsubss_abbr: ∀L1,L2,V1,V2,W1,W2,l. L1 ⊢ W1 ⬌* W2 →
27 ⦃h, L1⦄ ⊢ V1 •[g] ⦃l+1, W1⦄ → ⦃h, L2⦄ ⊢ W2 •[g] ⦃l, V2⦄ →
28 lsubss h g L1 L2 → lsubss h g (L1. ⓓV1) (L2. ⓛW2)
32 "local environment refinement (stratified static type assigment)"
33 'CrSubEqS h g L1 L2 = (lsubss h g L1 L2).
35 (* Basic inversion lemmas ***************************************************)
37 fact lsubss_inv_atom1_aux: ∀h,g,L1,L2. h ⊢ L1 •⊑[g] L2 → L1 = ⋆ → L2 = ⋆.
38 #h #g #L1 #L2 * -L1 -L2
40 | #I #L1 #L2 #V #_ #H destruct
41 | #L1 #L2 #V1 #V2 #W1 #W2 #l #_ #_ #_ #_ #H destruct
45 lemma lsubss_inv_atom1: ∀h,g,L2. h ⊢ ⋆ •⊑[g] L2 → L2 = ⋆.
46 /2 width=5 by lsubss_inv_atom1_aux/ qed-.
48 fact lsubss_inv_pair1_aux: ∀h,g,L1,L2. h ⊢ L1 •⊑[g] L2 →
49 ∀I,K1,V1. L1 = K1. ⓑ{I} V1 →
50 (∃∃K2. h ⊢ K1 •⊑[g] K2 & L2 = K2. ⓑ{I} V1) ∨
51 ∃∃K2,W1,W2,V2,l. ⦃h, K1⦄ ⊢ V1 •[g] ⦃l+1, W1⦄ & ⦃h, K2⦄ ⊢ W2 •[g] ⦃l, V2⦄ &
52 K1 ⊢ W1 ⬌* W2 & h ⊢ K1 •⊑[g] K2 & L2 = K2. ⓛW2 & I = Abbr.
53 #h #g #L1 #L2 * -L1 -L2
54 [ #J #K1 #U1 #H destruct
55 | #I #L1 #L2 #V #HL12 #J #K1 #U1 #H destruct /3 width=3/
56 | #L1 #L2 #V1 #V2 #W1 #W2 #l #HW12 #HVW1 #HWV2 #HL12 #J #K1 #U1 #H destruct /3 width=10/
60 lemma lsubss_inv_pair1: ∀h,g,I,K1,L2,V1. h ⊢ K1. ⓑ{I} V1 •⊑[g] L2 →
61 (∃∃K2. h ⊢ K1 •⊑[g] K2 & L2 = K2. ⓑ{I} V1) ∨
62 ∃∃K2,W1,W2,V2,l. ⦃h, K1⦄ ⊢ V1 •[g] ⦃l+1, W1⦄ & ⦃h, K2⦄ ⊢ W2 •[g] ⦃l, V2⦄ &
63 K1 ⊢ W1 ⬌* W2 & h ⊢ K1 •⊑[g] K2 & L2 = K2. ⓛW2 & I = Abbr.
64 /2 width=3 by lsubss_inv_pair1_aux/ qed-.
66 fact lsubss_inv_atom2_aux: ∀h,g,L1,L2. h ⊢ L1 •⊑[g] L2 → L2 = ⋆ → L1 = ⋆.
67 #h #g #L1 #L2 * -L1 -L2
69 | #I #L1 #L2 #V #_ #H destruct
70 | #L1 #L2 #V1 #V2 #W1 #W2 #l #_ #_ #_ #_ #H destruct
74 lemma lsubss_inv_atom2: ∀h,g,L1. h ⊢ L1 •⊑[g] ⋆ → L1 = ⋆.
75 /2 width=5 by lsubss_inv_atom2_aux/ qed-.
77 fact lsubss_inv_pair2_aux: ∀h,g,L1,L2. h ⊢ L1 •⊑[g] L2 →
78 ∀I,K2,W2. L2 = K2. ⓑ{I} W2 →
79 (∃∃K1. h ⊢ K1 •⊑[g] K2 & L1 = K1. ⓑ{I} W2) ∨
80 ∃∃K1,W1,V1,V2,l. ⦃h, K1⦄ ⊢ V1 •[g] ⦃l+1, W1⦄ & ⦃h, K2⦄ ⊢ W2 •[g] ⦃l, V2⦄ &
81 K1 ⊢ W1 ⬌* W2 & h ⊢ K1 •⊑[g] K2 & L1 = K1. ⓓV1 & I = Abst.
82 #h #g #L1 #L2 * -L1 -L2
83 [ #J #K2 #U2 #H destruct
84 | #I #L1 #L2 #V #HL12 #J #K2 #U2 #H destruct /3 width=3/
85 | #L1 #L2 #V1 #V2 #W1 #W2 #l #HW12 #HVW1 #HWV2 #HL12 #J #K2 #U2 #H destruct /3 width=10/
89 lemma lsubss_inv_pair2: ∀h,g,I,L1,K2,W2. h ⊢ L1 •⊑[g] K2. ⓑ{I} W2 →
90 (∃∃K1. h ⊢ K1 •⊑[g] K2 & L1 = K1. ⓑ{I} W2) ∨
91 ∃∃K1,W1,V1,V2,l. ⦃h, K1⦄ ⊢ V1 •[g] ⦃l+1, W1⦄ & ⦃h, K2⦄ ⊢ W2 •[g] ⦃l, V2⦄ &
92 K1 ⊢ W1 ⬌* W2 & h ⊢ K1 •⊑[g] K2 & L1 = K1. ⓓV1 & I = Abst.
93 /2 width=3 by lsubss_inv_pair2_aux/ qed-.
95 (* Basic_forward lemmas *****************************************************)
97 lemma lsubss_fwd_lsubr1: ∀h,g,L1,L2. h ⊢ L1 •⊑[g] L2 → L1 ⊑[0, |L1|] L2.
98 #h #g #L1 #L2 #H elim H -L1 -L2 // /2 width=1/
101 lemma lsubss_fwd_lsubr2: ∀h,g,L1,L2. h ⊢ L1 •⊑[g] L2 → L1 ⊑[0, |L2|] L2.
102 #h #g #L1 #L2 #H elim H -L1 -L2 // /2 width=1/
105 (* Basic properties *********************************************************)
107 lemma lsubss_refl: ∀h,g,L. h ⊢ L •⊑[g] L.
108 #h #g #L elim L -L // /2 width=1/
111 lemma lsubss_cprs_trans: ∀h,g,L1,L2. h ⊢ L1 •⊑[g] L2 →
112 ∀T1,T2. L2 ⊢ T1 ➡* T2 → L1 ⊢ T1 ➡* T2.
113 /3 width=5 by lsubss_fwd_lsubr2, cprs_lsubr_trans/