]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2A/multiple/llpx_sn_drop.ma
update in lambdadelta
[helm.git] / matita / matita / contribs / lambdadelta / basic_2A / multiple / llpx_sn_drop.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_2A/substitution/drop_drop.ma".
16 include "basic_2A/multiple/llpx_sn_lreq.ma".
17
18 (* LAZY SN POINTWISE EXTENSION OF A CONTEXT-SENSITIVE REALTION FOR TERMS ****)
19
20 (* Advanced forward lemmas **************************************************)
21
22 lemma llpx_sn_fwd_lref_dx: ∀R,L1,L2,l,i. llpx_sn R l (#i) L1 L2 →
23                            ∀I,K2,V2. ⬇[i] L2 ≡ K2.ⓑ{I}V2 →
24                            i < l ∨
25                            ∃∃K1,V1. ⬇[i] L1 ≡ K1.ⓑ{I}V1 & llpx_sn R 0 V1 K1 K2 &
26                                     R K1 V1 V2 & l ≤ i.
27 #R #L1 #L2 #l #i #H #I #K2 #V2 #HLK2 elim (llpx_sn_fwd_lref … H) -H [ * || * ]
28 [ #_ #H elim (lt_refl_false i)
29   lapply (drop_fwd_length_lt2 … HLK2) -HLK2
30   /2 width=3 by lt_to_le_to_lt/ (**) (* full auto too slow *)
31 | /2 width=1 by or_introl/
32 | #I #K11 #K22 #V11 #V22 #HLK11 #HLK22 #HK12 #HV12 #Hli
33   lapply (drop_mono … HLK22 … HLK2) -L2 #H destruct
34   /3 width=5 by ex4_2_intro, or_intror/
35 ]
36 qed-.
37
38 lemma llpx_sn_fwd_lref_sn: ∀R,L1,L2,l,i. llpx_sn R l (#i) L1 L2 →
39                            ∀I,K1,V1. ⬇[i] L1 ≡ K1.ⓑ{I}V1 →
40                            i < l ∨
41                            ∃∃K2,V2. ⬇[i] L2 ≡ K2.ⓑ{I}V2 & llpx_sn R 0 V1 K1 K2 &
42                                     R K1 V1 V2 & l ≤ i.
43 #R #L1 #L2 #l #i #H #I #K1 #V1 #HLK1 elim (llpx_sn_fwd_lref … H) -H [ * || * ]
44 [ #H #_ elim (lt_refl_false i)
45   lapply (drop_fwd_length_lt2 … HLK1) -HLK1
46   /2 width=3 by lt_to_le_to_lt/ (**) (* full auto too slow *)
47 | /2 width=1 by or_introl/
48 | #I #K11 #K22 #V11 #V22 #HLK11 #HLK22 #HK12 #HV12 #Hli
49   lapply (drop_mono … HLK11 … HLK1) -L1 #H destruct
50   /3 width=5 by ex4_2_intro, or_intror/
51 ]
52 qed-.
53
54 (* Advanced inversion lemmas ************************************************)
55
56 lemma llpx_sn_inv_lref_ge_dx: ∀R,L1,L2,l,i. llpx_sn R l (#i) L1 L2 → l ≤ i →
57                               ∀I,K2,V2. ⬇[i] L2 ≡ K2.ⓑ{I}V2 →
58                               ∃∃K1,V1. ⬇[i] L1 ≡ K1.ⓑ{I}V1 &
59                                        llpx_sn R 0 V1 K1 K2 & R K1 V1 V2.
60 #R #L1 #L2 #l #i #H #Hli #I #K2 #V2 #HLK2 elim (llpx_sn_fwd_lref_dx … H … HLK2) -L2
61 [ #H elim (ylt_yle_false … H Hli)
62 | * /2 width=5 by ex3_2_intro/
63 ]
64 qed-.
65
66 lemma llpx_sn_inv_lref_ge_sn: ∀R,L1,L2,l,i. llpx_sn R l (#i) L1 L2 → l ≤ i →
67                               ∀I,K1,V1. ⬇[i] L1 ≡ K1.ⓑ{I}V1 →
68                               ∃∃K2,V2. ⬇[i] L2 ≡ K2.ⓑ{I}V2 &
69                                        llpx_sn R 0 V1 K1 K2 & R K1 V1 V2.
70 #R #L1 #L2 #l #i #H #Hli #I #K1 #V1 #HLK1 elim (llpx_sn_fwd_lref_sn … H … HLK1) -L1
71 [ #H elim (ylt_yle_false … H Hli)
72 | * /2 width=5 by ex3_2_intro/
73 ]
74 qed-.
75
76 lemma llpx_sn_inv_lref_ge_bi: ∀R,L1,L2,l,i. llpx_sn R l (#i) L1 L2 → l ≤ i →
77                               ∀I1,I2,K1,K2,V1,V2.
78                               ⬇[i] L1 ≡ K1.ⓑ{I1}V1 → ⬇[i] L2 ≡ K2.ⓑ{I2}V2 →
79                               ∧∧ I1 = I2 & llpx_sn R 0 V1 K1 K2 & R K1 V1 V2.
80 #R #L1 #L2 #l #i #HL12 #Hli #I1 #I2 #K1 #K2 #V1 #V2 #HLK1 #HLK2
81 elim (llpx_sn_inv_lref_ge_sn … HL12 … HLK1) // -L1 -l
82 #J #Y #HY lapply (drop_mono … HY … HLK2) -L2 -i #H destruct /2 width=1 by and3_intro/
83 qed-.
84
85 fact llpx_sn_inv_S_aux: ∀R,L1,L2,T,l0. llpx_sn R l0 T L1 L2 → ∀l. l0 = l + 1 →
86                         ∀K1,K2,I,V1,V2. ⬇[l] L1 ≡ K1.ⓑ{I}V1 → ⬇[l] L2 ≡ K2.ⓑ{I}V2 →
87                         llpx_sn R 0 V1 K1 K2 → R K1 V1 V2 → llpx_sn R l T L1 L2.
88 #R #L1 #L2 #T #l0 #H elim H -L1 -L2 -T -l0
89 /2 width=1 by llpx_sn_gref, llpx_sn_free, llpx_sn_sort/
90 [ #L1 #L2 #l0 #i #HL12 #Hil #l #H #K1 #K2 #I #V1 #V2 #HLK1 #HLK2 #HK12 #HV12 destruct
91   elim (yle_split_eq i l) /2 width=1 by llpx_sn_skip, ylt_fwd_succ2/ -HL12 -Hil
92   #H destruct /2 width=9 by llpx_sn_lref/
93 | #I #L1 #L2 #K11 #K22 #V1 #V2 #l0 #i #Hl0i #HLK11 #HLK22 #HK12 #HV12 #_ #l #H #K1 #K2 #J #W1 #W2 #_ #_ #_ #_ destruct
94   /3 width=9 by llpx_sn_lref, yle_pred_sn/
95 | #a #I #L1 #L2 #V #T #l0 #_ #_ #IHV #IHT #l #H #K1 #K2 #J #W1 #W2 #HLK1 #HLK2 #HK12 #HW12 destruct
96   /4 width=9 by llpx_sn_bind, drop_drop/
97 | #I #L1 #L2 #V #T #l0 #_ #_ #IHV #IHT #l #H #K1 #K2 #J #W1 #W2 #HLK1 #HLK2 #HK12 #HW12 destruct
98   /3 width=9 by llpx_sn_flat/
99 ]
100 qed-.
101
102 lemma llpx_sn_inv_S: ∀R,L1,L2,T,l. llpx_sn R (l + 1) T L1 L2 →
103                      ∀K1,K2,I,V1,V2. ⬇[l] L1 ≡ K1.ⓑ{I}V1 → ⬇[l] L2 ≡ K2.ⓑ{I}V2 →
104                      llpx_sn R 0 V1 K1 K2 → R K1 V1 V2 → llpx_sn R l T L1 L2.
105 /2 width=9 by llpx_sn_inv_S_aux/ qed-.
106
107 lemma llpx_sn_inv_bind_O: ∀R. (∀L. reflexive … (R L)) →
108                           ∀a,I,L1,L2,V,T. llpx_sn R 0 (ⓑ{a,I}V.T) L1 L2 →
109                           llpx_sn R 0 V L1 L2 ∧ llpx_sn R 0 T (L1.ⓑ{I}V) (L2.ⓑ{I}V).
110 #R #HR #a #I #L1 #L2 #V #T #H elim (llpx_sn_inv_bind … H) -H
111 /3 width=9 by drop_pair, conj, llpx_sn_inv_S/
112 qed-.
113
114 (* More advanced forward lemmas *********************************************)
115
116 lemma llpx_sn_fwd_bind_O_dx: ∀R. (∀L. reflexive … (R L)) →
117                              ∀a,I,L1,L2,V,T. llpx_sn R 0 (ⓑ{a,I}V.T) L1 L2 →
118                              llpx_sn R 0 T (L1.ⓑ{I}V) (L2.ⓑ{I}V).
119 #R #HR #a #I #L1 #L2 #V #T #H elim (llpx_sn_inv_bind_O … H) -H //
120 qed-.
121
122 (* Advanced properties ******************************************************)
123
124 lemma llpx_sn_bind_repl_O: ∀R,I,L1,L2,V1,V2,T. llpx_sn R 0 T (L1.ⓑ{I}V1) (L2.ⓑ{I}V2) →
125                            ∀J,W1,W2. llpx_sn R 0 W1 L1 L2 → R L1 W1 W2 → llpx_sn R 0 T (L1.ⓑ{J}W1) (L2.ⓑ{J}W2).
126 /3 width=9 by llpx_sn_bind_repl_SO, llpx_sn_inv_S/ qed-.
127
128 lemma llpx_sn_dec: ∀R. (∀L,T1,T2. Decidable (R L T1 T2)) →
129                    ∀T,L1,L2,l. Decidable (llpx_sn R l T L1 L2).
130 #R #HR #T #L1 @(f2_ind … rfw … L1 T) -L1 -T
131 #x #IH #L1 * *
132 [ #k #Hx #L2 elim (eq_nat_dec (|L1|) (|L2|)) /3 width=1 by or_introl, llpx_sn_sort/
133 | #i #Hx #L2 elim (eq_nat_dec (|L1|) (|L2|))
134   [ #HL12 #l elim (ylt_split i l) /3 width=1 by llpx_sn_skip, or_introl/
135     #Hli elim (lt_or_ge i (|L1|)) #HiL1
136     elim (lt_or_ge i (|L2|)) #HiL2 /3 width=1 by or_introl, llpx_sn_free/
137     elim (drop_O1_lt (Ⓕ) … HiL2) #I2 #K2 #V2 #HLK2
138     elim (drop_O1_lt (Ⓕ) … HiL1) #I1 #K1 #V1 #HLK1
139     elim (eq_bind2_dec I2 I1)
140     [ #H2 elim (HR K1 V1 V2) -HR
141       [ #H3 elim (IH K1 V1 … K2 0) destruct
142         /3 width=9 by llpx_sn_lref, drop_fwd_rfw, or_introl/
143       ]
144     ]
145     -IH #H3 @or_intror
146     #H elim (llpx_sn_fwd_lref … H) -H [1,3,4,6,7,9: * ]
147     [1,3,5: /3 width=4 by lt_to_le_to_lt, lt_refl_false/
148     |7,8,9: /2 width=4 by ylt_yle_false/
149     ]
150     #Z #Y1 #Y2 #X1 #X2 #HLY1 #HLY2 #HY12 #HX12
151     lapply (drop_mono … HLY1 … HLK1) -HLY1 -HLK1
152     lapply (drop_mono … HLY2 … HLK2) -HLY2 -HLK2
153     #H #H0 destruct /2 width=1 by/
154   ]
155 | #p #Hx #L2 elim (eq_nat_dec (|L1|) (|L2|)) /3 width=1 by or_introl, llpx_sn_gref/
156 | #a #I #V #T #Hx #L2 #l destruct
157   elim (IH L1 V … L2 l) /2 width=1 by/
158   elim (IH (L1.ⓑ{I}V) T … (L2.ⓑ{I}V) (⫯l)) -IH /3 width=1 by or_introl, llpx_sn_bind/
159   #H1 #H2 @or_intror
160   #H elim (llpx_sn_inv_bind … H) -H /2 width=1 by/
161 | #I #V #T #Hx #L2 #l destruct
162   elim (IH L1 V … L2 l) /2 width=1 by/
163   elim (IH L1 T … L2 l) -IH /3 width=1 by or_introl, llpx_sn_flat/
164   #H1 #H2 @or_intror
165   #H elim (llpx_sn_inv_flat … H) -H /2 width=1 by/
166 ]
167 -x /4 width=4 by llpx_sn_fwd_length, or_intror/
168 qed-.
169
170 (* Properties on relocation *************************************************)
171
172 lemma llpx_sn_lift_le: ∀R. d_liftable R →
173                        ∀K1,K2,T,l0. llpx_sn R l0 T K1 K2 →
174                        ∀L1,L2,l,m. ⬇[Ⓕ, l, m] L1 ≡ K1 → ⬇[Ⓕ, l, m] L2 ≡ K2 →
175                        ∀U. ⬆[l, m] T ≡ U → l0 ≤ l → llpx_sn R l0 U L1 L2.
176 #R #HR #K1 #K2 #T #l0 #H elim H -K1 -K2 -T -l0
177 [ #K1 #K2 #l0 #k #HK12 #L1 #L2 #l #m #HLK1 #HLK2 #X #H #_ >(lift_inv_sort1 … H) -X
178   lapply (drop_fwd_length_eq2 … HLK1 HLK2 HK12) -K1 -K2 -l
179   /2 width=1 by llpx_sn_sort/
180 | #K1 #K2 #l0 #i #HK12 #Hil0 #L1 #L2 #l #m #HLK1 #HLK2 #X #H #Hl0 elim (lift_inv_lref1 … H) -H
181   * #Hli #H destruct
182   [ lapply (drop_fwd_length_eq2 … HLK1 HLK2 HK12) -K1 -K2 -l
183     /2 width=1 by llpx_sn_skip/
184   | elim (ylt_yle_false … Hil0) -L1 -L2 -K1 -K2 -m -Hil0
185     /3 width=3 by yle_trans, yle_inj/
186   ]
187 | #I #K1 #K2 #K11 #K22 #V1 #V2 #l0 #i #Hil0 #HK11 #HK22 #HK12 #HV12 #IHK12 #L1 #L2 #l #m #HLK1 #HLK2 #X #H #Hl0 elim (lift_inv_lref1 … H) -H
188   * #Hli #H destruct [ -HK12 | -IHK12 ]
189   [ elim (drop_trans_lt … HLK1 … HK11) // -K1
190     elim (drop_trans_lt … HLK2 … HK22) // -Hli -K2
191     /3 width=18 by llpx_sn_lref/
192   | lapply (drop_trans_ge_comm … HLK1 … HK11 ?) // -K1
193     lapply (drop_trans_ge_comm … HLK2 … HK22 ?) // -Hli -Hl0 -K2
194     /3 width=9 by llpx_sn_lref, yle_plus_dx1_trans/
195   ]
196 | #K1 #K2 #l0 #i #HK1 #HK2 #HK12 #L1 #L2 #l #m #HLK1 #HLK2 #X #H #Hl0 elim (lift_inv_lref1 … H) -H
197   * #Hil #H destruct
198   lapply (drop_fwd_length_eq2 … HLK1 HLK2 HK12) -HK12
199   [ /3 width=7 by llpx_sn_free, drop_fwd_be/
200   | lapply (drop_fwd_length … HLK1) -HLK1 #HLK1
201     lapply (drop_fwd_length … HLK2) -HLK2 #HLK2
202     @llpx_sn_free [ >HLK1 | >HLK2 ] -Hil -HLK1 -HLK2 /2 width=1 by monotonic_le_plus_r/ (**) (* explicit constructor *)
203   ]
204 | #K1 #K2 #l0 #p #HK12 #L1 #L2 #l #m #HLK1 #HLK2 #X #H #_ >(lift_inv_gref1 … H) -X
205   lapply (drop_fwd_length_eq2 … HLK1 HLK2 HK12) -K1 -K2 -l -m
206   /2 width=1 by llpx_sn_gref/
207 | #a #I #K1 #K2 #V #T #l0 #_ #_ #IHV #IHT #L1 #L2 #l #m #HLK1 #HLK2 #X #H #Hl0 elim (lift_inv_bind1 … H) -H
208   #W #U #HVW #HTU #H destruct /4 width=6 by llpx_sn_bind, drop_skip, yle_succ/
209 | #I #K1 #K2 #V #T #l0 #_ #_ #IHV #IHT #L1 #L2 #l #m #HLK1 #HLK2 #X #H #Hl0 elim (lift_inv_flat1 … H) -H
210   #W #U #HVW #HTU #H destruct /3 width=6 by llpx_sn_flat/
211 ]
212 qed-.
213
214 lemma llpx_sn_lift_ge: ∀R,K1,K2,T,l0. llpx_sn R l0 T K1 K2 →
215                        ∀L1,L2,l,m. ⬇[Ⓕ, l, m] L1 ≡ K1 → ⬇[Ⓕ, l, m] L2 ≡ K2 →
216                        ∀U. ⬆[l, m] T ≡ U → l ≤ l0 → llpx_sn R (l0+m) U L1 L2.
217 #R #K1 #K2 #T #l0 #H elim H -K1 -K2 -T -l0
218 [ #K1 #K2 #l0 #k #HK12 #L1 #L2 #l #m #HLK1 #HLK2 #X #H #_ >(lift_inv_sort1 … H) -X
219   lapply (drop_fwd_length_eq2 … HLK1 HLK2 HK12) -K1 -K2 -l
220   /2 width=1 by llpx_sn_sort/
221 | #K1 #K2 #l0 #i #HK12 #Hil0 #L1 #L2 #l #m #HLK1 #HLK2 #X #H #_ elim (lift_inv_lref1 … H) -H
222   * #_ #H destruct
223   lapply (drop_fwd_length_eq2 … HLK1 HLK2 HK12) -K1 -K2
224   [ /3 width=3 by llpx_sn_skip, ylt_plus_dx2_trans/
225   | /3 width=3 by llpx_sn_skip, monotonic_ylt_plus_dx/
226   ]
227 | #I #K1 #K2 #K11 #K22 #V1 #V2 #l0 #i #Hil0 #HK11 #HK22 #HK12 #HV12 #_ #L1 #L2 #l #m #HLK1 #HLK2 #X #H #Hl0 elim (lift_inv_lref1 … H) -H
228   * #Hil #H destruct
229   [ elim (ylt_yle_false … Hil0) -I -L1 -L2 -K1 -K2 -K11 -K22 -V1 -V2 -m -Hil0
230     /3 width=3 by ylt_yle_trans, ylt_inj/
231   | lapply (drop_trans_ge_comm … HLK1 … HK11 ?) // -K1
232     lapply (drop_trans_ge_comm … HLK2 … HK22 ?) // -Hil -Hl0 -K2
233     /3 width=9 by llpx_sn_lref, monotonic_yle_plus_dx/
234   ]
235 | #K1 #K2 #l0 #i #HK1 #HK2 #HK12 #L1 #L2 #l #m #HLK1 #HLK2 #X #H #Hl0 elim (lift_inv_lref1 … H) -H
236   * #Hil #H destruct
237   lapply (drop_fwd_length_eq2 … HLK1 HLK2 HK12) -HK12
238   [ /3 width=7 by llpx_sn_free, drop_fwd_be/
239   | lapply (drop_fwd_length … HLK1) -HLK1 #HLK1
240     lapply (drop_fwd_length … HLK2) -HLK2 #HLK2
241     @llpx_sn_free [ >HLK1 | >HLK2 ] -Hil -HLK1 -HLK2 /2 width=1 by monotonic_le_plus_r/ (**) (* explicit constructor *)
242   ]
243 | #K1 #K2 #l0 #p #HK12 #L1 #L2 #l #m #HLK1 #HLK2 #X #H #_ >(lift_inv_gref1 … H) -X
244   lapply (drop_fwd_length_eq2 … HLK1 HLK2 HK12) -K1 -K2 -l
245   /2 width=1 by llpx_sn_gref/
246 | #a #I #K1 #K2 #V #T #l0 #_ #_ #IHV #IHT #L1 #L2 #l #m #HLK1 #HLK2 #X #H #Hl0 elim (lift_inv_bind1 … H) -H
247   #W #U #HVW #HTU #H destruct /4 width=5 by llpx_sn_bind, drop_skip, yle_succ/
248 | #I #K1 #K2 #V #T #l0 #_ #_ #IHV #IHT #L1 #L2 #l #m #HLK1 #HLK2 #X #H #Hl0 elim (lift_inv_flat1 … H) -H
249   #W #U #HVW #HTU #H destruct /3 width=5 by llpx_sn_flat/
250 ]
251 qed-.
252
253 (* Inversion lemmas on relocation *******************************************)
254
255 lemma llpx_sn_inv_lift_le: ∀R. d_deliftable_sn R →
256                            ∀L1,L2,U,l0. llpx_sn R l0 U L1 L2 →
257                            ∀K1,K2,l,m. ⬇[Ⓕ, l, m] L1 ≡ K1 → ⬇[Ⓕ, l, m] L2 ≡ K2 →
258                            ∀T. ⬆[l, m] T ≡ U → l0 ≤ l → llpx_sn R l0 T K1 K2.
259 #R #HR #L1 #L2 #U #l0 #H elim H -L1 -L2 -U -l0
260 [ #L1 #L2 #l0 #k #HL12 #K1 #K2 #l #m #HLK1 #HLK2 #X #H #_ >(lift_inv_sort2 … H) -X
261   lapply (drop_fwd_length_eq1 … HLK1 HLK2 HL12) -L1 -L2 -l -m
262   /2 width=1 by llpx_sn_sort/
263 | #L1 #L2 #l0 #i #HL12 #Hil0 #K1 #K2 #l #m #HLK1 #HLK2 #X #H #_ elim (lift_inv_lref2 … H) -H
264   * #_ #H destruct
265   lapply (drop_fwd_length_eq1 … HLK1 HLK2 HL12) -L1 -L2
266   [ /2 width=1 by llpx_sn_skip/
267   | /3 width=3 by llpx_sn_skip, yle_ylt_trans/
268   ]
269 | #I #L1 #L2 #K11 #K22 #W1 #W2 #l0 #i #Hil0 #HLK11 #HLK22 #HK12 #HW12 #IHK12 #K1 #K2 #l #m #HLK1 #HLK2 #X #H #Hl0 elim (lift_inv_lref2 … H) -H
270   * #Hil #H destruct [ -HK12 | -IHK12 ]
271   [ elim (drop_conf_lt … HLK1 … HLK11) // -L1 #L1 #V1 #HKL1 #HKL11 #HVW1
272     elim (drop_conf_lt … HLK2 … HLK22) // -Hil -L2 #L2 #V2 #HKL2 #HKL22 #HVW2
273     elim (HR … HW12 … HKL11 … HVW1) -HR #V0 #HV0 #HV12
274     lapply (lift_inj … HV0 … HVW2) -HV0 -HVW2 #H destruct
275     /3 width=10 by llpx_sn_lref/
276   | lapply (drop_conf_ge … HLK1 … HLK11 ?) // -L1
277     lapply (drop_conf_ge … HLK2 … HLK22 ?) // -L2 -Hil0
278     elim (le_inv_plus_l … Hil) -Hil /4 width=9 by llpx_sn_lref, yle_trans, yle_inj/ (**) (* slow *)
279   ]
280 | #L1 #L2 #l0 #i #HL1 #HL2 #HL12 #K1 #K2 #l #m #HLK1 #HLK2 #X #H #Hl0 elim (lift_inv_lref2 … H) -H
281   * #_ #H destruct
282   lapply (drop_fwd_length_eq1 … HLK1 HLK2 HL12)
283   [ lapply (drop_fwd_length_le4 … HLK1) -HLK1
284     lapply (drop_fwd_length_le4 … HLK2) -HLK2
285     #HKL2 #HKL1 #HK12 @llpx_sn_free // /2 width=3 by transitive_le/ (**) (* full auto too slow *)
286   | lapply (drop_fwd_length … HLK1) -HLK1 #H >H in HL1; -H
287     lapply (drop_fwd_length … HLK2) -HLK2 #H >H in HL2; -H
288     /3 width=1 by llpx_sn_free, le_plus_to_minus_r/
289   ]
290 | #L1 #L2 #l0 #p #HL12 #K1 #K2 #l #m #HLK1 #HLK2 #X #H #_ >(lift_inv_gref2 … H) -X
291   lapply (drop_fwd_length_eq1 … HLK1 HLK2 HL12) -L1 -L2 -l -m
292   /2 width=1 by llpx_sn_gref/
293 | #a #I #L1 #L2 #W #U #l0 #_ #_ #IHW #IHU #K1 #K2 #l #m #HLK1 #HLK2 #X #H #Hl0 elim (lift_inv_bind2 … H) -H
294   #V #T #HVW #HTU #H destruct /4 width=6 by llpx_sn_bind, drop_skip, yle_succ/
295 | #I #L1 #L2 #W #U #l0 #_ #_ #IHW #IHU #K1 #K2 #l #m #HLK1 #HLK2 #X #H #Hl0 elim (lift_inv_flat2 … H) -H
296   #V #T #HVW #HTU #H destruct /3 width=6 by llpx_sn_flat/
297 ]
298 qed-.
299
300 lemma llpx_sn_inv_lift_be: ∀R,L1,L2,U,l0. llpx_sn R l0 U L1 L2 →
301                            ∀K1,K2,l,m. ⬇[Ⓕ, l, m] L1 ≡ K1 → ⬇[Ⓕ, l, m] L2 ≡ K2 →
302                            ∀T. ⬆[l, m] T ≡ U → l ≤ l0 → l0 ≤ yinj l + m → llpx_sn R l T K1 K2.
303 #R #L1 #L2 #U #l0 #H elim H -L1 -L2 -U -l0
304 [ #L1 #L2 #l0 #k #HL12 #K1 #K2 #l #m #HLK1 #HLK2 #X #H #_ #_ >(lift_inv_sort2 … H) -X
305   lapply (drop_fwd_length_eq1 … HLK1 HLK2 HL12) -L1 -L2 -l0 -m
306   /2 width=1 by llpx_sn_sort/
307 | #L1 #L2 #l0 #i #HL12 #Hil0 #K1 #K2 #l #m #HLK1 #HLK2 #X #H #Hl0 #Hl0m elim (lift_inv_lref2 … H) -H
308   * #Hil #H destruct
309   [ lapply (drop_fwd_length_eq1 … HLK1 HLK2 HL12) -L1 -L2
310     -Hil0 /3 width=1 by llpx_sn_skip, ylt_inj/
311   | elim (ylt_yle_false … Hil0) -L1 -L2 -Hl0 -Hil0
312     /3 width=3 by yle_trans, yle_inj/ (**) (* slow *)
313   ]
314 | #I #L1 #L2 #K11 #K22 #W1 #W2 #l0 #i #Hil0 #HLK11 #HLK22 #HK12 #HW12 #_ #K1 #K2 #l #m #HLK1 #HLK2 #X #H #Hl0 #Hl0m elim (lift_inv_lref2 … H) -H
315   * #Hil #H destruct
316   [ elim (ylt_yle_false … Hil0) -I -L1 -L2 -K11 -K22 -W1 -W2 -Hl0m -Hil0
317     /3 width=3 by ylt_yle_trans, ylt_inj/
318   | lapply (drop_conf_ge … HLK1 … HLK11 ?) // -L1
319     lapply (drop_conf_ge … HLK2 … HLK22 ?) // -L2 -Hil0 -Hl0 -Hl0m
320     elim (le_inv_plus_l … Hil) -Hil /3 width=9 by llpx_sn_lref, yle_inj/
321   ]
322 | #L1 #L2 #l0 #i #HL1 #HL2 #HL12 #K1 #K2 #l #m #HLK1 #HLK2 #X #H #Hl0 #Hl0m elim (lift_inv_lref2 … H) -H
323   * #_ #H destruct
324   lapply (drop_fwd_length_eq1 … HLK1 HLK2 HL12)
325   [ lapply (drop_fwd_length_le4 … HLK1) -HLK1
326     lapply (drop_fwd_length_le4 … HLK2) -HLK2
327     #HKL2 #HKL1 #HK12 @llpx_sn_free // /2 width=3 by transitive_le/ (**) (* full auto too slow *)
328   | lapply (drop_fwd_length … HLK1) -HLK1 #H >H in HL1; -H
329     lapply (drop_fwd_length … HLK2) -HLK2 #H >H in HL2; -H
330     /3 width=1 by llpx_sn_free, le_plus_to_minus_r/
331   ]
332 | #L1 #L2 #l0 #p #HL12 #K1 #K2 #l #m #HLK1 #HLK2 #X #H #_ #_ >(lift_inv_gref2 … H) -X
333   lapply (drop_fwd_length_eq1 … HLK1 HLK2 HL12) -L1 -L2 -l0 -m
334   /2 width=1 by llpx_sn_gref/
335 | #a #I #L1 #L2 #W #U #l0 #_ #_ #IHW #IHU #K1 #K2 #l #m #HLK1 #HLK2 #X #H #Hl0 #Hl0m elim (lift_inv_bind2 … H) -H
336   >commutative_plus #V #T #HVW #HTU #H destruct
337   @llpx_sn_bind [ /2 width=5 by/ ] -IHW (**) (* explicit constructor *)
338   @(IHU … HTU) -IHU -HTU /2 width=1 by drop_skip, yle_succ/
339 | #I #L1 #L2 #W #U #l0 #_ #_ #IHW #IHU #K1 #K2 #l #m #HLK1 #HLK2 #X #H #Hl0 #Hl0m elim (lift_inv_flat2 … H) -H
340   #V #T #HVW #HTU #H destruct /3 width=6 by llpx_sn_flat/
341 ]
342 qed-.
343
344 lemma llpx_sn_inv_lift_ge: ∀R,L1,L2,U,l0. llpx_sn R l0 U L1 L2 →
345                            ∀K1,K2,l,m. ⬇[Ⓕ, l, m] L1 ≡ K1 → ⬇[Ⓕ, l, m] L2 ≡ K2 →
346                            ∀T. ⬆[l, m] T ≡ U → yinj l + m ≤ l0 → llpx_sn R (l0-m) T K1 K2.
347 #R #L1 #L2 #U #l0 #H elim H -L1 -L2 -U -l0
348 [ #L1 #L2 #l0 #k #HL12 #K1 #K2 #l #m #HLK1 #HLK2 #X #H #_ >(lift_inv_sort2 … H) -X
349   lapply (drop_fwd_length_eq1 … HLK1 HLK2 HL12) -L1 -L2 -l
350   /2 width=1 by llpx_sn_sort/
351 | #L1 #L2 #l0 #i #HL12 #Hil0 #K1 #K2 #l #m #HLK1 #HLK2 #X #H #Hlml0 elim (lift_inv_lref2 … H) -H
352   * #Hil #H destruct [ -Hil0 | -Hlml0 ]
353   lapply (drop_fwd_length_eq1 … HLK1 HLK2 HL12) -L1 -L2
354   [ /4 width=3 by llpx_sn_skip, yle_plus1_to_minus_inj2, ylt_yle_trans, ylt_inj/
355   | elim (le_inv_plus_l … Hil) -Hil #_
356     /4 width=1 by llpx_sn_skip, monotonic_ylt_minus_dx, yle_inj/
357   ]
358 | #I #L1 #L2 #K11 #K22 #W1 #W2 #l0 #i #Hil0 #HLK11 #HLK22 #HK12 #HW12 #_ #K1 #K2 #l #m #HLK1 #HLK2 #X #H #Hlml0 elim (lift_inv_lref2 … H) -H
359   * #Hil #H destruct
360   [ elim (ylt_yle_false … Hil0) -I -L1 -L2 -K11 -K22 -W1 -W2 -Hil0
361     /3 width=3 by yle_fwd_plus_sn1, ylt_yle_trans, ylt_inj/
362   | lapply (drop_conf_ge … HLK1 … HLK11 ?) // -L1
363     lapply (drop_conf_ge … HLK2 … HLK22 ?) // -L2 -Hlml0 -Hil
364     /3 width=9 by llpx_sn_lref, monotonic_yle_minus_dx/
365   ]
366 | #L1 #L2 #l0 #i #HL1 #HL2 #HL12 #K1 #K2 #l #m #HLK1 #HLK2 #X #H #Hlml0 elim (lift_inv_lref2 … H) -H
367   * #_ #H destruct
368   lapply (drop_fwd_length_eq1 … HLK1 HLK2 HL12)
369   [ lapply (drop_fwd_length_le4 … HLK1) -HLK1
370     lapply (drop_fwd_length_le4 … HLK2) -HLK2
371     #HKL2 #HKL1 #HK12 @llpx_sn_free // /2 width=3 by transitive_le/ (**) (* full auto too slow *)
372   | lapply (drop_fwd_length … HLK1) -HLK1 #H >H in HL1; -H
373     lapply (drop_fwd_length … HLK2) -HLK2 #H >H in HL2; -H
374     /3 width=1 by llpx_sn_free, le_plus_to_minus_r/
375   ]
376 | #L1 #L2 #l0 #p #HL12 #K1 #K2 #l #m #HLK1 #HLK2 #X #H #_ >(lift_inv_gref2 … H) -X
377   lapply (drop_fwd_length_eq1 … HLK1 HLK2 HL12) -L1 -L2 -l
378   /2 width=1 by llpx_sn_gref/
379 | #a #I #L1 #L2 #W #U #l0 #_ #_ #IHW #IHU #K1 #K2 #l #m #HLK1 #HLK2 #X #H #Hlml0 elim (lift_inv_bind2 … H) -H
380   #V #T #HVW #HTU #H destruct
381   @llpx_sn_bind [ /2 width=5 by/ ] -IHW (**) (* explicit constructor *)
382   <yminus_succ1_inj /2 width=2 by yle_fwd_plus_sn2/
383   @(IHU … HTU) -IHU -HTU /2 width=1 by drop_skip, yle_succ/
384 | #I #L1 #L2 #W #U #l0 #_ #_ #IHW #IHU #K1 #K2 #l #m #HLK1 #HLK2 #X #H #Hlml0 elim (lift_inv_flat2 … H) -H
385   #V #T #HVW #HTU #H destruct /3 width=5 by llpx_sn_flat/
386 ]
387 qed-.
388
389 (* Advanced inversion lemmas on relocation **********************************)
390
391 lemma llpx_sn_inv_lift_O: ∀R,L1,L2,U. llpx_sn R 0 U L1 L2 →
392                           ∀K1,K2,m. ⬇[m] L1 ≡ K1 → ⬇[m] L2 ≡ K2 →
393                           ∀T. ⬆[0, m] T ≡ U → llpx_sn R 0 T K1 K2.
394 /2 width=11 by llpx_sn_inv_lift_be/ qed-.
395
396 lemma llpx_sn_drop_conf_O: ∀R,L1,L2,U. llpx_sn R 0 U L1 L2 →
397                            ∀K1,m. ⬇[m] L1 ≡ K1 → ∀T. ⬆[0, m] T ≡ U →
398                            ∃∃K2. ⬇[m] L2 ≡ K2 & llpx_sn R 0 T K1 K2.
399 #R #L1 #L2 #U #HU #K1 #m #HLK1 #T #HTU elim (llpx_sn_fwd_drop_sn … HU … HLK1)
400 /3 width=10 by llpx_sn_inv_lift_O, ex2_intro/
401 qed-.
402
403 lemma llpx_sn_drop_trans_O: ∀R,L1,L2,U. llpx_sn R 0 U L1 L2 →
404                             ∀K2,m. ⬇[m] L2 ≡ K2 → ∀T. ⬆[0, m] T ≡ U →
405                             ∃∃K1. ⬇[m] L1 ≡ K1 & llpx_sn R 0 T K1 K2.
406 #R #L1 #L2 #U #HU #K2 #m #HLK2 #T #HTU elim (llpx_sn_fwd_drop_dx … HU … HLK2)
407 /3 width=10 by llpx_sn_inv_lift_O, ex2_intro/
408 qed-.
409
410 (* Inversion lemmas on negated lazy pointwise extension *********************)
411
412 lemma nllpx_sn_inv_bind: ∀R. (∀L,T1,T2. Decidable (R L T1 T2)) →
413                          ∀a,I,L1,L2,V,T,l. (llpx_sn R l (ⓑ{a,I}V.T) L1 L2 → ⊥) →
414                          (llpx_sn R l V L1 L2 → ⊥) ∨ (llpx_sn R (⫯l) T (L1.ⓑ{I}V) (L2.ⓑ{I}V) → ⊥).
415 #R #HR #a #I #L1 #L2 #V #T #l #H elim (llpx_sn_dec … HR V L1 L2 l)
416 /4 width=1 by llpx_sn_bind, or_intror, or_introl/
417 qed-.
418
419 lemma nllpx_sn_inv_flat: ∀R. (∀L,T1,T2. Decidable (R L T1 T2)) →
420                          ∀I,L1,L2,V,T,l. (llpx_sn R l (ⓕ{I}V.T) L1 L2 → ⊥) →
421                          (llpx_sn R l V L1 L2 → ⊥) ∨ (llpx_sn R l T L1 L2 → ⊥).
422 #R #HR #I #L1 #L2 #V #T #l #H elim (llpx_sn_dec … HR V L1 L2 l)
423 /4 width=1 by llpx_sn_flat, or_intror, or_introl/
424 qed-.
425
426 lemma nllpx_sn_inv_bind_O: ∀R. (∀L,T1,T2. Decidable (R L T1 T2)) →
427                            ∀a,I,L1,L2,V,T. (llpx_sn R 0 (ⓑ{a,I}V.T) L1 L2 → ⊥) →
428                            (llpx_sn R 0 V L1 L2 → ⊥) ∨ (llpx_sn R 0 T (L1.ⓑ{I}V) (L2.ⓑ{I}V) → ⊥).
429 #R #HR #a #I #L1 #L2 #V #T #H elim (llpx_sn_dec … HR V L1 L2 0)
430 /4 width=1 by llpx_sn_bind_O, or_intror, or_introl/
431 qed-.