On 30/07/2013, Aurelien Mazurie <ajmazu...@oenone.net> wrote:
> Thank you very much for this answer. It seems like 'forall' will fire the
> rule only if all the 'bag-of-items' facts are validated (i.e., if all of
> them have 'item' facts with the names listed in their 'names' slot). Is that
> correct?

Yes.

>
> If yes, then what I am trying to do is slightly different. I do expect to
> have some of the 'bag-of-items' facts failing the validation. What I want is
> to act upon those who pass (and also, incidentally, on those who do not
> pass).

Ernest's rule fires on the "pass" set.

>
> Is there a way to keep track of which, among all the 'bag-of-items' facts,
> are validated by the 'forall' CE?

The negation of the "forall" is the negated existential quantifier, thus:

(defrule check-bag-NOT-valid
  (bag-of-items (names $?   ?name   $?))
  (not (item (name ?name)))
=>
  (printout t "The bag contains invalid " ?name crlf))

The rule fires for each of the bad items in a bag. Sometimes this is
desired. If not, the bad bag might be retracted or marked as "bad" in
an additional slot.

-W

>
> Best,
> Aurélien
>
> ps: 'dynamic' may be a poor choice of words. I meant that the LHS had to
> dynamically adapt to the content of a fact's multislot, different from one
> fact to another
>
> On Jul 30, 2013, at 8:21 AM, "Friedman-Hill, Ernest [via Jess]"
> <ml-node+s2305737n4654179...@n4.nabble.com> wrote:
>
>> Not sure what "dynamic" means in this context. But you can use the
>> "forall" conditional element to implement this rule. You could read the
>> LHS here as "For all values of ?name in bag-of-items, there's a
>> corresponding item fact."
>>
>> (defrule check-bag-valid
>>     (forall
>>         (bag-of-items (names $?    ?name   $?))
>>         (item (name ?name)))
>>     =>
>>     (printout t "The bag is valid" crlf))
>>
>> NOTE: Like many complex Jess rules, this one won't fire unless before
>> adding your facts you've executed the "(reset)" command to asset
>> (initial-fact).
>
>
>
>
>
> --
> View this message in context:
> http://jess.2305737.n4.nabble.com/Dynamic-rule-matching-in-the-LHS-tp4654176p4654180.html
> Sent from the Jess mailing list archive at Nabble.com.


--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users y...@address.com'
in the BODY of a message to majord...@sandia.gov, NOT to the list
(use your own address!) List problems? Notify owner-jess-us...@sandia.gov.
--------------------------------------------------------------------

Reply via email to