Abstract

A polyprogram is a generalization of a program which admits multiple definitions of a single function. Such objects arise in different transformation systems, such as the Burstall-Darlington framework or equality saturation. In this paper, we introduce the notion of a polyprogram in a non-strict first-order functional language. We define denotational semantics for polyprograms and describe some possible transformations of polyprograms, namely we present several main transformations in two different styles: in the style of the Burstall-Darlington framework and in the style of equality saturation. Transformations in the style of equality saturation are performed on polyprograms in decomposed form, where the difference between functions and expressions is blurred, and so is the difference between substitution and unfolding. Decomposed polyprograms are well suited for implementation and reasoning, although they are not very human-readable. We also introduce the notion of polyprogram bisimulation which enables a powerful transformation called merging by bisimulation, corresponding to proving equivalence of functions by induction or coinduction. Polyprogram bisimulation is a concept inspired by bisimulation of labelled transition systems, but yet it is quite different, because polyprogram bisimulation treats every definition as self-sufficient, that is a function is considered to be defined by any of its definitions, whereas in an LTS the behaviour of a state is defined by all transitions from this state. We present an algorithm for enumerating polyprogram bisimulations of a certain form. The algorithm consists of two phases: enumerating prebisimulations and converting them to proper bisimulations. This separation is required because polyprogram bisimulations take into account the possibility of parameter permutation. We prove correctness of this algorithm and formulate a certain weak form of its completeness. The article is published in the author’s wording.

Highlights

  • Many program transformation methods can be seen as special cases of the BurstallDarlington framework [3]

  • In decomposed polyprograms every definition has a very simple form containing only one nontrivial language construct, decomposed polyprograms are essentially closer to ASTs and EPEGs (E-PEG is a Program Expression Graph with an equivalence relation on nodes [8]), definitions of polyprograms corresponding to nodes and outgoing edges of E-PEGs, and functions corresponding to classes of node equivalence

  • In this paper we have introduced the notions of a polyprogram and a decomposed polyprogram

Read more

Summary

Introduction

Many program transformation methods can be seen as special cases of the BurstallDarlington framework [3]. One of the transformation rules of the Burstall-Darlington framework is called redefinition It allows replacing one function for another if they have isomorphic recursive definitions. The notion of polyprogram bisimulation and an algorithm for enumerating polyprogram bisimulations together with a proof of its correctness This is the main contribution, and most of the paper is devoted to this topic. The paper is structured as follows: first of all, we describe the language we use throughout the paper and give the definitions of a polyprogram and a decomposed polyprogram in this language (Section 1.), we show some basic transformation rules (Section 2.), and after that we introduce the notion of polyprogram bisimulation and present an algorithm for enumerating bisimulations (Section 3.).

Polyprograms
Polyprogram semantics
Polyprogram transformation rules
Rules in the style of the Burstall-Darlington framework
Rules in the style of equality saturation
Polyprogram bisimulation
The notion of polyprogram bisimulation
Enumerating bisimulations
Performance tricks and limitations
Related work
Conclusion
Full Text
Published version (Free)

Talk to us

Join us for a 30 min session where you can share your feedback and ask us any queries you have

Schedule a call