[mercury-users] Constraints and conditionals in Mercury

Mark Brown mark at csse.unimelb.edu.au
Mon Apr 14 12:10:31 AEST 2008

On 11-Apr-2008, Richard A. O'Keefe <ok at cs.otago.ac.nz> wrote:
> 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.  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?

As Ralph says, the problem is with variables going out of scope.  Here's
another example:

	some [A, B, C] (
		all_different([A, B, C])

This is likely to succeed even though there does not exist any A, B, C
satisfying the conjunction.  As the constraint programmers would say, the
goal is not "solver complete".


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