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 "basic_2/notation/constructors/item0_1.ma".
16 include "basic_2/notation/constructors/snitem2_3.ma".
17 include "basic_2/notation/constructors/snbind2_4.ma".
18 include "basic_2/notation/constructors/snbind2pos_3.ma".
19 include "basic_2/notation/constructors/snbind2neg_3.ma".
20 include "basic_2/notation/constructors/snflat2_3.ma".
21 include "basic_2/notation/constructors/star_1.ma".
22 include "basic_2/notation/constructors/lref_1.ma".
23 include "basic_2/notation/constructors/gref_1.ma".
24 include "basic_2/notation/constructors/snabbr_3.ma".
25 include "basic_2/notation/constructors/snabbrpos_2.ma".
26 include "basic_2/notation/constructors/snabbrneg_2.ma".
27 include "basic_2/notation/constructors/snabst_3.ma".
28 include "basic_2/notation/constructors/snabstpos_2.ma".
29 include "basic_2/notation/constructors/snabstneg_2.ma".
30 include "basic_2/notation/constructors/snappl_2.ma".
31 include "basic_2/notation/constructors/sncast_2.ma".
32 include "basic_2/grammar/item.ma".
34 (* TERMS ********************************************************************)
37 inductive term: Type[0] ≝
38 | TAtom: item0 → term (* atomic item construction *)
39 | TPair: item2 → term → term → term (* binary item construction *)
42 interpretation "term construction (atomic)"
45 interpretation "term construction (binary)"
46 'SnItem2 I T1 T2 = (TPair I T1 T2).
48 interpretation "term binding construction (binary)"
49 'SnBind2 a I T1 T2 = (TPair (Bind2 a I) T1 T2).
51 interpretation "term positive binding construction (binary)"
52 'SnBind2Pos I T1 T2 = (TPair (Bind2 true I) T1 T2).
54 interpretation "term negative binding construction (binary)"
55 'SnBind2Neg I T1 T2 = (TPair (Bind2 false I) T1 T2).
57 interpretation "term flat construction (binary)"
58 'SnFlat2 I T1 T2 = (TPair (Flat2 I) T1 T2).
60 interpretation "sort (term)"
61 'Star k = (TAtom (Sort k)).
63 interpretation "local reference (term)"
64 'LRef i = (TAtom (LRef i)).
66 interpretation "global reference (term)"
67 'GRef p = (TAtom (GRef p)).
69 interpretation "abbreviation (term)"
70 'SnAbbr a T1 T2 = (TPair (Bind2 a Abbr) T1 T2).
72 interpretation "positive abbreviation (term)"
73 'SnAbbrPos T1 T2 = (TPair (Bind2 true Abbr) T1 T2).
75 interpretation "negative abbreviation (term)"
76 'SnAbbrNeg T1 T2 = (TPair (Bind2 false Abbr) T1 T2).
78 interpretation "abstraction (term)"
79 'SnAbst a T1 T2 = (TPair (Bind2 a Abst) T1 T2).
81 interpretation "positive abstraction (term)"
82 'SnAbstPos T1 T2 = (TPair (Bind2 true Abst) T1 T2).
84 interpretation "negative abstraction (term)"
85 'SnAbstNeg T1 T2 = (TPair (Bind2 false Abst) T1 T2).
87 interpretation "application (term)"
88 'SnAppl T1 T2 = (TPair (Flat2 Appl) T1 T2).
90 interpretation "native type annotation (term)"
91 'SnCast T1 T2 = (TPair (Flat2 Cast) T1 T2).
93 (* Basic properties *********************************************************)
95 (* Basic_1: was: term_dec *)
96 lemma eq_term_dec: ∀T1,T2:term. Decidable (T1 = T2).
97 #T1 elim T1 -T1 #I1 [| #V1 #T1 #IHV1 #IHT1 ] * #I2 [2,4: #V2 #T2 ]
98 [1,4: @or_intror #H destruct
99 | elim (eq_item2_dec I1 I2) #HI
100 [ elim (IHV1 V2) -IHV1 #HV
101 [ elim (IHT1 T2) -IHT1 /2 width=1 by or_introl/ #HT ]
103 @or_intror #H destruct /2 width=1 by/
104 | elim (eq_item0_dec I1 I2) /2 width=1 by or_introl/ #HI
105 @or_intror #H destruct /2 width=1 by/
109 (* Basic inversion lemmas ***************************************************)
111 fact destruct_tatom_tatom_aux: ∀I1,I2. ⓪{I1} = ⓪{I2} → I1 = I2.
112 #I1 #I2 #H destruct //
115 fact destruct_tpair_tpair_aux: ∀I1,I2,T1,T2,V1,V2. ②{I1}T1.V1 = ②{I2}T2.V2 →
116 ∧∧T1 = T2 & I1 = I2 & V1 = V2.
117 #I1 #I2 #T1 #T2 #V1 #V2 #H destruct /2 width=1 by and3_intro/
120 lemma discr_tpair_xy_x: ∀I,T,V. ②{I} V. T = V → ⊥.
123 | #J #W #U #IHW #_ #H elim (destruct_tpair_tpair_aux … H) -H /2 width=1 by/ (**) (* destruct lemma needed *)
127 (* Basic_1: was: thead_x_y_y *)
128 lemma discr_tpair_xy_y: ∀I,V,T. ②{I} V. T = T → ⊥.
131 | #J #W #U #_ #IHU #H elim (destruct_tpair_tpair_aux … H) -H /2 width=1 by/ (**) (* destruct lemma needed *)
135 lemma eq_false_inv_tpair_sn: ∀I,V1,T1,V2,T2.
136 (②{I} V1. T1 = ②{I} V2. T2 → ⊥) →
137 (V1 = V2 → ⊥) ∨ (V1 = V2 ∧ (T1 = T2 → ⊥)).
138 #I #V1 #T1 #V2 #T2 #H
139 elim (eq_term_dec V1 V2) /3 width=1 by or_introl/ #HV12 destruct
140 @or_intror @conj // #HT12 destruct /2 width=1 by/
143 lemma eq_false_inv_tpair_dx: ∀I,V1,T1,V2,T2.
144 (②{I} V1. T1 = ②{I} V2. T2 → ⊥) →
145 (T1 = T2 → ⊥) ∨ (T1 = T2 ∧ (V1 = V2 → ⊥)).
146 #I #V1 #T1 #V2 #T2 #H
147 elim (eq_term_dec T1 T2) /3 width=1 by or_introl/ #HT12 destruct
148 @or_intror @conj // #HT12 destruct /2 width=1 by/
151 (* Basic_1: removed theorems 3:
152 not_void_abst not_abbr_void not_abst_void