[m-dev.] sequential conjunction (was: Fw: Re: Impurity annotations on clauses)

Mark Brown mark at csse.unimelb.edu.au
Tue Jan 23 00:34:38 AEDT 2007


On 22-Jan-2007, Julien Fischer <juliensf at csse.unimelb.edu.au> wrote:
> (You could also use an if-then-else to simulate
> the effect of sequential conjunction but that is ugly.)

Just to illustrate how ugly it is, consider the following typical FD
constraint program:

	post_constraints(Vars),
	label(Vars)

It is crucial that the labelling comes after all constraints have been
posted.  To do this with an if-then-else you would write:

	promise_pure
	(
		post_constraints(Vars)
	->
		label(Vars)
	;
		fail
	)

Note that the promise is required because Vars (which would include solver
variables) are used inside a negated context.  This is the dodgy part,
because in general constraining solver vars in a negated context is unsound
unless the goal is solver complete (*).  But, unless it is always satisfiable,
the goal in the condition is _not_ solver complete -- indeed the whole
purpose of doing the labelling afterwards is to turn the solver incomplete
goal into a solver complete one.

So long as the else branch always fails, this if-then-else can safely be
promised pure.  But if anyone came along later and modified the else branch,
which I imagine would be very tempting to do, the promise would in general
become a lie.  This use of if-then-else is a Bad Thing waiting to happen,
in my view.  Sequential conjunction doesn't have this problem, of course,
since there is no else branch to modify.

If anyone has any objection to adding sequential conjunction to the language,
now would be a good time to speak up.

Cheers,
Mark.

(*) A goal is "solver complete" if it always fails when the constraint store
is inconsistent.

--------------------------------------------------------------------------
mercury-developers mailing list
Post messages to:       mercury-developers at csse.unimelb.edu.au
Administrative Queries: owner-mercury-developers at csse.unimelb.edu.au
Subscriptions:          mercury-developers-request at csse.unimelb.edu.au
--------------------------------------------------------------------------



More information about the developers mailing list