### Notation

Recall that a *rooted binary phylogenetic X-tree* is a tree \left(\right)close="">\n \n T\n =\n (\n V\n (\n T\n )\n ,\n E\n (\n T\n )\n )\n \n with the following properties: There is one vertex \left(\right)close="">\n \n \rho \n \u2208\n V\n (\n T\n )\n \n with indegree 0 and outdegree 1, which is called the *root* of \left(\right)close="">\n \n T\n \n. All edges \left(\right)close="">\n \n e\n \u2208\n E\n (\n T\n )\n \n are directed away from *ρ*, and all vertices \left(\right)close="">\n \n v\n \u2208\n V\n (\n T\n )\n \u2216\n {\n \rho \n }\n \n have indegree 1 and outdegree 0 or 2. Vertices with outdegree 0 are usually referred to as *leaves* of \left(\right)close="">\n \n T\n \n. Remember that for an *X*-tree, there are exactly |*X*|=*n* leaves, which is why there is a bijection between the set of leaves of \left(\right)close="">\n \n T\n \n and the taxon set *X*. Thus, when there is no ambiguity, we use the terms *leaf* and *taxon* synonymously. Moreover, we often just write “phylogenetic tree” or “tree” when referring to a rooted binary phylogenetic tree.

Furthermore, recall that a *character* *f* is a function \left(\right)close="">\n \n f\n :\n X\n \u2192\n C\n \n for some set \left(\right)close="">\n \n C\n :\n =\n {\n \n \n c\n \n \n 1\n \n \n ,\n \n \n c\n \n \n 2\n \n \n ,\n \n \n c\n \n \n 3\n \n \n ,\n \u2026\n ,\n \n \n c\n \n \n r\n \n \n }\n \n of *r* *character states* (\left(\right)close="">\n \n r\n \u2208\n N\n \n). We denote by \left(\right)close="">\n \n \n \n C\n \n \n n\n \n \n \n the set of all *r*^{n} possible characters on \left(\right)close="">\n \n C\n \n and *n* taxa. For instance, for the four-state DNA alphabet, \left(\right)close="">\n \n \n \n C\n \n \n DNA\n \n \n =\n {\n A\n ,\n G\n ,\n C\n ,\n T\n }\n \n and the set \left(\right)close="">\n \n \n \n C\n \n \n DNA\n \n \n n\n \n \n \n consists of all 4^{n}possible characters.

An *extension* of *f* to \left(\right)close="">\n \n V\n (\n T\n )\n \n is a map \left(\right)close="">\n \n g\n :\n V\n (\n T\n )\n \u2192\n C\n \n such that *g*(*i*)=*f*(*i*) for all *i* in *X*. For such an extension *g* of *f*, we denote by \left(\right)close="">\n \n \n \n l\n \n \n T\n \n \n (\n g\n )\n \n the number of edges *e*={*u* *v*} in \left(\right)close="">\n \n T\n \n on which a substitution occurs, i.e. where *g*(*u*)≠*g*(*v*). The *parsimony score* of *f* on \left(\right)close="">\n \n T\n \n, denoted by \left(\right)close="">\n \n \n \n l\n \n \n T\n \n \n (\n f\n )\n \n, is obtained by minimizing \left(\right)close="">\n \n \n \n l\n \n \n T\n \n \n (\n g\n )\n \n over all possible extensions *g*. Given a tree \left(\right)close="">\n \n T\n \n and a character *f* on the same taxon set, one can easily calculate the parsimony score of *f* on \left(\right)close="">\n \n T\n \n with the famous Fitch algorithm [7]. Moreover, when a character state changes along one edge of the tree, we refer to this state change as *substitution* or *mutation*. As for our purposes only so-called manifest mutations are relevant, i.e. those mutations that can be observed and are not reversed, we do not distinguish between mutations and substitutions, which is why we use these terms synonymously.

### Construction of the OSM matrix

We now introduce the OSM framework in a stepwise fashion. The aim of the OSM approach is to determine the effects a single mutation occurring on a rooted tree \left(\right)close="">\n \n T\n \n has on a character evolving on that tree.

