]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambda_delta/Basic_2/reducibility/tpr.ma
4769a39dc72efe7274326bb9c68dfc5b4fdceccd
[helm.git] / matita / matita / contribs / lambda_delta / 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/grammar/term_simple.ma".
16 include "Basic_2/substitution/tps.ma".
17
18 (* CONTEXT-FREE PARALLEL REDUCTION ON TERMS *********************************)
19
20 (* Basic_1: includes: pr0_delta1 *)
21 inductive tpr: relation term ≝
22 | tpr_atom : ∀I. tpr (𝕒{I}) (𝕒{I})
23 | tpr_flat : ∀I,V1,V2,T1,T2. tpr V1 V2 → tpr T1 T2 →
24              tpr (𝕗{I} V1. T1) (𝕗{I} V2. T2)
25 | tpr_beta : ∀V1,V2,W,T1,T2.
26              tpr V1 V2 → tpr T1 T2 →
27              tpr (𝕔{Appl} V1. 𝕔{Abst} W. T1) (𝕔{Abbr} V2. T2)
28 | tpr_delta: ∀I,V1,V2,T1,T2,T.
29              tpr V1 V2 → tpr T1 T2 → ⋆.  𝕓{I} V2 ⊢ T2 [0, 1] ≫ T →
30              tpr (𝕓{I} V1. T1) (𝕓{I} V2. T)
31 | tpr_theta: ∀V,V1,V2,W1,W2,T1,T2.
32              tpr V1 V2 → ⇑[0,1] V2 ≡ V → tpr W1 W2 → tpr T1 T2 →
33              tpr (𝕔{Appl} V1. 𝕔{Abbr} W1. T1) (𝕔{Abbr} W2. 𝕔{Appl} V. T2)
34 | tpr_zeta : ∀V,T,T1,T2. ⇑[0,1] T1 ≡ T → tpr T1 T2 →
35              tpr (𝕔{Abbr} V. T) T2
36 | tpr_tau  : ∀V,T1,T2. tpr T1 T2 → tpr (𝕔{Cast} V. T1) T2
37 .
38
39 interpretation
40    "context-free parallel reduction (term)"
41    'PRed T1 T2 = (tpr T1 T2).
42
43 (* Basic properties *********************************************************)
44
45 lemma tpr_bind: ∀I,V1,V2,T1,T2. V1 ⇒ V2 → T1 ⇒ T2 →
46                             𝕓{I} V1. T1 ⇒  𝕓{I} V2. T2.
47 /2 width=3/ qed.
48
49 (* Basic_1: was by definition: pr0_refl *)
50 lemma tpr_refl: ∀T. T ⇒ T.
51 #T elim T -T //
52 #I elim I -I /2 width=1/
53 qed.
54
55 (* Basic inversion lemmas ***************************************************)
56
57 fact tpr_inv_atom1_aux: ∀U1,U2. U1 ⇒ U2 → ∀I. U1 = 𝕒{I} → U2 = 𝕒{I}.
58 #U1 #U2 * -U1 -U2
59 [ //
60 | #I #V1 #V2 #T1 #T2 #_ #_ #k #H destruct
61 | #V1 #V2 #W #T1 #T2 #_ #_ #k #H destruct
62 | #I #V1 #V2 #T1 #T2 #T #_ #_ #_ #k #H destruct
63 | #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #k #H destruct
64 | #V #T #T1 #T2 #_ #_ #k #H destruct
65 | #V #T1 #T2 #_ #k #H destruct
66 ]
67 qed.
68
69 (* Basic_1: was: pr0_gen_sort pr0_gen_lref *)
70 lemma tpr_inv_atom1: ∀I,U2. 𝕒{I} ⇒ U2 → U2 = 𝕒{I}.
71 /2 width=3/ qed-.
72
73 fact tpr_inv_bind1_aux: ∀U1,U2. U1 ⇒ U2 → ∀I,V1,T1. U1 = 𝕓{I} V1. T1 →
74                         (∃∃V2,T2,T. V1 ⇒ V2 & T1 ⇒ T2 &
75                                     ⋆.  𝕓{I} V2 ⊢ T2 [0, 1] ≫ T &
76                                     U2 = 𝕓{I} V2. T
77                         ) ∨
78                         ∃∃T. ⇑[0,1] T ≡ T1 & T ⇒ U2 & I = Abbr.
79 #U1 #U2 * -U1 -U2
80 [ #J #I #V #T #H destruct
81 | #I1 #V1 #V2 #T1 #T2 #_ #_ #I #V #T #H destruct
82 | #V1 #V2 #W #T1 #T2 #_ #_ #I #V #T #H destruct
83 | #I1 #V1 #V2 #T1 #T2 #T #HV12 #HT12 #HT2 #I0 #V0 #T0 #H destruct /3 width=7/
84 | #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #I0 #V0 #T0 #H destruct
85 | #V #T #T1 #T2 #HT1 #HT12 #I0 #V0 #T0 #H destruct /3 width=3/
86 | #V #T1 #T2 #_ #I0 #V0 #T0 #H destruct
87 ]
88 qed.
89
90 lemma tpr_inv_bind1: ∀V1,T1,U2,I. 𝕓{I} V1. T1 ⇒ U2 →
91                      (∃∃V2,T2,T. V1 ⇒ V2 & T1 ⇒ T2 &
92                                  ⋆.  𝕓{I} V2 ⊢ T2 [0, 1] ≫ T &
93                                  U2 = 𝕓{I} V2. T
94                      ) ∨
95                      ∃∃T. ⇑[0,1] T ≡ T1 & T ⇒ U2 & I = Abbr.
96 /2 width=3/ qed-.
97
98 (* Basic_1: was pr0_gen_abbr *)
99 lemma tpr_inv_abbr1: ∀V1,T1,U2. 𝕓{Abbr} V1. T1 ⇒ U2 →
100                      (∃∃V2,T2,T. V1 ⇒ V2 & T1 ⇒ T2 &
101                                  ⋆.  𝕓{Abbr} V2 ⊢ T2 [0, 1] ≫ T &
102                                  U2 = 𝕓{Abbr} V2. T
103                       ) ∨
104                       ∃∃T. ⇑[0,1] T ≡ T1 & T ⇒ U2.
105 #V1 #T1 #U2 #H
106 elim (tpr_inv_bind1 … H) -H * /3 width=7/
107 qed-.
108
109 fact tpr_inv_flat1_aux: ∀U1,U2. U1 ⇒ U2 → ∀I,V1,U0. U1 = 𝕗{I} V1. U0 →
110                         ∨∨ ∃∃V2,T2.            V1 ⇒ V2 & U0 ⇒ T2 &
111                                                U2 = 𝕗{I} V2. T2
112                          | ∃∃V2,W,T1,T2.       V1 ⇒ V2 & T1 ⇒ T2 &
113                                                U0 = 𝕔{Abst} W. T1 &
114                                                U2 = 𝕔{Abbr} V2. T2 & I = Appl
115                          | ∃∃V2,V,W1,W2,T1,T2. V1 ⇒ V2 & W1 ⇒ W2 & T1 ⇒ T2 &
116                                                ⇑[0,1] V2 ≡ V &
117                                                U0 = 𝕔{Abbr} W1. T1 &
118                                                U2 = 𝕔{Abbr} W2. 𝕔{Appl} V. T2 &
119                                                I = Appl
120                          |                     (U0 ⇒ U2 ∧ I = Cast).
121 #U1 #U2 * -U1 -U2
122 [ #I #J #V #T #H destruct
123 | #I #V1 #V2 #T1 #T2 #HV12 #HT12 #J #V #T #H destruct /3 width=5/
124 | #V1 #V2 #W #T1 #T2 #HV12 #HT12 #J #V #T #H destruct /3 width=8/
125 | #I #V1 #V2 #T1 #T2 #T #_ #_ #_ #J #V0 #T0 #H destruct
126 | #V #V1 #V2 #W1 #W2 #T1 #T2 #HV12 #HV2 #HW12 #HT12 #J #V0 #T0 #H destruct /3 width=12/
127 | #V #T #T1 #T2 #_ #_ #J #V0 #T0 #H destruct
128 | #V #T1 #T2 #HT12 #J #V0 #T0 #H destruct /3 width=1/
129 ]
130 qed.
131
132 lemma tpr_inv_flat1: ∀V1,U0,U2,I. 𝕗{I} V1. U0 ⇒ U2 →
133                      ∨∨ ∃∃V2,T2.            V1 ⇒ V2 & U0 ⇒ T2 &
134                                             U2 = 𝕗{I} V2. T2
135                       | ∃∃V2,W,T1,T2.       V1 ⇒ V2 & T1 ⇒ T2 &
136                                             U0 = 𝕔{Abst} W. T1 &
137                                             U2 = 𝕔{Abbr} V2. T2 & I = Appl
138                       | ∃∃V2,V,W1,W2,T1,T2. V1 ⇒ V2 & W1 ⇒ W2 & T1 ⇒ T2 &
139                                             ⇑[0,1] V2 ≡ V &
140                                             U0 = 𝕔{Abbr} W1. T1 &
141                                             U2 = 𝕔{Abbr} W2. 𝕔{Appl} V. T2 &
142                                             I = Appl
143                       |                     (U0 ⇒ U2 ∧ I = Cast).
144 /2 width=3/ qed-.
145
146 (* Basic_1: was pr0_gen_appl *)
147 lemma tpr_inv_appl1: ∀V1,U0,U2. 𝕔{Appl} V1. U0 ⇒ U2 →
148                      ∨∨ ∃∃V2,T2.            V1 ⇒ V2 & U0 ⇒ T2 &
149                                             U2 = 𝕔{Appl} V2. T2
150                       | ∃∃V2,W,T1,T2.       V1 ⇒ V2 & T1 ⇒ T2 &
151                                             U0 = 𝕔{Abst} W. T1 &
152                                             U2 = 𝕔{Abbr} V2. T2
153                       | ∃∃V2,V,W1,W2,T1,T2. V1 ⇒ V2 & W1 ⇒ W2 & T1 ⇒ T2 &
154                                             ⇑[0,1] V2 ≡ V &
155                                             U0 = 𝕔{Abbr} W1. T1 &
156                                             U2 = 𝕔{Abbr} W2. 𝕔{Appl} V. T2.
157 #V1 #U0 #U2 #H
158 elim (tpr_inv_flat1 … H) -H * /3 width=12/ #_ #H destruct
159 qed-.
160
161 (* Note: the main property of simple terms *)
162 lemma tpr_inv_appl1_simple: ∀V1,T1,U. 𝕔{Appl} V1. T1 ⇒ U → 𝕊[T1] →
163                             ∃∃V2,T2. V1 ⇒ V2 & T1 ⇒ T2 &
164                                      U = 𝕔{Appl} V2. T2.
165 #V1 #T1 #U #H #HT1
166 elim (tpr_inv_appl1 … H) -H *
167 [ /2 width=5/
168 | #V2 #W #W1 #W2 #_ #_ #H #_ destruct
169   elim (simple_inv_bind … HT1)
170 | #V2 #V #W1 #W2 #U1 #U2 #_ #_ #_ #_ #H #_ destruct
171   elim (simple_inv_bind … HT1)
172 ]
173 qed-.
174
175 (* Basic_1: was: pr0_gen_cast *)
176 lemma tpr_inv_cast1: ∀V1,T1,U2. 𝕔{Cast} V1. T1 ⇒ U2 →
177                        (∃∃V2,T2. V1 ⇒ V2 & T1 ⇒ T2 & U2 = 𝕔{Cast} V2. T2)
178                      ∨ T1 ⇒ U2.
179 #V1 #T1 #U2 #H
180 elim (tpr_inv_flat1 … H) -H * /3 width=5/
181 [ #V2 #W #W1 #W2 #_ #_ #_ #_ #H destruct
182 | #V2 #W #W1 #W2 #T2 #U1 #_ #_ #_ #_ #_ #_ #H destruct
183 ]
184 qed-.
185
186 fact tpr_inv_lref2_aux: ∀T1,T2. T1 ⇒ T2 → ∀i. T2 = #i →
187                         ∨∨           T1 = #i
188                          | ∃∃V,T,T0. ⇑[O,1] T0 ≡ T & T0 ⇒ #i &
189                                      T1 = 𝕔{Abbr} V. T
190                          | ∃∃V,T.    T ⇒ #i & T1 = 𝕔{Cast} V. T.
191 #T1 #T2 * -T1 -T2
192 [ #I #i #H destruct /2 width=1/
193 | #I #V1 #V2 #T1 #T2 #_ #_ #i #H destruct
194 | #V1 #V2 #W #T1 #T2 #_ #_ #i #H destruct
195 | #I #V1 #V2 #T1 #T2 #T #_ #_ #_ #i #H destruct
196 | #V #V1 #V2 #W1 #W2 #T1 #T2 #_ #_ #_ #_ #i #H destruct
197 | #V #T #T1 #T2 #HT1 #HT12 #i #H destruct /3 width=6/
198 | #V #T1 #T2 #HT12 #i #H destruct /3 width=4/
199 ]
200 qed.
201
202 lemma tpr_inv_lref2: ∀T1,i. T1 ⇒ #i →
203                      ∨∨           T1 = #i
204                       | ∃∃V,T,T0. ⇑[O,1] T0 ≡ T & T0 ⇒ #i &
205                                   T1 = 𝕔{Abbr} V. T
206                       | ∃∃V,T.    T ⇒ #i & T1 = 𝕔{Cast} V. T.
207 /2 width=3/ qed-.
208
209 (* Basic_1: removed theorems 3:
210             pr0_subst0_back pr0_subst0_fwd pr0_subst0
211    Basic_1: removed local theorems: 1: pr0_delta_tau
212 *)