]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/reducibility/tpr.ma
- improved Makefile esp. with the "trim" function
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / reducibility / tpr.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.ma".
16
17 (* CONTEXT-FREE PARALLEL REDUCTION ON TERMS *********************************)
18
19 (* Basic_1: includes: pr0_delta1 *)
20 inductive tpr: relation term ≝
21 | tpr_atom : ∀I. tpr (⓪{I}) (⓪{I})
22 | tpr_flat : ∀I,V1,V2,T1,T2. tpr V1 V2 → tpr T1 T2 →
23              tpr (ⓕ{I} V1. T1) (ⓕ{I} V2. T2)
24 | tpr_beta : ∀a,V1,V2,W,T1,T2.
25              tpr V1 V2 → tpr T1 T2 → tpr (ⓐV1. ⓛ{a}W. T1) (ⓓ{a}V2. T2)
26 | tpr_delta: ∀a,I,V1,V2,T1,T,T2.
27              tpr V1 V2 → tpr T1 T → ⋆. ⓑ{I} V2 ⊢ T ▶ [0, 1] T2 →
28              tpr (ⓑ{a,I} V1. T1) (ⓑ{a,I} V2. T2)
29 | tpr_theta: ∀a,V,V1,V2,W1,W2,T1,T2.
30              tpr V1 V2 → ⇧[0,1] V2 ≡ V → tpr W1 W2 → tpr T1 T2 →
31              tpr (ⓐV1. ⓓ{a}W1. T1) (ⓓ{a}W2. ⓐV. T2)
32 | tpr_zeta : ∀V,T1,T,T2. tpr T1 T → ⇧[0, 1] T2 ≡ T → tpr (+ⓓV. T1) T2
33 | tpr_tau  : ∀V,T1,T2. tpr T1 T2 → tpr (ⓝV. T1) T2
34 .
35
36 interpretation
37    "context-free parallel reduction (term)"
38    'PRed T1 T2 = (tpr T1 T2).
39
40 (* Basic properties *********************************************************)
41
42 lemma tpr_bind: ∀a,I,V1,V2,T1,T2. V1 ➡ V2 → T1 ➡ T2 → ⓑ{a,I} V1. T1 ➡ ⓑ{a,I} V2. T2.
43 /2 width=3/ qed.
44
45 (* Basic_1: was by definition: pr0_refl *)
46 lemma tpr_refl: reflexive … tpr.
47 #T elim T -T //
48 #I elim I -I /2 width=1/
49 qed.
50
51 (* Basic inversion lemmas ***************************************************)
52
53 fact tpr_inv_atom1_aux: ∀U1,U2. U1 ➡ U2 → ∀I. U1 = ⓪{I} → U2 = ⓪{I}.
54 #U1 #U2 * -U1 -U2
55 [ //
56 | #I #V1 #V2 #T1 #T2 #_ #_ #k #H destruct
57 | #a #V1 #V2 #W #T1 #T2 #_ #_ #k #H destruct
58 | #a #I #V1 #V2 #T1 #T #T2 #_ #_ #_ #k #H destruct
59 | #a #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #k #H destruct
60 | #V #T1 #T #T2 #_ #_ #k #H destruct
61 | #V #T1 #T2 #_ #k #H destruct
62 ]
63 qed.
64
65 (* Basic_1: was: pr0_gen_sort pr0_gen_lref *)
66 lemma tpr_inv_atom1: ∀I,U2. ⓪{I} ➡ U2 → U2 = ⓪{I}.
67 /2 width=3/ qed-.
68
69 fact tpr_inv_bind1_aux: ∀U1,U2. U1 ➡ U2 → ∀a,I,V1,T1. U1 = ⓑ{a,I} V1. T1 →
70                         (∃∃V2,T,T2. V1 ➡ V2 & T1 ➡ T &
71                                     ⋆.  ⓑ{I} V2 ⊢ T ▶ [0, 1] T2 &
72                                     U2 = ⓑ{a,I} V2. T2
73                         ) ∨
74                         ∃∃T. T1 ➡ T & ⇧[0, 1] U2 ≡ T & a = true & I = Abbr.
75 #U1 #U2 * -U1 -U2
76 [ #J #a #I #V #T #H destruct
77 | #I1 #V1 #V2 #T1 #T2 #_ #_ #a #I #V #T #H destruct
78 | #b #V1 #V2 #W #T1 #T2 #_ #_ #a #I #V #T #H destruct
79 | #b #I1 #V1 #V2 #T1 #T #T2 #HV12 #HT1 #HT2 #a #I0 #V0 #T0 #H destruct /3 width=7/
80 | #b #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #a #I0 #V0 #T0 #H destruct
81 | #V #T1 #T #T2 #HT1 #HT2 #a #I0 #V0 #T0 #H destruct /3 width=3/
82 | #V #T1 #T2 #_ #a #I0 #V0 #T0 #H destruct
83 ]
84 qed.
85
86 lemma tpr_inv_bind1: ∀V1,T1,U2,a,I. ⓑ{a,I} V1. T1 ➡ U2 →
87                      (∃∃V2,T,T2. V1 ➡ V2 & T1 ➡ T &
88                                  ⋆.  ⓑ{I} V2 ⊢ T ▶ [0, 1] T2 &
89                                  U2 = ⓑ{a,I} V2. T2
90                      ) ∨
91                      ∃∃T. T1 ➡ T & ⇧[0,1] U2 ≡ T & a = true & I = Abbr.
92 /2 width=3/ qed-.
93
94 (* Basic_1: was pr0_gen_abbr *)
95 lemma tpr_inv_abbr1: ∀a,V1,T1,U2. ⓓ{a}V1. T1 ➡ U2 →
96                      (∃∃V2,T,T2. V1 ➡ V2 & T1 ➡ T &
97                                  ⋆.  ⓓV2 ⊢ T ▶ [0, 1] T2 &
98                                  U2 = ⓓ{a}V2. T2
99                       ) ∨
100                       ∃∃T. T1 ➡ T & ⇧[0, 1] U2 ≡ T & a = true.
101 #a #V1 #T1 #U2 #H
102 elim (tpr_inv_bind1 … H) -H * /3 width=7/
103 qed-.
104
105 fact tpr_inv_flat1_aux: ∀U1,U2. U1 ➡ U2 → ∀I,V1,U0. U1 = ⓕ{I} V1. U0 →
106                         ∨∨ ∃∃V2,T2.              V1 ➡ V2 & U0 ➡ T2 &
107                                                  U2 = ⓕ{I} V2. T2
108                          | ∃∃a,V2,W,T1,T2.       V1 ➡ V2 & T1 ➡ T2 &
109                                                  U0 = ⓛ{a}W. T1 &
110                                                  U2 = ⓓ{a}V2. T2 & I = Appl
111                          | ∃∃a,V2,V,W1,W2,T1,T2. V1 ➡ V2 & W1 ➡ W2 & T1 ➡ T2 &
112                                                  ⇧[0,1] V2 ≡ V &
113                                                  U0 = ⓓ{a}W1. T1 &
114                                                  U2 = ⓓ{a}W2. ⓐV. T2 &
115                                                  I = Appl
116                          |                       (U0 ➡ U2 ∧ I = Cast).
117 #U1 #U2 * -U1 -U2
118 [ #I #J #V #T #H destruct
119 | #I #V1 #V2 #T1 #T2 #HV12 #HT12 #J #V #T #H destruct /3 width=5/
120 | #a #V1 #V2 #W #T1 #T2 #HV12 #HT12 #J #V #T #H destruct /3 width=9/
121 | #a #I #V1 #V2 #T1 #T #T2 #_ #_ #_ #J #V0 #T0 #H destruct
122 | #a #V #V1 #V2 #W1 #W2 #T1 #T2 #HV12 #HV2 #HW12 #HT12 #J #V0 #T0 #H destruct /3 width=13/
123 | #V #T1 #T #T2 #_ #_ #J #V0 #T0 #H destruct
124 | #V #T1 #T2 #HT12 #J #V0 #T0 #H destruct /3 width=1/
125 ]
126 qed.
127
128 lemma tpr_inv_flat1: ∀V1,U0,U2,I. ⓕ{I} V1. U0 ➡ U2 →
129                      ∨∨ ∃∃V2,T2.              V1 ➡ V2 & U0 ➡ T2 &
130                                               U2 = ⓕ{I} V2. T2
131                       | ∃∃a,V2,W,T1,T2.       V1 ➡ V2 & T1 ➡ T2 &
132                                               U0 = ⓛ{a}W. T1 &
133                                               U2 = ⓓ{a}V2. T2 & I = Appl
134                       | ∃∃a,V2,V,W1,W2,T1,T2. V1 ➡ V2 & W1 ➡ W2 & T1 ➡ T2 &
135                                               ⇧[0,1] V2 ≡ V &
136                                               U0 = ⓓ{a}W1. T1 &
137                                               U2 = ⓓ{a}W2. ⓐV. T2 &
138                                               I = Appl
139                       |                       (U0 ➡ U2 ∧ I = Cast).
140 /2 width=3/ qed-.
141
142 (* Basic_1: was pr0_gen_appl *)
143 lemma tpr_inv_appl1: ∀V1,U0,U2. ⓐV1. U0 ➡ U2 →
144                      ∨∨ ∃∃V2,T2.              V1 ➡ V2 & U0 ➡ T2 &
145                                               U2 = ⓐV2. T2
146                       | ∃∃a,V2,W,T1,T2.       V1 ➡ V2 & T1 ➡ T2 &
147                                               U0 = ⓛ{a}W. T1 &
148                                               U2 = ⓓ{a}V2. T2
149                       | ∃∃a,V2,V,W1,W2,T1,T2. V1 ➡ V2 & W1 ➡ W2 & T1 ➡ T2 &
150                                               ⇧[0,1] V2 ≡ V &
151                                               U0 = ⓓ{a}W1. T1 &
152                                               U2 = ⓓ{a}W2. ⓐV. T2.
153 #V1 #U0 #U2 #H
154 elim (tpr_inv_flat1 … H) -H *
155 /3 width=5/ /3 width=9/ /3 width=13/
156 #_ #H destruct
157 qed-.
158
159 (* Note: the main property of simple terms *)
160 lemma tpr_inv_appl1_simple: ∀V1,T1,U. ⓐV1. T1 ➡ U → 𝐒⦃T1⦄ →
161                             ∃∃V2,T2. V1 ➡ V2 & T1 ➡ T2 &
162                                      U = ⓐV2. T2.
163 #V1 #T1 #U #H #HT1
164 elim (tpr_inv_appl1 … H) -H *
165 [ /2 width=5/
166 | #a #V2 #W #W1 #W2 #_ #_ #H #_ destruct
167   elim (simple_inv_bind … HT1)
168 | #a #V2 #V #W1 #W2 #U1 #U2 #_ #_ #_ #_ #H #_ destruct
169   elim (simple_inv_bind … HT1)
170 ]
171 qed-.
172
173 (* Basic_1: was: pr0_gen_cast *)
174 lemma tpr_inv_cast1: ∀V1,T1,U2. ⓝV1. T1 ➡ U2 →
175                        (∃∃V2,T2. V1 ➡ V2 & T1 ➡ T2 & U2 = ⓝV2. T2)
176                      ∨ T1 ➡ U2.
177 #V1 #T1 #U2 #H
178 elim (tpr_inv_flat1 … H) -H * /3 width=5/ #a #V2 #W #W1 #W2
179 [ #_ #_ #_ #_ #H destruct
180 | #T2 #U1 #_ #_ #_ #_ #_ #_ #H destruct
181 ]
182 qed-.
183
184 fact tpr_inv_lref2_aux: ∀T1,T2. T1 ➡ T2 → ∀i. T2 = #i →
185                         ∨∨        T1 = #i
186                          | ∃∃V,T. T ➡ #(i+1) & T1 = +ⓓV. T
187                          | ∃∃V,T. T ➡ #i & T1 = ⓝV. T.
188 #T1 #T2 * -T1 -T2
189 [ #I #i #H destruct /2 width=1/
190 | #I #V1 #V2 #T1 #T2 #_ #_ #i #H destruct
191 | #a #V1 #V2 #W #T1 #T2 #_ #_ #i #H destruct
192 | #a #I #V1 #V2 #T1 #T #T2 #_ #_ #_ #i #H destruct
193 | #a #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #i #H destruct
194 | #V #T1 #T #T2 #HT1 #HT2 #i #H destruct
195   lapply (lift_inv_lref1_ge … HT2 ?) -HT2 // #H destruct /3 width=4/
196 | #V #T1 #T2 #HT12 #i #H destruct /3 width=4/
197 ]
198 qed.
199
200 lemma tpr_inv_lref2: ∀T1,i. T1 ➡ #i →
201                      ∨∨        T1 = #i
202                       | ∃∃V,T. T ➡ #(i+1) & T1 = +ⓓV. T
203                       | ∃∃V,T. T ➡ #i & T1 = ⓝV. T.
204 /2 width=3/ qed-.
205
206 (* Basic forward lemmas *****************************************************)
207
208 lemma tpr_fwd_bind1_minus: ∀I,V1,T1,T. -ⓑ{I}V1.T1 ➡ T → ∀b.
209                            ∃∃V2,T2. ⓑ{b,I}V1.T1 ➡ ⓑ{b,I}V2.T2 &
210                                     T = -ⓑ{I}V2.T2.
211 #I #V1 #T1 #T #H #b elim (tpr_inv_bind1 … H) -H *
212 [ #V2 #T0 #T2 #HV12 #HT10 #HT02 #H destruct /3 width=4/
213 | #T2 #_ #_ #H destruct
214 ]
215 qed-.
216
217 lemma tpr_fwd_shift1: ∀L1,T1,T. L1 @@ T1 ➡ T →
218                       ∃∃L2,T2. |L1| = |L2| & T = L2 @@ T2.
219 #L1 @(lenv_ind_dx … L1) -L1 normalize
220 [ #T1 #T #HT1
221   @(ex2_2_intro … (⋆)) // (**) (* explicit constructor *)
222 | #I #L1 #V1 #IH #T1 #X
223   >shift_append_assoc normalize #H
224   elim (tpr_inv_bind1 … H) -H *
225   [ #V0 #T0 #X0 #_ #HT10 #H0 #H destruct
226     elim (IH … HT10) -IH -T1 #L #T #HL1 #H destruct
227     elim (tps_fwd_shift1 … H0) -T #L2 #T2 #HL2 #H destruct
228     >append_length >HL1 >HL2 -L1 -L
229     @(ex2_2_intro … (⋆.ⓑ{I}V0@@L2) T2) [ >append_length ] // /2 width=3/ (**) (* explicit constructor *)
230   | #T #_ #_ #H destruct
231   ]
232 ]
233 qed-.
234
235 (* Basic_1: removed theorems 3:
236             pr0_subst0_back pr0_subst0_fwd pr0_subst0
237 *)
238 (* Basic_1: removed local theorems: 1: pr0_delta_tau *)