Logical purity is the property of logic programs that are written only using Horn clauses.
There are two equally justifiable ways to characterise purity:
The first is based on the intrinsic property of the program being composed of pure predicates. A pure predicate is a true relation, which is logically sound, preserving algebraic laws like commutativity of conjunction.
The second way to characterise purity is based on the operational properties of predicates: Only monotonic (also called: "monotone") predicates are pure: If the predicate succeeds for any arguments, then it does not fail for any generalisation of these arguments, and if it fails for any combination of arguments, then it does not succeed for any specialisation of these arguments.
In addition, pure predicates must not produce side-effects.
Examples of pure predicates are (=)/2
, dif/2
and CLP(FD) constraints like (#=)/2
. Further examples would be (=)/2
from any E-unification.