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:
53 ∀L1,L2. L1 ⫃ L2 → ∀I,K1. L1 = K1.ⓘ{I} →
54 ∨∨ ∃∃K2. K1 ⫃ K2 & L2 = K2.ⓘ{I}
55 | ∃∃K2,V,W. K1 ⫃ K2 & L2 = K2.ⓛW & I = BPair Abbr (ⓝW.V)
56 | ∃∃J1,J2,K2,V. K1 ⫃ K2 & L2 = K2.ⓤ{J2} & I = BPair J1 V.
59 | #I #L1 #L2 #HL12 #J #K1 #H destruct /3 width=3 by or3_intro0, ex2_intro/
60 | #L1 #L2 #V #W #HL12 #J #K1 #H destruct /3 width=6 by or3_intro1, ex3_3_intro/
61 | #I1 #I2 #L1 #L2 #V #HL12 #J #K1 #H destruct /3 width=4 by or3_intro2, ex3_4_intro/
65 (* Basic_2A1: uses: lsubr_inv_pair1 *)
66 lemma lsubr_inv_bind1:
67 ∀I,K1,L2. K1.ⓘ{I} ⫃ L2 →
68 ∨∨ ∃∃K2. K1 ⫃ K2 & L2 = K2.ⓘ{I}
69 | ∃∃K2,V,W. K1 ⫃ K2 & L2 = K2.ⓛW & I = BPair Abbr (ⓝW.V)
70 | ∃∃J1,J2,K2,V. K1 ⫃ K2 & L2 = K2.ⓤ{J2} & I = BPair J1 V.
71 /2 width=3 by lsubr_inv_bind1_aux/ qed-.
73 fact lsubr_inv_atom2_aux: ∀L1,L2. L1 ⫃ L2 → L2 = ⋆ → L1 = ⋆.
75 [ #I #L1 #L2 #_ #H destruct
76 | #L1 #L2 #V #W #_ #H destruct
77 | #I1 #I2 #L1 #L2 #V #_ #H destruct
81 lemma lsubr_inv_atom2: ∀L1. L1 ⫃ ⋆ → L1 = ⋆.
82 /2 width=3 by lsubr_inv_atom2_aux/ qed-.
84 fact lsubr_inv_bind2_aux:
85 ∀L1,L2. L1 ⫃ L2 → ∀I,K2. L2 = K2.ⓘ{I} →
86 ∨∨ ∃∃K1. K1 ⫃ K2 & L1 = K1.ⓘ{I}
87 | ∃∃K1,W,V. K1 ⫃ K2 & L1 = K1.ⓓⓝW.V & I = BPair Abst W
88 | ∃∃J1,J2,K1,V. K1 ⫃ K2 & L1 = K1.ⓑ{J1}V & I = BUnit J2.
91 | #I #L1 #L2 #HL12 #J #K2 #H destruct /3 width=3 by ex2_intro, or3_intro0/
92 | #L1 #L2 #V1 #V2 #HL12 #J #K2 #H destruct /3 width=6 by ex3_3_intro, or3_intro1/
93 | #I1 #I2 #L1 #L2 #V #HL12 #J #K2 #H destruct /3 width=5 by ex3_4_intro, or3_intro2/
97 lemma lsubr_inv_bind2:
98 ∀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:
107 ∀K1,L2,W. K1.ⓛW ⫃ L2 →
108 ∨∨ ∃∃K2. K1 ⫃ K2 & L2 = K2.ⓛW
109 | ∃∃I2,K2. K1 ⫃ K2 & L2 = K2.ⓤ{I2}.
110 #K1 #L2 #W #H elim (lsubr_inv_bind1 … H) -H *
111 /3 width=4 by ex2_2_intro, ex2_intro, or_introl, or_intror/
112 #K2 #V2 #W2 #_ #_ #H destruct
115 lemma lsubr_inv_unit1:
116 ∀I,K1,L2. K1.ⓤ{I} ⫃ L2 →
117 ∃∃K2. K1 ⫃ K2 & L2 = K2.ⓤ{I}.
118 #I #K1 #L2 #H elim (lsubr_inv_bind1 … H) -H *
119 [ #K2 #HK12 #H destruct /2 width=3 by ex2_intro/
120 | #K2 #V #W #_ #_ #H destruct
121 | #J1 #J2 #K2 #V #_ #_ #H destruct
125 lemma lsubr_inv_pair2:
126 ∀I,L1,K2,W. L1 ⫃ K2.ⓑ{I}W →
127 ∨∨ ∃∃K1. K1 ⫃ K2 & L1 = K1.ⓑ{I}W
128 | ∃∃K1,V. K1 ⫃ K2 & L1 = K1.ⓓⓝW.V & I = Abst.
129 #I #L1 #K2 #W #H elim (lsubr_inv_bind2 … H) -H *
130 [ /3 width=3 by ex2_intro, or_introl/
131 | #K1 #X #V #HK12 #H1 #H2 destruct /3 width=4 by ex3_2_intro, or_intror/
132 | #J1 #J1 #K1 #V #_ #_ #H destruct
136 lemma lsubr_inv_abbr2:
137 ∀L1,K2,V. L1 ⫃ K2.ⓓV →
138 ∃∃K1. K1 ⫃ K2 & L1 = K1.ⓓV.
139 #L1 #K2 #V #H elim (lsubr_inv_pair2 … H) -H *
140 [ /2 width=3 by ex2_intro/
141 | #K1 #X #_ #_ #H destruct
145 lemma lsubr_inv_abst2:
146 ∀L1,K2,W. L1 ⫃ K2.ⓛW →
147 ∨∨ ∃∃K1. K1 ⫃ K2 & L1 = K1.ⓛW
148 | ∃∃K1,V. K1 ⫃ K2 & L1 = K1.ⓓⓝW.V.
149 #L1 #K2 #W #H elim (lsubr_inv_pair2 … H) -H *
150 /3 width=4 by ex2_2_intro, ex2_intro, or_introl, or_intror/
153 lemma lsubr_inv_unit2:
154 ∀I,L1,K2. L1 ⫃ K2.ⓤ{I} →
155 ∨∨ ∃∃K1. K1 ⫃ K2 & L1 = K1.ⓤ{I}
156 | ∃∃J,K1,V. K1 ⫃ K2 & L1 = K1.ⓑ{J}V.
157 #I #L1 #K2 #H elim (lsubr_inv_bind2 … H) -H *
158 [ /3 width=3 by ex2_intro, or_introl/
159 | #K1 #W #V #_ #_ #H destruct
160 | #J1 #J2 #K1 #V #HK12 #H1 #H2 destruct /3 width=5 by ex2_3_intro, or_intror/
164 (* Basic forward lemmas *****************************************************)
166 lemma lsubr_fwd_bind1:
167 ∀I1,K1,L2. K1.ⓘ{I1} ⫃ L2 →
168 ∃∃I2,K2. K1 ⫃ K2 & L2 = K2.ⓘ{I2}.
169 #I1 #K1 #L2 #H elim (lsubr_inv_bind1 … H) -H *
170 [ #K2 #HK12 #H destruct /3 width=4 by ex2_2_intro/
171 | #K2 #W1 #V1 #HK12 #H1 #H2 destruct /3 width=4 by ex2_2_intro/
172 | #J1 #J2 #K2 #V1 #HK12 #H1 #H2 destruct /3 width=4 by ex2_2_intro/
176 lemma lsubr_fwd_bind2:
177 ∀I2,L1,K2. L1 ⫃ K2.ⓘ{I2} →
178 ∃∃I1,K1. K1 ⫃ K2 & L1 = K1.ⓘ{I1}.
179 #I2 #L1 #K2 #H elim (lsubr_inv_bind2 … H) -H *
180 [ #K1 #HK12 #H destruct /3 width=4 by ex2_2_intro/
181 | #K1 #W1 #V1 #HK12 #H1 #H2 destruct /3 width=4 by ex2_2_intro/
182 | #J1 #J2 #K1 #V1 #HK12 #H1 #H2 destruct /3 width=4 by ex2_2_intro/