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 "ground/xoa/ex_3_2.ma".
16 include "static_2/notation/relations/stareq_2.ma".
17 include "static_2/syntax/term.ma".
19 (* SORT-IRRELEVANT EQUIVALENCE ON TERMS *************************************)
21 inductive teqx: relation term ≝
22 | teqx_sort: ∀s1,s2. teqx (⋆s1) (⋆s2)
23 | teqx_lref: ∀i. teqx (#i) (#i)
24 | teqx_gref: ∀l. teqx (§l) (§l)
25 | teqx_pair: ∀I,V1,V2,T1,T2. teqx V1 V2 → teqx T1 T2 → teqx (②[I]V1.T1) (②[I]V2.T2)
29 "context-free sort-irrelevant equivalence (term)"
30 'StarEq T1 T2 = (teqx T1 T2).
32 (* Basic properties *********************************************************)
34 lemma teqx_refl: reflexive … teqx.
35 #T elim T -T /2 width=1 by teqx_pair/
36 * /2 width=1 by teqx_lref, teqx_gref/
39 lemma teqx_sym: symmetric … teqx.
40 #T1 #T2 #H elim H -T1 -T2
41 /2 width=3 by teqx_sort, teqx_lref, teqx_gref, teqx_pair/
44 (* Basic inversion lemmas ***************************************************)
46 fact teqx_inv_sort1_aux: ∀X,Y. X ≛ Y → ∀s1. X = ⋆s1 →
49 [ #s1 #s2 #s #H destruct /2 width=2 by ex_intro/
52 | #I #V1 #V2 #T1 #T2 #_ #_ #s #H destruct
56 lemma teqx_inv_sort1: ∀Y,s1. ⋆s1 ≛ Y →
58 /2 width=4 by teqx_inv_sort1_aux/ qed-.
60 fact teqx_inv_lref1_aux: ∀X,Y. X ≛ Y → ∀i. X = #i → Y = #i.
62 [ #s1 #s2 #j #H destruct
63 | #I #V1 #V2 #T1 #T2 #_ #_ #j #H destruct
67 lemma teqx_inv_lref1: ∀Y,i. #i ≛ Y → Y = #i.
68 /2 width=5 by teqx_inv_lref1_aux/ qed-.
70 fact teqx_inv_gref1_aux: ∀X,Y. X ≛ Y → ∀l. X = §l → Y = §l.
72 [ #s1 #s2 #k #H destruct
73 | #I #V1 #V2 #T1 #T2 #_ #_ #k #H destruct
77 lemma teqx_inv_gref1: ∀Y,l. §l ≛ Y → Y = §l.
78 /2 width=5 by teqx_inv_gref1_aux/ qed-.
80 fact teqx_inv_pair1_aux: ∀X,Y. X ≛ Y → ∀I,V1,T1. X = ②[I]V1.T1 →
81 ∃∃V2,T2. V1 ≛ V2 & T1 ≛ T2 & Y = ②[I]V2.T2.
83 [ #s1 #s2 #J #W1 #U1 #H destruct
84 | #i #J #W1 #U1 #H destruct
85 | #l #J #W1 #U1 #H destruct
86 | #I #V1 #V2 #T1 #T2 #HV #HT #J #W1 #U1 #H destruct /2 width=5 by ex3_2_intro/
90 lemma teqx_inv_pair1: ∀I,V1,T1,Y. ②[I]V1.T1 ≛ Y →
91 ∃∃V2,T2. V1 ≛ V2 & T1 ≛ T2 & Y = ②[I]V2.T2.
92 /2 width=3 by teqx_inv_pair1_aux/ qed-.
94 lemma teqx_inv_sort2: ∀X1,s2. X1 ≛ ⋆s2 →
97 elim (teqx_inv_sort1 X1 s2)
98 /2 width=2 by teqx_sym, ex_intro/
101 lemma teqx_inv_pair2: ∀I,X1,V2,T2. X1 ≛ ②[I]V2.T2 →
102 ∃∃V1,T1. V1 ≛ V2 & T1 ≛ T2 & X1 = ②[I]V1.T1.
104 elim (teqx_inv_pair1 I V2 T2 X1)
105 [ #V1 #T1 #HV #HT #H destruct ]
106 /3 width=5 by teqx_sym, ex3_2_intro/
109 (* Advanced inversion lemmas ************************************************)
111 lemma teqx_inv_pair: ∀I1,I2,V1,V2,T1,T2. ②[I1]V1.T1 ≛ ②[I2]V2.T2 →
112 ∧∧ I1 = I2 & V1 ≛ V2 & T1 ≛ T2.
113 #I1 #I2 #V1 #V2 #T1 #T2 #H elim (teqx_inv_pair1 … H) -H
114 #V0 #T0 #HV #HT #H destruct /2 width=1 by and3_intro/
117 lemma teqx_inv_pair_xy_x: ∀I,V,T. ②[I]V.T ≛ V → ⊥.
119 [ #J #T #H elim (teqx_inv_pair1 … H) -H #X #Y #_ #_ #H destruct
120 | #J #X #Y #IHX #_ #T #H elim (teqx_inv_pair … H) -H #H #HY #_ destruct /2 width=2 by/
124 lemma teqx_inv_pair_xy_y: ∀I,T,V. ②[I]V.T ≛ T → ⊥.
126 [ #J #V #H elim (teqx_inv_pair1 … H) -H #X #Y #_ #_ #H destruct
127 | #J #X #Y #_ #IHY #V #H elim (teqx_inv_pair … H) -H #H #_ #HY destruct /2 width=2 by/
131 (* Basic forward lemmas *****************************************************)
133 lemma teqx_fwd_atom1: ∀I,Y. ⓪[I] ≛ Y → ∃J. Y = ⓪[J].
134 * #x #Y #H [ elim (teqx_inv_sort1 … H) -H ]
135 /3 width=4 by teqx_inv_gref1, teqx_inv_lref1, ex_intro/
138 (* Advanced properties ******************************************************)
140 lemma teqx_dec: ∀T1,T2. Decidable (T1 ≛ T2).
141 #T1 elim T1 -T1 [ * #s1 | #I1 #V1 #T1 #IHV #IHT ] * [1,3,5,7: * #s2 |*: #I2 #V2 #T2 ]
142 [ /3 width=1 by teqx_sort, or_introl/
145 elim (teqx_inv_sort1 … H) -H #x #H destruct
148 lapply (teqx_inv_lref1 … H) -H #H destruct
150 elim (eq_nat_dec s1 s2) #Hs12 destruct /2 width=1 by or_introl/
152 lapply (teqx_inv_lref1 … H) -H #H destruct /2 width=1 by/
155 lapply (teqx_inv_gref1 … H) -H #H destruct
157 elim (eq_nat_dec s1 s2) #Hs12 destruct /2 width=1 by or_introl/
159 lapply (teqx_inv_gref1 … H) -H #H destruct /2 width=1 by/
162 elim (teqx_inv_pair1 … H) -H #X1 #X2 #_ #_ #H destruct
164 elim (eq_item2_dec I1 I2) #HI12 destruct
165 [ elim (IHV V2) -IHV #HV12
166 elim (IHT T2) -IHT #HT12
167 [ /3 width=1 by teqx_pair, or_introl/ ]
170 elim (teqx_inv_pair … H) -H /2 width=1 by/
174 (* Negated inversion lemmas *************************************************)
176 lemma tneqx_inv_pair: ∀I1,I2,V1,V2,T1,T2.
177 (②[I1]V1.T1 ≛ ②[I2]V2.T2 → ⊥) →
181 #I1 #I2 #V1 #V2 #T1 #T2 #H12
182 elim (eq_item2_dec I1 I2) /3 width=1 by or3_intro0/ #H destruct
183 elim (teqx_dec V1 V2) /3 width=1 by or3_intro1/
184 elim (teqx_dec T1 T2) /4 width=1 by teqx_pair, or3_intro2/