29 June 2016

prerequisites: The post A characteristic function of Moessner’s sieve

“The trick, William Potter,
is not minding that it hurts.”
– Robert Bolt, Lawrence of Arabia

1. Introduction

The goal of this blog post is to introduce a new combinatorial property which connects Moessner triangles of different rank but with the same triangle index, thus acting as a dual to the existing connection between Moessner triangles of the same rank but different triangle index. This duality proposes the view of Moessner’s sieve as generating a 2-dimensional grid of triangles instead of just a 1-dimensional sequence of triangles.

The post is structured as follows. In Section 2, we motivate the idea of viewing Moessner’s sieve as generating a grid of triangles, and introduce a rank upgrading procedure, which takes a seed tuple of a Moessner triangle of rank and returns the seed tuple of the same Moessner triangle of rank . As a dual to the first section, we introduce a set of rank decomposition rules in Section 3, which allows us to describe any entry of a Moessner triangle of rank as a sum of entries in the same Moessner triangle of rank . The post is concluded in Section 4.

2. Generating a grid of triangles with Moessner’s sieve

In this section, we propose the idea of viewing the output of Moessner’s sieve as a grid of triangles by first observing a connection between the seed tuples of the th Moessner triangle of different rank, and . Using this observation, we introduce a rank upgrading procedure, upgradeSeedTuple, which takes a seed tuple of a Moessner triangle of rank and returns the seed tuple of the same Moessner triangle of rank . Finally, we demonstrate its application.

2.1 A connection between seed tuples

In order to motivate the idea of Moessner’s sieve generating a grid of triangles, we start by examining the first three Moessner triangles of rank and , along with their respective seed tuples,

Now, for both sieves we know that we can move from left to right, i.e., increase the index of the triangles, but we do not know if we can move from top to bottom, i.e., increase the rank of the triangles. However, if we remember that we can characterize each seed tuple as an instance of the binomial expansion , where is the rank of the Moessner triangle and is the triangle index, we search for a combinatorial property that allows us to go from the seed tuple corresponding to the binomial expansion where to the seed tuple corresponding to the binomial expansion where , thus obtaining the needed vertical movement in the grid of triangles.

If we examine the two seed tuples generated by the first Moessner triangles, and , we observe that we can obtain the second seed tuple from the first using the following scheme,

where we obtain the th element of rank by adding the th element of rank plus the value of an accumulator which contains the value of the th element of rank – coincidentally this calculation is also equivalent to an application of Pascal’s rule in Pascal’s triangle for these values. However, when we examine the next pair of seed tuples, and , we realize that the above scheme is insufficient for calculating the second tuple from the first. Fortunately, we receive a hint from the fact that the last elements of the two tuples are equal to and , respectively, which means that we can obtain the latter by multiplying the former by . With this in mind, we change the scheme accordingly and get,

which now yields the desired result. It turns out that this Pascal-like property, of adding the two nearest entries of the seed tuple of rank , holds in general if we substitute the with . For example, if we look at the hypotenuses of the third pair of triangles, where , we get the following calculations,

which confirm the correctness of the formula – this property can also be seen from the multiplicative property, , of the binomial expansion. Thus, we have now demonstrated how to obtain the seed tuple of rank , when given the seed tuple of rank , which means that we can now move in a vertical direction as well as a horizontal direction in the grid of triangles shown at the beginning of this section.

Having covered the motivation for perceiving Moessner’s sieve as generating a grid of triangles, rather than a sequence of triangles, we move on to construct a rank upgrading procedure, which given a seed tuple of rank returns the corresponding seed tuple of rank , thus implementing the vertical direction discussed above.

2.2 Rank upgrading procedure

When taking the description of the rank upgrading procedure in the previous section and translating it into Haskell, we initially note that the procedure should take a seed tuple, xs, an accumulator, a, and a triangle index, t, as inputs. Furthermore, we want to pattern match on the structure of the seed tuple, xs, as the procedure works by traversing the tuple and operating on its elements. Lastly, we observe that for the base case of the pattern matching, xs = [], we simply return a list containing just the accumulator, while in the inductive case of the pattern matching, xs = x : xs', we add the accumulator, a, to (t + 1) * x and cons the intermediate result with the result of the recursive call on xs'. Putting these pieces together we get the procedure,

