diff options
| author | mohring | 2001-04-19 14:33:41 +0000 |
|---|---|---|
| committer | mohring | 2001-04-19 14:33:41 +0000 |
| commit | c8cba24511fe5f0ffc16fd2f7d7e53c9a1a3a791 (patch) | |
| tree | 5e482efec76e091b5a42b0b0b3691b116db489fc | |
| parent | 5fb26ab8b6cce851303798fa5fdf6005b025619f (diff) | |
Ajout de fonctions proposees par Cuiht Alvarado
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@1630 85f007b7-540e-0410-9357-904b9bb8a0f7
| -rw-r--r-- | theories/Lists/PolyList.v | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/theories/Lists/PolyList.v b/theories/Lists/PolyList.v index 45ee894fa8..ed64bad707 100644 --- a/theories/Lists/PolyList.v +++ b/theories/Lists/PolyList.v @@ -407,6 +407,20 @@ Lemma nth_S_cons : Simpl; Auto. Save. +Fixpoint nth_error [l:list;n:nat] : (Exc A) := + Cases n l of + | O (cons x _) => (Value x) + | (S n) (cons _ l) => (nth_error l n) + | _ _ => Error + end. + +Definition nth_default : A -> list -> nat -> A := + [default,l,n]Cases (nth_error l n) of + | (value x) => x + | error => default + end. + + (*i Lemma nth_In : (n:nat)(l:list)(d:A)(lt n (length l))->(In (nth n l d) l). @@ -423,6 +437,20 @@ Unfold lt; Induction l; ]. i*) +(* Decidable equality on lists *) + + +Lemma list_eq_dec : ((x,y:A){x=y}+{~x=y})->(x,y:list){x=y}+{~x=y}. +Proof. + Induction x; Destruct y; Intros; Auto. + Case (H a a0); Intro e. + Case (H0 l0); Intro e'. + Left; Rewrite e; Rewrite e'; Trivial. + Right; Red; Intro. + Apply e'; Injection H1; Trivial. + Right; Red; Intro. + Apply e; Injection H1; Trivial. +Qed. (*********************************************) (* Reverse Induction Principle on Lists *) |
