home *** CD-ROM | disk | FTP | other *** search
/ NetNews Usenet Archive 1992 #31 / NN_1992_31.iso / spool / comp / lang / prolog / 2282 < prev    next >
Encoding:
Text File  |  1992-12-21  |  2.1 KB  |  48 lines

  1. Newsgroups: comp.lang.prolog
  2. Path: sparky!uunet!paladin.american.edu!news.univie.ac.at!hp4at!mcsun!sunic!sics.se!torkel
  3. From: torkel@sics.se (Torkel Franzen)
  4. Subject: Re: Occurs check
  5. In-Reply-To: mj@cs.brown.edu's message of Mon, 21 Dec 1992 15:31:47 GMT
  6. Message-ID: <TORKEL.92Dec21175440@bast.sics.se>
  7. Sender: news@sics.se
  8. Organization: Swedish Institute of Computer Science, Kista
  9. References: <TORKEL.92Dec18231028@lludd.sics.se> <24454@alice.att.com>
  10.     <TORKEL.92Dec20104928@bast.sics.se>
  11.     <1992Dec21.153147.26177@cs.brown.edu>
  12. Date: Mon, 21 Dec 1992 16:54:40 GMT
  13. Lines: 33
  14.  
  15. In article <1992Dec21.153147.26177@cs.brown.edu> mj@cs.brown.edu 
  16. (Mark Johnson) writes:
  17.  
  18.    >This is a nice way of viewing things, but I don't know any Prolog that
  19.    >gives you all of the constraints C.  Consider the following program:
  20.    >p(a) :- q(X,X).
  21.    >q(Y, f(Y)).
  22.     ....
  23.    >That is, sicstus only returns constraints related to variables appearing
  24.    >the goal.  But the constraints that only have cyclic solutions may be
  25.    >associated with other variables.
  26.  
  27.   True; but this standard behavior can be understood from the point of view
  28. of the model.  In the theoretical model, your clauses have a canonical
  29. form
  30.  
  31.           p(X) :- X=a,q(Y,Y).
  32.           q(X,Y) :- Y=f(X).
  33.  
  34. and the Prolog execution ends with a goal X=a,Y=f(Y). Since this is a
  35. conjunction of constraints, there is nothing more for the resolution
  36. mechanism to do, and the constraint solver decides whether this is a
  37. solution to be presented to the user. Now, it's a difficult task in
  38. general for the constraint solver to massage a solution into a
  39. perspicuous human-readable form. In the present implementation of
  40. Prolog, in effect, a solution of the form C(X)&C'(Y) to a query
  41. A(X) is reduced to a simpler equivalent form C(X) - equivalent, that
  42. is, in the sense that EY(C(X)&C'(Y)) is equivalent in the constraint
  43. system to C(X). This, of course, is a good thing if the system doesn't
  44. have routines to handle the printing of C'(Y)...
  45.  
  46.   However, your example doesn't have anything to do with circular terms
  47. in particular. You might as well define q by the clause q(b,b).
  48.