Skip to Content.
Sympa Menu

coq-club - Re: [Coq-Club] Fixpoint definition

coq-club AT inria.fr

Subject: The Coq mailing list

List archive

Re: [Coq-Club] Fixpoint definition


Chronological Thread 
  • From: Jacques-Henri Jourdan <jacques-henri.jourdan AT inria.fr>
  • To: Michiel Helvensteijn <mhelvens AT gmail.com>
  • Cc: Pierre Casteran <pierre.casteran AT labri.fr>, coq-club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Fixpoint definition
  • Date: Tue, 16 Jul 2013 11:19:24 +0200 (CEST)



----- Mail original -----
> De: "Michiel Helvensteijn"
> <mhelvens AT gmail.com>
> À: "Jacques-Henri Jourdan"
> <jacques-henri.jourdan AT inria.fr>
> Cc: "Pierre Casteran"
> <pierre.casteran AT labri.fr>,
> "coq-club"
> <coq-club AT inria.fr>
> Envoyé: Lundi 15 Juillet 2013 22:40:59
> Objet: Re: [Coq-Club] Fixpoint definition
>
> On Mon, Jul 15, 2013 at 10:37 PM, Michiel Helvensteijn
> <mhelvens AT gmail.com>
> wrote:
>
> >> Well, but it does works when it is through pair then lst, but not
> >> through lst then pair, which is really confusing.
> >
> > As I understand it, your first example works because it
> > structurally
> > decreases on a `lst` parameter. A `lst` can "contain itself" by
> > definition.
> >
> > Your second example tries to decrease on a `pair`. As far as the
> > type
> > `pair` is concerned, the actual parameter is not structurally
> > smaller
> > than the formal parameter, it's just different.
>
> With that in mind, what about the following solution?
>
> Inductive lst :=
> | Nil | Cons : nat_lst_pair -> lst
> with nat_lst_pair :=
> | Both: nat -> lst -> nat_lst_pair.
>
> Fixpoint test2 p :=
> match p with
> | Both _ Nil => 0
> | Both _ (Cons l) => test2 l
> end.
>

This does work, but breaks the modularity of the pair type.

Thanks !

> --
> www.mhelvens.net
>



Archive powered by MHonArc 2.6.18.

Top of Page