]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/basic_2/syntax/append.ma
renaming in basic_2
[helm.git] / matita / matita / contribs / lambdadelta / basic_2 / syntax / append.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/notation/functions/snitem_2.ma".
16 include "basic_2/notation/functions/snbind1_2.ma".
17 include "basic_2/notation/functions/snbind2_3.ma".
18 include "basic_2/notation/functions/snvoid_1.ma".
19 include "basic_2/notation/functions/snabbr_2.ma".
20 include "basic_2/notation/functions/snabst_2.ma".
21 include "basic_2/syntax/lenv.ma".
22
23 (* APPEND FOR LOCAL ENVIRONMENTS ********************************************)
24
25 rec definition append L K on K ≝ match K with
26 [ LAtom     ⇒ L
27 | LBind K I ⇒ (append L K).ⓘ{I}
28 ].
29
30 interpretation "append (local environment)" 'plus L1 L2 = (append L1 L2).
31
32 interpretation "local environment tail binding construction (generic)"
33    'SnItem I L = (append (LBind LAtom I) L).
34
35 interpretation "local environment tail binding construction (unary)"
36    'SnBind1 I L = (append (LBind LAtom (BUnit I)) L).
37
38 interpretation "local environment tail binding construction (binary)"
39    'SnBind2 I T L = (append (LBind LAtom (BPair I T)) L).
40
41 interpretation "tail exclusion (local environment)"
42    'SnVoid L = (append (LBind LAtom (BUnit Void)) L).
43
44 interpretation "tail abbreviation (local environment)"
45    'SnAbbr T L = (append (LBind LAtom (BPair Abbr T)) L).
46
47 interpretation "tail abstraction (local environment)"
48    'SnAbst L T = (append (LBind LAtom (BPair Abst T)) L).
49
50 definition d_appendable_sn: predicate (lenv→relation term) ≝ λR.
51                             ∀K,T1,T2. R K T1 T2 → ∀L. R (L+K) T1 T2.
52
53 (* Basic properties *********************************************************)
54
55 lemma append_atom: ∀L. (L + ⋆) = L. (**) (* () should be redundant *)
56 // qed.
57
58 (* Basic_2A1: uses: append_pair *)
59 lemma append_bind: ∀I,L,K. L+(K.ⓘ{I}) = (L+K).ⓘ{I}.
60 // qed.
61
62 lemma append_atom_sn: ∀L. ⋆ + L = L.
63 #L elim L -L //
64 #L #I >append_bind //
65 qed.
66
67 lemma append_assoc: associative … append.
68 #L1 #L2 #L3 elim L3 -L3 //
69 qed.
70
71 lemma append_shift: ∀L,K,I. L+(ⓘ{I}.K) = (L.ⓘ{I})+K.
72 #L #K #I <append_assoc //
73 qed.
74
75 (* Basic inversion lemmas ***************************************************)
76
77 lemma append_inv_atom3_sn: ∀L,K. ⋆ = L + K → ∧∧ ⋆ = L & ⋆ = K.
78 #L * /2 width=1 by conj/
79 #K #I >append_bind #H destruct
80 qed-.
81
82 lemma append_inv_bind3_sn: ∀I0,L,L0,K. L0.ⓘ{I0} = L + K →
83                            ∨∨ ∧∧ L0.ⓘ{I0} = L & ⋆ = K
84                             | ∃∃K0. K = K0.ⓘ{I0} & L0 = L + K0.
85 #I0 #L #L0 * /3 width=1 by or_introl, conj/
86 #K #I >append_bind #H destruct /3 width=3 by ex2_intro, or_intror/
87 qed-.
88
89 lemma append_inj_sn: ∀K,L1,L2. L1+K = L2+K → L1 = L2.
90 #K elim K -K //
91 #K #I #IH #L1 #L2 >append_bind #H
92 elim (destruct_lbind_lbind_aux … H) -H /2 width=1 by/ (**) (* destruct lemma needed *)
93 qed-.
94
95 (* Basic_1: uses: chead_ctail *)
96 (* Basic_2A1: uses: lpair_ltail *)
97 lemma lenv_case_tail: ∀L. L = ⋆ ∨ ∃∃K,I. L = ⓘ{I}.K.
98 #L elim L -L /2 width=1 by or_introl/
99 #L #I * [2: * ] /3 width=3 by ex1_2_intro, or_intror/
100 qed-.