]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/static_2/syntax/term.ma
update in delayed_updating
[helm.git] / matita / matita / contribs / lambdadelta / static_2 / syntax / term.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 "ground/xoa/ex_1_3.ma".
16 include "static_2/notation/functions/item0_1.ma".
17 include "static_2/notation/functions/snitem2_3.ma".
18 include "static_2/notation/functions/snbind2_4.ma".
19 include "static_2/notation/functions/snbind2pos_3.ma".
20 include "static_2/notation/functions/snbind2neg_3.ma".
21 include "static_2/notation/functions/snflat2_3.ma".
22 include "static_2/notation/functions/star_1.ma".
23 include "static_2/notation/functions/lref_1.ma".
24 include "static_2/notation/functions/gref_1.ma".
25 include "static_2/notation/functions/snabbr_3.ma".
26 include "static_2/notation/functions/snabbrpos_2.ma".
27 include "static_2/notation/functions/snabbrneg_2.ma".
28 include "static_2/notation/functions/snabst_3.ma".
29 include "static_2/notation/functions/snabstpos_2.ma".
30 include "static_2/notation/functions/snabstneg_2.ma".
31 include "static_2/notation/functions/snappl_2.ma".
32 include "static_2/notation/functions/sncast_2.ma".
33 include "static_2/syntax/item.ma".
34
35 (* TERMS ********************************************************************)
36
37 (* terms *)
38 inductive term: Type[0] ≝
39 | TAtom: item0 → term               (* atomic item construction *)
40 | TPair: item2 → term → term → term (* binary item construction *)
41 .
42
43 interpretation
44   "term construction (atomic)"
45   'Item0 I = (TAtom I).
46
47 interpretation
48   "term construction (binary)"
49   'SnItem2 I T1 T2 = (TPair I T1 T2).
50
51 interpretation
52   "term binding construction (binary)"
53   'SnBind2 p I T1 T2 = (TPair (Bind2 p I) T1 T2).
54
55 interpretation
56   "term positive binding construction (binary)"
57   'SnBind2Pos I T1 T2 = (TPair (Bind2 true I) T1 T2).
58
59 interpretation
60   "term negative binding construction (binary)"
61   'SnBind2Neg I T1 T2 = (TPair (Bind2 false I) T1 T2).
62
63 interpretation
64   "term flat construction (binary)"
65   'SnFlat2 I T1 T2 = (TPair (Flat2 I) T1 T2).
66
67 interpretation
68   "sort (term)"
69   'Star s = (TAtom (Sort s)).
70
71 interpretation
72   "local reference (term)"
73   'LRef i = (TAtom (LRef i)).
74
75 interpretation
76   "global reference (term)"
77   'GRef l = (TAtom (GRef l)).
78
79 interpretation
80   "abbreviation (term)"
81   'SnAbbr p T1 T2 = (TPair (Bind2 p Abbr) T1 T2).
82
83 interpretation
84   "positive abbreviation (term)"
85   'SnAbbrPos T1 T2 = (TPair (Bind2 true Abbr) T1 T2).
86
87 interpretation
88   "negative abbreviation (term)"
89   'SnAbbrNeg T1 T2 = (TPair (Bind2 false Abbr) T1 T2).
90
91 interpretation
92   "abstraction (term)"
93   'SnAbst p T1 T2 = (TPair (Bind2 p Abst) T1 T2).
94
95 interpretation
96   "positive abstraction (term)"
97   'SnAbstPos T1 T2 = (TPair (Bind2 true Abst) T1 T2).
98
99 interpretation
100   "negative abstraction (term)"
101   'SnAbstNeg T1 T2 = (TPair (Bind2 false Abst) T1 T2).
102
103 interpretation
104   "application (term)"
105   'SnAppl T1 T2 = (TPair (Flat2 Appl) T1 T2).
106
107 interpretation
108   "native type annotation (term)"
109   'SnCast T1 T2 = (TPair (Flat2 Cast) T1 T2).
110
111 (* Basic properties *********************************************************)
112
113 lemma abst_dec (X):
114       ∨∨ ∃∃p,W,T. X = ⓛ[p]W.T
115        | (∀p,W,T. X = ⓛ[p]W.T → ⊥).
116 * [ #I | * [ #p * | #I ] #V #T ]
117 [3: /3 width=4 by ex1_3_intro, or_introl/ ]
118 @or_intror #q #W #U #H destruct
119 qed-.
120
121 (* Basic_1: was: term_dec *)
122 lemma eq_term_dec:
123       ∀T1,T2:term. Decidable (T1 = T2).
124 #T1 elim T1 -T1 #I1 [| #V1 #T1 #IHV1 #IHT1 ] * #I2 [2,4: #V2 #T2 ]
125 [1,4: @or_intror #H destruct
126 | elim (eq_item2_dec I1 I2) #HI
127   [ elim (IHV1 V2) -IHV1 #HV
128     [ elim (IHT1 T2) -IHT1 /2 width=1 by or_introl/ #HT ]
129   ]
130   @or_intror #H destruct /2 width=1 by/
131 | elim (eq_item0_dec I1 I2) /2 width=1 by or_introl/ #HI
132   @or_intror #H destruct /2 width=1 by/
133 ]
134 qed-.
135
136 (* Basic inversion lemmas ***************************************************)
137
138 fact destruct_tatom_tatom_aux:
139      ∀I1,I2. ⓪[I1] = ⓪[I2] → I1 = I2.
140 #I1 #I2 #H destruct //
141 qed-.
142
143 fact destruct_tpair_tpair_aux:
144      ∀I1,I2,T1,T2,V1,V2. ②[I1]T1.V1 = ②[I2]T2.V2 →
145      ∧∧ T1 = T2 & I1 = I2 & V1 = V2.
146 #I1 #I2 #T1 #T2 #V1 #V2 #H destruct /2 width=1 by and3_intro/
147 qed-.
148
149 lemma discr_tpair_xy_x:
150       ∀I,T,V. ②[I]V.T = V → ⊥.
151 #I #T #V elim V -V
152 [ #J #H destruct
153 | #J #W #U #IHW #_ #H elim (destruct_tpair_tpair_aux … H) -H /2 width=1 by/ (**) (* destruct lemma needed *)
154 ]
155 qed-.
156
157 (* Basic_1: was: thead_x_y_y *)
158 lemma discr_tpair_xy_y:
159       ∀I,V,T. ②[I]V.T = T → ⊥.
160 #I #V #T elim T -T
161 [ #J #H destruct
162 | #J #W #U #_ #IHU #H elim (destruct_tpair_tpair_aux … H) -H /2 width=1 by/ (**) (* destruct lemma needed *)
163 ]
164 qed-.
165
166 lemma eq_false_inv_tpair_sn:
167       ∀I,V1,T1,V2,T2.
168       (②[I]V1.T1 = ②[I]V2.T2 → ⊥) →
169       (V1 = V2 → ⊥) ∨ (V1 = V2 ∧ (T1 = T2 → ⊥)).
170 #I #V1 #T1 #V2 #T2 #H
171 elim (eq_term_dec V1 V2) /3 width=1 by or_introl/ #HV12 destruct
172 @or_intror @conj // #HT12 destruct /2 width=1 by/
173 qed-.
174
175 lemma eq_false_inv_tpair_dx:
176       ∀I,V1,T1,V2,T2.
177       (②[I] V1. T1 = ②[I]V2.T2 → ⊥) →
178       (T1 = T2 → ⊥) ∨ (T1 = T2 ∧ (V1 = V2 → ⊥)).
179 #I #V1 #T1 #V2 #T2 #H
180 elim (eq_term_dec T1 T2) /3 width=1 by or_introl/ #HT12 destruct
181 @or_intror @conj // #HT12 destruct /2 width=1 by/
182 qed-.
183
184 (* Basic_1: removed theorems 3:
185             not_void_abst not_abbr_void not_abst_void
186 *)