Use deftemplate facts:
(deftemplate relation
(slot reflexive) (slot actor) (slot object))
(deffacts family
(relation (reflexive love) (actor father) (object mother)))
(defrule reflect
(relation (reflexive ?r) (actor ?obj1) (object ?obj2))
=>
(assert (relation (reflexive ?r) (actor ?obj2) (object
?obj1))))
This is not only more readable and maintainable but more efficient internally.
I think PhiHo Hoang wrote:
>
> I tried:
>
> (defrule reflect
> (reflexive ?rel)
> (?rel ?obj1 ?obj2)
> =>
> (assert (?rel ?obj2 ?obj1))
> )
>
>
> (deffacts family
> (reflexive love)
> (love father mother)
> (love brother sister)
> )
>
> (deffacts business
> (reflexive hate)
> (hate Sun Microsoft)
> )
>
> and realised that the pattern (?rel ?obj1 ?obj2) is not acceptable because
> the head is not an atom.
>
> I can work around by putting a dummy head to the pattern like:
>
> (defrule reflect
> (reflexive ?rel)
> (relation ?rel ?obj1 ?obj2)
> =>
> (assert (relation ?rel ?obj2 ?obj1))
> )
>
>
> (deffacts family
> (reflexive love)
> (relation love father mother)
> (relation love brother sister)
> )
>
> (deffacts business
> (reflexive hate)
> (relation hate Sun Microsoft)
> )
>
> The extra "relation" looks ugly. Is there a better solution for this
> problem?
>
> Thank you for your help.
>
> PhiHo.
>
>
> ---------------------------------------------------------------------
> To unsubscribe, send the words 'unsubscribe jess-users [EMAIL PROTECTED]'
> in the BODY of a message to [EMAIL PROTECTED], NOT to the
> list. List problems? Notify [EMAIL PROTECTED]
> ---------------------------------------------------------------------
>
>
---------------------------------------------------------
Ernest Friedman-Hill
Distributed Systems Research Phone: (925) 294-2154
Sandia National Labs FAX: (925) 294-2234
Org. 8920, MS 9214 [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. List problems? Notify [EMAIL PROTECTED]
---------------------------------------------------------------------