[mercury-users] Confused about "undefined behaviour" of promise_only_solution

Fergus Henderson fjh at cs.mu.OZ.AU
Sat Nov 27 09:20:04 AEDT 2004


On 26-Nov-2004, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> On 26-Nov-2004, Ralph Becket <rafe at cs.mu.OZ.AU> wrote:
> > > 2) In my app the predicate of interest has many syntactically 
> > >    different, but semantically equivalent solutions.
> > >    Is is okay to use promise_only_solution within this case?
> > 
> > Ahh, it sounds as though what you want is user-defined equality.
> > User-defined equality is useful where, say, you want to represent sets
> > using unordered lists.  In this case you would like Mercury to recognise
> > the following identities: [1, 2, 3] = [1, 3, 2] = [1, 1, 3, 1, 2] = ...
> > You can do this by supplying your own equality predicate for your set
> > type.
> 
> Ralph's answer is correct, but he didn't connect the two parts of his answer.
> If your predicate has several solutions, but all the solutions are guaranteed
> to be semantically equal with respect to the equality theory you have in mind
> (just as [1, 2] = [2, 1] when representing sets with unordered lists),
> then you can use promise_only_solution on the predicate and everything
> will be fine, precisely because the solutions *are* all equal according
> to your semantic notion of equality.

Right.

> This is true even if you don't declare the type involved to have user-defined
> equality.

That may perhaps be the case for the current Mercury implementation,
but IMHO it would be unwise to rely on that remaining true for future
Mercury implementations.

-- 
Fergus Henderson                    |  "I have always known that the pursuit
                                    |  of excellence is a lethal habit"
WWW: <http://www.cs.mu.oz.au/~fjh>  |     -- the last words of T. S. Garp.
--------------------------------------------------------------------------
mercury-users mailing list
post:  mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe:   Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------



More information about the users mailing list