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/notation/relations/statictypestar_6.ma".
16 include "basic_2/grammar/genv.ma".
17 include "basic_2/substitution/drop.ma".
18 include "basic_2/static/sh.ma".
20 (* NAT-ITERATED STATIC TYPE ASSIGNMENT FOR TERMS ****************************)
23 inductive lstas (h): nat → relation4 genv lenv term term ≝
24 | lstas_sort: ∀G,L,l,k. lstas h l G L (⋆k) (⋆((next h)^l k))
25 | lstas_ldef: ∀G,L,K,V,W,U,i,l. ⬇[i] L ≡ K.ⓓV → lstas h l G K V W →
26 ⬆[0, i+1] W ≡ U → lstas h l G L (#i) U
27 | lstas_zero: ∀G,L,K,W,V,i. ⬇[i] L ≡ K.ⓛW → lstas h 0 G K W V →
28 lstas h 0 G L (#i) (#i)
29 | lstas_succ: ∀G,L,K,W,V,U,i,l. ⬇[i] L ≡ K.ⓛW → lstas h l G K W V →
30 ⬆[0, i+1] V ≡ U → lstas h (l+1) G L (#i) U
31 | lstas_bind: ∀a,I,G,L,V,T,U,l. lstas h l G (L.ⓑ{I}V) T U →
32 lstas h l G L (ⓑ{a,I}V.T) (ⓑ{a,I}V.U)
33 | lstas_appl: ∀G,L,V,T,U,l. lstas h l G L T U → lstas h l G L (ⓐV.T) (ⓐV.U)
34 | lstas_cast: ∀G,L,W,T,U,l. lstas h l G L T U → lstas h l G L (ⓝW.T) U
37 interpretation "nat-iterated static type assignment (term)"
38 'StaticTypeStar h G L l T U = (lstas h l G L T U).
40 (* Basic inversion lemmas ***************************************************)
42 fact lstas_inv_sort1_aux: ∀h,G,L,T,U,l. ⦃G, L⦄ ⊢ T •*[h, l] U → ∀k0. T = ⋆k0 →
44 #h #G #L #T #U #l * -G -L -T -U -l
45 [ #G #L #l #k #k0 #H destruct //
46 | #G #L #K #V #W #U #i #l #_ #_ #_ #k0 #H destruct
47 | #G #L #K #W #V #i #_ #_ #k0 #H destruct
48 | #G #L #K #W #V #U #i #l #_ #_ #_ #k0 #H destruct
49 | #a #I #G #L #V #T #U #l #_ #k0 #H destruct
50 | #G #L #V #T #U #l #_ #k0 #H destruct
51 | #G #L #W #T #U #l #_ #k0 #H destruct
54 (* Basic_1: was just: sty0_gen_sort *)
55 lemma lstas_inv_sort1: ∀h,G,L,X,k,l. ⦃G, L⦄ ⊢ ⋆k •*[h, l] X → X = ⋆((next h)^l k).
56 /2 width=5 by lstas_inv_sort1_aux/
59 fact lstas_inv_lref1_aux: ∀h,G,L,T,U,l. ⦃G, L⦄ ⊢ T •*[h, l] U → ∀j. T = #j → ∨∨
60 (∃∃K,V,W. ⬇[j] L ≡ K.ⓓV & ⦃G, K⦄ ⊢ V •*[h, l] W &
63 (∃∃K,W,V. ⬇[j] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, 0] V &
66 (∃∃K,W,V,l0. ⬇[j] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, l0] V &
67 ⬆[0, j+1] V ≡ U & l = l0+1
69 #h #G #L #T #U #l * -G -L -T -U -l
70 [ #G #L #l #k #j #H destruct
71 | #G #L #K #V #W #U #i #l #HLK #HVW #HWU #j #H destruct /3 width=6 by or3_intro0, ex3_3_intro/
72 | #G #L #K #W #V #i #HLK #HWV #j #H destruct /3 width=5 by or3_intro1, ex4_3_intro/
73 | #G #L #K #W #V #U #i #l #HLK #HWV #HWU #j #H destruct /3 width=8 by or3_intro2, ex4_4_intro/
74 | #a #I #G #L #V #T #U #l #_ #j #H destruct
75 | #G #L #V #T #U #l #_ #j #H destruct
76 | #G #L #W #T #U #l #_ #j #H destruct
80 lemma lstas_inv_lref1: ∀h,G,L,X,i,l. ⦃G, L⦄ ⊢ #i •*[h, l] X → ∨∨
81 (∃∃K,V,W. ⬇[i] L ≡ K.ⓓV & ⦃G, K⦄ ⊢ V •*[h, l] W &
84 (∃∃K,W,V. ⬇[i] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, 0] V &
87 (∃∃K,W,V,l0. ⬇[i] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, l0] V &
88 ⬆[0, i+1] V ≡ X & l = l0+1
90 /2 width=3 by lstas_inv_lref1_aux/
93 lemma lstas_inv_lref1_O: ∀h,G,L,X,i. ⦃G, L⦄ ⊢ #i •*[h, 0] X →
94 (∃∃K,V,W. ⬇[i] L ≡ K.ⓓV & ⦃G, K⦄ ⊢ V •*[h, 0] W &
97 (∃∃K,W,V. ⬇[i] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, 0] V &
100 #h #G #L #X #i #H elim (lstas_inv_lref1 … H) -H * /3 width=6 by ex3_3_intro, or_introl, or_intror/
101 #K #W #V #l #_ #_ #_ <plus_n_Sm #H destruct
104 (* Basic_1: was just: sty0_gen_lref *)
105 lemma lstas_inv_lref1_S: ∀h,G,L,X,i,l. ⦃G, L⦄ ⊢ #i •*[h, l+1] X →
106 (∃∃K,V,W. ⬇[i] L ≡ K.ⓓV & ⦃G, K⦄ ⊢ V •*[h, l+1] W &
109 (∃∃K,W,V. ⬇[i] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, l] V &
112 #h #G #L #X #i #l #H elim (lstas_inv_lref1 … H) -H * /3 width=6 by ex3_3_intro, or_introl, or_intror/
113 #K #W #V #_ #_ #_ <plus_n_Sm #H destruct
116 fact lstas_inv_gref1_aux: ∀h,G,L,T,U,l. ⦃G, L⦄ ⊢ T •*[h, l] U → ∀p0. T = §p0 → ⊥.
117 #h #G #L #T #U #l * -G -L -T -U -l
118 [ #G #L #l #k #p0 #H destruct
119 | #G #L #K #V #W #U #i #l #_ #_ #_ #p0 #H destruct
120 | #G #L #K #W #V #i #_ #_ #p0 #H destruct
121 | #G #L #K #W #V #U #i #l #_ #_ #_ #p0 #H destruct
122 | #a #I #G #L #V #T #U #l #_ #p0 #H destruct
123 | #G #L #V #T #U #l #_ #p0 #H destruct
124 | #G #L #W #T #U #l #_ #p0 #H destruct
127 lemma lstas_inv_gref1: ∀h,G,L,X,p,l. ⦃G, L⦄ ⊢ §p •*[h, l] X → ⊥.
128 /2 width=9 by lstas_inv_gref1_aux/
131 fact lstas_inv_bind1_aux: ∀h,G,L,T,U,l. ⦃G, L⦄ ⊢ T •*[h, l] U → ∀b,J,X,Y. T = ⓑ{b,J}Y.X →
132 ∃∃Z. ⦃G, L.ⓑ{J}Y⦄ ⊢ X •*[h, l] Z & U = ⓑ{b,J}Y.Z.
133 #h #G #L #T #U #l * -G -L -T -U -l
134 [ #G #L #l #k #b #J #X #Y #H destruct
135 | #G #L #K #V #W #U #i #l #_ #_ #_ #b #J #X #Y #H destruct
136 | #G #L #K #W #V #i #_ #_ #b #J #X #Y #H destruct
137 | #G #L #K #W #V #U #i #l #_ #_ #_ #b #J #X #Y #H destruct
138 | #a #I #G #L #V #T #U #l #HTU #b #J #X #Y #H destruct /2 width=3 by ex2_intro/
139 | #G #L #V #T #U #l #_ #b #J #X #Y #H destruct
140 | #G #L #W #T #U #l #_ #b #J #X #Y #H destruct
144 (* Basic_1: was just: sty0_gen_bind *)
145 lemma lstas_inv_bind1: ∀h,a,I,G,L,V,T,X,l. ⦃G, L⦄ ⊢ ⓑ{a,I}V.T •*[h, l] X →
146 ∃∃U. ⦃G, L.ⓑ{I}V⦄ ⊢ T •*[h, l] U & X = ⓑ{a,I}V.U.
147 /2 width=3 by lstas_inv_bind1_aux/
150 fact lstas_inv_appl1_aux: ∀h,G,L,T,U,l. ⦃G, L⦄ ⊢ T •*[h, l] U → ∀X,Y. T = ⓐY.X →
151 ∃∃Z. ⦃G, L⦄ ⊢ X •*[h, l] Z & U = ⓐY.Z.
152 #h #G #L #T #U #l * -G -L -T -U -l
153 [ #G #L #l #k #X #Y #H destruct
154 | #G #L #K #V #W #U #i #l #_ #_ #_ #X #Y #H destruct
155 | #G #L #K #W #V #i #_ #_ #X #Y #H destruct
156 | #G #L #K #W #V #U #i #l #_ #_ #_ #X #Y #H destruct
157 | #a #I #G #L #V #T #U #l #_ #X #Y #H destruct
158 | #G #L #V #T #U #l #HTU #X #Y #H destruct /2 width=3 by ex2_intro/
159 | #G #L #W #T #U #l #_ #X #Y #H destruct
163 (* Basic_1: was just: sty0_gen_appl *)
164 lemma lstas_inv_appl1: ∀h,G,L,V,T,X,l. ⦃G, L⦄ ⊢ ⓐV.T •*[h, l] X →
165 ∃∃U. ⦃G, L⦄ ⊢ T •*[h, l] U & X = ⓐV.U.
166 /2 width=3 by lstas_inv_appl1_aux/
169 fact lstas_inv_cast1_aux: ∀h,G,L,T,U,l. ⦃G, L⦄ ⊢ T •*[h, l] U → ∀X,Y. T = ⓝY.X →
170 ⦃G, L⦄ ⊢ X •*[h, l] U.
171 #h #G #L #T #U #l * -G -L -T -U -l
172 [ #G #L #l #k #X #Y #H destruct
173 | #G #L #K #V #W #U #i #l #_ #_ #_ #X #Y #H destruct
174 | #G #L #K #W #V #i #_ #_ #X #Y #H destruct
175 | #G #L #K #W #V #U #i #l #_ #_ #_ #X #Y #H destruct
176 | #a #I #G #L #V #T #U #l #_ #X #Y #H destruct
177 | #G #L #V #T #U #l #_ #X #Y #H destruct
178 | #G #L #W #T #U #l #HTU #X #Y #H destruct //
182 (* Basic_1: was just: sty0_gen_cast *)
183 lemma lstas_inv_cast1: ∀h,G,L,W,T,U,l. ⦃G, L⦄ ⊢ ⓝW.T •*[h, l] U → ⦃G, L⦄ ⊢ T •*[h, l] U.
184 /2 width=4 by lstas_inv_cast1_aux/
187 (* Basic_1: removed theorems 7:
188 sty1_abbr sty1_appl sty1_bind sty1_cast2
189 sty1_correct sty1_lift sty1_trans