JESS: RHS : Is it possible to assert (A or B or C) ?

View: New views
2 Messages — Rating Filter:   Alert me  

JESS: RHS : Is it possible to assert (A or B or C) ?

by Jean-Francois Lassonde :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,
 
I'm not sure if it's even possible to do this...

I would like to define a rule that when matched, will add a fact to the KB that says "Paul have-object A or B or C"... I tried several syntaxes
 
(defrule person-have-at-least-1-of-these-objects
    ...
    =>
    (assert 
       ...My ATLEAST fact here...
    )
  
First, with an OR. This does not work because "person-have-object" is a fact and not a function which is what "or" expect.
 
 (assert
  (or
    (person-have-object ?person ?object1)
    (person-have-object ?person ?object2)
    (person-have-object ?person ?object3)
  )
 )
 
Switching the or and assert is not really what I need either because it will assert all three facts.
 
 (or
  (assert
    (person-have-object ?person ?object1)
    (person-have-object ?person ?object2)
    (person-have-object ?person ?object3)
  )
 ) 
 
An "or" on 3 asserts will just take the first fact and add it to the KB. This is not what I want.
 
 (or
  (assert (person-have-object ?person ?object1))
  (assert (person-have-object ?person ?object2))
  (assert (person-have-object ?person ?object3))
 ) 
 
How can I explicitly state that ?person have ?object1 OR ?object2 OR ?object3?
 
Is there a way to do 3 assert and negating them with (not)? Or do I need to add a "special fact" that takes 3 arguments?
 
Thank you very much,

--
Jean-Francois Lassonde

Re: JESS: RHS : Is it possible to assert (A or B or C) ?

by Ernest Friedman-Hill :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

A fact in working memory is a real, physical Java object; it's either  
there, or it's not there. There's no way of saying "sort-of, partly  
assert this fact."

The most straightforward way to represent this would just be as a fact  
called something like "has-one-or-more-of", containing the list of  
possibly associated facts.

On May 23, 2008, at 3:58 PM, Jean-Francois Lassonde wrote:

> Hi,
>
> I'm not sure if it's even possible to do this...
>
> I would like to define a rule that when matched, will add a fact to  
> the KB that says "Paul have-object A or B or C"... I tried several  
> syntaxes
>
> (defrule person-have-at-least-1-of-these-objects
>     ...
>     =>
>     (assert
>        ...My ATLEAST fact here...
>     )
>
> First, with an OR. This does not work because "person-have-object"  
> is a fact and not a function which is what "or" expect.
>
>  (assert
>   (or
>     (person-have-object ?person ?object1)
>     (person-have-object ?person ?object2)
>     (person-have-object ?person ?object3)
>   )
>  )
>
> Switching the or and assert is not really what I need either because  
> it will assert all three facts.
>
>  (or
>   (assert
>     (person-have-object ?person ?object1)
>     (person-have-object ?person ?object2)
>     (person-have-object ?person ?object3)
>   )
>  )
>
> An "or" on 3 asserts will just take the first fact and add it to the  
> KB. This is not what I want.
>
>  (or
>   (assert (person-have-object ?person ?object1))
>   (assert (person-have-object ?person ?object2))
>   (assert (person-have-object ?person ?object3))
>  )
>
> How can I explicitly state that ?person have ?object1 OR ?object2  
> OR ?object3?
>
> Is there a way to do 3 assert and negating them with (not)? Or do I  
> need to add a "special fact" that takes 3 arguments?
>
> Thank you very much,
>
> --
> Jean-Francois Lassonde

---------------------------------------------------------
Ernest Friedman-Hill
Informatics & Decision Sciences          Phone: (925) 294-2154
Sandia National Labs                FAX:   (925) 294-2234
PO Box 969, MS 9012                 ejfried@...
Livermore, CA 94550                 http://www.jessrules.com




--------------------------------------------------------------------
To unsubscribe, send the words 'unsubscribe jess-users you@...'
in the BODY of a message to majordomo@..., NOT to the list
(use your own address!) List problems? Notify owner-jess-users@....
--------------------------------------------------------------------

LightInTheBox - Buy quality products at wholesale price