[mercury-users] compilation problem, all, some
David Overton
dmo at cs.mu.OZ.AU
Fri Jul 16 22:52:54 AEST 2004
On Fri, Jul 16, 2004 at 01:32:37PM -0700, Maurizio Colucci wrote:
> On Friday 16 July 2004 02:07, Zoltan Somogyi wrote:
> > The transliteration of the comment is the following:
> >
> > the_verb_is_visible(V, SelectedObjs) :-
> > verb_get_requirements(V, Reqs),
> > all [O] (
> > member(O, SelectedObjs)
> > =>
> > member(P, Reqs),
> > call(P, O)
> > ).
>
>
> Gosh... It was that easy :-)
>
> I hadn't tried that because, since I had used "all [O]", I assumed I had to
> use "some [P]".
>
> Instead, I notice you use "all [O]" for universal quantification, while
> leaving the existential quantification of P implicit.
>
> But then, what is "some" used for in Mercury?
Explicit existential quantification is not often necessary -- the
implicit quantification usually does what you want.
You could write:
the_verb_is_visible(V, SelectedObjs) :-
verb_get_requirements(V, Reqs),
all [O] (
member(O, SelectedObjs)
=>
some [P] (
member(P, Reqs),
call(P, O)
)
).
or even
the_verb_is_visible(V, SelectedObjs) :-
some [Reqs] (
verb_get_requirements(V, Reqs),
all [O] (
member(O, SelectedObjs)
=>
some [P] (
member(P, Reqs),
call(P, O)
)
)
).
both of which are equivalent to Zoltan's code, but much less readable.
The goal `all [X] p(X)' is really syntactic sugar for
`not ( some [X] not p(X) )'.
In this case, the explicit quantification is necessary:
`not ( not p(X) )' would be implicitly quantified as
`not ( not ( some [X] p(X) ) )' which would then be simplified to
`some [X] p(X)'.
David
--
David Overton
WWW: http://www.overtons.id.au/
Mobile Phone (UK): +44 7799 344 322
--------------------------------------------------------------------------
mercury-users mailing list
post: mercury-users at cs.mu.oz.au
administrative address: owner-mercury-users at cs.mu.oz.au
unsubscribe: Address: mercury-users-request at cs.mu.oz.au Message: unsubscribe
subscribe: Address: mercury-users-request at cs.mu.oz.au Message: subscribe
--------------------------------------------------------------------------
More information about the users
mailing list