]> matita.cs.unibo.it Git - helm.git/commitdiff
added list.ma
authorStefano Zacchiroli <zack@upsilon.cc>
Mon, 19 Sep 2005 13:38:05 +0000 (13:38 +0000)
committerStefano Zacchiroli <zack@upsilon.cc>
Mon, 19 Sep 2005 13:38:05 +0000 (13:38 +0000)
helm/matita/library/list/list.ma [new file with mode: 0644]

diff --git a/helm/matita/library/list/list.ma b/helm/matita/library/list/list.ma
new file mode 100644 (file)
index 0000000..417c88e
--- /dev/null
@@ -0,0 +1,104 @@
+(**************************************************************************)
+(*       ___                                                              *)
+(*      ||M||                                                             *)
+(*      ||A||       A project by Andrea Asperti                           *)
+(*      ||T||                                                             *)
+(*      ||I||       Developers:                                           *)
+(*      ||T||         The HELM team.                                      *)
+(*      ||A||         http://helm.cs.unibo.it                             *)
+(*      \   /                                                             *)
+(*       \ /        This file is distributed under the terms of the       *)
+(*        v         GNU General Public License Version 2                  *)
+(*                                                                        *)
+(**************************************************************************)
+
+set "baseuri" "cic:/matita/list/".
+include "logic/equality.ma".
+include "higher_order_defs/functions.ma".
+
+interpretation "leibnitz's equality" 'eq x y =
+  (cic:/matita/logic/equality/eq.ind#xpointer(1/1) _ x y).
+
+notation "hvbox(hd break :: tl)"
+  right associative with precedence 46
+  for @{'cons $hd $tl}.
+
+notation "[ list0 x sep ; ]"
+  non associative with precedence 90
+  for ${fold right @'nil rec acc @{'cons $x $acc}}.
+
+notation "hvbox(l1 break @ l2)"
+  right associative with precedence 47
+  for @{'append $l1 $l2 }.
+
+inductive list (A:Set) : Set \def
+  | nil: list A
+  | cons: A \to list A \to list A.
+
+interpretation "nil" 'nil = (cic:/matita/list/list.ind#xpointer(1/1/1) _).
+interpretation "cons" 'cons hd tl =
+  (cic:/matita/list/list.ind#xpointer(1/1/2) _ hd tl).
+
+theorem nil_cons:
+  \forall A:Set.\forall l:list A.\forall a:A.
+    a::l \neq [].
+  intros.
+  unfold; intros.
+  discriminate H.
+qed.
+
+let rec id_list A (l: list A) on l \def
+  match l with
+  [ nil \Rightarrow []
+  | (cons hd tl) \Rightarrow hd :: id_list A tl ].
+
+let rec append A (l1: list A) l2 on l1 \def
+  match l1 with
+  [ nil \Rightarrow l2
+  | (cons hd tl) \Rightarrow hd :: append A tl l2 ].
+
+interpretation "append" 'append l1 l2 = (cic:/matita/list/append.con _ l1 l2).
+
+theorem append_nil: \forall A:Set.\forall l:list A.l @ [] = l.
+  intros.
+  elim l.
+  reflexivity.
+  simplify.
+  rewrite > H.
+  reflexivity.
+qed.
+
+theorem associative_append: \forall A:Set.associative (list A) (append A).
+  intros; unfold; intros.
+  elim x.
+  simplify; reflexivity.
+  simplify.
+  rewrite > H.
+  reflexivity.
+qed.
+
+theorem cons_append_commute:
+  \forall A:Set.\forall l1,l2:list A.\forall a:A.
+    a :: (l1 @ l2) = (a :: l1) @ l2.
+  intros.
+  reflexivity.
+qed.
+
+(*
+theorem nil_append_nil_both:
+  \forall A:Set.\forall l1,l2:list A.
+    l1 @ l2 = [] \to l1 = [] \land l2 = [].
+*)
+
+(*
+include "nat/nat.ma".
+
+theorem test_notation: [O; S O; S (S O)] = O :: S O :: S (S O) :: []. 
+reflexivity.
+qed.
+
+theorem test_append: [O;O;O;O;O;O] = [O;O;O] @ [O;O] @ [O].
+simplify.
+reflexivity.
+qed.
+*)