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 set "baseuri" "cic:/matita/list/".
16 include "logic/equality.ma".
17 include "higher_order_defs/functions.ma".
19 interpretation "leibnitz's equality" 'eq x y =
20 (cic:/matita/logic/equality/eq.ind#xpointer(1/1) _ x y).
22 notation "hvbox(hd break :: tl)"
23 right associative with precedence 46
26 notation "[ list0 x sep ; ]"
27 non associative with precedence 90
28 for ${fold right @'nil rec acc @{'cons $x $acc}}.
30 notation "hvbox(l1 break @ l2)"
31 right associative with precedence 47
32 for @{'append $l1 $l2 }.
34 inductive list (A:Set) : Set \def
36 | cons: A \to list A \to list A.
38 interpretation "nil" 'nil = (cic:/matita/list/list.ind#xpointer(1/1/1) _).
39 interpretation "cons" 'cons hd tl =
40 (cic:/matita/list/list.ind#xpointer(1/1/2) _ hd tl).
43 \forall A:Set.\forall l:list A.\forall a:A.
50 let rec id_list A (l: list A) on l \def
53 | (cons hd tl) \Rightarrow hd :: id_list A tl ].
55 let rec append A (l1: list A) l2 on l1 \def
58 | (cons hd tl) \Rightarrow hd :: append A tl l2 ].
60 interpretation "append" 'append l1 l2 = (cic:/matita/list/append.con _ l1 l2).
62 theorem append_nil: \forall A:Set.\forall l:list A.l @ [] = l.
71 theorem associative_append: \forall A:Set.associative (list A) (append A).
72 intros; unfold; intros.
74 simplify; reflexivity.
80 theorem cons_append_commute:
81 \forall A:Set.\forall l1,l2:list A.\forall a:A.
82 a :: (l1 @ l2) = (a :: l1) @ l2.
88 theorem nil_append_nil_both:
89 \forall A:Set.\forall l1,l2:list A.
90 l1 @ l2 = [] \to l1 = [] \land l2 = [].
96 theorem test_notation: [O; S O; S (S O)] = O :: S O :: S (S O) :: [].
100 theorem test_append: [O;O;O;O;O;O] = [O;O;O] @ [O;O] @ [O].