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/notation/relations/lazyeqsn_5.ma".
16 include "basic_2/syntax/tdeq_ext.ma".
17 include "basic_2/static/lfxs.ma".
19 (* DEGREE-BASED EQUIVALENCE FOR LOCAL ENVIRONMENTS ON REFERRED ENTRIES ******)
21 definition lfdeq: ∀h. sd h → relation3 term lenv lenv ≝
22 λh,o. lfxs (cdeq h o).
25 "degree-based equivalence on referred entries (local environment)"
26 'LazyEqSn h o T L1 L2 = (lfdeq h o T L1 L2).
29 "degree-based ranged equivalence (local environment)"
30 'LazyEqSn h o f L1 L2 = (lexs (cdeq_ext h o) cfull f L1 L2).
32 definition lfdeq_transitive: predicate (relation3 lenv term term) ≝
33 λR. ∀L2,T1,T2. R L2 T1 T2 → ∀L1. L1 ≡[h, o, T1] L2 → R L1 T1 T2.
35 (* Basic properties ***********************************************************)
37 lemma frees_tdeq_conf_lexs: ∀h,o,f,L1,T1. L1 ⊢ 𝐅*⦃T1⦄ ≡ f → ∀T2. T1 ≡[h, o] T2 →
38 ∀L2. L1 ≡[h, o, f] L2 → L2 ⊢ 𝐅*⦃T2⦄ ≡ f.
39 #h #o #f #L1 #T1 #H elim H -f -L1 -T1
40 [ #f #L1 #s1 #Hf #X #H1 #L2 #_
41 elim (tdeq_inv_sort1 … H1) -H1 #s2 #d #_ #_ #H destruct
42 /2 width=3 by frees_sort/
44 >(tdeq_inv_lref1 … H1) -X #Y #H2
45 >(lexs_inv_atom1 … H2) -Y
46 /2 width=1 by frees_atom/
47 | #f #I #L1 #V1 #_ #IH #X #H1
48 >(tdeq_inv_lref1 … H1) -X #Y #H2
49 elim (lexs_inv_next1 … H2) -H2 #Z #L2 #HL12 #HZ #H destruct
50 elim (ext2_inv_pair_sn … HZ) -HZ #V2 #HV12 #H destruct
51 /3 width=1 by frees_pair/
52 | #f #I #L1 #Hf #X #H1
53 >(tdeq_inv_lref1 … H1) -X #Y #H2
54 elim (lexs_inv_next1 … H2) -H2 #Z #L2 #_ #HZ #H destruct
55 >(ext2_inv_unit_sn … HZ) -Z /2 width=1 by frees_unit/
56 | #f #I #L1 #i #_ #IH #X #H1
57 >(tdeq_inv_lref1 … H1) -X #Y #H2
58 elim (lexs_inv_push1 … H2) -H2 #J #L2 #HL12 #_ #H destruct
59 /3 width=1 by frees_lref/
60 | #f #L1 #l #Hf #X #H1 #L2 #_
61 >(tdeq_inv_gref1 … H1) -X /2 width=1 by frees_gref/
62 | #f1V #f1T #f1 #p #I #L1 #V1 #T1 #_ #_ #Hf1 #IHV #IHT #X #H1
63 elim (tdeq_inv_pair1 … H1) -H1 #V2 #T2 #HV12 #HT12 #H1 #L2 #HL12 destruct
64 /6 width=5 by frees_bind, lexs_inv_tl, ext2_pair, sle_lexs_trans, sor_inv_sle_dx, sor_inv_sle_sn/
65 | #f1V #f1T #f1 #I #L1 #V1 #T1 #_ #_ #Hf1 #IHV #IHT #X #H1
66 elim (tdeq_inv_pair1 … H1) -H1 #V2 #T2 #HV12 #HT12 #H1 #L2 #HL12 destruct
67 /5 width=5 by frees_flat, sle_lexs_trans, sor_inv_sle_dx, sor_inv_sle_sn/
71 lemma frees_tdeq_conf: ∀h,o,f,L,T1. L ⊢ 𝐅*⦃T1⦄ ≡ f →
72 ∀T2. T1 ≡[h, o] T2 → L ⊢ 𝐅*⦃T2⦄ ≡ f.
73 /4 width=7 by frees_tdeq_conf_lexs, lexs_refl, ext2_refl/ qed-.
75 lemma frees_lexs_conf: ∀h,o,f,L1,T. L1 ⊢ 𝐅*⦃T⦄ ≡ f →
76 ∀L2. L1 ≡[h, o, f] L2 → L2 ⊢ 𝐅*⦃T⦄ ≡ f.
77 /2 width=7 by frees_tdeq_conf_lexs, tdeq_refl/ qed-.
79 lemma frees_lfdeq_conf_lexs: ∀h,o. lexs_frees_confluent (cdeq_ext h o) cfull.
80 /3 width=7 by frees_tdeq_conf_lexs, ex2_intro/ qed-.
82 lemma tdeq_lfdeq_conf_sn: ∀h,o. s_r_confluent1 … (cdeq h o) (lfdeq h o).
83 #h #o #L1 #T1 #T2 #HT12 #L2 *
84 /3 width=5 by frees_tdeq_conf, ex2_intro/
87 (* Basic_2A1: uses: lleq_sym *)
88 lemma lfdeq_sym: ∀h,o,T. symmetric … (lfdeq h o T).
90 /4 width=7 by frees_tdeq_conf_lexs, lfxs_sym, tdeq_sym, ex2_intro/
93 lemma lfdeq_atom: ∀h,o,I. ⋆ ≡[h, o, ⓪{I}] ⋆.
94 /2 width=1 by lfxs_atom/ qed.
96 (* Basic_2A1: uses: lleq_sort *)
97 lemma lfdeq_sort: ∀h,o,I1,I2,L1,L2,s.
98 L1 ≡[h, o, ⋆s] L2 → L1.ⓘ{I1} ≡[h, o, ⋆s] L2.ⓘ{I2}.
99 /2 width=1 by lfxs_sort/ qed.
101 lemma lfdeq_pair: ∀h,o,I,L1,L2,V1,V2. L1 ≡[h, o, V1] L2 → V1 ≡[h, o] V2 →
102 L1.ⓑ{I}V1 ≡[h, o, #0] L2.ⓑ{I}V2.
103 /2 width=1 by lfxs_pair/ qed.
105 lemma lfdeq_unit: ∀h,o,f,I,L1,L2. 𝐈⦃f⦄ → L1 ⪤*[cdeq_ext h o, cfull, f] L2 →
106 L1.ⓤ{I} ≡[h, o, #0] L2.ⓤ{I}.
107 /2 width=3 by lfxs_unit/ qed.
109 lemma lfdeq_lref: ∀h,o,I1,I2,L1,L2,i.
110 L1 ≡[h, o, #i] L2 → L1.ⓘ{I1} ≡[h, o, #⫯i] L2.ⓘ{I2}.
111 /2 width=1 by lfxs_lref/ qed.
113 (* Basic_2A1: uses: lleq_gref *)
114 lemma lfdeq_gref: ∀h,o,I1,I2,L1,L2,l.
115 L1 ≡[h, o, §l] L2 → L1.ⓘ{I1} ≡[h, o, §l] L2.ⓘ{I2}.
116 /2 width=1 by lfxs_gref/ qed.
118 lemma lfdeq_bind_repl_dx: ∀h,o,I,I1,L1,L2.∀T:term.
119 L1.ⓘ{I} ≡[h, o, T] L2.ⓘ{I1} →
121 L1.ⓘ{I} ≡[h, o, T] L2.ⓘ{I2}.
122 /2 width=2 by lfxs_bind_repl_dx/ qed-.
124 (* Basic inversion lemmas ***************************************************)
126 lemma lfdeq_inv_atom_sn: ∀h,o,Y2. ∀T:term. ⋆ ≡[h, o, T] Y2 → Y2 = ⋆.
127 /2 width=3 by lfxs_inv_atom_sn/ qed-.
129 lemma lfdeq_inv_atom_dx: ∀h,o,Y1. ∀T:term. Y1 ≡[h, o, T] ⋆ → Y1 = ⋆.
130 /2 width=3 by lfxs_inv_atom_dx/ qed-.
132 lemma lfdeq_inv_zero: ∀h,o,Y1,Y2. Y1 ≡[h, o, #0] Y2 →
134 | ∃∃I,L1,L2,V1,V2. L1 ≡[h, o, V1] L2 & V1 ≡[h, o] V2 &
135 Y1 = L1.ⓑ{I}V1 & Y2 = L2.ⓑ{I}V2
136 | ∃∃f,I,L1,L2. 𝐈⦃f⦄ & L1 ⪤*[cdeq_ext h o, cfull, f] L2 &
137 Y1 = L1.ⓤ{I} & Y2 = L2.ⓤ{I}.
138 #h #o #Y1 #Y2 #H elim (lfxs_inv_zero … H) -H *
139 /3 width=9 by or3_intro0, or3_intro1, or3_intro2, ex4_5_intro, ex4_4_intro, conj/
142 lemma lfdeq_inv_lref: ∀h,o,Y1,Y2,i. Y1 ≡[h, o, #⫯i] Y2 →
144 ∃∃I1,I2,L1,L2. L1 ≡[h, o, #i] L2 &
145 Y1 = L1.ⓘ{I1} & Y2 = L2.ⓘ{I2}.
146 /2 width=1 by lfxs_inv_lref/ qed-.
148 (* Basic_2A1: uses: lleq_inv_bind lleq_inv_bind_O *)
149 lemma lfdeq_inv_bind: ∀h,o,p,I,L1,L2,V,T. L1 ≡[h, o, ⓑ{p,I}V.T] L2 →
150 L1 ≡[h, o, V] L2 ∧ L1.ⓑ{I}V ≡[h, o, T] L2.ⓑ{I}V.
151 /2 width=2 by lfxs_inv_bind/ qed-.
153 (* Basic_2A1: uses: lleq_inv_flat *)
154 lemma lfdeq_inv_flat: ∀h,o,I,L1,L2,V,T. L1 ≡[h, o, ⓕ{I}V.T] L2 →
155 L1 ≡[h, o, V] L2 ∧ L1 ≡[h, o, T] L2.
156 /2 width=2 by lfxs_inv_flat/ qed-.
158 (* Advanced inversion lemmas ************************************************)
160 lemma lfdeq_inv_zero_pair_sn: ∀h,o,I,Y2,L1,V1. L1.ⓑ{I}V1 ≡[h, o, #0] Y2 →
161 ∃∃L2,V2. L1 ≡[h, o, V1] L2 & V1 ≡[h, o] V2 & Y2 = L2.ⓑ{I}V2.
162 /2 width=1 by lfxs_inv_zero_pair_sn/ qed-.
164 lemma lfdeq_inv_zero_pair_dx: ∀h,o,I,Y1,L2,V2. Y1 ≡[h, o, #0] L2.ⓑ{I}V2 →
165 ∃∃L1,V1. L1 ≡[h, o, V1] L2 & V1 ≡[h, o] V2 & Y1 = L1.ⓑ{I}V1.
166 /2 width=1 by lfxs_inv_zero_pair_dx/ qed-.
168 lemma lfdeq_inv_lref_bind_sn: ∀h,o,I1,Y2,L1,i. L1.ⓘ{I1} ≡[h, o, #⫯i] Y2 →
169 ∃∃I2,L2. L1 ≡[h, o, #i] L2 & Y2 = L2.ⓘ{I2}.
170 /2 width=2 by lfxs_inv_lref_bind_sn/ qed-.
172 lemma lfdeq_inv_lref_bind_dx: ∀h,o,I2,Y1,L2,i. Y1 ≡[h, o, #⫯i] L2.ⓘ{I2} →
173 ∃∃I1,L1. L1 ≡[h, o, #i] L2 & Y1 = L1.ⓘ{I1}.
174 /2 width=2 by lfxs_inv_lref_bind_dx/ qed-.
176 (* Basic forward lemmas *****************************************************)
178 lemma lfdeq_fwd_zero_pair: ∀h,o,I,K1,K2,V1,V2.
179 K1.ⓑ{I}V1 ≡[h, o, #0] K2.ⓑ{I}V2 → K1 ≡[h, o, V1] K2.
180 /2 width=3 by lfxs_fwd_zero_pair/ qed-.
182 (* Basic_2A1: uses: lleq_fwd_bind_sn lleq_fwd_flat_sn *)
183 lemma lfdeq_fwd_pair_sn: ∀h,o,I,L1,L2,V,T. L1 ≡[h, o, ②{I}V.T] L2 → L1 ≡[h, o, V] L2.
184 /2 width=3 by lfxs_fwd_pair_sn/ qed-.
186 (* Basic_2A1: uses: lleq_fwd_bind_dx lleq_fwd_bind_O_dx *)
187 lemma lfdeq_fwd_bind_dx: ∀h,o,p,I,L1,L2,V,T.
188 L1 ≡[h, o, ⓑ{p,I}V.T] L2 → L1.ⓑ{I}V ≡[h, o, T] L2.ⓑ{I}V.
189 /2 width=2 by lfxs_fwd_bind_dx/ qed-.
191 (* Basic_2A1: uses: lleq_fwd_flat_dx *)
192 lemma lfdeq_fwd_flat_dx: ∀h,o,I,L1,L2,V,T. L1 ≡[h, o, ⓕ{I}V.T] L2 → L1 ≡[h, o, T] L2.
193 /2 width=3 by lfxs_fwd_flat_dx/ qed-.
195 lemma lfdeq_fwd_dx: ∀h,o,I2,L1,K2. ∀T:term. L1 ≡[h, o, T] K2.ⓘ{I2} →
196 ∃∃I1,K1. L1 = K1.ⓘ{I1}.
197 /2 width=5 by lfxs_fwd_dx/ qed-.
199 (* Basic_2A1: removed theorems 10:
200 lleq_ind lleq_fwd_lref
201 lleq_fwd_drop_sn lleq_fwd_drop_dx
202 lleq_skip lleq_lref lleq_free
203 lleq_Y lleq_ge_up lleq_ge