]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambda-delta/Basic-2/substitution/tps_tps.ma
a969da023b5017619e839c5a6d6e7724dc7b691d
[helm.git] / matita / matita / contribs / lambda-delta / Basic-2 / substitution / tps_tps.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
17 (* PARALLEL SUBSTITUTION ON TERMS *******************************************)
18
19 (* Main properties **********************************************************)
20
21 (* Basic-1: was: subst1_confluence_eq *)
22 theorem tps_conf_eq: ∀L,T0,T1,d1,e1. L ⊢ T0 [d1, e1] ≫ T1 →
23                      ∀T2,d2,e2. L ⊢ T0 [d2, e2] ≫ T2 →
24                      ∃∃T. L ⊢ T1 [d2, e2] ≫ T & L ⊢ T2 [d1, e1] ≫ T.
25 #L #T0 #T1 #d1 #e1 #H elim H -H L T0 T1 d1 e1
26 [ /2/
27 | #L #K1 #V1 #T1 #i0 #d1 #e1 #Hd1 #Hde1 #HLK1 #HVT1 #T2 #d2 #e2 #H
28   elim (tps_inv_lref1 … H) -H
29   [ #HX destruct -T2 /4/
30   | -Hd1 Hde1 * #K2 #V2 #_ #_ #HLK2 #HVT2
31     lapply (drop_mono … HLK1 … HLK2) -HLK1 HLK2 #H destruct -V1 K1
32     >(lift_mono … HVT1 … HVT2) -HVT1 HVT2 /2/
33   ]
34 | #L #I #V0 #V1 #T0 #T1 #d1 #e1 #_ #_ #IHV01 #IHT01 #X #d2 #e2 #HX
35   elim (tps_inv_bind1 … HX) -HX #V2 #T2 #HV02 #HT02 #HX destruct -X;
36   elim (IHV01 … HV02) -IHV01 HV02 #V #HV1 #HV2
37   elim (IHT01 … HT02) -IHT01 HT02 #T #HT1 #HT2
38   lapply (tps_leq_repl … HT1 (L. 𝕓{I} V1) ?) -HT1 /2/
39   lapply (tps_leq_repl … HT2 (L. 𝕓{I} V2) ?) -HT2 /3 width=5/
40 | #L #I #V0 #V1 #T0 #T1 #d1 #e1 #_ #_ #IHV01 #IHT01 #X #d2 #e2 #HX
41   elim (tps_inv_flat1 … HX) -HX #V2 #T2 #HV02 #HT02 #HX destruct -X;
42   elim (IHV01 … HV02) -IHV01 HV02;
43   elim (IHT01 … HT02) -IHT01 HT02 /3 width=5/
44 ]
45 qed.
46
47 (* Basic-1: was: subst1_confluence_neq *)
48 theorem tps_conf_neq: ∀L1,T0,T1,d1,e1. L1 ⊢ T0 [d1, e1] ≫ T1 →
49                       ∀L2,T2,d2,e2. L2 ⊢ T0 [d2, e2] ≫ T2 →
50                       (d1 + e1 ≤ d2 ∨ d2 + e2 ≤ d1) →
51                       ∃∃T. L2 ⊢ T1 [d2, e2] ≫ T & L1 ⊢ T2 [d1, e1] ≫ T.
52 #L1 #T0 #T1 #d1 #e1 #H elim H -H L1 T0 T1 d1 e1
53 [ /2/
54 | #L1 #K1 #V1 #T1 #i0 #d1 #e1 #Hd1 #Hde1 #HLK1 #HVT1 #L2 #T2 #d2 #e2 #H1 #H2 
55   elim (tps_inv_lref1 … H1) -H1
56   [ #H destruct -T2 /4/
57   | -HLK1 HVT1 * #K2 #V2 #Hd2 #Hde2 #_ #_ elim H2 -H2 #Hded
58     [ -Hd1 Hde2;
59       lapply (transitive_le … Hded Hd2) -Hded Hd2 #H
60       lapply (lt_to_le_to_lt … Hde1 H) -Hde1 H #H
61       elim (lt_refl_false … H)
62     | -Hd2 Hde1;
63       lapply (transitive_le … Hded Hd1) -Hded Hd1 #H
64       lapply (lt_to_le_to_lt … Hde2 H) -Hde2 H #H
65       elim (lt_refl_false … H)
66     ]
67   ]
68 | #L1 #I #V0 #V1 #T0 #T1 #d1 #e1 #_ #_ #IHV01 #IHT01 #L2 #X #d2 #e2 #HX #H
69   elim (tps_inv_bind1 … HX) -HX #V2 #T2 #HV02 #HT02 #HX destruct -X;
70   elim (IHV01 … HV02 H) -IHV01 HV02 #V #HV1 #HV2
71   elim (IHT01 … HT02 ?) -IHT01 HT02
72   [ -H #T #HT1 #HT2
73     lapply (tps_leq_repl … HT1 (L2. 𝕓{I} V1) ?) -HT1 /2/
74     lapply (tps_leq_repl … HT2 (L1. 𝕓{I} V2) ?) -HT2 /3 width=5/
75   | -HV1 HV2 >plus_plus_comm_23 >plus_plus_comm_23 in ⊢ (? ? %) elim H -H #H
76     [ @or_introl | @or_intror ] /2 by monotonic_le_plus_l/ (**) (* /3/ is too slow *)
77   ]
78 | #L1 #I #V0 #V1 #T0 #T1 #d1 #e1 #_ #_ #IHV01 #IHT01 #L2 #X #d2 #e2 #HX #H
79   elim (tps_inv_flat1 … HX) -HX #V2 #T2 #HV02 #HT02 #HX destruct -X;
80   elim (IHV01 … HV02 H) -IHV01 HV02;
81   elim (IHT01 … HT02 H) -IHT01 HT02 H /3 width=5/
82 ]
83 qed.
84
85 theorem tps_trans_down: ∀L,T1,T0,d1,e1. L ⊢ T1 [d1, e1] ≫ T0 →
86                         ∀T2,d2,e2. L ⊢ T0 [d2, e2] ≫ T2 → d2 + e2 ≤ d1 →
87                         ∃∃T. L ⊢ T1 [d2, e2] ≫ T & L ⊢ T [d1, e1] ≫ T2.
88 #L #T1 #T0 #d1 #e1 #H elim H -L T1 T0 d1 e1
89 [ /2/
90 | #L #K #V #W #i1 #d1 #e1 #Hdi1 #Hide1 #HLK #HVW #T2 #d2 #e2 #HWT2 #Hde2d1
91   lapply (transitive_le … Hde2d1 Hdi1) -Hde2d1 #Hde2i1
92   lapply (tps_weak … HWT2 0 (i1 + 1) ? ?) -HWT2; normalize /2/ -Hde2i1 #HWT2
93   <(tps_inv_lift1_eq … HWT2 … HVW) -HWT2 /4/
94 | #L #I #V1 #V0 #T1 #T0 #d1 #e1 #_ #_ #IHV10 #IHT10 #X #d2 #e2 #HX #de2d1
95   elim (tps_inv_bind1 … HX) -HX #V2 #T2 #HV02 #HT02 #HX destruct -X;
96   lapply (tps_leq_repl … HT02 (L. 𝕓{I} V1) ?) -HT02 /2/ #HT02
97   elim (IHV10 … HV02 ?) -IHV10 HV02 // #V
98   elim (IHT10 … HT02 ?) -IHT10 HT02 [2: /2/ ] #T #HT1 #HT2
99   lapply (tps_leq_repl … HT2 (L. 𝕓{I} V) ?) -HT2 /3 width=6/
100 | #L #I #V1 #V0 #T1 #T0 #d1 #e1 #_ #_ #IHV10 #IHT10 #X #d2 #e2 #HX #de2d1
101   elim (tps_inv_flat1 … HX) -HX #V2 #T2 #HV02 #HT02 #HX destruct -X;
102   elim (IHV10 … HV02 ?) -IHV10 HV02 //
103   elim (IHT10 … HT02 ?) -IHT10 HT02 // /3 width=6/
104 ]
105 qed.
106 (*
107       Theorem subst0_subst0: (t1,t2,u2:?; j:?) (subst0 j u2 t1 t2) ->
108                              (u1,u:?; i:?) (subst0 i u u1 u2) ->
109                              (EX t | (subst0 j u1 t1 t) & (subst0 (S (plus i j)) u t t2)).
110
111       Theorem subst0_subst0_back: (t1,t2,u2:?; j:?) (subst0 j u2 t1 t2) ->
112                                   (u1,u:?; i:?) (subst0 i u u2 u1) ->
113                                   (EX t | (subst0 j u1 t1 t) & (subst0 (S (plus i j)) u t2 t)).
114
115 *)