]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2A/unfold/lstas.ma
df678810c4c5611c1f492e23c53556428c3d531d
[helm.git] / matita / matita / contribs / lambdadelta / basic_2A / unfold / lstas.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "ground/xoa/ex_4_3.ma".
16 include "ground/xoa/ex_4_4.ma".
17 include "basic_2A/notation/relations/statictypestar_6.ma".
18 include "basic_2A/grammar/genv.ma".
19 include "basic_2A/substitution/drop.ma".
20 include "basic_2A/static/sh.ma".
21
22 (* NAT-ITERATED STATIC TYPE ASSIGNMENT FOR TERMS ****************************)
23
24 (* activate genv *)
25 inductive lstas (h): nat → relation4 genv lenv term term ≝
26 | lstas_sort: ∀G,L,d,k. lstas h d G L (⋆k) (⋆((next h)^d k))
27 | lstas_ldef: ∀G,L,K,V,W,U,i,d. ⬇[i] L ≡ K.ⓓV → lstas h d G K V W →
28               ⬆[0, i+1] W ≡ U → lstas h d G L (#i) U
29 | lstas_zero: ∀G,L,K,W,V,i. ⬇[i] L ≡ K.ⓛW → lstas h 0 G K W V →
30               lstas h 0 G L (#i) (#i)
31 | lstas_succ: ∀G,L,K,W,V,U,i,d. ⬇[i] L ≡ K.ⓛW → lstas h d G K W V →
32               ⬆[0, i+1] V ≡ U → lstas h (d+1) G L (#i) U
33 | lstas_bind: ∀a,I,G,L,V,T,U,d. lstas h d G (L.ⓑ{I}V) T U →
34               lstas h d G L (ⓑ{a,I}V.T) (ⓑ{a,I}V.U)
35 | lstas_appl: ∀G,L,V,T,U,d. lstas h d G L T U → lstas h d G L (ⓐV.T) (ⓐV.U)
36 | lstas_cast: ∀G,L,W,T,U,d. lstas h d G L T U → lstas h d G L (ⓝW.T) U
37 .
38
39 interpretation "nat-iterated static type assignment (term)"
40    'StaticTypeStar h G L d T U = (lstas h d G L T U).
41
42 (* Basic inversion lemmas ***************************************************)
43
44 fact lstas_inv_sort1_aux: ∀h,G,L,T,U,d. ⦃G, L⦄ ⊢ T •*[h, d] U → ∀k0. T = ⋆k0 →
45                           U = ⋆((next h)^d k0).
46 #h #G #L #T #U #d * -G -L -T -U -d
47 [ #G #L #d #k #k0 #H destruct //
48 | #G #L #K #V #W #U #i #d #_ #_ #_ #k0 #H destruct
49 | #G #L #K #W #V #i #_ #_ #k0 #H destruct
50 | #G #L #K #W #V #U #i #d #_ #_ #_ #k0 #H destruct
51 | #a #I #G #L #V #T #U #d #_ #k0 #H destruct
52 | #G #L #V #T #U #d #_ #k0 #H destruct
53 | #G #L #W #T #U #d #_ #k0 #H destruct
54 qed-.
55
56 (* Basic_1: was just: sty0_gen_sort *)
57 lemma lstas_inv_sort1: ∀h,G,L,X,k,d. ⦃G, L⦄ ⊢ ⋆k •*[h, d] X → X = ⋆((next h)^d k).
58 /2 width=5 by lstas_inv_sort1_aux/
59 qed-.
60
61 fact lstas_inv_lref1_aux: ∀h,G,L,T,U,d. ⦃G, L⦄ ⊢ T •*[h, d] U → ∀j. T = #j → ∨∨
62                           (∃∃K,V,W. ⬇[j] L ≡ K.ⓓV & ⦃G, K⦄ ⊢ V •*[h, d] W &
63                                     ⬆[0, j+1] W ≡ U
64                           ) |
65                           (∃∃K,W,V. ⬇[j] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, 0] V & 
66                                     U = #j & d = 0
67                           ) |
68                           (∃∃K,W,V,d0. ⬇[j] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, d0] V &
69                                        ⬆[0, j+1] V ≡ U & d = d0+1
70                           ).
71 #h #G #L #T #U #d * -G -L -T -U -d
72 [ #G #L #d #k #j #H destruct
73 | #G #L #K #V #W #U #i #d #HLK #HVW #HWU #j #H destruct /3 width=6 by or3_intro0, ex3_3_intro/
74 | #G #L #K #W #V #i #HLK #HWV #j #H destruct /3 width=5 by or3_intro1, ex4_3_intro/
75 | #G #L #K #W #V #U #i #d #HLK #HWV #HWU #j #H destruct /3 width=8 by or3_intro2, ex4_4_intro/ 
76 | #a #I #G #L #V #T #U #d #_ #j #H destruct
77 | #G #L #V #T #U #d #_ #j #H destruct
78 | #G #L #W #T #U #d #_ #j #H destruct
79 ]
80 qed-.
81
82 lemma lstas_inv_lref1: ∀h,G,L,X,i,d. ⦃G, L⦄ ⊢ #i •*[h, d] X → ∨∨
83                        (∃∃K,V,W. ⬇[i] L ≡ K.ⓓV & ⦃G, K⦄ ⊢ V •*[h, d] W &
84                                  ⬆[0, i+1] W ≡ X
85                        ) |
86                        (∃∃K,W,V. ⬇[i] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, 0] V & 
87                                  X = #i & d = 0
88                        ) |                      
89                        (∃∃K,W,V,d0. ⬇[i] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, d0] V &
90                                     ⬆[0, i+1] V ≡ X & d = d0+1
91                        ).
92 /2 width=3 by lstas_inv_lref1_aux/
93 qed-.
94
95 lemma lstas_inv_lref1_O: ∀h,G,L,X,i. ⦃G, L⦄ ⊢ #i •*[h, 0] X →
96                          (∃∃K,V,W. ⬇[i] L ≡ K.ⓓV & ⦃G, K⦄ ⊢ V •*[h, 0] W &
97                                    ⬆[0, i+1] W ≡ X
98                          ) ∨
99                          (∃∃K,W,V. ⬇[i] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, 0] V & 
100                                    X = #i
101                          ).
102 #h #G #L #X #i #H elim (lstas_inv_lref1 … H) -H * /3 width=6 by ex3_3_intro, or_introl, or_intror/
103 #K #W #V #d #_ #_ #_ <plus_n_Sm #H destruct
104 qed-.
105
106 (* Basic_1: was just: sty0_gen_lref *)
107 lemma lstas_inv_lref1_S: ∀h,G,L,X,i,d. ⦃G, L⦄ ⊢ #i •*[h, d+1] X →
108                          (∃∃K,V,W. ⬇[i] L ≡ K.ⓓV & ⦃G, K⦄ ⊢ V •*[h, d+1] W &
109                                    ⬆[0, i+1] W ≡ X
110                          ) ∨                      
111                          (∃∃K,W,V. ⬇[i] L ≡ K.ⓛW & ⦃G, K⦄ ⊢ W •*[h, d] V &
112                                    ⬆[0, i+1] V ≡ X
113                          ).
114 #h #G #L #X #i #d #H elim (lstas_inv_lref1 … H) -H * /3 width=6 by ex3_3_intro, or_introl, or_intror/
115 #K #W #V #_ #_ #_ <plus_n_Sm #H destruct
116 qed-.
117
118 fact lstas_inv_gref1_aux: ∀h,G,L,T,U,d. ⦃G, L⦄ ⊢ T •*[h, d] U → ∀p0. T = §p0 → ⊥.
119 #h #G #L #T #U #d * -G -L -T -U -d
120 [ #G #L #d #k #p0 #H destruct
121 | #G #L #K #V #W #U #i #d #_ #_ #_ #p0 #H destruct
122 | #G #L #K #W #V #i #_ #_ #p0 #H destruct
123 | #G #L #K #W #V #U #i #d #_ #_ #_ #p0 #H destruct
124 | #a #I #G #L #V #T #U #d #_ #p0 #H destruct
125 | #G #L #V #T #U #d #_ #p0 #H destruct
126 | #G #L #W #T #U #d #_ #p0 #H destruct
127 qed-.
128
129 lemma lstas_inv_gref1: ∀h,G,L,X,p,d. ⦃G, L⦄ ⊢ §p •*[h, d] X → ⊥.
130 /2 width=9 by lstas_inv_gref1_aux/
131 qed-.
132
133 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 →
134                           ∃∃Z. ⦃G, L.ⓑ{J}Y⦄ ⊢ X •*[h, d] Z & U = ⓑ{b,J}Y.Z.
135 #h #G #L #T #U #d * -G -L -T -U -d
136 [ #G #L #d #k #b #J #X #Y #H destruct
137 | #G #L #K #V #W #U #i #d #_ #_ #_ #b #J #X #Y #H destruct
138 | #G #L #K #W #V #i #_ #_ #b #J #X #Y #H destruct
139 | #G #L #K #W #V #U #i #d #_ #_ #_ #b #J #X #Y #H destruct
140 | #a #I #G #L #V #T #U #d #HTU #b #J #X #Y #H destruct /2 width=3 by ex2_intro/
141 | #G #L #V #T #U #d #_ #b #J #X #Y #H destruct
142 | #G #L #W #T #U #d #_ #b #J #X #Y #H destruct
143 ]
144 qed-.
145
146 (* Basic_1: was just: sty0_gen_bind *)
147 lemma lstas_inv_bind1: ∀h,a,I,G,L,V,T,X,d. ⦃G, L⦄ ⊢ ⓑ{a,I}V.T •*[h, d] X →
148                        ∃∃U. ⦃G, L.ⓑ{I}V⦄ ⊢ T •*[h, d] U & X = ⓑ{a,I}V.U.
149 /2 width=3 by lstas_inv_bind1_aux/
150 qed-.
151
152 fact lstas_inv_appl1_aux: ∀h,G,L,T,U,d. ⦃G, L⦄ ⊢ T •*[h, d] U → ∀X,Y. T = ⓐY.X →
153                           ∃∃Z. ⦃G, L⦄ ⊢ X •*[h, d] Z & U = ⓐY.Z.
154 #h #G #L #T #U #d * -G -L -T -U -d
155 [ #G #L #d #k #X #Y #H destruct
156 | #G #L #K #V #W #U #i #d #_ #_ #_ #X #Y #H destruct
157 | #G #L #K #W #V #i #_ #_ #X #Y #H destruct
158 | #G #L #K #W #V #U #i #d #_ #_ #_ #X #Y #H destruct
159 | #a #I #G #L #V #T #U #d #_ #X #Y #H destruct
160 | #G #L #V #T #U #d #HTU #X #Y #H destruct /2 width=3 by ex2_intro/
161 | #G #L #W #T #U #d #_ #X #Y #H destruct
162 ]
163 qed-.
164
165 (* Basic_1: was just: sty0_gen_appl *)
166 lemma lstas_inv_appl1: ∀h,G,L,V,T,X,d. ⦃G, L⦄ ⊢ ⓐV.T •*[h, d] X →
167                        ∃∃U. ⦃G, L⦄ ⊢ T •*[h, d] U & X = ⓐV.U.
168 /2 width=3 by lstas_inv_appl1_aux/
169 qed-.
170
171 fact lstas_inv_cast1_aux: ∀h,G,L,T,U,d. ⦃G, L⦄ ⊢ T •*[h, d] U → ∀X,Y. T = ⓝY.X →
172                           ⦃G, L⦄ ⊢ X •*[h, d] U.
173 #h #G #L #T #U #d * -G -L -T -U -d
174 [ #G #L #d #k #X #Y #H destruct
175 | #G #L #K #V #W #U #i #d #_ #_ #_ #X #Y #H destruct
176 | #G #L #K #W #V #i #_ #_ #X #Y #H destruct
177 | #G #L #K #W #V #U #i #d #_ #_ #_ #X #Y #H destruct
178 | #a #I #G #L #V #T #U #d #_ #X #Y #H destruct
179 | #G #L #V #T #U #d #_ #X #Y #H destruct
180 | #G #L #W #T #U #d #HTU #X #Y #H destruct //
181 ]
182 qed-.
183
184 (* Basic_1: was just: sty0_gen_cast *)
185 lemma lstas_inv_cast1: ∀h,G,L,W,T,U,d. ⦃G, L⦄ ⊢ ⓝW.T •*[h, d] U → ⦃G, L⦄ ⊢ T •*[h, d] U.
186 /2 width=4 by lstas_inv_cast1_aux/
187 qed-.
188
189 (* Basic_1: removed theorems 7:
190             sty1_abbr sty1_appl sty1_bind sty1_cast2
191             sty1_correct sty1_lift sty1_trans
192 *)