Relay-Version: version B 2.10 5/3/83; site utzoo.UUCP Path: utzoo!mnetor!seismo!mcvax!enea!zyx!bd From: bd@zyx.UUCP (Bjorn Danielsson) Newsgroups: net.lang.prolog Subject: Re: fixed points Message-ID: <177@zyx.UUCP> Date: Sat, 30-Aug-86 02:48:13 EDT Article-I.D.: zyx.177 Posted: Sat Aug 30 02:48:13 1986 Date-Received: Sun, 31-Aug-86 20:00:06 EDT References: <8608250740.AA00215@ucbvax.Berkeley.EDU> Reply-To: bd@zyx.UUCP (Bjorn Danielsson) Organization: ZYX AB, Stockholm, Sweden Lines: 47 In article <8608250740.AA00215@ucbvax.Berkeley.EDU> PGW@XX.LCS.MIT.EDU (Paul G. Weiss) writes: >Ideally, I would like to find a one-clause predicate fixed/1, with the >property that fixed(Term) is true of the Term which is the clause that >defines fixed/1. I have found a solution, but it requires an extra predicate that interprets a "represented" clause and melts it into a lower level of representation. Using an extra predicate might seem like cheating, especially if you write something like: fixed(X) :- cheat(X). cheat((fixed(X) :- cheat(X))). However, the extra predicate in my solution contains no information about the problem. The program follows: fixed(X) :- Y = (-z = (fixed(quote(-x)) :- quote(-y) = build_quote(-y), -y, melt(quote(-z),quote(-x)))), Z = (fixed(-x) :- -y = quote(Y), Y, melt(-z,-x)), melt(Z,X). % melt(X,Y) interprets the representation X of a clause fragment, % and unifies Y with the most general term it represents. % -(foo) represents the variable _foo. % quote(C) represents the constant C. % build_quote(X) represents the term quote(Y), where X is a term % that represents Y. % Everything else has its usual meaning. melt(X,Y) :- melt(X,Y,_). melt(quote(X),X,_). melt(build_quote(X),quote(Y),L) :- melt(X,Y,L). melt(-X,V,L) :- member([X|V],L). melt([A|B],[X|Y],L) :- melt(A,X,L), melt(B,Y,L). melt([],[],_). melt(A,X,L) :- A=..[F|B], melt(B,Y,L), X=..[F|Y]. melt(A,A,_). member(X,[Y|Z]) :- X=Y; member(X,Z). % End of program -- Bjorn Danielsson, ZYX, +46 8 653205, ...mcvax!enea!zyx!bd