]> matita.cs.unibo.it Git - helm.git/blob - matita/matita/contribs/lambdadelta/ground/lib/list_append.ma
update in ground
[helm.git] / matita / matita / contribs / lambdadelta / ground / lib / list_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 "ground/notation/functions/oplus_3.ma".
16 include "ground/lib/list.ma".
17
18 (* APPEND FOR LISTS *********************************************************)
19
20 rec definition list_append A (l1:list A) (l2:list A) on l1 ≝ match l1 with
21 [ list_empty       ⇒ l2
22 | list_lcons hd tl ⇒ hd ⨮ (list_append A tl l2)
23 ].
24
25 interpretation
26   "append (lists)"
27   'OPlus A l1 l2 = (list_append A l1 l2).
28
29 (* Basic constructions ******************************************************)
30
31 lemma list_append_empty_sn (A):
32       ∀l2. l2 = ⓔ ⨁{A} l2.
33 // qed.
34
35 lemma list_append_lcons_sn (A):
36       ∀a,l1,l2. a ⨮ l1 ⨁ l2 = (a⨮l1) ⨁{A} l2.
37 // qed.
38
39 (* Advanced constructions ***************************************************)
40
41 lemma list_append_empty_dx (A):
42       ∀l1. l1 = l1 ⨁{A} ⓔ.
43 #A #l1 elim l1 -l1
44 [ <list_append_empty_sn //
45 | #hd #tl #IH <list_append_lcons_sn <IH //
46 ]
47 qed.
48
49 lemma list_append_assoc (A):
50       associative … (list_append A).
51 #A #l1 elim l1 -l1
52 [ <list_append_empty_sn //
53 | #a1 #l1 #IH *
54   [ #l3 <list_append_empty_dx <list_append_empty_sn //
55   | #a2 #l2 #l3 <list_append_lcons_sn <list_append_lcons_sn <IH //
56   ]
57 ]
58 qed.