]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/etc_new/frees/frees_lift.etc
65b62920662bbe1caf8000b47eedaade0a3a6bb6
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / etc_new / frees / frees_lift.etc
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_2/ynat/ynat_max.ma".
16 include "basic_2/substitution/drop_drop.ma".
17 include "basic_2/multiple/frees.ma".
18
19 (* CONTEXT-SENSITIVE FREE VARIABLES *****************************************)
20
21 (* Advanced properties ******************************************************)
22
23 lemma frees_dec: ∀L,U,l,i. Decidable (frees l L U i).
24 #L #U @(f2_ind … rfw … L U) -L -U
25 #x #IH #L * *
26 [ -IH /3 width=5 by frees_inv_sort, or_intror/
27 | #j #Hx #l #i elim (ylt_split_eq i j) #Hji
28   [ -x @or_intror #H elim (ylt_yle_false … Hji)
29     lapply (frees_inv_lref_ge … H ?) -L -l /2 width=1 by ylt_fwd_le/
30   | -x /2 width=1 by or_introl/
31   | elim (ylt_split j l) #Hli
32     [ -x @or_intror #H elim (ylt_yle_false … Hji)
33       lapply (frees_inv_lref_skip … H ?) -L //
34     | elim (lt_or_ge j (|L|)) #Hj
35       [ elim (drop_O1_lt (Ⓕ) L j) // -Hj #I #K #W #HLK destruct
36         elim (IH K W … 0 (i-j-1)) -IH [1,3: /3 width=5 by frees_lref_be, drop_fwd_rfw, or_introl/ ] #HnW
37         @or_intror #H elim (frees_inv_lref_lt … H) // #Z #Y #X #_ #HLY -l
38         lapply (drop_mono … HLY … HLK) -L #H destruct /2 width=1 by/  
39       | -x @or_intror #H elim (ylt_yle_false … Hji)
40         lapply (frees_inv_lref_free … H ?) -l //
41       ]
42     ]
43   ]
44 | -IH /3 width=5 by frees_inv_gref, or_intror/
45 | #a #I #W #U #Hx #l #i destruct
46   elim (IH L W … l i) [1,3: /3 width=1 by frees_bind_sn, or_introl/ ] #HnW
47   elim (IH (L.ⓑ{I}W) U … (⫯l) (i+1)) -IH [1,3: /3 width=1 by frees_bind_dx, or_introl/ ] #HnU
48   @or_intror #H elim (frees_inv_bind … H) -H /2 width=1 by/
49 | #I #W #U #Hx #l #i destruct
50   elim (IH L W … l i) [1,3: /3 width=1 by frees_flat_sn, or_introl/ ] #HnW
51   elim (IH L U … l i) -IH [1,3: /3 width=1 by frees_flat_dx, or_introl/ ] #HnU
52   @or_intror #H elim (frees_inv_flat … H) -H /2 width=1 by/
53 ]
54 qed-.
55
56 lemma frees_S: ∀L,U,l,i. L ⊢ i ϵ 𝐅*[yinj l]⦃U⦄ → ∀I,K,W. ⬇[l] L ≡ K.ⓑ{I}W →
57                (K ⊢ ⫰(i-l) ϵ 𝐅*[0]⦃W⦄ → ⊥) → L ⊢ i ϵ 𝐅*[⫯l]⦃U⦄.
58 #L #U #l #i #H elim (frees_inv … H) -H /3 width=2 by frees_eq/
59 * #I #K #W #j #Hlj #Hji #HnU #HLK #HW #I0 #K0 #W0 #HLK0 #HnW0
60 lapply (yle_inv_inj … Hlj) -Hlj #Hlj
61 elim (le_to_or_lt_eq … Hlj) -Hlj
62 [ -I0 -K0 -W0 /3 width=9 by frees_be, yle_inj/
63 | -Hji -HnU #H destruct
64   lapply (drop_mono … HLK0 … HLK) #H destruct -I
65   elim HnW0 -L -U -HnW0 //
66 ]
67 qed.
68
69 (* Note: lemma 1250 *)
70 lemma frees_bind_dx_O: ∀a,I,L,W,U,i. L.ⓑ{I}W ⊢ ⫯i ϵ 𝐅*[0]⦃U⦄ →
71                        L ⊢ i ϵ 𝐅*[0]⦃ⓑ{a,I}W.U⦄.
72 #a #I #L #W #U #i #HU elim (frees_dec L W 0 i)
73 /4 width=5 by frees_S, frees_bind_dx, frees_bind_sn/
74 qed.
75
76 (* Properties on relocation *************************************************)
77
78 lemma frees_lift_ge: ∀K,T,l,i. K ⊢ i ϵ𝐅*[l]⦃T⦄ →
79                      ∀L,s,l0,m0. ⬇[s, l0, m0] L ≡ K →
80                      ∀U. ⬆[l0, m0] T ≡ U → l0 ≤ i →
81                      L ⊢ i+m0 ϵ 𝐅*[l]⦃U⦄.
82 #K #T #l #i #H elim H -K -T -l -i
83 [ #K #T #l #i #HnT #L #s #l0 #m0 #_ #U #HTU #Hl0i -K -s
84   @frees_eq #X #HXU elim (lift_div_le … HTU … HXU) -U /2 width=2 by/
85 | #I #K #K0 #T #V #l #i #j #Hlj #Hji #HnT #HK0 #HV #IHV #L #s #l0 #m0 #HLK #U #HTU #Hl0i
86   elim (ylt_split j l0) #H0
87   [ elim (drop_trans_lt … HLK … HK0) // -K #L0 #W #HL0 >yminus_SO2 #HLK0 #HVW
88     @(frees_be … HL0) -HL0 -HV /3 width=3 by ylt_plus_dx2_trans/
89     [ lapply (ylt_fwd_lt_O1 … H0) #H1
90       #X #HXU <(ymax_pre_sn l0 1) in HTU; /2 width=1 by ylt_fwd_le_succ1/ #HTU
91       <(ylt_inv_O1 l0) in H0; // -H1 #H0
92       elim (lift_div_le … HXU … HTU ?) -U /2 width=2 by ylt_fwd_succ2/
93     | >yplus_minus_comm_inj /2 width=1 by ylt_fwd_le/
94       <yplus_pred1 /4 width=5 by monotonic_yle_minus_dx, yle_pred, ylt_to_minus/
95     ]
96   | lapply (drop_trans_ge … HLK … HK0 ?) // -K #HLK0
97     lapply (drop_inv_gen … HLK0) >commutative_plus -HLK0 #HLK0
98     @(frees_be … HLK0) -HLK0 -IHV
99     /2 width=1 by monotonic_ylt_plus_dx, yle_plus_dx1_trans/
100     [ #X <yplus_inj #HXU elim (lift_div_le … HTU … HXU) -U /2 width=2 by/
101     | <yplus_minus_assoc_comm_inj //
102     ]
103   ]
104 ]
105 qed.
106
107 (* Inversion lemmas on relocation *******************************************)
108
109 lemma frees_inv_lift_be: ∀L,U,l,i. L ⊢ i ϵ 𝐅*[l]⦃U⦄ →
110                          ∀K,s,l0,m0. ⬇[s, l0, m0+1] L ≡ K →
111                          ∀T. ⬆[l0, m0+1] T ≡ U → l0 ≤ i → i ≤ l0 + m0 → ⊥.
112 #L #U #l #i #H elim H -L -U -l -i
113 [ #L #U #l #i #HnU #K #s #l0 #m0 #_ #T #HTU #Hl0i #Hilm0
114   elim (lift_split … HTU i m0) -HTU /2 width=2 by/
115 | #I #L #K0 #U #W #l #i #j #Hli #Hij #HnU #HLK0 #_ #IHW #K #s #l0 #m0 #HLK #T #HTU #Hl0i #Hilm0
116   elim (ylt_split j l0) #H1
117   [ elim (drop_conf_lt … HLK … HLK0) -L // #L0 #V #H #HKL0 #HVW
118     @(IHW … HKL0 … HVW)
119     [ /3 width=1 by monotonic_yle_minus_dx, yle_pred/
120     | >yplus_pred1 /2 width=1 by ylt_to_minus/
121       <yplus_minus_comm_inj /3 width=1 by monotonic_yle_minus_dx, yle_pred, ylt_fwd_le/
122     ]
123   | elim (lift_split … HTU j m0) -HTU /3 width=3 by ylt_yle_trans, ylt_fwd_le/
124   ]
125 ]
126 qed-.
127
128 lemma frees_inv_lift_ge: ∀L,U,l,i. L ⊢ i ϵ 𝐅*[l]⦃U⦄ →
129                          ∀K,s,l0,m0. ⬇[s, l0, m0] L ≡ K →
130                          ∀T. ⬆[l0, m0] T ≡ U → l0 + m0 ≤ i →
131                          K ⊢ i-m0 ϵ𝐅*[l-yinj m0]⦃T⦄.
132 #L #U #l #i #H elim H -L -U -l -i
133 [ #L #U #l #i #HnU #K #s #l0 #m0 #HLK #T #HTU #Hlm0i -L -s
134   elim (yle_inv_plus_inj2 … Hlm0i) -Hlm0i #Hl0im0 #Hm0i @frees_eq #X #HXT -K
135   elim (lift_trans_le … HXT … HTU) -T // >ymax_pre_sn /2 width=2 by/
136 | #I #L #K0 #U #W #l #i #j #Hli #Hij #HnU #HLK0 #_ #IHW #K #s #l0 #m0 #HLK #T #HTU #Hlm0i
137   elim (ylt_split j l0) #H1
138   [ elim (drop_conf_lt … HLK … HLK0) -L // #L0 #V #H #HKL0 #HVW
139     elim (yle_inv_plus_inj2 … Hlm0i) #H0 #Hm0i
140     @(frees_be … H) -H
141     [ /3 width=1 by yle_plus_dx1_trans, monotonic_yle_minus_dx/
142     | /2 width=3 by ylt_yle_trans/
143     | #X #HXT elim (lift_trans_ge … HXT … HTU) -T /2 width=2 by ylt_fwd_le_succ1/
144     | lapply (IHW … HKL0 … HVW ?) // -I -K -K0 -L0 -V -W -T -U -s
145       >yplus_pred1 /2 width=1 by ylt_to_minus/
146       <yplus_minus_comm_inj /3 width=1 by monotonic_yle_minus_dx, yle_pred, ylt_fwd_le/
147     ]
148   | elim (ylt_split j (l0+m0)) #H2
149     [ -L -I -W elim (yle_inv_inj2 … H1) -H1 #x #H1 #H destruct
150       lapply (ylt_plus2_to_minus_inj1 … H2) /2 width=1 by yle_inj/ #H3
151       lapply (ylt_fwd_lt_O1 … H3) -H3 #H3
152       elim (lift_split … HTU j (m0-1)) -HTU /2 width=1 by yle_inj/
153       [ >minus_minus_associative /2 width=1 by ylt_inv_inj/ <minus_n_n
154         -H2 #X #_ #H elim (HnU … H)
155       | <yminus_inj >yminus_SO2 >yplus_pred2 /2 width=1 by ylt_fwd_le_pred2/
156       ]
157     | lapply (drop_conf_ge … HLK … HLK0 ?) // -L #HK0
158       elim ( yle_inv_plus_inj2 … H2) -H2 #H2 #Hm0j
159       @(frees_be … HK0)
160       [ /2 width=1 by monotonic_yle_minus_dx/
161       | /2 width=1 by monotonic_ylt_minus_dx/
162       | #X #HXT elim (lift_trans_le … HXT … HTU) -T //
163         <yminus_inj >ymax_pre_sn /2 width=2 by/
164       | <yminus_inj >yplus_minus_assoc_comm_inj //
165         >ymax_pre_sn /3 width=5 by yle_trans, ylt_fwd_le/
166       ]
167     ]
168   ]
169 ]
170 qed-.