## 2 Method to Extract the Rule-Based Knowledge
### PR Generation through NAAR Mining and Prolog
#### 2.3.1 MineNAAR Algorithm
3:procedureSubsumptionCheck \((\mathcal{R}_{car},CF_{AR},D)\)
4:for each\(\mathcal{R}_{i}\in\mathcal{R}_{car}\)do
5:for each\(\mathcal{R}_{j}\in\mathcal{R}_{car}\), \(i=j\)do
6:if\(X_{i}=X_{j}\) or \(Y_{i}=Y_{j}\)then
7:if\(CF_{AR}\left(\mathcal{R}_{i}\right)=CF_{AR}\left(\mathcal{R}_{j}\right)\)then
8: delete \(\mathcal{R}_{i}/\mathcal{R}_{j}\) which has the lower \(CF_{AR}\);
9:else
10:if\(X_{i}=X_{j}\)then
11: delete \(\mathcal{R}_{i}/\mathcal{R}_{j}\) which has more items in antecedent
12: from \(\mathcal{R}_{car}\);
13:else if\(Y_{i}=Y_{j}\)then
14: delete \(\mathcal{R}_{i}/\mathcal{R}_{j}\) which has least items in consequent
15: from \(\mathcal{R}_{car}\);
16:endif
17:endif
18:endfor
19:\(\mathcal{R}_{sub}=\mathcal{R}_{car}\)
20:endprocedure. ```  
**Algorithm 2** Building Non-subsumption Rules  
The second problem is to avoid circular rules regarding Definition 9 from the generated non-subsumption NRARs. To overcome this problem, all of the non-subsumption NRARs are sorted in descending order of certainty factor values. Furthermore, there are several circularity conditions that must be considered as described in Table 2.  
**Property 3**. : _If there are three NRARs \(\mathcal{R}_{1}:\ X_{1}\to Y_{1}\), \(\mathcal{R}_{2}:\ X_{2}\to Y_{2}\), and \(\mathcal{R}_{3}:\ X_{3}\to Y_{3}\) which are considered to be circular rules regarding Definition 9, then,_  
1. Remove a rule that has a lower \(CF\) value when a rule chain forms any of the direct-circular (DC) conditions. 2. If some rules are linked and creating a rule-chain in a way of any of the indirect-circular (IC) conditions, then remove the last rule in the rule-chain. An algorithm is introduced called CircularCheck to implement Property 3. After the non-subsumption rules from Algorithm 2, CircularCheck is applied to obtain NAARs. In addition, CircularCheck is described in Algorithm 3. The last algorithm results in non-circular and non-subsumption NRARs. For simplicity, we call these NAARs. ```
1:procedure CircularCheck \((\mathcal{R}_{sub},\text{CF}_{AR},D)\)
2:\(\mathcal{R}_{temp}=\varnothing\)
3:for each\(\mathcal{R}_{i}\in\mathcal{R}_{sub}\)do
4:for each\(\mathcal{R}_{j}\in\mathcal{R}_{sub}\backslash\mathcal{R}_{i}\), \(i=j\)do
5:if\(X_{i}=Y_{j}\) and \(Y_{i}=X_{j}\)then
6:if\(\text{CF}_{AR}\left(\mathcal{R}_{i}\right)>\text{CF}_{AR}\left(\mathcal{R}_{j}\right)\)then
7:\(\mathcal{R}_{sub}=\mathcal{R}_{sub}\backslash\mathcal{R}_{j}\);
8:elseif\(\text{CF}_{AR}\left(\mathcal{R}_{i}\right)<\text{CF}_{AR}\left(\mathcal{R}_{j}\right)\)then
9:\(\mathcal{R}_{sub}=\mathcal{R}_{sub}\backslash\mathcal{R}_{i}\);
10:endif
11:elseif\(Y_{i}=X_{j}\)then
12:while\(Y_{j}\
eq X_{i}\)
13:for each\(\mathcal{R}_{j+1}\in\mathcal{R}_{sub}\left(\mathcal{R}_{i}\wedge\mathcal{R}_{j} \right)\), \(j=j+1\)do
14:\(\mathcal{R}_{temp}=\mathcal{R}_{temp}\cup\left(X_{i}\to Y_{j}\right)\);
15:endfor
16:endwhile
17:if\(X_{j-1}=Y_{j}\) and \(Y_{j-1}=X_{j}\)then
18:if\(\text{CF}_{AR}\left(\mathcal{R}_{j-1}\right)>\text{CF}_{AR}\left(\mathcal{R}_{j}\right)\)then
19:\(\mathcal{R}_{sub}=\mathcal{R}_{sub}\backslash\mathcal{R}_{j}\);
20:elseif\(\text{CF}_{AR}\left(\mathcal{R}_{i}\right)<\text{CF}_{AR}\left(\mathcal{R}_{j}\right)\)then
21:\(\mathcal{R}_{sub}=\mathcal{R}_{sub}\backslash\mathcal{R}_{j-1}\);
22:endif
23:elseif\(X_{i}=Y_{j}\)or\(\exists X_{i}=Y_{j}\) where \(i=2,\ldots,j-2\)then
24:\(\mathcal{R}_{sub}=\mathcal{R}_{sub}\backslash\mathcal{R}_{j}\);
25:endif
26:endif
27:endfor
28:endfor
29:\(\mathcal{R}_{cir}=\mathcal{R}_{sub}\);
30:endprocedure. ```  
**Algorithm 3** Building Non-circular Rules