caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Jean-Christophe Filliatre <filliatr@lri.fr>
To: "Lukasz Stafiniak" <lukstafi@gmail.com>
Cc: "Jon Harrop" <jon@ffconsultancy.com>, caml-list@yquem.inria.fr
Subject: Re: [Caml-list] functions' recursive construction
Date: Wed, 23 May 2007 08:25:02 +0200	[thread overview]
Message-ID: <18003.56894.913446.961092@serveur9-10.lri.fr> (raw)
In-Reply-To: <4a708d20705221631x82b6e9ala0cd8b9d83baa959@mail.gmail.com>


Damien Lefortier wrote:
 > I try to do a function f which takes one integer argument and returns
 > a function g which returns its nth arguments.
 > 
 > For example f 3 gives g with let g = fun x -> fun y -> fun z -> z ;;

Lukasz Stafiniak wrote:
 > Would this function (or some approximation) be possible in Coq?

Yes, and here it is (0-based instead of 1-based as above):

======================================================================
Fixpoint t (n:nat) : Type := match n with
  | O => forall (A:Set), A -> A
  | S p => forall (A:Set), A -> t p
end.

Fixpoint f  (n:nat) : t n := 
  match n return t n with
  | O => (fun (A:Set) (x:A) => x)
  | S p => (fun (A:Set) (x:A) => f p)
end.

Eval compute in f 2.
= fun (A : Set) (_ : A) (A0 : Set) (_ : A0) (A1 : Set) (x1 : A1) => x1
     : t 2
======================================================================


-- 
Jean-Christophe


  parent reply	other threads:[~2007-05-23  6:25 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2007-05-22 23:17 Damien Lefortier
2007-05-22 23:21 ` [Caml-list] " Jon Harrop
2007-05-22 23:31   ` Lukasz Stafiniak
2007-05-22 23:32     ` Lukasz Stafiniak
2007-05-22 23:41       ` Jon Harrop
2007-05-23  6:25     ` Jean-Christophe Filliatre [this message]
2008-07-07 18:01 ` Fabrice Marchant
     [not found]   ` <a58674cc0807071304x1640d670sde3045a0920a5922@mail.gmail.com>
2008-07-07 18:28     ` Fabrice Marchant
2008-07-07 20:40       ` Jeremy Yallop
     [not found]   ` <C3DD7276-23D5-41BE-A272-7579586A5559@gmail.com>
2008-07-07 18:36     ` Fabrice Marchant
2008-07-07 20:25   ` Jeremy Yallop
2008-07-07 19:11     ` Fabrice Marchant
2008-07-07 22:48       ` asmadeus77
2008-07-08  9:24       ` Daniel Bünzli

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=18003.56894.913446.961092@serveur9-10.lri.fr \
    --to=filliatr@lri.fr \
    --cc=caml-list@yquem.inria.fr \
    --cc=jon@ffconsultancy.com \
    --cc=lukstafi@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).