diff options
| author | msozeau | 2007-01-24 14:23:23 +0000 |
|---|---|---|
| committer | msozeau | 2007-01-24 14:23:23 +0000 |
| commit | c155e42cdd1dd70b9e20243a6dc599ec653aef7a (patch) | |
| tree | 38b5b2100373b3e94b11c7b6f7ebed987ce20fc7 /contrib/subtac/test | |
| parent | baa006bc1d14f77fc8477cff25f22d5074b1f991 (diff) | |
Update some tests and fix section bug.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@9530 85f007b7-540e-0410-9357-904b9bb8a0f7
Diffstat (limited to 'contrib/subtac/test')
| -rw-r--r-- | contrib/subtac/test/ListsTest.v | 149 | ||||
| -rw-r--r-- | contrib/subtac/test/take.v | 33 |
2 files changed, 87 insertions, 95 deletions
diff --git a/contrib/subtac/test/ListsTest.v b/contrib/subtac/test/ListsTest.v index 8429c26708..fb8b34eedd 100644 --- a/contrib/subtac/test/ListsTest.v +++ b/contrib/subtac/test/ListsTest.v @@ -1,95 +1,82 @@ +(* -*- coq-prog-args: ("-emacs-U" "-debug") -*- *) Require Import Coq.subtac.Utils. Require Import List. -Variable A : Set. - -Program Definition myhd : forall { l : list A | length l <> 0 }, A := - fun l => - match `l with - | nil => _ - | hd :: tl => hd - end. -Proof. - destruct l ; simpl ; intro H. - rewrite H in n ; intuition. -Defined. +Set Implicit Arguments. +Section Accessors. + Variable A : Set. -Extraction myhd. -Extraction Inline proj1_sig. + Program Definition myhd : forall { l : list A | length l <> 0 }, A := + fun l => + match l with + | nil => ! + | hd :: tl => hd + end. -Program Definition mytail : forall { l : list A | length l <> 0 }, list A := - fun l => + Program Definition mytail (l : list A | length l <> 0) : list A := match l with - | nil => _ - | hd :: tl => tl + | nil => ! + | hd :: tl => tl end. -Proof. -destruct l ; simpl ; intro H ; rewrite H in n ; intuition. -Defined. - -Extraction mytail. - -Variable a : A. - -Program Definition test_hd : A := myhd (cons a nil). -Proof. -simpl ; auto. -Defined. +End Accessors. -Extraction test_hd. +Program Definition test_hd : nat := myhd (cons 1 nil). +(*Eval compute in test_hd*) (*Program Definition test_tail : list A := mytail nil.*) +Section app. + Variable A : Set. + Program Fixpoint app (l : list A) (l' : list A) { struct l } : + { r : list A | length r = length l + length l' } := + match l with + | nil => l' + | hd :: tl => hd :: (tl ++ l') + end + where "x ++ y" := (app x y). + + Next Obligation. + intros. + destruct_call app ; subtac_simpl. + Defined. + + Program Lemma app_id_l : forall l : list A, l = nil ++ l. + Proof. + simpl ; auto. + Qed. + + Program Lemma app_id_r : forall l : list A, l = l ++ nil. + Proof. + induction l ; simpl ; auto. + rewrite <- IHl ; auto. + Qed. + +End app. + +Extraction app. + +Section Nth. + + Variable A : Set. + + Program Fixpoint nth (l : list A) (n : nat | n < length l) { struct l } : A := + match n, l with + | 0, hd :: _ => hd + | S n', _ :: tl => nth tl n' + | _, nil => ! + end. - - -Program Fixpoint append (l : list A) (l' : list A) { struct l } : - { r : list A | length r = length l + length l' } := - match l with - | nil => l' - | hd :: tl => hd :: (append tl l') - end. -subst ; auto. -simpl ; rewrite (subset_simpl (append tl0 l')). -simpl ; subst. -simpl ; auto. -Defined. - -Extraction append. - - -Program Lemma append_app' : forall l : list A, l = append nil l. -Proof. -simpl ; auto. -Qed. - -Program Lemma append_app : forall l : list A, l = append l nil. -Proof. -intros. -induction l ; simpl ; auto. -simpl in IHl. -rewrite <- IHl. -reflexivity. -Qed. - - - - - - - - - - - - - - - - - - - - + Next Obligation. + Proof. + intros. + simpl in * ; auto with arith. + Defined. + + Next Obligation. + Proof. + intros. + inversion l0. + Defined. +End Nth. diff --git a/contrib/subtac/test/take.v b/contrib/subtac/test/take.v index f73507d2f5..87ab47d639 100644 --- a/contrib/subtac/test/take.v +++ b/contrib/subtac/test/take.v @@ -1,33 +1,38 @@ +(* -*- coq-prog-args: ("-emacs-U" "-debug") -*- *) Require Import JMeq. Require Import List. Require Import Coq.subtac.Utils. +Set Implicit Arguments. + Program Fixpoint take (A : Set) (l : list A) (n : nat | n <= length l) { struct l } : { l' : list A | length l' = n } := match n with | 0 => nil | S p => match l with - | cons hd tl => let rest := take A tl p in cons hd rest - | nil => _ + | cons hd tl => let rest := take tl p in cons hd rest + | nil => ! end end. Require Import Omega. -Obligations. - -Solve Obligations using (subtac_simpl ; subst ; auto with arith). - -Obligations. +Next Obligation. + intros. + simpl in l0. + apply le_S_n ; exact l0. +Defined. -Obligation 3. - destruct_call take ; subtac_simpl ; subst ; auto. +Next Obligation. + intros. + destruct_call take ; subtac_simpl. Defined. -Obligation 4. - subst l x. - simpl in l0. - absurd (S p <= 0) ; omega. +Next Obligation. + intros. + inversion l0. Defined. -Extraction take. + + + |
