[mercury-users] Constraints and conditionals in Mercury

Ralph Becket rafe at csse.unimelb.edu.au
Fri Apr 11 14:00:15 AEST 2008

Richard A. O'Keefe, Friday, 11 April 2008:
> I should clarify that the concern was specifically with if-then-else
> tests where the solver variables are entirely local to the test and
> do not appear in the call, so would not be visible in the type or
> mode of the predicate itself.

Ah, I understand.

> It seems possible from Ralph Beckett's
> reply (saying that "inst 'any' in the condition is noticed) that
> Mercury might *not* notice this.
> Here's an example.
> 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.  (Perhaps the programmer got it wrong.)
> What happens?
> If it's not yet satisfactory, what _will_ happen?

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.
This is definitely an awkward one.
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