In their seminal paper, "The Semantics of Program Slicing and Program Integration," Thomas Reps and Wuu Yang establish the formal mathematical foundation for two essential software engineering operations: program slicing and the automated merging of program versions. By leveraging Program Dependence Graphs (PDGs), the authors demonstrate that these graph-based manipulations are not merely syntactic heuristics but are semantically sound transformations that strictly preserve program behavior.
The Challenge of Semantic Soundness
By the late 1980s, program slicing—the technique of isolating all statements that affect a specific variable at a specific point—was a recognized concept. However, its semantic properties had not been fully proven for graph-based approaches. A parallel challenge existed in "program integration": when multiple developers independently modify a base program, how can their changes be merged automatically?
Traditional text-based tools like diff and patch are logic-blind; they focus on line-by-line differences and can easily produce programs that are syntactically correct but logically broken. Reps and Yang sought to prove that an integration algorithm based on PDGs would produce a merged program that is semantically correct—behaving exactly like the variants where they were modified and like the base program where they were not.
The Program Dependence Graph (PDG)
The paper’s methodology centers on the Program Dependence Graph (PDG). In a PDG, nodes represent statements or predicates, while edges represent the essential relationships that dictate execution logic:
- Control Dependencies: These indicate which predicates (such as
iforwhileconditions) govern whether a particular statement is executed. - Data Flow Dependencies: These track how values flow from an assignment to a subsequent use of that variable.
- Def-Order Dependencies: These maintain the relative order of assignments to the same variable that reach the same use, ensuring the correct value is preserved.
As shown in Figure 1, the PDG maps the linear source code into a web of dependencies. This representation allows the authors to treat program manipulation as graph manipulation, which is more robust than text-based editing.
The Slicing Theorem
The authors introduce the Slicing Theorem to prove that a slice captures a true "behavioral projection." They argue that a slice is not just a subset of source code; it is a functional program guaranteed to mimic the original program's behavior regarding specific variables. If the original program halts, the slice is guaranteed to halt and produce the exact same sequence of values for the variables within that slice.
Figure 4 illustrates this concept: by isolating the logic for variable x, the PDG is pruned to only those nodes and edges that contribute to x's final state. The authors also provide a Feasibility Lemma, proving that any slice extracted from a PDG always corresponds to at least one valid, executable program.
Formalizing Program Integration
The paper’s "grand finale" is the Integration Theorem. This theorem proves that if the integration algorithm succeeds (meaning no "semantic interference" or merge conflicts are detected), the resulting merged program $M$ is semantically correct.
Specifically, for any initial state where the base program and its variants ($A$ and $B$) halt:
- The merged program $M$ will also halt.
- If variant $A$ changed a variable's behavior relative to the base, $M$ will match $A$.
- If variant $B$ changed a variable's behavior, $M$ will match $B$.
- If a variable's behavior remained unchanged across all three, $M$ will match the base program.
This definition of interference is based on whether the merged graph fails to preserve the slices of the variants, providing a much deeper level of safety than text-based merging.
Limitations and Future Directions
While groundbreaking, the proofs in this paper are limited to a "restricted" language consisting of scalar variables, assignments, if statements, and while loops. It does not yet account for complex features like pointers, arrays, or inter-procedural calls. Furthermore, the authors acknowledge the "infeasible graph" problem: while a merged PDG might be semantically sound, reconstructing that graph back into human-readable source code is a non-trivial task that can sometimes be impossible.
Despite these limitations, the paper remains a cornerstone of formal methods, bridging the gap between abstract graph representations and the concrete execution logic of software.
Summary updated