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 (* GENERAL ENTRYWISE EXTENSION OF CONTEXT-SENSITIVE REALTIONS FOR TERMS *****)
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.
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.
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)
38 interpretation "general entrywise extension (local environment)"
39 'RelationStar RN RP f L1 L2 = (lexs RN RP f L1 L2).
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.
48 definition lexs_transitive: relation4 (relation3 lenv term term)
49 (relation3 lenv term term) … ≝
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.
54 (* Basic inversion lemmas ***************************************************)
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
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-.
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)
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-.
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/
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-.
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
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-.
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)
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-.
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/
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-.
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/
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/
148 (* Basic properties *********************************************************)
150 lemma lexs_eq_repl_back: ∀RN,RP,L1,L2. eq_repl_back … (λf. L1 ⦻*[RN, RP, f] L2).
151 #RN #RP #L1 #L2 #f1 #H elim H -L1 -L2 -f1 //
152 #I #L1 #L2 #V1 #v2 #f1 #_ #HV #IH #f2 #H
153 [ elim (eq_inv_nx … H) -H /3 width=3 by lexs_next/
154 | elim (eq_inv_px … H) -H /3 width=3 by lexs_push/
158 lemma lexs_eq_repl_fwd: ∀RN,RP,L1,L2. eq_repl_fwd … (λf. L1 ⦻*[RN, RP, f] L2).
159 #RN #RP #L1 #L2 @eq_repl_sym /2 width=3 by lexs_eq_repl_back/ (**) (* full auto fails *)
162 (* Note: fexs_sym and fexs_trans hold, but lexs_sym and lexs_trans do not *)
163 (* Basic_2A1: includes: lpx_sn_refl *)
164 lemma lexs_refl: ∀RN,RP,f.
165 (∀L. reflexive … (RN L)) →
166 (∀L. reflexive … (RP L)) →
167 reflexive … (lexs RN RP f).
168 #RN #RP #f #HRN #HRP #L generalize in match f; -f elim L -L //
169 #L #I #V #IH * * /2 width=1 by lexs_next, lexs_push/
172 lemma sle_lexs_trans: ∀RN,RP. (∀L,T1,T2. RN L T1 T2 → RP L T1 T2) →
173 ∀L1,L2,f2. L1 ⦻*[RN, RP, f2] L2 →
174 ∀f1. f1 ⊆ f2 → L1 ⦻*[RN, RP, f1] L2.
175 #RN #RP #HR #L1 #L2 #f2 #H elim H -L1 -L2 -f2 //
176 #I #L1 #L2 #V1 #V2 #f2 #_ #HV12 #IH
177 [ * * [2: #n1 ] ] #f1 #H
178 [ /4 width=5 by lexs_next, sle_inv_nn/
179 | /4 width=5 by lexs_push, sle_inv_pn/
180 | elim (sle_inv_xp … H) -H [2,3: // ]
181 #g1 #H #H1 destruct /3 width=5 by lexs_push/
185 lemma sle_lexs_conf: ∀RN,RP. (∀L,T1,T2. RP L T1 T2 → RN L T1 T2) →
186 ∀L1,L2,f1. L1 ⦻*[RN, RP, f1] L2 →
187 ∀f2. f1 ⊆ f2 → L1 ⦻*[RN, RP, f2] L2.
188 #RN #RP #HR #L1 #L2 #f2 #H elim H -L1 -L2 -f2 //
189 #I #L1 #L2 #V1 #V2 #f1 #_ #HV12 #IH
190 [2: * * [2: #n2 ] ] #f2 #H
191 [ /4 width=5 by lexs_next, sle_inv_pn/
192 | /4 width=5 by lexs_push, sle_inv_pp/
193 | elim (sle_inv_nx … H) -H [2,3: // ]
194 #g2 #H #H2 destruct /3 width=5 by lexs_next/
198 lemma lexs_co: ∀RN1,RP1,RN2,RP2.
199 (∀L1,T1,T2. RN1 L1 T1 T2 → RN2 L1 T1 T2) →
200 (∀L1,T1,T2. RP1 L1 T1 T2 → RP2 L1 T1 T2) →
201 ∀L1,L2,f. L1 ⦻*[RN1, RP1, f] L2 → L1 ⦻*[RN2, RP2, f] L2.
202 #RN1 #RP1 #RN2 #RP2 #HRN #HRP #L1 #L2 #f #H elim H -L1 -L2 -f
203 /3 width=1 by lexs_atom, lexs_next, lexs_push/
206 (* Basic_2A1: removed theorems 17:
207 llpx_sn_inv_bind llpx_sn_inv_flat
208 llpx_sn_fwd_lref llpx_sn_fwd_pair_sn llpx_sn_fwd_length
209 llpx_sn_fwd_bind_sn llpx_sn_fwd_bind_dx llpx_sn_fwd_flat_sn llpx_sn_fwd_flat_dx
210 llpx_sn_refl llpx_sn_Y llpx_sn_bind_O llpx_sn_ge_up llpx_sn_ge llpx_sn_co
211 llpx_sn_fwd_drop_sn llpx_sn_fwd_drop_dx