# A proof of Moessner’s theorem by coinduction

## Authors

- First Online:

DOI: 10.1007/s10990-012-9082-7

- Cite this article as:
- Niqui, M. & Rutten, J.J.M.M. Higher-Order Symb Comput (2011) 24: 191. doi:10.1007/s10990-012-9082-7

- 1 Citations
- 302 Views

## Abstract

We present a coinductive proof of Moessner’s theorem. This theorem describes the construction of the stream (1^{n},2^{n},3^{n},…) (for *n*≥1) out of the stream of positive natural numbers by repeatedly dropping and summing elements. Our formalisation consists of a direct translation of the operational description of Moessner’s procedure into the equivalence of—in essence—two functional programs. Our proof fully exploits the circularity that is implicitly present in Moessner’s procedure, and it is more elementary than existing proofs. As such, it serves as a non-trivial illustration of the relevance and power of coinduction.

### Keywords

StreamStream bisimulationCoalgebraCoinductionStream differential equationStream calculusMoessner’s theorem## 1 Introduction

*third*element, obtaining

*n*≥1: drop every

*n*th element and form the subsequent stream of partial sums, and then drop every (

*n*−1)th element and form the subsequent stream of partial sums, etc. A proof of the correctness of this procedure, which is known as Moessner’s theorem, was given by Perron [8]. An alternative proof and further generalisations were provided by Paasche [7] and Salié [11]. All these proofs are based on a detailed bookkeeping of the elements of all the intermediate streams, and use nested inductions, involving binomial coefficients and falling factorial numbers. More details about these classical proofs can be found in recent work [3, 4] by Hinze, in which he has given a new proof of Moessner’s theorem (and its generalisations), in a calculational style.

Here, we present another proof of Moessner’s theorem, based on coinduction. Coinduction is both a definition principle and a proof principle, and it is one of the cornerstones of the theory of coalgebra [9]. It is dual to the well-known principle of mathematical induction, which is well-suited for finite and well-founded structures, such as the natural numbers and finite lists. In contrast, coinduction can be used for reasoning about infinite structures such as the streams of natural numbers above.

- 1.
Our formalisation of Moessner’s procedure consists of a direct translation of the operational description of Moessner’s procedure with which we started this paper.

- 2.
The construction of a suitable stream bisimulation, which as usual constitutes the heart of a proof by coinduction, fully exploits the circularity that is present in our definition of both the stream of natural numbers and the drop and sum operators.

- 3.
Our proof is elementary to a degree that we expect that it can be easily automated, as is often the case with coinductive proofs.

None of these characteristics are shared by the afore-mentioned classic proofs by Perron, Paasche and Salié. And although Hinze’s proof does exploit some of the circularity involved, using corecursive definitions of the operators it uses, his formalisation is at a considerable distance from the original operational description of Moessner’s procedure. Moreover, the proof by Hinze is, to be sure, very interesting and clever but also somewhat ad hoc and relatively complex.

At the same time, the proofs by Paasche, Salié and Hinze deal with both Moessner’s original theorem and with the generalisations mentioned above. In contrast, our present proof deals with Moessner’s original procedure only. And although we conclude our paper with a formalisation of a representative example of these generalisations, finding a proof by coinduction for this representative example is left as future work.

## 2 Preliminaries

*streams*of natural numbers by

*σ*(0) the

*initial value*of

*σ*and we call the remainder of the stream the

*stream*

*derivative*of

*σ*, denoted by

*σ*, which will be denoted by

*σ*″. We can view streams as states of an abstract machine, for which initial value and derivative together determine the

*behaviour*: one can think of the initial value

*σ*(0) as an (initial) observation on

*σ*; and when we take one single transition step in state

*σ*, we reach the new state

*σ*′.

*stream differential equations*[10]. In analogy to differential equations in classical mathematics, stream differential equations define streams by specifying their stream derivative and their initial value.

