From: Todd Pierce
Subject: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <b95cb1a3.0408171241.afb97e9@posting.google.com>
Hello everybody, 

Does anybody have a suggestion for a small and fast implementation of
Prolog written in Common Lisp?

Basically, I just want to extend the functionality of my Lisp programs
with some Prolog capabilities.  I don't need anything very
full-featured, and something that is commonly used, updated and
documented would be ideal.

Thanks, 

-Todd

From: Cesar Rabak
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <41227A66.4060606@acm.org>
Todd Pierce escreveu:
 > Hello everybody,
 >
 > Does anybody have a suggestion for a small and fast implementation of
 >  Prolog written in Common Lisp?
 >
 > Basically, I just want to extend the functionality of my Lisp
 > programs with some Prolog capabilities.  I don't need anything very
 > full-featured, and something that is commonly used, updated and
 > documented would be ideal.
 >
Humm. . . my suspectmeter(TM) calibration date is somewhat due, but it 
is pointing there must some kind of homework involving the 
implementation of a "small and fast Prolog" in CL.

LOL

--
Cesar Rabak
From: Thomas Schilling
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <opscwfk3j7trs3c0@news.CIS.DFN.DE>
Todd Pierce <···········@hotmail.com> wrote:

> Hello everybody,
>
> Does anybody have a suggestion for a small and fast implementation of
> Prolog written in Common Lisp?
>
> Basically, I just want to extend the functionality of my Lisp programs
> with some Prolog capabilities.  I don't need anything very
> full-featured, and something that is commonly used, updated and
> documented would be ideal.
>
> Thanks,
>
> -Todd

Hm first an emulator, now small and fast?

I know of two well-documented ones:

  Peter Norvig's[1] and Paul Graham's[2] both are available online. The 
first as real source and compiles to full lisp (of course seemlessly), the 
latter only in the book.

[1] "Paradigms of Artificial Intelligence Programming" by Peter Norvig
[2] "On Lisp" by Paul Graham
please ask google for the urls
From: Todd Pierce
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <b95cb1a3.0408172110.71d748ff@posting.google.com>
Thomas,

> I know of two well-documented ones:
> Peter Norvig's[1] and Paul Graham's[2] both are available online. 

Cool.  Thanks for the tip.  For those reading this, I did find the
URLs for these and they are:

http://www.ncst.ernet.in/education/apgdst/aifac/resources/Norvig/
(not the original site, but has some example files)
and
http://www-2.cs.cmu.edu/afs/cs/project/ai-repository/ai/lang/lisp/bookcode/graham/0.html
(or in other words, at the CMU AI repository)
respectively.

I didn't see any documentation on them on the Web, but I didn't look
too hard yet.

One interesting thing to note for whomever is interested, it appears
Allegro has based their Prolog emulator they created on Norvig's code.

Anyways, it will still be a bit before I take the plunge and start
coding against one of these, so if anybody has ideas, I'm all ears.

-T
From: Steven M. Haflich
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <41250287.3020605@alum.mit.edu>
Todd Pierce wrote:

> One interesting thing to note for whomever is interested, it appears
> Allegro has based their Prolog emulator they created on Norvig's code.

I am greatly perplexed by these two recent threads about Prolog emulators.
What is a Prolog >>Emulator<<?  How does it differ from a Prolog implementation?
And how do these differ from a Prolog HyperFramulator?
From: mikel evins
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <N5aVc.4737$QJ3.380@newssvr21.news.prodigy.com>
Steven M. Haflich wrote:
> Todd Pierce wrote:
> 
>> One interesting thing to note for whomever is interested, it appears
>> Allegro has based their Prolog emulator they created on Norvig's code.
> 
> 
> I am greatly perplexed by these two recent threads about Prolog emulators.
> What is a Prolog >>Emulator<<?  How does it differ from a Prolog 
> implementation?
> And how do these differ from a Prolog HyperFramulator?

The questions seem to be about Prolog implementations that are embedded 
in Lisp.
From: Cesar Rabak
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <41254D03.20007@acm.org>
mikel evins escreveu:
> Steven M. Haflich wrote:
> 
>> Todd Pierce wrote:
>>
>>> One interesting thing to note for whomever is interested, it appears
>>> Allegro has based their Prolog emulator they created on Norvig's code.
>>
>>
>>
>> I am greatly perplexed by these two recent threads about Prolog 
>> emulators.
>> What is a Prolog >>Emulator<<?  How does it differ from a Prolog 
>> implementation?
>> And how do these differ from a Prolog HyperFramulator?
> 
> 
> The questions seem to be about Prolog implementations that are embedded 
> in Lisp.

