]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/relocation/lexs.ma
- ext2_tc added
[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/syntax/lenv.ma".
18
19 (* GENERIC ENTRYWISE EXTENSION OF CONTEXT-SENSITIVE REALTIONS FOR TERMS *****)
20
21 inductive lexs (RN,RP:relation3 lenv bind bind): rtmap → relation lenv ≝
22 | lexs_atom: ∀f. lexs RN RP f (⋆) (⋆)
23 | lexs_next: ∀f,I1,I2,L1,L2.
24              lexs RN RP f L1 L2 → RN L1 I1 I2 →
25              lexs RN RP (⫯f) (L1.ⓘ{I1}) (L2.ⓘ{I2})
26 | lexs_push: ∀f,I1,I2,L1,L2.
27              lexs RN RP f L1 L2 → RP L1 I1 I2 →
28              lexs RN RP (↑f) (L1.ⓘ{I1}) (L2.ⓘ{I2})
29 .
30
31 interpretation "generic entrywise extension (local environment)"
32    'RelationStar RN RP f L1 L2 = (lexs RN RP f L1 L2).
33
34 definition R_pw_confluent2_lexs: relation3 lenv bind bind → relation3 lenv bind bind →
35                                  relation3 lenv bind bind → relation3 lenv bind bind →
36                                  relation3 lenv bind bind → relation3 lenv bind bind →
37                                  relation3 rtmap lenv bind ≝
38                                  λR1,R2,RN1,RP1,RN2,RP2,f,L0,T0.
39                                  ∀T1. R1 L0 T0 T1 → ∀T2. R2 L0 T0 T2 →
40                                  ∀L1. L0 ⪤*[RN1, RP1, f] L1 → ∀L2. L0 ⪤*[RN2, RP2, f] L2 →
41                                  ∃∃T. R2 L1 T1 T & R1 L2 T2 T.
42
43 definition lexs_transitive: relation5 (relation3 lenv bind bind)
44                                       (relation3 lenv bind bind) … ≝
45                             λR1,R2,R3,RN,RP.
46                             ∀f,L1,T1,T. R1 L1 T1 T → ∀L2. L1 ⪤*[RN, RP, f] L2 →
47                             ∀T2. R2 L2 T T2 → R3 L1 T1 T2.
48
49 (* Basic inversion lemmas ***************************************************)
50
51 fact lexs_inv_atom1_aux: ∀RN,RP,f,X,Y. X ⪤*[RN, RP, f] Y → X = ⋆ → Y = ⋆.
52 #RN #RP #f #X #Y * -f -X -Y //
53 #f #I1 #I2 #L1 #L2 #_ #_ #H destruct
54 qed-.
55
56 (* Basic_2A1: includes lpx_sn_inv_atom1 *)
57 lemma lexs_inv_atom1: ∀RN,RP,f,Y. ⋆ ⪤*[RN, RP, f] Y → Y = ⋆.
58 /2 width=6 by lexs_inv_atom1_aux/ qed-.
59
60 fact lexs_inv_next1_aux: ∀RN,RP,f,X,Y. X ⪤*[RN, RP, f] Y → ∀g,J1,K1. X = K1.ⓘ{J1} → f = ⫯g →
61                          ∃∃J2,K2. K1 ⪤*[RN, RP, g] K2 & RN K1 J1 J2 & Y = K2.ⓘ{J2}.
62 #RN #RP #f #X #Y * -f -X -Y
63 [ #f #g #J1 #K1 #H destruct
64 | #f #I1 #I2 #L1 #L2 #HL #HI #g #J1 #K1 #H1 #H2 <(injective_next … H2) -g destruct
65   /2 width=5 by ex3_2_intro/
66 | #f #I1 #I2 #L1 #L2 #_ #_ #g #J1 #K1 #_ #H elim (discr_push_next … H)
67 ]
68 qed-.
69
70 (* Basic_2A1: includes lpx_sn_inv_pair1 *)
71 lemma lexs_inv_next1: ∀RN,RP,g,J1,K1,Y. K1.ⓘ{J1} ⪤*[RN, RP, ⫯g] Y →
72                       ∃∃J2,K2. K1 ⪤*[RN, RP, g] K2 & RN K1 J1 J2 & Y = K2.ⓘ{J2}.
73 /2 width=7 by lexs_inv_next1_aux/ qed-.
74
75 fact lexs_inv_push1_aux: ∀RN,RP,f,X,Y. X ⪤*[RN, RP, f] Y → ∀g,J1,K1. X = K1.ⓘ{J1} → f = ↑g →
76                          ∃∃J2,K2. K1 ⪤*[RN, RP, g] K2 & RP K1 J1 J2 & Y = K2.ⓘ{J2}.
77 #RN #RP #f #X #Y * -f -X -Y
78 [ #f #g #J1 #K1 #H destruct
79 | #f #I1 #I2 #L1 #L2 #_ #_ #g #J1 #K1 #_ #H elim (discr_next_push … H)
80 | #f #I1 #I2 #L1 #L2 #HL #HI #g #J1 #K1 #H1 #H2 <(injective_push … H2) -g destruct
81   /2 width=5 by ex3_2_intro/
82 ]
83 qed-.
84
85 lemma lexs_inv_push1: ∀RN,RP,g,J1,K1,Y. K1.ⓘ{J1} ⪤*[RN, RP, ↑g] Y →
86                       ∃∃J2,K2. K1 ⪤*[RN, RP, g] K2 & RP K1 J1 J2 & Y = K2.ⓘ{J2}.
87 /2 width=7 by lexs_inv_push1_aux/ qed-.
88
89 fact lexs_inv_atom2_aux: ∀RN,RP,f,X,Y. X ⪤*[RN, RP, f] Y → Y = ⋆ → X = ⋆.
90 #RN #RP #f #X #Y * -f -X -Y //
91 #f #I1 #I2 #L1 #L2 #_ #_ #H destruct
92 qed-.
93
94 (* Basic_2A1: includes lpx_sn_inv_atom2 *)
95 lemma lexs_inv_atom2: ∀RN,RP,f,X. X ⪤*[RN, RP, f] ⋆ → X = ⋆.
96 /2 width=6 by lexs_inv_atom2_aux/ qed-.
97
98 fact lexs_inv_next2_aux: ∀RN,RP,f,X,Y. X ⪤*[RN, RP, f] Y → ∀g,J2,K2. Y = K2.ⓘ{J2} → f = ⫯g →
99                          ∃∃J1,K1. K1 ⪤*[RN, RP, g] K2 & RN K1 J1 J2 & X = K1.ⓘ{J1}.
100 #RN #RP #f #X #Y * -f -X -Y
101 [ #f #g #J2 #K2 #H destruct
102 | #f #I1 #I2 #L1 #L2 #HL #HI #g #J2 #K2 #H1 #H2 <(injective_next … H2) -g destruct
103   /2 width=5 by ex3_2_intro/
104 | #f #I1 #I2 #L1 #L2 #_ #_ #g #J2 #K2 #_ #H elim (discr_push_next … H)
105 ]
106 qed-.
107
108 (* Basic_2A1: includes lpx_sn_inv_pair2 *)
109 lemma lexs_inv_next2: ∀RN,RP,g,J2,X,K2. X ⪤*[RN, RP, ⫯g] K2.ⓘ{J2} →
110                       ∃∃J1,K1. K1 ⪤*[RN, RP, g] K2 & RN K1 J1 J2 & X = K1.ⓘ{J1}.
111 /2 width=7 by lexs_inv_next2_aux/ qed-.
112
113 fact lexs_inv_push2_aux: ∀RN,RP,f,X,Y. X ⪤*[RN, RP, f] Y → ∀g,J2,K2. Y = K2.ⓘ{J2} → f = ↑g →
114                          ∃∃J1,K1. K1 ⪤*[RN, RP, g] K2 & RP K1 J1 J2 & X = K1.ⓘ{J1}.
115 #RN #RP #f #X #Y * -f -X -Y
116 [ #f #J2 #K2 #g #H destruct
117 | #f #I1 #I2 #L1 #L2 #_ #_ #g #J2 #K2 #_ #H elim (discr_next_push … H)
118 | #f #I1 #I2 #L1 #L2 #HL #HI #g #J2 #K2 #H1 #H2 <(injective_push … H2) -g destruct
119   /2 width=5 by ex3_2_intro/
120 ]
121 qed-.
122
123 lemma lexs_inv_push2: ∀RN,RP,g,J2,X,K2. X ⪤*[RN, RP, ↑g] K2.ⓘ{J2} →
124                       ∃∃J1,K1. K1 ⪤*[RN, RP, g] K2 & RP K1 J1 J2 & X = K1.ⓘ{J1}.
125 /2 width=7 by lexs_inv_push2_aux/ qed-.
126
127 (* Basic_2A1: includes lpx_sn_inv_pair *)
128 lemma lexs_inv_next: ∀RN,RP,f,I1,I2,L1,L2.
129                      L1.ⓘ{I1} ⪤*[RN, RP, ⫯f] L2.ⓘ{I2} →
130                      L1 ⪤*[RN, RP, f] L2 ∧ RN L1 I1 I2.
131 #RN #RP #f #I1 #I2 #L1 #L2 #H elim (lexs_inv_next1 … H) -H
132 #I0 #L0 #HL10 #HI10 #H destruct /2 width=1 by conj/
133 qed-.
134
135 lemma lexs_inv_push: ∀RN,RP,f,I1,I2,L1,L2.
136                      L1.ⓘ{I1} ⪤*[RN, RP, ↑f] L2.ⓘ{I2} →
137                      L1 ⪤*[RN, RP, f] L2 ∧ RP L1 I1 I2.
138 #RN #RP #f #I1 #I2 #L1 #L2 #H elim (lexs_inv_push1 … H) -H
139 #I0 #L0 #HL10 #HI10 #H destruct /2 width=1 by conj/
140 qed-.
141
142 lemma lexs_inv_tl: ∀RN,RP,f,I1,I2,L1,L2. L1 ⪤*[RN, RP, ⫱f] L2 →
143                    RN L1 I1 I2 → RP L1 I1 I2 → 
144                    L1.ⓘ{I1} ⪤*[RN, RP, f] L2.ⓘ{I2}.
145 #RN #RP #f #I1 #I2 #L2 #L2 elim (pn_split f) *
146 /2 width=1 by lexs_next, lexs_push/
147 qed-.
148
149 (* Basic forward lemmas *****************************************************)
150
151 lemma lexs_fwd_bind: ∀RN,RP,f,I1,I2,L1,L2. 
152                      L1.ⓘ{I1} ⪤*[RN, RP, f] L2.ⓘ{I2} →
153                      L1 ⪤*[RN, RP, ⫱f] L2.
154 #RN #RP #f #I1 #I2 #L1 #L2 #Hf
155 elim (pn_split f) * #g #H destruct
156 [ elim (lexs_inv_push … Hf) | elim (lexs_inv_next … Hf) ] -Hf //
157 qed-.
158
159 (* Basic properties *********************************************************)
160
161 lemma lexs_eq_repl_back: ∀RN,RP,L1,L2. eq_repl_back … (λf. L1 ⪤*[RN, RP, f] L2).
162 #RN #RP #L1 #L2 #f1 #H elim H -f1 -L1 -L2 //
163 #f1 #I1 #I2 #L1 #L2 #_ #HI #IH #f2 #H
164 [ elim (eq_inv_nx … H) -H /3 width=3 by lexs_next/
165 | elim (eq_inv_px … H) -H /3 width=3 by lexs_push/
166 ]
167 qed-.
168
169 lemma lexs_eq_repl_fwd: ∀RN,RP,L1,L2. eq_repl_fwd … (λf. L1 ⪤*[RN, RP, f] L2).
170 #RN #RP #L1 #L2 @eq_repl_sym /2 width=3 by lexs_eq_repl_back/ (**) (* full auto fails *)
171 qed-.
172
173 (* Basic_2A1: uses: lpx_sn_refl *)
174 lemma lexs_refl: ∀RN,RP.
175                  (∀L. reflexive … (RN L)) →
176                  (∀L. reflexive … (RP L)) →
177                  ∀f.reflexive … (lexs RN RP f).
178 #RN #RP #HRN #HRP #f #L generalize in match f; -f elim L -L //
179 #L #I #IH #f elim (pn_split f) *
180 #g #H destruct /2 width=1 by lexs_next, lexs_push/
181 qed.
182
183 lemma lexs_sym: ∀RN,RP.
184                 (∀L1,L2,I1,I2. RN L1 I1 I2 → RN L2 I2 I1) →
185                 (∀L1,L2,I1,I2. RP L1 I1 I2 → RP L2 I2 I1) →
186                 ∀f. symmetric … (lexs RN RP f).
187 #RN #RP #HRN #HRP #f #L1 #L2 #H elim H -L1 -L2 -f
188 /3 width=2 by lexs_next, lexs_push/
189 qed-.
190
191 lemma lexs_pair_repl: ∀RN,RP,f,I1,I2,L1,L2.
192                       L1.ⓘ{I1} ⪤*[RN, RP, f] L2.ⓘ{I2} →
193                       ∀J1,J2. RN L1 J1 J2 → RP L1 J1 J2 →
194                       L1.ⓘ{J1} ⪤*[RN, RP, f] L2.ⓘ{J2}.
195 /3 width=3 by lexs_inv_tl, lexs_fwd_bind/ qed-.
196
197 lemma lexs_co: ∀RN1,RP1,RN2,RP2.
198                (∀L1,I1,I2. RN1 L1 I1 I2 → RN2 L1 I1 I2) →
199                (∀L1,I1,I2. RP1 L1 I1 I2 → RP2 L1 I1 I2) →
200                ∀f,L1,L2. L1 ⪤*[RN1, RP1, f] L2 → L1 ⪤*[RN2, RP2, f] L2.
201 #RN1 #RP1 #RN2 #RP2 #HRN #HRP #f #L1 #L2 #H elim H -f -L1 -L2
202 /3 width=1 by lexs_atom, lexs_next, lexs_push/
203 qed-.
204
205 lemma lexs_co_isid: ∀RN1,RP1,RN2,RP2.
206                     (∀L1,I1,I2. RP1 L1 I1 I2 → RP2 L1 I1 I2) →
207                     ∀f,L1,L2. L1 ⪤*[RN1, RP1, f] L2 → 𝐈⦃f⦄ →
208                     L1 ⪤*[RN2, RP2, f] L2.
209 #RN1 #RP1 #RN2 #RP2 #HR #f #L1 #L2 #H elim H -f -L1 -L2 //
210 #f #I1 #I2 #K1 #K2 #_ #HI12 #IH #H
211 [ elim (isid_inv_next … H) -H //
212 | /4 width=3 by lexs_push, isid_inv_push/
213 ]
214 qed-.
215
216 lemma sle_lexs_trans: ∀RN,RP. (∀L,I1,I2. RN L I1 I2 → RP L I1 I2) →
217                       ∀f2,L1,L2. L1 ⪤*[RN, RP, f2] L2 →
218                       ∀f1. f1 ⊆ f2 → L1 ⪤*[RN, RP, f1] L2.
219 #RN #RP #HR #f2 #L1 #L2 #H elim H -f2 -L1 -L2 //
220 #f2 #I1 #I2 #L1 #L2 #_ #HI12 #IH #f1 #H12
221 [ elim (pn_split f1) * ]
222 [ /4 width=5 by lexs_push, sle_inv_pn/
223 | /4 width=5 by lexs_next, sle_inv_nn/
224 | elim (sle_inv_xp … H12) -H12 [2,3: // ]
225   #g1 #H #H1 destruct /3 width=5 by lexs_push/
226 ]
227 qed-.
228
229 lemma sle_lexs_conf: ∀RN,RP. (∀L,I1,I2. RP L I1 I2 → RN L I1 I2) →
230                      ∀f1,L1,L2. L1 ⪤*[RN, RP, f1] L2 →
231                      ∀f2. f1 ⊆ f2 → L1 ⪤*[RN, RP, f2] L2.
232 #RN #RP #HR #f1 #L1 #L2 #H elim H -f1 -L1 -L2 //
233 #f1 #I1 #I2 #L1 #L2 #_ #HI12 #IH #f2 #H12
234 [2: elim (pn_split f2) * ]
235 [ /4 width=5 by lexs_push, sle_inv_pp/
236 | /4 width=5 by lexs_next, sle_inv_pn/
237 | elim (sle_inv_nx … H12) -H12 [2,3: // ]
238   #g2 #H #H2 destruct /3 width=5 by lexs_next/
239 ]
240 qed-.
241
242 lemma lexs_sle_split: ∀R1,R2,RP. (∀L. reflexive … (R1 L)) → (∀L. reflexive … (R2 L)) →
243                       ∀f,L1,L2. L1 ⪤*[R1, RP, f] L2 → ∀g. f ⊆ g →
244                       ∃∃L. L1 ⪤*[R1, RP, g] L & L ⪤*[R2, cfull, f] L2.
245 #R1 #R2 #RP #HR1 #HR2 #f #L1 #L2 #H elim H -f -L1 -L2
246 [ /2 width=3 by lexs_atom, ex2_intro/ ]
247 #f #I1 #I2 #L1 #L2 #_ #HI12 #IH #y #H
248 [ elim (sle_inv_nx … H ??) -H [ |*: // ] #g #Hfg #H destruct
249   elim (IH … Hfg) -IH -Hfg /3 width=5 by lexs_next, ex2_intro/
250 | elim (sle_inv_px … H ??) -H [1,3: * |*: // ] #g #Hfg #H destruct
251   elim (IH … Hfg) -IH -Hfg /3 width=5 by lexs_next, lexs_push, ex2_intro/
252 ]
253 qed-.
254
255 lemma lexs_dec: ∀RN,RP.
256                 (∀L,I1,I2. Decidable (RN L I1 I2)) →
257                 (∀L,I1,I2. Decidable (RP L I1 I2)) →
258                 ∀L1,L2,f. Decidable (L1 ⪤*[RN, RP, f] L2).
259 #RN #RP #HRN #HRP #L1 elim L1 -L1 [ * | #L1 #I1 #IH * ]
260 [ /2 width=1 by lexs_atom, or_introl/
261 | #L2 #I2 #f @or_intror #H
262   lapply (lexs_inv_atom1 … H) -H #H destruct
263 | #f @or_intror #H
264   lapply (lexs_inv_atom2 … H) -H #H destruct
265 | #L2 #I2 #f elim (IH L2 (⫱f)) -IH #HL12
266   [2: /4 width=3 by lexs_fwd_bind, or_intror/ ]
267   elim (pn_split f) * #g #H destruct
268   [ elim (HRP L1 I1 I2) | elim (HRN L1 I1 I2) ] -HRP -HRN #HV12
269   [1,3: /3 width=1 by lexs_push, lexs_next, or_introl/ ]
270   @or_intror #H
271   [ elim (lexs_inv_push … H) | elim (lexs_inv_next … H) ] -H
272   /2 width=1 by/
273 ]
274 qed-.