Dynamic slicing of lazy functional programs based on redex trails

  • Claudio Ochoa
  • Josep Silva
  • Germán Vidal


Tracing computations is a widely used methodology for program debugging. 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.


Lazy functional programming Debugging Slicing Redex trails 


  1. 1.
    Albert, E., Hanus, M., Huch, F., Olvier, J., Vidal, G.: Operational semantics for declarative multi-paradigm languages. J. Symb. Comput. 40(1), 795–829 (2005) zbMATHCrossRefGoogle Scholar
  2. 2.
    Biswas, S.: A demand-driven set-based analysis. In: Proc. of the 24th ACM Symp. on Principles of Programming Languages (POPL’97), pp. 372–385. ACM Press, New York (1997) CrossRefGoogle Scholar
  3. 3.
    Biswas, S.: Dynamic slicing in higher-order programming languages. Ph.D. thesis, Department of CIS, University of Pennsylvania (1997) Google Scholar
  4. 4.
    Braßel, B., Hanus, M., Huch, F., Vidal, G.: A semantics for tracing declarative multi-paradigm programs. In: Proc. of the 6th Int’l Conf. on Principles and Practice of Declarative Programming (PPDP’04), pp. 179–190. ACM Press, New York (2004) CrossRefGoogle Scholar
  5. 5.
    Cheda, D., Silva, J., Vidal, G.: Static slicing of rewrite systems. In: Proc. of the 15th Int’l Workshop on Functional and (Constraint) Logic Programming (WFLP 2006). Electronic Notes in Theoretical Computer Science, vol. 177, pp. 123–136 (2007) Google Scholar
  6. 6.
    Chitil, O.: A semantics for tracing. In: 13th Int’l Workshop on Implementation of Functional Languages (IFL 2001), pp. 249–254. Ericsson Computer Science Laboratory (2001) Google Scholar
  7. 7.
    Chitil, O.: Source-based trace exploration. In: 16th Int’l Workshop on Implementation of Functional Languages (IFL 2004). LNCS, vol. 3474, pp. 126–141. Springer, Berlin (2005) Google Scholar
  8. 8.
    Ferrante, J., Ottenstein, K., Warren, J.: The program dependence graph and its use in optimization. ACM Trans. Program. Lang. Syst. 9(3), 319–349 (1987) zbMATHCrossRefGoogle Scholar
  9. 9.
    Gill, A.: Debugging Haskell by observing intermediate data structures. Electron. Notes Theor. Comput. Sci. 41(1). Proc. of the 4th Haskell Workshop (2000) Google Scholar
  10. 10.
    Hallgren, T.: Haskell tools from the programatica project. In: Proc. of the ACM Workshop on Haskell (Haskell’03), pp. 103–106. ACM Press, New York (2003) CrossRefGoogle Scholar
  11. 11.
    Hanus, M.: A unified computation model for functional and logic programming. In: Proc. of the 24th ACM Symp. on Principles of Programming Languages (POPL’97), pp. 80–93. ACM Press, New York (1997) CrossRefGoogle Scholar
  12. 12.
    Hanus, M.: Curry: an integrated functional logic language. Available at: (2000)
  13. 13.
    Hanus, M., Prehofer, C.: Higher-order narrowing with definitional trees. J. Funct. Program. 9(1), 33–75 (1999) zbMATHCrossRefMathSciNetGoogle Scholar
  14. 14.
    Korel, B., Laski, J.: Dynamic program slicing. Inf. Process. Lett. 29(3), 155–163 (1988) zbMATHCrossRefGoogle Scholar
  15. 15.
    Kuck, D., Kuhn, R., Padua, D., Leasure, B., Wolfe, M.: Dependence graphs and compiler optimization. In: Proc. of the 8th Symp. on the Principles of Programming Languages (POPL’81), SIGPLAN Notices, pp. 207–218 (1981) Google Scholar
  16. 16.
    Liu, Y., Stoller, S.: Eliminating dead code on recursive data. Sci. Comput. Program. 47, 221–242 (2003) zbMATHCrossRefGoogle Scholar
  17. 17.
    López-Fraguas, F., Sánchez-Hernández, J.: TOY: a multiparadigm declarative system. In: Proc. of the 10th Int’l Conf. on Rewriting Techniques and Applications (RTA’99). LNCS, vol. 1631, pp. 244–247. Springer, Berlin (1999) Google Scholar
  18. 18.
    Nilsson, H., Sparud, J.: The evaluation dependence tree as a basis for lazy functional debugging. Autom. Softw. Eng. 4(2), 121–150 (1997) CrossRefGoogle Scholar
  19. 19.
    Ochoa, C., Silva, J., Vidal, G.: Dynamic slicing based on redex trails. In: Proc. of the ACM SIGPLAN 2004 Symposium on Partial Evaluation and Program Manipulation (PEPM’04), pp. 123–134. ACM Press, New York (2004) CrossRefGoogle Scholar
  20. 20.
    Peyton Jones, S. (ed): Haskell 98 language and libraries. The Revised Report. Cambridge University Press, Cambridge (2003) Google Scholar
  21. 21.
    Pope, B.: A declarative debugger for Haskell. Ph.D. thesis, The University of Melbourne, Australia (2006) Google Scholar
  22. 22.
    Pope, B., Naish, L.: A program transformation for debugging Haskell 98. In: Proc. of 26th Australasian Computer Science Conference (ACSC 2003). Conferences in Research and Practice in Information Technology, vol. 16, pp. 227–236. ACS, Washington (2003) Google Scholar
  23. 23.
    Reps, T., Turnidge, T.: Program specialization via program slicing. In: Danvy, O., Glück, R., Thiemann, P. (eds.) Partial Evaluation. Dagstuhl Castle, Germany, February 1996. LNCS, vol. 1110, pp. 409–429. Springer, Berlin (1996) Google Scholar
  24. 24.
    Rodrigues, N., Barbosa, L.: Slicing functional programs by calculation. In: Proc. of the Dagstuhl Seminar on Beyond Program Slicing. Seminar n. 05451, Schloss Dagstuhl (2005) Google Scholar
  25. 25.
    Sparud, J., Runciman, C.: Tracing lazy functional computations using redex trails. In: Proc. of the 9th Int’l Symp. on Programming Languages, Implementations, Logics and Programs (PLILP’97). LNCS, vol. 1292, pp. 291–308. Springer, Berlin (1997) CrossRefGoogle Scholar
  26. 26.
    Tip, F.: A survey of program slicing techniques. J. Program. Lang. 3, 121–189 (1995) Google Scholar
  27. 27.
    Vidal, G.: Forward slicing of multi-paradigm declarative programs based on partial evaluation. In: Logic-based Program Synthesis and Transformation (revised and selected papers from the 12th Int’l Workshop LOPSTR 2002). LNCS, vol. 2664, pp. 219–237. Springer, Berlin (2003) Google Scholar
  28. 28.
    Wallace, M., Chitil, O., Brehm, T., Runciman, C.: Multiple-view tracing for Haskell: a new hat. In: Proc. of the 2001 ACM SIGPLAN Haskell Workshop. Universiteit Utrecht UU-CS-2001-23 (2001) Google Scholar
  29. 29.
    Weiser, M.: Program slicing. IEEE Trans. Softw. Eng. 10(4), 352–357 (1984) CrossRefGoogle Scholar

Copyright information

© Springer Science+Business Media, LLC 2008

Authors and Affiliations

  1. 1.DIATechnical University of MadridBoadilla del MonteSpain
  2. 2.DSICTechnical University of ValenciaValenciaSpain

Personalised recommendations