Newsgroups: comp.lang.prolog
Path: cantaloupe.srv.cs.cmu.edu!rochester!udel!news.mathworks.com!uunet!newsflash.concordia.ca!CC.UMontreal.CA!IRO.UMontreal.CA!tarau
From: tarau@IRO.UMontreal.CA (Paul Tarau)
Subject: Re: Novice prolog questions and thanks
Message-ID: <D3wny4.Cso@IRO.UMontreal.CA>
Sender: news@IRO.UMontreal.CA
Organization: Universite de Montcton, Canada
References: <3hf9m4$grt@news.irisa.fr> <D3uG6r.B2q@IRO.UMontreal.CA> <PEREIRA.95Feb12123604@radish.research.att.com>
Date: Sun, 12 Feb 1995 21:06:03 GMT
Lines: 120

In article <PEREIRA.95Feb12123604@radish.research.att.com> pereira@research.att.com writes:
>In article <D3uG6r.B2q@IRO.UMontreal.CA> tarau@IRO.UMontreal.CA (Paul Tarau) writes:

>Can you explain why you decided to appropriate -: (and :- ) for linear
>(reverse) implication, when there's the perfectly reasonable and
>standard -o notation for it? The symbol :- has never stood for a
>resource-sensitive connective in the history of Prolog. Won't the
>appropriation cause confusion and code incompatibility?
>
>>   Here is a CUT & PASTE from the BinProlog 3.30 distribution (netsurf with Mosaic
>>   for file progs/lgraph.pl on ftp://clement.info.umoncton.ca/BinProlog):
>>
>>   path(X,X,[X]).
>>   path(X,Z,[X|Xs]):-linked(X,Y),path(Y,Z,Xs).
>>
>>   linked(X,Y):-c(X,Ys),member(Y,Ys).
>>
>>   go(Xs):-
>>     c(1,[2,3]) -: c(2,[1,4]) -: c(3,[1,5]) -: c(4,[1,5]) -:
>>     path(1,5,Xs).
>>

':-' is not reverse linear implication in the example, it is 
just the ordinary Prolog connective.

For '-:' the mundane answer is that '-o' needs quoting to be
an operator in most "read.pl" based Prolog parsers. The same
seems to be the case with C-Prolog. The following happens
in Sicstus Prolog (as it does in BinProlog):

| ?- op(400, xfy, '-o').

yes
| ?- display(a -o b).
{SYNTAX ERROR: in lines 16-17}
** , or ) expected in arguments **
?- display ( a - o 
** here **
b ) . 

Of course, the following is OK but I will leave to Haskell
programmers the joy of having to (back-)quote operators:

| ?- display(a '-o' b).
-o(a,b)
yes

I've seen people in Rennes using '-<>' which looks close to '-o', and
that was the previous notation for BinProlog.  As '-<>' is not exactly 
'-o' I have decided to use '-:' which is easier to remember :-), after
noticing that BinProlog's '-:' was not exactly the same thing as
Lolli's '-o'.

An important difference is that '-o' requires to consume
all your assumptions, otherwise the proof will fail. I found this
rather counter-intuitive and changed the semantics: it is OK to leave
unconsumed assumptions with BinProlog's '-:'. Pros and cons for this
behavior are welcome.

% Lolli version 0.701

?- a(1) -o a(2) -o a(X).
no

?- a(1)-o a(2) -o (a(X),a(Y)).
X_3 <- 2 ,
Y_2 <- 1;
X_3 <- 1 ,
Y_2 <- 2;
no

% BinProlog 3.30

?- a(1) -: a(2) -: a(X).

X=1;

X=2;

no

?- a(1) -: a(2) -: (a(X),a(Y)).
X=1,
Y=2;

X=2,
Y=1;

no

Although by no means the reverse ':-' is a resource conscious
operation (as we use each time a new logical copy of a clause),
half of the metaphor is still true: we have a kind of
implication in both cases and we have also some
kind of defining process (static for :-, dynamic for -:).
Again, notations are almost always imperfect descriptions
of meanings and a metaphor is always centered around
some essential attribute while ignoring others.

>This will certainly confuse novices (and not so novices).  Most of the
>program seems standard Prolog, but it depends crucially on the linear
>interpretation of :-.

>Trying out new logic programming ideas is good. Confusing matters by
>using old names for the new ideas is not.

I do not have strong opinions about what's more appropriate in this
case, after all. If a large number of `non-linear' users of '-:' will
ask, I am ready to go back to either -<> or -o. Of course, by
`non-linear users' I mean people who are actually `using' linear
implication in their programs more than once :-).

For `linear' users of this notation it is always possible to define:

:-op(950, xfy, '-o').

H '-o' C :- H -: C.

Paul tarau

