You want two things that your rule doesn't actually state. One is that
?x and ?y aren't the same; the other is that ?x and ?y are in
alphabetical order (or, at least that's one way to express the
uniqueness contraint.) So you have to put these into the rule.
In cases like this I find it's often worth creating a tiny
deffunction for clarity, and of course well-chosen variable names help
too:

(deffunction in-proper-order (?x ?y)
  "Return true when two lexemes are in alphabetical order"
  (> 0 (str-compare ?x ?y)))

(defrule find-siblings
  (parents-of ?child1 ?dad ?mom)
  (parents-of ?child2 ?dad ?mom)
  (test (in-proper-order ?child1 ?child2))
  =>
  (printout t ?child1 " " ?child2 crlf))




I think Archana Raghavendra wrote:
[Charset iso-8859-1 unsupported, filtering to ASCII...]
> Hi all,
>         i am new to jess and am having problems with this.I create a .clp file which 
>is like this.
> 
> (deffacts list
> (parents-of bob john mary)
> (parents-of sue john mary)
> (siblings hansel gretel)
> )
> 
> (defrule  find-siblings
> (parents-of ?x ?a ?b)
> (parents-of ?y ?a ?b)
> =>
> (printout t ?x ?y))
> 
> (reset)
> (run)
> 
> when i run this, I get 4 combinations,
> bob and bob 
> bob and sue
> sue and sue
> sue and bob
> 
> whereas I only want one.
> bob and sue OR sue and bob.
> 
> Archana
> 
>  



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

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