A dynamic slice, as originally presented in [19], is an executable part of the program whose behavior
is identical, for the same program input, to that of the original program with respect to a variable of
interest at some execution position. A slicing criterion of program P executed on program input x is
a tuple C=(x,yq
) where yq
is a variable at execution position q. An executable dynamic slice of
program P on slicing criterion C is any syntactically correct and executable program P’ that is
obtained from P by deleting zero or more statements, and when executed on program input x
produces an execution trace T’x for which there exists the corresponding execution position q’ such
that the value of yq
in Tx equals the value of yq’ in T’x. A dynamic slice P’ preserves the value of y for
a given program input x. The goal in dynamic slicing is to find the slice with the minimal number of
statements, but, in general, this goal may not be achievable. However, it is possible to determine a
safe approximation of the dynamic slice that preserves the computation of the value of a variable of
interest. For example, Figure 2 shows an executable dynamic slice of the program of Figure 1a.
4
Notice that when the original program of Figure 1a and its dynamic slice of Figure 2 are executed on
input: n=3, a=(1,2,3), the value of variable max at statement 15 is the same.