The first task of this approach is to formalize the term mutation and its effects on a single character state in \left(\right)close="">\n \n C\n \n. A mutation is an operation \left(\right)close="">\n \n \sigma \n :\n \n C\n \u2192\n C\n \n which is bijective, i.e. it satisfies the following condition:

C1. For all \left(\right)close="">\n \n \n \n c\n \n \n i\n \n \n \u2208\n C\n \n there is a \left(\right)close="">\n \n \n \n c\n \n \n j\n \n \n \u2208\n C\n \n such that *σ*(*c*_{
i
})=*c*_{
j
}, and if *σ*(*c*_{
i
})=*σ*(*c*_{
j
}), then *c*_{
i
}=*c*_{
j
}.

This guarantees that a mutation affects a character state in a unique fashion. It is well-known that any bijective function on a finite discrete state set is a permutation (e.g., [13]). Thus, a mutation is a specific instance of a permutation applied to a character.

The next step is to select the set *Σ* of admissible permutations acting on \left(\right)close="">\n \n C\n \n. It is mathematically convenient to select *Σ* such that it forms an Abelian group [9] with a regular (transitive and free) action on \left(\right)close="">\n \n C\n \n. Hence, *Σ* satisfies the following conditions:

C2. For every pair \left(\right)close="">\n \n \n \n c\n \n \n i\n \n \n ,\n \n \n c\n \n \n j\n \n \n \u2208\n C\n \n there is exactly one permutation *σ* ∈ *Σ* such that *σ* (*c*_{
i
}) = *c*_{
j
}, i.e., the action of *Σ* on \left(\right)close="">\n \n C\n \n is regular.

C3. For all *σ*_{1},*σ*_{2} ∈ *Σ* also the product *σ*_{1} ∘ *σ*_{2} ∈ *Σ*. Mathematically speaking, *Σ* is closed with respect to concatenation of its permutations.

C4. For all *σ*_{1},*σ*_{2}∈*Σ* we have \left(\right)close="">\n \n \n \n \sigma \n \n \n 1\n \n \n \u2218\n \n \n \sigma \n \n \n 2\n \n \n =\n \n \n \sigma \n \n \n 2\n \n \n \u2218\n \n \n \sigma \n \n \n 1\n \n \n \n Thus, *Σ* is commutative, and hence the order in which we assign permutations is irrelevant for the outcome.

C5. There is an element *σ*_{0} ∈ *Σ* such that for all *σ*_{1} ∈ *Σ* we have \left(\right)close="">\n \n \n \n \sigma \n \n \n 1\n \n \n \u2218\n \n \n \sigma \n \n \n 0\n \n \n =\n \n \n \sigma \n \n \n 0\n \n \n \u2218\n \n \n \sigma \n \n \n 1\n \n \n =\n \n \n \sigma \n \n \n 1\n \n \n \n, i.e. there exists a so-called neutral element, namely the identity, in *Σ*. For all \left(\right)close="">\n \n \n \n c\n \n \n i\n \n \n \u2208\n C\n \n only *σ*_{0}(*c*_{
i
}) = *c*_{
i
}, i.e. *σ*_{
i
}is fixed point free for all *σ*_{
i
}≠*σ*_{0}.

C6. For every *σ*_{1} ∈ *Σ* there exists a *σ*_{2} ∈ *Σ* such that *σ*_{1} ∘ *σ*_{2} = *σ*_{0}. Mathematically speaking, for every element of *Σ* there exists an inverse element. This guarantees that every permutation can be reversed within a single step.

C7. For all *σ*_{1},*σ*_{2},*σ*_{3} ∈ *Σ* we have *σ*_{1} ∘ (*σ*_{2} ∘ *σ*_{3}) = (*σ*_{1} ∘ *σ*_{2}) ∘ *σ*_{3} = *σ*_{1} ∘ *σ*_{2} ∘ *σ*_{3}, i.e. the associative law holds.

It should be noted that any set of permutations is associative, i.e. satifies C7. Thus, for a set of permutations *Σ* to be Abelian with a regular action on \left(\right)close="">\n \n C\n \n it only needs to satisfy C1−C6.

