next up previous contents
Next: Facts Up: Example: Forward- and Backward-Chaining Previous: Slots

Rules

Gender-specific relations are tightly connected by matched forward- and backward-chaining rules to their gender-neutral counterparts.

  (tell '((:rules people
           ((father ?x ?f) -> (parent ?x ?f) (gender ?f male))
           ((father ?x ?f) <- (parent ?x ?f) (gender ?f male))

           ((mother ?x ?f) -> (parent ?x ?f) (gender ?f female))
           ((mother ?x ?f) <- (parent ?x ?f) (gender ?f female))

           ((son ?x ?s) -> (child ?x ?s) (gender ?s male))
           ((son ?x ?s) <- (child ?x ?s) (gender ?s male))

           ((daughter ?x ?d) -> (child ?x ?d) (gender ?d female))
           ((daughter ?x ?d) <- (child ?x ?d) (gender ?d female))

           ((brother ?x ?b) -> (sibling ?x ?b) (gender ?b male))
           ((brother ?x ?b) <- (sibling ?x ?b) (gender ?b male))

           ((sister ?x ?b) -> (sibling ?x ?b) (gender ?b female))
           ((sister ?x ?b) <- (sibling ?x ?b) (gender ?b female))

           ((grandfather ?x ?gf) -> (grandparent ?x ?gf) (gender ?gf male))
           ((grandfather ?x ?gf) <- (grandparent ?x ?gf) (gender ?gf male))

           ((grandmother ?x ?gf) -> (grandparent ?x ?gf) (gender ?gf female))
           ((grandmother ?x ?gf) <- (grandparent ?x ?gf) (gender ?gf female))

           ((grandson ?x ?gs) -> (grandchild ?x ?gs) (gender ?gs male))
           ((grandson ?x ?gs) <- (grandchild ?x ?gs) (gender ?gs male))

           ((grandaughter ?x ?gs) -> (grandchild ?x ?gs) (gender ?gs female))
           ((grandaughter ?x ?gs) <- (grandchild ?x ?gs) (gender ?gs female)))))

More complex rules show how to infer some relations from others. Note that it isn't correct to say that one relation is defined in terms of more primitive relations. Rather, there is a network of inferences that link relations together. For example, the uncle relation can be inferred from parent and brother, or from aunt and husband, but it can also be asserted without commitment to which type of relation forms the intermediate link.

The :neq special form succeeds if two frames are not identical, and is necessary here to define the relation sibling. These rules demonstrate the use of embedded terms such as (father (parent ?a) ?c) as an abbreviation for (parent ?a ?b) (father ?b ?c).

  (tell '((:rules people

           ((grandfather ?a ?c)  <- (father (parent ?a) ?c))
           ((grandmother ?a ?c)  <- (mother (parent ?a) ?c))
           ((grandson ?a ?c)     <- (son (child ?a) ?c))
           ((grandaughter ?a ?c) <- (daughter (child ?a) ?c))

           ((sibling ?x ?y) <- (child (parent ?x) ?y) (:neq ?x ?y))

           ;; Aunt and Uncle are a bit different (there is no unisex term):
           ((uncle ?x ?u) -> (gender ?u male))
           ((aunt ?x ?a)  -> (gender ?a female))

           ((uncle ?x ?u) <- (brother (parent ?x) ?u))
           ((uncle ?x ?u) <- (husband (aunt ?x) ?u))
           ((aunt ?x ?a)  <- (sister (parent ?x) ?a))
           ((aunt ?x ?a)  <- (wife (uncle ?x) ?a))

           ((husband ?w ?h)
            <-
            (gender ?w female) (spouse ?w ?h) (gender ?h male))
           ((wife ?h ?w)
            <-
            (gender ?h male) (spouse ?h ?w) (gender ?w female)))))



Micheal S. Hewett
Tue Oct 29 10:54:13 CST 1996