# CvAMoS--Event Abstraction Using Contextual Information
## 4 Approach
### Step 1: Construction of the Set of Motifs
Accordingly, the attribute distance between two traces is the sum of these differences. Only differences that exceed the tolerance value are included in the attribute distance calculation. **Definition 11** (Overall Distance). : _Given two traces \(t_{1}\) and \(t_{2}\), given an attribute map \(\mathcal{R}:\mathcal{N}\rightarrow(\mathcal{O},\sigma)\), an activity cost \(cost_{act}\), a maximum activity cost \(d_{act}\), and a maximum attribute cost \(d_{attr}\), the distance between the two traces is defined as:_  
\[dist(t_{1},t_{2},\mathcal{R},cost_{act},d_{act},d_{attr})= \begin{cases}0&\text {if }dist_{act}(t_{1},t_{2},cost_{act})\leq d_{act}\wedge dist_{attr}(t_{1},t_{2}, \mathcal{R})\leq d_{attr}\\ 1&\text{otherwise}\end{cases} \]  
It follows from the above that two traces can be considered similar if their activity distance is less than the given threshold \(d_{act}\) and their attributes must match too (according to the tolerance) within the respective distance \(d_{attr}\). We can slightly adapt this definition to compare traces and candidate motifs too:  
**Definition 12**. : _Given a trace \(t\) and a candidate motif \(c=(t_{c},\mathcal{AT})\), given the attribute map \(\mathcal{R}\) used to construct \(c\), the activity cost \(cost_{act}\), a maximum activity cost \(d_{act}\) and a maximum attribute cost \(d_{attr}\), we can verify whether the candidate motif is verified by the trace with the following:_  
\[verify(t,(t_{c},\mathcal{AT}),\mathcal{R},cost_{act},d_{act},d_{attr})= \begin{cases}1&\text{if }\exists\ i.dist(t[i,t_{c}]],t_{c},\mathcal{R},cost_{act},d_{act},d_{attr})= 0\\ 0&\text{otherwise}\end{cases} \]  
The last concept to be discussed is the _quorum_. The quorum is the minimum relative amount of traces in which the candidate motif must appear in order to be considered as an actual motif. Since the objective is to look for recurrent sequences, the quorum value allows defining how recurrent the motif should be to be considered relevant. With this, we can now define a motif:  
**Definition 13** (Motif, or verified motif). : _Given an event log \(E_{L}\) and candidate motif \(c\in C(E_{L},l_{m},\mathcal{R})\), a maximum activity cost \(d_{act}\) and attribute cost \(d_{attr}\), an activity cost relation \(cost_{act}\), and a quorum \(q\), we call \(c\) motif (or verified motif), if_  
\[\left(\sum_{t\in E_{L}}E_{L}(t)\cdot verify(t,c,\mathcal{R},cost_{act},d_{act},d_{attr}) \right)\geq q\cdot|E_{L}|.\]In other words, to verify whether a candidate motif is indeed a motif, we check in all the traces of the event log if there is at least one sub-trace (of the same length as the motif) that matches it in terms of both activities and attributes, according to the two distance thresholds provided \(d_{act}\), \(d_{attr}\) (as described in Equation (1)). If the amount of traces containing the motif satisfies the quorum \(q\), the candidate motif is returned as a motif. **Definition 14** (Set of motifs). : _We call \(M(E_{L},l_{m},\mathcal{R},d_{act},d_{attr},cost_{act},q)\subseteq C(E_{L},l_{ m},\mathcal{R})\) the set of all motifs. This set comprises all candidate motifs that are verified (cf. Definition 13)._  
Algorithm 1 describes in detail the procedure for the verification of a set of candidates motifs: for each candidate motif the number of traces where it appears is computed (lines 4-9) by checking each possible sub-trace (with same length as the candidate motif) of each trace in the log (lines 4-5). If the candidate motif is contained in a trace (i.e., its activity distance is less than a parameter, cf. line 6), then their attributes are verified (line 7). If the distance between the attributes is less than the attribute distance parameter, a counter is incremented by the multiplicity of the trace in the log (line 8) and the procedure can skip to the next trace (line 9). If the number of traces containing the candidate motif satisfies the quorum, then the candidate motif becomes verified and hence it is added to the list of motifs to be returned (lines 11-12).