In the following, we consider the matrix representation of permutations. A permutation matrix over \left(\right)close="">\n \n C\n \n is an *r*×*r* matrix such that \left(\right)close="">\n \n \n \n \sigma \n \n \n \n \n c\n \n \n i\n \n \n \n \n c\n \n \n j\n \n \n \n \n =\n 1\n \n if *σ*(*c*_{
i
})=*c*_{
j
}, and 0 otherwise. We consider it equivalent to discuss a permutation or its corresponding matrix. Therefore, concatenation “∘” is equivalent to the matrix multiplication “·”. We use *σ* to denote a permutation or a permutation matrix, depending on the context.

**Example 1.** *In genetics, the most commonly used character state set is*\left(\right)close="">\n \n \n \n C\n \n \n DNA\n \n \n =\n {\n A\n ,\n G\n ,\n C\n ,\n T\n }\n \n. *There are two different Abelian groups for four states, namely the Klein-Four-group*\left(\right)close="">\n \n \n \n Z\n \n \n 2\n \n \n \xd7\n \n \n Z\n \n \n 2\n \n \n \n*and the cyclic group*\left(\right)close="">\n \n \n \n Z\n \n \n 4\n \n \n \n. *The Klein-Four-group is constructed from the cyclic group*\left(\right)close="">\n \n \n \n Z\n \n \n 2\n \n \n \n*over two elements, the identity* *τ*_{0}*and the flip* *τ*_{1}. *These take the matrix form*

{\tau}_{0}=\left(\begin{array}{cc}1& 0\\ 0& 1\end{array}\right),\phantom{\rule{1em}{0ex}}{\tau}_{1}=\left(\begin{array}{cc}0& 1\\ 1& 0\end{array}\right).

*The Klein-Four-group consists of the four Kronecker products of these two matrices, i.e.* *s*_{0} = *τ*_{0} ⊗ *τ*_{0}, *s*_{1} = *τ*_{1} ⊗ *τ*_{0}, *s*_{2} = *τ*_{0} ⊗ *τ*_{1}, and *s*_{3} = *τ*_{1} ⊗ *τ*_{1}. *The Kronecker products here yield 4×4 matrices, e.g.,*

{s}_{1}={\tau}_{1}\otimes {\tau}_{0}=\left(\begin{array}{cc}0& {\tau}_{0}\\ {\tau}_{0}& 0\end{array}\right)=\begin{array}{c}A\\ C\\ G\\ T\end{array}\phantom{\rule{0.5em}{0ex}}\stackrel{\begin{array}{cccc}A& C& G& T\end{array}}{\left(\begin{array}{cccc}0& 0& 1& 0\\ 0& 0& 0& 1\\ 1& 0& 0& 0\\ 0& 1& 0& 0\end{array}\right)}.

*The set* *Σ*_{K3ST}:={*s*_{0}*s*_{1}*s*_{2}*s*_{3}} *coincides with the substitution matrices under the Kimura 3ST model*[6]. *In particular,* *s*_{1}*describes transitions within purines* (*A* *G*) *and pyrimidines* (*C* *T*), *s*_{2}*represents transversions within pairs* (*A* *C*) *and* (*G* *T*), *and* *s*_{3}*represents the remaining set of transversions within pairs* (*A* *T*) *and* (*C* *G*).

*The second Abelian group over four states, the cyclic group*\left(\right)close="">\n \n \n \n Z\n \n \n 4\n \n \n \n, *is formed by selecting a 4-cycle, e.g.,* *A*→*G*→*T*→*C*→*A* *and concatenating this cycle with itself. The resulting set of permutations*\left(\right)close="">\n \n \n \n \Sigma \n \n \n \n \n Z\n \n \n 4\n \n \n \n \n \n*contains the following elements:*

\begin{array}{l}{{s}^{\prime}}_{1}=\begin{array}{c}A\\ C\\ G\\ T\end{array}\phantom{\rule{0.5em}{0ex}}\stackrel{\begin{array}{cccc}A& C& G& T\end{array}}{\left(\begin{array}{cccc}0& 0& 1& 0\\ 1& 0& 0& 0\\ 0& 0& 0& 1\\ 0& 1& 0& 0\end{array}\right)},\\ {{s}^{\prime}}_{2}={{s}^{\prime}}_{1}^{2}={{s}^{\prime}}_{1}\xb7{{s}^{\prime}}_{1},\phantom{\rule{1em}{0ex}}{{s}^{\prime}}_{3}={{s}^{\prime}}_{1}^{3},\phantom{\rule{1em}{0ex}}{{s}^{\prime}}_{0}={{s}^{\prime}}_{1}^{4}.\end{array}