- The stream \(\overline{n} = (n,n,n, \ldots)\), for every
*n*∈ℕ, is given by the following stream differential equation:with initial value \(\overline{n}(0) = n\).$$\overline{n}'= \overline{n} $$ - The element-wise
*sum*of two streams$$\sigma+ \tau= \bigl(\sigma(0) + \tau(0) , \sigma(1) + \tau(1) , \sigma(2) + \tau(2), \ldots\bigr) $$*σ*,*τ*∈ℕ^{ω}can be specified by the following stream differential equation:with initial value$$(\sigma+ \tau)' = \sigma' + \tau' $$(We use overloading: the same symbol is used for the sum of natural numbers and the sum of streams.)$$(\sigma+ \tau) (0) = \sigma(0) + \tau(0) $$ - Using the operation of sum, we can specify the stream of the
*positive natural numbers*nat=(1,2,3,…) bywith initial value nat(0)=1.$$\mbox {\textsf {nat}}'= \mbox {\textsf {nat}}+ \overline {1}$$ - The (element-wise)
*Hadamard product*of two streams$$\sigma\odot\tau= \bigl(\sigma(0) \cdot\tau(0) , \sigma(1) \cdot \tau(1) , \sigma(2) \cdot\tau(2), \ldots\bigr) $$*σ*,*τ*∈ℕ^{ω}satisfieswith initial value$$(\sigma\odot\tau)' = \sigma' \odot \tau' $$$$(\sigma\odot\tau) (0) = \sigma(0) \cdot\tau(0) $$ - The following
*notation*will be convenient. For a stream*σ*and for*n*≥0, we defineThus$$\sigma^{\langle0 \rangle} = \overline {1}\qquad \sigma^{\langle n+1 \rangle} = \sigma\odot \sigma^{ \langle n \rangle} $$*σ*^{〈1〉}=*σ*,*σ*^{〈2〉}=*σ*⊙*σ*,*σ*^{〈3〉}=*σ*⊙*σ*⊙*σ*, and so on. Also,$$\mbox {\textsf {nat}}^{ \langle n \rangle} = \bigl(1^n, 2^n, 3^n, \ldots\bigr) $$ - Scalar multiplicationof a stream$$k\sigma= \bigl(k \cdot\sigma(0) , k \cdot\sigma(1) , k \cdot\sigma (2) , \ldots \bigr) $$
*σ*∈ℕ^{ω}with a natural number*k*∈ℕ satisfies:with initial value$$(k\sigma)' = k\sigma' $$$$(k\sigma) (0) = k \cdot\sigma(0) $$ - For every
*σ*∈ℕ^{ω}, the streamof$$\varSigma \sigma = \bigl(\sigma(0) , \sigma(0) + \sigma(1) , \sigma(0) + \sigma(1) + \sigma(2) , \ldots\bigr) $$*partial sums*of*σ*is defined by the following stream differential equation:with initial value$$( \varSigma \sigma )' = \bigl( \varSigma \sigma' \bigr) + \overline{\sigma(0)} $$$$( \varSigma \sigma ) (0) = \sigma(0) $$ - We define
*drop operators*\(D_{k}^{i}\), for all*k*≥2 and 0≤*i*<*k*, and for all*σ*∈ℕ^{ω}, by the following system of stream differential equations: for all*k*≥2 and 0≤*i*<*k*−1, with initial values The operator \(D_{k}^{i}\) repeatedly drops the*i*-th element of every block of*k*elements of the incoming stream (please note that we start counting the elements of streams with 0). For instance,$$D_3^1(\sigma) = \bigl(\sigma(0), \sigma(2), \sigma(3), \sigma(5), \sigma(6), \sigma(8) ,\ldots\bigr) $$ - It will be convenient to have one function symbol for the composition of a drop operator with the operator for partial sums. Therefore we define, for all
*k*≥2 and 0≤*i*<*k*,These operators satisfy the following differential equations: for all$$\varSigma_k^i = \varSigma\circ D_k^i $$*k*≥2 and 0≤*i*<*k*−1, with initial values

(It is straightforward to prove that all of the stream differential equations [10] mentioned above are well-defined, that is, have a unique solution.)

In our proof of Moessner’s theorem, we will use a few basic properties of the operators above, all of which are easily verified.

We use stream differential equations not only because they offer a very succinct and convenient way of specifying streams. Equally importantly, they also allow us to build *stream bisimulation relations*, which are defined in terms of stream derivatives and initial values. Stream bisimulations are the key ingredient of proofs by coinduction, as we will see shortly.

### Definition 2.2

(stream bisimulation)

*A relation*

*R*⊆ℕ

^{ω}×ℕ

