]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/lib/lambda-delta/substitution/tps_tps.ma
confluence of parallel substitution (tps) started ...
[helm.git] / matita / matita / lib / lambda-delta / substitution / tps_tps.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/tps_split.ma".
13
14 lemma arith_i2: ∀a,c1,c2. c1 + c2 ≤ a → c1 + c2 + (a - c1 - c2) = a.
15 /2/ qed.
16
17 (* PARTIAL SUBSTITUTION ON TERMS ********************************************)
18
19 (* Main properties **********************************************************)
20 (*
21 theorem tps_trans: ∀L,T1,T,d,e. L ⊢ T1 [d, e] ≫ T → ∀T2. L ⊢ T [d, e] ≫ T2 →
22                    L ⊢ T1 [d, e] ≫ T2.
23 #L #T1 #T #d #e #H elim H -L T1 T d e
24 [ //
25 | //
26 | #L #K #V #V1 #V2 #i #d #e #Hdi #Hide #HLK #_ #HV12 #IHV12 #T2 #HVT2
27   lapply (drop_fwd_drop2 … HLK) #H
28   elim (tps_inv_lift1_up … HVT2 … H … HV12 ? ? ?) -HVT2 H HV12 // normalize [2: /2/ ] #V #HV1 #HVT2
29   @tps_subst [4,5,6,8: // |1,2,3: skip | /2/ ]
30 | #L #I #V1 #V2 #T1 #T2 #d #e #_ #_ #IHV12 #IHT12 #X #HX
31   elim (tps_inv_bind1 … HX) -HX #V #T #HV2 #HT2 #HX destruct -X;
32   @tps_bind /2/ @IHT12 @(tps_leq_repl … HT2) /2/
33 | #L #I #V1 #V2 #T1 #T2 #d #e #_ #_ #IHV12 #IHT12 #X #HX
34   elim (tps_inv_flat1 … HX) -HX #V #T #HV2 #HT2 #HX destruct -X /3/
35 ]
36 qed.
37 *)
38
39 axiom tps_conf_subst_subst_lt: ∀L,K1,V1,W1,T1,i1,d,e,T2,K2,V2,W2,i2.
40    ↓[O, i1] L ≡ K1. 𝕓{Abbr} V1 → ↓[O, i2] L≡ K2. 𝕓{Abbr} V2 →
41    K1 ⊢ V1 [O, d + e - i1 - 1] ≫ W1 → K2 ⊢ V2 [O, d + e - i2 - 1] ≫ W2 →
42    ↑[O, i1 + 1] W1 ≡ T1 → ↑[O, i2 + 1] W2 ≡ T2 → 
43    d ≤ i1 → i1 < d + e → d ≤ i2 → i2 < d + e → i1 < i2 →
44    ∃∃T. L ⊢ T1 [d, e] ≫ T & L ⊢ T2 [d, e] ≫ T.  
45 (*
46 #L #K1 #V1 #W1 #T1 #i1 #d #e #T2 #K2 #V2 #W2 #i2
47 #HLK1 #HLK2 #HVW1 #HVW2 #HWT1 #HWT2 #Hdi1 #Hi1de #Hdi2 #Hi2de #Hi12
48 *)
49
50 theorem tps_conf: ∀L,T0,T1,d,e. L ⊢ T0 [d, e] ≫ T1 → ∀T2. L ⊢ T0 [d, e] ≫ T2 →
51                   ∃∃T. L ⊢ T1 [d, e] ≫ T & L ⊢ T2 [d, e] ≫ T.
52 #L #T0 #T1 #d #e #H elim H -H L T0 T1 d e
53 [ /2/
54 | /2/
55 | #L #K1 #V1 #W1 #T1 #i1 #d #e #Hdi1 #Hi1de #HLK1 #HVW1 #HWT1 #IHVW1 #T2 #H
56   elim (tps_inv_lref1 … H) -H
57   [ -IHVW1 #HX destruct -T2
58     @ex2_1_intro [2: // | skip ] /2 width=6/ (**) (* /3 width=9/ is slow *)
59   | * #K2 #V2 #W2 #i2 #Hdi2 #Hi2de #HLK2 #HVW2 #HWT2
60     elim (lt_or_eq_or_gt i1 i2) #Hi12
61     [ @tps_conf_subst_subst_lt /width=19/
62     | -HVW1; destruct -i2;
63       lapply (transitive_le ? ? (i1 + 1) Hdi2 ?) -Hdi2 // #Hdi2
64       lapply (drop_mono … HLK1 … HLK2) -HLK1 Hdi1 Hi1de #H destruct -V1 K1;
65       elim (IHVW1 … HVW2) -IHVW1 HVW2 #W #HW1 #HW2
66       lapply (drop_fwd_drop2 … HLK2) -HLK2 #HLK2
67       elim (lift_total W 0 (i1 + 1)) #T #HWT
68       lapply (tps_lift_ge … HW1 … HLK2 HWT1 HWT ?) -HW1 HWT1 //
69       lapply (tps_lift_ge … HW2 … HLK2 HWT2 HWT ?) -HW2 HWT2 HLK2 HWT // normalize #HT2 #HT1
70       lapply (tps_weak … HT1 d e ? ?) -HT1 [ >arith_i2 // | // ]
71       lapply (tps_weak … HT2 d e ? ?) -HT2 [ >arith_i2 // | // ]
72       /2/
73     | @ex2_1_comm @tps_conf_subst_subst_lt /width=19/
74     ]
75   ]
76 | #L #I #V0 #V1 #T0 #T1 #d #e #_ #_ #IHV01 #IHT01 #X #HX
77   elim (tps_inv_bind1 … HX) -HX #V2 #T2 #HV02 #HT02 #HX destruct -X; 
78   elim (IHV01 … HV02) -IHV01 HV02 #V #HV1 #HV2
79   elim (IHT01 … HT02) -IHT01 HT02 #T #HT1 #HT2 
80   @ex2_1_intro
81   [2: @tps_bind [4: @(tps_leq_repl … HT1) /2/ |2: skip ]
82   |1: skip
83   |3: @tps_bind [2: @(tps_leq_repl … HT2) /2/ ]
84   ] // (**) (* /5/ is too slow *)
85 | #L #I #V0 #V1 #T0 #T1 #d #e #_ #_ #IHV01 #IHT01 #X #HX
86   elim (tps_inv_flat1 … HX) -HX #V2 #T2 #HV02 #HT02 #HX destruct -X; 
87   elim (IHV01 … HV02) -IHV01 HV02;
88   elim (IHT01 … HT02) -IHT01 HT02 /3 width=5/
89 ]
90 qed.
91
92 (*
93       Theorem subst0_subst0: (t1,t2,u2:?; j:?) (subst0 j u2 t1 t2) ->
94                              (u1,u:?; i:?) (subst0 i u u1 u2) ->
95                              (EX t | (subst0 j u1 t1 t) & (subst0 (S (plus i j)) u t t2)).
96
97       Theorem subst0_subst0_back: (t1,t2,u2:?; j:?) (subst0 j u2 t1 t2) ->
98                                   (u1,u:?; i:?) (subst0 i u u2 u1) ->
99                                   (EX t | (subst0 j u1 t1 t) & (subst0 (S (plus i j)) u t2 t)).
100
101 *)