[net.lang.prolog] PROLOG Digest V3 #44

PROLOG-REQUEST@SU-SCORE.ARPA (Chuck Restivo, The Moderator) (11/10/85)

PROLOG Digest            Monday, 11 Nov 1985       Volume 3 : Issue 44

Today's Topics:
                      Query - Profiling & Crays,
                   LP Philosophy - Lisp in Prolog,
                Implementation - DCG + Left Recursion
----------------------------------------------------------------------

Date: Sun, 20-Oct-85 20:52:26 PDT
From: (Jonathan Pincus) ernie!pincus@UCB-Vax
Subject: Profiling Programs?

Has anybody out there ever tried to profile a Prolog program?
Specifically, how do I find out how much time various procedures
require?  Obviously, I want to do this in order to speed up the
program in the important places (for that matter, does the old
chestnut about 10% of the code requiring 90% of the execution
time hold for Prolog?).

My specific environment is C-Prolog (version 1.2) on a VAX.  One
thought that has occurred to me is that timing information needs
to be recorded at the same time that "spy"ing information gets
printed out, but I'm not sure how to do that.  Any comments/advice
/solutions will be gratefully accepted, and if anything exciting
turns up I'll post a summary. Please don't tell me "Oh, that's just
an efficiency question, you shouldn't worry about that!"

-- Jon

------------------------------

Date: Wed, 23 Oct 85 10:20:44 edt
From: Carl Landwehr <landwehr@nrl-css.ARPA>
Subject: Prolog for Cray?

I am new to this list, so bear with me if this is an old query.
We have a Cray X-MP that might be available for us to run Prolog,
if we could find a Prolog for it.  Does anyone out there have one,
or know of plans to develop one?

-- Carl Landwehr

------------------------------

Date: 23 Oct 85 17:48:09 PDT (Wed)
From: Sanjai Narain <narain@rand-unix.ARPA>

We are about to begin a project which intends to use both
Franzlisp and Prolog IN THE SAME ENVIRONMENT. Are there any
suitable Prologs with efficiency >= 1KLips? We use SUNs and
Vaxes running UNIX. Any leads would be greatly appreciated.

-- Sanjai Narain

------------------------------

Date: Thu, 24 Oct 85 22:14 EDT
From: Hewitt@MIT-MC.ARPA
Subject: Lisp in Prolog?

I would like to reply to the message from William Clocksin which said

 ... it cannot have escaped the attention of most people that writing
 a compiler (in Prolog) to COMPILE Lisp into some target (say LAP)
 would be as easy as pie.  For those of us who have written
 compilers in both Lisp and Prolog, I daresay it would be a lot
 easier in Prolog.  I might further suggest that the compiler
 test is more useful than the interpreter test, and that the
 interpreter test has no especial theoretical advantage, since
 the compiler can be seen as a meaning-preserving transformation.
 (Ahem. Which in fact it isn't for Lisp if you're not careful
 with bindings).

I argue that the above compiler is not a very good test of Prolog
because the code produced by the proposed Prolog compiler for
Common Lisp WILL NOT RUN on a standalone Prolog system.  Thus the
proposed compiler does not address a fundamental problem which is
the LACK OF EXPRESSIVE CAPABILITY in the Prolog language:  there
is large and growing amount of software written in Common Lisp which
will NEVER execute efficiently on standalone Prolog systems.  On the
 other hand Prolog programs will ALREADY execute efficiently on Lisp
systems.  Thus the compiler which Clocksin proposes does not address
the fundamental problems of Prolog.

------------------------------

Date: Thu, 24 Oct 85 20:32:10 PDT
From: Adolfo Di-Mare <dimare@LOCUS.UCLA.EDU>
Subject: DCG + Left Recursion :- Succeed!

After looking into the dragon book, I found the trick I needed
to do avoid left recursion but still have left associative
operators.

The problem is how to evaluate arithmetic expressions with left
associative operators. The naive way is to say:

expr(Z) --> expr(Y), "-", term(X), {Z is X-Y}.
expr(Z) --> term(Z).
term(X) --> [C], {48=<C, C=<57, X is C-48}.

If we call:
        | ?- expr(Z,"2-3-5-1",[]).
this program loops.

The trick is very simple: inherit from the left (above) the
left operand, and use it right away when building the expression
tree. The modified grammar:

expr(Tree) --> term(Left), rest(Left,Tree).
rest(Left,Tree) --> "-",term(Right),{Temp is Left-Right},rest
                                                        (Temp,Tree).
rest(Tree,Tree) --> [].
term(X) --> [C], {48=<C, C=<57, X is C-48}.

The call
        | ?- expr(Z,"2-3-5-1",[]).

now gives the desired result: Z = -7.

Thanks to all those that helped me.

-- Adolfo

------------------------------

End of PROLOG Digest
********************