The rules in the Algernon knowledge-base determine which inferences will take place. Here, we give two rules that show how the husband and wife relations determine gender of the participants. Along with the rules implied by the :backlink and :inverse keywords to the :slot declarations, these rules fill out the implications of a single asserted relationship between two people.
(tell '((:rules people ((wife ?x ?p1) -> (gender ?p1 female)) ((husband ?x ?p1) -> (gender ?p1 male)))))
Rules are associated with sets, so the above rules are only considered in case the variable ?x is bound to an individual known to belong to the set people.
Relatively little is known about controlling mixed forward- and backward-chaining inference, so many systems are restricted to only one direction. This example uses only forward-chaining inference, but later examples will demonstrated mixed inference. One convention that appears to be useful is to use forward-chaining rules to maintain invariants that should be true of the information explicitly appearing in the KB, and backward-chaining rules to do search-based problem-solving. Other conventions are certainly possible.