Yes. Todd's question seems to be why a Prolog implementation written in 
(say) C is not an emulator either or why a Prolog emulator written in 
Lisp cannot be called an implementation.
From: Björn Lindberg
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <hcs1xi2ez2z.fsf@my.nada.kth.se>
Cesar Rabak <······@acm.org> writes:

> mikel evins escreveu:
> > Steven M. Haflich wrote:
> >
> >> Todd Pierce wrote:
> >>
> >>> One interesting thing to note for whomever is interested, it appears
> >>> Allegro has based their Prolog emulator they created on Norvig's code.
> >>
> >>
> >>
> >> I am greatly perplexed by these two recent threads about Prolog
> >> emulators.
> >> What is a Prolog >>Emulator<<?  How does it differ from a Prolog
> >> implementation?
> >> And how do these differ from a Prolog HyperFramulator?
> > The questions seem to be about Prolog implementations that are
> > embedded in Lisp.
> 
> Yes. Todd's question seems to be why a Prolog implementation written
> in (say) C is not an emulator either or why a Prolog emulator written
> in Lisp cannot be called an implementation.

Perhaps because the Prolog emulators exist within Lisp, so that you
can use all of lisp alongside it. But I agree that "emulator"
connotates something less than the real thing, whereas the
Prolog-in-lisps might be more than the real thing.


Bj�rn
From: Todd Pierce
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <b95cb1a3.0408201233.3ab37260@posting.google.com>
Guys, 

> > Yes. Todd's question seems to be why a Prolog implementation written
> > in (say) C is not an emulator either or why a Prolog emulator written
> > in Lisp cannot be called an implementation.
> 
> Perhaps because the Prolog emulators exist within Lisp, so that you
> can use all of lisp alongside it. But I agree that "emulator"
> connotates something less than the real thing, whereas the
> Prolog-in-lisps might be more than the real thing.

I didn't mean to throw you into a semantic tailspin.  I guess the
important thing is that you understand what I'm talking about.  And
Bjorn, you do bring up the interesting point that I do aim to have all
of the functionality of Lisp at the same time.  Actually, I wonder why
anybody would want to use plain Prolog if all of these implementations
in Lisp are available.

-Todd
From: Fred Gilham
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <u7acwp1gd3.fsf@snapdragon.csl.sri.com>
···········@hotmail.com (Todd Pierce) writes:

> Actually, I wonder why anybody would want to use plain Prolog if all
> of these implementations in Lisp are available.

Most of the stand-alone prolog environments seem to be faster than the
embedded lisp ones.

-- 
Fred Gilham                                       ······@csl.sri.com
The best way to understand the difference between a true right and a
falsely claimed right is that a true right does not compel anyone else
to do anything except leave us alone.                 -- Charley Reese
From: mikel evins
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <UixVc.1127$Rp6.22@newssvr14.news.prodigy.com>
Fred Gilham wrote:
> ···········@hotmail.com (Todd Pierce) writes:
> 
> 
>>Actually, I wonder why anybody would want to use plain Prolog if all
>>of these implementations in Lisp are available.
> 
> 
> Most of the stand-alone prolog environments seem to be faster than the
> embedded lisp ones.
> 

Nowadays full Prolog implementations mostly seem to compile to some 
version or other of the Warren Abstract Machine model before either 
interpreting or further compiling down to native code. The WAM produces 
good performance, but its design is rather nonobvious, and figuring out 
how to implement it is kind of a significant undertaking. It's quite a 
bit easier to implement more naive prolog interpreters and compilers in 
a Lisp environment than to learn how the WAM works before implementing.
From: Nick Lacey
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <7jrrx8ys.fsf@pobox.com>
Fred Gilham <······@snapdragon.csl.sri.com> writes:

> ···········@hotmail.com (Todd Pierce) writes:
>
>> Actually, I wonder why anybody would want to use plain Prolog if all
>> of these implementations in Lisp are available.
>
> Most of the stand-alone prolog environments seem to be faster than the
> embedded lisp ones.

IMHO, "prolog running in lisp" isn't quite as prolog-like as prolog-
running-in-prolog. You get some very nice libraries in Sicstus and SWI
Prolog (possibly others), which would be fiddly to use in lisp, as
well as nice debugging tools, etc.

Also, it's just as easy to implement a naive lisp in prolog, as it is
to implement a naive prolog in lisp. As far as I'm concerned they both
have their place in the world.

Nick
From: Espen Vestre
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <kwbrh2cn47.fsf@merced.netfonds.no>
Nick Lacey <··········@pobox.com> writes:

> Also, it's just as easy to implement a naive lisp in prolog, as it is
> to implement a naive prolog in lisp. As far as I'm concerned they both
> have their place in the world.

Sure. But it's not quite uncommon to have some pieces of software in
lisp and some in prolog and a need to combine them, and it's natural
to do the integration from lisp, since IMHO Common Lisp is better for
general-purpose programming than Prolog.

