Abstract
A domain-specific language (DSL) is a specification language designed to facilitate programming in a certain application domain. A well-designed DSL reflects the natural structure of the modeled domain, enforces abstraction, and its implementation exploits domain-specific properties for safety and performance. Expounding on the latter, in this paper we describe a simple, but powerful method for gradually enhancing a base implementation with computational performance improvements. It consists of adding constructors for expensive operations if this facilitates asymptotic performance improvements in some contexts, with at most constant-factor overhead. The resulting implementation can be thought of as executing "standard" computation steps from the base implementation interleaved with symbolic computation steps on the newly introduced constructors. Evaluation of constructor expressions is lazy in a strong sense: It does not only delay evaluation by thunkifying its standard evaluation, but performs run-time inspection to evaluate constructor expressions in a nonstandard way. Extending earlier work by Henglein and Larsen [1] on generic multiset programming we arrive at novel multiset representations with constructors for unions, Cartesian products, scalar multiplication, and mapping binary functions over Cartesian products. We show how the resulting implementation can be used to implement finite probability distributions with exact (rational) probabilities. It supports computing both the expected value and, what we believe to be novel, the variance of random variables over n-ary product distributions efficiently by avoiding enumeration of the product sample space.
Original language | English |
---|---|
Title of host publication | Logic-Based Program Synthesis and Transformation : 21st International Symposium, LOPSTR 2011, Odense, Denmark, July 18-20, 2011. Revised Selected Papers |
Editors | Germán Vidal |
Number of pages | 21 |
Publisher | Springer |
Publication date | 2012 |
Pages | 4-24 |
ISBN (Print) | 978-3-642-32210-5 |
ISBN (Electronic) | 978-3-642-32211-2 |
DOIs | |
Publication status | Published - 2012 |
Event | 21st International Symposium on Logic-Based Program Synthesis and Transformation - Odense, Denmark Duration: 18 Jul 2011 → 20 Jul 2011 Conference number: 21 |
Conference
Conference | 21st International Symposium on Logic-Based Program Synthesis and Transformation |
---|---|
Number | 21 |
Country/Territory | Denmark |
City | Odense |
Period | 18/07/2011 → 20/07/2011 |
Series | Lecture notes in computer science |
---|---|
Volume | 7225 |
ISSN | 0302-9743 |