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/lazyeq_4.ma".
16 include "basic_2/substitution/llpx_sn.ma".
18 (* LAZY EQUIVALENCE FOR LOCAL ENVIRONMENTS **********************************)
20 definition ceq: relation4 bind2 lenv term term ≝ λI,L,T1,T2. T1 = T2.
22 definition lleq: relation4 ynat term lenv lenv ≝ llpx_sn ceq.
25 "lazy equivalence (local environment)"
26 'LazyEq T d L1 L2 = (lleq d T L1 L2).
28 definition lleq_transitive: predicate (relation4 bind2 lenv term term) ≝
29 λR. ∀I,L2,T1,T2. R I L2 T1 T2 → ∀L1. L1 ≡[T1, 0] L2 → R I L1 T1 T2.
31 (* Basic inversion lemmas ***************************************************)
33 lemma lleq_ind: ∀R:relation4 ynat term lenv lenv. (
34 ∀L1,L2,d,k. |L1| = |L2| → R d (⋆k) L1 L2
36 ∀L1,L2,d,i. |L1| = |L2| → yinj i < d → R d (#i) L1 L2
38 ∀I,L1,L2,K1,K2,V,d,i. d ≤ yinj i →
39 ⇩[i] L1 ≡ K1.ⓑ{I}V → ⇩[i] L2 ≡ K2.ⓑ{I}V →
40 K1 ≡[V, yinj O] K2 → R (yinj O) V K1 K2 → R d (#i) L1 L2
42 ∀L1,L2,d,i. |L1| = |L2| → |L1| ≤ i → |L2| ≤ i → R d (#i) L1 L2
44 ∀L1,L2,d,p. |L1| = |L2| → R d (§p) L1 L2
47 L1 ≡[V, d]L2 → L1.ⓑ{I}V ≡[T, ⫯d] L2.ⓑ{I}V →
48 R d V L1 L2 → R (⫯d) T (L1.ⓑ{I}V) (L2.ⓑ{I}V) → R d (ⓑ{a,I}V.T) L1 L2
51 L1 ≡[V, d]L2 → L1 ≡[T, d] L2 →
52 R d V L1 L2 → R d T L1 L2 → R d (ⓕ{I}V.T) L1 L2
54 ∀d,T,L1,L2. L1 ≡[T, d] L2 → R d T L1 L2.
55 #R #H1 #H2 #H3 #H4 #H5 #H6 #H7 #d #T #L1 #L2 #H elim H -L1 -L2 -T -d /2 width=8 by/
58 lemma lleq_inv_bind: ∀a,I,L1,L2,V,T,d. L1 ≡[ⓑ{a,I}V.T, d] L2 →
59 L1 ≡[V, d] L2 ∧ L1.ⓑ{I}V ≡[T, ⫯d] L2.ⓑ{I}V.
60 /2 width=2 by llpx_sn_inv_bind/ qed-.
62 lemma lleq_inv_flat: ∀I,L1,L2,V,T,d. L1 ≡[ⓕ{I}V.T, d] L2 →
63 L1 ≡[V, d] L2 ∧ L1 ≡[T, d] L2.
64 /2 width=2 by llpx_sn_inv_flat/ qed-.
66 (* Basic forward lemmas *****************************************************)
68 lemma lleq_fwd_length: ∀L1,L2,T,d. L1 ≡[T, d] L2 → |L1| = |L2|.
69 /2 width=4 by llpx_sn_fwd_length/ qed-.
71 lemma lleq_fwd_lref: ∀L1,L2,d,i. L1 ≡[#i, d] L2 →
72 ∨∨ |L1| ≤ i ∧ |L2| ≤ i
74 | ∃∃I,K1,K2,V. ⇩[i] L1 ≡ K1.ⓑ{I}V &
76 K1 ≡[V, yinj 0] K2 & d ≤ yinj i.
77 #L1 #L2 #d #i #H elim (llpx_sn_fwd_lref … H) /2 width=1/
78 * /3 width=7 by or3_intro2, ex4_4_intro/
81 lemma lleq_fwd_ldrop_sn: ∀L1,L2,T,d. L1 ≡[d, T] L2 → ∀K1,i. ⇩[i] L1 ≡ K1 →
83 /2 width=7 by llpx_sn_fwd_ldrop_sn/ qed-.
85 lemma lleq_fwd_ldrop_dx: ∀L1,L2,T,d. L1 ≡[d, T] L2 → ∀K2,i. ⇩[i] L2 ≡ K2 →
87 /2 width=7 by llpx_sn_fwd_ldrop_dx/ qed-.
89 lemma lleq_fwd_bind_sn: ∀a,I,L1,L2,V,T,d.
90 L1 ≡[ⓑ{a,I}V.T, d] L2 → L1 ≡[V, d] L2.
91 /2 width=4 by llpx_sn_fwd_bind_sn/ qed-.
93 lemma lleq_fwd_bind_dx: ∀a,I,L1,L2,V,T,d.
94 L1 ≡[ⓑ{a,I}V.T, d] L2 → L1.ⓑ{I}V ≡[T, ⫯d] L2.ⓑ{I}V.
95 /2 width=2 by llpx_sn_fwd_bind_dx/ qed-.
97 lemma lleq_fwd_flat_sn: ∀I,L1,L2,V,T,d.
98 L1 ≡[ⓕ{I}V.T, d] L2 → L1 ≡[V, d] L2.
99 /2 width=3 by llpx_sn_fwd_flat_sn/ qed-.
101 lemma lleq_fwd_flat_dx: ∀I,L1,L2,V,T,d.
102 L1 ≡[ⓕ{I}V.T, d] L2 → L1 ≡[T, d] L2.
103 /2 width=3 by llpx_sn_fwd_flat_dx/ qed-.
105 (* Basic properties *********************************************************)
107 lemma lleq_sort: ∀L1,L2,d,k. |L1| = |L2| → L1 ≡[⋆k, d] L2.
108 /2 width=1 by llpx_sn_sort/ qed.
110 lemma lleq_skip: ∀L1,L2,d,i. yinj i < d → |L1| = |L2| → L1 ≡[#i, d] L2.
111 /2 width=1 by llpx_sn_skip/ qed.
113 lemma lleq_lref: ∀I,L1,L2,K1,K2,V,d,i. d ≤ yinj i →
114 ⇩[i] L1 ≡ K1.ⓑ{I}V → ⇩[i] L2 ≡ K2.ⓑ{I}V →
115 K1 ≡[V, 0] K2 → L1 ≡[#i, d] L2.
116 /2 width=9 by llpx_sn_lref/ qed.
118 lemma lleq_free: ∀L1,L2,d,i. |L1| ≤ i → |L2| ≤ i → |L1| = |L2| → L1 ≡[#i, d] L2.
119 /2 width=1 by llpx_sn_free/ qed.
121 lemma lleq_gref: ∀L1,L2,d,p. |L1| = |L2| → L1 ≡[§p, d] L2.
122 /2 width=1 by llpx_sn_gref/ qed.
124 lemma lleq_bind: ∀a,I,L1,L2,V,T,d.
125 L1 ≡[V, d] L2 → L1.ⓑ{I}V ≡[T, ⫯d] L2.ⓑ{I}V →
126 L1 ≡[ⓑ{a,I}V.T, d] L2.
127 /2 width=1 by llpx_sn_bind/ qed.
129 lemma lleq_flat: ∀I,L1,L2,V,T,d.
130 L1 ≡[V, d] L2 → L1 ≡[T, d] L2 → L1 ≡[ⓕ{I}V.T, d] L2.
131 /2 width=1 by llpx_sn_flat/ qed.
133 lemma lleq_refl: ∀d,T. reflexive … (lleq d T).
134 /2 width=1 by llpx_sn_refl/ qed.
136 lemma lleq_Y: ∀L1,L2,T. |L1| = |L2| → L1 ≡[T, ∞] L2.
137 /2 width=1 by llpx_sn_Y/ qed.
139 lemma lleq_sym: ∀d,T. symmetric … (lleq d T).
140 #d #T #L1 #L2 #H @(lleq_ind … H) -d -T -L1 -L2
141 /2 width=7 by lleq_sort, lleq_skip, lleq_lref, lleq_free, lleq_gref, lleq_bind, lleq_flat/
144 lemma lleq_ge_up: ∀L1,L2,U,dt. L1 ≡[U, dt] L2 →
145 ∀T,d,e. ⇧[d, e] T ≡ U →
146 dt ≤ d + e → L1 ≡[U, d] L2.
147 /2 width=6 by llpx_sn_ge_up/ qed-.
149 lemma lleq_ge: ∀L1,L2,T,d1. L1 ≡[T, d1] L2 → ∀d2. d1 ≤ d2 → L1 ≡[T, d2] L2.
150 /2 width=3 by llpx_sn_ge/ qed-.
152 lemma lleq_bind_O: ∀a,I,L1,L2,V,T. L1 ≡[V, 0] L2 → L1.ⓑ{I}V ≡[T, 0] L2.ⓑ{I}V →
153 L1 ≡[ⓑ{a,I}V.T, 0] L2.
154 /2 width=1 by llpx_sn_bind_O/ qed-.
156 (* Advancded properties on lazy pointwise exyensions ************************)
158 lemma llpx_sn_lrefl: ∀R. (∀I,L. reflexive … (R I L)) →
159 ∀L1,L2,T,d. L1 ≡[T, d] L2 → llpx_sn R d T L1 L2.
160 /2 width=3 by llpx_sn_co/ qed-.