Re: notational question about :Goal
"Richard A. O'Keefe" <[email protected]> Tue, 26 Aug 2014 10:23:02 +1200
| Newsgroups | gmane.comp.ai.prolog.swi |
|---|---|
| Message-ID | <[email protected]> |
On 26/08/2014, at 8:05 AM, Ross Boylan wrote:
> The manual defines
> findall(+Template, :Goal, -Bag)
> and the "Notation of predicate descriptions"
> (http://www.swi-prolog.org/pldoc/man?section=3Dpreddesc), say ":"
> indicates a meta-argument.
> =
> What's a meta-argument?
An argument that represents something to do.
The convention always was that : represented
something that WASN'T a goal but needed module
annotation, while 0, 1, 2, .... represented a
a goal that was missing the rightmost n arguments.
SWI Prolog documentation appears to use :Goal
for an argument that is a complete callable term.
> =
> I'm wondering about this because I was wondering if I could construct
> a composite goal, perhaps like =
> (mount(A, B, W1), mount(A, B, W2), W1\=3D W2).
Yes, certainly.
> I realize that could be turned into a helper predicate.
For findall/3, it's just a style issue.
For setof/3 and bagof/3, you have to think
about the r=F4les the variables play.
If a variable
- will be ground when findall, setof, or bagof is called
=3D> no worries
- is captured in the Template
=3D> no worries
- is local to your 'composite goal'
=3D> it must be explicitly existentially quantified
- is a wildcard
=3D> it is local to your 'composite goal' and cannot be
existentially quantified so you mustn't do that.
Let's suppose for argument's sake that in your example,
A will be ground, B is captured by the template, and W1
W2 are local to the composite goal. Then either you
should existentially quantify them
W1^W2^(mount(A, B, W1), mount(A, B, W2), W1 \=3D=3D W2)
or you should introduce an auxiliary predicate
has_dual_mount(A, B)
where
has_dual_mount(A, B) :-
mount(A, B, W1), mount(A, B, W2), W1 \=3D=3D W2.
> I also notice the description of setof is
> setof(+Template, +Goal, -Set)
> for which Goal gets a "+" rather than a ":".
Since bagof/3 in the same page uses :, I think you
can take it that this is an incomplete edit of the
documentation, not a subtle difference.