HDTenEightyP/NetNews huggingface dataset:
From: cyberman@toz.buffalo.ny.us (Cyberman)
Newsgroups: comp.lang.prolog
Subject: Compilors in Prolog
Date: 2 Sep 92 01:44:15 GMT
X-Maildoor: WaflineMail 1.00r

I've written a Parser in prolog [seemed the EASY way to do it!]
and I would like to put in code gnerateing.  The problem I'm
having is ERROR generation and backtracking.  I'm confused a bit.

1:  has anyone successfully used prolog this way?  IE languuage
prototyping

2:  What is a GOOD set of rules to go about this process?

Thanks reply here or in mail!  I'm sure this won't be of intrest
to a lot of poeple.  :)

        Stephen Cyberman@Toz.Buffalo.NY.US
        Scripted at Tue  09-01-1992  00:28:15

... In GOD we trust all others pay CASH!
--- Blue Wave/QWK v2.10
From: popx@vax.oxford.ac.uk
Newsgroups: comp.lang.prolog
Subject: Wanted: production system/coroutiner
Date: 25 Aug 92 19:20:04 GMT
Organization: Oxford University VAX 6620

I'm looking for two Prolog programs:


1) An efficient production system, possibly one that works by compiling
into a Rete network. I have written a slow production system that works
in the obvious fashion, to use as part of my
teaching-AI-by-controlling-simulated-animals project. (Shame English
lost the clausal adjective construction: it's handy in Dutch and      
German :-). This slow PS produces a log showing each match-resolve-act
stage as it cycles. What I need now is a fast system that can be used
with big rule-bases/long-running programs, and that I can make
behaviourally identical (apart from logging) with the slow one.


2) A meta-interpreter for implementing coroutines. Example:

        test :-
            goal_to_coroutine( count(10), C ),
            test_count( C ).


        test_count( C ) :-
            resume( C, Result ),    % Resume or start C.
                                    % Result will be unified with
                                    % the argument to the next call
                                    % C makes of 'suspend'.
            write( Result ), nl,
            test_count( C ).


        count( N ) :-
            write( 'Suspending' ), nl,
            suspend( N ),           % Return N as result.
            write( 'Resuming' ), nl,
            Next is N + 1,
            count( Next ).

Again, I want this for the animal. My simulation works in a cycle:
update animal's perceptions, call animal's "brain" predicate, act on
result. Many "brains" are easiest to write if control appears to go the
other way: that is, the "brain" is in a continuous loop, and calls
suspend each time it has to return a result to the world simulator. This
saves a lot of nasty program inversion. I was able, for example, to make
the animal crawl in depth-first, breadth-first, and other search
patterns along trees, just by taking the standard code for these, doing
some simple transformations to add the between-node walks, and inserting
calls to 'suspend'.

I have implemented coroutines in Poplog: very easy to do, using Pop
processes (bet you can't do that in Quintus without operating-system
support...). However, I'll eventually be publishing this software in my
next book, and I'd like a portable version. (Failing that, does anyone
have a system for automatically inverting coroutined programs?).


Any other software for animal control, e.g. planners, would also be
welcome. This has to be public domain, since I'll be making all my code
freely available, but I'll acknowledge all donors.


Jocelyn Paine
Newsgroups: comp.lang.prolog
From: matsc@sics.se (Mats Carlsson)
Subject: Re: SICStus prolog problem
Organization: Swedish Institute of Computer Science, Kista
	<1992Aug26.145353.21444@sics.se>
Date: Thu, 27 Aug 1992 08:06:08 GMT

