From matt@oracorp.com Tue Sep 18 02:23:23 2001
Received: from server20.oracorp.com (server20.oracorp.com [192.76.175.5])
	by swi.psy.uva.nl (8.11.2/8.11.2) with ESMTP id f8I0NMv13330
	for <prolog@swi.psy.uva.nl>; Tue, 18 Sep 2001 02:23:22 +0200 (MET DST)
Received: by server20.oracorp.com with Internet Mail Service (5.5.2653.19)
	id <QX1Y6HRA>; Mon, 17 Sep 2001 20:23:21 -0400
Message-ID: <60D45469A1AAD311A04C009027B6BF683869FD@server20.oracorp.com>
From: "Stillerman, Matt" <matt@oracorp.com>
To: "'Dave Schumann'" <dschuman@agouron.com>,
   Steve Prior
	 <sprior@geekster.com>
Cc: prolog@swi.psy.uva.nl
Subject: RE: [SWIPL] Getting Started with SWI
Date: Mon, 17 Sep 2001 20:23:16 -0400
MIME-Version: 1.0
X-Mailer: Internet Mail Service (5.5.2653.19)
Content-Type: text/plain;
	charset="iso-8859-1"

Steve and Dave,

Pardon me for jumping into the middle of this.  If you simply reorder the
clauses, putting the facts about friends before the recursive clause, you
will not completely fix the problem.  To see this, try reordering the
clauses and then give this query:

?- friends("sam", "joe").

You will get an infinite recursion, rather than a clean failure.  I
recommend an idiom more like this one:

?- [user].
|: friends(steve, alicja).
|: friends(alicja, tim).
|: ft(A, B) :- friends(A, B).
|: ft(A, B) :- friends(A, C), ft(C, B).
|: end_of_file.
% user compiled 0.00 sec, 908 bytes

Now, a query like

?- ft(sam, joe).

fails cleanly.  You can even do this:

?- ft(AA, BB).

AA = steve
BB = alicja ;

AA = alicja
BB = tim ;

AA = steve
BB = tim ;

No

Matt Stillerman
Odyssey Research Associates, Inc.


-----Original Message-----
From: Dave Schumann [mailto:dschuman@agouron.com]
Sent: Monday, September 17, 2001 7:38 PM
To: Steve Prior
Cc: prolog@swi.psy.uva.nl
Subject: Re: [SWIPL] Getting Started with SWI


Only the known problem of infinite recursion.  The recursive definition of
friends
appears in the database before the concrete definition.  So given the query

friends("steve", "alicja").

Prolog tries to find some Y such that friends("steve",Y) is true, and to do
that
it
tries to find some Y' such that friends("steve",Y') is true, etc etc.

--David Schumann
Pfizer, Inc.

Steve Prior wrote:

> Thanks Richard and all the others who have responded.  You have all
> been eager to help and that made me feel welcome.  I tried the [user].
> and entered the following:
>
> ?- [user].
> |: friends(X,Z):-
> |: friends(X,Y),
> |: friends(Y,Z).
> |: friends("steve","alicja").
> |: friends("alicja","tim").
> ^D
> %user compiled 0.00 sec, 676 bytes
>
> ?- friends("steve","alicja").
> ERROR: Out of local stack
> Exception: (31,742) friends([115, 116, 101, 118, 101], _G404) ?
>
> I'm using SWI-Prolog (version 4.0.9) on Windows 2000
>
> Did I step on some kind of known problem?
>
> Thanks
> Steve
>
> "Richard A. O'Keefe" wrote:
>
> > Tom Breton wrote:
> >
> >         You need to type
> >
> >                 [user].
> >
> >         before defining rules, and ^D when you're done.
> >
> > Correction.  You should type *whatever* your end-of-file key is,
> > at the beginning of a line with nothing else on it.
> > For many people, the end-of-file key is ^Z, not ^D.
> >
> > Or you can use the Prolog end-of-file convention, which is to type
> >         end_of_file.
> > and works whatever the host's end-of-file convention might be.
>
> ----------------
> * To UNSUBSCRIBE, please use the HTML form at
>
>     http://www.swi.psy.uva.nl/projects/SWI-Prolog/index.html#mailinglist
>
> or send mail to prolog-request@swi.psy.uva.nl using the Subject:
"unsubscribe"
> (without the quotes) and *no* message body.
>
> ** An ARCHIVE of this list is maintained at
>
>     http://www.swi.psy.uva.nl/projects/SWI-Prolog/mailinglist/archive/

