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 "basic_2/relocation/lexs_length.ma".
16 include "basic_2/relocation/lexs_lexs.ma".
17 include "basic_2/static/frees_drops.ma".
18 include "basic_2/static/fsle_fsle.ma".
19 include "basic_2/static/lfxs_fsle.ma".
21 (* GENERIC EXTENSION ON REFERRED ENTRIES OF A CONTEXT-SENSITIVE REALTION ****)
23 (* Advanced inversion lemmas ************************************************)
25 lemma lfxs_inv_frees: ∀R,L1,L2,T. L1 ⪤*[R, T] L2 →
26 ∀f. L1 ⊢ 𝐅*⦃T⦄ ≡ f → L1 ⪤*[cext2 R, cfull, f] L2.
27 #R #L1 #L2 #T * /3 width=6 by frees_mono, lexs_eq_repl_back/
30 lemma frees_lexs_conf: ∀R. lfxs_fsle_compatible R →
31 ∀L1,T,f1. L1 ⊢ 𝐅*⦃T⦄ ≡ f1 →
32 ∀L2. L1 ⪤*[cext2 R, cfull, f1] L2 →
33 ∃∃f2. L2 ⊢ 𝐅*⦃T⦄ ≡ f2 & f2 ⊆ f1.
34 #R #HR #L1 #T #f1 #Hf1 #L2 #H1L
35 lapply (HR L1 L2 T ?) /2 width=3 by ex2_intro/ #H2L
36 @(fsle_frees_trans_eq … H2L … Hf1) /3 width=4 by lexs_fwd_length, sym_eq/
39 (* Properties with free variables inclusion for restricted closures *********)
41 (* Note: we just need lveq_inv_refl: ∀L,n1,n2. L ≋ⓧ*[n1, n2] L → ∧∧ 0 = n1 & 0 = n2 *)
42 lemma fle_lfxs_trans: ∀R,L1,T1,T2. ⦃L1, T1⦄ ⊆ ⦃L1, T2⦄ →
43 ∀L2. L1 ⪤*[R, T2] L2 → L1 ⪤*[R, T1] L2.
44 #R #L1 #T1 #T2 * #n1 #n2 #f1 #f2 #Hf1 #Hf2 #Hn #Hf #L2 #HL12
45 elim (lveq_inj_length … Hn ?) // #H1 #H2 destruct
46 /4 width=5 by lfxs_inv_frees, sle_lexs_trans, ex2_intro/
49 (* Advanced properties ******************************************************)
51 lemma lfxs_sym: ∀R. lfxs_fsle_compatible R →
52 (∀L1,L2,T1,T2. R L1 T1 T2 → R L2 T2 T1) →
53 ∀T. symmetric … (lfxs R T).
54 #R #H1R #H2R #T #L1 #L2
56 elim (frees_lexs_conf … Hf1 … HL12) -Hf1 //
57 /5 width=5 by sle_lexs_trans, lexs_sym, cext2_sym, ex2_intro/
60 (* Basic_2A1: uses: llpx_sn_dec *)
61 lemma lfxs_dec: ∀R. (∀L,T1,T2. Decidable (R L T1 T2)) →
62 ∀L1,L2,T. Decidable (L1 ⪤*[R, T] L2).
64 elim (frees_total L1 T) #f #Hf
65 elim (lexs_dec (cext2 R) cfull … L1 L2 f)
66 /4 width=3 by lfxs_inv_frees, cfull_dec, ext2_dec, ex2_intro, or_intror, or_introl/
69 lemma lfxs_pair_sn_split: ∀R1,R2. (∀L. reflexive … (R1 L)) → (∀L. reflexive … (R2 L)) →
70 lfxs_fsle_compatible R1 →
71 ∀L1,L2,V. L1 ⪤*[R1, V] L2 → ∀I,T.
72 ∃∃L. L1 ⪤*[R1, ②{I}V.T] L & L ⪤*[R2, V] L2.
73 #R1 #R2 #HR1 #HR2 #HR #L1 #L2 #V * #f #Hf #HL12 * [ #p ] #I #T
74 [ elim (frees_total L1 (ⓑ{p,I}V.T)) #g #Hg
75 elim (frees_inv_bind … Hg) #y1 #y2 #H #_ #Hy
76 | elim (frees_total L1 (ⓕ{I}V.T)) #g #Hg
77 elim (frees_inv_flat … Hg) #y1 #y2 #H #_ #Hy
79 lapply(frees_mono … H … Hf) -H #H1
80 lapply (sor_eq_repl_back1 … Hy … H1) -y1 #Hy
81 lapply (sor_inv_sle_sn … Hy) -y2 #Hfg
82 elim (lexs_sle_split (cext2 R1) (cext2 R2) … HL12 … Hfg) -HL12 /2 width=1 by ext2_refl/ #L #HL1 #HL2
83 lapply (sle_lexs_trans … HL1 … Hfg) // #H
84 elim (frees_lexs_conf … Hf … H) -Hf -H
85 /4 width=7 by sle_lexs_trans, ex2_intro/
88 lemma lfxs_flat_dx_split: ∀R1,R2. (∀L. reflexive … (R1 L)) → (∀L. reflexive … (R2 L)) →
89 lfxs_fsle_compatible R1 →
90 ∀L1,L2,T. L1 ⪤*[R1, T] L2 → ∀I,V.
91 ∃∃L. L1 ⪤*[R1, ⓕ{I}V.T] L & L ⪤*[R2, T] L2.
92 #R1 #R2 #HR1 #HR2 #HR #L1 #L2 #T * #f #Hf #HL12 #I #V
93 elim (frees_total L1 (ⓕ{I}V.T)) #g #Hg
94 elim (frees_inv_flat … Hg) #y1 #y2 #_ #H #Hy
95 lapply(frees_mono … H … Hf) -H #H2
96 lapply (sor_eq_repl_back2 … Hy … H2) -y2 #Hy
97 lapply (sor_inv_sle_dx … Hy) -y1 #Hfg
98 elim (lexs_sle_split (cext2 R1) (cext2 R2) … HL12 … Hfg) -HL12 /2 width=1 by ext2_refl/ #L #HL1 #HL2
99 lapply (sle_lexs_trans … HL1 … Hfg) // #H
100 elim (frees_lexs_conf … Hf … H) -Hf -H
101 /4 width=7 by sle_lexs_trans, ex2_intro/
104 lemma lfxs_bind_dx_split: ∀R1,R2. (∀L. reflexive … (R1 L)) → (∀L. reflexive … (R2 L)) →
105 lfxs_fsle_compatible R1 →
106 ∀I,L1,L2,V1,T. L1.ⓑ{I}V1 ⪤*[R1, T] L2 → ∀p.
107 ∃∃L,V. L1 ⪤*[R1, ⓑ{p,I}V1.T] L & L.ⓑ{I}V ⪤*[R2, T] L2 & R1 L1 V1 V.
108 #R1 #R2 #HR1 #HR2 #HR #I #L1 #L2 #V1 #T * #f #Hf #HL12 #p
109 elim (frees_total L1 (ⓑ{p,I}V1.T)) #g #Hg
110 elim (frees_inv_bind … Hg) #y1 #y2 #_ #H #Hy
111 lapply(frees_mono … H … Hf) -H #H2
112 lapply (tl_eq_repl … H2) -H2 #H2
113 lapply (sor_eq_repl_back2 … Hy … H2) -y2 #Hy
114 lapply (sor_inv_sle_dx … Hy) -y1 #Hfg
115 lapply (sle_inv_tl_sn … Hfg) -Hfg #Hfg
116 elim (lexs_sle_split (cext2 R1) (cext2 R2) … HL12 … Hfg) -HL12 /2 width=1 by ext2_refl/ #Y #H #HL2
117 lapply (sle_lexs_trans … H … Hfg) // #H0
118 elim (lexs_inv_next1 … H) -H #Z #L #HL1 #H
119 elim (ext2_inv_pair_sn … H) -H #V #HV #H1 #H2 destruct
120 elim (frees_lexs_conf … Hf … H0) -Hf -H0
121 /4 width=7 by sle_lexs_trans, ex3_2_intro, ex2_intro/
124 lemma lfxs_bind_dx_split_void: ∀R1,R2. (∀L. reflexive … (R1 L)) → (∀L. reflexive … (R2 L)) →
125 lfxs_fsle_compatible R1 →
126 ∀L1,L2,T. L1.ⓧ ⪤*[R1, T] L2 → ∀p,I,V.
127 ∃∃L. L1 ⪤*[R1, ⓑ{p,I}V.T] L & L.ⓧ ⪤*[R2, T] L2.
128 #R1 #R2 #HR1 #HR2 #HR #L1 #L2 #T * #f #Hf #HL12 #p #I #V
129 elim (frees_total L1 (ⓑ{p,I}V.T)) #g #Hg
130 elim (frees_inv_bind_void … Hg) #y1 #y2 #_ #H #Hy
131 lapply(frees_mono … H … Hf) -H #H2
132 lapply (tl_eq_repl … H2) -H2 #H2
133 lapply (sor_eq_repl_back2 … Hy … H2) -y2 #Hy
134 lapply (sor_inv_sle_dx … Hy) -y1 #Hfg
135 lapply (sle_inv_tl_sn … Hfg) -Hfg #Hfg
136 elim (lexs_sle_split (cext2 R1) (cext2 R2) … HL12 … Hfg) -HL12 /2 width=1 by ext2_refl/ #Y #H #HL2
137 lapply (sle_lexs_trans … H … Hfg) // #H0
138 elim (lexs_inv_next1 … H) -H #Z #L #HL1 #H
139 elim (ext2_inv_unit_sn … H) -H #H destruct
140 elim (frees_lexs_conf … Hf … H0) -Hf -H0
141 /4 width=7 by sle_lexs_trans, ex2_intro/ (* note: 2 ex2_intro *)
144 (* Main properties **********************************************************)
146 (* Basic_2A1: uses: llpx_sn_bind llpx_sn_bind_O *)
147 theorem lfxs_bind: ∀R,p,I,L1,L2,V1,V2,T.
148 L1 ⪤*[R, V1] L2 → L1.ⓑ{I}V1 ⪤*[R, T] L2.ⓑ{I}V2 →
149 L1 ⪤*[R, ⓑ{p,I}V1.T] L2.
150 #R #p #I #L1 #L2 #V1 #V2 #T * #f1 #HV #Hf1 * #f2 #HT #Hf2
151 lapply (lexs_fwd_bind … Hf2) -Hf2 #Hf2 elim (sor_isfin_ex f1 (⫱f2))
152 /3 width=7 by frees_fwd_isfin, frees_bind, lexs_join, isfin_tl, ex2_intro/
155 (* Basic_2A1: llpx_sn_flat *)
156 theorem lfxs_flat: ∀R,I,L1,L2,V,T.
157 L1 ⪤*[R, V] L2 → L1 ⪤*[R, T] L2 →
158 L1 ⪤*[R, ⓕ{I}V.T] L2.
159 #R #I #L1 #L2 #V #T * #f1 #HV #Hf1 * #f2 #HT #Hf2 elim (sor_isfin_ex f1 f2)
160 /3 width=7 by frees_fwd_isfin, frees_flat, lexs_join, ex2_intro/
163 theorem lfxs_bind_void: ∀R,p,I,L1,L2,V,T.
164 L1 ⪤*[R, V] L2 → L1.ⓧ ⪤*[R, T] L2.ⓧ →
165 L1 ⪤*[R, ⓑ{p,I}V.T] L2.
166 #R #p #I #L1 #L2 #V #T * #f1 #HV #Hf1 * #f2 #HT #Hf2
167 lapply (lexs_fwd_bind … Hf2) -Hf2 #Hf2 elim (sor_isfin_ex f1 (⫱f2))
168 /3 width=7 by frees_fwd_isfin, frees_bind_void, lexs_join, isfin_tl, ex2_intro/
171 theorem lfxs_conf: ∀R1,R2.
172 lfxs_fsle_compatible R1 →
173 lfxs_fsle_compatible R2 →
174 R_confluent2_lfxs R1 R2 R1 R2 →
175 ∀T. confluent2 … (lfxs R1 T) (lfxs R2 T).
176 #R1 #R2 #HR1 #HR2 #HR12 #T #L0 #L1 * #f1 #Hf1 #HL01 #L2 * #f #Hf #HL02
177 lapply (frees_mono … Hf1 … Hf) -Hf1 #Hf12
178 lapply (lexs_eq_repl_back … HL01 … Hf12) -f1 #HL01
179 elim (lexs_conf … HL01 … HL02) /2 width=3 by ex2_intro/ [ | -HL01 -HL02 ]
181 elim (frees_lexs_conf … Hf … HL01) // -HR1 -HL01 #f1 #Hf1 #H1
182 elim (frees_lexs_conf … Hf … HL02) // -HR2 -HL02 #f2 #Hf2 #H2
183 lapply (sle_lexs_trans … HL1 … H1) // -HL1 -H1 #HL1
184 lapply (sle_lexs_trans … HL2 … H2) // -HL2 -H2 #HL2
185 /3 width=5 by ex2_intro/
186 | #g * #I0 [2: #V0 ] #K0 #n #HLK0 #Hgf #Z1 #H1 #Z2 #H2 #K1 #HK01 #K2 #HK02
187 [ elim (ext2_inv_pair_sn … H1) -H1 #V1 #HV01 #H destruct
188 elim (ext2_inv_pair_sn … H2) -H2 #V2 #HV02 #H destruct
189 elim (frees_inv_drops_next … Hf … HLK0 … Hgf) -Hf -HLK0 -Hgf #g0 #Hg0 #H0
190 lapply (sle_lexs_trans … HK01 … H0) // -HK01 #HK01
191 lapply (sle_lexs_trans … HK02 … H0) // -HK02 #HK02
192 elim (HR12 … HV01 … HV02 K1 … K2) /3 width=3 by ext2_pair, ex2_intro/
193 | lapply (ext2_inv_unit_sn … H1) -H1 #H destruct
194 lapply (ext2_inv_unit_sn … H2) -H2 #H destruct
195 /3 width=3 by ext2_unit, ex2_intro/
200 theorem lfxs_trans_gen: ∀R1,R2,R3.
201 c_reflexive … R1 → c_reflexive … R2 →
202 lfxs_confluent R1 R2 → lfxs_transitive R1 R2 R3 →
203 ∀L1,T,L. L1 ⪤*[R1, T] L →
204 ∀L2. L ⪤*[R2, T] L2 → L1 ⪤*[R3, T] L2.
205 #R1 #R2 #R3 #H1R #H2R #H3R #H4R #L1 #T @(fqup_wf_ind_eq (Ⓣ) … (⋆) L1 T) -L1 -T
206 #G0 #L0 #T0 #IH #G #L1 * *
207 [ #s #HG #HL #HT #L #H1 #L2 #H2 destruct
208 elim (lfxs_inv_sort … H1) -H1 *
210 >(lfxs_inv_atom_sn … H2) -L2 //
211 | #I1 #I #K1 #K #HK1 #H1 #H0 destruct
212 elim (lfxs_inv_sort_bind_sn … H2) -H2 #I2 #K2 #HK2 #H destruct
213 /4 width=3 by lfxs_sort, fqu_fqup/
215 | * [ | #i ] #HG #HL #HT #L #H1 #L2 #H2 destruct
216 [ elim (lfxs_inv_zero … H1) -H1 *
218 >(lfxs_inv_atom_sn … H2) -L2 //
219 | #I #K1 #K #V1 #V #HK1 #H1 #H0 #H destruct
220 elim (lfxs_inv_zero_pair_sn … H2) -H2 #K2 #V2 #HK2 #HV2 #H destruct
221 /4 width=7 by lfxs_pair, fqu_fqup, fqu_lref_O/
222 | #f1 #I #K1 #K #Hf1 #HK1 #H1 #H0 destruct
223 elim (lfxs_inv_zero_unit_sn … H2) -H2 #f2 #K2 #Hf2 #HK2 #H destruct
224 /5 width=8 by lfxs_unit, lexs_trans_id_cfull, lexs_eq_repl_back, isid_inv_eq_repl/
226 | elim (lfxs_inv_lref … H1) -H1 *
228 >(lfxs_inv_atom_sn … H2) -L2 //
229 | #I1 #I #K1 #K #HK1 #H1 #H0 destruct
230 elim (lfxs_inv_lref_bind_sn … H2) -H2 #I2 #K2 #HK2 #H destruct
231 /4 width=3 by lfxs_lref, fqu_fqup/
234 | #l #HG #HL #HT #L #H1 #L2 #H2 destruct
235 elim (lfxs_inv_gref … H1) -H1 *
237 >(lfxs_inv_atom_sn … H2) -L2 //
238 | #I1 #I #K1 #K #HK1 #H1 #H0 destruct
239 elim (lfxs_inv_gref_bind_sn … H2) -H2 #I2 #K2 #HK2 #H destruct
240 /4 width=3 by lfxs_gref, fqu_fqup/
242 | #p #I #V1 #T1 #HG #HL #HT #L #H1 #L2 #H2 destruct
243 elim (lfxs_inv_bind … V1 V1 … H1) -H1 // #H1V #H1T
244 elim (lfxs_inv_bind … V1 V1 … H2) -H2 // #H2V #H2T
245 /3 width=4 by lfxs_bind/
246 | #I #V1 #T1 #HG #HL #HT #L #H1 #L2 #H2 destruct
247 elim (lfxs_inv_flat … H1) -H1 #H1V #H1T
248 elim (lfxs_inv_flat … H2) -H2 #H2V #H2T
249 /3 width=3 by lfxs_flat/
253 (* Negated inversion lemmas *************************************************)
255 (* Basic_2A1: uses: nllpx_sn_inv_bind nllpx_sn_inv_bind_O *)
256 lemma lfnxs_inv_bind: ∀R. (∀L,T1,T2. Decidable (R L T1 T2)) →
257 ∀p,I,L1,L2,V,T. (L1 ⪤*[R, ⓑ{p,I}V.T] L2 → ⊥) →
258 (L1 ⪤*[R, V] L2 → ⊥) ∨ (L1.ⓑ{I}V ⪤*[R, T] L2.ⓑ{I}V → ⊥).
259 #R #HR #p #I #L1 #L2 #V #T #H elim (lfxs_dec … HR L1 L2 V)
260 /4 width=2 by lfxs_bind, or_intror, or_introl/
263 (* Basic_2A1: uses: nllpx_sn_inv_flat *)
264 lemma lfnxs_inv_flat: ∀R. (∀L,T1,T2. Decidable (R L T1 T2)) →
265 ∀I,L1,L2,V,T. (L1 ⪤*[R, ⓕ{I}V.T] L2 → ⊥) →
266 (L1 ⪤*[R, V] L2 → ⊥) ∨ (L1 ⪤*[R, T] L2 → ⊥).
267 #R #HR #I #L1 #L2 #V #T #H elim (lfxs_dec … HR L1 L2 V)
268 /4 width=1 by lfxs_flat, or_intror, or_introl/
271 lemma lfnxs_inv_bind_void: ∀R. (∀L,T1,T2. Decidable (R L T1 T2)) →
272 ∀p,I,L1,L2,V,T. (L1 ⪤*[R, ⓑ{p,I}V.T] L2 → ⊥) →
273 (L1 ⪤*[R, V] L2 → ⊥) ∨ (L1.ⓧ ⪤*[R, T] L2.ⓧ → ⊥).
274 #R #HR #p #I #L1 #L2 #V #T #H elim (lfxs_dec … HR L1 L2 V)
275 /4 width=2 by lfxs_bind_void, or_intror, or_introl/