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 "static_2/relocation/sex_length.ma".
16 include "static_2/static/fsle_fsle.ma".
17 include "static_2/static/rex_drops.ma".
18 include "static_2/static/rex_rex.ma".
20 (* GENERIC EXTENSION ON REFERRED ENTRIES OF A CONTEXT-SENSITIVE REALTION ****)
22 definition R_fsge_compatible: predicate (relation3 …) ≝ λRN.
23 ∀L,T1,T2. RN L T1 T2 → ❨L,T2❩ ⊆ ❨L,T1❩.
25 definition rex_fsge_compatible: predicate (relation3 …) ≝ λRN.
26 ∀L1,L2,T. L1 ⪤[RN,T] L2 → ❨L2,T❩ ⊆ ❨L1,T❩.
28 definition rex_fsle_compatible: predicate (relation3 …) ≝ λRN.
29 ∀L1,L2,T. L1 ⪤[RN,T] L2 → ❨L1,T❩ ⊆ ❨L2,T❩.
31 (* Basic inversions with free variables inclusion for restricted closures ***)
33 lemma frees_sex_conf_fsge (R):
34 rex_fsge_compatible R →
35 ∀L1,T,f1. L1 ⊢ 𝐅+❨T❩ ≘ f1 →
36 ∀L2. L1 ⪤[cext2 R,cfull,f1] L2 →
37 ∃∃f2. L2 ⊢ 𝐅+❨T❩ ≘ f2 & f2 ⊆ f1.
38 #R #HR #L1 #T #f1 #Hf1 #L2 #H1L
39 lapply (HR L1 L2 T ?) /2 width=3 by ex2_intro/ #H2L
40 @(fsle_frees_trans_eq … H2L … Hf1) /3 width=4 by sex_fwd_length, sym_eq/
43 lemma frees_sex_conf_fsle (R):
44 rex_fsle_compatible R →
45 ∀L1,T,f1. L1 ⊢ 𝐅+❨T❩ ≘ f1 →
46 ∀L2. L1 ⪤[cext2 R,cfull,f1] L2 →
47 ∃∃f2. L2 ⊢ 𝐅+❨T❩ ≘ f2 & f1 ⊆ f2.
48 #R #HR #L1 #T #f1 #Hf1 #L2 #H1L
49 lapply (HR L1 L2 T ?) /2 width=3 by ex2_intro/ #H2L
50 @(fsle_frees_conf_eq … H2L … Hf1) /3 width=4 by sex_fwd_length, sym_eq/
53 (* Properties with free variables inclusion for restricted closures *********)
55 (* Note: we just need lveq_inv_refl: ∀L, n1, n2. L ≋ⓧ*[n1, n2] L → ∧∧ 0 = n1 & 0 = n2 *)
56 lemma fsge_rex_trans (R):
57 ∀L1,T1,T2. ❨L1,T1❩ ⊆ ❨L1,T2❩ →
58 ∀L2. L1 ⪤[R,T2] L2 → L1 ⪤[R,T1] L2.
59 #R #L1 #T1 #T2 * #n1 #n2 #f1 #f2 #Hf1 #Hf2 #Hn #Hf #L2 #HL12
60 elim (lveq_inj_length … Hn ?) // #H1 #H2 destruct
61 /4 width=5 by rex_inv_frees, sle_sex_trans, ex2_intro/
65 rex_fsge_compatible R →
66 (∀L1,L2,T1,T2. R L1 T1 T2 → R L2 T2 T1) →
67 ∀T. symmetric … (rex R T).
68 #R #H1R #H2R #T #L1 #L2
70 elim (frees_sex_conf_fsge … Hf1 … HL12) -Hf1 //
71 /5 width=5 by sle_sex_trans, sex_sym, cext2_sym, ex2_intro/
74 lemma rex_pair_sn_split (R1) (R2):
75 (∀L. reflexive … (R1 L)) → (∀L. reflexive … (R2 L)) →
76 rex_fsge_compatible R1 →
77 ∀L1,L2,V. L1 ⪤[R1,V] L2 → ∀I,T.
78 ∃∃L. L1 ⪤[R1,②[I]V.T] L & L ⪤[R2,V] L2.
79 #R1 #R2 #HR1 #HR2 #HR #L1 #L2 #V * #f #Hf #HL12 * [ #p ] #I #T
80 [ elim (frees_total L1 (ⓑ[p,I]V.T)) #g #Hg
81 elim (frees_inv_bind … Hg) #y1 #y2 #H #_ #Hy
82 | elim (frees_total L1 (ⓕ[I]V.T)) #g #Hg
83 elim (frees_inv_flat … Hg) #y1 #y2 #H #_ #Hy
85 lapply(frees_mono … H … Hf) -H #H1
86 lapply (pr_sor_eq_repl_back_sn … Hy … H1) -y1 #Hy
87 lapply (pr_sor_inv_sle_sn … Hy) -y2 #Hfg
88 elim (sex_sle_split_sn (cext2 R1) (cext2 R2) … HL12 … Hfg) -HL12 /2 width=1 by ext2_refl/ #L #HL1 #HL2
89 lapply (sle_sex_trans … HL1 … Hfg) // #H
90 elim (frees_sex_conf_fsge … Hf … H) -Hf -H
91 /4 width=7 by sle_sex_trans, ex2_intro/
94 lemma rex_flat_dx_split (R1) (R2):
95 (∀L. reflexive … (R1 L)) → (∀L. reflexive … (R2 L)) →
96 rex_fsge_compatible R1 →
97 ∀L1,L2,T. L1 ⪤[R1,T] L2 → ∀I,V.
98 ∃∃L. L1 ⪤[R1,ⓕ[I]V.T] L & L ⪤[R2,T] L2.
99 #R1 #R2 #HR1 #HR2 #HR #L1 #L2 #T * #f #Hf #HL12 #I #V
100 elim (frees_total L1 (ⓕ[I]V.T)) #g #Hg
101 elim (frees_inv_flat … Hg) #y1 #y2 #_ #H #Hy
102 lapply(frees_mono … H … Hf) -H #H2
103 lapply (pr_sor_eq_repl_back_dx … Hy … H2) -y2 #Hy
104 lapply (pr_sor_inv_sle_dx … Hy) -y1 #Hfg
105 elim (sex_sle_split_sn (cext2 R1) (cext2 R2) … HL12 … Hfg) -HL12 /2 width=1 by ext2_refl/ #L #HL1 #HL2
106 lapply (sle_sex_trans … HL1 … Hfg) // #H
107 elim (frees_sex_conf_fsge … Hf … H) -Hf -H
108 /4 width=7 by sle_sex_trans, ex2_intro/
111 lemma rex_bind_dx_split (R1) (R2):
112 (∀L. reflexive … (R1 L)) → (∀L. reflexive … (R2 L)) →
113 rex_fsge_compatible R1 →
114 ∀I,L1,L2,V1,T. L1.ⓑ[I]V1 ⪤[R1,T] L2 → ∀p.
115 ∃∃L,V. L1 ⪤[R1,ⓑ[p,I]V1.T] L & L.ⓑ[I]V ⪤[R2,T] L2 & R1 L1 V1 V.
116 #R1 #R2 #HR1 #HR2 #HR #I #L1 #L2 #V1 #T * #f #Hf #HL12 #p
117 elim (frees_total L1 (ⓑ[p,I]V1.T)) #g #Hg
118 elim (frees_inv_bind … Hg) #y1 #y2 #_ #H #Hy
119 lapply(frees_mono … H … Hf) -H #H2
120 lapply (pr_tl_eq_repl … H2) -H2 #H2
121 lapply (pr_sor_eq_repl_back_dx … Hy … H2) -y2 #Hy
122 lapply (pr_sor_inv_sle_dx … Hy) -y1 #Hfg
123 lapply (pr_sle_inv_tl_sn … Hfg) -Hfg #Hfg
124 elim (sex_sle_split_sn (cext2 R1) (cext2 R2) … HL12 … Hfg) -HL12 /2 width=1 by ext2_refl/ #Y #H #HL2
125 lapply (sle_sex_trans … H … Hfg) // #H0
126 elim (sex_inv_next1 … H) -H #Z #L #HL1 #H
127 elim (ext2_inv_pair_sn … H) -H #V #HV #H1 #H2 destruct
128 elim (frees_sex_conf_fsge … Hf … H0) -Hf -H0
129 /4 width=7 by sle_sex_trans, ex3_2_intro, ex2_intro/
132 lemma rex_bind_dx_split_void (R1) (R2):
133 (∀L. reflexive … (R1 L)) → (∀L. reflexive … (R2 L)) →
134 rex_fsge_compatible R1 →
135 ∀L1,L2,T. L1.ⓧ ⪤[R1,T] L2 → ∀p,I,V.
136 ∃∃L. L1 ⪤[R1,ⓑ[p,I]V.T] L & L.ⓧ ⪤[R2,T] L2.
137 #R1 #R2 #HR1 #HR2 #HR #L1 #L2 #T * #f #Hf #HL12 #p #I #V
138 elim (frees_total L1 (ⓑ[p,I]V.T)) #g #Hg
139 elim (frees_inv_bind_void … Hg) #y1 #y2 #_ #H #Hy
140 lapply(frees_mono … H … Hf) -H #H2
141 lapply (pr_tl_eq_repl … H2) -H2 #H2
142 lapply (pr_sor_eq_repl_back_dx … Hy … H2) -y2 #Hy
143 lapply (pr_sor_inv_sle_dx … Hy) -y1 #Hfg
144 lapply (pr_sle_inv_tl_sn … Hfg) -Hfg #Hfg
145 elim (sex_sle_split_sn (cext2 R1) (cext2 R2) … HL12 … Hfg) -HL12 /2 width=1 by ext2_refl/ #Y #H #HL2
146 lapply (sle_sex_trans … H … Hfg) // #H0
147 elim (sex_inv_next1 … H) -H #Z #L #HL1 #H
148 elim (ext2_inv_unit_sn … H) -H #H destruct
149 elim (frees_sex_conf_fsge … Hf … H0) -Hf -H0
150 /4 width=7 by sle_sex_trans, ex2_intro/ (* note: 2 ex2_intro *)
153 (* Main properties with free variables inclusion for restricted closures ****)
155 theorem rex_conf1 (R1) (R2):
156 rex_fsge_compatible R2 → (c_reflexive … R2) →
157 R_replace3_rex R1 R2 R1 R2 →
158 ∀T. confluent1 … (rex R1 T) (rex R2 T).
159 #R1 #R2 #H1R #H2R #H3R #T #L1 #L * #f1 #Hf1 #HL1 #L2 * #f2 #Hf2 #HL12
160 lapply (frees_mono … Hf1 … Hf2) -Hf1 #Hf12
161 lapply (sex_eq_repl_back … HL1 … Hf12) -f1 #HL1
162 elim (frees_sex_conf_fsge … Hf2 … HL12) // #g2 #Hg2 #Hfg2
163 lapply (sex_repl … HL1 … HL12 L ?) //
164 [ /3 width=1 by sex_refl, ext2_refl/
165 | -g2 #g2 * #I1 [| #V1 ] #K1 #n #HLK1 #Hgf2 #Z1 #H1 #Z2 #H2 #Y1 #HY1 #Y2 #HY2 #Z #HZ
166 [ lapply (ext2_inv_unit_sn … H1) -H1 #H destruct
167 lapply (ext2_inv_unit_sn … H2) -H2 #H destruct
168 lapply (ext2_inv_unit_sn … HZ) -HZ #H destruct
169 /2 width=1 by ext2_unit/
170 | elim (ext2_inv_pair_sn … H1) -H1 #W1 #HW1 #H destruct
171 elim (ext2_inv_pair_sn … H2) -H2 #W2 #HW2 #H destruct
172 elim (ext2_inv_pair_sn … HZ) -HZ #W #HW #H destruct
173 elim (frees_inv_drops_next … Hf2 … HLK1 … Hgf2) -Hf2 -HLK1 -Hgf2 #g0 #Hg0 #Hg02
174 lapply (sle_sex_trans … HY1 … Hg02) // -HY1 #HY1
175 lapply (sle_sex_trans … HY2 … Hg02) // -HY2 #HY2
176 /4 width=9 by ext2_pair, ex2_intro/
178 | /3 width=5 by sle_sex_trans, ex2_intro/
182 theorem rex_conf (R1) (R2):
183 rex_fsge_compatible R1 → rex_fsge_compatible R2 →
184 R_confluent2_rex R1 R2 R1 R2 →
185 ∀T. confluent2 … (rex R1 T) (rex R2 T).
186 #R1 #R2 #HR1 #HR2 #HR12 #T #L0 #L1 * #f1 #Hf1 #HL01 #L2 * #f #Hf #HL02
187 lapply (frees_mono … Hf1 … Hf) -Hf1 #Hf12
188 lapply (sex_eq_repl_back … HL01 … Hf12) -f1 #HL01
189 elim (sex_conf … HL01 … HL02) /2 width=3 by ex2_intro/ [ | -HL01 -HL02 ]
191 elim (frees_sex_conf_fsge … Hf … HL01) // -HR1 -HL01 #f1 #Hf1 #H1
192 elim (frees_sex_conf_fsge … Hf … HL02) // -HR2 -HL02 #f2 #Hf2 #H2
193 lapply (sle_sex_trans … HL1 … H1) // -HL1 -H1 #HL1
194 lapply (sle_sex_trans … HL2 … H2) // -HL2 -H2 #HL2
195 /3 width=5 by ex2_intro/
196 | #g * #I0 [| #V0 ] #K0 #n #HLK0 #Hgf #Z1 #H1 #Z2 #H2 #K1 #HK01 #K2 #HK02
197 [ lapply (ext2_inv_unit_sn … H1) -H1 #H destruct
198 lapply (ext2_inv_unit_sn … H2) -H2 #H destruct
199 /3 width=3 by ext2_unit, ex2_intro/
200 | elim (ext2_inv_pair_sn … H1) -H1 #V1 #HV01 #H destruct
201 elim (ext2_inv_pair_sn … H2) -H2 #V2 #HV02 #H destruct
202 elim (frees_inv_drops_next … Hf … HLK0 … Hgf) -Hf -HLK0 -Hgf #g0 #Hg0 #H0
203 lapply (sle_sex_trans … HK01 … H0) // -HK01 #HK01
204 lapply (sle_sex_trans … HK02 … H0) // -HK02 #HK02
205 elim (HR12 … HV01 … HV02 K1 … K2) /3 width=3 by ext2_pair, ex2_intro/
210 theorem rex_trans_fsle (R1) (R2) (R3):
211 rex_fsle_compatible R1 → f_transitive_next R1 R2 R3 →
212 ∀L1,L,T. L1 ⪤[R1,T] L → ∀L2. L ⪤[R2,T] L2 → L1 ⪤[R3,T] L2.
213 #R1 #R2 #R3 #H1R #H2R #L1 #L #T #H
214 lapply (H1R … H) -H1R #H0
215 cases H -H #f1 #Hf1 #HL1 #L2 * #f2 #Hf2 #HL2
216 lapply (fsle_inv_frees_eq … H0 … Hf1 … Hf2) -H0 -Hf2
217 /4 width=14 by sex_trans_gen, sex_fwd_length, sle_sex_trans, ex2_intro/