A cost recurrence describes an upper bound for the running time of a program in terms of the size of its input. Finding cost recurrences is a frequent intermediate step in complexity analysis, and this step requires an abstraction from data to data size. In this article, we use information contained in dependent types to achieve such an abstraction: Dependent ML (DML), a conservative extension of ML, provides dependent types that can be used to associate data with size information, thus describing a possible abstraction. We systematically extract cost recurrences from first-order DML programs, guiding the abstraction from data to data size with information contained in DML type derivations.
Specializing string matchers is a canonical example of partial evaluation. A naive implementation of a string matcher repeatedly matches a pattern against every substring of the data string; this operation should intuitively benefit from specializing the matcher with respect to the pattern. In practice, however, producing an efficient implementation by performing this specialization using standard partial-evaluation techniques has been found to require non-trivial binding-time improvements. Starting with a naive matcher, we thus present a derivation of a binding-time improved string matcher. We prove its correctness and show that specialization with respect to a pattern yields a matcher with code size linear in the length of the pattern and running time linear in the length of its input. We then consider several variants of matchers that specialize well, amongst them the first such matcher presented in the literature, and we demonstrate how variants can be derived from each other systematically. *
A generating extension of a program specializes it with respect to<br />some specified part of the input. A generating extension of a program<br />can be formed trivially by applying a partial evaluator to the program;<br />the second Futamura projection describes the automatic generation<br />of non-trivial generating extensions by applying a partial evaluator to<br />itself with respect to the programs.<br />We derive an ML implementation of the second Futamura projection<br /> for Type-Directed Partial Evaluation (TDPE). Due to the differences<br /> between `traditional', syntax-directed partial evaluation and<br />TDPE, this derivation involves several conceptual and technical steps.<br />These include a suitable formulation of the second Futamura projection<br /> and techniques for making TDPE amenable to self-application. In<br />the context of the second Futamura projection, we also compare and<br />relate TDPE with conventional offline partial evaluation.<br />We demonstrate our technique with several examples, including<br />compiler generation for Tiny, a prototypical imperative language.
scite is a Brooklyn-based organization that helps researchers better discover and understand research articles through Smart Citations–citations that display the context of the citation and describe whether the article provides supporting or contrasting evidence. scite is used by students and researchers from around the world and is funded in part by the National Science Foundation and the National Institute on Drug Abuse of the National Institutes of Health.