# Combining Machine Learning and Logical Reasoning to Improve Requirements Traceability Recovery
## 3 A Hybrid Traceability Recovery Approach
### Phase 2 Logical Reasoning Recovery
#### 3.3.2 Interrelationships between Use Cases  
In addition to exploring the interrelations between source code classes, we argue it is equally important to investigate the interrelations between use cases. A use case describes the system response to participant requests in certain conditions. The interrelations between use cases contain _include_, _extend_, and _generalize_. All of these are explored in our approach. We here first briefly introduce the three types of relationships, and then describe how they are used in our approach. _Include:_ The include relationship means that a use case can include behaviors that other use cases have and contain them as a part of its own behavior. Use of the include relationship can avoid inconsistencies and duplicate work in multiple use cases. Figure 7 shows an example of an include relationship. Use cases with an include relationship are usually closely related. According to our empirical investigation, if there is a traceability link between the use case \(U\) and a class \(C\), then other use cases which have an include relationship with the use case \(U\) usually also have traceability links with the class \(C\). _Extend:_ The extend relationship means adding a new behavior to an existing use case under specified conditions. In this type of relationship, the base use case provides one or more insertion points, and the extending use case provides the behaviors that need to be inserted for these insertion points. An example of an extend relationship is shown in Figure 8. Use cases with extend relationship are usually closely related. According to our empirical research, if there is a traceability link between the a case \(U\) and a class \(C\), then other use cases that have an extend relationship with the use case \(U\) are very likely to have traceability links with the class \(C\). _Generalize:_ The generalize relationship of use cases means that a basic use case can be generalized into multiple sub use cases. If multiple use cases have the same structure and behavior, we can abstract their commonality as the basic use case. An example of a generalize relationship is shown in Figure 9. Use cases with generalization relationships are usually closely related. According to our empirical research, if there is a traceability link between a use case \(U\) and a class \(C\), then other use cases that have generalization relationship with use case \(U\) usually also have traceability links with the class \(C\). On the whole, we propose the following use case relationships as features, which are shown in Table 4. Considering such relationships, we have defined the following inference rules based on the semantics of these relationships: Rule 6 means if there is a traceability link between use case \(s_{i}\) and source code \(c_{j}\), and use case \(s_{k}\) includes use case \(s_{i}\), then there is a traceability link between use case \(s_{k}\) and source code \(c_{j}\). Rule 7 means if there is a traceability link between use case \(s_{i}\) and source code \(c_{j}\), and use case \(s_{k}\) extends use case \(s_{i}\), then there is a traceability link between use case \(s_{k}\) and source code  
Figure 8: The extend relationship between use cases. Figure 7: The include relationship between use cases. Figure 9: The generalize relationship between use cases. \(c_{j}\). Rule 8 means if there is a traceability link between use case \(s_{i}\) and source code \(c_{j}\), and use case \(s_{i}\) generalizes use case \(s_{k}\), then there is a traceability link between use case \(s_{k}\) and source code \(c_{j}\). \[Rule6:traceability\_link(use\_case(s_{k}),source\_code(c_{j}))\] \[\leftarrow traceability\_link(use\_case(s_{i}),source\_code(c_{j})) \tag{7}\] \[\wedge include(use\_case(s_{k}),use\_case(s_{i}))\] \[Rule7:traceability\_link((use\_case(s_{k}),source\_code(c_{j}))\] Figure 9.0 (8) Figure 9.1 Figure 9.2 Figure 9.3 (9) Figure 9.4  
We apply these rules to capture more links based on the traceability links output by the inference rules that are defined in Section 3.3.1.