12.8. Rules

A rule is an axiom, or statement of truth, that has more than one structure. In a rule, the truth of the first structure follows from the ability to prove the remaining structures. For example, you could add to a program a rule that displays itself as

custCharge (Name, Fee) :- 
    charge(City, Fee), customer(Name, City);

The “:-” symbol is the “if” symbol. Prolog and Logikus use this symbol rather than a comma after the first structure in a rule. This convention emphasizes the meaning of rules: The first structure is true if the latter structures are provable. Figure 12.4 shows the Rule class.

Figure 12.4. The Rule class. A rule is a sequence of structures. A query can prove itself by unifying with the first structure in a rule and ...

Get Building Parsers with Java™ now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.