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: Michiel Helvensteijn <mhelvens AT gmail.com>
  • To: Jacques-Henri Jourdan <jacques-henri.jourdan AT inria.fr>
  • Cc: Pierre Casteran <pierre.casteran AT labri.fr>, coq-club <coq-club AT inria.fr>
  • Subject: Re: [Coq-Club] Fixpoint definition
  • Date: Mon, 15 Jul 2013 22:40:59 +0200

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.

--
www.mhelvens.net



Archive powered by MHonArc 2.6.18.

Top of Page