]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/static/ssta_lift.ma
commit of the "static" component
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / static / ssta_lift.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 "basic_2/static/da_lift.ma".
16 include "basic_2/static/ssta.ma".
17
18 (* STRATIFIED STATIC TYPE ASSIGNMENT FOR TERMS ******************************)
19
20 (* Properties on relocation *************************************************)
21
22 lemma ssta_lift: ∀h,g,G. l_liftable (ssta h g G).
23 #h #g #G #L1 #T1 #U1 #H elim H -G -L1 -T1 -U1
24 [ #G #L1 #k #L2 #s #d #e #HL21 #X1 #H1 #X2 #H2
25   >(lift_inv_sort1 … H1) -X1
26   >(lift_inv_sort1 … H2) -X2 //
27 | #G #L1 #K1 #V1 #U1 #W1 #i #HLK1 #_ #HWU1 #IHVW1 #L2 #s #d #e #HL21 #X #H #U2 #HU12
28   elim (lift_inv_lref1 … H) * #Hid #H destruct
29   [ elim (lift_trans_ge … HWU1 … HU12) -U1 // #W2 #HW12 #HWU2
30     elim (ldrop_trans_le … HL21 … HLK1) -L1 /2 width=2 by lt_to_le/ #X #HLK2 #H
31     elim (ldrop_inv_skip2 … H) -H /2 width=1 by lt_plus_to_minus_r/ -Hid #K2 #V2 #HK21 #HV12 #H destruct
32     /3 width=9 by ssta_ldef/
33   | lapply (lift_trans_be … HWU1 … HU12 ? ?) -U1 /2 width=1 by le_S/ #HW1U2
34     lapply (ldrop_trans_ge … HL21 … HLK1 ?) -L1 // -Hid
35     /3 width=9 by ssta_ldef, ldrop_inv_gen/
36   ]
37 | #G #L1 #K1 #W1 #U1 #l #i #HLK1 #HW1l #HWU1 #L2 #s #d #e #HL21 #X #H #U2 #HU12
38   elim (lift_inv_lref1 … H) * #Hid #H destruct
39   [ elim (lift_trans_ge … HWU1 … HU12) -U1 // <minus_plus #W2 #HW12 #HWU2
40     elim (ldrop_trans_le … HL21 … HLK1) -L1 /2 width=2 by lt_to_le/ #X #HLK2 #H
41     elim (ldrop_inv_skip2 … H) -H /2 width=1 by lt_plus_to_minus_r/ -Hid #K2 #W #HK21 #HW1 #H destruct
42     lapply (lift_mono … HW1 … HW12) -HW1 #H destruct
43     /3 width=11 by da_lift, ssta_ldec/
44   | lapply (lift_trans_be … HWU1 … HU12 ? ?) -U1 /2 width=1 by le_S/ #HW1U2
45     lapply (ldrop_trans_ge … HL21 … HLK1 ?) -L1 // -Hid
46     /3 width=8 by ssta_ldec, ldrop_inv_gen/
47   ]
48 | #a #I #G #L1 #V1 #T1 #U1 #_ #IHTU1 #L2 #s #d #e #HL21 #X1 #H1 #X2 #H2
49   elim (lift_inv_bind1 … H1) -H1 #V2 #T2 #HV12 #HT12 #H destruct
50   elim (lift_inv_bind1 … H2) -H2 #X #U2 #H1 #HU12 #H2 destruct
51   lapply (lift_mono … H1 … HV12) -H1 #H destruct /4 width=6 by ssta_bind, ldrop_skip/
52 | #G #L1 #V1 #T1 #U1 #_ #IHTU1 #L2 #s #d #e #HL21 #X1 #H1 #X2 #H2
53   elim (lift_inv_flat1 … H1) -H1 #V2 #T2 #HV12 #HT12 #H destruct
54   elim (lift_inv_flat1 … H2) -H2 #X #U2 #H1 #HU12 #H2 destruct
55   lapply (lift_mono … H1 … HV12) -H1 #H destruct /4 width=6 by ssta_appl/
56 | #G #L1 #W1 #T1 #U1 #_ #IHTU1 #L2 #s #d #e #HL21 #X #H #U2 #HU12
57   elim (lift_inv_flat1 … H) -H #W2 #T2 #_ #HT12 #H destruct /3 width=6 by ssta_cast/
58 ]
59 qed.
60
61 (* Inversion lemmas on relocation *******************************************)
62
63 lemma ssta_inv_lift1: ∀h,g,G. l_deliftable_sn (ssta h g G).
64 #h #g #G #L2 #T2 #U2 #H elim H -G -L2 -T2 -U2
65 [ #G #L2 #k #L1 #s #d #e #_ #X #H
66   >(lift_inv_sort2 … H) -X /2 width=3 by ssta_sort, lift_sort, ex2_intro/
67 | #G #L2 #K2 #V2 #U2 #W2 #i #HLK2 #HVW2 #HWU2 #IHVW2 #L1 #s #d #e #HL21 #X #H
68   elim (lift_inv_lref2 … H) * #Hid #H destruct [ -HVW2 | -IHVW2 ]
69   [ elim (ldrop_conf_lt … HL21 … HLK2) -L2 // #K1 #V1 #HLK1 #HK21 #HV12
70     elim (IHVW2 … HK21 … HV12) -K2 -V2 #W1 #HW12 #HVW1
71     elim (lift_trans_le … HW12 … HWU2) -W2 // >minus_plus <plus_minus_m_m
72     /3 width=8 by ssta_ldef, ex2_intro/
73   | lapply (ldrop_conf_ge … HL21 … HLK2 ?) -L2 // #HL1K2
74     elim (le_inv_plus_l … Hid) -Hid #Hdie #ei
75     elim (lift_split … HWU2 d (i-e+1)) -HWU2 // [3: /2 width=1 by le_S/ ]
76     [ #W0 #HW20 <le_plus_minus_comm // >minus_minus_m_m
77       /3 width=8 by ssta_ldef, le_S, ex2_intro/
78     | <le_plus_minus_comm //
79     ]
80   ]
81 | #G #L2 #K2 #W2 #U2 #l #i #HLK2 #HW2l #HWU2 #L1 #s #d #e #HL21 #X #H
82   elim (lift_inv_lref2 … H) * #Hid #H destruct
83   [ elim (ldrop_conf_lt … HL21 … HLK2) -L2 // #K1 #W1 #HLK1 #HK21 #HW12
84     lapply (da_inv_lift … HW2l … HK21 … HW12) -K2
85     elim (lift_trans_le … HW12 … HWU2) -W2 // >minus_plus <plus_minus_m_m
86     /3 width=8 by ssta_ldec, ex2_intro/
87   | lapply (ldrop_conf_ge … HL21 … HLK2 ?) -L2 // #HL1K2
88     elim (le_inv_plus_l … Hid) -Hid #Hdie #ei
89     elim (lift_split … HWU2 d (i-e+1)) -HWU2 // [3: /2 width=1 by le_S/ ]
90     [ #W0 #HW20 <le_plus_minus_comm // >minus_minus_m_m
91       /3 width=8 by ssta_ldec, le_S, ex2_intro/
92     | <le_plus_minus_comm //
93     ]
94   ]
95 | #a #I #G #L2 #V2 #T2 #U2 #_ #IHTU2 #L1 #s #d #e #HL21 #X #H
96   elim (lift_inv_bind2 … H) -H #V1 #T1 #HV12 #HT12 #H destruct
97   elim (IHTU2 (L1.ⓑ{I}V1) … HT12) -IHTU2 -HT12
98   /3 width=5 by ssta_bind, ldrop_skip, lift_bind, ex2_intro/
99 | #G #L2 #V2 #T2 #U2 #_ #IHTU2 #L1 #s #d #e #HL21 #X #H
100   elim (lift_inv_flat2 … H) -H #V1 #T1 #HV12 #HT12 #H destruct
101   elim (IHTU2 … HL21 … HT12) -L2 -HT12
102   /3 width=5 by ssta_appl, lift_flat, ex2_intro/
103 | #G #L2 #W2 #T2 #U2 #_ #IHTU2 #L1 #s #d #e #HL21 #X #H
104   elim (lift_inv_flat2 … H) -H #W1 #T1 #_ #HT12 #H destruct
105   elim (IHTU2 … HL21 … HT12) -L2 -HT12
106  /3 width=3 by ssta_cast, ex2_intro/
107 ]
108 qed-.
109
110 (* Advanced properties ******************************************************)
111
112 lemma ssta_da_conf: ∀h,g,G,L,T,U. ⦃G, L⦄ ⊢ T •[h, g] U →
113                     ∀l. ⦃G, L⦄ ⊢ T ▪[h, g] l → ⦃G, L⦄ ⊢ U ▪[h, g] l-1.
114 #h #g #G #L #T #U #H elim H -G -L -T -U
115 [ #G #L #k #l #H
116   lapply (da_inv_sort … H) -H /3 width=1 by da_sort, deg_next/
117 | #G #L #K #V #U #W #i #HLK #_ #HWU #IHVW #l #H
118   elim (da_inv_lref … H) -H * #K0 #V0 [| #l0] #HLK0 #HV0
119   lapply (ldrop_mono … HLK0 … HLK) -HLK0 #H destruct
120   lapply (ldrop_fwd_drop2 … HLK) -HLK /3 width=8 by da_lift/
121 | #G #L #K #W #U #l0 #i #HLK #_ #HWU #l #H -l0
122   elim (da_inv_lref … H) -H * #K0 #V0 [| #l1] #HLK0 #HV0 [| #H0 ]
123   lapply (ldrop_mono … HLK0 … HLK) -HLK0 #H destruct
124   lapply (ldrop_fwd_drop2 … HLK) -HLK /3 width=8 by da_lift/
125 | #a #I #G #L #V #T #U #_ #IHTU #l #H
126   lapply (da_inv_bind … H) -H /3 width=1 by da_bind/
127 | #G #L #V #T #U #_ #IHTU #l #H
128   lapply (da_inv_flat … H) -H /3 width=1 by da_flat/
129 | #G #L #W #T #U #_ #IHTU #l #H
130   lapply (da_inv_flat … H) -H /2 width=1 by /
131 ]
132 qed-.
133
134 (* Advanced forvard lemmas **************************************************)
135
136 lemma ssta_fwd_correct: ∀h,g,G,L,T,U. ⦃G, L⦄ ⊢ T •[h, g] U →
137                         ∃T0. ⦃G, L⦄ ⊢ U •[h, g] T0.
138 #h #g #G #L #T #U #H elim H -G -L -T -U
139 [ /2 width=2/
140 | #G #L #K #V #U #W #i #HLK #_ #HWU * #T #HWT
141   lapply (ldrop_fwd_drop2 … HLK) -HLK #HLK
142   elim (lift_total T 0 (i+1)) /3 width=11 by ssta_lift, ex_intro/
143 | #G #L #K #W #U #l #i #HLK #HWl #HWU
144   elim (da_ssta … HWl) -HWl #T #HWT
145   lapply (ldrop_fwd_drop2 … HLK) -HLK #HLK
146   elim (lift_total T 0 (i+1)) /3 width=11 by ssta_lift, ex_intro/
147 | #a #I #G #L #V #T #U #_ * /3 width=2 by ssta_bind, ex_intro/
148 | #G #L #V #T #U #_ * #T0 #HUT0 /3 width=2 by ssta_appl, ex_intro/
149 | #G #L #W #T #U #_ * /2 width=2 by ex_intro/
150 ]
151 qed-.