A Semantics for Approximate Program Transformations

An approximate program transformation is a transformation that can change the semantics of a program within a specified empirical error bound. Such transformations have wide applications: they can decrease computation time, power consumption, and memory usage, and can, in some cases, allow implementations of incomputable operations. Correctness proofs of approximate program transformations are by definition quantitative. Unfortunately, unlike with standard program transformations, there is as of yet no modular way to prove correctness of an approximate transformation itself. Error bounds must be proved for each transformed program individually, and must be re-proved each time a program is modified or a different set of approximations are applied. In this paper, we give a semantics that enables quantitative reasoning about a large class of approximate program transformations in a local, composable way. Our semantics is based on a notion of distance between programs that defines what it means for an approximate transformation to be correct up to an error bound. The key insight is that distances between programs cannot in general be formulated in terms of metric spaces and real numbers. Instead, our semantics admits natural notions of distance for each type construct; for example, numbers are used as distances for numerical data, functions are used as distances for functional data, an polymorphic lambda-terms are used as distances for polymorphic data. We then show how our semantics applies to two example approximations: replacing reals with floating-point numbers, and loop perforation.

[1]  Daniel M. Roy,et al.  Probabilistically Accurate Program Transformations , 2011, SAS.

[2]  Viktor Kuncak,et al.  Trustworthy numerical computation in Scala , 2011, OOPSLA '11.

[3]  Lars Birkedal,et al.  Logical Step-Indexed Logical Relations , 2009, LICS.

[4]  Zeyuan Allen Zhu,et al.  Randomized accuracy-aware program transformations for efficient approximate computations , 2012, POPL '12.

[5]  Antoine Girard,et al.  Approximate Bisimulation: A Bridge Between Computer Science and Control Theory , 2011, Eur. J. Control.

[6]  Sumit Gulwani,et al.  Proving programs robust , 2011, ESEC/FSE '11.

[7]  Sumit Gulwani,et al.  Continuity analysis of programs , 2010, POPL '10.

[8]  Michael A. Arbib,et al.  Algebraic Approaches to Program Semantics , 1986, Texts and Monographs in Computer Science.

[9]  Norman Ramsey,et al.  Stochastic lambda calculus and monads of probability distributions , 2002, POPL '02.

[10]  Henry Hoffmann,et al.  Managing performance vs. accuracy trade-offs with loop perforation , 2011, ESEC/FSE '11.

[11]  Dan Grossman,et al.  EnerJ: approximate data types for safe and general low-power computation , 2011, PLDI '11.

[12]  Davide Sangiorgi,et al.  On the bisimulation proof method , 1998, Mathematical Structures in Computer Science.

[13]  Eric Goubault,et al.  Static Analysis of Finite Precision Computations , 2011, VMCAI.

[14]  John C. Reynolds,et al.  Types, Abstraction and Parametric Polymorphism , 1983, IFIP Congress.

[15]  Martin C. Rinard,et al.  Proving acceptability properties of relaxed nondeterministic approximate programs , 2012, PLDI.

[16]  Jan Rutten,et al.  On the foundations of final coalgebra semantics: non-well-founded sets, partial orders, metric spaces , 1998, Mathematical Structures in Computer Science.

[17]  Ralph Kopperman,et al.  Continuity Spaces: Reconciling Domains and Metric Spaces , 1997, Theor. Comput. Sci..

[18]  Benjamin C. Pierce,et al.  Distance makes the types grow stronger: a calculus for differential privacy , 2010, ICFP '10.

[19]  Hans-Juergen Boehm,et al.  Exact real arithmetic: a case study in higher order programming , 1986, LFP '86.

[20]  Benjamin C. Pierce,et al.  Types and programming languages: the next generation , 2003, 18th Annual IEEE Symposium of Logic in Computer Science, 2003. Proceedings..

[21]  A. W. Roscoe,et al.  Metric Spaces as Models for Real-Time Concurrency , 1987, MFPS.

[22]  Abbas Edalat,et al.  A new representation for exact real numbers , 1997, MFPS.