]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/relocation/lpx_sn.ma
513d62019b42bcd2557c9964ac048c454f750295
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / relocation / lpx_sn.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/nstream_sle.ma".
16 include "basic_2/notation/relations/relationstar_5.ma".
17 include "basic_2/grammar/lenv.ma".
18
19 (* GENERAL ENTRYWISE EXTENSION OF A CONTEXT-SENSITIVE REALTION FOR TERMS ****)
20
21 (* Basic_2A1: includes: lpx_sn_atom lpx_sn_pair *)
22 inductive lexs (RS,RO:relation3 lenv term term): rtmap → relation lenv ≝
23 | lexs_atom: ∀f. lexs RS RO f (⋆) (⋆)
24 | lexs_next: ∀I,L1,L2,V1,V2,f.
25              lexs RS RO f L1 L2 → RS L1 V1 V2 →
26              lexs RS RO (⫯f) (L1.ⓑ{I}V1) (L2.ⓑ{I}V2)
27 | lexs_push: ∀I,L1,L2,V1,V2,f.
28              lexs RS RO f L1 L2 → RO L1 V1 V2 →
29              lexs RS RO (↑f) (L1.ⓑ{I}V1) (L2.ⓑ{I}V2)
30 .
31
32 interpretation "general entrywise extension (local environment)"
33    'RelationStar RS RO f L1 L2 = (lexs RS RO f L1 L2).
34
35 (* Basic inversion lemmas ***************************************************)
36
37 fact lexs_inv_atom1_aux: ∀RS,RO,X,Y,f. X ⦻*[RS, RO, f] Y → X = ⋆ → Y = ⋆.
38 #RS #RO #X #Y #f * -X -Y -f //
39 #I #L1 #L2 #V1 #V2 #f #_ #_ #H destruct
40 qed-.
41
42 (* Basic_2A1: includes lpx_sn_inv_atom1 *)
43 lemma lexs_inv_atom1: ∀RS,RO,Y,f. ⋆ ⦻*[RS, RO, f] Y → Y = ⋆.
44 /2 width=6 by lexs_inv_atom1_aux/ qed-.
45
46 fact lexs_inv_next1_aux: ∀RS,RO,X,Y,f. X ⦻*[RS, RO, f] Y → ∀J,K1,W1,g. X = K1.ⓑ{J}W1 → f = ⫯g →
47                          ∃∃K2,W2. K1 ⦻*[RS, RO, g] K2 & RS K1 W1 W2 & Y = K2.ⓑ{J}W2.
48 #RS #RO #X #Y #f * -X -Y -f
49 [ #f #J #K1 #W1 #g #H destruct
50 | #I #L1 #L2 #V1 #V2 #f #HL #HS #J #K1 #W1 #g #H1 #H2 <(injective_next … H2) -g destruct
51   /2 width=5 by ex3_2_intro/
52 | #I #L1 #L2 #V1 #V2 #f #_ #_ #J #K1 #W1 #g #_ #H elim (discr_push_next … H)
53 ]
54 qed-.
55
56 (* Basic_2A1: includes lpx_sn_inv_pair1 *)
57 lemma lexs_inv_next1: ∀RS,RO,J,K1,Y,W1,g. K1.ⓑ{J}W1 ⦻*[RS, RO, ⫯g] Y →
58                       ∃∃K2,W2. K1 ⦻*[RS, RO, g] K2 & RS K1 W1 W2 & Y = K2.ⓑ{J}W2.
59 /2 width=7 by lexs_inv_next1_aux/ qed-.
60
61
62 fact lexs_inv_push1_aux: ∀RS,RO,X,Y,f. X ⦻*[RS, RO, f] Y → ∀J,K1,W1,g. X = K1.ⓑ{J}W1 → f = ↑g →
63                          ∃∃K2,W2. K1 ⦻*[RS, RO, g] K2 & RO K1 W1 W2 & Y = K2.ⓑ{J}W2.
64 #RS #RO #X #Y #f * -X -Y -f
65 [ #f #J #K1 #W1 #g #H destruct
66 | #I #L1 #L2 #V1 #V2 #f #_ #_ #J #K1 #W1 #g #_ #H elim (discr_next_push … H)
67 | #I #L1 #L2 #V1 #V2 #f #HL #HO #J #K1 #W1 #g #H1 #H2 <(injective_push … H2) -g destruct
68   /2 width=5 by ex3_2_intro/
69 ]
70 qed-.
71
72 lemma lexs_inv_push1: ∀RS,RO,J,K1,Y,W1,g. K1.ⓑ{J}W1 ⦻*[RS, RO, ↑g] Y →
73                       ∃∃K2,W2. K1 ⦻*[RS, RO, g] K2 & RO K1 W1 W2 & Y = K2.ⓑ{J}W2.
74 /2 width=7 by lexs_inv_push1_aux/ qed-.
75
76 fact lexs_inv_atom2_aux: ∀RS,RO,X,Y,f. X ⦻*[RS, RO, f] Y → Y = ⋆ → X = ⋆.
77 #RS #RO #X #Y #f * -X -Y -f //
78 #I #L1 #L2 #V1 #V2 #f #_ #_ #H destruct
79 qed-.
80
81 (* Basic_2A1: includes lpx_sn_inv_atom2 *)
82 lemma lexs_inv_atom2: ∀RS,RO,X,f. X ⦻*[RS, RO, f] ⋆ → X = ⋆.
83 /2 width=6 by lexs_inv_atom2_aux/ qed-.
84
85 fact lexs_inv_next2_aux: ∀RS,RO,X,Y,f. X ⦻*[RS, RO, f] Y → ∀J,K2,W2,g. Y = K2.ⓑ{J}W2 → f = ⫯g →
86                          ∃∃K1,W1. K1 ⦻*[RS, RO, g] K2 & RS K1 W1 W2 & X = K1.ⓑ{J}W1.
87 #RS #RO #X #Y #f * -X -Y -f
88 [ #f #J #K2 #W2 #g #H destruct
89 | #I #L1 #L2 #V1 #V2 #f #HL #HS #J #K2 #W2 #g #H1 #H2 <(injective_next … H2) -g destruct
90   /2 width=5 by ex3_2_intro/
91 | #I #L1 #L2 #V1 #V2 #f #_ #_ #J #K2 #W2 #g #_ #H elim (discr_push_next … H)
92 ]
93 qed-.
94
95 (* Basic_2A1: includes lpx_sn_inv_pair2 *)
96 lemma lexs_inv_next2: ∀RS,RO,J,X,K2,W2,g. X ⦻*[RS, RO, ⫯g] K2.ⓑ{J}W2 →
97                       ∃∃K1,W1. K1 ⦻*[RS, RO, g] K2 & RS K1 W1 W2 & X = K1.ⓑ{J}W1.
98 /2 width=7 by lexs_inv_next2_aux/ qed-.
99
100 fact lexs_inv_push2_aux: ∀RS,RO,X,Y,f. X ⦻*[RS, RO, f] Y → ∀J,K2,W2,g. Y = K2.ⓑ{J}W2 → f = ↑g →
101                          ∃∃K1,W1. K1 ⦻*[RS, RO, g] K2 & RO K1 W1 W2 & X = K1.ⓑ{J}W1.
102 #RS #RO #X #Y #f * -X -Y -f
103 [ #f #J #K2 #W2 #g #H destruct
104 | #I #L1 #L2 #V1 #V2 #f #_ #_ #J #K2 #W2 #g #_ #H elim (discr_next_push … H)
105 | #I #L1 #L2 #V1 #V2 #f #HL #HO #J #K2 #W2 #g #H1 #H2 <(injective_push … H2) -g destruct
106   /2 width=5 by ex3_2_intro/
107 ]
108 qed-.
109
110 lemma lexs_inv_push2: ∀RS,RO,J,X,K2,W2,g. X ⦻*[RS, RO, ↑g] K2.ⓑ{J}W2 →
111                       ∃∃K1,W1. K1 ⦻*[RS, RO, g] K2 & RO K1 W1 W2 & X = K1.ⓑ{J}W1.
112 /2 width=7 by lexs_inv_push2_aux/ qed-.
113
114 (* Basic_2A1: includes lpx_sn_inv_pair *)
115 lemma lexs_inv_next: ∀RS,RO,I1,I2,L1,L2,V1,V2,f.
116                      L1.ⓑ{I1}V1 ⦻*[RS, RO, ⫯f] (L2.ⓑ{I2}V2) →
117                      ∧∧ L1 ⦻*[RS, RO, f] L2 & RS L1 V1 V2 & I1 = I2.
118 #RS #RO #I1 #I2 #L1 #L2 #V1 #V2 #f #H elim (lexs_inv_next1 … H) -H
119 #L0 #V0 #HL10 #HV10 #H destruct /2 width=1 by and3_intro/
120 qed-.
121
122 lemma lexs_inv_push: ∀RS,RO,I1,I2,L1,L2,V1,V2,f.
123                      L1.ⓑ{I1}V1 ⦻*[RS, RO, ↑f] (L2.ⓑ{I2}V2) →
124                      ∧∧ L1 ⦻*[RS, RO, f] L2 & RO L1 V1 V2 & I1 = I2.
125 #RS #RO #I1 #I2 #L1 #L2 #V1 #V2 #f #H elim (lexs_inv_push1 … H) -H
126 #L0 #V0 #HL10 #HV10 #H destruct /2 width=1 by and3_intro/
127 qed-.
128
129 (* Basic properties *********************************************************)
130
131 lemma lexs_eq_repl_back: ∀RS,RO,L1,L2. eq_stream_repl_back … (λf. L1 ⦻*[RS, RO, f] L2).
132 #RS #RO #L1 #L2 #f1 #H elim H -L1 -L2 -f1 //
133 [ #I #L1 #L2 #V1 #v2 #f1 #_ #HS #IH #f2 #H elim (next_inv_sn … H) -H /3 width=1 by lexs_next/
134 | #I #L1 #L2 #V1 #v2 #f1 #_ #HO #IH #f2 #H elim (push_inv_sn … H) -H /3 width=1 by lexs_push/
135 ]
136 qed-.
137
138 lemma lexs_eq_repl_fwd: ∀RS,RO,L1,L2. eq_stream_repl_fwd … (λf. L1 ⦻*[RS, RO, f] L2).
139 #RS #RO #L1 #L2 @eq_stream_repl_sym /2 width=3 by lexs_eq_repl_back/ (**) (* full auto fails *)
140 qed-.
141
142 (* Basic_2A1: includes: lpx_sn_refl *)
143 lemma lexs_refl: ∀RS,RO,f. 
144                  (∀L. reflexive … (RS L)) →
145                  (∀L. reflexive … (RO L)) →
146                  reflexive … (lexs RS RO f).
147 #RS #RO #f #HS #HO #L generalize in match f; -f elim L -L //
148 #L #I #V #IH * * /2 width=1 by lexs_next, lexs_push/
149 qed.
150
151 lemma sle_lexs_trans: ∀RS,RO. (∀L,T1,T2. RO L T1 T2 → RS L T1 T2) →
152                       ∀L1,L2,f2. L1 ⦻*[RS, RO, f2] L2 →
153                       ∀f1. f1 ⊆ f2 →  L1 ⦻*[RS, RO, f1] L2.
154 #RS #RO #HR #L1 #L2 #f2 #H elim H -L1 -L2 -f2 //
155 #I #L1 #L2 #V1 #V2 #f2 #_ #HV12 #IH
156 [2: * * [2: #n1 ] ] #f1 #H
157 [ <next_rew /4 width=5 by lexs_next, sle_inv_SO_aux/
158 | /4 width=5 by lexs_push, sle_inv_OO_aux/
159 | elim (sle_inv_xS_aux … H) -H [3: // |2: skip ]
160   #g1 #H #H1 destruct /3 width=5 by lexs_next/
161 ]
162 qed-.
163
164 lemma sle_lexs_conf: ∀RS,RO. (∀L,T1,T2. RS L T1 T2 → RO L T1 T2) →
165                      ∀L1,L2,f1. L1 ⦻*[RS, RO, f1] L2 →
166                      ∀f2. f1 ⊆ f2 →  L1 ⦻*[RS, RO, f2] L2.
167 #RS #RO #HR #L1 #L2 #f2 #H elim H -L1 -L2 -f2 //
168 #I #L1 #L2 #V1 #V2 #f1 #_ #HV12 #IH
169 [ * * [2: #n2 ] ] #f2 #H
170 [ <next_rew /4 width=5 by lexs_next, sle_inv_SS_aux/
171 | /4 width=5 by lexs_push, sle_inv_SO_aux/
172 | elim (sle_inv_Ox_aux … H) -H [3: // |2: skip ]
173   #g2 #H #H2 destruct /3 width=5 by lexs_push/
174 ]
175 qed-.
176
177 lemma lexs_co: ∀RS1,RS2,RO1,RO2.
178                (∀L1,T1,T2. RS1 L1 T1 T2 → RS2 L1 T1 T2) →
179                (∀L1,T1,T2. RO1 L1 T1 T2 → RO2 L1 T1 T2) →
180                ∀L1,L2,f. L1 ⦻*[RS1, RO1, f] L2 → L1 ⦻*[RS2, RO2, f] L2.
181 #RS1 #RS2 #RO1 #RO2 #HS #HO #L1 #L2 #f #H elim H -L1 -L2 -f
182 /3 width=1 by lexs_atom, lexs_next, lexs_push/
183 qed-.
184
185 (* Basic_2A1: removed theorems 17:
186               llpx_sn_inv_bind llpx_sn_inv_flat
187               llpx_sn_fwd_lref llpx_sn_fwd_pair_sn llpx_sn_fwd_length
188               llpx_sn_fwd_bind_sn llpx_sn_fwd_bind_dx llpx_sn_fwd_flat_sn llpx_sn_fwd_flat_dx
189               llpx_sn_refl llpx_sn_Y llpx_sn_bind_O llpx_sn_ge_up llpx_sn_ge llpx_sn_co
190               llpx_sn_fwd_drop_sn llpx_sn_fwd_drop_dx              
191 *)