]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/syntax/tdeq.ma
- tdeq must imply tsts
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / syntax / tdeq.ma
1 (**************************************************************************)
2 (*       ___                                                              *)
3 (*      ||M||                                                             *)
4 (*      ||A||       A project by Andrea Asperti                           *)
5 (*      ||T||                                                             *)
6 (*      ||I||       Developers:                                           *)
7 (*      ||T||         The HELM team.                                      *)
8 (*      ||A||         http://helm.cs.unibo.it                             *)
9 (*      \   /                                                             *)
10 (*       \ /        This file is distributed under the terms of the       *)
11 (*        v         GNU General Public License Version 2                  *)
12 (*                                                                        *)
13 (**************************************************************************)
14
15 include "basic_2/notation/relations/lazyeq_4.ma".
16 include "basic_2/syntax/item_sd.ma".
17 include "basic_2/syntax/lenv.ma".
18
19 (* DEGREE-BASED EQUIVALENCE ON TERMS ****************************************)
20
21 inductive tdeq (h) (o): relation term ≝
22 | tdeq_sort: ∀s1,s2,d. deg h o s1 d → deg h o s2 d → tdeq h o (⋆s1) (⋆s2)
23 | tdeq_lref: ∀i. tdeq h o (#i) (#i)
24 | tdeq_gref: ∀l. tdeq h o (§l) (§l)
25 | tdeq_pair: ∀I,V1,V2,T1,T2. tdeq h o V1 V2 → tdeq h o T1 T2 → tdeq h o (②{I}V1.T1) (②{I}V2.T2)
26 .
27
28 interpretation
29    "degree-based equivalence (terms)"
30    'LazyEq h o T1 T2 = (tdeq h o T1 T2).
31
32 definition cdeq: ∀h. sd h → relation3 lenv term term ≝
33                  λh,o,L. tdeq h o.
34
35 (* Basic inversion lemmas ***************************************************)
36
37 fact tdeq_inv_sort1_aux: ∀h,o,X,Y. X ≡[h, o] Y → ∀s1. X = ⋆s1 →
38                          ∃∃s2,d. deg h o s1 d & deg h o s2 d & Y = ⋆s2.
39 #h #o #X #Y * -X -Y
40 [ #s1 #s2 #d #Hs1 #Hs2 #s #H destruct /2 width=5 by ex3_2_intro/
41 | #i #s #H destruct
42 | #l #s #H destruct
43 | #I #V1 #V2 #T1 #T2 #_ #_ #s #H destruct
44 ]
45 qed-.
46
47 lemma tdeq_inv_sort1: ∀h,o,Y,s1. ⋆s1 ≡[h, o] Y →
48                       ∃∃s2,d. deg h o s1 d & deg h o s2 d & Y = ⋆s2.
49 /2 width=3 by tdeq_inv_sort1_aux/ qed-.
50
51 fact tdeq_inv_lref1_aux: ∀h,o,X,Y. X ≡[h, o] Y → ∀i. X = #i → Y = #i.
52 #h #o #X #Y * -X -Y //
53 [ #s1 #s2 #d #_ #_ #j #H destruct
54 | #I #V1 #V2 #T1 #T2 #_ #_ #j #H destruct
55 ]
56 qed-.
57
58 lemma tdeq_inv_lref1: ∀h,o,Y,i. #i ≡[h, o] Y → Y = #i.
59 /2 width=5 by tdeq_inv_lref1_aux/ qed-.
60
61 fact tdeq_inv_gref1_aux: ∀h,o,X,Y. X ≡[h, o] Y → ∀l. X = §l → Y = §l.
62 #h #o #X #Y * -X -Y //
63 [ #s1 #s2 #d #_ #_ #k #H destruct
64 | #I #V1 #V2 #T1 #T2 #_ #_ #k #H destruct
65 ]
66 qed-.
67
68 lemma tdeq_inv_gref1: ∀h,o,Y,l. §l ≡[h, o] Y → Y = §l.
69 /2 width=5 by tdeq_inv_gref1_aux/ qed-.
70
71 fact tdeq_inv_pair1_aux: ∀h,o,X,Y. X ≡[h, o] Y → ∀I,V1,T1. X = ②{I}V1.T1 →
72                          ∃∃V2,T2. V1 ≡[h, o] V2 & T1 ≡[h, o] T2 & Y = ②{I}V2.T2.
73 #h #o #X #Y * -X -Y
74 [ #s1 #s2 #d #_ #_ #J #W1 #U1 #H destruct
75 | #i #J #W1 #U1 #H destruct
76 | #l #J #W1 #U1 #H destruct
77 | #I #V1 #V2 #T1 #T2 #HV #HT #J #W1 #U1 #H destruct /2 width=5 by ex3_2_intro/
78 ]
79 qed-.
80
81 lemma tdeq_inv_pair1: ∀h,o,I,V1,T1,Y. ②{I}V1.T1 ≡[h, o] Y →
82                       ∃∃V2,T2. V1 ≡[h, o] V2 & T1 ≡[h, o] T2 & Y = ②{I}V2.T2.
83 /2 width=3 by tdeq_inv_pair1_aux/ qed-.
84
85 (* Advanced inversion lemmas ************************************************)
86
87 lemma tdeq_inv_sort1_deg: ∀h,o,Y,s1. ⋆s1 ≡[h, o] Y → ∀d. deg h o s1 d →
88                           ∃∃s2. deg h o s2 d & Y = ⋆s2.
89 #h #o #Y #s1 #H #d #Hs1 elim (tdeq_inv_sort1 … H) -H
90 #s2 #x #Hx <(deg_mono h o … Hx … Hs1) -s1 -d /2 width=3 by ex2_intro/
91 qed-.
92
93 lemma tdeq_inv_sort_deg: ∀h,o,s1,s2. ⋆s1 ≡[h, o] ⋆s2 →
94                          ∀d1,d2. deg h o s1 d1 → deg h o s2 d2 →
95                          d1 = d2.
96 #h #o #s1 #y #H #d1 #d2 #Hs1 #Hy
97 elim (tdeq_inv_sort1_deg … H … Hs1) -s1 #s2 #Hs2 #H destruct
98 <(deg_mono h o … Hy … Hs2) -s2 -d1 //
99 qed-.
100
101 lemma tdeq_inv_pair: ∀h,o,I1,I2,V1,V2,T1,T2. ②{I1}V1.T1 ≡[h, o] ②{I2}V2.T2 →
102                      ∧∧ I1 = I2 & V1 ≡[h, o] V2 & T1 ≡[h, o] T2.
103 #h #o #I1 #I2 #V1 #V2 #T1 #T2 #H elim (tdeq_inv_pair1 … H) -H
104 #V0 #T0 #HV #HT #H destruct /2 width=1 by and3_intro/
105 qed-.
106
107 lemma tdeq_inv_pair_xy_y: ∀h,o,I,T,V. ②{I}V.T ≡[h, o] T → ⊥.
108 #h #o #I #T elim T -T
109 [ #J #V #H elim (tdeq_inv_pair1 … H) -H #X #Y #_ #_ #H destruct
110 | #J #X #Y #_ #IHY #V #H elim (tdeq_inv_pair … H) -H #H #_ #HY destruct /2 width=2 by/
111 ]
112 qed-.
113
114 (* Basic forward lemmas *****************************************************)
115
116 lemma tdeq_fwd_atom1: ∀h,o,I,Y. ⓪{I} ≡[h, o] Y → ∃J. Y = ⓪{J}.
117 #h #o * #x #Y #H [ elim (tdeq_inv_sort1 … H) -H ]
118 /3 width=4 by tdeq_inv_gref1, tdeq_inv_lref1, ex_intro/
119 qed-.
120
121 (* Basic properties *********************************************************)
122
123 lemma tdeq_refl: ∀h,o. reflexive … (tdeq h o).
124 #h #o #T elim T -T /2 width=1 by tdeq_pair/
125 * /2 width=1 by tdeq_lref, tdeq_gref/
126 #s elim (deg_total h o s) /2 width=3 by tdeq_sort/
127 qed.
128
129 lemma tdeq_sym: ∀h,o. symmetric … (tdeq h o).
130 #h #o #T1 #T2 #H elim H -T1 -T2
131 /2 width=3 by tdeq_sort, tdeq_lref, tdeq_gref, tdeq_pair/
132 qed-.
133
134 lemma tdeq_dec: ∀h,o,T1,T2. Decidable (T1 ≡[h, o] T2).
135 #h #o #T1 elim T1 -T1 [ * #s1 | #I1 #V1 #T1 #IHV #IHT ] * [1,3,5,7: * #s2 |*: #I2 #V2 #T2 ]
136 [ elim (deg_total h o s1) #d1 #H1
137   elim (deg_total h o s2) #d2 #H2
138   elim (eq_nat_dec d1 d2) #Hd12 destruct /3 width=3 by tdeq_sort, or_introl/
139   @or_intror #H
140   lapply (tdeq_inv_sort_deg … H … H1 H2) -H -H1 -H2 /2 width=1 by/
141 |2,3,13:
142   @or_intror #H
143   elim (tdeq_inv_sort1 … H) -H #x1 #x2 #_ #_ #H destruct
144 |4,6,14:
145   @or_intror #H
146   lapply (tdeq_inv_lref1 … H) -H #H destruct
147 |5:
148   elim (eq_nat_dec s1 s2) #Hs12 destruct /2 width=1 by or_introl/
149   @or_intror #H
150   lapply (tdeq_inv_lref1 … H) -H #H destruct /2 width=1 by/
151 |7,8,15:
152   @or_intror #H
153   lapply (tdeq_inv_gref1 … H) -H #H destruct
154 |9:
155   elim (eq_nat_dec s1 s2) #Hs12 destruct /2 width=1 by or_introl/
156   @or_intror #H
157   lapply (tdeq_inv_gref1 … H) -H #H destruct /2 width=1 by/
158 |10,11,12:
159   @or_intror #H
160   elim (tdeq_inv_pair1 … H) -H #X1 #X2 #_ #_ #H destruct
161 |16:
162   elim (eq_item2_dec I1 I2) #HI12 destruct
163   [ elim (IHV V2) -IHV #HV12
164     elim (IHT T2) -IHT #HT12
165     [ /3 width=1 by tdeq_pair, or_introl/ ]
166   ]
167   @or_intror #H
168   elim (tdeq_inv_pair … H) -H /2 width=1 by/
169 ]
170 qed-.
171
172 (* Negated inversion lemmas *************************************************)
173
174 lemma tdneq_inv_pair: ∀h,o,I1,I2,V1,V2,T1,T2.
175                       (②{I1}V1.T1 ≡[h, o] ②{I2}V2.T2 → ⊥) → 
176                       ∨∨ I1 = I2 → ⊥
177                       |  V1 ≡[h, o] V2 → ⊥
178                       |  (T1 ≡[h, o] T2 → ⊥).
179 #h #o #I1 #I2 #V1 #V2 #T1 #T2 #H12
180 elim (eq_item2_dec I1 I2) /3 width=1 by or3_intro0/ #H destruct
181 elim (tdeq_dec h o V1 V2) /3 width=1 by or3_intro1/
182 elim (tdeq_dec h o T1 T2) /4 width=1 by tdeq_pair, or3_intro2/
183 qed-.