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