# Integrating ISA and Part-of Domain Knowledge into Process Model Discovery
## 6 Interactive Process-Model Discovery through Merge and Abstraction
```
1:GenerateModel(VerTree,L,KB)Output:Node
2:CurNode\(\leftarrow\)Root(VerTree)
3:Operation\(\leftarrow\)AskOp(CurNode)
4:whileOperation\(\
eq\)\"approve\"do
5:switchOperationdo
6:case\"analyze\":
7:...query answering operations\(\ldots\)
8:case\"merge\":
9:MergeParameters\(\leftarrow\)AskMergeParameters(CurNode)
10:NeeModel\(\leftarrow\)ExecuteMerge(CurNode.Model,MergeParameters)
11:NewNode\(\leftarrow\)AppendSon(CurNode,NewModel,CurNode.AbstrST)
12:CurNode\(\leftarrow\)NewNode
13:case\"abstract\":
14:AbstractionModality\(\leftarrow\)AskModality()
15:switchAbstractionModalitydo
16:case\"automatic_activity\":
17:Activity\(\leftarrow\)AskActivity(KB)
18:NewModel\(\leftarrow\)AutomaticActAbstract(KB,Activity,CurNode.Model,CurNode.AbstrST)
19:NewAbstrST\(\leftarrow\)CurNode.AbstrST\(\cup\){Activity}
20:case\"automatic_level\":
21:Level\(\leftarrow\)AskLevel(KB)
22:Activities\(\leftarrow\)GetActivities(KB,Level)
23:NewModel\(\leftarrow\)AutomaticLevAbstract(KB,Activities,CurNode.Model,CurNode.AbstrST)
24:NewAbstrST\(\leftarrow\)CurNode.AbstrST\(\cup\){Activities}
25:case\"interactive_activity\":
26:Activity\(\leftarrow\)AskAction(KB)
27:NewModel\(\leftarrow\)InteractiveActAbstract(KB,Activity,CurNode.Model,CurNode.AbstrST)
28:NewAbstrST\(\leftarrow\)CurNode.AbstrST\(\cup\){Activity}
29:case\"interactive_level\":
30:Level\(\leftarrow\)AskLevel(KB)
31:Activities\(\leftarrow\)GetActivities(KB,Level)
32:NewModel\(\leftarrow\)InteractiveLevAbstract(KB,Level,CurNode.Model,CurNode.AbstrST)
33:NewAbstrST\(\leftarrow\)CurNode.AbstrST\(\cup\){Activities}
34:endswitch
35:NewNode\(\leftarrow\)AppendSon(CurNode,NewModel,NewAbstrST)
36:CurNode\(\leftarrow\)NewNode
37:case\"back\":
38:CurNode\(\leftarrow\)AskCur(VerTree)
39:endswitch
40:Operation\(\leftarrow\)AskOp(CurNode)
41:endwhile
42:returnCurNode
```  
**Algorithm 5**_GenerateModel_ pseudo-code. The _GenerateModel_ algorithm has three parameters: the versioning tree (_VerTree_), the log (_L_), and the knowledge base (_KB_). Before invoking the _GenerateModel_ algorithm, the root of the versioning tree is generated, containing (i) the mined log tree and (ii) the abstraction symbol table (which is empty). The _GenerateModel_ algorithm repeatedly proposes different operations (namely _\"analyze\"_, _\"merge\"_, _\"abstract\"_, _\"back\"_, and _\"approree\"_) to the experts, until the _\"approree\"_ operation is chosen, which means that the expert accepts the model in the current node of the versioning tree as output. In short, the _\"analyze\"_ operation does not change the model (and the versioning tree) and is used by the expert when s/he wants to inspect and query the model in the current node (through the facilities described in [3]). The _\"back\"_ operation does not modify the versioning tree, but allows the expert to move back to a previously built node in the versioning tree. On the other hand, the _\"merge\"_ operation culminates with the addition of a new node to the versioning tree, containing a new process model obtained through the application of a merge operation to the model in the current node. While the above operations were already provided in the algorithm in [3], the _\"abstract\"_ operation deals with the extensions defined in this paper. With such an option (line 13), the analyst is asked to select among four abstraction modalities: (1) _\"automatic_activity\"_, which performs automatic abstraction of a single activity in the _KB_ (managed at lines 16-19), (2) _\"automatic_level\"_, which performs automatic abstraction of a complete level in the _KB_ (managed at lines 20-24), (3) _\"interactive_activity\"_, which performs interactive abstraction of a single activity (managed at lines 25-28), and (4) _\"interactive_level\"_, which performs interactive abstraction of a complete level in the _KB_ (managed at lines 29-33).