[net.lang.prolog] fixed points

bd@zyx.UUCP (Bjorn Danielsson) (08/30/86)

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

andrews@ubc-cs.UUCP (Jamie Andrews) (09/02/86)

>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.

In article <177@zyx.UUCP> bd@zyx.UUCP (Bjorn Danielsson) writes:
>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))).

     Actually, the original query was framed so loosely that even this
program works:

fixed(X).

     I think Paul Weiss probably wanted to say "fixed(Term) is true ONLY
of Terms which are clauses defining a predicate extensionally identical
to fixed(Term)."  Can the people who proposed solutions prove that their
solutions have this property?

--Jamie.
...!seismo!ubc-vision!ubc-cs!andrews
"Two sapphires and a couple rows of pearls"