]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/etc/cpr/cpr_lift.etc
- basic_2: induction for preservation results now uses supclosure
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / etc / cpr / cpr_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 "basic_2/unfold/tpss_lift.ma".
16 include "basic_2/reducibility/tpr_lift.ma".
17 include "basic_2/reducibility/cpr.ma".
18
19 (* CONTEXT-SENSITIVE PARALLEL REDUCTION ON TERMS ****************************)
20
21 (* Advanced properties ******************************************************)
22
23 lemma cpr_cdelta: ∀L,K,V1,W1,W2,i.
24                   ⇩[0, i] L ≡ K. ⓓV1 → K ⊢ V1 ▶* [0, |L| - i - 1] W1 →
25                   ⇧[0, i + 1] W1 ≡ W2 → L ⊢ #i ➡ W2.
26 #L #K #V1 #W1 #W2 #i #HLK #HVW1 #HW12
27 lapply (ldrop_fwd_ldrop2_length … HLK) #Hi
28 @ex2_intro [2: // | skip | @tpss_subst /width=6/ ] (**) (* /3 width=6/ is too slow *)
29 qed.
30
31 lemma cpr_abst: ∀L,V1,V2. L ⊢ V1 ➡ V2 → ∀V,T1,T2. L.ⓛV ⊢ T1 ➡ T2 →
32                           ∀a,I. L ⊢ ⓑ{a,I}V1. T1 ➡ ⓑ{a,I}V2. T2.
33 #L #V1 #V2 * #V0 #HV10 #HV02 #V #T1 #T2 * #T0 #HT10 #HT02 #a #I
34 lapply (tpss_inv_S2 … HT02 L V ?) -HT02 // #HT02
35 lapply (tpss_lsubr_trans … HT02 (L.ⓑ{I}V2) ?) -HT02 /2 width=1/ #HT02
36 @(ex2_intro … (ⓑ{a,I}V0.T0)) /2 width=1/ (* explicit constructors *)
37 qed.
38
39 lemma cpr_beta: ∀a,L,V1,V2,W,T1,T2.
40                 L ⊢ V1 ➡ V2 → L.ⓛW ⊢ T1 ➡ T2 → L ⊢ ⓐV1.ⓛ{a}W.T1 ➡ ⓓ{a}V2.T2.
41 #a #L #V1 #V2 #W #T1 #T2 * #V #HV1 #HV2 * #T #HT1 #HT2
42 lapply (tpss_inv_S2 … HT2 L W ?) -HT2 // #HT2
43 lapply (tpss_lsubr_trans … HT2 (L.ⓓV2) ?) -HT2 /2 width=1/ #HT2
44 @(ex2_intro … (ⓓ{a}V.T)) /2 width=1/ (**) (* explicit constructor, /3/ is too slow *)
45 qed.
46
47 lemma cpr_beta_dx: ∀a,L,V1,V2,W,T1,T2.
48                    V1 ➡ V2 → L.ⓛW ⊢ T1 ➡ T2 → L ⊢ ⓐV1.ⓛ{a}W.T1 ➡ ⓓ{a}V2.T2.
49 /3 width=1/ qed.
50
51 (* Advanced inversion lemmas ************************************************)
52
53 (* Basic_1: was: pr2_gen_lref *)
54 lemma cpr_inv_lref1: ∀L,T2,i. L ⊢ #i ➡ T2 →
55                      T2 = #i ∨
56                      ∃∃K,V1,T1. ⇩[0, i] L ≡ K. ⓓV1 &
57                                 K ⊢ V1 ▶* [0, |L| - i - 1] T1 &
58                                 ⇧[0, i + 1] T1 ≡ T2 &
59                                 i < |L|.
60 #L #T2 #i * #X #H
61 >(tpr_inv_atom1 … H) -H #H
62 elim (tpss_inv_lref1 … H) -H /2 width=1/
63 * /3 width=6/
64 qed-.
65
66 (* Basic_1: was pr2_gen_abbr *)
67 lemma cpr_inv_abbr1: ∀a,L,V1,T1,U2. L ⊢ ⓓ{a}V1. T1 ➡ U2 →
68                      (∃∃V,V2,T2. V1 ➡ V & L ⊢ V ▶* [O, |L|] V2 &
69                                  L. ⓓV ⊢ T1 ➡ T2 &
70                                  U2 = ⓓ{a}V2. T2
71                       ) ∨
72                       ∃∃T2. L.ⓓV1 ⊢ T1 ➡ T2 & ⇧[0,1] U2 ≡ T2 & a = true.
73 #a #L #V1 #T1 #Y * #X #H1 #H2
74 elim (tpr_inv_abbr1 … H1) -H1 *
75 [ #V #T #T0 #HV1 #HT1 #HT0 #H destruct
76   elim (tpss_inv_bind1 … H2) -H2 #V2 #T2 #HV2 #HT02 #H destruct
77   lapply (tps_lsubr_trans … HT0 (L. ⓓV) ?) -HT0 /2 width=1/ #HT0
78   lapply (tps_weak_full … HT0) -HT0 #HT0
79   lapply (tpss_lsubr_trans … HT02 (L. ⓓV) ?) -HT02 /2 width=1/ #HT02
80   lapply (tpss_weak_full … HT02) -HT02 #HT02
81   lapply (tpss_strap2 … HT0 HT02) -T0 /4 width=7/
82 | #T2 #HT12 #HXT2 #H destruct
83   elim (lift_total Y 0 1) #Z #HYZ
84   lapply (tpss_lift_ge … H2 (L.ⓓV1) … HXT2 … HYZ) -X // /2 width=1/ #H
85   lapply (cpr_intro … HT12 … H) -T2 /3 width=3/
86 ]
87 qed-.
88
89 (* Basic_1: was: pr2_gen_abst *)
90 lemma cpr_inv_abst1: ∀a,L,V1,T1,U2. L ⊢ ⓛ{a}V1. T1 ➡ U2 → ∀I,W.
91                      ∃∃V2,T2. L ⊢ V1 ➡ V2 & L. ⓑ{I} W ⊢ T1 ➡ T2 & U2 = ⓛ{a}V2. T2.
92 #a #L #V1 #T1 #Y * #X #H1 #H2 #I #W
93 elim (tpr_inv_abst1 … H1) -H1 #V #T #HV1 #HT1 #H destruct
94 elim (tpss_inv_bind1 … H2) -H2 #V2 #T2 #HV2 #HT2 #H destruct
95 lapply (tpss_lsubr_trans … HT2 (L. ⓑ{I} W) ?) -HT2 /2 width=1/ /4 width=5/
96 qed-.
97
98 (* Basic_1: was pr2_gen_appl *)
99 lemma cpr_inv_appl1: ∀L,V1,U0,U2. L ⊢ ⓐV1. U0 ➡ U2 →
100                      ∨∨ ∃∃V2,T2.              L ⊢ V1 ➡ V2 & L ⊢ U0 ➡ T2 &
101                                               U2 = ⓐV2. T2
102                       | ∃∃a,V2,W,T1,T2.       L ⊢ V1 ➡ V2 & L. ⓓV2 ⊢ T1 ➡ T2 &
103                                               U0 = ⓛ{a}W. T1 &
104                                               U2 = ⓓ{a}V2. T2
105                       | ∃∃a,V2,V,W1,W2,T1,T2. L ⊢ V1 ➡ V2 & L ⊢ W1 ➡ W2 & L. ⓓW2 ⊢ T1 ➡ T2 &
106                                               ⇧[0,1] V2 ≡ V &
107                                               U0 = ⓓ{a}W1. T1 &
108                                               U2 = ⓓ{a}W2. ⓐV. T2.
109 #L #V1 #U0 #Y * #X #H1 #H2
110 elim (tpr_inv_appl1 … H1) -H1 *
111 [ #V #U #HV1 #HU0 #H destruct
112   elim (tpss_inv_flat1 … H2) -H2 #V2 #U2 #HV2 #HU2 #H destruct /4 width=5/
113 | #a #V #W #T0 #T #HV1 #HT0 #H #H1 destruct
114   elim (tpss_inv_bind1 … H2) -H2 #V2 #T2 #HV2 #HT2 #H destruct
115   lapply (tpss_weak … HT2 0 (|L|+1) ? ?) -HT2 // /4 width=9/
116 | #a #V0 #V #W #W0 #T #T0 #HV10 #HW0 #HT0 #HV0 #H #H1 destruct
117   elim (tpss_inv_bind1 … H2) -H2 #W2 #X #HW02 #HX #HY destruct
118   elim (tpss_inv_flat1 … HX) -HX #V2 #T2 #HV2 #HT2 #H destruct
119   elim (tpss_inv_lift1_ge … HV2 … HV0 ?) -V // [3: /2 width=1/ |2: skip ] #V <minus_plus_m_m
120   lapply (tpss_weak … HT2 0 (|L|+1) ? ?) -HT2 // /4 width=13/
121 ]
122 qed-.
123
124 (* Note: the main property of simple terms *)
125 lemma cpr_inv_appl1_simple: ∀L,V1,T1,U. L ⊢ ⓐV1. T1 ➡ U → 𝐒⦃T1⦄ →
126                             ∃∃V2,T2. L ⊢ V1 ➡ V2 & L ⊢ T1 ➡ T2 &
127                                      U = ⓐV2. T2.
128 #L #V1 #T1 #U #H #HT1
129 elim (cpr_inv_appl1 … H) -H *
130 [ /2 width=5/
131 | #a #V2 #W #W1 #W2 #_ #_ #H #_ destruct
132   elim (simple_inv_bind … HT1)
133 | #a #V2 #V #W1 #W2 #U1 #U2 #_ #_ #_ #_ #H #_ destruct
134   elim (simple_inv_bind … HT1)
135 ]
136 qed-.
137
138 (* Advanced forward lemmas **************************************************)
139
140 lemma cpr_fwd_abst1: ∀a,L,V1,T1,U2. L ⊢ ⓛ{a}V1.T1 ➡ U2 → ∀b,I,W.
141                      ∃∃V2,T2. L ⊢ ⓑ{b,I}W.T1 ➡ ⓑ{b,I}W.T2 &
142                               U2 = ⓛ{a}V2.T2.
143 #a #L #V1 #T1 #U2 * #U #H #HU2 #b #I #W
144 elim (tpr_fwd_abst1 … H b I W) -H #V #T #HT1 #H destruct
145 elim (tpss_inv_bind1 … HU2) -HU2 #V2 #T2 #_ #HT2
146 lapply (tpss_lsubr_trans … HT2 (L.ⓑ{I}W) ?) -HT2 /2 width=1/ /4 width=5/
147 qed-.
148
149 (* Relocation properties ****************************************************)
150
151 (* Basic_1: was: pr2_lift *)
152 lemma cpr_lift: ∀L,K,d,e. ⇩[d, e] L ≡ K →
153                 ∀T1,U1. ⇧[d, e] T1 ≡ U1 → ∀T2,U2. ⇧[d, e] T2 ≡ U2 →
154                 K ⊢ T1 ➡ T2 → L ⊢ U1 ➡ U2.
155 #L #K #d #e #HLK #T1 #U1 #HTU1 #T2 #U2 #HTU2 * #T #HT1 #HT2
156 elim (lift_total T d e) #U #HTU
157 lapply (tpr_lift … HT1 … HTU1 … HTU) -T1 #HU1
158 elim (lt_or_ge (|K|) d) #HKd
159 [ lapply (tpss_lift_le … HT2 … HLK HTU … HTU2) -T2 -T -HLK [ /2 width=2/ | /3 width=4/ ]
160 | lapply (tpss_lift_be … HT2 … HLK HTU … HTU2) -T2 -T -HLK // /3 width=4/
161 ]
162 qed.
163
164 (* Basic_1: was: pr2_gen_lift *)
165 lemma cpr_inv_lift1: ∀L,K,d,e. ⇩[d, e] L ≡ K →
166                      ∀T1,U1. ⇧[d, e] T1 ≡ U1 → ∀U2. L ⊢ U1 ➡ U2 →
167                      ∃∃T2. ⇧[d, e] T2 ≡ U2 & K ⊢ T1 ➡ T2.
168 #L #K #d #e #HLK #T1 #U1 #HTU1 #U2 * #U #HU1 #HU2
169 elim (tpr_inv_lift1 … HU1 … HTU1) -U1 #T #HTU #T1
170 elim (lt_or_ge (|L|) d) #HLd
171 [ elim (tpss_inv_lift1_le … HU2 … HLK … HTU ?) -U -HLK /2 width=2/
172   /3 width=7 by ex2_intro, cpr_intro/
173 | elim (lt_or_ge (|L|) (d + e)) #HLde
174   [ elim (tpss_inv_lift1_be_up … HU2 … HLK … HTU ? ?) -U -HLK // /2 width=2/
175     /3 width=7 by ex2_intro, cpr_intro/
176   | elim (tpss_inv_lift1_be … HU2 … HLK … HTU ? ?) -U -HLK //
177     /3 width=7 by ex2_intro, cpr_intro/
178   ]
179 ]
180 qed.