Article View: comp.lang.prolog
Article #2150Re: Occurs check
From: Torkel Franzen
Date: Mon, 21 Dec 1992 16:54
Date: Mon, 21 Dec 1992 16:54
33 lines
2173 bytes
2173 bytes
In article <1992Dec21.153147.26177@cs.brown.edu> mj@cs.brown.edu
(Mark Johnson) writes:
>This is a nice way of viewing things, but I don't know any Prolog that
>gives you all of the constraints C. Consider the following program:
>p(a) :- q(X,X).
>q(Y, f(Y)).
....
>That is, sicstus only returns constraints related to variables appearing
>the goal. But the constraints that only have cyclic solutions may be
>associated with other variables.
True; but this standard behavior can be understood from the point of view
of the model. In the theoretical model, your clauses have a canonical
form
p(X) :- X=a,q(Y,Y).
q(X,Y) :- Y=f(X).
and the Prolog execution ends with a goal X=a,Y=f(Y). Since this is a
conjunction of constraints, there is nothing more for the resolution
mechanism to do, and the constraint solver decides whether this is a
solution to be presented to the user. Now, it's a difficult task in
general for the constraint solver to massage a solution into a
perspicuous human-readable form. In the present implementation of
Prolog, in effect, a solution of the form C(X)&C'(Y) to a query
A(X) is reduced to a simpler equivalent form C(X) - equivalent, that
is, in the sense that EY(C(X)&C'(Y)) is equivalent in the constraint
system to C(X). This, of course, is a good thing if the system doesn't
have routines to handle the printing of C'(Y)...
However, your example doesn't have anything to do with circular terms
in particular. You might as well define q by the clause q(b,b).
Technical Details
Message-ID:
<TORKEL.92Dec21175440@bast.sics.se>Path:
arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!sunic!sics.se!torkelReferences:
<TORKEL.92Dec18231028@lludd.sics.se> <24454@alice.att.com> <TORKEL.92Dec20104928@bast.sics.se> <1992Dec21.153147.26177@cs.brown.edu>Show Full Headers
Complete Article Headers
Newsgroups: comp.lang.prolog Path: arc1-ca.pugleaf.net!sparky!uunet!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!sunic!sics.se!torkel From: torkel@sics.se (Torkel Franzen) Subject: Re: Occurs check In-Reply-To: mj@cs.brown.edu's message of Mon, 21 Dec 1992 15:31:47 GMT Message-ID: <TORKEL.92Dec21175440@bast.sics.se> Sender: news@sics.se Organization: Swedish Institute of Computer Science, Kista References: <TORKEL.92Dec18231028@lludd.sics.se> <24454@alice.att.com> <TORKEL.92Dec20104928@bast.sics.se> <1992Dec21.153147.26177@cs.brown.edu> Date: Mon, 21 Dec 1992 16:54:40 GMT Lines: 33