[cells-devel] Thought For Someone Who Would Use Cells to Do Prolog
Thomas F. Burdick
tfb at OCF.Berkeley.EDU
Thu May 26 18:43:47 UTC 2005
Marco Antoniotti writes:
> As an aside, any Prolog implementation needs a good unification routine.
>
> Now, you also want a good unification routine that does CL objects
> properly.
>
> So you cannot help but using the CL-UNIFICATION package from
> http://common-lisp.net/project/cl-unification
>
> I know it is a shameless plug, but you simply cannot avoid it :)
Shameless but well timed, I hadn't realized that your cl-unification
goes through slot accessors. Very nice.
Just to dispell any illusions, I'm not trying to turn Cells into a
Prolog interpreter. I kind of want a Real Constraints system, but
know the problems associated with that, so I'm just playing with
trying to mix a little LP into Cells to see if I can get something
where my code is a little clearer than what I could get otherwise.
The other motivation is that, in the past, I've had situations where I
got data out of a database, and fed it line-by-line into a c-input
until I got a consistent model, like:
(do-results (x y z) (db (generate-query a b c))
(setf (values (x obj) (y obj) (z obj))
(values x y z))
(when (model-is-good obj) (return obj)))
I'd prefer to be able to integrate this into the model, so I could
have something more like:
(defmodel my-model ()
((a :initform (c-input () ...) :accessor a)
(b :initform (c-input () ...) :accessor b)
(c :initform (c-input () ...) :accessor c)
(xyz :initform (c-generator ((it (db-query-iterator *db*
(generate-query (^a) (^b) (^c)))))
(if (more-tuples-p it)
(next it)
(fail)))
:accessor xyz)
... x y and z here depend on xyz, and if something is inconsistent in
the model, their formulas call fail instead of causing (^model-is-good)
to be nil ... ))
> On May 26, 2005, at 12:20 AM, Kenny Tilton wrote:
>
> > If your Prolog-in-CL uses slot readers/accessors, dependencies will
> > arise. So the position (or whatever GUI layout attribute you have in
> > mind) can be calculated by a cl-prolog operating over CLOS instances
> > via CLOS slot accessor GFs, and the necessary dataflow will arise
> > naturally.
Yeah, it could be that some Allegro Prolog enhancements would handle
all of this as well. But in the cases where I just want a *little*
Logic, making Cells handle it might not be a bad idea. Certainly what
I have is entertaining.
Now to look at your recent changes, and to actually restore the old
dependencies on backtracking.
More information about the cells-devel
mailing list