My knowledgebase starts with certain information about the structure
of a planar graph. It infers that there's a face on opposite sides of
each edge, and some additional information from the nodes. It then
tries to infer which of these edge faces are the same faces as others,
for example to edges that are adjacent at node would share a face.
The faces are represented by generated atoms. I've been using a
binary relationship to show that two such atoms represent the same
face, e.g.
(same-face face-4 face-13)
with rules that implement the reflexive, symetric and transitive
properties of this relation, for example:
(defrule same-face-symetric
(same-face ?b ?a)
=>
(assert (same-face ?a ?b)))
(for the sake of clarity, I've edited out some additional logic in the
predicate that reduces redundant firings of this rule).
This representation leads to much clutter in the knowledgebase since
it requires that a set of n equivalent faces is represented as
2 * (n choose 2)
facts. This clutter is making it hard to diagnose why my kb isn't
concluding what I'm hoping for (information leading to a graphical
layout of the planar graph).
I thought that by representing the equivalences using
sets/multifields, the kb would be easier to diagnoose:
(deftemplate equiv-face
(multislot set))
(defrule equiv-faces-merge
?fact1 <- (equiv-face (set $?set1))
?fact2 <- (equiv-face (set $?set2))
(test (not (eq ?fact1 ?fact2)))
;; ** Is this the way to test that an intersection is not empty?
(test (intersection$ $?set1 $?set2))
=>
(assert (equiv-face (set (union$ $?set1 $?set2))))
(retract ?fact1)
(retract ?fact2))
(defquery equiv-faces
(equiv (set $?set)))
(deffunction test-equiv (?thing1 ?thing2)
(bind ?e (run-query equiv-faces))
(while (?e hasMoreElements)
(bind ?elt (call ?e nextElement))
(find ?fact (call ?elt fact 1))
(bind $?set (fact-slot-value ?fact set))
(if (and (member$ ?thing1 $?set)
(member$ ?thing2 $?set))
then
(return ?fact)))
(return FALSE))
Will this work? Is that the right test for intersection?
The kb also knoos that the two edge faces of an edge are "opposites"
of one another:
(opposite-faces face-3 face-4)
Given one such assertion, I want to be able to test oppositeness of
any two faces that are equivalent to face-3 and face-4 respectively.
I think I can do this with the following in the predicate half of a
rule
(opposite-faces ?op-face1 ?op-face2)
(test (or (and (test-equiv ?face1 ?op-face1)
(test-equiv ?face2 ?op-face2))
(and (test-equiv ?face2 ?op-face1)
(test-equiv ?face1 ?op-face2))))
Is there some way to encapsulate that test to that it can be
conveniently used in a number of rules?
Is there a more efficient way to go about this?
--------------------------------------------------------------------
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]
--------------------------------------------------------------------