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 notation "hvbox(hd break :: tl)"
20 right associative with precedence 46
23 notation "[ list0 x sep ; ]"
24 non associative with precedence 90
25 for ${fold right @'nil rec acc @{'cons $x $acc}}.
27 notation "hvbox(l1 break @ l2)"
28 right associative with precedence 47
29 for @{'append $l1 $l2 }.
31 inductive list (A:Set) : Set :=
33 | cons: A -> list A -> list A.
35 interpretation "nil" 'nil = (cic:/matita/list/list.ind#xpointer(1/1/1) _).
36 interpretation "cons" 'cons hd tl =
37 (cic:/matita/list/list.ind#xpointer(1/1/2) _ hd tl).
39 (* theorem test_notation: [O; S O; S (S O)] = O :: S O :: S (S O) :: []. *)
42 \forall A:Set.\forall l:list A.\forall a:A.
49 let rec id_list A (l: list A) on l :=
52 | (cons hd tl) => hd :: id_list A tl ].
54 let rec append A (l1: list A) l2 on l1 :=
57 | (cons hd tl) => hd :: append A tl l2 ].
59 interpretation "append" 'append l1 l2 = (cic:/matita/list/append.con _ l1 l2).
61 theorem append_nil: \forall A:Set.\forall l:list A.l @ [] = l.
70 theorem associative_append: \forall A:Set.associative (list A) (append A).
71 intros; unfold; intros.
73 simplify; reflexivity.
79 theorem cons_append_commute:
80 \forall A:Set.\forall l1,l2:list A.\forall a:A.
81 a :: (l1 @ l2) = (a :: l1) @ l2.
87 theorem nil_append_nil_both:
88 \forall A:Set.\forall l1,l2:list A.
89 l1 @ l2 = [] \to l1 = [] \land l2 = [].
95 theorem test_notation: [O; S O; S (S O)] = O :: S O :: S (S O) :: [].
99 theorem test_append: [O;O;O;O;O;O] = [O;O;O] @ [O;O] @ [O].