Hi,
Thank you your your help. I wish if I could factor out the relations and
their nature. I tried to extend my sample like this:
(defrule reflect
(reflexive ?rel)
(relation ?rel ?obj1 ?obj2)
=>
(assert (relation ?rel ?obj2 ?obj1))
)
(defrule transit
(transitive ?rel)
(relation ?rel ?obj1 ?obj2)
(relation ?rel ?obj2 ?obj3&:(not (eq ?obj1 ?obj3)))
=>
(assert (relation ?rel ?obj1 ?obj3))
)
(deffacts relations
(reflexive love)
(transitive love)
)
(deffacts family
(relation love father mother)
(relation love brother sister)
(relation love sister mother)
)
A relation may have many properties and I found it confusing to translate
this into the templates.
Thank you,
PhiHo.
----- Original Message -----
From: Ernest Friedman-Hill <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 07, 1999 1:57 PM
Subject: Re: JESS: Newbie question: Pattern in a rule
> 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]
> ---------------------------------------------------------------------
>
>
---------------------------------------------------------------------
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]
---------------------------------------------------------------------