In article <1992Aug26.145353.21444@sics.se> lhe@sics.se (Lars-Henrik Eriksson) writes:

   In article <714823911.21006@minster.york.ac.uk> cjhs@minster.york.ac.uk writes:
   >: I have a program in SICStus prolog that makes extensive use of the wait
   >: declaration. Program (137 lines) supplied to anyone who is curious.
   >: 
   >: The problem is that it runs ok interpreted, but fails when compiled.
   >: Insertion of a diagnostic in a critical place makes the compiled
   >: version behave like the interpreted version.

   I suspect that the problem you have run into is the same one that I
   once encountered and that caused me much grief before I got an
   explanation and a workaround.

   If you have a clause body that looks like this:

	   .... baz(...), !, ....

   and the call to baz causes blocked goals to run, the compiler executes
   the cut *before* running the blocked goals. This may cause the program
   to fail even if it works correctly under the interpreter.

   The following program illustrates the point:

	   :- block bar(-). /* :- wait bar/1 before SICStus 2.0 /*
	   foo :- bar(X), baz(X), !.
	   bar(2).
	   baz(X) :- X=1.
	   baz(X) :- X=2.

   The reason baz/1 is written in a slightly odd way is to prevent
   indexing. It is essential that a choicepoint is created.

You _will_ get indexing with this formulation too, but that
doesn't change anything for your example.  There will be a choicepoint
since X is unbound.

   Calling foo/0 as a goal succeeds under the interpreter, but fails
   under the compiler.

   The compiled code calls baz(X), which succeeds, binding X to 1. The
   call to bar/1 is now unblocked, but *not* run.  First Sicstus cuts
   away the choice point in baz/1, *then* calls the unblocked goal. Of
   course bar(1) will fail, and since the choicepoint in baz/1 has been
   cut away, the call to foo/0 will also fail.

   The interpreter will do the cut only *after* calling bar/1, so in that
   case foo/0 will succeed.

   [...]

   The solution is to insert a dummy goal (likely the diagnostic in your
   case!) before the cut, e.g.

	   foo :- bar(X), baz(X), true, !.

   Now the compiled code runs as expected.
   The manual should really state clearly that this can happen. 
   [...]

But it does, witness page 110 in the User's Manual for version 2.1.

The check for unblocked goals is done at procedure calls.  To fix the
interpreter/compiler discrepancy, nearly all built-in predicates that
compile in-line would have to check.  Also, the compiled code would
have to include information to make it possible to safely "escape"
from the current execution and invoke the unblocked goals.
We haven't yet figured out a way to do this without undue overhead.
--
Mats Carlsson
SICS, PO Box 1263, S-164 28  KISTA, Sweden    Internet: matsc@sics.se
Tel: +46 8 7521543     Ttx: 812 6154 7010 SICS     Fax: +46 8 7517230
Newsgroups: comp.lang.prolog
From: rhyspj@occs.cs.oberlin.edu (Rhys Price Jones)
Subject: Soliciting names for ACM/SIGCSE panelists
Organization: Oberlin College Computer Science
Distribution: comp
Date: Wed, 2 Sep 1992 22:17:06 GMT
X-Posted-From: occs.cs.oberlin.edu
X-Posted-Through: sol.ctr.columbia.edu

I am looking for participants in a panel discussion  for next year's
SIGCSE to discuss issues affecting choice of language in CS1 - the
introductory CS course.  Please e-mail me suggested names for
advocates of your particular favorite introductory language.

Thanks

--
Rhys Price Jones                            
Cyd-athro Cyfrifiaduriaeth                   ____
Associate Professor Computer Science        /   / /
Oberlin College                            /   / /
King 223C                                 /___/ /__      __
Oberlin OH 44074 - USA - UDA             / \   /  / / / (
(216) 775 8697                          /   \_/  /_/_/ __)
<rhyspj@occs.cs.oberlin.edu>                      __/_/
From: baechtel@iccgcc.decnet.ab.com
Newsgroups: comp.lang.prolog
Subject: Help with Grips (aka. Get a Grip).
Date: 1 Sep 92 10:55:37 EST


  I am trying to port Grips to C-prolog.

  I am getting syntax errors in both grips.pl and gripstop.pl.

  gripstop.pl requires a read/2 function that I do not have.
  Supposedly read(Term,Vars) reads Term and returns also a list
  of Vars in Term, so that the interpreter can display Vars later.


  Has anyone done this port before?

  Does anyone have the source for read/.2?


  Thanks in advance.

Newsgroups: comp.lang.prolog
From: jonas@csd.uu.se (Jonas Barklund)
Subject: Re: Help on problem needed!
Organization: Uppsala University, Sweden
	<14219@goanna.cs.rmit.oz.au> <meskes.714916931@ulysses>
Date: Thu, 27 Aug 1992 13:20:39 GMT

Since my attempted answer to Michael Meskes' question started this
thread of discussion, let me just say that I consider the problem he
posed non-trivial. It is the kind of problem that a teacher might give
to a student on an advanced course in logic programming. I do not know
Mr.  Meskes at all and certainly did not want to insinuate that he is
a cheating student. I just wanted him to know that if he were, he was
probably doing wrong.

-- Jonas B.

--
Jonas Barklund, Computing Science Department, Uppsala University
Email jonas@csd.uu.se, phone +46-18-181050, fax +46-18-521270
From: jkreznar@ininx.UUCP (John E. Kreznar)
Newsgroups: comp.lang.prolog
Subject: Re: Wanted: production system/coroutiner
Summary: coroutine meta-interpreter
Date: 30 Aug 92 05:34:29 GMT
Organization: Independence Industries, Los Angeles

In article <1992Aug25.202004.8511@vax.oxford.ac.uk>, popx@vax.oxford.ac.uk writes:
> I'm looking for two Prolog programs:
> 
> 1) ...
> 
> 2) A meta-interpreter for implementing coroutines.

Have you seen L.M. Pereira's "Logic control with logic" in _Implementations of
Prolog_, J.A. Campbell editor, Ellis Horwood Limited, 1984?  Section 2.2 of the
paper is entitled "An Interpreter to Control Coroutining".

-- 
        Relations among people to be by mutual consent, or not at all.
         ---John E. Kreznar, jkreznar@ininx.com, uunet!ininx!jkreznar
From: serge@irisa.fr (Serge Lehuitouze)
Newsgroups: comp.lang.prolog
Subject: Compilation of Disjuncts
Date: 1 Sep 92 16:05:05 GMT
Organization: IRISA, Rennes (Fr)

I have some knowledge (only "theoretic", though) about the WAM, but I have
never seen anything about the compilation of the disjunction ';' (and
also things like '->').

You, WAM gurus, do you do anything special about this construct, or do you just
consider it as an ordinary predicate with a definition like:
P ;_Q :- P.
_P; Q :- Q.
From: billaud@greco-prog.fr (Michel BILLAUD)
Newsgroups: comp.lang.prolog
Subject: Re: Help on problem needed!
Keywords: help
Date: 25 Aug 92 07:46:23 GMT
Reply-To: billaud@geocub.UUCP (Michel BILLAUD)
Organization: LaBRI - Universite Bordeaux I - France

In article <meskes.713709771@ulysses> meskes@ulysses.informatik.rwth-aachen.de (Michael Meskes) writes:

>Can you program a IF...THEN...ELSE in Prolog without using the cut?

No. a proof by contradiction:

Suppose you can program IF..THEN ...ELSE, then you could also
program NOT ... (negation as failure) because
	NOT(X) <==> IF X THEN FAIL ELSE TRUE

Obviously NOT(TRUE) <=> FAIL     and NOT(FAIL) <=> TRUE

But every program P built from AND/OR/TRUE/FAIL only has the following property
  P(TRUE) "produces more solutions than" P(FAIL)
					(not very hard to prove)
Which is not the case for NOT.
----
Also, it is not possible to replace CUT by IF...THEN..ELSE
for a similar reason

Michel
-- 
Michel BILLAUD                 :  billaud@geocub.greco-prog.fr
Departement d'Informatique     :  phone W: 56.84.57.92  // 56.84.69.22
IUT "A", Universite Bordeaux I :  "Je veux jouer de l'helicon
33405 Talence  (FRANCE)        :        pon pon pon pon !    "
From: pereira@alice.att.com (Fernando Pereira)
Newsgroups: comp.lang.prolog
Subject: Prolog for Silicon Graphics Indigo?
Keywords: Silicon Graphics
Date: 29 Aug 92 13:46:30 GMT
Organization: AT&T Bell Laboratories, Murray Hill NJ

I am looking for recommendations for commercial or non-commercial
Prolog systems with performance and facilities comparable with
Quintus Prolog that will run on Silicon Graphics Indigo (R4000 processor)
workstations. Unfortunately, Quintus does not have an SGI port.

Please reply by mail, I will summarize for the net if there are
responses and interest.

Fernando Pereira
AT&T Bell Laboratories, Murray Hill
pereira@research.att.com
From: baechtel@iccgcc.decnet.ab.com
Newsgroups: comp.lang.prolog
Subject: Help with C-Prolog, Please.
Date: 3 Sep 92 16:43:03 EST



	In C-Prolog 1.5, is there anyway to get the name of a variable
in a term?

	Specifically, If I write:

read(Term, Vars) :-
    read(Term),
    functor(Term,F,A),
    getvars(Term,A,Vars,[]).

getvars(Term,0,Varlist,Varlist).

getvars(Term,A,Vars,Varlist) :-
    arg(A,Term,Arg),
    ( var(Arg), Vars1 = [Arg | Varlist]; Vars1 = Varlist),
    A1 is A-1,
    getvars(Term,A1,Vars,Vars1).

If I execute read(Term,Vars) and my input is: "X is Y.",
Term = "X is Y" and Vars = [_15,_16].

Is there anyway to get Vars=[X,Y]?
I don't understand how to get the name of the Variable instead of its
reference.

Can anyone suggest code that will work in C-Prolog?

Thanks in advance.
.

Newsgroups: comp.lang.prolog
From: tim@quintus.com (Tim Lindholm)
Subject: Re: Compilation of Disjuncts
Organization: Quintus Corporation, Palo Alto, CA
Date: Wed, 2 Sep 1992 17:18:37 GMT

In article <1992Sep1.160505.6828@irisa.fr>, serge@irisa.fr (Serge Lehuitouze) writes:
> I have some knowledge (only "theoretic", though) about the WAM, but I have
> never seen anything about the compilation of the disjunction ';' (and
> also things like '->').
> 
> You, WAM gurus, do you do anything special about this construct, or do you just
> consider it as an ordinary predicate with a definition like:
> P ;_Q :- P.
> _P; Q :- Q.

Quintus Prolog compiles disjunction and if-then-else in line rather than
calling out to a predicate, although to a first approximation it comes down
to the same thing -- pushing a choice point allowing you to backtrack to the
second horn of the disjunction, then calling the first horn.  Doing so in
line has a few advantages like avoiding the cost of the call and leaving you 
free to customize the choice point to best suit disjunction.  

However, when compiling disjunction and if-then-else you also need to worry 
about the scope of cuts.  For instance, the nonsensical program:

    go :- ( write('first horn'), nl,
            !,
	    fail
	  ; write('second horn'), nl
          ).
    go.

writes "first horn" and *fails* in Quintus Prolog, the cut cutting away the
choice point for go/0 as well as the choice point for the disjunction.  If you defined ;/2 as above, the cut in the first horn would only affect the meta-
called goal, cutting neither the choice point for ;/2 nor go/0.

Quintus compiles general if-then-elses similarly, except that it optimizes
many cases where failure of an "if" test doesn't need all the power of
backtracking to recover and get to the "then".  These include things like
term type tests, arithmetic and term comparisons (==/2), etc.  Calls to user-
defined predicates are never optimized like this, as compilation doesn't know
what all they are going to do (e.g. create structure, bind variables) when
they are called.

Knowing how your Prolog handles disjunction and if-then-else, and whether
there are cases that it optimizes, you can often greatly reduce the number of time- and space-expensive choice points you push.

-- Tim

Tim Lindholm				Manager, Prolog Technology Group
Quintus Corporation                     InterNet:       tim@quintus.com
2100 Geng Road                          FAX:            415 494 7608
Palo Alto, California 94303             Phone:          415 813 3844
Newsgroups: comp.lang.prolog
From: micha@ecrc.de (Micha Meier)
Subject: Re: Help with C-Prolog, Please.
Reply-To: micha@ecrc.de
Organization: European Computer-Industry Research Centre
Date: Fri, 4 Sep 1992 12:15:44 GMT

In article 8798@iccgcc.decnet.ab.com, baechtel@iccgcc.decnet.ab.com () writes:
>
>
>	In C-Prolog 1.5, is there anyway to get the name of a variable
>in a term?
>
>	Specifically, If I write:
>
>read(Term, Vars) :-
>    read(Term),
>    functor(Term,F,A),
>    getvars(Term,A,Vars,[]).
>
>getvars(Term,0,Varlist,Varlist).
>
>getvars(Term,A,Vars,Varlist) :-
>    arg(A,Term,Arg),
>    ( var(Arg), Vars1 = [Arg | Varlist]; Vars1 = Varlist),
>    A1 is A-1,
>    getvars(Term,A1,Vars,Vars1).
>
>If I execute read(Term,Vars) and my input is: "X is Y.",
>Term = "X is Y" and Vars = [_15,_16].
>
>Is there anyway to get Vars=[X,Y]?
>I don't understand how to get the name of the Variable instead of its
>reference.

Actually, if I execute your code, I get
| ?- read(Term, Vars).
|: "X is Y".

Term = [88,32,105,115,32,89]
Vars = []  

or, if the quotes were not meant to be there,

| ?- read(Term, Vars).
|: X is Y.

Term = _6 is _7
Vars = [_6,_7] 

Most Prologs do not keep the names of variables in terms being read in.
The only exception is the top level loop, where usually a special predicate is used which returns variables together with their names as atoms. C-Prolog 1.5 has no such
predicate, the top-level answer is hard-wired. If you insist on C-Prolog, use ROK's public domain parser read.pl and rdtok.pl which gives you both the term and a list of
variable/name pairs.

--Micha

---
Micha Meier			------------------------------------------------
ECRC, Arabellastr. 17		The opinions expressed above are private
D-8000 Munich 81		and may not reflect those of my employer.
micha@ecrc.de, Tel. +49-89-92699-108, Fax  +49-89-92699-170

Newsgroups: comp.lang.prolog
From: meskes@ulysses.informatik.rwth-aachen.de (Michael Meskes)
Subject: Re: Help on problem needed!
Keywords: help
Organization: Rechnerbetrieb Informatik  /  RWTH Aachen
Date: 27 Aug 92 12:02:11 GMT

After all the discussion I started with my question on IF...THEN...ELSE in
Prolog without using the Cut I think I should give all of you some more
information.

I don't like you all to think I can't do my homework myself. But this problem
I posted isn`t my homework. I do not have any experience in programming Prolog
and, to be honest, I'm also not interested in it, too. The only thing I'm
interested in is pure first-order-logic with functional symbols. I only thought
of Prolog to test the expressive power of this pure logic, in which I'm
interested in as a side effect. It's not the main topic I'm working on.
You can regard it as one very interesting example used in my work.

If it seems to be such a stupid question that some of you thought of a student
searching for someone to do his homework, why isn't there such an easy answer?
All the answers are quite interesting but the don't solve the problem.
As far as I know Prolog is turing-complete and the proofs I know don't use
the Cut. So why isn't it possible to solve this problem im Prolog?

If you still think I want you to do my homework try not to answer. Perhaps
some of you are friendly enough to do though. But remember the predicate a
isn't defined only using built-in comparisons like <.

Michael

-- 
Michael Meskes, Lehrstuhl fuer angewandte Mathematik insb. Informatik,
RWTH-Aachen, Ahornstr. 55, D-W-5100 Aachen
Email: meskes@ulysses.informatik.rwth-aachen.de
Newsgroups: comp.lang.prolog
From: reidld@ecf.toronto.edu (Lloyd D Reid)
Subject: The Effect of the Cut on Prolog Stack
Organization: University of Toronto, Engineering Computing Facility
Date: Thu, 27 Aug 1992 21:26:49 GMT

  I have a question concerning the effect of the cut on the global 
  stack usage for prolog.


 If I enter the query,

 > test,!,test.

 and test is a predicate which uses X amount of global stack space
 will the above require 2X global stack or could the cut reduce it ? 
 For MPROLOG by Logicware it appears that 2X is used. 
 Is this a problem with their software or with prolog interpreters 
 in general since it would seem that the stack would not be required
 after the cut.

                                            Thanks in advance,
                                              Peter Grant

 Note: If you are responding with mail, mail to:
       reidld@bullet.ecf.utoronto.ca
-- 
reidld@ecf.toronto.edu (Daniel Chisholm)
Newsgroups: comp.lang.prolog
From: matsc@sics.se (Mats Carlsson)
Subject: Re: Errors in ISO Prolog Draft?
Followup-To: comp.lang.prolog
Organization: Swedish Institute of Computer Science, Kista
Date: Tue, 1 Sep 1992 07:42:10 GMT

In article <Trinity-College-Dublin--Ireland-310892103019@brady.cs.tcd.ie> Trinity College Dublin, Ireland (Michael Brady) writes:

   I am trying to implement disjunction, if-then, if-then-else and
   negation-by-failure according to ISO Prolog Draft of March 27, 1992, and I
   think there may be some mistakes in the examples. Can anyone comment?

   The mistakes (?) are:

   Section 7.8.7.2. This is examples of if-then. The second-last example
   appears to have a syntax error. I won't lose sleep worrying about that one.

Yes, the parentheses don't match.

   Section 7.8.8.2. This is examples of if-then-else. I just don't see how the
   stated behaviour of the last example can conform to the intended operation
   of if-then-else. This one I worry about.

Don't worry.  The example should fail on backtracking.
--
Mats Carlsson
SICS, PO Box 1263, S-164 28  KISTA, Sweden    Internet: matsc@sics.se
Tel: +46 8 7521543     Ttx: 812 6154 7010 SICS     Fax: +46 8 7517230
Newsgroups: comp.lang.prolog
From: roland@sics.se (Roland Karlsson)
Subject: Re: The Effect of the Cut on Prolog Stack
Organization: Swedish Institute of Computer Science, Kista
Date: Sat, 29 Aug 1992 14:21:31 GMT


The cut operation in the WAM implementation of Prolog does not in it
self reduce the amount of used global stack.  But a garbage collection
does reclaim the space.

so
...  test,!,garbage_collect,test ...

is a way (in SICStus) to just use X global stack space.

(It is not always true.  Undo, setarg .. etc can make it hard to
reclaim everything.)


Roland Karlsson
--
Roland Karlsson             SICS, PO Box 1263, S-164 28 KISTA, SWEDEN
Internet: roland@sics.se    Tel: +46 8 752 15 40          Fax: +46 8 751 72 30
Telex: 812 6154 7011 SICS   Ttx: 2401-812 6154 7011=SICS
Newsgroups: comp.lang.prolog
From: micha@ecrc.de (Micha Meier)
Subject: Re: Compilation of Disjuncts
Reply-To: micha@ecrc.de
Organization: European Computer-Industry Research Centre
Date: Fri, 4 Sep 1992 12:20:27 GMT

In article 97440011@hpbbrd.bbn.hp.com, jensk@hpbbrd.bbn.hp.com (Jens Kilian) writes:
>The main reason for compiling disjunctions is that it can speed up code
>like
>
>	p(X) :-
>	  (  X >= 0 ->
>	     do_something_for_positive_X(X)
>	  ;  do_something_for_negative_X(X)
>	  ).
>

No. The main reason for compiling disjunctions is to avoid to build a structure
and metacall it. The improvement you mention is also significant, but nowhere as important as this.

--Micha

---
Micha Meier			------------------------------------------------
ECRC, Arabellastr. 17		The opinions expressed above are private
D-8000 Munich 81		and may not reflect those of my employer.
micha@ecrc.de, Tel. +49-89-92699-108, Fax  +49-89-92699-170

Newsgroups: comp.lang.prolog