^{ω}

*is a*(stream) bisimulation

*if all*(

*σ*,

*τ*)∈

*R*

*satisfy the following two properties*:

- (1)
*σ*(0)=*τ*(0) - (2)
(

*σ*′,*τ*′)∈*R*

### Theorem 2.3

(coinduction proof principle)

*For a stream bisimulation relation*

*R*⊆ℕ

^{ω}×ℕ

^{ω}

*and for all*

*σ*,

*τ*∈ℕ

^{ω},

### Proof

If *R* is a bisimulation relation, then one proves *σ*(*n*)=*τ*(*n*), for all *σ*,*τ*∈ℕ^{ω} with (*σ*,*τ*)∈*R*, by induction on *n*∈ℕ. □

### Example 2.4

*shuffle product*[1, 10] of two streams

*σ*and

*τ*can be defined, using binomial coefficients, by

*R*⊆ℕ

^{ω}×ℕ

^{ω}to be the smallest set such that

- (i)for all
*σ*,*τ*and*ρ*in ℕ^{ω},$$\bigl( (\sigma\otimes\tau)\otimes\rho, \sigma \otimes( \tau \otimes\rho) \bigr) \in R $$ - (ii)for all (
*σ*_{1},*σ*_{2})∈*R*and (*τ*_{1},*τ*_{2})∈*R*,$$( \sigma_1 + \tau_1 , \sigma_2 + \tau_2 ) \in R $$

*R*is a bisimulation relation. The associativity of the shuffle product now follows by the coinduction proof principle, Theorem 2.3.

The example above will not play a role in the rest of this paper, apart from the last part of Sect. 7, where we discuss future research.

## 3 Moessner’s theorem

Using the definitions from Sect. 2, we shall now formalise Moessner’s construction, which we shall start not with the stream of natural numbers but with the constant stream \(\overline {1}= (1,1,1, \ldots)\). This formulation is equivalent to the description given in the introduction because, as we shall see, \(\varSigma \overline {1}= \mbox {\textsf {nat}}\) whence \(\varSigma^{n}_{n+1} \overline {1}= \mbox {\textsf {nat}}\), for all *n*≥1.

### Theorem 3.1

(Moessner’s theorem)

*For all*

*n*≥1,

We note that the above formula is a direct translation of the operational description of Moessner’s procedure, given in the introduction.

## 4 The proof: warming up

We shall first prove Moessner’s theorem for *n*=1 and *n*=2. The proofs will be by coinduction and consist of the construction of a stream bisimulation relation. After that, it will be easy to define one (big) bisimulation relation for Moessner’s theorem in its full generality, for all *n*≥1 at the same time.

### 4.1 Moessner theorem for *n*=1

*R*⊆ℕ

^{ω}×ℕ

^{ω}is to put

*R*is a stream bisimulation relation, we compute initial values on the left and the right, which are equal to 1. Thus

*R*satisfies stream bisimulation property (1), of Definition 2.2. Computing stream derivatives gives

*R*is not closed under stream derivatives, and so does not satisfy stream bisimulation property (2). In order to ensure that

*R*will be closed under stream derivatives, our second attempt at defining

*R*is now as follows: let

*R*⊆ℕ

^{ω}×ℕ

^{ω}be the smallest set satisfying

- (i)
\(( \varSigma^{1}_{2} \overline {1}, \mbox {\textsf {nat}}) \in R \)

- (ii)
\(( \varSigma^{0}_{2} \overline {1}, \mbox {\textsf {nat}}) \in R \)

- (iii)
for all

*σ*∈ℕ^{ω}, (*σ*,*σ*)∈*R* - (iv)for all (
*σ*_{1},*τ*_{1})∈*R*and (*σ*_{2},*τ*_{2})∈*R*,$$(\sigma_1 + \sigma_2 , \tau_1 + \tau_2 ) \in R $$

*R*is indeed closed under derivatives. Also, one easily checks that initial values left and right are equal, for all pairs in

*R*. Thus

*R*is a stream bisimulation. It follows, by coinduction Theorem 2.3, that \(\varSigma^{1}_{2} \overline {1}= \mbox {\textsf {nat}}\).

### 4.2 Moessner theorem for *n*=2

*R*⊆ℕ

^{ω}×ℕ

^{ω}such that

