PRD Refraction Repeatability

From RIF
Jump to: navigation, search

This page is intended to explain and host the discussion about refracation vs. repeatability.

It is linked to Action 634.

Terminology used in this page

  • Rule instance: Instantiation of a rule over a substitution.
  • Conflict set: The set of rule instances currently under consideration by the PICK function.
  • A rule instance is created: Denotes a rule instance that becomes a member of the conflict set.
  • A rule instance is removed: Denotes a rule instance that is removed from the conflict set.

Note: When a rule instance becomes a member of the conflict set, the rule instance is not necessarily fired. It will first be subject of all the selection principles such as priority, recency, and only if it is selected, it will be fired.


  • Refraction: When a rule instance is fired, it is removed from the conflict set (and thus will not be created again even its condition part remains true), unless one of the objects in its condition part is modified again. In the later case, the repeatability concept determines how the rule instance is treated.
  • Repeatability: After the execution of a rule instance, the rule instance is removed from the conflict set by the refraction. Later on, if one of the objects in the condition part is modified and if the rule evaluates to true, the repeatability controls whether if the rule instance can be created again.

To better illustrate these concepts, I give some examples of rules, written in a pseudo-language, and illustrate their behavior in the different cases.

Illustration by examples

Example 1

IF Car (status is OnHighway, speed > 70)
Then Assert Waning-message(“slow down the speed”);

Description: If a car running on the highway has a speed greater than 70, then issue a warning message (by asserting an object).

This rule is fired when a car with a speed of 80 is asserted, or when the speed of a car is changed from 60 to 80. After the rule is fired (on a specific car), a warning message will be asserted and remains in the WM.

Then we have different scenarios:

  • The speed of the car is modified:
    • Case A: From 90 to 100 (the rule condition was true and remains true after modification)
      • Repeatable = true: a rule instance is created.
      • Repeatable = false: a rule instance is not created.
    • Case B: Modified from 100 to 60: The rule instance is removed (condition becomes false).
    • Case C: Modified from 60 to 80: a rule instance is created, whatever the value of repeatability (condition changes from false to true).
  • If some other attribute of car is modified and the condition part remains true. We are in the same case as Case A.

Example 2

IF Employee (job is Architect, salary < 100)
THEN Modify employee salary = salary * 1.1;

Description: If an employee whose job is architect has a salary of less than 100, then modify the employee’s salary and increases it by 10%.

Following cases are considered:

  • Initial salary is 80, after rule firing, it is raised by 10% and the new salary is 88.
    • The condition is still true, the rule remains logically applicable.
      • If it is repeatable, then the instance will be created.
      • If not repeatable, the rule instance will not be created.
  • Initial salary is 95, it is reaised to 95x1.1=104,5, the rule is not longer true, and we don’t have to consider the repeatability flag.

Note that if the author’s intention is to apply the rule only once, then the rule should be marked as non-repeatable.

Example 3

IF Car (status = OnHighway, speed < 60)
THEN modify speed = speed + 5;

Description: If a car on a high way has a speed less than 60, then accelerate and add 5 to its speed.

The behavior of this rule is the same as the previous one. However, the author of this rule has designed it to be repeatable. So starting with a car on the highway having the speed of 30, the rule keeps applicable until the speed reaches 60.


This page illustrates the differences between refraction and repeatability. They do not control the same thing. Although the rule systems have a wide acceptation of refraction, the notion of repeatability may vary.

The important thing here is to observe that both concepts exist, and that we don't use one word for the other. For PRD, we need to specify the refraction principle. The "repeatability" should also be specified, at least minimally. One option could be to provide some flexibility so that each system could implement its own repeatability.