]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/relocation/lexs.ma
- ground_2: update ...
[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/nstream_sle.ma".
16 include "basic_2/notation/relations/relationstar_4.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 (R:relation4 bool lenv term term): rtmap → relation lenv ≝
23 | lexs_atom: ∀f. lexs R f (⋆) (⋆)
24 | lexs_next: ∀I,L1,L2,V1,V2,f.
25              lexs R f L1 L2 → R (Ⓣ) L1 V1 V2 →
26              lexs R (⫯f) (L1.ⓑ{I}V1) (L2.ⓑ{I}V2)
27 | lexs_push: ∀I,L1,L2,V1,V2,f.
28              lexs R f L1 L2 → R (Ⓕ) L1 V1 V2 →
29              lexs R (↑f) (L1.ⓑ{I}V1) (L2.ⓑ{I}V2)
30 .
31
32 interpretation "general entrywise extension (local environment)"
33    'RelationStar R f L1 L2 = (lexs R f L1 L2).
34
35 (* Basic inversion lemmas ***************************************************)
36
37 fact lexs_inv_atom1_aux: ∀R,X,Y,f. X ⦻*[R, f] Y → X = ⋆ → Y = ⋆.
38 #R #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: ∀R,Y,f. ⋆ ⦻*[R, f] Y → Y = ⋆.
44 /2 width=6 by lexs_inv_atom1_aux/ qed-.
45
46 fact lexs_inv_next1_aux: ∀R,X,Y,f. X ⦻*[R, f] Y → ∀J,K1,W1,g. X = K1.ⓑ{J}W1 → f = ⫯g →
47                          ∃∃K2,W2. K1 ⦻*[R, g] K2 & R (Ⓣ)  K1 W1 W2 & Y = K2.ⓑ{J}W2.
48 #R #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: ∀R,J,K1,Y,W1,g. K1.ⓑ{J}W1 ⦻*[R, ⫯g] Y →
58                       ∃∃K2,W2. K1 ⦻*[R, g] K2 & R (Ⓣ)  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: ∀R,X,Y,f. X ⦻*[R, f] Y → ∀J,K1,W1,g. X = K1.ⓑ{J}W1 → f = ↑g →
63                          ∃∃K2,W2. K1 ⦻*[R, g] K2 & R (Ⓕ)  K1 W1 W2 & Y = K2.ⓑ{J}W2.
64 #R #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: ∀R,J,K1,Y,W1,g. K1.ⓑ{J}W1 ⦻*[R, ↑g] Y →
73                       ∃∃K2,W2. K1 ⦻*[R, g] K2 & R (Ⓕ)  K1 W1 W2 & Y = K2.ⓑ{J}W2.
74 /2 width=7 by lexs_inv_push1_aux/ qed-.
75
76 fact lexs_inv_atom2_aux: ∀R,X,Y,f. X ⦻*[R, f] Y → Y = ⋆ → X = ⋆.
77 #R #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: ∀R,X,f. X ⦻*[R, f] ⋆ → X = ⋆.
83 /2 width=6 by lexs_inv_atom2_aux/ qed-.
84
85 fact lexs_inv_next2_aux: ∀R,X,Y,f. X ⦻*[R, f] Y → ∀J,K2,W2,g. Y = K2.ⓑ{J}W2 → f = ⫯g →
86                          ∃∃K1,W1. K1 ⦻*[R, g] K2 & R (Ⓣ)  K1 W1 W2 & X = K1.ⓑ{J}W1.
87 #R #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: ∀R,J,X,K2,W2,g. X ⦻*[R, ⫯g] K2.ⓑ{J}W2 →
97                       ∃∃K1,W1. K1 ⦻*[R, g] K2 & R (Ⓣ)  K1 W1 W2 & X = K1.ⓑ{J}W1.
98 /2 width=7 by lexs_inv_next2_aux/ qed-.
99
100 fact lexs_inv_push2_aux: ∀R,X,Y,f. X ⦻*[R, f] Y → ∀J,K2,W2,g. Y = K2.ⓑ{J}W2 → f = ↑g →
101                          ∃∃K1,W1. K1 ⦻*[R, g] K2 & R (Ⓕ)  K1 W1 W2 & X = K1.ⓑ{J}W1.
102 #R #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: ∀R,J,X,K2,W2,g. X ⦻*[R, ↑g] K2.ⓑ{J}W2 →
111                       ∃∃K1,W1. K1 ⦻*[R, g] K2 & R (Ⓕ)  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: ∀R,I1,I2,L1,L2,V1,V2,f.
116                      L1.ⓑ{I1}V1 ⦻*[R, ⫯f] (L2.ⓑ{I2}V2) →
117                      ∧∧ L1 ⦻*[R, f] L2 & R (Ⓣ)  L1 V1 V2 & I1 = I2.
118 #R #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: ∀R,I1,I2,L1,L2,V1,V2,f.
123                      L1.ⓑ{I1}V1 ⦻*[R, ↑f] (L2.ⓑ{I2}V2) →
124                      ∧∧ L1 ⦻*[R, f] L2 & R (Ⓕ)  L1 V1 V2 & I1 = I2.
125 #R #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: ∀R,L1,L2. eq_stream_repl_back … (λf. L1 ⦻*[R, f] L2).
132 #R #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: ∀R,L1,L2. eq_stream_repl_fwd … (λf. L1 ⦻*[R, f] L2).
139 #R #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: ∀R,f.
144                  (∀b,L. reflexive … (R b L)) →
145                  reflexive … (lexs R f).
146 #R #f #HR #L generalize in match f; -f elim L -L //
147 #L #I #V #IH * * /2 width=1 by lexs_next, lexs_push/
148 qed.
149
150 lemma sle_lexs_trans: ∀R. (∀L,T1,T2. R (Ⓣ) L T1 T2 → R (Ⓕ) L T1 T2) →
151                       ∀L1,L2,f2. L1 ⦻*[R, f2] L2 →
152                       ∀f1. f1 ⊆ f2 →  L1 ⦻*[R, f1] L2.
153 #R #HR #L1 #L2 #f2 #H elim H -L1 -L2 -f2 //
154 #I #L1 #L2 #V1 #V2 #f2 #_ #HV12 #IH
155 [ * * [2: #n1 ] ] #f1 #H
156 [ /4 width=5 by lexs_next, sle_inv_SS_aux/
157 | /4 width=5 by lexs_push, sle_inv_OS_aux/
158 | elim (sle_inv_xO_aux … H) -H [3: // |2: skip ]
159   #g1 #H #H1 destruct /3 width=5 by lexs_push/
160 ]
161 qed-.
162
163 lemma sle_lexs_conf: ∀R. (∀L,T1,T2. R (Ⓕ) L T1 T2 → R (Ⓣ) L T1 T2) →
164                      ∀L1,L2,f1. L1 ⦻*[R, f1] L2 →
165                      ∀f2. f1 ⊆ f2 →  L1 ⦻*[R, f2] L2.
166 #R #HR #L1 #L2 #f2 #H elim H -L1 -L2 -f2 //
167 #I #L1 #L2 #V1 #V2 #f1 #_ #HV12 #IH
168 [2: * * [2: #n2 ] ] #f2 #H
169 [ /4 width=5 by lexs_next, sle_inv_OS_aux/
170 | /4 width=5 by lexs_push, sle_inv_OO_aux/
171 | elim (sle_inv_Sx_aux … H) -H [3: // |2: skip ]
172   #g2 #H #H2 destruct /3 width=5 by lexs_next/
173 ]
174 qed-.
175
176 lemma lexs_co: ∀R1,R2.
177                (∀b,L1,T1,T2. R1 b L1 T1 T2 → R2 b L1 T1 T2) →
178                ∀L1,L2,f. L1 ⦻*[R1, f] L2 → L1 ⦻*[R2, f] L2.
179 #R1 #R2 #HR #L1 #L2 #f #H elim H -L1 -L2 -f
180 /3 width=1 by lexs_atom, lexs_next, lexs_push/
181 qed-.
182
183 (* Basic_2A1: removed theorems 17:
184               llpx_sn_inv_bind llpx_sn_inv_flat
185               llpx_sn_fwd_lref llpx_sn_fwd_pair_sn llpx_sn_fwd_length
186               llpx_sn_fwd_bind_sn llpx_sn_fwd_bind_dx llpx_sn_fwd_flat_sn llpx_sn_fwd_flat_dx
187               llpx_sn_refl llpx_sn_Y llpx_sn_bind_O llpx_sn_ge_up llpx_sn_ge llpx_sn_co
188               llpx_sn_fwd_drop_sn llpx_sn_fwd_drop_dx              
189 *)