Yes, in take the rules have implicit universal quantifiers. However, if
you only want to test whether there are people that love sport, you
could query for this predicate and check whether the result set is not
empty. Because take is based on on-demand computing (iterators), this
will not compute all solutions but only one.
Cheers, Jens
Just to add to my previous post - an easy way to add existential
quantifier support might be to implement it as an aggregation function,
similar to the existing count function.
Cheers, Jens
Lets say you have a predicate p(x,y) and you want to build a rule
if exists x:p(x,y) then q(y)
then what you could do is define an aggregation function
aggregation *f** *= count x *p***[x,y]
and rewrite the rule as
if f(y)>0 then q(y)
This is a form of Skolemization - to get rid of an existentially quantified variable by introducing a new function symbol.
The only problem is that count is not very effective - you count ALL x such that p(x,y). It would therefore be better to define
another aggregation function exists very similar to count but only looking whether there is one x. The rule would then simply be:
aggregation *f2** *= exists x *p*[x,y]
if f2(y)=='true' then q(y)
It should be easy to add some syntactic sugar to the scripting language and add simplify this further to:
if f2(y) then q(y)
essentially treating f2 as a predicate.
I will add this as an issue to take, but cannot promise to get this done
soon. Its not difficult though. If you want to do it feel free to do so
and send me the code so that I can qa it and commit it.
Cheers, Jens