[comp.lang.icon] icon & prolog

goer@SOPHIST.UCHICAGO.EDU (Richard Goerwitz) (03/29/90)

Just an idle question:  Has anyone thought of implementing
Prolog in Icon, either as a Prolog -> Icon translator, or
as a Prolog interpreter written in Icon?  I'm not a Prolog
expert, but it occurs to me that Icon might offer facili-
ties to make such a project much easier than it might be
for most other languages.

Just curious.

    -Richard L. Goerwitz              goer%sophist@uchicago.bitnet
    goer@sophist.uchicago.edu         rutgers!oddjob!gide!sophist!goer

gudeman@CS.ARIZONA.EDU (David Gudeman) (03/29/90)

   From: Richard Goerwitz <goer@sophist.uchicago.EDU>

   Just an idle question:  Has anyone thought of implementing
   Prolog in Icon, either as a Prolog -> Icon translator, or
   as a Prolog interpreter written in Icon?  I'm not a Prolog
   expert, but it occurs to me that Icon might offer facili-
   ties to make such a project much easier than it might be
   for most other languages.

I wrote an interpreter for a small logic language in Icon, not much
like Prolog, but it did do goal-directed unification with backtracking
like Prolog does.  Your intuition is correct that Icon makes this
easy, at least for an interpreter.  I was able to use Icon's
goal-directed evaluation to do all the goal-directed evualation of the
logic language, so I didn't have to keep track of states or anything
like that.

I just looked for the code I wrote, and it seems to have disapeared.
Oh well.

alanf@bruce.OZ (Alan Grant Finlay) (03/29/90)

In article <9003281833.AA18812@sophist.uchicago.edu>, goer@SOPHIST.UCHICAGO.EDU (Richard Goerwitz) writes:
> Just an idle question:  Has anyone thought of implementing
> Prolog in Icon, either as a Prolog -> Icon translator, or
> as a Prolog interpreter written in Icon?  I'm not a Prolog ...

I wrote a Prolog interpreter in Icon some time ago.  I never got
around to doing anything with it (i.e. publishing wise).  I was
in the process of writing the converse (Icon interpreter in Prolog)
when I got sidetracked.  I will post the sources and documentation.
There were four versions in increasing order of complexity.  I only got
around to documentation for versions 1 and 2.  The versions appear to
have implemented the following incrementally:
	1. Basic pure Prolog with negation by failure,
	2. List notation added (syntactic sugar),
	3. Assert and Retract,
	4. Cut.

The program documentation files *.doc are in troff format.  They're still
readable however.  The user guides *.usr are just plain text.  The source
is copyright in the sense that it can be used anywhere for any purpose 
provided the copyright is maintained and I get credit for my work.

I would be interested in any comments about the code.  I was trying to get
as succinct a source file as possible without sacrificing clarity (but its
always tempting to save a line here and there!).

kwalker@CS.ARIZONA.EDU ("Kenneth Walker") (03/30/90)

> Date: Wed, 28 Mar 90 12:33:15 CST
> From: Richard Goerwitz <goer@sophist.uchicago.EDU>
> 
> Just an idle question:  Has anyone thought of implementing
> Prolog in Icon, either as a Prolog -> Icon translator, or
> as a Prolog interpreter written in Icon?

You might want to check out "Logicon: an Integration of Prolog into
Icon" by Guy Lapalme and Suzanne Chapleau, Software Practice and
Experience, Oct 1986. They implement a Prolog interpreter in Icon
which lets you call back and forth between the two languages.

  Ken Walker / Computer Science Dept / Univ of Arizona / Tucson, AZ 85721
  +1 602 621 2858  kwalker@cs.arizona.edu {uunet|allegra|noao}!arizona!kwalker