The answer to the question is: yes. A ppdefpattern shows that the test is
just a trailing appendix of the preceding pattern:

(defrule MAIN::related1
   (or
     (and
       (parent ?z ?x)
       (parent ?z ?y))
     (and
       (parent ?x ?y))
     (and
       (and (parent ?y ?x)
        (test (neq ?x ?y)))))
   => ...

In any case, to avoid a child being found as its own sibling, a pattern such
as
   (parent ?z ?x)
   (parent ?z ?y&~?x)
is probably preferable.
-W

On Mon, Oct 12, 2009 at 9:54 PM, David Scuse <[email protected]> wrote:

>  Ernest, I suspect that this is a question for you.
>
> The documentation on the test CE states:
>
> "A test CE is evaluated every time the *preceding* pattern on the rule's
> LHS is evaluated."
>
>  (page 41 of the current Jess manual.)
>
> The problem has been simplified from the original but the intent remains
> the same,
> that is, two identify two people who are related by blood (i.e. have a
> common ancestor
> or one is the ancestor of the other).
>
> The test CE is used to prevent a person from being related to him/herself.
>
> If the test is placed immediately after the AND, everything works as
> desired  (see related3 and related4)
> but if the test follows a different pattern (see related1 and related2),
> duplicates are generated.
>
> The question is: does the test apply only to the pattern that immediately
> precedes it,
> even if that pattern is part of a compound pattern?
>
> Thanks
> David Scuse
>
>
> (Yes, I know that the definition of related is not general; this was done
> on purpose.)
>

Reply via email to