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".
17 (* LOCAL ENVIRONMENT REFINEMENT FOR STRATIFIED STATIC TYPE ASSIGNMENT *******)
19 (* Note: may not be transitive *)
20 inductive lsubss (h:sh) (g:sd h): relation lenv ≝
21 | lsubss_atom: lsubss h g (⋆) (⋆)
22 | lsubss_pair: ∀I,L1,L2,W. lsubss h g L1 L2 →
23 lsubss h g (L1. ⓑ{I} W) (L2. ⓑ{I} W)
24 | lsubss_abbr: ∀L1,L2,V,W,l. ⦃h, L1⦄ ⊢ V •[g, l+1] W → ⦃h, L2⦄ ⊢ V •[g, l+1] W →
25 lsubss h g L1 L2 → lsubss h g (L1. ⓓV) (L2. ⓛW)
29 "local environment refinement (stratified static type assigment)"
30 'CrSubEqS h g L1 L2 = (lsubss h g L1 L2).
32 (* Basic inversion lemmas ***************************************************)
34 fact lsubss_inv_atom1_aux: ∀h,g,L1,L2. h ⊢ L1 •⊑[g] L2 → L1 = ⋆ → L2 = ⋆.
35 #h #g #L1 #L2 * -L1 -L2
37 | #I #L1 #L2 #V #_ #H destruct
38 | #L1 #L2 #V #W #l #_ #_ #_ #H destruct
42 lemma lsubss_inv_atom1: ∀h,g,L2. h ⊢ ⋆ •⊑[g] L2 → L2 = ⋆.
45 fact lsubss_inv_pair1_aux: ∀h,g,L1,L2. h ⊢ L1 •⊑[g] L2 →
46 ∀I,K1,V. L1 = K1. ⓑ{I} V →
47 (∃∃K2. h ⊢ K1 •⊑[g] K2 & L2 = K2. ⓑ{I} V) ∨
48 ∃∃K2,W,l. ⦃h, K1⦄ ⊢ V •[g,l+1] W & ⦃h, K2⦄ ⊢ V •[g,l+1] W &
49 h ⊢ K1 •⊑[g] K2 & L2 = K2. ⓛW & I = Abbr.
50 #h #g #L1 #L2 * -L1 -L2
51 [ #I #K1 #V #H destruct
52 | #J #L1 #L2 #V #HL12 #I #K1 #W #H destruct /3 width=3/
53 | #L1 #L2 #V #W #l #H1VW #H2VW #HL12 #I #K1 #V1 #H destruct /3 width=7/
57 lemma lsubss_inv_pair1: ∀h,g,I,K1,L2,V. h ⊢ K1. ⓑ{I} V •⊑[g] L2 →
58 (∃∃K2. h ⊢ K1 •⊑[g] K2 & L2 = K2. ⓑ{I} V) ∨
59 ∃∃K2,W,l. ⦃h, K1⦄ ⊢ V •[g,l+1] W & ⦃h, K2⦄ ⊢ V •[g,l+1] W &
60 h ⊢ K1 •⊑[g] K2 & L2 = K2. ⓛW & I = Abbr.
63 fact lsubss_inv_atom2_aux: ∀h,g,L1,L2. h ⊢ L1 •⊑[g] L2 → L2 = ⋆ → L1 = ⋆.
64 #h #g #L1 #L2 * -L1 -L2
66 | #I #L1 #L2 #V #_ #H destruct
67 | #L1 #L2 #V #W #l #_ #_ #_ #H destruct
71 lemma lsubss_inv_atom2: ∀h,g,L1. h ⊢ L1 •⊑[g] ⋆ → L1 = ⋆.
74 fact lsubss_inv_pair2_aux: ∀h,g,L1,L2. h ⊢ L1 •⊑[g] L2 →
75 ∀I,K2,W. L2 = K2. ⓑ{I} W →
76 (∃∃K1. h ⊢ K1 •⊑[g] K2 & L1 = K1. ⓑ{I} W) ∨
77 ∃∃K1,V,l. ⦃h, K1⦄ ⊢ V •[g,l+1] W & ⦃h, K2⦄ ⊢ V •[g,l+1] W &
78 h ⊢ K1 •⊑[g] K2 & L1 = K1. ⓓV & I = Abst.
79 #h #g #L1 #L2 * -L1 -L2
80 [ #I #K2 #W #H destruct
81 | #J #L1 #L2 #V #HL12 #I #K2 #W #H destruct /3 width=3/
82 | #L1 #L2 #V #W #l #H1VW #H2VW #HL12 #I #K2 #W2 #H destruct /3 width=7/
86 lemma lsubss_inv_pair2: ∀h,g,I,L1,K2,W. h ⊢ L1 •⊑[g] K2. ⓑ{I} W →
87 (∃∃K1. h ⊢ K1 •⊑[g] K2 & L1 = K1. ⓑ{I} W) ∨
88 ∃∃K1,V,l. ⦃h, K1⦄ ⊢ V •[g,l+1] W & ⦃h, K2⦄ ⊢ V •[g,l+1] W &
89 h ⊢ K1 •⊑[g] K2 & L1 = K1. ⓓV & I = Abst.
92 (* Basic_forward lemmas *****************************************************)
94 lemma lsubss_fwd_lsubs1: ∀h,g,L1,L2. h ⊢ L1 •⊑[g] L2 → L1 ≼[0, |L1|] L2.
95 #h #g #L1 #L2 #H elim H -L1 -L2 // /2 width=1/
98 lemma lsubss_fwd_lsubs2: ∀h,g,L1,L2. h ⊢ L1 •⊑[g] L2 → L1 ≼[0, |L2|] L2.
99 #h #g #L1 #L2 #H elim H -L1 -L2 // /2 width=1/
102 (* Basic properties *********************************************************)
104 lemma lsubss_refl: ∀h,g,L. h ⊢ L •⊑[g] L.
105 #h #g #L elim L -L // /2 width=1/