Prolog-style unification?
junk
junk at geekabytes.net
Sat Jun 7 16:38:40 EDT 2003
Robert Oschler wrote:
>Has anybody seen a Python module that adds Prolog-style unification (pattern
>matching) to Python? I know about PyLog and SnoPy, but that's not quite
>what I'm looking for.
>
>thx
>
>--
>Robert Oschler,
>Android Technologies, Inc.
>http://www.androidtechnologies.com
>- The home of Off-Book! (tm)
>The scene memorization tool for Actors and Actresses!
>
>
>
>
Hi Robert,
I am working on a Master's Thesis currently where this issue is of
concern. I would also like to know if there is such a module.
In the mean time, I have written my own module which does a pretty good
job of simulating Prolog style calls. Here is what my syntax looks like
right now:
import logic
Father = logic.Fact()
Father("Seth","Alex")
Father("James","Seth")
X = logic.LogicalVariable()
Y = logic.LgocialVariable()
while Father(X,Y):
print X, Y
print "--------------"
Grandfather = logic.Fact()
Grandfather(Grandfather.Grandfather, Grandfather.Grandson) (
Father(Grandfather.Grandfather, Grandfather.Son)
Father(Grandfather.Son, Grandfather.Grandson))
while Grandfather(X,Y):
print X,Y
The output of this is:
James Seth
Seth Alex
------------------
James Alex
I'm still tracking down bugs all the time, but it's getting pretty good.
Would you PLEASE let me know what you think?
-- Seth James Nielson
More information about the Python-list
mailing list