Since the prologs-in-lisp are rather toy-like compared to the really
good prologs, running _both_ may be the best option for some users.
One could always use socket communication between them.

(my first exposure to lisp programming was actually doing FLI from 
 Prolog  :-) 
 I used Xerox Quintus Prolog on a Xerox Lisp Machine and needed to
 do some stuff in Interlisp that wasn't supported by Prolog, and
 there was a decent FLI to lisp.)
-- 
  (espen)
From: Cesar Rabak
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <4129D90F.1000304@acm.org>
Espen Vestre escreveu:
 > Nick Lacey <··········@pobox.com> writes:
 >
 >
 > Since the prologs-in-lisp are rather toy-like compared to the really

I would say the tentative converse as well. . . and

 > good prologs, running _both_ may be the best option for some users.
 > One could always use socket communication between them.
 >

I second this approach and would dare to add that for completness we
whould think of complementing it with a portable GUI (my choice is Tk).


BUT. . . then for a really useful model we would need to sit and create
means of portably exchange data between the modules written in the 
different languages ;-(

<sigh>

OK. World is not perfect :-D
</sigh>

--
Cesar Rabak
From: Christopher Browne
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <2ou7k5FeultsU1@uni-berlin.de>
Oops! Cesar Rabak <······@acm.org> was seen spray-painting on a wall:
> Espen Vestre escreveu:
>  > Nick Lacey <··········@pobox.com> writes:
>  >
>  >
>  > Since the prologs-in-lisp are rather toy-like compared to the really
>
> I would say the tentative converse as well. . . and
>
>  > good prologs, running _both_ may be the best option for some users.
>  > One could always use socket communication between them.
>  >
>
> I second this approach and would dare to add that for completness we
> whould think of complementing it with a portable GUI (my choice is Tk).
>
>
> BUT. . . then for a really useful model we would need to sit and create
> means of portably exchange data between the modules written in the
> different languages ;-(

Well, there's precedent for this sort of thing.

<http://bedevere.sourceforge.net/>

Bedevere is a SWIG wrapper for GNU Prolog, pointedly permitting the
gentle Python user to throw Prolog rules over the wall and get answers
back.
-- 
output = reverse("gro.mca" ·@" "enworbbc")
http://www3.sympatico.ca/cbbrowne/linuxdistributions.html
Mary had a little lambda
A sheep she couldn't clone
And every where that lambda went
Her calculus got blown
From: Christopher Browne
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <2ot808Feem6uU1@uni-berlin.de>
Oops! Cesar Rabak <······@acm.org> was seen spray-painting on a wall:
> Yes. Todd's question seems to be why a Prolog implementation written
> in (say) C is not an emulator either or why a Prolog emulator
> written in Lisp cannot be called an implementation.

The thing about both of these "chunks of code" is that neither are
intended as full implementations of Prolog.  They don't comply with
the ISO standard; they don't have the "fullness" of Prolog syntax.

What they really represent are embeddings of _part_ of Prolog into a
Lisp system.

That's pretty different from SWI-Prolog or GNU-Prolog, both of which
implement WAMs (Warren Abstract Machines) with "real" Prolog syntax.

I can't see it being impossible to implement a "full-fledged" Prolog
in Lisp; it may even have been done.  But these systems _aren't_
full-bore Prolog systems.
-- 
(reverse (concatenate 'string "gro.gultn" ·@" "enworbbc"))
http://www.ntlug.org/~cbbrowne/emacs.html
"well, take it from an old hand: the only reason it would be easier
to program in C is that you can't easily express complex  problems
in C, so you don't."                -- Erik Naggum, comp.lang.lisp
From: Todd Pierce
Subject: Re: Small, Fast Prolog in Lisp?
Date: 
Message-ID: <b95cb1a3.0408271703.7ce73c8e@posting.google.com>
Ladies and Gentlemen, 

I have found something of a hack that might work, and I'm
experimenting with it.  I'm putting a book in my pants before you even
start to spank me.

It's the example code for a tiny prolog interpreter provided with
XLISP.  Here are the comments from the code:

;; The following is a tiny Prolog interpreter in MacLisp
;; written by Ken Kahn and modified for XLISP by David Betz.
;; It was inspired by other tiny Lisp-based Prologs of
;; Par Emanuelson and Martin Nilsson.
;; There are no side-effects anywhere in the implementation.
;; Though it is VERY slow of course.

I have already modified it to function as... well... a function,
rather than as a stand-alone application, and it gives great results. 
Of course, I don't want to stop you people from thinking along these
lines (I'm documenting all of your suggestions) because I have no idea
how performance is going to suffer when the database gets big.  I'll
keep you posted.

Whatever the case, I thought it prudent to tell you all that I'm
actually insane.

Sincerely, 

-Todd