6.6 Clauses and predicates

Clauses

A fact is a clause, and a rule is a clause. This can be expressed as in the following type-hierarchy:

Thus "clause" is the general name we give to rules and facts collectively.

Predicates

Recall that clauses are either facts or rules.

Facts can be a number of things, including structures and atoms, and so can the heads of rules.

If more than one fact consists of the same structure or atom, they are collectively called a predicate.

Similarly, if more than one rule have heads that are the same atom or structure, they are collectively called a predicate.

Example

// Type hierarchy
Animal > Dog, Cat.

// A predicate of facts
graph(graph1, [Cat]).
graph(graph2, [Dog]).

// A predicate of rules
animal_is_in_graph(L) :- graph(L, G), concOfCG([Dog], G).
animal_is_in_graph(L) :- graph(L, G), concOfCG([Cat], G).

Note how the "animal_is_in_graph" predicate could have been reduced to one rule by taking advantage of the type hierarchy:

animal_is_in_graph(L) :- graph(L, G), concOfCG([Animal], G).

Summary

Thus a clause is either a rule or a fact. A predicate is a collection of facts which are the same structure or atom, or a collection of rules which have the same structure or atom in their heads.


PrevLite: 6.5 Rules, Goals and Subgoals
NextLite: 6.7 Matching

Prev: 6.5 Rules, Goals and Subgoals
Up: 6 Prolog for CG users
Next: 6.7 Matching