Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!das-news2.harvard.edu!news2.near.net!news.mathworks.com!europa.eng.gtefsd.com!howland.reston.ans.net!news.moneng.mei.com!uwm.edu!msunews!harbinger.cc.monash.edu.au!bunyip.cc.uq.oz.au!munnari.oz.au!cs.mu.OZ.AU!munta.cs.mu.OZ.AU!conway
From: conway@munta.cs.mu.OZ.AU (Thomas Charles CONWAY)
Subject: Re: Nondeterminism
Message-ID: <9434910.19326@mulga.cs.mu.OZ.AU>
Sender: news@cs.mu.OZ.AU
Organization: Computer Science, University of Melbourne, Australia
References: <9434021.28025@mulga.cs.mu.OZ.AU> <D0Jt09.KBy@ecrc.de>
Date: Wed, 14 Dec 1994 23:38:43 GMT
Lines: 59

thom@ecrc.de (Thom Fruehwirth) writes:

>>From conway@munta.cs.mu.OZ.AU (Thomas Charles CONWAY)
>>Subject: Re: In defense of Prolog's dynamic typing
>>Date: Tue, 6 Dec 1994 10:56:12 GMT
>>
>>Number of modes:                  2209
>>        - det:                    1858 ( 84.11%)
>>        - semidet:                 344 ( 15.57%)
>>        - nondet:                   38 (  1.72%)
>>
>
>Nondeterminism seems to be rare in logic programs. 
>
>So why don't we get rid of the overhead of global/implicit search
>by chronological backtracking in favor of local/explicit search
>constructs ?
>

Three points:

1. The program for which these stats were generated is a compiler.
As such it is not really a _search_ oriented application, so you
can expect that it doesn't make much use of nondeterminism. Also,
to simplify bootstrapping, it doesn't use any all-solutions
predicates. Using these, we might make heavier use of nondeterminism
in the future.

2. Mercury has different execution models for deterministic and
nondeterministic predicates. The model for deterministic execution
does not pay they overhead of nondeterminism, which means that
you only pay for nondeterminism when you need it.

3. We plan to implement "intelligent" backtracking which uses
compile time data dependency and mode information to avoid
backtracking into parts of the computation that did not cause
the failure. That is, in a predicate like:
p(X, Y) :-
	q(X), % nondet producer of X
	r(Y). % nondet producer of Y

if the call r(Y) fails, then retrying q(X) is not going to
have any effect on whether or not r(Y) will succeed, so we
may as well backtrack past q(X).

The bottom line is that "when she was good, she was very very good,
and when she was bad she was horrid". Nondeterminism in the right
time and place is very useful for expressing relations, but if not
managed properly it can ruin your whole day. Mercury allows the
programmer to use nondeterminism in such a way that the compiler
can check that it is not going to ruin your day.

For more information on Mercury, check Zoltan Somogyi's home page:
	http://www.cs.mu.oz.au/~zs/

Thomas
-- 
Thomas Conway                                           conway@cs.mu.oz.au
AD DEUM ET VINUM
