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/voidstareq_4.ma".
16 include "basic_2/syntax/lenv.ma".
18 (* EQUIVALENCE FOR LOCAL ENVIRONMENTS UP TO EXCLUSION BINDERS ***************)
20 inductive lveq: bi_relation nat lenv ≝
21 | lveq_atom : lveq 0 (⋆) 0 (⋆)
22 | lveq_pair_sn: ∀I1,I2,K1,K2,V1,n. lveq n K1 n K2 →
23 lveq 0 (K1.ⓑ{I1}V1) 0 (K2.ⓘ{I2})
24 | lveq_pair_dx: ∀I1,I2,K1,K2,V2,n. lveq n K1 n K2 →
25 lveq 0 (K1.ⓘ{I1}) 0 (K2.ⓑ{I2}V2)
26 | lveq_void_sn: ∀K1,K2,n1,n2. lveq n1 K1 n2 K2 →
27 lveq (⫯n1) (K1.ⓧ) n2 K2
28 | lveq_void_dx: ∀K1,K2,n1,n2. lveq n1 K1 n2 K2 →
29 lveq n1 K1 (⫯n2) (K2.ⓧ)
32 interpretation "equivalence up to exclusion binders (local environment)"
33 'VoidStarEq L1 n1 n2 L2 = (lveq n1 L1 n2 L2).
35 (* Basic properties *********************************************************)
37 lemma lveq_refl: ∀L. ∃n. L ≋ⓧ*[n, n] L.
38 #L elim L -L /2 width=2 by ex_intro, lveq_atom/
39 #L #I * #n #IH cases I -I /3 width=2 by ex_intro, lveq_pair_dx/
40 * /4 width=2 by ex_intro, lveq_void_sn, lveq_void_dx/
43 lemma lveq_sym: bi_symmetric … lveq.
44 #n1 #n2 #L1 #L2 #H elim H -L1 -L2 -n1 -n2
45 /2 width=2 by lveq_atom, lveq_pair_sn, lveq_pair_dx, lveq_void_sn, lveq_void_dx/
48 (* Basic inversion lemmas ***************************************************)
50 fact lveq_inv_atom_atom_aux: ∀L1,L2,n1,n2. L1 ≋ⓧ*[n1, n2] L2 →
51 ⋆ = L1 → ⋆ = L2 → ∧∧ 0 = n1 & 0 = n2.
52 #L1 #L2 #n1 #n2 * -L1 -L2 -n1 -n2
54 |2,3: #I1 #I2 #K1 #K2 #V #n #_ #H1 #H2 destruct
55 |4,5: #K1 #K2 #n1 #n2 #_ #H1 #H2 destruct
59 lemma lveq_inv_atom_atom: ∀n1,n2. ⋆ ≋ⓧ*[n1, n2] ⋆ → 0 = n1 ∧ 0 = n2.
60 /2 width=5 by lveq_inv_atom_atom_aux/ qed-.
62 fact lveq_inv_bind_atom_aux: ∀L1,L2,n1,n2. L1 ≋ⓧ*[n1, n2] L2 →
63 ∀I1,K1. K1.ⓘ{I1} = L1 → ⋆ = L2 →
64 ∃∃m1. K1 ≋ⓧ*[m1, n2] ⋆ & BUnit Void = I1 & ⫯m1 = n1.
65 #L1 #L2 #n1 #n2 * -L1 -L2 -n1 -n2
67 |2,3: #I1 #I2 #K1 #K2 #V #n #_ #Z1 #Y1 #_ #H2 destruct
68 |4,5: #K1 #K2 #n1 #n2 #HK #Z1 #Y1 #H1 #H2 destruct /2 width=3 by ex3_intro/
72 lemma lveq_inv_bind_atom: ∀I1,K1,n1,n2. K1.ⓘ{I1} ≋ⓧ*[n1, n2] ⋆ →
73 ∃∃m1. K1 ≋ⓧ*[m1, n2] ⋆ & BUnit Void = I1 & ⫯m1 = n1.
74 /2 width=5 by lveq_inv_bind_atom_aux/ qed-.
76 lemma lveq_inv_atom_bind: ∀I2,K2,n1,n2. ⋆ ≋ⓧ*[n1, n2] K2.ⓘ{I2} →
77 ∃∃m2. ⋆ ≋ⓧ*[n1, m2] K2 & BUnit Void = I2 & ⫯m2 = n2.
79 lapply (lveq_sym … H) -H #H
80 elim (lveq_inv_bind_atom … H) -H
81 /3 width=3 by lveq_sym, ex3_intro/
84 fact lveq_inv_pair_pair_aux: ∀L1,L2,n1,n2. L1 ≋ⓧ*[n1, n2] L2 →
85 ∀I1,I2,K1,K2,V1,V2. K1.ⓑ{I1}V1 = L1 → K2.ⓑ{I2}V2 = L2 →
86 ∃∃n. K1 ≋ⓧ*[n, n] K2 & 0 = n1 & 0 = n2.
87 #L1 #L2 #n1 #n2 * -L1 -L2 -n1 -n2
88 [ #Z1 #Z2 #Y1 #Y2 #X1 #X2 #H1 #H2 destruct
89 |2,3: #I1 #I2 #K1 #K2 #V #n #HK #Z1 #Z2 #Y1 #Y2 #X1 #X2 #H1 #H2 destruct /2 width=2 by ex3_intro/
90 |4,5: #K1 #K2 #n1 #n2 #_ #Z1 #Z2 #Y1 #Y2 #X1 #X2 #H1 #H2 destruct
94 lemma lveq_inv_pair_pair: ∀I1,I2,K1,K2,V1,V2,m1,m2. K1.ⓑ{I1}V1 ≋ⓧ*[m1, m2] K2.ⓑ{I2}V2 →
95 ∃∃n. K1 ≋ⓧ*[n, n] K2 & 0 = m1 & 0 = m2.
96 /2 width=9 by lveq_inv_pair_pair_aux/ qed-.
98 (* Advanced inversion lemmas ************************************************)
100 fact lveq_inv_void_succ_sn_aux: ∀L1,L2,n1,n2. L1 ≋ⓧ*[n1, n2] L2 →
101 ∀K1,m1. L1 = K1.ⓧ → n1 = ⫯m1 → K1 ≋ ⓧ*[m1, n2] L2.
102 #L1 #L2 #n1 #n2 #H elim H -L1 -L2 -n1 -n2
103 [ #K2 #m2 #H destruct
104 | #I1 #I2 #L1 #L2 #V #n #_ #_ #K1 #m1 #H1 #H2 destruct
105 | #I1 #I2 #L1 #L2 #V #n #_ #_ #K1 #m1 #H1 #H2 destruct
106 | #L1 #L2 #n1 #n2 #HL12 #_ #K1 #m1 #H1 #H2 destruct //
107 | #L1 #L2 #n1 #n2 #_ #IH #K1 #m1 #H1 #H2 destruct
108 /3 width=1 by lveq_void_dx/
112 lemma lveq_inv_void_succ_sn: ∀L1,L2,n1,n2. L1.ⓧ ≋ⓧ*[⫯n1, n2] L2 → L1 ≋ ⓧ*[n1, n2] L2.
113 /2 width=5 by lveq_inv_void_succ_sn_aux/ qed-.
115 lemma lveq_inv_void_succ_dx: ∀L1,L2,n1,n2. L1 ≋ⓧ*[n1, ⫯n2] L2.ⓧ → L1 ≋ ⓧ*[n1, n2] L2.
116 /4 width=5 by lveq_inv_void_succ_sn_aux, lveq_sym/ qed-.
118 (* Basic forward lemmas *****************************************************)
120 fact lveq_fwd_void_void_aux: ∀L1,L2,m1,m2. L1 ≋ⓧ*[m1, m2] L2 →
121 ∀K1,K2. K1.ⓧ = L1 → K2.ⓧ = L2 →
122 ∨∨ ∃n. ⫯n = m1 | ∃n. ⫯n = m2.
123 #L1 #L2 #m1 #m2 * -L1 -L2 -m1 -m2
124 [ #Y1 #Y2 #H1 #H2 destruct
125 |2,3: #I1 #I2 #K1 #K2 #V #n #_ #Y1 #Y2 #H1 #H2 destruct
126 |4,5: #K1 #K2 #n1 #n2 #_ #Y1 #Y2 #H1 #H2 destruct /3 width=2 by ex_intro, or_introl, or_intror/
130 lemma lveq_fwd_void_void: ∀K1,K2,m1,m2. K1.ⓧ ≋ⓧ*[m1, m2] K2.ⓧ →
131 ∨∨ ∃n. ⫯n = m1 | ∃n. ⫯n = m2.
132 /2 width=7 by lveq_fwd_void_void_aux/ qed-.
134 (* Advanced forward lemmas **************************************************)
136 fact lveq_fwd_pair_sn_aux: ∀L1,L2,n1,n2. L1 ≋ⓧ*[n1, n2] L2 →
137 ∀I,K1,V. K1.ⓑ{I}V = L1 → 0 = n1.
138 #L1 #L2 #n1 #n2 #H elim H -L1 -L2 -n1 -n2 //
139 #K1 #K2 #n1 #n2 #_ #IH #J #L1 #V #H destruct /2 width=4 by/
142 lemma lveq_fwd_pair_sn: ∀I,K1,L2,V,n1,n2. K1.ⓑ{I}V ≋ⓧ*[n1, n2] L2 → 0 = n1.
143 /2 width=8 by lveq_fwd_pair_sn_aux/ qed-.
145 lemma lveq_fwd_pair_dx: ∀I,L1,K2,V,n1,n2. L1 ≋ⓧ*[n1, n2] K2.ⓑ{I}V → 0 = n2.
146 /3 width=6 by lveq_fwd_pair_sn, lveq_sym/ qed-.