home *** CD-ROM | disk | FTP | other *** search
- Newsgroups: comp.lang.prolog
- Path: sparky!uunet!mcsun!Germany.EU.net!ira.uka.de!chx400!bernina!neptune!nugget.inf.ethz.ch!marti
- From: marti@nugget.inf.ethz.ch (Robert Marti)
- Subject: Re: transitive and symetric relations
- Message-ID: <1992Aug14.162919.6025@neptune.inf.ethz.ch>
- Sender: news@neptune.inf.ethz.ch (Mr News)
- Nntp-Posting-Host: nugget.inf.ethz.ch
- Organization: Dept. Informatik, Swiss Federal Institute of Technology (ETH), Zurich, CH
- References: <SWK.92Aug10220513@seymour.mlb.semi.harris.com> <189@syllogi.syllogic.nl> <1992Aug13.111745.17980@odin.diku.dk> <7199@skye.ed.ac.uk>
- Date: Fri, 14 Aug 1992 16:29:19 GMT
- Lines: 52
-
- In article <7199@skye.ed.ac.uk>, ken@aiai.ed.ac.uk (Ken Johnson) writes:
- |> In article <1992Aug13.111745.17980@odin.diku.dk> torbenm@diku.dk (Torben
- |> AEgidius Mogensen) writes:
- |> # A correct formulation of the transitive clause is
- |> #
- |> # distance(X,Z,D) :-
- |> # distance_fact(X,Y,D1),
- |> # distance(Y,Z,D2),
- |> # D is D1 + D2.
- |> This may loop indefinitely.
-
- Agreed.
-
-
- |> For instance, suppose you invoked it with
- |> ?- distance(london,paris,X).
- |> when `paris' was not mentioned in any distance fact.
-
- Hardly, as seen below. (Note that since there is no distance_fact
- in the program, your precondition is fulfilled. Also, the dynamic
- declaration may not be necessary in your flavor of Prolog.)
-
- ----- Begin Included Transscript -----
- mint[254]: prolog
- SICStus 2.1 #5: Tue May 12 12:04:21 MET DST 1992
- | ?- [user].
- | :- dynamic distance_fact/3.
- | distance(X,Z,D) :-
- distance_fact(X,Y,D1),
- distance(Y,Z,D2),
- D is D1 + D2.
- | {user consulted, 40 msec 672 bytes}
-
- yes
- | ?- distance(london,paris,X).
-
- no
- | ?- ^D
- ------ End Included Transscript ------
-
- However, the goal ?- distance(london,paris,X) leads to an infinite
- loop in Prolog if you can deduce both the facts
- distance_fact(london,paris,_)
- and
- distance_fact(paris,london,_)
- from your program.
-
- --
- Robert Marti | Phone: +41 1 254 72 60
- Informationssysteme | FAX: +41 1 262 39 73
- ETH-Zentrum | E-Mail: marti@inf.ethz.ch
- CH-8092 Zurich, Switzerland |
-