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_2A/substitution/lift.ma".
17 (* BASIC TERM RELOCATION ****************************************************)
19 (* Main properties ***********************************************************)
21 theorem lift_inj: ∀l,m,T1,U. ⬆[l,m] T1 ≡ U → ∀T2. ⬆[l,m] T2 ≡ U → T1 = T2.
22 #l #m #T1 #U #H elim H -l -m -T1 -U
24 lapply (lift_inv_sort2 … HX) -HX //
25 | #i #l #m #Hil #X #HX
26 lapply (lift_inv_lref2_lt … HX ?) -HX //
27 | #i #l #m #Hli #X #HX
28 lapply (lift_inv_lref2_ge … HX ?) -HX /2 width=1 by monotonic_le_plus_l/
30 lapply (lift_inv_gref2 … HX) -HX //
31 | #a #I #V1 #V2 #T1 #T2 #l #m #_ #_ #IHV12 #IHT12 #X #HX
32 elim (lift_inv_bind2 … HX) -HX #V #T #HV1 #HT1 #HX destruct /3 width=1 by eq_f2/
33 | #I #V1 #V2 #T1 #T2 #l #m #_ #_ #IHV12 #IHT12 #X #HX
34 elim (lift_inv_flat2 … HX) -HX #V #T #HV1 #HT1 #HX destruct /3 width=1 by eq_f2/
38 theorem lift_div_le: ∀l1,m1,T1,T. ⬆[l1, m1] T1 ≡ T →
39 ∀l2,m2,T2. ⬆[l2 + m1, m2] T2 ≡ T →
41 ∃∃T0. ⬆[l1, m1] T0 ≡ T2 & ⬆[l2, m2] T0 ≡ T1.
42 #l1 #m1 #T1 #T #H elim H -l1 -m1 -T1 -T
43 [ #k #l1 #m1 #l2 #m2 #T2 #Hk #Hl12
44 lapply (lift_inv_sort2 … Hk) -Hk #Hk destruct /3 width=3 by lift_sort, ex2_intro/
45 | #i #l1 #m1 #Hil1 #l2 #m2 #T2 #Hi #Hl12
46 lapply (lt_to_le_to_lt … Hil1 Hl12) -Hl12 #Hil2
47 lapply (lift_inv_lref2_lt … Hi ?) -Hi /3 width=3 by lift_lref_lt, lt_plus_to_minus_r, lt_to_le_to_lt, ex2_intro/
48 | #i #l1 #m1 #Hil1 #l2 #m2 #T2 #Hi #Hl12
49 elim (lift_inv_lref2 … Hi) -Hi * #Hil2 #H destruct
50 [ -Hl12 lapply (lt_plus_to_lt_l … Hil2) -Hil2 #Hil2 /3 width=3 by lift_lref_lt, lift_lref_ge, ex2_intro/
51 | -Hil1 >plus_plus_comm_23 in Hil2; #H lapply (le_plus_to_le_r … H) -H #H
52 elim (le_inv_plus_l … H) -H #Hilm2 #Hm2i
53 lapply (transitive_le … Hl12 Hilm2) -Hl12 #Hl12
54 >le_plus_minus_comm // >(plus_minus_m_m i m2) in ⊢ (? ? ? %);
55 /4 width=3 by lift_lref_ge, ex2_intro/
57 | #p #l1 #m1 #l2 #m2 #T2 #Hk #Hl12
58 lapply (lift_inv_gref2 … Hk) -Hk #Hk destruct /3 width=3 by lift_gref, ex2_intro/
59 | #a #I #W1 #W #U1 #U #l1 #m1 #_ #_ #IHW #IHU #l2 #m2 #T2 #H #Hl12
60 lapply (lift_inv_bind2 … H) -H * #W2 #U2 #HW2 #HU2 #H destruct
61 elim (IHW … HW2) // -IHW -HW2 #W0 #HW2 #HW1
62 >plus_plus_comm_23 in HU2; #HU2 elim (IHU … HU2) /3 width=5 by lift_bind, le_S_S, ex2_intro/
63 | #I #W1 #W #U1 #U #l1 #m1 #_ #_ #IHW #IHU #l2 #m2 #T2 #H #Hl12
64 lapply (lift_inv_flat2 … H) -H * #W2 #U2 #HW2 #HU2 #H destruct
65 elim (IHW … HW2) // -IHW -HW2 #W0 #HW2 #HW1
66 elim (IHU … HU2) /3 width=5 by lift_flat, ex2_intro/
70 theorem lift_div_be: ∀l1,m1,T1,T. ⬆[l1, m1] T1 ≡ T →
71 ∀m,m2,T2. ⬆[l1 + m, m2] T2 ≡ T →
72 m ≤ m1 → m1 ≤ m + m2 →
73 ∃∃T0. ⬆[l1, m] T0 ≡ T2 & ⬆[l1, m + m2 - m1] T0 ≡ T1.
74 #l1 #m1 #T1 #T #H elim H -l1 -m1 -T1 -T
75 [ #k #l1 #m1 #m #m2 #T2 #H >(lift_inv_sort2 … H) -H /2 width=3 by lift_sort, ex2_intro/
76 | #i #l1 #m1 #Hil1 #m #m2 #T2 #H #Hm1 #Hm1m2
77 >(lift_inv_lref2_lt … H) -H /3 width=3 by lift_lref_lt, lt_plus_to_minus_r, lt_to_le_to_lt, ex2_intro/
78 | #i #l1 #m1 #Hil1 #m #m2 #T2 #H #Hm1 #Hm1m2
79 elim (lt_or_ge (i+m1) (l1+m+m2)) #Him1l1m2
80 [ elim (lift_inv_lref2_be … H) -H /2 width=1 by le_plus/
81 | >(lift_inv_lref2_ge … H ?) -H //
82 lapply (le_plus_to_minus … Him1l1m2) #Hl1m21i
83 elim (le_inv_plus_l … Him1l1m2) -Him1l1m2 #Hl1m12 #Hm2im1
84 @ex2_intro [2: /2 width=1 by lift_lref_ge_minus/ | skip ] -Hl1m12
85 @lift_lref_ge_minus_eq [ >plus_minus_associative // | /2 width=1 by minus_le_minus_minus_comm/ ]
87 | #p #l1 #m1 #m #m2 #T2 #H >(lift_inv_gref2 … H) -H /2 width=3 by lift_gref, ex2_intro/
88 | #a #I #V1 #V #T1 #T #l1 #m1 #_ #_ #IHV1 #IHT1 #m #m2 #X #H #Hm1 #Hm1m2
89 elim (lift_inv_bind2 … H) -H #V2 #T2 #HV2 #HT2 #H destruct
90 elim (IHV1 … HV2) -V // >plus_plus_comm_23 in HT2; #HT2
91 elim (IHT1 … HT2) -T /3 width=5 by lift_bind, ex2_intro/
92 | #I #V1 #V #T1 #T #l1 #m1 #_ #_ #IHV1 #IHT1 #m #m2 #X #H #Hm1 #Hm1m2
93 elim (lift_inv_flat2 … H) -H #V2 #T2 #HV2 #HT2 #H destruct
94 elim (IHV1 … HV2) -V //
95 elim (IHT1 … HT2) -T /3 width=5 by lift_flat, ex2_intro/
99 theorem lift_mono: ∀l,m,T,U1. ⬆[l,m] T ≡ U1 → ∀U2. ⬆[l,m] T ≡ U2 → U1 = U2.
100 #l #m #T #U1 #H elim H -l -m -T -U1
102 lapply (lift_inv_sort1 … HX) -HX //
103 | #i #l #m #Hil #X #HX
104 lapply (lift_inv_lref1_lt … HX ?) -HX //
105 | #i #l #m #Hli #X #HX
106 lapply (lift_inv_lref1_ge … HX ?) -HX //
108 lapply (lift_inv_gref1 … HX) -HX //
109 | #a #I #V1 #V2 #T1 #T2 #l #m #_ #_ #IHV12 #IHT12 #X #HX
110 elim (lift_inv_bind1 … HX) -HX #V #T #HV1 #HT1 #HX destruct /3 width=1 by eq_f2/
111 | #I #V1 #V2 #T1 #T2 #l #m #_ #_ #IHV12 #IHT12 #X #HX
112 elim (lift_inv_flat1 … HX) -HX #V #T #HV1 #HT1 #HX destruct /3 width=1 by eq_f2/
116 theorem lift_trans_be: ∀l1,m1,T1,T. ⬆[l1, m1] T1 ≡ T →
117 ∀l2,m2,T2. ⬆[l2, m2] T ≡ T2 →
118 l1 ≤ l2 → l2 ≤ l1 + m1 → ⬆[l1, m1 + m2] T1 ≡ T2.
119 #l1 #m1 #T1 #T #H elim H -l1 -m1 -T1 -T
120 [ #k #l1 #m1 #l2 #m2 #T2 #HT2 #_ #_
121 >(lift_inv_sort1 … HT2) -HT2 //
122 | #i #l1 #m1 #Hil1 #l2 #m2 #T2 #HT2 #Hl12 #_
123 lapply (lt_to_le_to_lt … Hil1 Hl12) -Hl12 #Hil2
124 lapply (lift_inv_lref1_lt … HT2 Hil2) /2 width=1 by lift_lref_lt/
125 | #i #l1 #m1 #Hil1 #l2 #m2 #T2 #HT2 #_ #Hl21
126 lapply (lift_inv_lref1_ge … HT2 ?) -HT2
127 [ @(transitive_le … Hl21 ?) -Hl21 /2 width=1 by monotonic_le_plus_l/
128 | -Hl21 /2 width=1 by lift_lref_ge/
130 | #p #l1 #m1 #l2 #m2 #T2 #HT2 #_ #_
131 >(lift_inv_gref1 … HT2) -HT2 //
132 | #a #I #V1 #V2 #T1 #T2 #l1 #m1 #_ #_ #IHV12 #IHT12 #l2 #m2 #X #HX #Hl12 #Hl21
133 elim (lift_inv_bind1 … HX) -HX #V0 #T0 #HV20 #HT20 #HX destruct
134 lapply (IHV12 … HV20 ? ?) // -IHV12 -HV20 #HV10
135 lapply (IHT12 … HT20 ? ?) /2 width=1 by lift_bind, monotonic_le_plus_l, le_S_S/ (* full auto a bit slow *)
136 | #I #V1 #V2 #T1 #T2 #l1 #m1 #_ #_ #IHV12 #IHT12 #l2 #m2 #X #HX #Hl12 #Hl21
137 elim (lift_inv_flat1 … HX) -HX #V0 #T0 #HV20 #HT20 #HX destruct
138 lapply (IHV12 … HV20 ? ?) // -IHV12 -HV20 #HV10
139 lapply (IHT12 … HT20 ? ?) /2 width=1 by lift_flat/ (**) (* full auto a bit slow *)
143 theorem lift_trans_le: ∀l1,m1,T1,T. ⬆[l1, m1] T1 ≡ T →
144 ∀l2,m2,T2. ⬆[l2, m2] T ≡ T2 → l2 ≤ l1 →
145 ∃∃T0. ⬆[l2, m2] T1 ≡ T0 & ⬆[l1 + m2, m1] T0 ≡ T2.
146 #l1 #m1 #T1 #T #H elim H -l1 -m1 -T1 -T
147 [ #k #l1 #m1 #l2 #m2 #X #HX #_
148 >(lift_inv_sort1 … HX) -HX /2 width=3 by lift_sort, ex2_intro/
149 | #i #l1 #m1 #Hil1 #l2 #m2 #X #HX #_
150 lapply (lt_to_le_to_lt … (l1+m2) Hil1 ?) // #Him2
151 elim (lift_inv_lref1 … HX) -HX * #Hil2 #HX destruct /4 width=3 by lift_lref_ge_minus, lift_lref_lt, lt_minus_to_plus, monotonic_le_plus_l, ex2_intro/
152 | #i #l1 #m1 #Hil1 #l2 #m2 #X #HX #Hl21
153 lapply (transitive_le … Hl21 Hil1) -Hl21 #Hil2
154 lapply (lift_inv_lref1_ge … HX ?) -HX /2 width=3 by transitive_le/ #HX destruct
155 >plus_plus_comm_23 /4 width=3 by lift_lref_ge_minus, lift_lref_ge, monotonic_le_plus_l, ex2_intro/
156 | #p #l1 #m1 #l2 #m2 #X #HX #_
157 >(lift_inv_gref1 … HX) -HX /2 width=3 by lift_gref, ex2_intro/
158 | #a #I #V1 #V2 #T1 #T2 #l1 #m1 #_ #_ #IHV12 #IHT12 #l2 #m2 #X #HX #Hl21
159 elim (lift_inv_bind1 … HX) -HX #V0 #T0 #HV20 #HT20 #HX destruct
160 elim (IHV12 … HV20) -IHV12 -HV20 //
161 elim (IHT12 … HT20) -IHT12 -HT20 /3 width=5 by lift_bind, le_S_S, ex2_intro/
162 | #I #V1 #V2 #T1 #T2 #l1 #m1 #_ #_ #IHV12 #IHT12 #l2 #m2 #X #HX #Hl21
163 elim (lift_inv_flat1 … HX) -HX #V0 #T0 #HV20 #HT20 #HX destruct
164 elim (IHV12 … HV20) -IHV12 -HV20 //
165 elim (IHT12 … HT20) -IHT12 -HT20 /3 width=5 by lift_flat, ex2_intro/
169 theorem lift_trans_ge: ∀l1,m1,T1,T. ⬆[l1, m1] T1 ≡ T →
170 ∀l2,m2,T2. ⬆[l2, m2] T ≡ T2 → l1 + m1 ≤ l2 →
171 ∃∃T0. ⬆[l2 - m1, m2] T1 ≡ T0 & ⬆[l1, m1] T0 ≡ T2.
172 #l1 #m1 #T1 #T #H elim H -l1 -m1 -T1 -T
173 [ #k #l1 #m1 #l2 #m2 #X #HX #_
174 >(lift_inv_sort1 … HX) -HX /2 width=3 by lift_sort, ex2_intro/
175 | #i #l1 #m1 #Hil1 #l2 #m2 #X #HX #Hlml
176 lapply (lt_to_le_to_lt … (l1+m1) Hil1 ?) // #Hil1m
177 lapply (lt_to_le_to_lt … (l2-m1) Hil1 ?) /2 width=1 by le_plus_to_minus_r/ #Hil2m
178 lapply (lt_to_le_to_lt … Hil1m Hlml) -Hil1m -Hlml #Hil2
179 lapply (lift_inv_lref1_lt … HX ?) -HX // #HX destruct /3 width=3 by lift_lref_lt, ex2_intro/
180 | #i #l1 #m1 #Hil1 #l2 #m2 #X #HX #_
181 elim (lift_inv_lref1 … HX) -HX * #Himl #HX destruct /4 width=3 by lift_lref_lt, lift_lref_ge, monotonic_le_minus_l, lt_plus_to_minus_r, transitive_le, ex2_intro/
182 | #p #l1 #m1 #l2 #m2 #X #HX #_
183 >(lift_inv_gref1 … HX) -HX /2 width=3 by lift_gref, ex2_intro/
184 | #a #I #V1 #V2 #T1 #T2 #l1 #m1 #_ #_ #IHV12 #IHT12 #l2 #m2 #X #HX #Hlml
185 elim (lift_inv_bind1 … HX) -HX #V0 #T0 #HV20 #HT20 #HX destruct
186 elim (IHV12 … HV20) -IHV12 -HV20 //
187 elim (IHT12 … HT20) -IHT12 -HT20 [2: <assoc_plus1 /2 width=1 by le_S_S/ ]
188 <plus_minus /3 width=5 by lift_bind, le_plus_to_minus_r, le_plus_b, ex2_intro/
189 | #I #V1 #V2 #T1 #T2 #l1 #m1 #_ #_ #IHV12 #IHT12 #l2 #m2 #X #HX #Hlml
190 elim (lift_inv_flat1 … HX) -HX #V0 #T0 #HV20 #HT20 #HX destruct
191 elim (IHV12 … HV20) -IHV12 -HV20 //
192 elim (IHT12 … HT20) -IHT12 -HT20 /3 width=5 by lift_flat, ex2_intro/
196 (* Advanced properties ******************************************************)
198 lemma lift_conf_O1: ∀T,T1,l1,m1. ⬆[l1, m1] T ≡ T1 → ∀T2,m2. ⬆[0, m2] T ≡ T2 →
199 ∃∃T0. ⬆[0, m2] T1 ≡ T0 & ⬆[l1 + m2, m1] T2 ≡ T0.
200 #T #T1 #l1 #m1 #HT1 #T2 #m2 #HT2
201 elim (lift_total T1 0 m2) #T0 #HT10
202 elim (lift_trans_le … HT1 … HT10) -HT1 // #X #HTX #HT20
203 lapply (lift_mono … HTX … HT2) -T #H destruct /2 width=3 by ex2_intro/
206 lemma lift_conf_be: ∀T,T1,l,m1. ⬆[l, m1] T ≡ T1 → ∀T2,m2. ⬆[l, m2] T ≡ T2 →
207 m1 ≤ m2 → ⬆[l + m1, m2 - m1] T1 ≡ T2.
208 #T #T1 #l #m1 #HT1 #T2 #m2 #HT2 #Hm12
209 elim (lift_split … HT2 (l+m1) m1) -HT2 // #X #H
210 >(lift_mono … H … HT1) -T //