[mercury-users] Constraints and conditionals in Mercury

Peter Schachte schachte at csse.unimelb.edu.au
Sun Apr 13 13:00:41 AEST 2008


Ralph Becket wrote:
> Richard A. O'Keefe, Friday, 11 April 2008:
>> knights_tour/1 has one argument, an integer.  It is known to be ground.
>> There is a conditional
>>
>> 	if knights_tour(N) then ... else ...
>>
>> The implementation of knights_tour/1 uses constraints *internally* to
>> determine whether there exists at least one knight's tour on an NxN
>> board or not.  Suppose that knights_tour(N) leaves some constraints
>> pending when it exits, and that for some value of N those constraints
>> are not satisfiable.
> 
> Right now: we don't catch this situation.  We have discussed the
> problem, however.  One suggestion was to look out for cases where
> a solver variable goes out of scope without having become ground
> and require some kind of promise of good behaviour from the programmer.

The problem with that is that the promise could be a lie, and there may be no
way for the caller to make it true.  I suggested there should be a way for
Mercury to force a constraint solver to either satisfy all pending
constraints if it ca, fail if it can determine they're unsatisfiable, or
throw an exception if it can't do either.  The Mercury compiler would then
force a decision in negated contexts and anywhere else it has to commit.

Having the compiler force you to promise something you don't have the power
to enforce is tantamount to saying "lie to me."

-- 
Peter Schachte              I worry that 10 or 15 years from now, [my child]
schachte at cs.mu.OZ.AU        will come to me and say 'Daddy, where were you
www.cs.mu.oz.au/~schachte/  when they took freedom of the press away from
Phone: +61 3 8344 1338      the Internet?' -- Mike Godwin
--------------------------------------------------------------------------
mercury-users mailing list
Post messages to:       mercury-users at csse.unimelb.edu.au
Administrative Queries: owner-mercury-users at csse.unimelb.edu.au
Subscriptions:          mercury-users-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the users mailing list