1
2
3
4
upgradeSeedTupleAux :: Int -> Int -> Tuple -> Tuple
upgradeSeedTupleAux t a xs = case xs of
  [] -> [a]
  (x:xs') -> (t + 1) * x + a : upgradeSeedTupleAux t x xs'

for which we also define a wrapper function that initializes the accumulator to 0,

1
2
upgradeSeedTuple :: Int -> Tuple -> Tuple
upgradeSeedTuple t xs = upgradeSeedTupleAux t 0 xs

such that the three examples in Figure \ref{eq:substitute-moessner-triangle-one}-\ref{eq:substitute-moessner-triangle-three} can be expressed as the propositions,

1
2
3
(upgradeSeedTuple 0 [1,3,3,1]) == [1,4,6,4,1]
(upgradeSeedTuple 1 [8,12,6,1]) == [16,32,24,8,1]
(upgradeSeedTuple 2 [27,27,9,1]) == [81,108,54,12,1]

Having defined upgradeSeedTuple and demonstrated its use, we take a step back and investigate the dual of this section. Specifically, our next step is to show how to decompose the entries of the th Moessner triangle of rank in terms of the same Moessner triangle of rank .

3. Rank decomposition of Moessner triangles

In this section, we take the dual approach of the previous section by first motivating the introduction of a series of rank decomposition rules, which allows us to describe the entries of a Moessner triangle of rank in terms of the same Moessner triangle of rank .

3.1 Motivating the decomposition of Moessner triangles

Starting from the same example as in the previous section, we examine the first three Moessner triangles of rank and ,

and use the knowledge we have gathered so far to drive our motivation. Instead of looking at the calculations in Formula \ref{eq:substitute-moessner-triangle-two} and \ref{eq:substitute-moessner-triangle-three} as the upgrading of a seed tuple, we flip the perspective and see it as an example of decomposing the hypotenuse in terms of the Moessner triangle of lower rank. Taking this idea one step further, we propose the idea that there exists a set of rank decomposition rules which work for all entries of a triangle and not just the hypotenuse/seed tuple. With this idea in mind, we focus on the first column of the second and third pair of Moessner triangles and try to apply the same scheme as before, except that we make two minor adjustments,

  1. we multiply the first term with instead of , and
  2. we start with an accumulator equal to the last value of the column instead of ,

which gives us the following calculations, for the second and third triangles,

demonstrating that the property also holds for the initial column of every Moessner triangle. Remembering that the different Moessner triangles are constructed using Pascal’s rule, we restate the calculations in the formula above as,

by realizing that each of the values used for accumulators is actually the sum of one of the values in the seed tuple (western neighbor) and the entry which we have already multiplied by (northern neighbor),

Thus, we get times the entry above the desired entry (northern neighbor) and a value of the seed tuple/hypotenuse of the previous triangle (western neighbor).

Noting that we now have a Pascal-like rule which works across ranks, we examine whether it also holds true for the subsequent columns of the Moessner triangles. As such, we try to calculate the second column of the second and third pair of triangles using the first columns for accumulator values, instead of the seed tuples,

Again, we obtain the desired results, which demonstrates a consistent Pascal-like property across ranks and triangles. Thus, we have now shown how it is possible to state an entry of a Moessner triangle of rank as a sum of entries in the same Moessner triangle of rank .

Next, we transform our motivating examples into concrete rank decomposition rules.

3.2 Formalizing the decomposition rules

A subtle point lies in the fact that while the Moessner triangles have a finite number of entries in each column, this is not the case of our characteristic function rotatedMoessnerEntry,

as the gray values above are the results of computing entries outside of the Moessner triangles using our characteristic function. Thus, we obtain a more general, and easier to state, set of the rank decomposition rules by stating them in terms of our characteristic function, rotatedMoessnerEntry, rather than directly on the triangle creation procedure, createTriangleVertically.

In the previous section, we demonstrated two Pascal-like properties that could be merged into one simpler property, expressing an entry of a Moessner triangle of rank in terms of the same entry in the triangle of rank along with the entry above it (northern neighbor), which works for all columns of a Moessner triangle. We can define this decomposition rule in the following way,

1
2
3
4
 (n r c t : Int),
  rotatedMoessnerEntry (n  + 1) (r + 1) c t ==
  t * rotatedMoessnerEntry n r c t +
  rotatedMoessnerEntry n (r + 1) c t

which states that the entry in the th row and th column of a Moessner triangle of rank , is the sum of times the entry at the th row and th column of rank and the entry at the th row and th column of rank . This rule captures the examples we have shown above, and it can be proved by nested induction on the row and column indices, r and c. From this rule follows the two Pascal-like rule,

1
2
3
4
 (n r t : Int),
  rotatedMoessnerEntry (n + 1) (r + 1) 0 t ==
  (t + 1) * rotatedMoessnerEntry n r 0 t +
  monomial t n (r + 1)

and

1
2
3
4
 (r c n t : Int),
  rotatedMoessnerEntry (n + 1) (r + 1) (c + 1) t ==
  (t + 1) * rotatedMoessnerEntry n r (c + 1) t +
  rotatedMoessnerEntry n (r + 1) c t

which captures the two cases where the column index, c, is either 0 or greater than 0.

Combining the above rules and the procedure of the previous section, we have now shown a new property of Moessner’s sieve that creates a vertical connection between the seed tuples and entries of two Moessner triangles with the same triangle index, , but different ranks, and , thus acting as a dual to the existing properties which horizontally connects two triangles with different triangle index, , but same rank, , in this implicit grid of triangles.

4. Conclusion

In this post, we have introduced a new combinatorial property which connects Moessner triangles of different rank but with the same triangle index, thus acting as a dual to the existing connection between Moessner triangles of the same rank but different triangle index. This duality implies a 2-dimensional grid of Moessner triangles, where the triangle index is increasing as we go along the horizontal axis, from left to right, while the rank is increasing when going along the vertical axis, from top to bottom. These grid properties have been introduced as a rank upgrading procedure, which takes a seed tuple of the th Moessner triangle of rank and returns the seed tuple of the th Moessner triangle of rank , and several rank decomposition rules, which describe an entry of the th Moessner triangle of rank as a sum of entries in the th Moessner triangle of rank .

The rank upgrading procedure, upgradeSeedTuple, was the result of the observation that we could obtain the seed tuple of the Moessner triangle of rank by adding pairs of entries in the seed tuple of the Moessner triangle of rank where one was multiplied with the triangle index.

Conversely, the rank decomposition rules were the result of exploring whether the decomposition rule only applied for the seed tuples or if it persisted into the entries of the Moessner triangles.

This post was a small excerpt from my Master’s thesis, in which I also prove the correctness of the decomposition rules stated above, and relate them to the actual triangle creation procedures of the dual sieve.