]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/static_2/syntax/theq.ma
milestone in basic_2
[helm.git] / matita / matita / contribs / lambdadelta / static_2 / syntax / theq.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 "static_2/notation/relations/topiso_2.ma".
16 include "static_2/syntax/term.ma".
17
18 (* HEAD EQUIVALENCE FOR TERMS ***********************************************)
19
20 (* Basic_2A1: includes: tsts_atom tsts_pair *)
21 inductive theq: relation term ≝
22 | theq_sort: ∀s1,s2. theq (⋆s1) (⋆s2)
23 | theq_lref: ∀i. theq (#i) (#i)
24 | theq_gref: ∀l. theq (§l) (§l)
25 | theq_pair: ∀I,V1,V2,T1,T2. theq (②{I}V1.T1) (②{I}V2.T2)
26 .
27
28 interpretation "head equivalence (term)" 'TopIso T1 T2 = (theq T1 T2).
29
30 (* Basic inversion lemmas ***************************************************)
31
32 fact theq_inv_sort1_aux: ∀X,Y. X ⩳ Y → ∀s1. X = ⋆s1 →
33                          ∃s2. Y = ⋆s2.
34 #X #Y * -X -Y
35 [ #s1 #s2 #s #H destruct /2 width=2 by ex_intro/
36 | #i #s #H destruct
37 | #l #s #H destruct
38 | #I #V1 #V2 #T1 #T2 #s #H destruct
39 ]
40 qed-.
41
42 (* Basic_1: was just: iso_gen_sort *)
43 lemma theq_inv_sort1: ∀Y,s1. ⋆s1 ⩳ Y →
44                       ∃s2. Y = ⋆s2.
45 /2 width=4 by theq_inv_sort1_aux/ qed-.
46
47 fact theq_inv_lref1_aux: ∀X,Y. X ⩳ Y → ∀i. X = #i → Y = #i.
48 #X #Y * -X -Y //
49 [ #s1 #s2 #j #H destruct
50 | #I #V1 #V2 #T1 #T2 #j #H destruct
51 ]
52 qed-.
53
54 (* Basic_1: was: iso_gen_lref *)
55 lemma theq_inv_lref1: ∀Y,i. #i ⩳ Y → Y = #i.
56 /2 width=5 by theq_inv_lref1_aux/ qed-.
57
58 fact theq_inv_gref1_aux: ∀X,Y. X ⩳ Y → ∀l. X = §l → Y = §l.
59 #X #Y * -X -Y //
60 [ #s1 #s2 #k #H destruct
61 | #I #V1 #V2 #T1 #T2 #k #H destruct
62 ]
63 qed-.
64
65 lemma theq_inv_gref1: ∀Y,l. §l ⩳ Y → Y = §l.
66 /2 width=5 by theq_inv_gref1_aux/ qed-.
67
68 fact theq_inv_pair1_aux: ∀T1,T2. T1 ⩳ T2 →
69                          ∀J,W1,U1. T1 = ②{J}W1.U1 →
70                          ∃∃W2,U2. T2 = ②{J}W2.U2.
71 #T1 #T2 * -T1 -T2
72 [ #s1 #s2 #J #W1 #U1 #H destruct
73 | #i #J #W1 #U1 #H destruct
74 | #l #J #W1 #U1 #H destruct
75 | #I #V1 #V2 #T1 #T2 #J #W1 #U1 #H destruct /2 width=3 by ex1_2_intro/
76 ]
77 qed-.
78
79 (* Basic_1: was: iso_gen_head *)
80 (* Basic_2A1: was: tsts_inv_pair1 *)
81 lemma theq_inv_pair1: ∀J,W1,U1,T2. ②{J}W1.U1 ⩳ T2 →
82                       ∃∃W2,U2. T2 = ②{J}W2. U2.
83 /2 width=7 by theq_inv_pair1_aux/ qed-.
84
85 fact theq_inv_pair2_aux: ∀T1,T2. T1 ⩳ T2 →
86                          ∀J,W2,U2. T2 = ②{J}W2.U2 →
87                          ∃∃W1,U1. T1 = ②{J}W1.U1.
88 #T1 #T2 * -T1 -T2
89 [ #s1 #s2 #J #W2 #U2 #H destruct
90 | #i #J #W2 #U2 #H destruct
91 | #l #J #W2 #U2 #H destruct
92 | #I #V1 #V2 #T1 #T2 #J #W2 #U2 #H destruct /2 width=3 by ex1_2_intro/
93 ]
94 qed-.
95
96 (* Basic_2A1: was: tsts_inv_pair2 *)
97 lemma theq_inv_pair2: ∀J,T1,W2,U2. T1 ⩳ ②{J}W2.U2 →
98                       ∃∃W1,U1. T1 = ②{J}W1.U1.
99 /2 width=7 by theq_inv_pair2_aux/ qed-.
100
101 (* Advanced inversion lemmas ************************************************)
102
103 lemma theq_inv_pair: ∀I1,I2,V1,V2,T1,T2. ②{I1}V1.T1 ⩳ ②{I2}V2.T2 →
104                      I1 = I2.
105 #I1 #I2 #V1 #V2 #T1 #T2 #H elim (theq_inv_pair1 … H) -H
106 #V0 #T0 #H destruct //
107 qed-.
108
109 (* Basic properties *********************************************************)
110
111 (* Basic_1: was: iso_refl *)
112 (* Basic_2A1: was: tsts_refl *)
113 lemma theq_refl: reflexive … theq.
114 * //
115 * /2 width=1 by theq_lref, theq_gref/
116 qed.
117
118 (* Basic_2A1: was: tsts_sym *)
119 lemma theq_sym: symmetric … theq.
120 #T1 #T2 * -T1 -T2 /2 width=3 by theq_sort/
121 qed-.
122
123 (* Basic_2A1: was: tsts_dec *)
124 lemma theq_dec: ∀T1,T2. Decidable (T1 ⩳ T2).
125 * [ * #s1 | #I1 #V1 #T1 ] * [1,3,5,7: * #s2 |*: #I2 #V2 #T2 ]
126 [ /3 width=1 by theq_sort, or_introl/
127 |2,3,13:
128   @or_intror #H
129   elim (theq_inv_sort1 … H) -H #x #H destruct
130 |4,6,14:
131   @or_intror #H
132   lapply (theq_inv_lref1 … H) -H #H destruct
133 |5:
134   elim (eq_nat_dec s1 s2) #Hs12 destruct /2 width=1 by or_introl/
135   @or_intror #H
136   lapply (theq_inv_lref1 … H) -H #H destruct /2 width=1 by/
137 |7,8,15:
138   @or_intror #H
139   lapply (theq_inv_gref1 … H) -H #H destruct
140 |9:
141   elim (eq_nat_dec s1 s2) #Hs12 destruct /2 width=1 by or_introl/
142   @or_intror #H
143   lapply (theq_inv_gref1 … H) -H #H destruct /2 width=1 by/
144 |10,11,12:
145   @or_intror #H
146   elim (theq_inv_pair1 … H) -H #X1 #X2 #H destruct
147 |16:
148   elim (eq_item2_dec I1 I2) #HI12 destruct
149   [ /3 width=1 by theq_pair, or_introl/ ]
150   @or_intror #H
151   lapply (theq_inv_pair … H) -H /2 width=1 by/
152 ]
153 qed-.
154
155 (* Basic_2A1: removed theorems 2:
156               tsts_inv_atom1 tsts_inv_atom2
157 *)