aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormsozeau2006-09-28 12:51:42 +0000
committermsozeau2006-09-28 12:51:42 +0000
commit56b16f014ae9a2f06a8531eae3c86aa386fb40af (patch)
treeff7cfc3a5c175d62617dc529125159908a35977d
parentb82b06ca3346b2a766edbe607a7e139004fdcb86 (diff)
Add dependent list combinators test.
git-svn-id: svn+ssh://scm.gforge.inria.fr/svn/coq/trunk@9184 85f007b7-540e-0410-9357-904b9bb8a0f7
-rw-r--r--contrib/subtac/test/ListDep.v86
1 files changed, 86 insertions, 0 deletions
diff --git a/contrib/subtac/test/ListDep.v b/contrib/subtac/test/ListDep.v
new file mode 100644
index 0000000000..7ab720f6b6
--- /dev/null
+++ b/contrib/subtac/test/ListDep.v
@@ -0,0 +1,86 @@
+Require Import List.
+Require Import Coq.subtac.Utils.
+
+Set Implicit Arguments.
+
+Definition sub_list (A : Set) (l' l : list A) := (forall v, In v l' -> In v l) /\ length l' <= length l.
+
+Lemma sub_list_tl : forall A : Set, forall x (l l' : list A), sub_list (x :: l) l' -> sub_list l l'.
+Proof.
+ intros.
+ inversion H.
+ split.
+ intros.
+ apply H0.
+ auto with datatypes.
+ auto with arith.
+Qed.
+
+Section Map_DependentRecursor.
+ Variable U V : Set.
+ Variable l : list U.
+ Variable f : { x : U | In x l } -> V.
+
+ Program Fixpoint map_rec ( l' : list U | sub_list l' l )
+ { measure l' length } : { r : list V | length r = length l' } :=
+ match l' with
+ nil => nil
+ | cons x tl => let tl' := map_rec tl in
+ f x :: tl'
+ end.
+
+ Obligation 1.
+ intros.
+ destruct tl' ; simpl ; simpl in e.
+ subst x0 tl0.
+ rewrite <- Heql'.
+ rewrite e.
+ auto.
+ Qed.
+
+ Obligation 2.
+ simpl.
+ intros.
+ destruct l'.
+ simpl in Heql'.
+ destruct x0 ; simpl ; try discriminate.
+ inversion Heql'.
+ inversion s.
+ apply H.
+ auto with datatypes.
+ Qed.
+
+
+ Obligation 3 of map_rec.
+ simpl.
+ intros.
+ rewrite <- Heql'.
+ simpl ; auto with arith.
+ Qed.
+
+ Obligation 4.
+ simpl.
+ intros.
+ destruct l'.
+ simpl in Heql'.
+ destruct x0 ; simpl ; try discriminate.
+ inversion Heql'.
+ subst x tl.
+ apply sub_list_tl with u ; auto.
+ Qed.
+
+ Obligation 5.
+ intros.
+ rewrite <- Heql' ; auto.
+ Qed.
+
+ Program Definition map : list V := map_rec l.
+ Obligation 1.
+ split ; auto.
+ Qed.
+
+End Map_DependentRecursor.
+
+Extraction map.
+Extraction map_rec.
+