Abstract
Active rules have been employed for enhance self-reaction functionality, but how to detect their confluence property during an indeterminable rule process is intractable. If two rules without priority have been triggered at the same time, then anyone can be firstly chosen to execute at random and two different executive sequences will be arisen. An active rule set is confluence if and only if the same final database state appears no matter which executive sequence has been chosen to execute. The existing methods based on Rule Commutativity are no more effective to detect the confluence case if a rule set has exclusive rules and has no user-defined priority as they do not designed for rules without priority and they do not consider whether two different executive sequences for rules can be satisfied by the same database state. To address these problems, this work proposes the concepts of Exclusive Rule and Confluence Requirement with exclusive rules based on the conditional formula of an executive sequence. Then, a new algorithm for confluence detection is provided. The examples and theoretical analysis clearly show that the proposed method achieves much better detection performance when exclusive rules appear.
Introduction
Recently, active rules have attracted many researchers’ attention and have been applied for many new fields such as XML document [1, 2], RDF [3], Semantics network [4] and sensor database [5], etc. In addition, active database systems provide a convenient platform for large and efficient knowledge-bases and expert systems [6]. Active rules follow the paradigm as Event-Condition-Action. If two rules have been triggered at the same time and there is no priority between their executions, then one of them can be firstly chosen to execute at random and two different executive sequences will be arisen. An active rule set is confluence if and only if the same final database state appears no matter which executive sequence has been chosen to execute. Data consistency is one of crucial aspects to guarantee the data quality of a database. Obviously, the confluence property of rules will maintain the data consistency.
The existing approaches are based on Rule Commutativity to detect whether an active rules set is confluence [6–9], but they are conservative to some degree. Aiken et al. [6] presented the precondition to guarantee the confluence property based on Rule Commutativity; Comai et al. [7] tried to transform active rules into deductive rules with better-defined terms, then detect the confluence property based on their triggering priorities; Papamarkos et al. [8] presented how to detect the Rule Commutativity of rules on RDF Metadata; Bostan-Korpeoglu et al. [9] inferred a total order of the triggering priorities of a rule set using a fuzzy Petri net model. These approaches have the following inadequacies: They are specially designed for an active rule set with priority and don’t consider those rules without priority. From the following example 2, we can see that an active rule set without user-defined priority may appears in an application. Also, Baralis et al. [10] considered an active rule set with priority or without priority when addressing the termination detection problem. If an active rules set has a total order of the triggering priorities, its rule processing is deterministic and it is confluent [11]. It is shown that our consideration in this paper is significant, that is, an active rule set without priority is more easily to exhibit the non-confluence property than those rules with priority. Based on Rule Commutativity, they consider all possible executive sequences (i.e. paths in a executive graph in [6]) which originated from the same initial database state when detecting whether the same final database state appears after whichever executive sequence has been chosen to execute; However, they ignore that such an executive sequence may be not really executed if there is a rule in it cannot be satisfied its condition by the current database state. Obviously, an executive sequence should not affect the confluence property if it is not really executed; that is, the existing approaches would be not effective unless such an executive sequence has been identified and considered.
To address the above inadequacies, the concepts of Exclusive Rule and Confluence Requirement with exclusive rules are proposed in this paper for a rule set without user-defined priority. As discussed later, exclusive rules will usually appear for expressing the control logic just like the switch-case structure in C or C++ programs. Moreover, a new algorithm of confluence detection is provided for an active rule set with exclusive rules, and its complexity is analyzed.
This paper is organized as follows. Section 2 presents a brief review of Confluence Requirement and confluence analysis in existing methods. An example in Section 3, which models the behavior of a control system, illustrates our motivation in this paper. Section 4 defines exclusive rules and prepares a theorem to identify them. After analyzing the inadequacy of the existing methods, Confluence analysis for a rule set without priorities is developed in Section 5. A new algorithm is presented to analyze the confluence of a rule set with exclusive rules in Section 6. The conclusion is shown in Section 7.
Preliminary
Active rule
Active rule follow the paradigm Event-Condition-Action (ECA). Using relational database schema, ECA rules can be expressed as follows [11]:
(1) The Event set is a set of data manipulate operations that are monitored by system; (2) Condition is a sentence which consists of the predicates defined on the current database state and transition values appeared in rules; (3) Action is a set of data manipulate operations.
r1:
event:
update (sensor.T), sendMessage (‘valve opened’)
condition:
valve.state=‘open’, sensor.T < T1, valve.lock:=‘on’
action:
valve.lock:= ‘off’, valve.state:= ‘closed’,
sendMessage (‘valve closed’);
The indeterminable rule process
The rule process will be performed by the following steps [11]: If there is no triggered rule, then the process ends; To choose a rule which is triggered and set it untriggered; To evaluate the condition of the chosen rule; If the condition of the chosen rule is evaluated as true, then its action will be performed.
A new event may be arisen during the rule’s action execution in step 4) and it may trigger other rules, then the above scheduling sequence as 1)-2)-3)-4) will repeat until no triggered rule is left and the rule process ends.
Maybe more than one rule is triggered in step 2) and they compose the set of conflict rules [11]. If there is no priority between two conflict rules, then anyone of them can be firstly chosen to execute at random and the rule process is indeterminable [11]. Many different executive sequences will be arisen during an indeterminable rule process, thus the confluence or non-confluence property should be detected to show whether the same final database state appears no matter which executive sequence has been chosen to execute. Such a case will be illustrated by the Example 2 in Section 3.
Confluence analysis based on rule commutativity
Illustrated as Fig. 1 abstracted from Aiken et al. [6], we say that two rules ri and rj are commutative if, given any state S in any execution graph for active rules process, considering rule ri and then rule rj from state S produces the same state S′ as considering rule rj and then rule ri.
Based on Rule Commutativity, the confluence requirement is presented in [6]. That is, if two different executive sequences can be scheduled at random and any two rules, which are abstracted respectively from them, are commutative, then they can be converted each other through Rule Commutativity. Really, such two executive sequences are equivalence.
To simplify, the following notations will appear in the rest of this paper. Let R = {r1, r2, … , rn} be a rule set and P = {ri > rj, rk > r1, ⋯} be the priorities assigned for R, where ri > rj means that ri has priority over rj in scheduling for execution. Let Triggers(r) be the set of rules triggered by r’s action (such a rule may be r itself)
rj∈T riggers(ri), i.e.,rican causerj, to become triggered; rican untriggeredrj; ri’s operations can affect whatrjuses; ri’s insertions can affect whatrjupdates or deletes; ri’s updates can affectrj’s updates; any of 1–5 withriandrjreversed.
For every pair of rules r1 ∈ R1 and r2 ∈ R2, r1 and r2 must commute.
From Theorem 1, it is known that the termination property for execution should hold if a rules set is confluent. How to detect the termination property of a rule set is another crucial issue [10–16] and is omitted as it goes beyond this paper.
As Aiken et al. [6] mentioned, the Confluence Requirement is not a necessary condition but a sufficient condition to guarantee the conclusion of theorem 1 holds. That is, applying Theorem 1 for confluence analysis is conservative to some degree. If a rules set is not satisfied by the Confluence Requirement, it may be either confluence or non-confluence.
Motivation
Here, the motivation example is used to model the behavior of a control system where active rules are shown as the form as the Example 3.4 in [11].
1) r1 is used for the generation of an alarm when the pressure of the pipe is high and falls into the scope to be control.
event: update (sensor.P)
condition:
sensor . P ≥ p1, h1 < tank . H < h2, Done= false
action: sendMessage (‘Pipe pressure is high’);
2) r2 and r3 are used for the operations reacting to the case that the pressure of pipe is high when the oil flows into the tank. Once the height of the oil exceeds the defined threshold, all valves should be closed to stop the oil flowing into the tank.
r2:
event: sendMessage (‘Pipe pressure is high’)
condition:
pipe.State= ‘in’, v1.State = ‘semiopened’
action:
v1.State= ‘open’, v2.State= ‘semiopened’
sendMessage(‘the regulation valve v1 is open’)
Done= true, sendMessage (‘the regulation is done’);
r3:
event:
sendMessage (‘the regulation valve v1 is open’), update (tank.H)
condition: pipe.State= ‘in’, tank . H ≥ h2
action:
v2.State= ‘closed’, v1.State= ‘closed’
Done= false, sendMessage (‘stop oil flowing into the tank as its height is overhigh’);
3) r4 and r5 are used for the operations reacting to the case that the pressure of pipe is high when the oil flows out of the tank. Once the height of oil is under the defined threshold, all valves should be closed to stop oil flowing out of the tank.
r4:
event: sendMessage (‘Pipe pressure is high’)
condition:
pipe.State= ‘out’, v1.State= ‘open’
action:
v1.State= ‘semiopened’, v2.State= ‘open’
sendMessage(‘the bypass valve v2 is open’)
Done=true, sendMessage (‘the regulation is done’);
r5:
event:
sendMessage (‘the bypass valve v2 is open’), update (tank.H)
condition: pipe.State= ‘out’, tank . H ≤ h1
action:
v1.State=‘closed’, v2.State= ‘closed’
Done = false, sendMessage (‘stop oil flowing out of the tank as its height is too low’);
Figure 3 represents the triggering graph of the above rule system R = {r1, r2, r3, r4, r5}.
In Fig. 3, r2 and r4 are both triggered by r1 and they form a conflict set. No priority is assigned between r2 and r4, so there are two different executive sequences: 1) if r2 is firstly chosen to execute, the executive sequence will be the form as r1 → r2 → r3 → r4 → r5; 2) if r4 is firstly chosen to execute, the executive sequence will be the form as r1 → r4 → r5 → r2 → r3.
Obviously, r2 and r4 are a pair of unordered rules represented in Definition 1. Through Definition 1, R1 and R2 are initiated with R1 = {r2} and R2 = {r4}. During the process of computing R1 and R2, some a rule will be triggered but it isn’t electable as it has not been assigned any priority. According to (3) and (5) of Lemma 1, r2 and r4 are noncommutative as v1.State appears in the conditions and actions of both r2 and r4. Based on Theorem 1, R = {r1, r2, r3, r4, r5} is non-confluent.
Really, r2 and r4 are exclusive rules because their conditions can not be both satisfied according to the following logic expression: (pipe.State=‘in’) ∩ (pipe.State=‘out’)=false. There is at most one of exclusive rules can be satisfied by the same database state. However [6–9], implicitly approved that r2 and r4 are both satisfied by the same database state and eligible for execution when identifying whether they are commutative rules. r2 and r4 are located respectively in two different executive sequences which represent the operational reactions when oil flows into or out of the tank, but the direction of flux in pipe cannot both flows into and flows out of the tank at the same time. That is, at most one of such two different executive sequences can be executed at the same database state. Thus, the rule set R = {r1, r2, r3, r4, r5} in Fig. 3 is really confluence: there is exact one final database state after R has been executed completely no matter which one of r2 and r4 is firstly chosen to execute.
Exclusive rules
Just like the switch-case structure in C or C++ which is used to express many operational options in a program, two or more rules are exclusive as they are used to react with many different cases. Such as Example 2, two groups of rules are designed respectively for the oil flowing into or out of the tank.
In Definition 2, exclusive rules refine the meaning of unordered rules and will contribute to more precise confluence detection than Aiken et al. [6] (this can be seen from Example 2).
The complexity of rules process results in the complexity of the exclusive rule detection. As the Rule Commutativity detection in [6], a sufficient condition will be provided here to detect whether a pair of unordered rules are exclusive.
Using the method presented in [17, 18], we can construct the conditional formula for two rules to detect whether they are exclusive. In [17, 18], the predicates, concerned with non-updatable variables of a rule set, will be chosen from the conditions of all rules in an executive sequence and they form the conditional formula for such an executive sequence. Non-updatable variables of a rule set R must not be updated by any rule of R and it is intuitive that there must exist a rule which cannot be executed in an executive sequence Sq if the conditional formula for Sq is false. That is, there is at least a contradiction between the conditions of two rules in Sq and at least one of such two rules can not be satisfied during the rule process of Sq. For example, r2 and r4 in Example 2 are such two rules because pipe.State is a non-updatable variable of {r1, r2, r3, r4, r5} and the conditions of {r2, r4} can not be both satisfied by the contradiction: (pipe.State=‘in’)∩(pipe.State=‘out’) = false.
Confluence detection of rules without priorities
The inadequacy of the existing methods
Confluence Requirement in Defintion1 and Confluence Theorem in Theorem 1 are both presented in Aiken et al. [6] and they aim at a rule set with priority. If analyzing a rule set without priority as Baralis et al. [10], those techniques in [6–9] will be no more effective.
The following corollaries are presented in [6] for summarizing the characteristics of a rule set with confluence.
Obviously, Corollary 2 will help us in the design of a rule set with confluence. Unfortunately, an contradiction can be deduced when these corollaries are applied. Assuming that R is found to be confluence and P = φ and r i and r j in R such that r i may trigger r j , then r i and r j are found to be ordered through Corollary 3 and they are commutative according to Corollary 2. However, it can be deduced that r i and r j may be noncommutative according to the condition (1) of Lemma 1. Also, we can see that the rule set R in Example 2 is confluence and r2 and r4 are noncommutative although they are a pair of unordered rules. That is, Corollary 1 and Corollary 2 can not be validated when they are applied for rules in Example 2. Thus, how to detect the confluence of a rule set without user-defined priorities is pending and will be addressed in this paper.
The detection of unordered rules
Indeed, it is implied in [6] that any pair of rules without user-defined priorities between them are unordered rules; thus, Corollary 1 and Corollary 2 would be valid once the confluence is detected by Theorem 1. Howerver, it is can be seen from Corollary 3 that a pair of rules should be ordered if there are no user-defined priorities between them but one of them may trigger the other. So the detection of unordered rules is a critical issue for the confluence detection.
As mentioned as [11], a triggering graph implies all triggering relations of a rule set. Base on a triggering graph, the following theorem indicates the properties that should be satisfied by unordered rules in a rule set.
In the associated triggering graph, such rules that there are no incoming arcs; That is, such rules can not be triggered by any rule;
In the associated triggering graph, such rules that their incoming arcs are originated from the same rule; That is, such rules can be triggered by the same rule;
Letr1andr2be a pair of unordered rules. Ifr
i
andr
j
, are triggered respectively byr1andr2, such two rules that one is abstracted from {r1, r
i
} and the other is abstracted from {r2, r
j
};
For those rules that there are no incoming arcs in the associated triggering graph of R, each of them need not wait a rule of R to be triggered prior to it if it wants to be triggered. Thus, such rules must be unordered. For those rules whose incoming arcs are originated from the same rule r, they will compose a set of conflict rules after r has been triggered and then r triggers them (refer to the rule process in the Section 1.2). As there are no user-defined priorities assigned for the rules of R, the rule process associated with R is indeterminate [11] and each of such rules can be firstly chosen at random for execution. Thus, such rules must be unordered. Let r1 and r2 be a pair of unordered rules and r
i
and r
j
are triggered respectively by r1 and r2. So we consider r1 and r2 have been triggered at the same time and form a conflict set as {r1, r2}. Assuming that r1 is chosen to execute prior to r2, r1 must be executed prior to r
j
but r
i
may be executed: i) prior to {r2, r
j
} if r
i
has been immediately chosen to execute; ii) subsequent to r2 or r
j
if r
i
has been deferred to execute; that is, {r
i
, r2} and {r
i
, r
j
} are unordered; Assuming that r2 is chosen to execute prior to r1, r2 must be executed prior to r
i
but r
j
may be executed either prior to {r1, r
i
} or subsequent to r1 or r
i
, that is, {r
j
, r1} and {r
j
, r
i
} are unordered. That is, that r1 and r2 are unordered causes that there are no executive order between such two rules that one is abstracted from {r1, r
i
} and the other is abstracted from {r2, r
j
}. ■
Confluence analysis for a rule set without priorities
In Theorem 3, the case (3) is used for the derivation of all unordered rules based on the triggering relations originated from a pair of unordered rules found by the case (1) and the case (2). Based on Theorem 3, the following definition is presented for Confluence Requirement of a rule set without priority. If not special specified, it is should be reminded that unordered rules indicate those rules detected by the case (1) and the case (2) of Theorem 3 in the rear of this paper, while the case (3) of Theorem 3 can guarantee that the following definition will derive all pair of unordered rules and these unordered rules should be commute to guarantee the confluence of all rules.
For every pair of rules r1 ∈ R1 and r2 ∈ R2, r1 and r2 must commute.
Now suppose that there are two rules in Sq1 which can not be commutative and cause Sq1 can not be permuted to Sq2. All rules in R are not assigned user-defined priorities, so the rule process for R is indeterminate [11]. Thus, Sq1 and Sq2 are obtained by two different schedules for the set of conflict rules during the rule process of R. Consequently, such two rules are in the set of conflict rules consisted of unordered rules that are all eligible for consideration at the same state. From the proof of Theorem 3, it is known that every pair of unordered rules in R must be commutative if the Confluence Requirement without Priorities holds for R. Thus, such two rules are unordered and commutative. This contradicts the above assumption. So the conclusion holds. ■
Confluence analysis for a rule set with exclusive rules
Based on Confluence Theorem without Priorities, next we want to determine whether the rule set with exclusive rules is confluent.
For every pair of rules r1 ∈ R1 and r2 ∈ R2, r1 and r2 must commute.
The conclusion can be proven by contradiction. Assuming that the rules in R are not confluent, then there must exist two nonequivalent executive sequences denoted as Sq1 and Sq2. That is, Sq1 can not be permuted to Sq2 without affecting the final state through the commutation of some unordered rules in R, and vice versa.
Now suppose that there are two rules in Sq1 which can not be commutative and cause Sq1 can not be permuted to Sq2 by exchanging them. All rules in R are not assigned user-defined priorities, so the rule process for R is indeterminate [11]. Thus, Sq1 and Sq2 are obtained by two different schedules for the set of conflict rules during the rule process of R. Consequently, such two rules are in the set of conflict rules consisted of unordered rules that are all eligible for consideration at the same state. If the Confluence Requirement with exclusive rules holds for R, every pair of unordered rules in R is either exclusive or commutative. If such two rules are exclusive, then Sq1 and Sq2 are equivalent by Theorem 5 and this contradicts the above assumption that Sq1 and Sq2 are not equivalent; if such two rules are not exclusive, then they must be commutative by Definition 5 and this contradicts the above assumption. So the conclusion holds. ■
We define an algorithm as follows, called Confluence detection with exclusive rules, to detect the confluence of a rule set without user-defined priorities. Here, our algorithm adopts the following structures similar to the ones in Baralis [11]. Let R be an arbitrary active rule set such that R has no user-defined priorities, and let TG be its associated Triggering Graph; let Out (r i ) denote the endpoints of arcs originating from r i in TG; also let r i . T denote the counters of arcs incoming into r i in TG. Finally, let L denote a list of rules.
At the beginning of preparing our algorithm on Table 2, we define a function on Table 1, called as Trigger _ Set (), which is used for computing the rule set R1 and R2 during the examination of Confluence Requirement with exclusive rules for R.
As v1.State appears in both the conditions and the actions of r2 and r4, r2 and r4 are determined as noncommutative rules since the conditions (3) and (5) of Lemma 1 hold for them. That is, the existing methods [6–9] determine the rule set of Example 2 is not confluent; but this conclusion contradicts the fact mentioned above.
Conclusions
We deduced a contradiction from the corollaries presented in Aiken et al. [6] when they summarized the characteristics of a rule set with confluence; thus, how to detect the confluence of a rule set without priorities is still pending. The concept of unordered rules is introduced in Aiken et al. [6], but how to detect a pair of unordered rules is still pending. And we found that the existing methods [6–9] based on Rule Commutativity can not detect the confluence case if a rule set has exclusive rules and has no user-defined priority. To address these problems, this work proposes the concepts of Exclusive Rule and Confluence Requirement with exclusive rules based on the conditional formula of an executive sequence; and the proposed method provides more accurate analysis than the existing methods [6–9]. The main question this paper leaves open is that the proposed method is not necessary but sufficient, though it can improve the quality of confluence analysis.
Schmolze [20] presented a formal definition of production rule redundancy and an algorithm for detecting redundant production rules; Tan [21] addressed when and how ECA rules determine to react to different kinds of events. In future, we would consider rule redundancy and composite events to refine our method.
Footnotes
Acknowledgments
This work was supported by the Research Foundation of Shanghai Science and Technology Commission under Grant 14391901400.
