]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambda-delta/Basic-2/reduction/tpr_lift.ma
412a0a2ede2041bd801611e1c78bbcdf5d9d4102
[helm.git] / matita / matita / contribs / lambda-delta / Basic-2 / reduction / tpr_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/substitution/tps_lift.ma".
16 include "Basic-2/reduction/tpr.ma".
17
18 (* Relocation properties ****************************************************)
19
20 lemma tpr_lift: ∀T1,T2. T1 ⇒ T2 →
21                 ∀d,e,U1. ↑[d, e] T1 ≡ U1 → ∀U2. ↑[d, e] T2 ≡ U2 → U1 ⇒ U2.
22 #T1 #T2 #H elim H -H T1 T2
23 [ * #i #d #e #U1 #HU1 #U2 #HU2
24   lapply (lift_mono … HU1 … HU2) -HU1 #H destruct -U1
25   [ lapply (lift_inv_sort1 … HU2) -HU2 #H destruct -U2 //
26   | lapply (lift_inv_lref1 … HU2) * * #Hid #H destruct -U2 //
27   ]
28 | #I #V1 #V2 #T1 #T2 #_ #_ #IHV12 #IHT12 #d #e #X1 #HX1 #X2 #HX2
29   elim (lift_inv_flat1 … HX1) -HX1 #W1 #U1 #HVW1 #HTU1 #HX1 destruct -X1;
30   elim (lift_inv_flat1 … HX2) -HX2 #W2 #U2 #HVW2 #HTU2 #HX2 destruct -X2 /3/
31 | #V1 #V2 #W #T1 #T2 #_ #_ #IHV12 #IHT12 #d #e #X1 #HX1 #X2 #HX2
32   elim (lift_inv_flat1 … HX1) -HX1 #V0 #X #HV10 #HX #HX1 destruct -X1;
33   elim (lift_inv_bind1 … HX) -HX #W0 #T0 #HW0 #HT10 #HX destruct -X;
34   elim (lift_inv_bind1 … HX2) -HX2 #V3 #T3 #HV23 #HT23 #HX2 destruct -X2 /3/
35 | #I #V1 #V2 #T1 #T2 #T0 #HV12 #HT12 #HT2 #IHV12 #IHT12 #d #e #X1 #HX1 #X2 #HX2
36   elim (lift_inv_bind1 … HX1) -HX1 #W1 #U1 #HVW1 #HTU1 #HX1 destruct -X1;
37   elim (lift_inv_bind1 … HX2) -HX2 #W2 #U0 #HVW2 #HTU0 #HX2 destruct -X2;
38   elim (lift_total T2 (d + 1) e) #U2 #HTU2
39   @tpr_delta
40   [4: @(tps_lift_le … HT2 … HTU2 HTU0 ?) /2/ |1: skip |2: /2/ |3: /2/ ] (**) (*/3. is too slow *)
41 | #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #HV2 #_ #_ #IHV12 #IHW12 #IHT12 #d #e #X1 #HX1 #X2 #HX2
42   elim (lift_inv_flat1 … HX1) -HX1 #V0 #X #HV10 #HX #HX1 destruct -X1;
43   elim (lift_inv_bind1 … HX) -HX #W0 #T0 #HW0 #HT10 #HX destruct -X;
44   elim (lift_inv_bind1 … HX2) -HX2 #W3 #X #HW23 #HX #HX2 destruct -X2;
45   elim (lift_inv_flat1 … HX) -HX #V3 #T3 #HV3 #HT23 #HX destruct -X;
46   elim (lift_trans_ge … HV2 … HV3 ?) -HV2 HV3 V // /3/
47 | #V #T #T1 #T2 #HT1 #_ #IHT12 #d #e #X #HX #T0 #HT20
48   elim (lift_inv_bind1 … HX) -HX #V3 #T3 #_ #HT3 #HX destruct -X;
49   elim (lift_trans_ge … HT1 … HT3 ?) -HT1 HT3 T // /3 width=6/
50 | #V #T1 #T2 #_ #IHT12 #d #e #X #HX #T #HT2
51   elim (lift_inv_flat1 … HX) -HX #V0 #T0 #_ #HT0 #HX destruct -X /3/
52 ]
53 qed.
54
55 lemma tpr_inv_lift: ∀T1,T2. T1 ⇒ T2 →
56                     ∀d,e,U1. ↑[d, e] U1 ≡ T1 →
57                     ∃∃U2. ↑[d, e] U2 ≡ T2 & U1 ⇒ U2.
58 #T1 #T2 #H elim H -H T1 T2
59 [ * #i #d #e #U1 #HU1
60   [ lapply (lift_inv_sort2 … HU1) -HU1 #H destruct -U1 /2/
61   | lapply (lift_inv_lref2 … HU1) -HU1 * * #Hid #H destruct -U1 /3/
62   ]
63 | #I #V1 #V2 #T1 #T2 #_ #_ #IHV12 #IHT12 #d #e #X #HX
64   elim (lift_inv_flat2 … HX) -HX #V0 #T0 #HV01 #HT01 #HX destruct -X;
65   elim (IHV12 … HV01) -IHV12 HV01;
66   elim (IHT12 … HT01) -IHT12 HT01 /3 width=5/
67 | #V1 #V2 #W1 #T1 #T2 #_ #_ #IHV12 #IHT12 #d #e #X #HX
68   elim (lift_inv_flat2 … HX) -HX #V0 #Y #HV01 #HY #HX destruct -X;
69   elim (lift_inv_bind2 … HY) -HY #W0 #T0 #HW01 #HT01 #HY destruct -Y;
70   elim (IHV12 … HV01) -IHV12 HV01;
71   elim (IHT12 … HT01) -IHT12 HT01 /3 width=5/
72 | #I #V1 #V2 #T1 #T2 #T0 #_ #_ #HT20 #IHV12 #IHT12 #d #e #X #HX
73   elim (lift_inv_bind2 … HX) -HX #W1 #U1 #HWV1 #HUT1 #HX destruct -X;
74   elim (IHV12 … HWV1) -IHV12 HWV1 #W2 #HWV2 #HW12
75   elim (IHT12 … HUT1) -IHT12 HUT1 #U2 #HUT2 #HU12
76   elim (tps_inv_lift1_le … HT20 … HUT2 ?) -HT20 HUT2 // [3: /2 width=5/ |2: skip ] #U0 #HU20 #HUT0
77   @ex2_1_intro  [2: /2/ |1: skip |3: /2/ ] (**) (* /3 width=5/ is slow *)
78 | #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #HV2 #_ #_ #IHV12 #IHW12 #IHT12 #d #e #X #HX
79   elim (lift_inv_flat2 … HX) -HX #V0 #Y #HV01 #HY #HX destruct -X;
80   elim (lift_inv_bind2 … HY) -HY #W0 #T0 #HW01 #HT01 #HY destruct -Y;
81   elim (IHV12 … HV01) -IHV12 HV01 #V3 #HV32 #HV03
82   elim (IHW12 … HW01) -IHW12 HW01 #W3 #HW32 #HW03
83   elim (IHT12 … HT01) -IHT12 HT01 #T3 #HT32 #HT03
84   elim (lift_trans_le … HV32 … HV2 ?) -HV32 HV2 V2 // #V2 #HV32 #HV2
85   @ex2_1_intro [2: /3/ |1: skip |3: /2/ ] (**) (* /4 width=5/ is slow *)
86 | #V #T #T1 #T2 #HT1 #_ #IHT12 #d #e #X #HX
87   elim (lift_inv_bind2 … HX) -HX #V0 #T0 #_ #HT0 #H destruct -X;
88   elim (lift_div_le … HT1 … HT0 ?) -HT1 HT0 T // #T #HT0 #HT1
89   elim (IHT12 … HT1) -IHT12 HT1 /3 width=5/
90 | #V #T1 #T2 #_ #IHT12 #d #e #X #HX
91   elim (lift_inv_flat2 … HX) -HX #V0 #T0 #_ #HT01 #H destruct -X;
92   elim (IHT12 … HT01) -IHT12 HT01 /3/
93 ]
94 qed.
95
96 (* Advanced inversion lemmas ************************************************)
97
98 fact tpr_inv_abst1_aux: ∀U1,U2. U1 ⇒ U2 → ∀V1,T1. U1 = 𝕔{Abst} V1. T1 →
99                         ∃∃V2,T2. V1 ⇒ V2 & T1 ⇒ T2 & U2 = 𝕔{Abst} V2. T2.
100 #U1 #U2 * -U1 U2
101 [ #I #V #T #H destruct
102 | #I #V1 #V2 #T1 #T2 #_ #_ #V #T #H destruct
103 | #V1 #V2 #W #T1 #T2 #_ #_ #V #T #H destruct
104 | #I #V1 #V2 #T1 #T2 #T #HV12 #HT12 #HT2 #V0 #T0 #H destruct -I V1 T1;
105   <(tps_inv_refl_SO2 … HT2 ? ? ?) -HT2 T /2 width=5/
106 | #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #V0 #T0 #H destruct
107 | #V #T #T1 #T2 #_ #_ #V0 #T0 #H destruct
108 | #V #T1 #T2 #_ #V0 #T0 #H destruct
109 ]
110 qed.
111
112 lemma tpr_inv_abst1: ∀V1,T1,U2. 𝕔{Abst} V1. T1 ⇒ U2 →
113                      ∃∃V2,T2. V1 ⇒ V2 & T1 ⇒ T2 & U2 = 𝕔{Abst} V2. T2.
114 /2/ qed.