## 4 Discovering Inconsistent Data Based on WFT-Nets
### Data Refinement for Inconsistent Data  
To focus on reflecting inconsistent data, the refinement here always pursues fresh values compared to the current database and/or the last written under the preconditions that all different states of guards are considered. In addition, suppose each loop structure is executed only once, i.e., the refined values of each data element written by a transition in the loop structure are the same, no matter how many times the data element is written by the transition. Therefore, from an abstract (i.e., _defined_) state to some concrete data values, the refinement here also considers all possible executable versions, and the essential properties' preservation [35] in a refinement process is also guaranteed. In a WFT-net, once a data element \(d\) is written by a transition \(t\) at a configuration \(c\), the defined \(d\) will be refined. Let \(\mathcal{B}_{d}\) be the domain of \(d\), \(\mathcal{R}_{d}\) be the set of those tables that are related to \(d\), \(T_{d}^{c}\) be the value set of \(d\) stored into the database at \(c\), and \(\Pi_{d}\) be the set of those predicates that are related to \(d\). Assuming that \(d\) is written for the \(n\)-\(th\) (\(n\)\(\geq\)1) time by \(t\) at \(c\) from \(c_{0}\), let \(\mathbb{V}_{d}^{n}\) represent the set of all refined values of such \(d\) and \(\mathbb{V}_{d}^{n-1}\) represent the refined value set of \(d\) written for the \((n\)-1)-\(th\) time (when \(n=1\), \(\mathbb{V}_{d}^{0}=\emptyset\)) from \(c_{0}\) to \(c\). Then, the process of refining \(d\) written by \(t\) at a configuration \(c\) is shown in Algorithm 1. ```
0: A WFT-net \(N\), \(d\), \(\mathcal{B}_{d}\), \(c\), and \(\mathbb{V}_{d}^{1}\), \(\cdots\), \(\mathbb{V}_{d}^{n-1}\) (\(n\)\(\geq\)1);
0: A refined value set \(\mathbb{V}_{d}^{m}\) of \(d\) written by \(t\) at \(c\);
1: Initialize \(\mathbb{V}_{d}^{m}=\emptyset\) and \(T_{d}^{c}=\emptyset\);
2:if\(\mathcal{R}_{d}=\emptyset\land\Pi_{d}=\emptyset\)then
3: Select any \(d^{\prime}\) from \(\mathcal{B}_{d}\backslash\mathbb{V}_{d}^{1}\cup\cdots\ \cup\mathbb{V}_{d}^{n-1}\), and let \(\mathbb{V}_{d}^{n}=\{d^{\prime}\}\);
4:else
5:if\(\mathcal{R}_{d}\
eq\emptyset\)then
6: for each \(R_{i}\in\mathcal{R}_{d}\)do
7: Add all values of \(d\) stored in \(R_{i}\) to \(T_{d}^{c}\)
8: endfor
9: Select any \(d^{\prime}\) from \(\mathcal{B}_{d}\backslash(T_{d}^{c}\cup\mathbb{V}_{d}^{1}\cup\cdots\cup \mathbb{V}_{d}^{n-1})\), and let \(\mathbb{V}_{d}^{n}=\{d^{\prime}\}\);
10:endif
11:if\(\Pi_{d}\
eq\emptyset\)then
12:for each \(\pi_{i}\in\Pi_{d}\) such that \(\pi_{i}\) is defined at \(c\)do
13:if any element in \(\mathbb{V}_{d}^{m}\) cannot make \(\pi_{i}\) true then
14: Select any \(d^{\prime}_{i}\) from \(\mathcal{B}_{d}\) that can make \(\pi_{i}\) true and add \(d^{\prime}_{i}\) into \(\mathbb{V}_{d}^{n}\);
15:endif
16:if any element in \(\mathbb{V}_{d}^{n}\) cannot make \(\pi_{i}\) false then
17: Select any \(d^{\prime\prime}_{i}\) from \(\mathcal{B}_{d}\) that can make \(\pi_{i}\) false and add \(d^{\prime\prime}_{i}\) into \(\mathbb{V}_{d}^{n}\);
18:endif
19:endfor
20:endif
21:endif
22:Output \(\mathbb{V}_{d}^{n}\). ```  
**Algorithm 1** Generating \(\mathbb{V}_{d}^{n}\) by refining \(d\) at \(c\)  
To reduce the state space, it should consider the absence of the database along with the fresh value reflecting overwritten, if possible. For a data element \(d\), if there exist some tables that are related to \(d\) and \(d\) that have been written before, it is enough to refine a value of \(d\) for reflecting both the absence of the database and the overwriting of \(d\). Note that Algorithm 1 can be terminated regardless of whether the domain of the data element \(d\) is finite or not. This is because the number of the refined values of \(d\) depends on the cardinalities of \(\Pi_{d}\) and \(\mathcal{R}_{d}\) that must be finite. Let \(\pi_{\Pi_{d}}\) and \(\pi_{\mathcal{R}_{d}}\) be the cardinality of \(\Pi_{d}\) and \(\mathcal{R}_{d}\); then, the time complexity of Algorithm 1 is \(O(\pi_{\Pi_{d}}+\pi_{\mathcal{R}_{d}})\).