The algorithm for detecting unsafe rules is now located in a dedicated class: RuleValidator. This algorithm is taken from Principles of Database and Knowledgebase Systems, Ullman, page 105:

A rule is considered safe if all variables are limited.

A variable is limited if:

- It appears in a positive ordinary predicate
- It appears in a positive equality with a constant, e.g. ?X = 'a'
- It appears in a positive equality with another variable known to be limited, e.g. ?X = ?Y, ?Y = 'a'

However, rule validation in IRIS can be parameterised to allow the relaxation of two aspects of this algorithm, specifically:

- variables that ONLY appear in a negated ordinary predicate (and nowhere else) can still make for a safe rule, because such a rule can be re-written to move the negated sub-goal to a separate rule, see the example in Ullman, page 129-130
- Furthermore, variables that appear in arithmetic predicates can also be considered limited if all the other variables are known to be limited, e.g. ?X + ?Y = ?Z, ?X = 3, ?Z = 4, implies that ?Y is also limited

These two relaxations of the definition of a safe rule are configurable (on/off) in the RuleValidator class.

If an unsafe rule is detected during the evaluation of a logic program then a RuleUnsafeException is thrown containing details of why the rule is considered unsafe.