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,d,s. lstas h d G L (⋆s) (⋆((next h)^d s))
25 | lstas_ldef: ∀G,L,K,V,W,U,i,d. ⬇[i] L ≡ K.ⓓV → lstas h d G K V W →
26 ⬆[0, i+1] W ≡ U → lstas h d 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,d. ⬇[i] L ≡ K.ⓛW → lstas h d G K W V →
30 ⬆[0, i+1] V ≡ U → lstas h (d+1) G L (#i) U
31 | lstas_bind: ∀a,I,G,L,V,T,U,d. lstas h d G (L.ⓑ{I}V) T U →
32 lstas h d G L (ⓑ{a,I}V.T) (ⓑ{a,I}V.U)
33 | lstas_appl: ∀G,L,V,T,U,d. lstas h d G L T U → lstas h d G L (ⓐV.T) (ⓐV.U)
34 | lstas_cast: ∀G,L,W,T,U,d. lstas h d G L T U → lstas h d G L (ⓝW.T) U
37 interpretation "nat-iterated static type assignment (term)"
38 'StaticTypeStar h G L d T U = (lstas h d G L T U).
40 (* Basic inversion lemmas ***************************************************)
42 fact lstas_inv_sort1_aux: ∀h,G,L,T,U,d. ⦃G, L⦄ ⊢ T •*[h, d] U → ∀s0. T = ⋆s0 →
44 #h #G #L #T #U #d * -G -L -T -U -d
45 [ #G #L #d #s #s0 #H destruct //
46 | #G #L #K #V #W #U #i #d #_ #_ #_ #s0 #H destruct
47 | #G #L #K #W #V #i #_ #_ #s0 #H destruct
48 | #G #L #K #W #V #U #i #d #_ #_ #_ #s0 #H destruct
49 | #a #I #G #L #V #T #U #d #_ #s0 #H destruct
50 | #G #L #V #T #U #d #_ #s0 #H destruct
51 | #G #L #W #T #U #d #_ #s0 #H destruct
54 (* Basic_1: was just: sty0_gen_sort *)
55 lemma lstas_inv_sort1: ∀h,G,L,X,s,d. ⦃G, L⦄ ⊢ ⋆s •*[h, d] X → X = ⋆((next h)^d s).
56 /2 width=5 by lstas_inv_sort1_aux/
59 fact lstas_inv_lref1_aux: ∀h,G,L,T,U,d. ⦃G, L⦄ ⊢ T •*[h, d] U → ∀j. T = #j → ∨∨
60 (∃∃K,V,W. ⬇[j] L ≡ K.ⓓV & ⦃G, K⦄ ⊢ V •*[h, d] W &
63 (∃∃K,W,V. ⬇[j] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, 0] V &
66 (∃∃K,W,V,d0. ⬇[j] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, d0] V &
67 ⬆[0, j+1] V ≡ U & d = d0+1
69 #h #G #L #T #U #d * -G -L -T -U -d
70 [ #G #L #d #s #j #H destruct
71 | #G #L #K #V #W #U #i #d #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 #d #HLK #HWV #HWU #j #H destruct /3 width=8 by or3_intro2, ex4_4_intro/
74 | #a #I #G #L #V #T #U #d #_ #j #H destruct
75 | #G #L #V #T #U #d #_ #j #H destruct
76 | #G #L #W #T #U #d #_ #j #H destruct
80 lemma lstas_inv_lref1: ∀h,G,L,X,i,d. ⦃G, L⦄ ⊢ #i •*[h, d] X → ∨∨
81 (∃∃K,V,W. ⬇[i] L ≡ K.ⓓV & ⦃G, K⦄ ⊢ V •*[h, d] W &
84 (∃∃K,W,V. ⬇[i] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, 0] V &
87 (∃∃K,W,V,d0. ⬇[i] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, d0] V &
88 ⬆[0, i+1] V ≡ X & d = d0+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 #d #_ #_ #_ <plus_n_Sm #H destruct
104 (* Basic_1: was just: sty0_gen_lref *)
105 lemma lstas_inv_lref1_S: ∀h,G,L,X,i,d. ⦃G, L⦄ ⊢ #i •*[h, d+1] X →
106 (∃∃K,V,W. ⬇[i] L ≡ K.ⓓV & ⦃G, K⦄ ⊢ V •*[h, d+1] W &
109 (∃∃K,W,V. ⬇[i] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, d] V &
112 #h #G #L #X #i #d #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,d. ⦃G, L⦄ ⊢ T •*[h, d] U → ∀p0. T = §p0 → ⊥.
117 #h #G #L #T #U #d * -G -L -T -U -d
118 [ #G #L #d #s #p0 #H destruct
119 | #G #L #K #V #W #U #i #d #_ #_ #_ #p0 #H destruct
120 | #G #L #K #W #V #i #_ #_ #p0 #H destruct
121 | #G #L #K #W #V #U #i #d #_ #_ #_ #p0 #H destruct
122 | #a #I #G #L #V #T #U #d #_ #p0 #H destruct
123 | #G #L #V #T #U #d #_ #p0 #H destruct
124 | #G #L #W #T #U #d #_ #p0 #H destruct
127 lemma lstas_inv_gref1: ∀h,G,L,X,p,d. ⦃G, L⦄ ⊢ §p •*[h, d] X → ⊥.
128 /2 width=9 by lstas_inv_gref1_aux/
131 fact lstas_inv_bind1_aux: ∀h,G,L,T,U,d. ⦃G, L⦄ ⊢ T •*[h, d] U → ∀b,J,X,Y. T = ⓑ{b,J}Y.X →
132 ∃∃Z. ⦃G, L.ⓑ{J}Y⦄ ⊢ X •*[h, d] Z & U = ⓑ{b,J}Y.Z.
133 #h #G #L #T #U #d * -G -L -T -U -d
134 [ #G #L #d #s #b #J #X #Y #H destruct
135 | #G #L #K #V #W #U #i #d #_ #_ #_ #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 #d #_ #_ #_ #b #J #X #Y #H destruct
138 | #a #I #G #L #V #T #U #d #HTU #b #J #X #Y #H destruct /2 width=3 by ex2_intro/
139 | #G #L #V #T #U #d #_ #b #J #X #Y #H destruct
140 | #G #L #W #T #U #d #_ #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,d. ⦃G, L⦄ ⊢ ⓑ{a,I}V.T •*[h, d] X →
146 ∃∃U. ⦃G, L.ⓑ{I}V⦄ ⊢ T •*[h, d] 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,d. ⦃G, L⦄ ⊢ T •*[h, d] U → ∀X,Y. T = ⓐY.X →
151 ∃∃Z. ⦃G, L⦄ ⊢ X •*[h, d] Z & U = ⓐY.Z.
152 #h #G #L #T #U #d * -G -L -T -U -d
153 [ #G #L #d #s #X #Y #H destruct
154 | #G #L #K #V #W #U #i #d #_ #_ #_ #X #Y #H destruct
155 | #G #L #K #W #V #i #_ #_ #X #Y #H destruct
156 | #G #L #K #W #V #U #i #d #_ #_ #_ #X #Y #H destruct
157 | #a #I #G #L #V #T #U #d #_ #X #Y #H destruct
158 | #G #L #V #T #U #d #HTU #X #Y #H destruct /2 width=3 by ex2_intro/
159 | #G #L #W #T #U #d #_ #X #Y #H destruct
163 (* Basic_1: was just: sty0_gen_appl *)
164 lemma lstas_inv_appl1: ∀h,G,L,V,T,X,d. ⦃G, L⦄ ⊢ ⓐV.T •*[h, d] X →
165 ∃∃U. ⦃G, L⦄ ⊢ T •*[h, d] U & X = ⓐV.U.
166 /2 width=3 by lstas_inv_appl1_aux/
169 fact lstas_inv_cast1_aux: ∀h,G,L,T,U,d. ⦃G, L⦄ ⊢ T •*[h, d] U → ∀X,Y. T = ⓝY.X →
170 ⦃G, L⦄ ⊢ X •*[h, d] U.
171 #h #G #L #T #U #d * -G -L -T -U -d
172 [ #G #L #d #s #X #Y #H destruct
173 | #G #L #K #V #W #U #i #d #_ #_ #_ #X #Y #H destruct
174 | #G #L #K #W #V #i #_ #_ #X #Y #H destruct
175 | #G #L #K #W #V #U #i #d #_ #_ #_ #X #Y #H destruct
176 | #a #I #G #L #V #T #U #d #_ #X #Y #H destruct
177 | #G #L #V #T #U #d #_ #X #Y #H destruct
178 | #G #L #W #T #U #d #HTU #X #Y #H destruct //
182 (* Basic_1: was just: sty0_gen_cast *)
183 lemma lstas_inv_cast1: ∀h,G,L,W,T,U,d. ⦃G, L⦄ ⊢ ⓝW.T •*[h, d] U → ⦃G, L⦄ ⊢ T •*[h, d] 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