]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/relocation/lexs.ma
more on lfpx_frees.ma ...
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / relocation / lexs.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 "ground_2/relocation/rtmap_sle.ma".
16 include "basic_2/notation/relations/relationstar_5.ma".
17 include "basic_2/grammar/lenv.ma".
18
19 (* GENERIC ENTRYWISE EXTENSION OF CONTEXT-SENSITIVE REALTIONS FOR TERMS *****)
20
21 (* Basic_2A1: includes: lpx_sn_atom lpx_sn_pair *)
22 inductive lexs (RN,RP:relation3 lenv term term): rtmap → relation lenv ≝
23 | lexs_atom: ∀f. lexs RN RP f (⋆) (⋆)
24 | lexs_next: ∀f,I,L1,L2,V1,V2.
25              lexs RN RP f L1 L2 → RN L1 V1 V2 →
26              lexs RN RP (⫯f) (L1.ⓑ{I}V1) (L2.ⓑ{I}V2)
27 | lexs_push: ∀f,I,L1,L2,V1,V2.
28              lexs RN RP f L1 L2 → RP L1 V1 V2 →
29              lexs RN RP (↑f) (L1.ⓑ{I}V1) (L2.ⓑ{I}V2)
30 .
31
32 interpretation "generic entrywise extension (local environment)"
33    'RelationStar RN RP f L1 L2 = (lexs RN RP f L1 L2).
34
35 definition R_pw_confluent2_lexs: relation3 lenv term term → relation3 lenv term term →
36                                  relation3 lenv term term → relation3 lenv term term →
37                                  relation3 lenv term term → relation3 lenv term term →
38                                  relation3 rtmap lenv term ≝
39                                  λR1,R2,RN1,RP1,RN2,RP2,f,L0,T0.
40                                  ∀T1. R1 L0 T0 T1 → ∀T2. R2 L0 T0 T2 →
41                                  ∀L1. L0 ⦻*[RN1, RP1, f] L1 → ∀L2. L0 ⦻*[RN2, RP2, f] L2 →
42                                  ∃∃T. R2 L1 T1 T & R1 L2 T2 T.
43
44 definition lexs_transitive: relation5 (relation3 lenv term term)
45                                       (relation3 lenv term term) … ≝
46                             λR1,R2,R3,RN,RP.
47                             ∀f,L1,T1,T. R1 L1 T1 T → ∀L2. L1 ⦻*[RN, RP, f] L2 →
48                             ∀T2. R2 L2 T T2 → R3 L1 T1 T2.
49
50 (* Basic inversion lemmas ***************************************************)
51
52 fact lexs_inv_atom1_aux: ∀RN,RP,f,X,Y. X ⦻*[RN, RP, f] Y → X = ⋆ → Y = ⋆.
53 #RN #RP #f #X #Y * -f -X -Y //
54 #f #I #L1 #L2 #V1 #V2 #_ #_ #H destruct
55 qed-.
56
57 (* Basic_2A1: includes lpx_sn_inv_atom1 *)
58 lemma lexs_inv_atom1: ∀RN,RP,f,Y. ⋆ ⦻*[RN, RP, f] Y → Y = ⋆.
59 /2 width=6 by lexs_inv_atom1_aux/ qed-.
60
61 fact lexs_inv_next1_aux: ∀RN,RP,f,X,Y. X ⦻*[RN, RP, f] Y → ∀g,J,K1,W1. X = K1.ⓑ{J}W1 → f = ⫯g →
62                          ∃∃K2,W2. K1 ⦻*[RN, RP, g] K2 & RN K1 W1 W2 & Y = K2.ⓑ{J}W2.
63 #RN #RP #f #X #Y * -f -X -Y
64 [ #f #g #J #K1 #W1 #H destruct
65 | #f #I #L1 #L2 #V1 #V2 #HL #HV #g #J #K1 #W1 #H1 #H2 <(injective_next … H2) -g destruct
66   /2 width=5 by ex3_2_intro/
67 | #f #I #L1 #L2 #V1 #V2 #_ #_ #g #J #K1 #W1 #_ #H elim (discr_push_next … H)
68 ]
69 qed-.
70
71 (* Basic_2A1: includes lpx_sn_inv_pair1 *)
72 lemma lexs_inv_next1: ∀RN,RP,g,J,K1,Y,W1. K1.ⓑ{J}W1 ⦻*[RN, RP, ⫯g] Y →
73                       ∃∃K2,W2. K1 ⦻*[RN, RP, g] K2 & RN K1 W1 W2 & Y = K2.ⓑ{J}W2.
74 /2 width=7 by lexs_inv_next1_aux/ qed-.
75
76
77 fact lexs_inv_push1_aux: ∀RN,RP,f,X,Y. X ⦻*[RN, RP, f] Y → ∀g,J,K1,W1. X = K1.ⓑ{J}W1 → f = ↑g →
78                          ∃∃K2,W2. K1 ⦻*[RN, RP, g] K2 & RP K1 W1 W2 & Y = K2.ⓑ{J}W2.
79 #RN #RP #f #X #Y * -f -X -Y
80 [ #f #g #J #K1 #W1 #H destruct
81 | #f #I #L1 #L2 #V1 #V2 #_ #_ #g #J #K1 #W1 #_ #H elim (discr_next_push … H)
82 | #f #I #L1 #L2 #V1 #V2 #HL #HV #g #J #K1 #W1 #H1 #H2 <(injective_push … H2) -g destruct
83   /2 width=5 by ex3_2_intro/
84 ]
85 qed-.
86
87 lemma lexs_inv_push1: ∀RN,RP,g,J,K1,Y,W1. K1.ⓑ{J}W1 ⦻*[RN, RP, ↑g] Y →
88                       ∃∃K2,W2. K1 ⦻*[RN, RP, g] K2 & RP K1 W1 W2 & Y = K2.ⓑ{J}W2.
89 /2 width=7 by lexs_inv_push1_aux/ qed-.
90
91 fact lexs_inv_atom2_aux: ∀RN,RP,f,X,Y. X ⦻*[RN, RP, f] Y → Y = ⋆ → X = ⋆.
92 #RN #RP #f #X #Y * -f -X -Y //
93 #f #I #L1 #L2 #V1 #V2 #_ #_ #H destruct
94 qed-.
95
96 (* Basic_2A1: includes lpx_sn_inv_atom2 *)
97 lemma lexs_inv_atom2: ∀RN,RP,f,X. X ⦻*[RN, RP, f] ⋆ → X = ⋆.
98 /2 width=6 by lexs_inv_atom2_aux/ qed-.
99
100 fact lexs_inv_next2_aux: ∀RN,RP,f,X,Y. X ⦻*[RN, RP, f] Y → ∀g,J,K2,W2. Y = K2.ⓑ{J}W2 → f = ⫯g →
101                          ∃∃K1,W1. K1 ⦻*[RN, RP, g] K2 & RN K1 W1 W2 & X = K1.ⓑ{J}W1.
102 #RN #RP #f #X #Y * -f -X -Y
103 [ #f #g #J #K2 #W2 #H destruct
104 | #f #I #L1 #L2 #V1 #V2 #HL #HV #g #J #K2 #W2 #H1 #H2 <(injective_next … H2) -g destruct
105   /2 width=5 by ex3_2_intro/
106 | #f #I #L1 #L2 #V1 #V2 #_ #_ #g #J #K2 #W2 #_ #H elim (discr_push_next … H)
107 ]
108 qed-.
109
110 (* Basic_2A1: includes lpx_sn_inv_pair2 *)
111 lemma lexs_inv_next2: ∀RN,RP,g,J,X,K2,W2. X ⦻*[RN, RP, ⫯g] K2.ⓑ{J}W2 →
112                       ∃∃K1,W1. K1 ⦻*[RN, RP, g] K2 & RN K1 W1 W2 & X = K1.ⓑ{J}W1.
113 /2 width=7 by lexs_inv_next2_aux/ qed-.
114
115 fact lexs_inv_push2_aux: ∀RN,RP,f,X,Y. X ⦻*[RN, RP, f] Y → ∀g,J,K2,W2. Y = K2.ⓑ{J}W2 → f = ↑g →
116                          ∃∃K1,W1. K1 ⦻*[RN, RP, g] K2 & RP K1 W1 W2 & X = K1.ⓑ{J}W1.
117 #RN #RP #f #X #Y * -f -X -Y
118 [ #f #J #K2 #W2 #g #H destruct
119 | #f #I #L1 #L2 #V1 #V2 #_ #_ #g #J #K2 #W2 #_ #H elim (discr_next_push … H)
120 | #f #I #L1 #L2 #V1 #V2 #HL #HV #g #J #K2 #W2 #H1 #H2 <(injective_push … H2) -g destruct
121   /2 width=5 by ex3_2_intro/
122 ]
123 qed-.
124
125 lemma lexs_inv_push2: ∀RN,RP,g,J,X,K2,W2. X ⦻*[RN, RP, ↑g] K2.ⓑ{J}W2 →
126                       ∃∃K1,W1. K1 ⦻*[RN, RP, g] K2 & RP K1 W1 W2 & X = K1.ⓑ{J}W1.
127 /2 width=7 by lexs_inv_push2_aux/ qed-.
128
129 (* Basic_2A1: includes lpx_sn_inv_pair *)
130 lemma lexs_inv_next: ∀RN,RP,f,I1,I2,L1,L2,V1,V2.
131                      L1.ⓑ{I1}V1 ⦻*[RN, RP, ⫯f] (L2.ⓑ{I2}V2) →
132                      ∧∧ L1 ⦻*[RN, RP, f] L2 & RN L1 V1 V2 & I1 = I2.
133 #RN #RP #f #I1 #I2 #L1 #L2 #V1 #V2 #H elim (lexs_inv_next1 … H) -H
134 #L0 #V0 #HL10 #HV10 #H destruct /2 width=1 by and3_intro/
135 qed-.
136
137 lemma lexs_inv_push: ∀RN,RP,f,I1,I2,L1,L2,V1,V2.
138                      L1.ⓑ{I1}V1 ⦻*[RN, RP, ↑f] (L2.ⓑ{I2}V2) →
139                      ∧∧ L1 ⦻*[RN, RP, f] L2 & RP L1 V1 V2 & I1 = I2.
140 #RN #RP #f #I1 #I2 #L1 #L2 #V1 #V2 #H elim (lexs_inv_push1 … H) -H
141 #L0 #V0 #HL10 #HV10 #H destruct /2 width=1 by and3_intro/
142 qed-.
143
144 lemma lexs_inv_tl: ∀RN,RP,f,I,L1,L2,V1,V2. L1 ⦻*[RN, RP, ⫱f] L2 →
145                    RN L1 V1 V2 → RP L1 V1 V2 → 
146                    L1.ⓑ{I}V1 ⦻*[RN, RP, f] L2.ⓑ{I}V2.
147 #RN #RP #f #I #L2 #L2 #V1 #V2 elim (pn_split f) *
148 /2 width=1 by lexs_next, lexs_push/
149 qed-.
150
151 (* Basic forward lemmas *****************************************************)
152
153 lemma lexs_fwd_pair: ∀RN,RP,f,I1,I2,L1,L2,V1,V2. 
154                      L1.ⓑ{I1}V1 ⦻*[RN, RP, f] L2.ⓑ{I2}V2 →
155                      L1 ⦻*[RN, RP, ⫱f] L2 ∧ I1 = I2.
156 #RN #RP #f #I1 #I2 #L2 #L2 #V1 #V2 #Hf
157 elim (pn_split f) * #g #H destruct
158 [ elim (lexs_inv_push … Hf) | elim (lexs_inv_next … Hf) ] -Hf
159 /2 width=1 by conj/
160 qed-.
161
162 (* Basic properties *********************************************************)
163
164 lemma lexs_eq_repl_back: ∀RN,RP,L1,L2. eq_repl_back … (λf. L1 ⦻*[RN, RP, f] L2).
165 #RN #RP #L1 #L2 #f1 #H elim H -f1 -L1 -L2 //
166 #f1 #I #L1 #L2 #V1 #v2 #_ #HV #IH #f2 #H
167 [ elim (eq_inv_nx … H) -H /3 width=3 by lexs_next/
168 | elim (eq_inv_px … H) -H /3 width=3 by lexs_push/
169 ]
170 qed-.
171
172 lemma lexs_eq_repl_fwd: ∀RN,RP,L1,L2. eq_repl_fwd … (λf. L1 ⦻*[RN, RP, f] L2).
173 #RN #RP #L1 #L2 @eq_repl_sym /2 width=3 by lexs_eq_repl_back/ (**) (* full auto fails *)
174 qed-.
175
176 (* Note: fexs_sym and fexs_trans hold, but lexs_sym and lexs_trans do not  *)
177 (* Basic_2A1: includes: lpx_sn_refl *)
178 lemma lexs_refl: ∀RN,RP,f.
179                  (∀L. reflexive … (RN L)) →
180                  (∀L. reflexive … (RP L)) →
181                  reflexive … (lexs RN RP f).
182 #RN #RP #f #HRN #HRP #L generalize in match f; -f elim L -L //
183 #L #I #V #IH * * /2 width=1 by lexs_next, lexs_push/
184 qed.
185
186 lemma lexs_pair_repl: ∀RN,RP,f,I,L1,L2,V1,V2.
187                       L1.ⓑ{I}V1 ⦻*[RN, RP, f] L2.ⓑ{I}V2 →
188                       ∀W1,W2. RN L1 W1 W2 → RP L1 W1 W2 →
189                       L1.ⓑ{I}W1 ⦻*[RN, RP, f] L2.ⓑ{I}W2.
190 #RN #RP #f #I #L1 #L2 #V1 #V2 #HL12 #W1 #W2 #HN #HP
191 elim (lexs_fwd_pair … HL12) -HL12 /2 width=1 by lexs_inv_tl/
192 qed-.
193
194 lemma lexs_co: ∀RN1,RP1,RN2,RP2.
195                (∀L1,T1,T2. RN1 L1 T1 T2 → RN2 L1 T1 T2) →
196                (∀L1,T1,T2. RP1 L1 T1 T2 → RP2 L1 T1 T2) →
197                ∀f,L1,L2. L1 ⦻*[RN1, RP1, f] L2 → L1 ⦻*[RN2, RP2, f] L2.
198 #RN1 #RP1 #RN2 #RP2 #HRN #HRP #f #L1 #L2 #H elim H -f -L1 -L2
199 /3 width=1 by lexs_atom, lexs_next, lexs_push/
200 qed-.
201
202 lemma sle_lexs_trans: ∀RN,RP. (∀L,T1,T2. RN L T1 T2 → RP L T1 T2) →
203                       ∀f2,L1,L2. L1 ⦻*[RN, RP, f2] L2 →
204                       ∀f1. f1 ⊆ f2 → L1 ⦻*[RN, RP, f1] L2.
205 #RN #RP #HR #f2 #L1 #L2 #H elim H -f2 -L1 -L2 //
206 #f2 #I #L1 #L2 #V1 #V2 #_ #HV12 #IH
207 [ * * [2: #n1 ] ] #f1 #H
208 [ /4 width=5 by lexs_next, sle_inv_nn/
209 | /4 width=5 by lexs_push, sle_inv_pn/
210 | elim (sle_inv_xp … H) -H [2,3: // ]
211   #g1 #H #H1 destruct /3 width=5 by lexs_push/
212 ]
213 qed-.
214
215 lemma sle_lexs_conf: ∀RN,RP. (∀L,T1,T2. RP L T1 T2 → RN L T1 T2) →
216                      ∀f1,L1,L2. L1 ⦻*[RN, RP, f1] L2 →
217                      ∀f2. f1 ⊆ f2 → L1 ⦻*[RN, RP, f2] L2.
218 #RN #RP #HR #f1 #L1 #L2 #H elim H -f1 -L1 -L2 //
219 #f1 #I #L1 #L2 #V1 #V2 #_ #HV12 #IH
220 [2: * * [2: #n2 ] ] #f2 #H
221 [ /4 width=5 by lexs_next, sle_inv_pn/
222 | /4 width=5 by lexs_push, sle_inv_pp/
223 | elim (sle_inv_nx … H) -H [2,3: // ]
224   #g2 #H #H2 destruct /3 width=5 by lexs_next/
225 ]
226 qed-.