[m-dev.] from [mercury-users] Re: Question regarding determinism

Fergus Henderson fjh at cs.mu.OZ.AU
Mon Aug 31 16:37:12 AEST 1998


On 30-Aug-1998, Zoltan Somogyi <zs at cs.mu.OZ.AU> wrote:
> 
> > > moddat__add_assumption(Obj, Model, [a(Obj)|Model]) :-
> > > 	list__member(o(Obj, _), Model).
> > 
> > Conjunctions get flattened before mode analysis, so that mode analysis
> > can do reordering properly.
> > 
> > A possible solution would be to make determinism analysis check not just for
> > goals (e.g. whole conjunctions) with no outputs but also for
> > subsequences of conjunctions with no outputs.
> 
> The real problem with the above code is that the conversion to
> superhomogeneous form converts
> 
>  	list__member(o(Obj, _), Model)
> 
> to
> 
> 	A = o(Obj, _B),
>  	list__member(A, Model)
> 
> Given that A is not fully ground, mode analysis then transforms this to
> 
> 	A = o(Obj, _B),
>  	( list__member(C, Model), A = C )
> 
> The determinism problem arises because the nested conjunction has an output;
> it grounds A.
> 
> Mode analysis is careful to preserve the scope over which we may want to
> commit, but the conversion to superhomogeneous form already threw away
> the scope we wanted. I think the proper fix is for this conversion to
> preserve the scope, introducing a conjunction for every atom it flattens.
> I believe this shouldn't be too expensive. What do you think, Fergus?

I agree that probably wouldn't be too expensive.  But it would inhibit some
reordering possibilities.  That might perhaps cause some problems.

There are other cases where making determinism analysis smarter would help.
For example, if the user writes

	:- mode t(in, out).
	t(X, O) :-
		p(X, Y),		% outputs `Y'
		( q(Y, Z), r(Z) ),	% outputs only `Z', which is local
		s(O).			% outputs `O'.

then they might expect that the explicit parentheses would be enough
to ensure that the compiler will prune the goal in parentheses.
But currently that isn't the case.

That's why I think it may be more better to make determinism analysis
smarter rather than changing the conversion to SHF.

-- 
Fergus Henderson <fjh at cs.mu.oz.au>  |  "I have always known that the pursuit
WWW: <http://www.cs.mu.oz.au/~fjh>  |  of excellence is a lethal habit"
PGP: finger fjh at 128.250.37.3        |     -- the last words of T. S. Garp.



More information about the developers mailing list