1 (**************************************************************************)
4 (* ||A|| A project by Andrea Asperti *)
6 (* ||I|| Developers: *)
7 (* ||T|| The HELM team. *)
8 (* ||A|| http://helm.cs.unibo.it *)
10 (* \ / This file is distributed under the terms of the *)
11 (* v GNU General Public License Version 2 *)
13 (**************************************************************************)
15 include "ground_2/relocation/rtmap_sle.ma".
16 include "basic_2/notation/relations/relationstar_5.ma".
17 include "basic_2/grammar/lenv.ma".
19 (* GENERIC ENTRYWISE EXTENSION OF CONTEXT-SENSITIVE REALTIONS FOR TERMS *****)
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)
32 interpretation "generic entrywise extension (local environment)"
33 'RelationStar RN RP f L1 L2 = (lexs RN RP f L1 L2).
35 definition lexs_confluent: relation6 (relation3 lenv term term)
36 (relation3 lenv term term) … ≝
37 λR1,R2,RN1,RP1,RN2,RP2.
38 ∀f,L0,T0,T1. R1 L0 T0 T1 → ∀T2. R2 L0 T0 T2 →
39 ∀L1. L0 ⦻*[RN1, RP1, f] L1 → ∀L2. L0 ⦻*[RN2, RP2, f] L2 →
40 ∃∃T. R2 L1 T1 T & R1 L2 T2 T.
42 definition lexs_transitive: relation5 (relation3 lenv term term)
43 (relation3 lenv term term) … ≝
45 ∀f,L1,T1,T. R1 L1 T1 T → ∀L2. L1 ⦻*[RN, RP, f] L2 →
46 ∀T2. R2 L2 T T2 → R3 L1 T1 T2.
48 (* Basic inversion lemmas ***************************************************)
50 fact lexs_inv_atom1_aux: ∀RN,RP,f,X,Y. X ⦻*[RN, RP, f] Y → X = ⋆ → Y = ⋆.
51 #RN #RP #f #X #Y * -f -X -Y //
52 #f #I #L1 #L2 #V1 #V2 #_ #_ #H destruct
55 (* Basic_2A1: includes lpx_sn_inv_atom1 *)
56 lemma lexs_inv_atom1: ∀RN,RP,f,Y. ⋆ ⦻*[RN, RP, f] Y → Y = ⋆.
57 /2 width=6 by lexs_inv_atom1_aux/ qed-.
59 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 →
60 ∃∃K2,W2. K1 ⦻*[RN, RP, g] K2 & RN K1 W1 W2 & Y = K2.ⓑ{J}W2.
61 #RN #RP #f #X #Y * -f -X -Y
62 [ #f #g #J #K1 #W1 #H destruct
63 | #f #I #L1 #L2 #V1 #V2 #HL #HV #g #J #K1 #W1 #H1 #H2 <(injective_next … H2) -g destruct
64 /2 width=5 by ex3_2_intro/
65 | #f #I #L1 #L2 #V1 #V2 #_ #_ #g #J #K1 #W1 #_ #H elim (discr_push_next … H)
69 (* Basic_2A1: includes lpx_sn_inv_pair1 *)
70 lemma lexs_inv_next1: ∀RN,RP,g,J,K1,Y,W1. K1.ⓑ{J}W1 ⦻*[RN, RP, ⫯g] Y →
71 ∃∃K2,W2. K1 ⦻*[RN, RP, g] K2 & RN K1 W1 W2 & Y = K2.ⓑ{J}W2.
72 /2 width=7 by lexs_inv_next1_aux/ qed-.
75 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 →
76 ∃∃K2,W2. K1 ⦻*[RN, RP, g] K2 & RP K1 W1 W2 & Y = K2.ⓑ{J}W2.
77 #RN #RP #f #X #Y * -f -X -Y
78 [ #f #g #J #K1 #W1 #H destruct
79 | #f #I #L1 #L2 #V1 #V2 #_ #_ #g #J #K1 #W1 #_ #H elim (discr_next_push … H)
80 | #f #I #L1 #L2 #V1 #V2 #HL #HV #g #J #K1 #W1 #H1 #H2 <(injective_push … H2) -g destruct
81 /2 width=5 by ex3_2_intro/
85 lemma lexs_inv_push1: ∀RN,RP,g,J,K1,Y,W1. K1.ⓑ{J}W1 ⦻*[RN, RP, ↑g] Y →
86 ∃∃K2,W2. K1 ⦻*[RN, RP, g] K2 & RP K1 W1 W2 & Y = K2.ⓑ{J}W2.
87 /2 width=7 by lexs_inv_push1_aux/ qed-.
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 #I #L1 #L2 #V1 #V2 #_ #_ #H destruct
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-.
98 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 →
99 ∃∃K1,W1. K1 ⦻*[RN, RP, g] K2 & RN K1 W1 W2 & X = K1.ⓑ{J}W1.
100 #RN #RP #f #X #Y * -f -X -Y
101 [ #f #g #J #K2 #W2 #H destruct
102 | #f #I #L1 #L2 #V1 #V2 #HL #HV #g #J #K2 #W2 #H1 #H2 <(injective_next … H2) -g destruct
103 /2 width=5 by ex3_2_intro/
104 | #f #I #L1 #L2 #V1 #V2 #_ #_ #g #J #K2 #W2 #_ #H elim (discr_push_next … H)
108 (* Basic_2A1: includes lpx_sn_inv_pair2 *)
109 lemma lexs_inv_next2: ∀RN,RP,g,J,X,K2,W2. X ⦻*[RN, RP, ⫯g] K2.ⓑ{J}W2 →
110 ∃∃K1,W1. K1 ⦻*[RN, RP, g] K2 & RN K1 W1 W2 & X = K1.ⓑ{J}W1.
111 /2 width=7 by lexs_inv_next2_aux/ qed-.
113 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 →
114 ∃∃K1,W1. K1 ⦻*[RN, RP, g] K2 & RP K1 W1 W2 & X = K1.ⓑ{J}W1.
115 #RN #RP #f #X #Y * -f -X -Y
116 [ #f #J #K2 #W2 #g #H destruct
117 | #f #I #L1 #L2 #V1 #V2 #_ #_ #g #J #K2 #W2 #_ #H elim (discr_next_push … H)
118 | #f #I #L1 #L2 #V1 #V2 #HL #HV #g #J #K2 #W2 #H1 #H2 <(injective_push … H2) -g destruct
119 /2 width=5 by ex3_2_intro/
123 lemma lexs_inv_push2: ∀RN,RP,g,J,X,K2,W2. X ⦻*[RN, RP, ↑g] K2.ⓑ{J}W2 →
124 ∃∃K1,W1. K1 ⦻*[RN, RP, g] K2 & RP K1 W1 W2 & X = K1.ⓑ{J}W1.
125 /2 width=7 by lexs_inv_push2_aux/ qed-.
127 (* Basic_2A1: includes lpx_sn_inv_pair *)
128 lemma lexs_inv_next: ∀RN,RP,f,I1,I2,L1,L2,V1,V2.
129 L1.ⓑ{I1}V1 ⦻*[RN, RP, ⫯f] (L2.ⓑ{I2}V2) →
130 ∧∧ L1 ⦻*[RN, RP, f] L2 & RN L1 V1 V2 & I1 = I2.
131 #RN #RP #f #I1 #I2 #L1 #L2 #V1 #V2 #H elim (lexs_inv_next1 … H) -H
132 #L0 #V0 #HL10 #HV10 #H destruct /2 width=1 by and3_intro/
135 lemma lexs_inv_push: ∀RN,RP,f,I1,I2,L1,L2,V1,V2.
136 L1.ⓑ{I1}V1 ⦻*[RN, RP, ↑f] (L2.ⓑ{I2}V2) →
137 ∧∧ L1 ⦻*[RN, RP, f] L2 & RP L1 V1 V2 & I1 = I2.
138 #RN #RP #f #I1 #I2 #L1 #L2 #V1 #V2 #H elim (lexs_inv_push1 … H) -H
139 #L0 #V0 #HL10 #HV10 #H destruct /2 width=1 by and3_intro/
142 lemma lexs_inv_tl: ∀RN,RP,f,I,L1,L2,V1,V2. L1 ⦻*[RN, RP, ⫱f] L2 →
143 RN L1 V1 V2 → RP L1 V1 V2 →
144 L1.ⓑ{I}V1 ⦻*[RN, RP, f] L2.ⓑ{I}V2.
145 #RN #RP #f #I #L2 #L2 #V1 #V2 elim (pn_split f) *
146 /2 width=1 by lexs_next, lexs_push/
149 (* Basic forward lemmas *****************************************************)
151 lemma lexs_fwd_pair: ∀RN,RP,f,I1,I2,L1,L2,V1,V2.
152 L1.ⓑ{I1}V1 ⦻*[RN, RP, f] L2.ⓑ{I2}V2 →
153 L1 ⦻*[RN, RP, ⫱f] L2 ∧ I1 = I2.
154 #RN #RP #f #I1 #I2 #L2 #L2 #V1 #V2 #Hf
155 elim (pn_split f) * #g #H destruct
156 [ elim (lexs_inv_push … Hf) | elim (lexs_inv_next … Hf) ] -Hf
160 (* Basic properties *********************************************************)
162 lemma lexs_eq_repl_back: ∀RN,RP,L1,L2. eq_repl_back … (λf. L1 ⦻*[RN, RP, f] L2).
163 #RN #RP #L1 #L2 #f1 #H elim H -f1 -L1 -L2 //
164 #f1 #I #L1 #L2 #V1 #v2 #_ #HV #IH #f2 #H
165 [ elim (eq_inv_nx … H) -H /3 width=3 by lexs_next/
166 | elim (eq_inv_px … H) -H /3 width=3 by lexs_push/
170 lemma lexs_eq_repl_fwd: ∀RN,RP,L1,L2. eq_repl_fwd … (λf. L1 ⦻*[RN, RP, f] L2).
171 #RN #RP #L1 #L2 @eq_repl_sym /2 width=3 by lexs_eq_repl_back/ (**) (* full auto fails *)
174 (* Note: fexs_sym and fexs_trans hold, but lexs_sym and lexs_trans do not *)
175 (* Basic_2A1: includes: lpx_sn_refl *)
176 lemma lexs_refl: ∀RN,RP,f.
177 (∀L. reflexive … (RN L)) →
178 (∀L. reflexive … (RP L)) →
179 reflexive … (lexs RN RP f).
180 #RN #RP #f #HRN #HRP #L generalize in match f; -f elim L -L //
181 #L #I #V #IH * * /2 width=1 by lexs_next, lexs_push/
184 lemma sle_lexs_trans: ∀RN,RP. (∀L,T1,T2. RN L T1 T2 → RP L T1 T2) →
185 ∀f2,L1,L2. L1 ⦻*[RN, RP, f2] L2 →
186 ∀f1. f1 ⊆ f2 → L1 ⦻*[RN, RP, f1] L2.
187 #RN #RP #HR #f2 #L1 #L2 #H elim H -f2 -L1 -L2 //
188 #f2 #I #L1 #L2 #V1 #V2 #_ #HV12 #IH
189 [ * * [2: #n1 ] ] #f1 #H
190 [ /4 width=5 by lexs_next, sle_inv_nn/
191 | /4 width=5 by lexs_push, sle_inv_pn/
192 | elim (sle_inv_xp … H) -H [2,3: // ]
193 #g1 #H #H1 destruct /3 width=5 by lexs_push/
197 lemma sle_lexs_conf: ∀RN,RP. (∀L,T1,T2. RP L T1 T2 → RN L T1 T2) →
198 ∀f1,L1,L2. L1 ⦻*[RN, RP, f1] L2 →
199 ∀f2. f1 ⊆ f2 → L1 ⦻*[RN, RP, f2] L2.
200 #RN #RP #HR #f1 #L1 #L2 #H elim H -f1 -L1 -L2 //
201 #f1 #I #L1 #L2 #V1 #V2 #_ #HV12 #IH
202 [2: * * [2: #n2 ] ] #f2 #H
203 [ /4 width=5 by lexs_next, sle_inv_pn/
204 | /4 width=5 by lexs_push, sle_inv_pp/
205 | elim (sle_inv_nx … H) -H [2,3: // ]
206 #g2 #H #H2 destruct /3 width=5 by lexs_next/
210 lemma lexs_co: ∀RN1,RP1,RN2,RP2.
211 (∀L1,T1,T2. RN1 L1 T1 T2 → RN2 L1 T1 T2) →
212 (∀L1,T1,T2. RP1 L1 T1 T2 → RP2 L1 T1 T2) →
213 ∀f,L1,L2. L1 ⦻*[RN1, RP1, f] L2 → L1 ⦻*[RN2, RP2, f] L2.
214 #RN1 #RP1 #RN2 #RP2 #HRN #HRP #f #L1 #L2 #H elim H -f -L1 -L2
215 /3 width=1 by lexs_atom, lexs_next, lexs_push/