*R*is a stream bisimulation. As before, we investigate stream derivatives left and right and compute (using Proposition 2.1 for the last equality). Also, We make a (mental) note to include the following three pairs in

*R*:

*n*=1, and we continue with the computation of the stream derivatives of the streams in the first pair. Skipping a few intermediate steps, in which again some of the properties from Proposition 2.1 are used, we find:

*R*⊆ℕ

^{ω}×ℕ

^{ω}be the smallest set satisfying

- (i)
\(( \varSigma^{1}_{2} \overline {1}, \mbox {\textsf {nat}}) \in R\) and \(( \varSigma^{1}_{2} \varSigma^{2}_{3} \overline {1}, \mbox {\textsf {nat}}^{ \langle2 \rangle } ) \in R \)

- (ii)
\(( \varSigma^{0}_{2} \overline {1}, \mbox {\textsf {nat}}) \in R \) and \(( \varSigma^{0}_{2} \varSigma^{1}_{3} \overline {1}, \mbox {\textsf {nat}}\odot(\mbox {\textsf {nat}}+ \overline {1}) ) \in R\)

- (iii)
for all

*σ*∈ℕ^{ω}, (*σ*,*σ*)∈*R* - (iv)
for all (

*σ*_{1},*τ*_{1})∈*R*and (*σ*_{2},*τ*_{2})∈*R*, (*σ*_{1}+*σ*_{2},*τ*_{1}+*τ*_{2})∈*R*

*R*is a stream bisimulation relation. It follows, by coinduction Theorem 2.3, that \(\varSigma^{1}_{2} \overline {1}= \mbox {\textsf {nat}}\) and that \(\varSigma^{1}_{2} \varSigma^{2}_{3} \overline {1}= \mbox {\textsf {nat}}^{ \langle2 \rangle}\). In other words, the above relation

*R*proves Moessner’s theorem for

*n*=1 and

*n*=2 at the same time.

## 5 The proof: general case

*n*≥1. For the proof, we define again a stream bisimulation relation, generalising the relations used previously, as follows: Let

*R*⊆ℕ

^{ω}×ℕ

^{ω}be the smallest set satisfying

- (i)for all
*n*≥1,$$\bigl( \varSigma^1_2 \varSigma^2_3 \cdots \varSigma^n_{n+1} \overline {1}, \mbox {\textsf {nat}}^{ \langle n \rangle} \bigr) \in R $$ - (ii)for all
*n*≥1,$$\bigl( \varSigma^0_2 \varSigma^1_3 \cdots \varSigma^{n-1}_{n+1} \overline {1}, \mbox {\textsf {nat}}\odot(\mbox {\textsf {nat}}+ \overline {1})^{ \langle n-1 \rangle} \bigr) \in R $$ - (iii)for all
*σ*∈ℕ^{ω},$$(\sigma, \sigma) \in R $$ - (iv)for all (
*σ*_{1},*τ*_{1})∈*R*and (*σ*_{2},*τ*_{2})∈*R*,$$(\sigma_1 + \sigma_2 , \tau_1 + \tau_2 ) \in R $$

*R*is a stream bisimulation. Moessner’s theorem then follows by coinduction, Theorem 2.3.

In order to prove that the relation *R* is a bisimulation, we shall use the following facts.

### Proposition 5.2

### Proposition 5.3

### Proposition 5.4

*n*. In the induction step, one uses the following property of binomial coefficients: for all

*n*≥1 and 0≤

*i*≤

*n*−1,

Using these four propositions, one can easily show that the relation *R*, defined at the beginning of this section, is a stream bisimulation relation. Moessner’s theorem, now for all *n*≥1, follows as before by coinduction.

## 6 Stream calculus

The coinductive proof of the previous section is what we see as the main contribution of this paper. In the present section, we want to give yet another proof of Moessner’s theorem, which can be viewed as an equational version of the proof by coinduction: by using a bit of elementary stream calculus [10], of which we shall briefly recall the basics below, we can find closed expressions for each of the streams in Moessner’s theorem. The theorem is then proved by showing that these expressions are equal.

*r*∈ℝ, we define the constant stream

*sum*is given, as before, by

*σ*,

*τ*∈ℝ

^{ω}and

*n*≥0.

*(convolution) product*:

*r*∈ℝ and any stream

