# Integrating ISA and Part-of Domain Knowledge into Process Model Discovery
## 5 Knowledge-Based Abstraction Operations
### Interactive Abstraction Operators  
The abstraction algorithms in 5.2 perform the abstractions (chosen by the analysts) in a fully automatic fashion. They do not consider intersecting paths and automatically solve conflicts. However, analysts may want to play an active role in the abstraction process, by having the possibility of (i) preserving some intersecting paths, (ii) solving conflicts, and (iii) selectively performing abstractions. The algorithms introduced in this section provide analysts with such possibilities. The main algorithm we have defined to cover the above task is called _InteractiveActAbstract_ (see Algorithm 3). It takes the following parameters as input:  
* _KB_: the starting node of the ontological KB;
* _AN_: the node of _KB_ the user wishes to abstract;
* _PM_: the current process model, which needs to be abstracted, in regard to the instances of node _AN_;
* _AbstrST_: the abstraction symbol table, which keeps track of what _KB_ nodes, have already been considered for abstraction in _PM_. Intuitively, the _InteractiveActAbstract_ algorithm applies the _AN_ abstraction node of _KB_ to the _PM_ model, considering the previous abstraction activities (i.e., stored in _AbstrST_) and interacting with the user to manage intersecting paths and conflicts. ```
1:InteractiveActAbstract(\(KB\), AN, PM, AbstrST)
2:\(D\leftarrow\) DistanceGround(\(KB\), AN)
3:for\(L\gets D\)-1 to 0 do
4:\(Nodes\leftarrow\) GetNodesLevel (\(KB\), AN, \(L\))
5:\(Paths\leftarrow\) {1}
6:for each N in Nodes do
7:if(not GroundNode? (\(KB\), \(N\)) and not Abstracted? (\(N\), AbstrST)) then
8:if IsaNode? (\(KB\), \(N\)) then
9:for each CN in GetSons (\(KB\), \(N\)) do
10: Substitute (Find (\(CN\), PM), \(N\), PM)
11:endfor
12: Add (\(N\), AbstrST)
13:else
14:if PartOnNode? (\(KB\), \(N\)) then
15:\(Paths\leftarrow\) Paths \(\bigcup\) <Exec (\(N\), PM), \(N\)>
16: Add (\(N\), AbstrST)
17:endif
18:endif
19:endif
20:endfor
21:if(not IsEmpty? (\(Paths\))) then
22:\(PartitionSet\leftarrow\) Partition (\(Paths\))
23:for each Set in PartitionSet do
24: SolveAndAbstract(\(Set\), PM)
25:endfor
26:endif
27:endfor
```  
**Algorithm 3** pseudocode of the interactive activity-based abstraction algorithm. This algorithm iterates (lines 3-27) over all descendant nodes of _AN_ located at the same level in a bottom-up way (i.e., from the most distant ones from _AN_ in the _KB_), starting from \"pre-ground\" nodes (i.e., nodes located one step just before ground nodes) up to the _AN_ node, and performs abstractions level-by-level. The function _DistanceGround_ evaluates the maximum level \(D\) to the ground nodes (paths in the ontological KB may have different lengths); then, the \"for loop\" at lines 3-27 starts iterating from level _D-1_, as ground nodes are not considered for abstraction. Specifically, at each iteration, the algorithm retrieves all nodes _Nodes_ at a certain level \(L\) from _AN_ through the function _GetNodesLevel_ (line 4) and considers them for abstraction, according to their type. In particular, for each retrieved node \(N\), first, the algorithm checks whether the node can be considered for abstraction; to this aim, it checks whether \(N\) is either a ground node or has already been considered for abstraction (as checked in line 7 by the _GroundNode_? and _Abstract_? functions, respectively). If the abstraction for \(N\) is possible, two cases are possible. In the case \(N\) is an ISA node (lines 9-12), the algorithm just substitutes all the sons (i.e., subtypes) of \(N\) that occur in the process model _PM_ with \(N\) itself (line 10), and through the function _Add_, the algorithm adds \(N\) to the abstraction table _AbstrST_ to indicate that it has already been considered for abstraction (line 12).