This has been bothering me for some time now so I thought I'd ask about 
it. I think can kludge a solution through some counters and using 
queries in the RHS but I'd prefer a cleaner (more efficient solution?), 
which I just can't figure out.

The basic problem is trying to convert the following first order 
statement (in KIF-ish form) into Jess:

   (forall (?x, ?list)
     (iff (of-list ?x ?list)
          (forall (?item)
            (and (list-item ?list ?item)
                 (assoc ?x ?item)
            )
          )
     )
   )

The words don't really mean anything, but to take a shot at it "An 
object ?x is of-list of some object ?list is equivalent to ?x being 
assoc to each object ?item related to ?list through list-item."

You can handle one direction in the equivalency (the notion of the RHS 
as neccesary) pretty simple as:

(defrule Rule1
   (of-list ?x ?list)
   (list-item ?list ?item)
=>
   (printout t "//-- " ?x " is assoc " ?item crlf)
)

The reverse implication (the notion of the RHS as sufficient) seems to 
be more difficult. I thought something like this would do it:

(defrule Rule2
   (list-item ?list ?item1)
   (assoc ?x ?item1)
   (not (and (list-item ?list ?item2)
     (not (assoc ?x ?item2))
   ))
=>
   (printout t "//-- " ?x " is of-list " ?list crlf)
)

But the forall construct there in the (not (and () (not ()))) seems to 
be quantified in some manner that I can't grasp. I thought the use of 
the construct stemmed naturally from thinking of the problem as:
   "If there is some ?x which is assoc with a list-item and it is not 
true that there exists a list item for which ?x is not assoc then the 
RHS should be evaluated."
But, I guess I'm wrong.

For example, if we assert:
   (list-item Tree Leaf)
   (list-item Tree Root)

   (of-list Joe Tree)

Then first rule works as expected. If we assert:
   (assoc Mike Leaf)
   (assoc Mike Root)

Then the second rule works as expected. However, if we had also asserted:
   (assoc Ann Root)

Then the second rule wouldn't have fired. I guess I don't understand the 
binding pattern for ?x there. You could read the construct (as the Jess 
manual does) as "if for every fact (a ?x), there is a fact (b ?x)" but 
then it's not clear to me why if I assert:
   (assoc Mike Leaf)
   (assoc Ann Root)

Nothing happens, even though that seems to fit the reading (combined 
with the list-item assertions above). Also, that reading doesn't seem 
equivalent to the other statement the manual makes, "It is not true that 
for some ?x, there is an (a ?x) and no (b ?x)." Any clarification or 
help would be appreciated.

-- 
- joe kopena

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