*σ*,

*shorthand*is justified:

*σ*and

*n*≥0, we define

*σ*

^{1}=

*σ*,

*σ*

^{2}=

*σ*×

*σ*,

*σ*

^{3}=

*σ*×

*σ*×

*σ*, and so on. (Please note the difference between these powers of the convolution product, on the one hand, and the powers of the Hadamard product, on the other hand. The Hadamard powers were defined previously by \(\sigma^{ \langle0 \rangle} = \overline {1}= (1,1,1, \ldots)\) and

*σ*

^{〈n+1〉}=

*σ*⊙

*σ*

^{〈n〉}.)

*σ*with

*σ*(0)≠0 has an inverse in ℝ

^{ω}with respect to convolution product. This multiplicative inverse is denoted by

*σ*

^{−1}. It is unique and satisfies

*σ*for

*σ*

^{−1}and

*σ*/

*τ*for

*σ*×

*τ*

^{−1}.

*X*lies in the following property: for all

*σ*∈ℝ

^{ω},

*σ*=

*X*yields and so on.

*π*∈ℝ

^{ω}

*polynomial*if there are

*k*≥0 and

*a*

_{i}∈ℝ such that A stream

*ρ*∈ℝ

^{ω}is

*rational*if it is the quotient

*ρ*=

*σ*/

*τ*of two polynomial streams

*σ*and

*τ*with

*τ*(0)≠0. For instance, the following streams are rational:

*fundamental theorem*of stream calculus [10]: for all

*σ*∈ℝ

^{ω},

*σ*=[1]×

*σ*, this yields the following solution

In the remainder of this section, we shall apply the stream calculus above for yet another proof of Moessner’s theorem. More specifically, we shall prove that both streams on the left-hand side and the right-hand side of Moessner’s identity are rational, using the fundamental theorem together with the propositions from Sect. 5. Then Moessner’s follows simply from the observation that these rational streams are equal.

### 6.1 A rational expression for \(\varSigma^{1}_{2} \varSigma^{2}_{3} \cdots \varSigma^{n}_{n+1} \overline {1}\)

*n*≥1. For the numbers

*P*

_{n}, we have And for the numbers

*Q*

_{n}, we have where the coefficients \(a_{i}^{j}\) are defined as in Proposition 5.3. As a consequence, we obtain the following recurrence relation for

*Q*

_{n}: This recurrence together with the above formula for

*P*

_{n}allows us to compute a closed rational expression for (both

*Q*

_{n}and)

*P*

_{n}, yielding the following formulae, for the first few values of

*n*: (A general formula for

*P*

_{n}, for arbitrary

*n*≥1, will be discussed below.)

### 6.2 A rational expression for nat^{〈n〉}

^{〈0〉}. It leads to the following rational expressions, again for the first few values of

*n*

### 6.3 Yet another proof of Moessner’s theorem

*P*

_{1},

*P*

_{2}, etc. are equal to those for nat

^{〈1〉}, nat

^{〈2〉}, etc., we have proved Moessner’s theorem again, for each of these cases. For a general proof, for all

*n*≥1 at the same time, we have to determine a general expression for arbitrary

*n*, for both

*P*

_{n}and nat

^{〈n〉}. To this end, we use the fact that there exists a

*generating function*for the

*n*-powers of the natural numbers [2, 12]. Such generating functions can be (almost literally) translated into an expression in stream calculus: for all

*n*≥1:

*A*(

*n*,

*m*) are the so-called

*Eulerian numbers*, which are defined, for every

*n*≥1 and 0≤

*m*≤

*n*−1, by the following recurrence relation: Identity (1) above constitutes yet another proof of Moessner’s theorem.

## 7 Discussion

Streams are viewed as single entities.

- The coinduction proof principle, Theorem 2.3, says that in order to prove that two streams
*are*the same, it suffices to show that they*behave*the same (since two streams have the same behaviour if they are related by a bisimulation). For streams, in other words,*being is doing* Showing that two streams behave the same (and hence are equal) is particularly easy when their behaviour is

