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/notation/relations/lrsubeqc_2.ma".
16 include "static_2/syntax/lenv.ma".
18 (* RESTRICTED REFINEMENT FOR LOCAL ENVIRONMENTS *****************************)
20 (* Basic_2A1: just tpr_cpr and tprs_cprs require the extended lsubr_atom *)
21 (* Basic_2A1: includes: lsubr_pair *)
22 inductive lsubr: relation lenv ≝
23 | lsubr_atom: lsubr (⋆) (⋆)
24 | lsubr_bind: ∀I,L1,L2. lsubr L1 L2 → lsubr (L1.ⓘ{I}) (L2.ⓘ{I})
25 | lsubr_beta: ∀L1,L2,V,W. lsubr L1 L2 → lsubr (L1.ⓓⓝW.V) (L2.ⓛW)
26 | lsubr_unit: ∀I1,I2,L1,L2,V. lsubr L1 L2 → lsubr (L1.ⓑ{I1}V) (L2.ⓤ{I2})
30 "restricted refinement (local environment)"
31 'LRSubEqC L1 L2 = (lsubr L1 L2).
33 (* Basic properties *********************************************************)
35 lemma lsubr_refl: ∀L. L ⫃ L.
36 #L elim L -L /2 width=1 by lsubr_atom, lsubr_bind/
39 (* Basic inversion lemmas ***************************************************)
41 fact lsubr_inv_atom1_aux: ∀L1,L2. L1 ⫃ L2 → L1 = ⋆ → L2 = ⋆.
43 [ #I #L1 #L2 #_ #H destruct
44 | #L1 #L2 #V #W #_ #H destruct
45 | #I1 #I2 #L1 #L2 #V #_ #H destruct
49 lemma lsubr_inv_atom1: ∀L2. ⋆ ⫃ L2 → L2 = ⋆.
50 /2 width=3 by lsubr_inv_atom1_aux/ qed-.
52 fact lsubr_inv_bind1_aux: ∀L1,L2. L1 ⫃ L2 → ∀I,K1. L1 = K1.ⓘ{I} →
53 ∨∨ ∃∃K2. K1 ⫃ K2 & L2 = K2.ⓘ{I}
54 | ∃∃K2,V,W. K1 ⫃ K2 & L2 = K2.ⓛW &
56 | ∃∃J1,J2,K2,V. K1 ⫃ K2 & L2 = K2.ⓤ{J2} &
60 | #I #L1 #L2 #HL12 #J #K1 #H destruct /3 width=3 by or3_intro0, ex2_intro/
61 | #L1 #L2 #V #W #HL12 #J #K1 #H destruct /3 width=6 by or3_intro1, ex3_3_intro/
62 | #I1 #I2 #L1 #L2 #V #HL12 #J #K1 #H destruct /3 width=4 by or3_intro2, ex3_4_intro/
66 (* Basic_2A1: uses: lsubr_inv_pair1 *)
67 lemma lsubr_inv_bind1: ∀I,K1,L2. K1.ⓘ{I} ⫃ L2 →
68 ∨∨ ∃∃K2. K1 ⫃ K2 & L2 = K2.ⓘ{I}
69 | ∃∃K2,V,W. K1 ⫃ K2 & L2 = K2.ⓛW &
71 | ∃∃J1,J2,K2,V. K1 ⫃ K2 & L2 = K2.ⓤ{J2} &
73 /2 width=3 by lsubr_inv_bind1_aux/ qed-.
75 fact lsubr_inv_atom2_aux: ∀L1,L2. L1 ⫃ L2 → L2 = ⋆ → L1 = ⋆.
77 [ #I #L1 #L2 #_ #H destruct
78 | #L1 #L2 #V #W #_ #H destruct
79 | #I1 #I2 #L1 #L2 #V #_ #H destruct
83 lemma lsubr_inv_atom2: ∀L1. L1 ⫃ ⋆ → L1 = ⋆.
84 /2 width=3 by lsubr_inv_atom2_aux/ qed-.
86 fact lsubr_inv_bind2_aux: ∀L1,L2. L1 ⫃ L2 → ∀I,K2. L2 = K2.ⓘ{I} →
87 ∨∨ ∃∃K1. K1 ⫃ K2 & L1 = K1.ⓘ{I}
88 | ∃∃K1,W,V. K1 ⫃ K2 & L1 = K1.ⓓⓝW.V & I = BPair Abst W
89 | ∃∃J1,J2,K1,V. K1 ⫃ K2 & L1 = K1.ⓑ{J1}V & I = BUnit J2.
92 | #I #L1 #L2 #HL12 #J #K2 #H destruct /3 width=3 by ex2_intro, or3_intro0/
93 | #L1 #L2 #V1 #V2 #HL12 #J #K2 #H destruct /3 width=6 by ex3_3_intro, or3_intro1/
94 | #I1 #I2 #L1 #L2 #V #HL12 #J #K2 #H destruct /3 width=5 by ex3_4_intro, or3_intro2/
98 lemma lsubr_inv_bind2: ∀I,L1,K2. L1 ⫃ K2.ⓘ{I} →
99 ∨∨ ∃∃K1. K1 ⫃ K2 & L1 = K1.ⓘ{I}
100 | ∃∃K1,W,V. K1 ⫃ K2 & L1 = K1.ⓓⓝW.V & I = BPair Abst W
101 | ∃∃J1,J2,K1,V. K1 ⫃ K2 & L1 = K1.ⓑ{J1}V & I = BUnit J2.
102 /2 width=3 by lsubr_inv_bind2_aux/ qed-.
104 (* Advanced inversion lemmas ************************************************)
106 lemma lsubr_inv_abst1: ∀K1,L2,W. K1.ⓛW ⫃ L2 →
107 ∨∨ ∃∃K2. K1 ⫃ K2 & L2 = K2.ⓛW
108 | ∃∃I2,K2. K1 ⫃ K2 & L2 = K2.ⓤ{I2}.
109 #K1 #L2 #W #H elim (lsubr_inv_bind1 … H) -H *
110 /3 width=4 by ex2_2_intro, ex2_intro, or_introl, or_intror/
111 #K2 #V2 #W2 #_ #_ #H destruct
114 lemma lsubr_inv_unit1: ∀I,K1,L2. K1.ⓤ{I} ⫃ L2 →
115 ∃∃K2. K1 ⫃ K2 & L2 = K2.ⓤ{I}.
116 #I #K1 #L2 #H elim (lsubr_inv_bind1 … H) -H *
117 [ #K2 #HK12 #H destruct /2 width=3 by ex2_intro/
118 | #K2 #V #W #_ #_ #H destruct
119 | #I1 #I2 #K2 #V #_ #_ #H destruct
123 lemma lsubr_inv_pair2: ∀I,L1,K2,W. L1 ⫃ K2.ⓑ{I}W →
124 ∨∨ ∃∃K1. K1 ⫃ K2 & L1 = K1.ⓑ{I}W
125 | ∃∃K1,V. K1 ⫃ K2 & L1 = K1.ⓓⓝW.V & I = Abst.
126 #I #L1 #K2 #W #H elim (lsubr_inv_bind2 … H) -H *
127 [ /3 width=3 by ex2_intro, or_introl/
128 | #K2 #X #V #HK12 #H1 #H2 destruct /3 width=4 by ex3_2_intro, or_intror/
129 | #I1 #I1 #K2 #V #_ #_ #H destruct
133 lemma lsubr_inv_abbr2: ∀L1,K2,V. L1 ⫃ K2.ⓓV →
134 ∃∃K1. K1 ⫃ K2 & L1 = K1.ⓓV.
135 #L1 #K2 #V #H elim (lsubr_inv_pair2 … H) -H *
136 [ /2 width=3 by ex2_intro/
137 | #K1 #X #_ #_ #H destruct
141 lemma lsubr_inv_abst2: ∀L1,K2,W. L1 ⫃ K2.ⓛW →
142 ∨∨ ∃∃K1. K1 ⫃ K2 & L1 = K1.ⓛW
143 | ∃∃K1,V. K1 ⫃ K2 & L1 = K1.ⓓⓝW.V.
144 #L1 #K2 #W #H elim (lsubr_inv_pair2 … H) -H *
145 /3 width=4 by ex2_2_intro, ex2_intro, or_introl, or_intror/
148 lemma lsubr_inv_unit2: ∀I,L1,K2. L1 ⫃ K2.ⓤ{I} →
149 ∨∨ ∃∃K1. K1 ⫃ K2 & L1 = K1.ⓤ{I}
150 | ∃∃J,K1,V. K1 ⫃ K2 & L1 = K1.ⓑ{J}V.
151 #I #L1 #K2 #H elim (lsubr_inv_bind2 … H) -H *
152 [ /3 width=3 by ex2_intro, or_introl/
153 | #K1 #W #V #_ #_ #H destruct
154 | #I1 #I2 #K1 #V #HK12 #H1 #H2 destruct /3 width=5 by ex2_3_intro, or_intror/
158 (* Basic forward lemmas *****************************************************)
160 lemma lsubr_fwd_bind1: ∀I1,K1,L2. K1.ⓘ{I1} ⫃ L2 →
161 ∃∃I2,K2. K1 ⫃ K2 & L2 = K2.ⓘ{I2}.
162 #I1 #K1 #L2 #H elim (lsubr_inv_bind1 … H) -H *
163 [ #K2 #HK12 #H destruct /3 width=4 by ex2_2_intro/
164 | #K2 #W1 #V1 #HK12 #H1 #H2 destruct /3 width=4 by ex2_2_intro/
165 | #I1 #I2 #K2 #V1 #HK12 #H1 #H2 destruct /3 width=4 by ex2_2_intro/
169 lemma lsubr_fwd_bind2: ∀I2,L1,K2. L1 ⫃ K2.ⓘ{I2} →
170 ∃∃I1,K1. K1 ⫃ K2 & L1 = K1.ⓘ{I1}.
171 #I2 #L1 #K2 #H elim (lsubr_inv_bind2 … H) -H *
172 [ #K1 #HK12 #H destruct /3 width=4 by ex2_2_intro/
173 | #K1 #W1 #V1 #HK12 #H1 #H2 destruct /3 width=4 by ex2_2_intro/
174 | #I1 #I2 #K1 #V1 #HK12 #H1 #H2 destruct /3 width=4 by ex2_2_intro/