Bryan,

   I'm not sure I completely understood your scenario, but Drools supports FOL and your scenario can be implemented whatever it is.

   I think the best way is giving you some examples:

rule "Fires FOR EACH fact that does not have a corresponding Exception Range"
  when
    Fact1($number : number)
    not ExceptionRange(startRange <= $number, stopRange >= $number)
  then
    // do something
end

rule "Fires only IF ALL Facts have a corresponding Exception Range (this rule will fire only once)"
  when
    not (
            Fact1($number : number) and
            not ExceptionRange(startRange <= $number, stopRange >= $number)
         )
  then
    // do something
end

rule "SAME AS ABOVE: Fires only if all Facts have a corresponding Exception Range (this rule will fire only once)"
  when
    forall( Fact1($number : number)
             ExceptionRange(startRange <= $number, stopRange >= $number) )
  then
    // do something
end

rule "Fires only if THERE IS ANY Fact that does not have a corresponding Exception Range (this rule will fire only once)"
  when
    not( forall( Fact1($number : number)
                   ExceptionRange(startRange <= $number, stopRange >= $number) ) )
  then
    // do something
end

rule "fires FOR EACH PAIR [fact, exception range] (cross product)"
  when
    Fact1($number : number)
    ExceptionRange(startRange <= $number, stopRange >= $number)
  then
    // do something
end

rule "fires if THERE ARE NO facts that have a corresponding exception range (fires only once)"
  when
    not (
            Fact1($number : number) and
            ExceptionRange(startRange <= $number, stopRange >= $number)
          )
  then
    // do something
end

    Take a look at the "exists" qualifier that is the same as "not( not( ... ) )".
    Hope it helps.

    []s
    Edson


2007/9/19, wasabifan <bryan.rickman@kewill.com>:

I have several rules I am working on that I am having problems implementing.
Most of our tests are composed of at least one "pass" and one "fail" rule.
Basically, there are some tests where exceptions need to be thrown based on
a date or number being inside a range where these exceptions occur (causing
a possible failure).

The problem is that we are testing several objects, so using the existensial
not, is problematic.

For example, in the pass, if we write:

rule "pass example"
  when
    Fact1($number : number)
    not ExceptionRange(startRange <= $number, stopRange >= $number)
  then
    System.out.println("Pass" + $number);
end

For the fail, it would be like:

rule "fail example"
  when
    Fact1($number : number)
    ExceptionRange(startRange <= $number, stopRange >= $number)
  then
    System.out.println ("Fail" + $number);
end

Is there a way to rewrite the pass rule, so that it checks the existence of
a range satisfying each number from Fact1?  If I understand not correctly,
it will either pass once, and only once if ANY range matches at least one
number from Fact1.  Or it would pass for all Fact1's if any Fact1's match
any exception range.

A little clarification here would be appreciated, and if you know of a
workaround to actually test for getting exactly one and only one pass or
fail (exclusively) for each Fact1 asserted.

Thanks,
Bryan Rickman


--
View this message in context: http://www.nabble.com/Existensial-not-question-tf4481066.html#a12777641
Sent from the drools - user mailing list archive at Nabble.com.

_______________________________________________
rules-users mailing list
rules-users@lists.jboss.org
https://lists.jboss.org/mailman/listinfo/rules-users



--
  Edson Tirelli
  Software Engineer - JBoss Rules Core Developer
  Office: +55 11 3529-6000
  Mobile: +55 11 9287-5646
  JBoss, a division of Red Hat @ www.jboss.com