Mealy synthesis of arithmetic bitstream functions

A (binary) Mealy machine is a deterministic automaton which in each step reads an input bit, produces an output bit and moves to a next state. The induced mapping of input streams to output streams is a causal bitstream function, which we call the bitstream function realised by the Mealy machine. In this note, we describe a synthesis method which given an algebraic specification of a bitstream function f, constructs a minimal Mealy machine which realises f. In the design of digital hardware, Mealy machines specify the behaviour of sequential circuits, and there exist algorithms which construct from a (finite) Mealy machine, a sequential circuit which exhibits the specified behaviour. Combining these algorithms with our synthesis algorithm we thus obtain a complete construction from algebraic specification to sequential circuit. The inputs to our synthesis algorithm are called function expressions and they define bitstream functions in the algebra of 2-adic numbers. Here we use that the formal power series representation of a 2-adic integer can be seen as the bitstream of its coefficients. We describe the 2-adic algebra below, but for now such a function expression can be thought of as a specification of a function on the rational numbers. The interesting property of 2-adic arithmetic is that it allows us to calculate with rational numbers in an easy manner similar to how one computes with integers. The synthesis algorithm described here can be seen as an analogue of Brzozowski's construction in [3] of a finite deterministic automaton from a regular expression. In particular, we show that the set of function expressions can be given the structure of a Mealy machine by giving an inductive definition of derivative and output of function expressions. This Mealy machine of expressions is defined in such a way that the algebraic semantics coincides with the behavioural semantics of Mealy machines. Hence, given a function expression E which specifies a function f, the submachine generated by E realises f. In general, this submachine is not minimal, but we can ensure minimality by reducing expressions to normal form. In addition, the language of 2-adic arithmetic allows the specification of functions that are not realised by any finite Mealy machine. But we identify a subclass of so-called rational function expressions for which a finite realisation exists. Hence given a rational function expression E, we can effectively construct a minimal Mealy machine which realises the bitstream function specified by E. This is our main result. The theory underlying the synthesis method is essentially coalgebraic (cf. [10]), but we have deliberately chosen for a presentation which does not require any familiarity with coalgebra. The fundamental ideas behind the synthesis method are due to Jan Rutten (cf. [13]). These ideas were developed into a proper algorithm in [7] and implemented by the author and David Costa (cf. [6]). Further results on complexity and size of realisations were included in the author's PhD thesis [5, Ch. 3]. This note contains a short, but improved presentation of the basic results in the abovementioned work. In particular, the presentation of the Mealy machine of expressions, the algebraic semantics of function expressions, and the proof that algebraic semantics coincides with behavioural semantics for function expressions are new with respect to [5, 7, 13]. The rest of this paper is structured as follows. In Section 1 we give the basic definitions regarding Mealy machines, and in Section 2 we describe the 2-adic algebra of bitstreams and define the function expressions which serve as our specification language. In Section 3 we show how function expressions can be turned into a Mealy machine, and Section 4 describes the synthesis method for rational functions. Finally, we discuss related and future work in Section 5.