Abstract
We present techniques that enable higher-order functional computations to "explain" their work by answering questions about how parts of their output were calculated. As explanations, we consider the traditional notion of program slices, which we show can be inadequate, and propose a new notion: trace slices. We present techniques for specifying flexible and rich slicing criteria based on partial expressions, parts of which have been replaced by holes.
We characterise program slices in an algorithm-independent fashion and show that a least slice for a given criterion exists. We then present an algorithm, called unevaluation, for computing least program slices from computations reified as traces. Observing a limitation of program slices, we develop a notion of trace slice as another form of explanation and present an algorithm for computing them. The unevaluation algorithm can be applied to any subtrace of a trace slice to compute a program slice whose evaluation generates that subtrace. This close correspondence between programs, traces, and their slices can enable the programmer to understand a computation interactively, in terms of the programming language in which the computation is expressed. We present an implementation in the form of a tool, discuss some important practical implementation concerns and present some techniques for addressing them.
Supplemental Material
Available for Download
This zip file contains an extended version of the paper Functional Programs that Explain their Work, by Roly Perera, Umut A. Acar, James Cheney and Paul Blain Levy. ICFP 2012. The extended version is identical to the version published in the conference proceedings, except that it has an Appendix containing proofs omitted from the proceedings version.
- U. A. Acar. Self-Adjusting Computation. PhD thesis, Department of Computer Science, Carnegie Mellon University, May 2005. Google Scholar
Digital Library
- U. A. Acar, A. Ahmed, J. Cheney, and R. Perera. A core calculus for provenance. In Proceedings of the First Conference on Principles of Security and Trust (POST), pages 410--429. Springer, 2012. Google Scholar
Digital Library
- J. R. Allen, K. Kennedy, C. Porterfield, and J. Warren. Conversion of control dependence to data dependence. In POPL, pages 177--189. ACM, 1983. Google Scholar
Digital Library
- D. C. Atkinson and W. G. Griswold. Implementation techniques for efficient data-flow analysis of large programs. In ICSM, pages 52--61. IEEE, 2001. Google Scholar
Digital Library
- T. Ball and S. Horwitz. Slicing programs with arbitrary control-flow. In Proceedings of the First International Workshop on Automated and Algorithmic Debugging, pages 206--222, London, UK, 1993. Springer-Verlag. Google Scholar
Digital Library
- S. Biswas. Dynamic Slicing in Higher-Order Programming Languages. PhD thesis, University of Pennsylvania, 1997. Google Scholar
Digital Library
- R. Bose and J. Frew. Lineage retrieval for scientific data processing: a survey. ACM Comput. Surv., 37(1):1--28, 2005. Google Scholar
Digital Library
- P. Buneman, J. Cheney, and S. Vansummeren. On the expressiveness of implicit provenance in query and update languages. ACM Transactions on Database Systems, 33(4):28, November 2008. Google Scholar
Digital Library
- P. Buneman, S. Khanna, and W. Tan. Why and where: A characterization of data provenance. In ICDT, number 1973 in LNCS, pages 316--330, 2001. Google Scholar
Digital Library
- A. Cirillo, R. Jagadeesan, C. Pitcher, and J. Riely. Tapido: Trust and authorization via provenance and integrity in distributed objects. In ESOP, volume 4960 of LNCS, pages 208--223, 2008. Google Scholar
Digital Library
- K. Claessen, C. Runciman, O. Chitil, J. Hughes, and M. Wallace. Testing and tracing lazy functional programs using Quickcheck and Hat. In In 4th Summer School in Advanced Functional Programming, number 2638 in LNCS, pages 59--99. Springer LNCS, 2003.Google Scholar
Cross Ref
- S. B. Davidson and J. Freire. Provenance and scientific workflows: challenges and opportunities. In SIGMOD, pages 1345--1350, New York, NY, USA, 2008. Google Scholar
Digital Library
- J. N. Foster, T. J. Green, and V. Tannen. Annotated XML: queries and provenance. In PODS, pages 271--280, 2008. Google Scholar
Digital Library
- T. J. Green, G. Karvounarakis, and V. Tannen. Provenance semirings. In PODS, pages 31--40, 2007. Google Scholar
Digital Library
- J. Hidders, N. Kwasnikowska, J. Sroka, J. Tyszkiewicz, and J. Van den Bussche. A formal model of dataflow repositories. In DILS, volume 4544 of LNCS, pages 105--121, 2007. Google Scholar
Digital Library
- N. M. Johnson, J. Caballero, K. Z. Chen, S. McCamant, P. Poosankam, D. Reynaud, and D. Song. Differential slicing: Identifying causal execution differences for security applications. In IEEE Symposium on Security and Privacy, 2011. Google Scholar
Digital Library
- A. Kishon and P. Hudak. Semantics directed program execution monitoring. J. Funct. Prog., 5(4):501--547, 1995. Google Scholar
Digital Library
- H. Nilsson. Tracing piece by piece: affordable debugging for lazy functional languages. In Proceedings of the 1999 ACM SIGPLAN international conference on Functional programming, pages 36--47, Paris, France, Sept. 1999. ACM Press. Google Scholar
Digital Library
- C. Ochoa, J. Silva, and G. Vidal. Dynamic slicing of lazy functional programs based on redex trails. Higher Order Symbol. Comput., 21(1-2):147--192, 2008. Google Scholar
Digital Library
- R. Perera, U. A. Acar, J. Cheney, and P. B. Levy. Functional programs that explain their work. Technical Report MPI-SWS-2012-003, Max Planck Institute for Software Systems, July 2012.Google Scholar
- T. Reps and T. Turnidge. Program specialization via program slicing. In O. Danvy, R. Glck, and P. Thiemann, editors, Partial Evaluation, volume 1110 of LNCS, pages 409--429. Springer-Verlag, 1996. Google Scholar
Digital Library
- Y. Simmhan, B. Plale, and D. Gannon. A survey of data provenance in e-science. SIGMOD Record, 34(3):31--36, 2005. Google Scholar
Digital Library
- J. Sparud and C. Runciman. Complete and partial redex trails of functional computations. In IFL 1997, number 1467 in LNCS, pages 160--177. Springer-Verlag, 1998. Google Scholar
Digital Library
- E. Sumii and H. Bannai. VMλ: A functional calculus for scientific discovery. In Z. Hu and M. Rodríguez-Artalejo, editors, Functional and Logic Programming, volume 2441 of Lecture Notes in Computer Science, pages 290--304. Springer Berlin / Heidelberg, 2002. Google Scholar
Digital Library
- N. Swamy, B. J. Corcoran, and M. Hicks. Fable: A language for enforcing user-defined security policies. In IEEE Symposium on Security and Privacy, pages 369--383, 2008. Google Scholar
Digital Library
- F. Tip. A survey of program slicing techniques. J. Prog. Lang., 3(3), 1995.Google Scholar
- M. Weiser. Program slicing. In ICSE, pages 439--449, 1981. Google Scholar
Digital Library
- B. Xu, J. Qian, X. Zhang, Z. Wu, and L. Chen. A brief survey of program slicing. SIGSOFT Softw. Eng. Notes, 30:1--36, March 2005. Google Scholar
Digital Library
Index Terms
Functional programs that explain their work
Recommendations
Imperative functional programs that explain their work
Program slicing provides explanations that illustrate how program outputs were produced from inputs. We build on an approach introduced in prior work, where dynamic slicing was defined for pure higher-order functional programs as a Galois connection ...
Functional programs that explain their work
ICFP '12: Proceedings of the 17th ACM SIGPLAN international conference on Functional programmingWe present techniques that enable higher-order functional computations to "explain" their work by answering questions about how parts of their output were calculated. As explanations, we consider the traditional notion of program slices, which we show ...
A brief survey of program slicing
Program slicing is a technique to extract program parts with respect to some special computation. Since Weiser first proposed the notion of slicing in 1979, hundreds of papers have been presented in this area. Tens of variants of slicing have been ...







Comments