[comp.lang.prolog] Quintus Prolog problem

bradley@cs.utexas.edu (Bradley L. Richards) (11/14/90)

As near as I can tell, setof and bagof don't work properly with the
"recorded" predicate in Quintus Prolog (version 2.5.1, sun3-4.0).

If I record:  recorda(woof, term2, _),
              recorda(woof, term1, _).

and then query:  setof(X, recorded(woof, X, _), Set).

I receive the answer Set = [term2], and on backtracking the answer
Set - [term1].  It seems to me that I should receive a single answer
Set - [term1, term2].

Am I missing something?  Or is this a known bug?

Bradley

dowding@ai.sri.com (John Dowding) (11/14/90)

In article <264@messina.cs.utexas.edu> bradley@cs.utexas.edu (Bradley L. Richards) writes:

   As near as I can tell, setof and bagof don't work properly with the
   "recorded" predicate in Quintus Prolog (version 2.5.1, sun3-4.0).

   If I record:  recorda(woof, term2, _),
		 recorda(woof, term1, _).

   and then query:  setof(X, recorded(woof, X, _), Set).

   I receive the answer Set = [term2], and on backtracking the answer
   Set - [term1].  It seems to me that I should receive a single answer
   Set - [term1, term2].

   Am I missing something?  Or is this a known bug?

   Bradley

It is trickey.  This would work:

	setof(X, Ref^recorded(woof, X, Ref), Set)

Prolog doesn't have a true don't-care variable.  The _ is really
just a shorthand for some particular variable that you haven't
bothered to name.  


John Dowding
dowding@ai.sri.com

ok@goanna.cs.rmit.oz.au (Richard A. O'Keefe) (11/14/90)

In article <DOWDING.90Nov13152422@palm.ai.sri.com>, dowding@ai.sri.com (John Dowding) writes:
> In article <264@messina.cs.utexas.edu> bradley@cs.utexas.edu (Bradley L. Richards) writes:
>*  As near as I can tell, setof and bagof don't work properly with the
>*  "recorded" predicate in Quintus Prolog (version 2.5.1, sun3-4.0). ...
>*   and then query:  setof(X, recorded(woof, X, _), Set).
> It is trickey.  This would work:
> 	setof(X, Ref^recorded(woof, X, Ref), Set)

> Prolog doesn't have a true don't-care variable.  The _ is really
> just a shorthand for some particular variable that you haven't
> bothered to name.  

Just to stress this:  this behaviour has *nothing* to do with recorded/3
at all.  setof/3 is in this instance behaving *exactly* the way it is
*supposed* to work, and any Prolog giving different results _would_ have
a bug.  (See the last chapter in The Craft of Prolog, plug plug.)
You may prefer to use findall/3.

-- 
The problem about real life is that moving one's knight to QB3
may always be replied to with a lob across the net.  --Alasdair Macintyre.

ken@aiai.ed.ac.uk (Ken Johnson) (11/14/90)

In article <264@messina.cs.utexas.edu> bradley@cs.utexas.edu (Bradley L. Richards) writes:

# As near as I can tell, setof and bagof don't work properly with the
# "recorded" predicate in Quintus Prolog (version 2.5.1, sun3-4.0).
# 
# If I record:  recorda(woof, term2, _),
#               recorda(woof, term1, _).
# 
# and then query:  setof(X, recorded(woof, X, _), Set).
# 
# I receive the answer Set = [term2], and on backtracking the answer
# Set - [term1].  It seems to me that I should receive a single answer
# Set - [term1, term2].
# 
# Am I missing something?  Or is this a known bug?
# 
# Bradley

You're missing something.  That's the correct behaviour.  Look again at
the incantation:

?- setof(X, recorded(woof, X, _), Set).

That anonymous variable will be given a different value on each
backtrack.  To state that you want all values to be included in Set, use
the existential quantifier and give the variable a name:

?- setof(X, Ref^recorded(woof, X, Ref), Set).

In general you should not use the anonymous variable anywhere inside a
setof or bagof unless you *know* what you are doing. 
-- 
Ken Johnson, AI Applications Inst., 80 South Bridge, Edinburgh EH1 1HN
       E-mail ken@aiai.ed.ac.uk,   ******************************************
phone 031-225 4464 extension 213   **  `You can resole your boot, but you  **
                 new quotation --> ** can't reboot your soul' [The Oracle] **

bradley@cs.utexas.edu (Bradley L. Richards) (02/11/91)

I've run into a very odd problem with Quintus Prolog--perhaps someone else has
run into this problem and determined the cause of it.  My program is generating
an endless stream of segmentation fault messages, for no apparent reason.  An
editted excerpt from a trace follows:

.
.
.
   (154052) 10 Call: ifoil:ifoil_find_best_ante(...) ? s
 > (154052) 10 Exit: ifoil:ifoil_find_best_ante(...) ?
   (156657) 10 Call (built_in): retract(data:ifoil_ante(_12868, ...)) ?
   (156657) 10 Exit (built_in): retract(data:ifoil_ante(-1, ...)) ?
   (156660) 10 Call (built_in): -1>=0 ?
   (156660) 10 Fail (built_in): -1>=0 ?
   (156657) 10 Redo (built_in): retract(data:ifoil_ante(-1, ...)) ?
[ Internal error (signal): Segmentation fault ]
[ Internal error (signal): Segmentation fault ]
[ Internal error (signal): Segmentation fault ]
.
.
.
ad infinitum

The redo of the retract should fail, since there are no more matching clauses.
In fact, it *used* to fail (and this problem did not arise), until I made some
changes in what should have been unrelated parts of the program.

The only recourse at this point is to interrupt with ^C and exit Prolog.  Even
an abort doesn't help--the error messages just keep coming.  The idea that
Prolog is out of memory turns out not to be the case--at this point it is
using about 1.5M out of a 15M limit (on a machine with much more than that
available).

Any ideas on causes or cures?

Bradley

-------------------------------------------------------------------------------
 Bradley L. Richards             "The abandonment of formal mathematics
 bradley@cs.utexas.edu           is an extremely popular thing to do in
 uucp:  cs.utexas.edu!bradley    computer science."
                                                    Dr. Robert Boyer, NACLP-90
-------------------------------------------------------------------------------