coq-club AT inria.fr
Subject: The Coq mailing list
List archive
- From: Pierre Boutillier <pierre.boutillier AT pps.univ-paris-diderot.fr>
- To: coq-club AT inria.fr
- Subject: Re: [Coq-Club] Tricky recursion?
- Date: Tue, 18 Mar 2014 21:27:08 +0100
Le 18 mars 2014 à 02:10, Geoff Hulette
<ghulette AT gmail.com>
a écrit :
> Is there an easy way to convince Coq to accept the following recursion?
Yes but it implies to know about the gory detail of the guard condition…
if something is a parameter (identical for all recursive calls) put it as so :
Definition sum_to (f : nat -> nat): nat -> nat :=
fix aux i :=
match i with
| O => f O
| S i' => f i + (aux i')
end.
This is not enough : O when i is O and when i is a sub term is not a sub term
… but i (that is equal to O) is so :
Definition sum_to (f : nat -> nat): nat -> nat :=
fix aux i :=
match i with
| O => f i
| S i' => f i + (aux i')
end.
is the sum_to definition that will make problem works !
> Parameter G : nat -> nat.
>
> Fixpoint problem (t : nat) : nat :=
> match t with
> | O => G O
> | S t' => sum_to t' (fun t_i => G (problem t_i))
> end.
All the best,
Pierre B.
- [Coq-Club] Tricky recursion?, Geoff Hulette, 03/18/2014
- Re: [Coq-Club] Tricky recursion?, Cedric Auger, 03/18/2014
- Re: [Coq-Club] Tricky recursion?, Pierre Boutillier, 03/18/2014
- Re: [Coq-Club] Tricky recursion?, Hugo Carvalho, 03/26/2014
- Re: [Coq-Club] Tricky recursion?, Guillaume Melquiond, 03/26/2014
- Re: [Coq-Club] Tricky recursion?, Hugo Carvalho, 03/26/2014
- Re: [Coq-Club] Tricky recursion?, Guillaume Melquiond, 03/26/2014
- Re: [Coq-Club] Tricky recursion?, Hugo Carvalho, 03/26/2014
- Re: [Coq-Club] Tricky recursion?, Xavier Leroy, 03/26/2014
- Re: [Coq-Club] Tricky recursion?, Guillaume Melquiond, 03/26/2014
- Re: [Coq-Club] Tricky recursion?, Hugo Carvalho, 03/26/2014
Archive powered by MHonArc 2.6.18.