*circular*. Circularity makes it possible to construct finite or (using induction) finitary bisimulation relations.- For the proof of Moessner’s theorem, the circularity involved is expressed by the stream differential equations for the operations of partial summation and dropping, on the one hand, and the stream of natural numbers, on the other hand. To illustrate this circularity for the natural numbers, we recall thatHere we have circular behaviour in that after one transition step of nat, we obtain a new state nat′ that contains nat again as a summand.$$\mbox {\textsf {nat}}'= \mbox {\textsf {nat}}+ \overline {1}$$
We arrived at the definition of the bisimulation relation

*R*used in the proof of Moessner’s theorem in a fairly standard way. First we constructed*R*for the cases of*n*equal to 1 (Sect. 4.1) and 2 (Sect. 4.2). For each of these cases, we included first the pair of streams that we wanted to prove equal (clause (i) of the definition of*R*). Then we computed their derivatives and observed that they consist of sums of the streams we started out with together with some new streams. The latter were added as new pairs, in clause (ii). Closing*R*under sums, in clause (iii) and including the identity relation, in clause (iv), then was sufficient to prove that*R*is a bisimulation. Having gone through this process for the first few values of*n*, the general definition of*R*emerged (Sect. 5).

*P*

_{n}and nat

^{〈n〉}, which resulted in the propositions of Sect. 5. Similarly, the recurrence relations that led to the rational expressions for

*P*

_{n}and nat

^{〈n〉}are based on these same propositions.

- (1)
We want to analyse the precise relationships between our present two proofs, on the one hand, and the proofs by Perron [8], Paasche [7] and Salié [11], and by Hinze [3], on the other hand. Such an analysis will be more difficult than one might expect, since our coinductive proof exploits another type of circularity (of the natural numbers, of the various stream operators) than any of the other proofs. This difference makes a direct comparison rather difficult. Also, our formalisation, that is, our mathematical formulation of Moessner’s theorem is different from any of the other proofs: ours is an almost literal translation of the operational description of Moessner’s procedure.

- (2)We want to try and apply our coinductive proof method to the following generalisation of Moessner’s theorem [3, 7, 11]. A first contribution to a coinductive proof of this generalisation is already contained in our formulation of it here: we present its ingredients in terms of again a stream differential equation, using the following slightly adapted version of the drop operator: for all
*σ*∈ℕ^{ω}and all*k*≥2 and 0≤*i*<*k*, we define The difference between this definition and the one in Sect. 2 lies in the value of \(( D_{k}^{0} \sigma )'\), which changes the cycle of the drop operator from*k*to*k*+1. Using this new definition, we define an operation*M*on streams*σ*∈ℕ^{ω}of natural numbers by the following stream differential equation:The question with which we want to conclude the present paper is: to give a coinductive proof of the fact that$$M(\sigma) (0) = \sigma(0)\qquad \bigl(M(\sigma)\bigr)' = M\bigl( \varSigma\circ D^1_2 \bigl(\sigma' \bigr) \bigr) $$The fact that we are able to formalise also this generalised version of Moessner’s theorem can be considered in itself already as a contribution. In order to be able to come up with a coinductive proof, we will have to understand better which type of circularity is underlying the stream of factorial numbers. The following characterisation [10] might turn out to be useful:$$M(\overline {1}) = (0!,1!,2!, \ldots) $$where the operator of (underlined) inverse is with respect to the shuffle product, introduced in Example 2.4. Shuffle inverse is formally defined by the following stream differential equation:$$(0!,1!,2!, \ldots) = \bigl([1]-X\bigr)^{-\underline{1}} $$with initial value$$\bigl(\sigma^{-\underline{1}}\bigr)' = -\sigma' \otimes\bigl( \sigma^{-\underline{1}} \otimes\sigma^{-\underline {1}} \bigr) $$$$\sigma^{-\underline{1}}(0) = \sigma(0)^{-1} $$

## Acknowledgements

We are very much indebted to Ralf Hinze, who gave a proof of Moessner’s theorem in a calculational style [3, 4]. On hearing the presentation of our paper on stream splitting and sampling [6], he invited us to investigate a possible link with coinduction. The outcome of our investigation is the present paper. We are grateful to Olivier Danvy for various constructive comments on earlier versions of this paper. Finally we would like to thank the anonymous referees for their corrections and suggestions for improvements.

### Open Access

This article is distributed under the terms of the Creative Commons Attribution License which permits any use, distribution, and reproduction in any medium, provided the original author(s) and the source are credited.