*Note that there are actually six different four-cycles for*\left(\right)close="">\n \n \n \n C\n \n \n DNA\n \n \n \n. *These result in three distinguishable Abelian groups. Bryant*[14]*generates his cyclic group with the four-cycle* *A*→*C*→*G*→*T*→*A*, *and shows that the resulting set* *Σ*_{K2ST}*underlies the Kimura 2ST model*[15], *where*\left(\right)close="">\n \n \n \n \n \n s\n \n \n \u2032\n \n \n \n \n \n \n 2\n \n \n \n*corresponds to the transition within purines and pyrimidines, and*\left(\right)close="">\n \n \n \n \n \n s\n \n \n \u2032\n \n \n \n \n 1\n \n \n \n*and*\left(\right)close="">\n \n \n \n \n \n s\n \n \n \u2032\n \n \n \n \n 3\n \n \n \n*are the (not further distinguished) transversions.*

The next step in constructing the OSM matrix is to construct a set \left(\right)close="">\n \n \n \n \Sigma \n \n \n T\n \n \n \n of operations over \left(\right)close="">\n \n \n \n C\n \n \n n\n \n \n \n governed by \left(\right)close="">\n \n T\n \n, and based on the permutation set *Σ*. To this end, we first define *Σ*^{n} as a set of operations which work elementwise, i.e. for \left(\right)close="">\n \n f\n =\n (\n \n \n f\n \n \n 1\n \n \n ,\n \u2026\n ,\n \n \n f\n \n \n n\n \n \n )\n \u2208\n \n \n C\n \n \n n\n \n \n \n and *σ*∈*Σ*^{n} we have

\sigma \left(f\right):=\left({\sigma}_{1}\right({f}_{1}),\dots ,{\sigma}_{n}({f}_{n}\left)\right),\phantom{\rule{1em}{0ex}}{\sigma}_{i}\in \mathrm{\Sigma .}

This can also be described by the Kronecker product, i.e. equally

\sigma \left(f\right)={\sigma}_{1}\otimes \cdots \otimes {\sigma}_{n}\left(f\right).

(1)

This means that there are *r*^{n}different operators in *Σ*^{n}=*Σ*⊗⋯⊗*Σ*.

**Remark 1.** *Therefore, for any pair of characters*\left(\right)close="">\n \n f\n ,\n g\n \u2208\n \n \n C\n \n \n n\n \n \n \n*we can find an operation* *σ* ∈ *Σ*^{n}*such that* *σ* (*f*) = *g*.

Another noteworthy consequence of using the Kronecker product is that the elements of *Σ*^{n} are permutations over \left(\right)close="">\n \n \n \n C\n \n \n n\n \n \n \n[16, 17], and in fact *Σ*^{n} satisfies our Conditions C1−C7, i.e. *Σ*^{n} is an Abelian group over \left(\right)close="">\n \n \n \n C\n \n \n n\n \n \n \n.

In the OSM framework we assume that the permutations acting on a character \left(\right)close="">\n \n f\n \u2208\n \n \n C\n \n \n n\n \n \n \n are derived from the underlying rooted tree \left(\right)close="">\n \n T\n \n. If permutation *σ*_{
i
}∈*Σ* acts on the pendant edge leading to taxon *j*∈*X*, then the associated permutation matrix *σ*^{j,i}acting on \left(\right)close="">\n \n \n \n C\n \n \n n\n \n \n \n has the form

{\sigma}^{j,i}:=\underset{l=1}{\overset{j-1}{\otimes}}{\sigma}_{0}\otimes {\sigma}_{i}\otimes \underset{l=j+1}{\overset{n}{\otimes}}{\sigma}_{0}.

If a permutation acts on an interior edge *e*, then it simultaneously acts on the states of all descendant taxa of *e*, i.e. all those taxa whose path to the root passes *e*. E.g., assume Taxa 1 and 2 form a cherry, i.e. their most recent common ancestor, 12, has no other descendants, and permutation *σ*_{
i
}∈*Σ*, *i*=1,…,*r*−1 is acting on the edge leading to this ancestor. Then, we get the permutation

