]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/lib/lambda-delta/reduction/pr.ma
reductions rules and one lemma
[helm.git] / matita / matita / lib / lambda-delta / reduction / pr.ma
1 (*
2     ||M||  This file is part of HELM, an Hypertextual, Electronic
3     ||A||  Library of Mathematics, developed at the Computer Science
4     ||T||  Department of the University of Bologna, Italy.
5     ||I||
6     ||T||
7     ||A||  This file is distributed under the terms of the
8     \   /  GNU General Public License Version 2
9      \ /
10       V_______________________________________________________________ *)
11
12 include "lambda-delta/substitution/thin.ma".
13
14 (* SINGLE STEP PARALLEL REDUCTION *******************************************)
15
16 inductive pr: lenv → term → term → Prop ≝
17 | pr_sort : ∀L,k. pr L (⋆k) (⋆k)
18 | pr_lref : ∀L,i. pr L (#i) (#i)
19 | pr_bind : ∀L,I,V1,V2,T1,T2. pr L V1 V2 → pr (L. 𝕓{I} V1) T1 T2 →
20             pr L (𝕓{I} V1. T1) (𝕓{I} V2. T2)
21 | pr_flat : ∀L,I,V1,V2,T1,T2. pr L V1 V2 → pr L T1 T2 →
22             pr L (𝕗{I} V1. T1) (𝕗{I} V2. T2)
23 | pr_beta : ∀L,V1,V2,W,T1,T2.
24             pr L V1 V2 → pr (L. 𝕓{Abst} W) T1 T2 → (*𝕓*)
25             pr L (𝕚{Appl} V1. 𝕚{Abst} W. T1) (𝕚{Abbr} V2. T2)
26 | pr_delta: ∀L,K,V1,V2,V,i.
27             ↓[0,i] L ≡ K. 𝕓{Abbr} V1 → pr K V1 V2 → ↑[0,i+1] V2 ≡ V →
28             pr L (#i) V
29 | pr_theta: ∀L,V,V1,V2,W1,W2,T1,T2.
30             pr L V1 V2 → ↑[0,1] V2 ≡ V → pr L W1 W2 → pr (L. 𝕓{Abbr} W1) T1 T2 → (*𝕓*)
31             pr L (𝕚{Appl} V1. 𝕚{Abbr} W1. T1) (𝕚{Abbr} W2. 𝕚{Appl} V. T2)
32 | pr_zeta : ∀L,V,T,T1,T2. ↑[0,1] T1 ≡ T → pr L T1 T2 →
33             pr L (𝕚{Abbr} V. T) T2
34 | pr_tau  : ∀L,V,T1,T2. pr L T1 T2 → pr L (𝕚{Cast} V. T1) T2
35 .
36
37 interpretation "single step parallel reduction" 'PR L T1 T2 = (pr L T1 T2).
38
39 (* The three main lemmas on reduction ***************************************)
40
41 lemma pr_inv_lift: ∀L,T1,T2. L ⊢ T1 ⇒ T2 →
42                    ∀d,e,K. ↓[d,e] L ≡ K → ∀U1. ↑[d,e] U1 ≡ T1 →
43                    ∃∃U2. ↑[d,e] U2 ≡ T2 & K ⊢ U1 ⇒ U2.
44 #L #T1 #T2 #H elim H -H L T1 T2
45 [ #L #k #d #e #K #_ #U1 #HU1
46   lapply (lift_inv_sort2 … HU1) -HU1 #H destruct -U1 /2/
47 | #L #i #d #e #K #_ #U1 #HU1
48   lapply (lift_inv_lref2 … HU1) -HU1 * * #Hid #H destruct -U1 /3/
49 | #L #I #V1 #V2 #T1 #T2 #_ #_ #IHV12 #IHT12 #d #e #K #HLK #X #HX
50   lapply (lift_inv_bind2 … HX) -HX * #V0 #T0 #HV01 #HT01 #HX destruct -X;
51   elim (IHV12 … HLK … HV01) -IHV12 #V3 #HV32 #HV03
52   elim (IHT12 … HT01) -IHT12 HT01 [2,3: -HV32 HV03 /3/] -HLK HV01 /3 width=5/
53 | #L #I #V1 #V2 #T1 #T2 #_ #_ #IHV12 #IHT12 #d #e #K #HLK #X #HX
54   elim (lift_inv_flat2 … HX) -HX #V0 #T0 #HV01 #HT01 #HX destruct -X;
55   elim (IHV12 … HLK … HV01) -IHV12 HV01 #V3 #HV32 #HV03
56   elim (IHT12 … HLK … HT01) -IHT12 HT01 HLK /3 width=5/
57 | #L #V1 #V2 #W1 #T1 #T2 #_ #_ #IHV12 #IHT12 #d #e #K #HLK #X #HX
58   elim (lift_inv_flat2 … HX) -HX #V0 #Y #HV01 #HY #HX destruct -X;
59   elim (lift_inv_bind2 … HY) -HY #W0 #T0 #HW01 #HT01 #HY destruct -Y;
60   elim (IHV12 … HLK … HV01) -IHV12 HV01 #V3 #HV32 #HV03
61   elim (IHT12 … HT01) -IHT12 HT01
62     [3: -HV32 HV03 @(thin_skip … HLK) /2/ |2: skip ] (**) (* /3 width=5/ is too slow *)
63     -HLK HW01
64   /3 width=5/
65 | #L #K0 #V1 #V2 #V0 #i #HLK0 #HV12 #HV20 #IHV12 #d #e #K #HLK #X #HX
66   lapply (lift_inv_lref2 … HX) -HX * * #Hid #HX destruct -X;
67   [ -HV12;
68     elim (thin_conf_lt … HLK … HLK0 Hid) -HLK HLK0 L #L #V3 #HKL #HK0L #HV31
69     elim (IHV12 … HK0L … HV31) -IHV12 HK0L HV31 #V4 #HV42 #HV34
70     elim (lift_trans_le … HV42 … HV20 ?) -HV42 HV20 V2 // #V2 #HV42
71     >arith5 // -Hid #HV20  
72     @(ex2_1_intro … V2) /2 width=6/ (**) (* /3 width=8/ is slow *)
73   | -IHV12;
74     lapply (thin_conf_ge … HLK … HLK0 Hid) -HLK HLK0 L #HK
75     elim (lift_free … HV20 d (i - e + 1) ? ? ?) -HV20 /2/
76     >arith3 /2/ -Hid /3 width=8/ (**) (* just /3 width=8/ is a bit slow *)
77   ]
78 | #L #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #HV2 #_ #_ #IHV12 #IHW12 #IHT12 #d #e #K #HLK #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 ? ? ? HLK ? HV01) -IHV12 HV01 #V3 #HV32 #HV03
82   elim (IHW12 ? ? ? HLK ? HW01) -IHW12 #W3 #HW32 #HW03
83   elim (IHT12 … HT01) -IHT12 HT01
84     [3: -HV2 HV32 HV03 HW32 HW03 @(thin_skip … HLK) /2/ |2: skip ] (**) (* /3/ is too slow *)
85     -HLK HW01 #T3 #HT32 #HT03
86   elim (lift_trans_le … HV32 … HV2 ?) -HV32 HV2 V2 // #V2 #HV32 #HV2
87   @(ex2_1_intro … (𝕓{Abbr}W3.𝕗{Appl}V2.T3)) /3/ (**) (* /4/ loops *)
88 | #L #V #T #T1 #T2 #HT1 #_ #IHT12 #d #e #K #HLK #X #HX
89   elim (lift_inv_bind2 … HX) -HX #V0 #T0 #_ #HT0 #H destruct -X;
90   elim (lift_conf_rev … HT1 … HT0 ?) -HT1 HT0 T // #T #HT0 #HT1
91   elim (IHT12 … HLK … HT1) -IHT12 HLK HT1 /3 width=5/
92 | #L #V #T1 #T2 #_ #IHT12 #d #e #K #HLK #X #HX
93   elim (lift_inv_flat2 … HX) -HX #V0 #T0 #_ #HT01 #H destruct -X;
94   elim (IHT12 … HLK … HT01) -IHT12 HLK HT01 /3/
95 ]
96 qed.
97
98 (* this may be moved *)
99 lemma pr_refl: ∀T,L. L ⊢ T ⇒ T.
100 #T elim T -T //
101 #I elim I -I /2/
102 qed.