I'm going to introduce a more complex example, with some inference. I won't explain how all the inference works; see the references in Appendix B if you're interested. The example is from the same source as the aforementioned genealogy ontology.
Let's take a look at how we can infer new knowledge using the inference rules in Figure 14.7. The letters after the question marks are local variables, local to that rule. In formal semantics they are usually x and y, but here they are letters that are mnemonic for the domain. In rule 1 we assert that if a child c is in family f, and a parent p is a spouse in the same family f, then we can logically infer that c's parent is p. Because of the inverse declared previously, we now already know that c is p's child. (I realize it seems obvious to a human, but this is hard for a computer to work out.)
(: rule1. ?c gc:childIn ?f. ?p gc:spouseIn ?f) log:implies (?cgc:parent ?p). ... (: rule6. ?c gc:parent ?p. ?p gc:parent ?gp) log:implies (?c gc:grandparent ?gp). (: rule7. ?c gc:grandparent ?gp. ?gp gc:sex :M) log:implies (?c gc:grandfather ?gp).
In a similar form, rule 6 tells us that if child c has a parent p, who in turn has a parent gp, then c's grandparent is gp. Rule 7 tells us that if the grandparent is male, he is also a grandfather to the child.
Armed with the two dozen or so rules in this particular ontology, we could infer just about anything from a database of an extended family as long as we knew the members of each immediate family. We could pose and get sensible answers to questions such as "Who is Billy's uncle?" and "Are Sarah and Irving cousins?" even though the family database does not explicitly specify these relationships.