X-Git-Url: http://matita.cs.unibo.it/gitweb/?a=blobdiff_plain;ds=sidebyside;f=matita%2Flibrary%2Flist%2Flist.ma;h=f832d502002f3c9a59855a13acea0ac966fa69bc;hb=a5bfa65b18a876fca982270f673c686a7d124f65;hp=bb341d245fad82a43657e4e427956968fac8b3c2;hpb=b2788a5ed06fa093c607ea3f5a29058845e1f9c6;p=helm.git diff --git a/matita/library/list/list.ma b/matita/library/list/list.ma index bb341d245..f832d5020 100644 --- a/matita/library/list/list.ma +++ b/matita/library/list/list.ma @@ -16,7 +16,7 @@ set "baseuri" "cic:/matita/list/". include "logic/equality.ma". include "higher_order_defs/functions.ma". -inductive list (A:Set) : Set := +inductive list (A:Type) : Type := | nil: list A | cons: A -> list A -> list A. @@ -39,12 +39,12 @@ interpretation "cons" 'cons 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. + \forall A:Type.\forall l:list A.\forall a:A. a::l <> []. intros; unfold Not; intros; - discriminate H. + destruct H. qed. let rec id_list A (l: list A) on l := @@ -57,14 +57,14 @@ let rec append A (l1: list A) l2 on l1 := [ nil => l2 | (cons hd tl) => hd :: append A tl l2 ]. -definition tail := \lambda A:Set. \lambda l: list A. +definition tail := \lambda A:Type. \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. +theorem append_nil: \forall A:Type.\forall l:list A.l @ [] = l. intros; elim l; [ reflexivity; @@ -74,7 +74,7 @@ theorem append_nil: \forall A:Set.\forall l:list A.l @ [] = l. ] qed. -theorem associative_append: \forall A:Set.associative (list A) (append A). +theorem associative_append: \forall A:Type.associative (list A) (append A). intros; unfold; intros; elim x; [ simplify; @@ -86,13 +86,13 @@ theorem associative_append: \forall A:Set.associative (list A) (append A). qed. theorem cons_append_commute: - \forall A:Set.\forall l1,l2:list A.\forall a:A. + \forall A:Type.\forall l1,l2:list A.\forall a:A. a :: (l1 @ l2) = (a :: l1) @ l2. intros; reflexivity; qed. -inductive permutation (A:Set) : list A -> list A -> Prop \def +inductive permutation (A:Type) : list A -> list A -> Prop \def | refl : \forall l:list A. permutation ? l l | swap : \forall l:list A. \forall x,y:A. permutation ? (x :: y :: l) (y :: x :: l) @@ -117,7 +117,7 @@ theorem tmp : permutation nat (x1 :: x2 :: x3 :: []) (x1 :: x3 :: x2 :: []). (* theorem nil_append_nil_both: - \forall A:Set.\forall l1,l2:list A. + \forall A:Type.\forall l1,l2:list A. l1 @ l2 = [] \to l1 = [] \land l2 = []. *) @@ -133,3 +133,13 @@ simplify. reflexivity. qed. *) + +let rec nth (A:Type) l d n on n ≝ + match n with + [ O ⇒ + match l with + [ nil ⇒ d + | cons (x : A) _ ⇒ x + ] + | S n' ⇒ nth A (tail ? l) d n' + ].