]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambda_delta/basic_2/grammar/term.ma
- a caracterization of the top elements of the local evironment
[helm.git] / matita / matita / contribs / lambda_delta / basic_2 / grammar / 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 "basic_2/grammar/item.ma".
16
17 (* TERMS ********************************************************************)
18
19 (* terms *)
20 inductive term: Type[0] ≝
21   | TAtom: item0 → term               (* atomic item construction *)
22   | TPair: item2 → term → term → term (* binary item construction *)
23 .
24
25 interpretation "term construction (atomic)"
26    'Item0 I = (TAtom I).
27
28 interpretation "term construction (binary)"
29    'SnItem2 I T1 T2 = (TPair I T1 T2).
30
31 interpretation "term binding construction (binary)"
32    'SnBind2 I T1 T2 = (TPair (Bind2 I) T1 T2).
33
34 interpretation "term flat construction (binary)"
35    'SnFlat2 I T1 T2 = (TPair (Flat2 I) T1 T2).
36
37 interpretation "sort (term)"
38    'Star k = (TAtom (Sort k)).
39
40 interpretation "local reference (term)"
41    'LRef i = (TAtom (LRef i)).
42
43 interpretation "global reference (term)"
44    'GRef p = (TAtom (GRef p)).
45
46 interpretation "abbreviation (term)"
47    'SnAbbr T1 T2 = (TPair (Bind2 Abbr) T1 T2).
48
49 interpretation "abstraction (term)"
50    'SnAbst T1 T2 = (TPair (Bind2 Abst) T1 T2).
51
52 interpretation "application (term)"
53    'SnAppl T1 T2 = (TPair (Flat2 Appl) T1 T2).
54
55 interpretation "native type annotation (term)"
56    'SnCast T1 T2 = (TPair (Flat2 Cast) T1 T2).
57
58 (* Basic properties *********************************************************)
59
60 (* Basic_1: was: term_dec *)
61 axiom term_eq_dec: ∀T1,T2:term. Decidable (T1 = T2).
62
63 (* Basic inversion lemmas ***************************************************)
64
65 lemma discr_tpair_xy_x: ∀I,T,V. ②{I} V. T = V → ⊥.
66 #I #T #V elim V -V
67 [ #J #H destruct
68 | #J #W #U #IHW #_ #H destruct
69   -H >e0 in e1; normalize (**) (* destruct: one quality is not simplified, the destucted equality is not erased *)
70   /2 width=1/
71 ]
72 qed-.
73
74 (* Basic_1: was: thead_x_y_y *)
75 lemma discr_tpair_xy_y: ∀I,V,T. ②{I} V. T = T → ⊥.
76 #I #V #T elim T -T
77 [ #J #H destruct
78 | #J #W #U #_ #IHU #H destruct
79   -H (**) (* destruct: the destucted equality is not erased *)
80   /2 width=1/
81 ]
82 qed-.
83
84 lemma eq_false_inv_tpair_sn: ∀I,V1,T1,V2,T2.
85                              (②{I} V1. T1 = ②{I} V2. T2 → ⊥) →
86                              (V1 = V2 → ⊥) ∨ (V1 = V2 ∧ (T1 = T2 → ⊥)).
87 #I #V1 #T1 #V2 #T2 #H
88 elim (term_eq_dec V1 V2) /3 width=1/ #HV12 destruct
89 @or_intror @conj // #HT12 destruct /2 width=1/ 
90 qed-.
91
92 lemma eq_false_inv_tpair_dx: ∀I,V1,T1,V2,T2.
93                              (②{I} V1. T1 = ②{I} V2. T2 → ⊥) →
94                              (T1 = T2 → ⊥) ∨ (T1 = T2 ∧ (V1 = V2 → ⊥)).
95 #I #V1 #T1 #V2 #T2 #H
96 elim (term_eq_dec T1 T2) /3 width=1/ #HT12 destruct
97 @or_intror @conj // #HT12 destruct /2 width=1/
98 qed-.
99
100 lemma eq_false_inv_beta: ∀V1,V2,W1,W2,T1,T2.
101                          (ⓐV1. ⓛW1. T1 = ⓐV2. ⓛW2 .T2 →⊥) →
102                          (W1 = W2 → ⊥) ∨
103                          (W1 = W2 ∧ (ⓓV1. T1 = ⓓV2. T2 → ⊥)).
104 #V1 #V2 #W1 #W2 #T1 #T2 #H
105 elim (eq_false_inv_tpair_sn … H) -H
106 [ #HV12 elim (term_eq_dec W1 W2) /3 width=1/
107   #H destruct @or_intror @conj // #H destruct /2 width=1/
108 | * #H1 #H2 destruct
109   elim (eq_false_inv_tpair_sn … H2) -H2 /3 width=1/
110   * #H #HT12 destruct
111   @or_intror @conj // #H destruct /2 width=1/
112 ]
113 qed.
114
115 (* Basic_1: removed theorems 3:
116             not_void_abst not_abbr_void not_abst_void
117 *)