I'm having a problem executing queries with 'not's in them.

My goal is checking set membership with intersections, so I've
defined the following three queries:

Q1 - Items in set 1
Q2 - Items in both set 1 and set 2
Q3 - iitems in set 1 that are not in set 2

Unless I'm having a logic problem or brain hiccup, :-), it appears
to me that the count of results from Q1 should equal the count from
Q2 plus the count from Q3, but the third query, the one containing
the 'not', seems to always return zero, as shown below:


    Jess> (defquery q1 (declare (variables ?s1)) (comesFrom ?object ?s1))
    TRUE
    Jess> (defquery q2 (declare (variables ?s1 ?s2)) (comesFrom ?object ?s1) 
(comesFrom ?object ?s2))
    TRUE
    Jess> (defquery q3 (declare (variables ?s1 ?s2)) (comesFrom ?object ?s1) (not 
(comesFrom ?object ?s2)))
    TRUE
    Jess> (count-query-results q1 "s1")
    240
    Jess> (count-query-results q1 "s2")
    108
    Jess> (count-query-results q2 "s1" "s2")
    45
    Jess> (count-query-results q3 "s1" "s2")
    0

BTW, I tried putting in rule that looked query 3 with another fact to pass in the 
variables, 

    Jess> (defrule checkIT (compareSources ?s1 ?s2) (comesFrom ?object ?s1) (not 
(comesFrom ?object ?s2)) => (printout t "Found " ?object crlf))
    TRUE
    Jess> (assert (compareSources "s1" "s2"))
    <Fact-10451>

and I got lots of output when I ran it:

    Jess> (run)
    FIRE 1 MAIN::checkIT f-10451, f-10402,
    Found HC:m:301
    FIRE 2 MAIN::checkIT f-10451, f-10401,
    Found HC:m:302
    FIRE 3 MAIN::checkIT f-10451, f-10400,
    Found HC:m:300
    FIRE 4 MAIN::checkIT f-10451, f-10399,
    Found HC:m:299

Is this a bug, or am I doing something wrong?

Bruce

--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
in the BODY of a message to [EMAIL PROTECTED], NOT to the list
(use your own address!) List problems? Notify [EMAIL PROTECTED]
--------------------------------------------------------------------

Reply via email to