caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Gabriel Scherer <gabriel.scherer@gmail.com>
To: Martin Riener <martin.riener@inria.fr>
Cc: caml users <caml-list@inria.fr>
Subject: Re: [Caml-list] Specification of the choose function on sets
Date: Tue, 20 Jun 2017 12:52:09 -0400	[thread overview]
Message-ID: <CAPFanBGYwS4DsFBrWiZwO7mG0Z4NLvuvT4y_EacdfKA0dndTHA@mail.gmail.com> (raw)
In-Reply-To: <36cdaad0-efa4-a4f3-4d14-46985a5f1101@inria.fr>

For the record, we had the same discussion for the Batteries
library, raised by Cedric "rixed" Cellier, and we decided to
add "any" functions to the Map and Set module that drop the
requirement of being deterministic with respect to set
rebalancing, and are a bit faster. (Note that "choose" is already
relatively fast in practice as its O(log(size))).

  https://github.com/ocaml-batteries-team/batteries-included/pull/751

On Tue, Jun 20, 2017 at 11:19 AM, Martin Riener <martin.riener@inria.fr> wrote:
> Hello Bruno,
>
>
> I'm far from being an expert in ocaml, but that's my explanation so for:
> The specification comes from Hilbert's epsilon operator, which picks an
> unspecified element from a set (for details, see e.g. [1]). Since
> epsilon is a function (of the set), it must always return the same
> element. An example which comes to mind is to have a quick check for the
> inequality of sets:
>
> let ineq s1 s2 =
>  if (S.choose s1 <> S.choose s2) then
>    false
>  else
>    not (
>     (S.for_all (fun x -> S.mem x s1) s2) &&
>     (S.for_all (fun x -> S.mem x s2) s1)
>    )
>
> I hope that helps,
> cheers, Martin
>
> [1] https://plato.stanford.edu/entries/epsilon-calculus/
>
> On 06/20/2017 07:46 AM, Bruno Guillaume wrote:
>> Dear Ocamlers,
>>
>> In a context not directly related to OCaml, I want to define the semantics of a “choose” function on a set.
>> In the doc of Set.Make, for the “choose" function, it is said:
>>
>> “but equal elements will be chosen for equal sets.”
>>
>> What is the rationale behind this specification? Do you have examples where this specific requirement is needed?
>>
>> Thanks,
>>
>> Bruno
>>
>

      reply	other threads:[~2017-06-20 16:52 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-20  5:46 Bruno Guillaume
2017-06-20 15:19 ` Martin Riener
2017-06-20 16:52   ` Gabriel Scherer [this message]

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=CAPFanBGYwS4DsFBrWiZwO7mG0Z4NLvuvT4y_EacdfKA0dndTHA@mail.gmail.com \
    --to=gabriel.scherer@gmail.com \
    --cc=caml-list@inria.fr \
    --cc=martin.riener@inria.fr \
    /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).