scholarly journals Interleaving data and effects

Author(s):  
ROBERT ATKEY ◽  
PATRICIA JOHANN

AbstractThe study of programming with and reasoning about inductive datatypes such as lists and trees has benefited from the simple categorical principle of initial algebras. In initial algebra semantics, each inductive datatype is represented by an initial f-algebra for an appropriate functor f. The initial algebra principle then supports the straightforward derivation of definitional principles and proof principles for these datatypes. This technique has been expanded to a whole methodology of structured functional programming, often called origami programming.In this article we show how to extend initial algebra semantics from pure inductive datatypes to inductive datatypes interleaved with computational effects. Inductive datatypes interleaved with effects arise naturally in many computational settings. For example, incrementally reading characters from a file generates a list of characters interleaved with input/output actions, and lazily constructed infinite values can be represented by pure data interleaved with the possibility of non-terminating computation. Straightforward application of initial algebra techniques to effectful datatypes leads either to unsound conclusions if we ignore the possibility of effects, or to unnecessarily complicated reasoning because the pure and effectful concerns must be considered simultaneously. We show how pure and effectful concerns can be separated using the abstraction of initial f-and-m-algebras, where the functor f describes the pure part of a datatype and the monad m describes the interleaved effects. Because initial f-and-m-algebras are the analogue for the effectful setting of initial f-algebras, they support the extension of the standard definitional and proof principles to the effectful setting.Initial f-and-m-algebras are originally due to Filinski and Støvring, who studied them in the category Cpo. They were subsequently generalised to arbitrary categories by Atkey, Ghani, Jacobs, and Johann in a FoSSaCS 2012 paper. In this article we aim to introduce the general concept of initial f-and-m-algebras to a general functional programming audience.

1977 ◽  
Vol 24 (1) ◽  
pp. 68-95 ◽  
Author(s):  
J. A. Goguen ◽  
J. W. Thatcher ◽  
E. G. Wagner ◽  
J. B. Wright

2021 ◽  
Vol vol. 23 no. 1 (Automata, Logic and Semantics) ◽  
Author(s):  
Zoltán Fülöp ◽  
Dávid Kószó ◽  
Heiko Vogler

We consider weighted tree automata (wta) over strong bimonoids and their initial algebra semantics and their run semantics. There are wta for which these semantics are different; however, for bottom-up deterministic wta and for wta over semirings, the difference vanishes. A wta is crisp-deterministic if it is bottom-up deterministic and each transition is weighted by one of the unit elements of the strong bimonoid. We prove that the class of weighted tree languages recognized by crisp-deterministic wta is the same as the class of recognizable step mappings. Moreover, we investigate the following two crisp-determinization problems: for a given wta ${\cal A}$, (a) does there exist a crisp-deterministic wta which computes the initial algebra semantics of ${\cal A}$ and (b) does there exist a crisp-deterministic wta which computes the run semantics of ${\cal A}$? We show that the finiteness of the Nerode algebra ${\cal N}({\cal A})$ of ${\cal A}$ implies a positive answer for (a), and that the finite order property of ${\cal A}$ implies a positive answer for (b). We show a sufficient condition which guarantees the finiteness of ${\cal N}({\cal A})$ and a sufficient condition which guarantees the finite order property of ${\cal A}$. Also, we provide an algorithm for the construction of the crisp-deterministic wta according to (a) if ${\cal N}({\cal A})$ is finite, and similarly for (b) if ${\cal A}$ has finite order property. We prove that it is undecidable whether an arbitrary wta ${\cal A}$ is crisp-determinizable. We also prove that both, the finiteness of ${\cal N}({\cal A})$ and the finite order property of ${\cal A}$ are undecidable.


2020 ◽  
Author(s):  
Jan Aldert Bergstra ◽  
John V. Tucker

In an arithmetical structure one can make division a total function by defining 1/0 to be an element of the structure, or by adding a new element, such as an error element also denoted with a new constant symbol, an unsigned infinity or one or both signed infinities, one positive and one negative. We define an enlargement of a field to a transfield, in which division is totalised by setting 1/0 equal to the positive infinite value and -1/0 equal to its opposite, and which also contains an error element to help control their effects. We construct the transrational numbers as a transfield of the field of rational numbers and consider it as an abstract data type. We give it an equational specification under initial algebra semantics.


1999 ◽  
Vol Vol. 3 no. 4 ◽  
Author(s):  
Ralf Hinze

International audience The theory and practice of polytypic programming is intimately connected with the initial algebra semantics of datatypes. This is both a blessing and a curse. It is a blessing because the underlying theory is beautiful and well developed. It is a curse because the initial algebra semantics is restricted to so-called regular datatypes. Recent work by R. Bird and L. Meertens [3] on the semantics of non-regular or nested datatypes suggests that an extension to general datatypes is not entirely straightforward. Here we propose an alternative that extends polytypism to arbitrary datatypes, including nested datatypes and mutually recursive datatypes. The central idea is to use rational trees over a suitable set of functor symbols as type arguments for polytypic functions. Besides covering a wider range of types the approach is also simpler and technically less involving than previous ones. We present several examples of polytypic functions, among others polytypic reduction and polytypic equality. The presentation assumes some background in functional and in polytypic programming. A basic knowledge of monads is required for some of the examples.


1982 ◽  
Vol 11 (145) ◽  
Author(s):  
Peter D. Mosses

A new approach to the formal description of programming language semantics is described and illustrated. ''Abstract semantic algebras'' are just algebraically-specified abstract data types whose operations correspond to fundamental concepts of programming languages. The values of abstract semantic algebras are taken as meanings of programs in Denotational (or Initial Algebra) Semantics, instead of using Scott domains. This leads to semantic descriptions that clearly exhibit the underlying conceptual analysis, and which are rather easy to modify and extend. Some basic abstract semantic algebras corresponding to fundamental concepts of programming languages are given; they could be used in the description of many different programming languages.


2010 ◽  
Vol 20 (3-4) ◽  
pp. 353-373 ◽  
Author(s):  
GRAHAM HUTTON ◽  
MAURO JASKELIOFF ◽  
ANDY GILL

AbstractThe worker/wrapper transformation is a general technique for improving the performance of recursive programs by changing their types. The previous formalisation (A. Gill & G. Hutton, J. Funct. Program., vol. 19, 2009, pp. 227–251) was based upon a simple fixed-point semantics of recursion. In this paper, we develop a more structured approach, based upon initial-algebra semantics. In particular, we show how the worker/wrapper transformation can be applied to programs defined using the structured pattern of recursion captured by fold operators, and illustrate our new technique with a number of examples.


1974 ◽  
Author(s):  
J. A. Goguen ◽  
J. W. Thatcher

Sign in / Sign up

Export Citation Format

Share Document