I think [EMAIL PROTECTED] wrote:

> 
> I would now like to add a defrule which states:
> " A FootballPlayer can play for only one team."


Aaak, aaak, aaak. Repeat after me: "Queries are for contexts in which
you can't do pattern matching."

If you want to write a rule which watches for such double assertions,
and fixes them, then you want to do something like

(defrule remove-redundant-affiliations
   (PropertyValue rdf:type         ?n   football:FootballPlayer)
   ?t1 <- (PropertyValue football:team  ?n      ?)
   ?t2 <- (PropertyValue football:team  ?n      ?)
   (test (> (?t2 getFactId) (?t1 getFactId)))
   =>
   (retract ?t2)

If, on the other hand, you want to prevent such assertions from ever
happening, there are several possibilities. One is to match for the
preexistence of an affiliation before asserting a new one -- this
presupposes that such assertions will come from the RHS of a rule:

(defrule assert-affiliation-carefully
   (PropertyValue rdf:type         ?n   football:FootballPlayer)
   (not (PropertyValue football:team  ?n        ?))
   ...
   =>
   (assert PropertyValue football:team  ?n      whatever))

Or, if the assertions can come from many different random places, you
-could- try adding defadvice to the assert function. This would be
messy and I'm not going to work out the details here, but it
definitely be possible. The defadvice -would- use
count-query-results, since it wouldn't be in a position to
pattern-match directly.
        

---------------------------------------------------------
Ernest Friedman-Hill  
Distributed Systems Research        Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 [EMAIL PROTECTED]
Livermore, CA 94550         http://herzberg.ca.sandia.gov

--------------------------------------------------------------------
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