{\sigma}^{12,i}:={\sigma}_{i}\otimes {\sigma}_{i}\otimes {\sigma}_{0}\cdots \otimes {\sigma}_{0}={\sigma}^{1,i}\xb7{\sigma}^{2,i}.

(2)

This shows in particular that a Kronecker product of some permutations acting on each character state is equivalent to the matrix product of the permutations acting on the entire character. The right hand side equation shows that a single permutation on an internal edge has the same effect as simultaneously applying the same permutation on the pendant edges of all descendant taxa. In other words, if de(*e*) denotes the set of descendants of edge *e*, and *σ*_{
i
}∈*Σ*, then

{\sigma}^{e,i}=\prod _{j\in \mathrm{de}\left(e\right)}{\sigma}^{j,i}.

(3)

Note that the set *Σ*^{X}of all permutations acting on the pendant edges is a generator of *Σ*^{n}, i.e. the closure of *Σ*^{X} contains all permutations in *Σ*^{n}. Since *Σ*^{n} contains a single permutation to transform character \left(\right)close="">\n \n f\n \u2208\n \n \n C\n \n \n n\n \n \n \n into \left(\right)close="">\n \n g\n \u2208\n \n \n C\n \n \n n\n \n \n \n, and since *Σ*^{X} generates *Σ*^{n}, there is a shortest chain of permutations in *Σ*^{X}which transforms *f* into *g*. *Σ*^{X} is also the set of permutations implied by the star tree for *X*. In general, the set of all permutations on tree \left(\right)close="">\n \n T\n \n is

{\Sigma}^{\mathcal{T}}=\left\{{\sigma}^{e,i}:\phantom{\rule{0.3em}{0ex}}e\in E\left(\mathcal{T}\right),\phantom{\rule{2.77695pt}{0ex}}i\in \{0,\dots ,r-1\}\right\},

where *r* is the number of states in *Σ*.

For every *X*-tree \left(\right)close="">\n \n T\n \n we have \left(\right)close="">\n \n \n \n \Sigma \n \n \n T\n \n \n \u2287\n \n \n \Sigma \n \n \n X\n \n \n \n, and therefore \left(\right)close="">\n \n \n \n \Sigma \n \n \n T\n \n \n \n is a generator for *Σ*^{n}, too. An illustration of such a generator set \left(\right)close="">\n \n \n \n \Sigma \n \n \n T\n \n \n \n over the character set \left(\right)close="">\n \n \n \n C\n \n \n n\n \n \n \n is the so-called *Cayley graph*[18], which has as vertices the characters of \left(\right)close="">\n \n \n \n C\n \n \n n\n \n \n \n, and two characters \left(\right)close="">\n \n f\n ,\n g\n \u2208\n \n \n C\n \n \n n\n \n \n \n are connected if there is a permutation \left(\right)close="">\n \n \sigma \n \u2208\n \n \n \Sigma \n \n \n T\n \n \n \n such that *σ*(*f*)=*g*. In [5] Cayley graphs have been presented as alternative illustrations of the tree \left(\right)close="">\n \n T\n \n over a binary state set \left(\right)close="">\n \n C\n =\n {\n 0\n ,\n 1\n }\n \n.

**Example 2.** *Regard the K3ST model from Example 1 and the rooted two-taxon tree depicted in Figure*1a. *With this*\left(\right)close="">\n \n \n \n \Sigma \n \n \n K3ST\n \n \n T\n \n \n \n*is given by the set*

\begin{array}{llllll}{s}^{{e}_{1},1}& :={s}_{1}\otimes {s}_{0},\phantom{\rule{2em}{0ex}}& {s}^{{e}_{2},1}& :={s}_{0}\otimes {s}_{1},\phantom{\rule{2em}{0ex}}& {s}^{{e}_{12},1}& :={s}_{1}\otimes {s}_{1},\phantom{\rule{2em}{0ex}}\\ {s}^{{e}_{1},2}& :={s}_{2}\otimes {s}_{0},\phantom{\rule{2em}{0ex}}& {s}^{{e}_{2},2}& :={s}_{0}\otimes {s}_{2},\phantom{\rule{2em}{0ex}}& {s}^{{e}_{12},2}& :={s}_{2}\otimes {s}_{2},\phantom{\rule{2em}{0ex}}\\ {s}^{{e}_{1},3}& :={s}_{3}\otimes {s}_{0},\phantom{\rule{2em}{0ex}}& {s}^{{e}_{2},3}& :={s}_{0}\otimes {s}_{3},\phantom{\rule{2em}{0ex}}& {s}^{{e}_{12},3}& :={s}_{3}\otimes {s}_{3}.\phantom{\rule{2em}{0ex}}\end{array}

