Abstract
Nondeterminism can be introduced into a functional language, along with a set of laws for reasoning about the behaviour of programs, without disturbing referential transparency. We show how to do this by adding a new type constructor for sets and a carefully selected family of operations on sets. Instead of specifying a nondeterministic choice explicitly with choose or amb, a programmer specifies the set of values which the program might compute. Operations on sets are restricted in order to maintain laws for reasoning about programs; in particular, no function can choose an element from a set. The implementation is specified via rewrite rules that transform a program in the nondeterministic language into an ordinary functional program augmented with amb (which is not directly accessible to the programmer). The denotational semantics for this language is based on the Hoare powerdomain, so it includes bottom as a possible result even when the implementation will definitely not produce bottom. Since the denotational semantics fails to capture all the properties of the implementation, we present an additional method for reasoning about the productivity of a program. Productivity can be used to place additional constraints on the implementation which are not expressible in the powerdomain semantics. All of these techniques are illustrated by defining a “processor farm” program and proving several of its properties.
Access this chapter
Tax calculation will be finalised at checkout
Purchases are for personal use only
Preview
Unable to display preview. Download preview PDF.
References
John Hughes and John O’Donnell, “Expressing and reasoning about non-deterministic functional programs,” Functional Programming, Glasgow 1989,Springer-Verlag (1990) 308–328.
G. Kahn and D. McQueen, “Coroutines and networks of parallel processes,” Information Processing 77, North-Holland, Amsterdam (1977).
John McCarthy, “A basis for a mathematical theory of computation,” Computer Programming and Formal Systems North-Holland (1963) 33–70.
B. A. Sijtsma, Verification and Derivation of Infinite-List Programs, PhD Thesis, University of Groningen (1988).
Philip L. Wadler, “Theorems for free,” 4’th International Conference on Functional Programming Languages and Computer Architecture, ACM (1989).
Author information
Authors and Affiliations
Editor information
Editors and Affiliations
Rights and permissions
Copyright information
© 1991 British Computer Society
About this paper
Cite this paper
Hughes, J., O’Donnell, J. (1991). Nondeterministic Functional Programming with Sets. In: Birtwistle, G. (eds) IV Higher Order Workshop, Banff 1990. Workshops in Computing. Springer, London. https://doi.org/10.1007/978-1-4471-3182-3_2
Download citation
DOI: https://doi.org/10.1007/978-1-4471-3182-3_2
Publisher Name: Springer, London
Print ISBN: 978-3-540-19660-0
Online ISBN: 978-1-4471-3182-3
eBook Packages: Springer Book Archive