Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club]Problems writing programs with tactics (fwd)

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club]Problems writing programs with tactics (fwd)


chronological Thread 
  • From: Thery Laurent <thery AT ns.di.univaq.it>
  • To: coq-club AT pauillac.inria.fr
  • Subject: Re: [Coq-Club]Problems writing programs with tactics (fwd)
  • Date: Tue, 5 Dec 2006 15:40:59 +0100 (CET)
  • List-archive: <http://pauillac.inria.fr/pipermail/coq-club/>


Hi,

Definition take : forall (x:list nat) (n:nat), list nat.
intros.
induction n.

This is wrong, you should generalize x, since it is going to vary
in the recursive call.

An undocumented feature to define recursive function in proof mode
is fix. It takes as parameter the ranks o the structural argument.
On your function:

Definition take : forall (x:list nat) (n:nat), list nat.
fix 2.
intros l [| n].
exact (@nil nat).
destruct l as [|h t].
exact (@nil nat).
exact (h::take t n).
Defined.

The nice thing is now that
  Print take.
gives you the expected code

--
Laurent





Archive powered by MhonArc 2.6.16.

Top of Page