]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2A/etc/llpx_sn/llpx_sn_tc.etc
milestone update in ground_2 and basic_2A
[helm.git] / matita / matita / contribs / lambdadelta / basic_2A / etc / llpx_sn / llpx_sn_tc.etc
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/relocation/ldrop_leq.ma".
16 include "basic_2/relocation/llpx_sn.ma".
17
18 (* LAZY SN POINTWISE EXTENSION OF A CONTEXT-SENSITIVE REALTION FOR TERMS ****)
19
20 definition TC_llpx_sn_confluent1: relation (relation3 lenv term term) ≝ λS,R.
21                                   ∀Ls,T1,T2. S Ls T1 T2 →
22                                   ∀Ld. TC … (llpx_sn R 0 T1) Ls Ld → TC … (llpx_sn R 0 T2) Ls Ld.
23
24 lemma TC_llpx_sn_s_confluent: ∀S,R. (llpx_sn_confluent1 S R) → TC_llpx_sn_confluent1 S R.
25 #S #R #HSR #Ls #T1 #T2 #HT12 #Ld #H
26 generalize in match HT12; -HT12
27 @(TC_ind_dx … Ls H) -Ls
28 [ /3 width=3 by inj/
29 | #Ls #L #HLs #_ #IHLd #HT12
30   @(TC_strap … L) /2 width=3 by/ @IHLd -IHLd
31
32 lemma TC_llpx_sn_lref_refl: ∀R. (∀L.reflexive … (R L)) →
33                             ∀I,L1,K1,K2,V,d,i. d ≤ yinj i → ⇩[i] L1 ≡ K1.ⓑ{I}V →
34                             TC lenv (llpx_sn R 0 V) K1 K2 →
35                             ∀L2. ⇩[i] L2 ≡ K2.ⓑ{I}V → TC … (llpx_sn R d (#i)) L1 L2.
36 #R #HR #I #L1 #K1 #K2 #V #d #i #Hdi #HLK1 #H @(TC_star_ind … K2 H) -K2
37 [ /2 width=1 by llpx_sn_refl/
38 | /4 width=9 by llpx_sn_refl, llpx_sn_lref, inj/
39 | #K #K2 #_ #HV #IHK1 #L2 #HLK2 lapply (ldrop_fwd_length … HLK2)
40   #H elim (ldrop_O1_ex (K.ⓑ{I}V) i L2) [2: normalize in H ⊢ %; >(llpx_sn_fwd_length … HV) ]
41   /4 width=11 by llpx_sn_lref, step/
42 ]
43 qed-.
44
45 lemma TC_llpx_sn_lref: ∀R. (∀L.reflexive … (R L)) → (llpx_sn_confluent1 R R) →
46                        ∀I,K1,V1,V2,d,i. d ≤ yinj i → LTC … R K1 V1 V2 →
47                        ∀K2. TC lenv (llpx_sn R 0 V1) K1 K2 → ∀L1. ⇩[i] L1 ≡ K1.ⓑ{I}V1 →
48                        ∀L2. ⇩[i] L2 ≡ K2.ⓑ{I}V2 → TC … (llpx_sn R d (#i)) L1 L2.
49 #R #H1R #H2R #I #K1 #V1 #V2 #d #i #Hdi #H @(TC_star_ind_dx … V1 H) -V1
50 [ /2 width=1 by llpx_sn_refl/
51 | /2 width=7 by TC_llpx_sn_lref_refl/
52 | #V1 #V #HV1 #_ #IHV2 #K2 #HK12 #L1 #HLK1 #L2 #HLK2
53   lapply (ldrop_fwd_length … HLK1)
54   #H elim (ldrop_O1_ex (K1.ⓑ{I}V) i L1) [2: normalize in H ⊢ %; // ] -H
55   #L #_ #HLK @(TC_strap … L)
56   [ @(llpx_sn_lref … HLK1 … HLK) /2 width=1 by llpx_sn_refl/
57   | @(IHV2 … HLK … HLK2)
58     -HLK1 -HLK2 -HLK -IHV2 -Hdi @(TC_llpx_sn_s_confluent R R … HK12) //
59   ]
60 ]
61
62
63 lemma llpx_sn_LTC_TC_llpx_sn: ∀R. (∀L. reflexive … (R L)) →
64                               ∀L1,L2,T,d. llpx_sn (LTC … R) d T L1 L2 →
65                               TC … (llpx_sn R d T) L1 L2.
66 #R #HR #L1 #L2 #T #d #H elim H -L1 -L2
67 /3 width=3 by llpx_sn_gref, llpx_sn_free, llpx_sn_skip, llpx_sn_sort, inj/
68 [ #I #L1 #L2 #K1 #K2 #V1 #V2 #d #i #Hdi #HLK1 #HLK2 #_ #HV12 #IHV1   
69
70 (* Properties on transitive_closure *****************************************)
71
72 lemma TC_lpx_sn_pair: ∀R. (∀L. reflexive … (R L)) →
73                       ∀I,L1,L2. TC … (lpx_sn R) L1 L2 →
74                       ∀V1,V2. LTC … R L1 V1 V2 →
75                       TC … (lpx_sn R) (L1. ⓑ{I} V1) (L2. ⓑ{I} V2).
76 #R #HR #I #L1 #L2 #HL12 #V1 #V2 #H @(TC_star_ind_dx … V1 H) -V1 //
77 [ /2 width=1 by TC_lpx_sn_pair_refl/
78 | /4 width=3 by TC_strap, lpx_sn_pair, lpx_sn_refl/
79 ]
80 qed-.
81
82 lemma lpx_sn_LTC_TC_lpx_sn: ∀R. (∀L. reflexive … (R L)) →
83                             ∀L1,L2. lpx_sn (LTC … R) L1 L2 →
84                             TC … (lpx_sn R) L1 L2.
85 #R #HR #L1 #L2 #H elim H -L1 -L2
86 /2 width=1 by TC_lpx_sn_pair, lpx_sn_atom, inj/
87 qed-.
88
89 (* Inversion lemmas on transitive closure ***********************************)
90
91 lemma TC_lpx_sn_inv_atom2: ∀R,L1. TC … (lpx_sn R) L1 (⋆) → L1 = ⋆.
92 #R #L1 #H @(TC_ind_dx … L1 H) -L1
93 [ /2 width=2 by lpx_sn_inv_atom2/
94 | #L1 #L #HL1 #_ #IHL2 destruct /2 width=2 by lpx_sn_inv_atom2/
95 ]
96 qed-.
97
98 lemma TC_lpx_sn_inv_pair2: ∀R. s_rs_trans … R (lpx_sn R) →
99                            ∀I,L1,K2,V2. TC  … (lpx_sn R) L1 (K2.ⓑ{I}V2) →
100                            ∃∃K1,V1. TC … (lpx_sn R) K1 K2 & LTC … R K1 V1 V2 & L1 = K1. ⓑ{I} V1.
101 #R #HR #I #L1 #K2 #V2 #H @(TC_ind_dx … L1 H) -L1
102 [ #L1 #H elim (lpx_sn_inv_pair2 … H) -H /3 width=5 by inj, ex3_2_intro/
103 | #L1 #L #HL1 #_ * #K #V #HK2 #HV2 #H destruct
104   elim (lpx_sn_inv_pair2 … HL1) -HL1 #K1 #V1 #HK1 #HV1 #H destruct
105   lapply (HR … HV2 … HK1) -HR -HV2 /3 width=5 by TC_strap, ex3_2_intro/
106 ]
107 qed-.
108
109 lemma TC_lpx_sn_ind: ∀R. s_rs_trans … R (lpx_sn R) →
110                      ∀S:relation lenv.
111                      S (⋆) (⋆) → (
112                         ∀I,K1,K2,V1,V2.
113                         TC … (lpx_sn R) K1 K2 → LTC … R K1 V1 V2 →
114                         S K1 K2 → S (K1.ⓑ{I}V1) (K2.ⓑ{I}V2)
115                      ) →
116                      ∀L2,L1. TC … (lpx_sn R) L1 L2 → S L1 L2.
117 #R #HR #S #IH1 #IH2 #L2 elim L2 -L2
118 [ #X #H >(TC_lpx_sn_inv_atom2 … H) -X //
119 | #L2 #I #V2 #IHL2 #X #H
120   elim (TC_lpx_sn_inv_pair2 … H) // -H -HR
121   #L1 #V1 #HL12 #HV12 #H destruct /3 width=1 by/
122 ]
123 qed-.
124
125 lemma TC_lpx_sn_inv_atom1: ∀R,L2. TC … (lpx_sn R) (⋆) L2 → L2 = ⋆.
126 #R #L2 #H elim H -L2
127 [ /2 width=2 by lpx_sn_inv_atom1/
128 | #L #L2 #_ #HL2 #IHL1 destruct /2 width=2 by lpx_sn_inv_atom1/
129 ]
130 qed-.
131
132 fact TC_lpx_sn_inv_pair1_aux: ∀R. s_rs_trans … R (lpx_sn R) →
133                               ∀L1,L2. TC … (lpx_sn R) L1 L2 →
134                               ∀I,K1,V1. L1 = K1.ⓑ{I}V1 →
135                               ∃∃K2,V2. TC … (lpx_sn R) K1 K2 & LTC … R K1 V1 V2 & L2 = K2. ⓑ{I} V2.
136 #R #HR #L1 #L2 #H @(TC_lpx_sn_ind … H) // -HR -L1 -L2
137 [ #J #K #W #H destruct
138 | #I #L1 #L2 #V1 #V2 #HL12 #HV12 #_ #J #K #W #H destruct /2 width=5 by ex3_2_intro/
139 ]
140 qed-.
141
142 lemma TC_lpx_sn_inv_pair1: ∀R. s_rs_trans … R (lpx_sn R) →
143                            ∀I,K1,L2,V1. TC … (lpx_sn R) (K1.ⓑ{I}V1) L2 →
144                            ∃∃K2,V2. TC … (lpx_sn R) K1 K2 & LTC … R K1 V1 V2 & L2 = K2. ⓑ{I} V2.
145 /2 width=3 by TC_lpx_sn_inv_pair1_aux/ qed-.
146
147 lemma TC_lpx_sn_inv_lpx_sn_LTC: ∀R. s_rs_trans … R (lpx_sn R) →
148                                 ∀L1,L2. TC … (lpx_sn R) L1 L2 →
149                                 lpx_sn (LTC … R) L1 L2.
150 /3 width=4 by TC_lpx_sn_ind, lpx_sn_pair/ qed-.
151
152 (* Forward lemmas on transitive closure *************************************)
153
154 lemma TC_lpx_sn_fwd_length: ∀R,L1,L2. TC … (lpx_sn R) L1 L2 → |L1| = |L2|.
155 #R #L1 #L2 #H elim H -L2
156 [ #L2 #HL12 >(lpx_sn_fwd_length … HL12) -HL12 //
157 | #L #L2 #_ #HL2 #IHL1
158   >IHL1 -L1 >(lpx_sn_fwd_length … HL2) -HL2 //
159 ]
160 qed-.