Dynamic Slicing of Lazy Functional Programs Based on Redex Trails ∗ Claudio Ochoa DIA, Technical University of Madrid Campus de Montegancedo s/n, E-28660 Boadilla del Monte (Spain) (cochoa@fi.upm.es) Josep Silva DSIC, Technical University of Valencia Camino de Vera s/n, E-46022 Valencia (Spain) (jsilva@dsic.upv.es) Germ´anVidal DSIC, Technical University of Valencia Camino de Vera s/n, E-46022 Valencia (Spain) (gvidal@dsic.upv.es) Abstract. Tracing computations is a widely used methodology for program de- bugging. Lazy languages, however, pose new demands on tracing techniques because following the actual trace of a computation is generally useless. Typically, tracers for lazy languages rely on the construction of a redex trail, a graph that stores the reductions performed in a computation. While tracing provides a significant help for locating bugs, the task still remains complex. A well-known debugging technique for imperative programs is based on dynamic slicing, a method for finding the program statements that influence the computation of a value for a specific program input. In this work, we introduce a novel technique for dynamic slicing in first-order lazy functional languages. Rather than starting from scratch, our technique relies on (a slight extension of) redex trails. We provide a notion of dynamic slice and introduce a method to compute it from the redex trail of a computation. We also sketch the extension of our technique to deal with a functional logic language. A clear advantage of our proposal is that one can enhance existing tracers with slicing capabilities with a modest implementation effort, since the same data structure (the redex trail) can be used for both tracing and slicing. Keywords: lazy functional programming, debugging, slicing, redex trails 1. Introduction In lazy functional programming languages, following the actual trace of a computation is often useless due to the on demand style of evaluation. In the language Haskell (Peyton Jones, 2003), this drawback has been ∗ A preliminary version of this paper appeared in the Proceedings of PEPM’04 (Ochoa et al., 2004). This work has been partially supported by EU (FEDER) and Spanish MEC under grants TIN2004-00231, TIN2005-09207-C03-02, and Acci´on Integrada HA2006-0008. c 2007 Kluwer Academic Publishers. Printed in the Netherlands. paper.tex; 13/09/2007; 13:00; p.1