Each permutation which acts on the characters is thus a symmetric 16×16 permutation matrix depicting a transition (*s*^{e,1}), transversion 1 (*s*^{e,2}), or transversion 2 (*s*^{e,3}) along edge \left(\right)close="">\n \n e\n \u2208\n E\n (\n T\n )\n \n. Figures 1b-d display the permutation matrices for a transition on branch *e*_{1}(\left(\right)close="">\n \n \n \n s\n \n \n \n \n e\n \n \n 1\n \n \n ,\n 1\n \n \n \n), *e*_{2}(\left(\right)close="">\n \n \n \n s\n \n \n \n \n e\n \n \n 2\n \n \n ,\n 1\n \n \n \n) and *e*_{12}(\left(\right)close="">\n \n \n \n s\n \n \n \n \n e\n \n \n 12\n \n \n ,\n 1\n \n \n \n), respectively. Figure 1e shows the Cayley graph associated with \left(\right)close="">\n \n \n \n \Sigma \n \n \n K3ST\n \n \n T\n \n \n \n.

We are now in a position to recall the definition of the *OSM matrix*\left(\right)close="">\n \n \n \n M\n \n \n T\n \n \n \n for a rooted binary phylogenetic tree \left(\right)close="">\n \n T\n \n as explained in [5] and [19]. For an edge \left(\right)close="">\n \n e\n \u2208\n E\n (\n T\n )\n \n we denote by *p*_{
e
}the relative branch length of *e*, i.e. its actual branch length (expected number of substitutions per site) divided by the length of \left(\right)close="">\n \n T\n \n (the sum of all branch lengths). Thus, one can view *p*_{
e
}as the probability that a mutation is observed at edge *e* assuming that a single mutation occurred on \left(\right)close="">\n \n T\n \n. Clearly, \left(\right)close="">\n \n \n \n \u2211\n \n \n e\n \u2208\n E\n (\n T\n )\n \n \n \n \n p\n \n \n e\n \n \n =\n 1\n \n. Further, denote by *α*_{e,i} the probability that this mutation on *e* is of type *i*∈{1,…,*r*−1} with \left(\right)close="">\n \n \n \n \u2211\n \n \n i\n \u2208\n 1\n \n \n r\n \u2212\n 1\n \n \n \n \n \alpha \n \n \n e\n ,\n i\n \n \n =\n 1\n \n for all \left(\right)close="">\n \n e\n \u2208\n E\n (\n T\n )\n \n. Then the OSM matrix is the convex sum of the elements in \left(\right)close="">\n \n \n \n \Sigma \n \n \n T\n \n \n \n, where each permutation *σ*^{e,i} is multiplied by *α*_{e,i}*p*_{
e
}, the probability of hitting the edge *e* with permutation *σ*_{
i
}∈*Σ*. Thus, we obtain:

{M}_{\mathcal{T}}=\sum _{e\in E\left(\mathcal{T}\right)}\sum _{i=1}^{r-1}{\alpha}_{e,i}{p}_{e}{\sigma}^{e,i}.

(4)

\left(\right)close="">\n \n \n \n M\n \n \n T\n \n \n \n can be regarded as the weighted exchangeability matrix for all characters under the K3ST model assuming that a single substitution occurs on the tree \left(\right)close="">\n \n T\n \n. Figure 1f depicts the OSM matrix for the tree in Figure 1a. Here, colors indicate relative branch lengths *p*_{
e
}, and patterns denote permutation types *α*_{
i
}. E.g., a blue square with horizontal lines indicates the product \left(\right)close="">\n \n \n \n p\n \n \n \n \n e\n \n \n 2\n \n \n \n \n \n \n \alpha \n \n \n \n \n e\n \n \n 2\n \n \n ,\n 1\n \n \n \n, i.e. the probability of observing a transition *s*_{1}on edge *e*_{2}.

