X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;f=helm%2Fmatita%2Flibrary%2Flist%2Flist.ma;h=ffa2c8ef9ac106c007f701cef1cf21b589f51a19;hb=112afe13b5aef27425d1a0bc9c71a70b491069bf;hp=0b7340d051ce5fc1f34e4f5480bea986df6c5247;hpb=2826aed999b30a6f53978fe457c1e5f3587ac6d6;p=helm.git diff --git a/helm/matita/library/list/list.ma b/helm/matita/library/list/list.ma index 0b7340d05..ffa2c8ef9 100644 --- a/helm/matita/library/list/list.ma +++ b/helm/matita/library/list/list.ma @@ -16,6 +16,10 @@ set "baseuri" "cic:/matita/list/". include "logic/equality.ma". include "higher_order_defs/functions.ma". +inductive list (A:Set) : Set := + | nil: list A + | cons: A -> list A -> list A. + notation "hvbox(hd break :: tl)" right associative with precedence 46 for @{'cons $hd $tl}. @@ -28,57 +32,64 @@ 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 test_notation: [O; S O; S (S O)] = O :: S O :: S (S O) :: []. *) + theorem nil_cons: \forall A:Set.\forall l:list A.\forall a:A. - a::l \neq []. - intros. - unfold; intros. + a::l <> []. + intros; + unfold Not; + intros; discriminate H. qed. -let rec id_list A (l: list A) on l \def +let rec id_list A (l: list A) on l := match l with - [ nil \Rightarrow [] - | (cons hd tl) \Rightarrow hd :: id_list A tl ]. + [ nil => [] + | (cons hd tl) => hd :: id_list A tl ]. -let rec append A (l1: list A) l2 on l1 \def +let rec append A (l1: list A) l2 on l1 := match l1 with - [ nil \Rightarrow l2 - | (cons hd tl) \Rightarrow hd :: append A tl l2 ]. + [ nil => l2 + | (cons hd tl) => hd :: append A tl l2 ]. + +definition tail := \lambda A:Set. \lambda l: list A. + match l with + [ nil => [] + | (cons hd tl) => tl]. 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. + 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. + 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. + intros; + reflexivity; qed. (*