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