### The transformation problem

With the construction of \left(\right)close="">\n \n \n \n \Sigma \n \n \n T\n \n \n \n we have generated the tools needed to formally describe the computations in Step 4 of the Misfits algorithm [4]. Given a rooted tree \left(\right)close="">\n \n T\n \n and two characters *f* and *f*^{d} in \left(\right)close="">\n \n \n \n C\n \n \n n\n \n \n \n, we want to compute the minimal number of substitutions required on the tree to convert *f* into *f*^{d}. [4] presented an efficient procedure to compute this minimal number of substitutions.

### Algorithm 1

**INPUT:** rooted binary phylogenetic tree \left(\right)close="">\n \n T\n \n on leaf set *X*, characters *f* and *f*^{d}on *X*, Abelian group *Σ*.

**STEP 1:** Using Remark 1, find the substitution type *σ*_{
i
}which translates *f*_{
j
}into \left(\right)close="">\n \n \n \n f\n \n \n j\n \n \n d\n \n \n \n for all positions *j*=1,…,|*X*|. Let *σ*∈*Σ*^{n}be the resulting operation, i.e. *σ*(*f*)=*f*^{d}.

**STEP 2:** Let *c*:=*c*_{1}…*c*_{1}be a constant character on *X* with \left(\right)close="">\n \n \n \n c\n \n \n 1\n \n \n \u2208\n C\n \n. Let *h*:=*σ*(*c*).

**STEP 3:** Calculate \left(\right)close="">\n \n m\n :\n =\n \n \n l\n \n \n T\n \n \n (\n h\n )\n \n.

**OUTPUT:** *m*.

We prove the correctness of our algorithm. In our framework, *m* corresponds to the minimum number of permutations *σ*_{1},…,*σ*_{
m
}∈*Σ* such that *σ*_{1}⊗⋯⊗*σ*_{
m
}(*f*)=*f*^{d}. In this form, *m* has multiple equivalent interpretations. It is the length of the shortest path between *f* and *f*^{d} in the Cayley graph for \left(\right)close="">\n \n \n \n \Sigma \n \n \n T\n \n \n \n, where this path corresponds to *σ*_{1}⊗⋯⊗*σ*_{
m
}. Further, *m* corresponds to the minimum power (*k*) of \left(\right)close="">\n \n \n \n M\n \n \n T\n \n \n \n such that \left(\right)close="">\n \n \n \n M\n \n \n T\n \n \n j\n \n \n (\n f\n ,\n \n \n f\n \n \n d\n \n \n )\n =\n 0\n \n for *j*<*k* and \left(\right)close="">\n \n \n \n M\n \n \n T\n \n \n k\n \n \n (\n f\n ,\n \n \n f\n \n \n d\n \n \n )\n \n 0\n \n, because a positive entry in \left(\right)close="">\n \n \n \n M\n \n \n T\n \n \n k\n \n \n \n means that there is a concatenation of *k* permutations connecting the associated characters.

**Example 3.** *Figure*2*demonstrates how Algorithm 4 works under the K3ST model, i.e. when the group is* *Σ* = *Σ*_{
K3ST
} (*Figure*2a). *Consider the rooted five-taxon tree in Figure*2b*and the character GTAGA at the leaves. Assume that the character GTAGA is to be converted into character ACCTC. By comparing the two characters position-wise, we need a substitution* *s*_{1}*on the external branch leading to taxon 1 to convert G into A at the first position. Similarly, we need a substitution* *s*_{1}*on the external branch leading to taxon 2, and a substitution* *s*_{2}*on every external branch leading to taxa 3, 4, and 5. Thus, the operation* *s*:=(*s*_{1}*s*_{1}*s*_{2}*s*_{2}*s*_{2}) *transfers the character GTAGA into the character ACCTC. As the operation s also translates the constant character AAAAA into GGCCC, converting GTAGA into ACCTC is equivalent to evolving the character state A at the root along the tree to obtain the character GGCCC at the leaves. The Fitch algorithm*[7]*applied to the character GGCCC with the constraint that the character state at the root is A produces a unique most parsimonious solution of two substitutions as depicted by Figure*2c.