Defining Phylogenetic Network Distances Using Cherry Operations

In phylogenetic networks, picking a cherry consists of removing a leaf that shares a parent with another leaf, or removing a reticulate edge whose endpoints are parents of leaves. Cherry-picking operations were recently shown to have several structural and algorithmic applications in the study of networks, for instance in determining their reconstructibility or in solving the network hybridization and network containment problems. In particular, some networks within certain classes are isomorphic if they can be reduced to a single node by the same sequence of cherry-picking operations. Therefore, cherry-picking sequences contain information on the level of similarity between two networks. In this paper, we expand on this idea by devising four novel distances on networks based on cherry picking and their reverse operation. We provide bounds between these distances and show that three of them are equal despite their different formulations. We also show that computing these three equivalent distances is NP-hard, even when restricted to comparing a tree and a network. On the positive side, we show that they can be computed in quadratic time on two trees, providing a new comparative measure for phylogenetic trees that can be computed efficiently.


INTRODUCTION
B IOLOGY research has long been concerned with establishing evolutionary relationships between species. The first illustrations that were drawn of these relationships took the form of "trees of life" [1], [2], [3]. Today this work is mostly accomplished in the realm of bioinformatics and is based on the analysis of genomic sequences instead of physical traits to produce these phylogenies. Phylogenomics has been mainly focused on constructing trees since those early days, but these types of graphs are only able to represent vertical relationships, in the direction of ancestor to descendant. Hybridization events, such as the ones created by cross-pollination or crossbreeding in plants [4], [5], and horizontal gene transfer events, which are more common in prokaryotes [6], [7] but are believed to be occurring in eukaryotes as well [8], [9], are best represented by phylogenetic networks instead. Furthermore, the recombination of viruses is well-known and network-like [10]. Phylogenetic networks introduce the concept of reticulations [11], which allow internal nodes to have multiple parents, and thus represent the transfer of information from other species than the direct ancestor. With recent research focusing more on these evolutionary relationships, phylogenetic networks are gaining more traction as a better way of illustrating links between species.
Since errors in the phylogenetic construction pipeline, missing data, the use of different datasets or different construction methods/models can result in incompatible evolutionary relationships [12], distance methods allowing to compare phylogenies are necessary to measure differences between them. Distance calculations can also be used to evaluate the performance of a new construction approach (by comparing a phylogeny produced by a new tool with a state-of-the-art manually curated one) and to evaluate the differences between a gene tree and a species tree. In the context of phylogenetic trees, the Robinson-Foulds distance [13] is by far the most widely used metric, mostly because of its simplicity and ease of calculation. Cardona et al. presented in 2008 a generalization of the Robinson-Foulds distance that is computed in polynomial time for tree-child time-consistent networks [14]. This distance is based on calculating the symmetric difference between the sets of all clusters (a cluster is the set of leaves descendant of a node) corresponding to the two compared networks. Lu et al. [15] developed a fast exponential-time algorithm for computing the soft Robinson-Foulds distance between phylogenetic networks, which compares soft clusters between networks, i.e., clusters that appear in each of the trees represented by the network.
Finding new ways to characterize phylogenetic trees and networks can also lead to new distance definitions. In 2013, Humphries et al. [16] presented a new type of characterization for phylogenetic trees named cherry-picking sequences, which was later reformulated in 2019 by co-authors Linz and Semple [17]. Essentially, a cherry-picking move corresponds to the removal of a leaf that is part of a cherry (i.e., two sibling leaves connected to the same parent), and a cherry-picking sequence (CPS) represents a series of cherry-picking moves that can reduce a phylogenetic tree to a single leaf. These sequences were initially defined to help characterize the hybridization number for a set of phylogenies, i.e., the minimum number of reticulations required to build a network that represents all the phylogenies. Since the introduction of cherry-picking sequences, they have also been used to solve other problems, such as the network hybridization problem [18] and the network containment problem [19], [20]. Interestingly, it was shown in [19] that defining an ordering on the cherry-picking sequences allows to find a unique smallest CPS to represent a reconstructible cherry-picking network (i.e., a network that can be reduced by a CPS and reconstructed by the same CPS). Moreover, it follows that two cherry-picking networks within the same reconstructible class are isomorphic if and only if they have the same smallest CPS [19]. Since cherry-picking operations can be used to decide whether two cherry-picking networks are identical, one may ask whether they can also be used to infer a level of similarity or dissimilarity between two networks. This fact is what motivated us to explore how distances between phylogenetic trees and networks could be defined using the concept of cherry-picking sequences.
In this paper, we begin by presenting several different distances between cherry-picking networks based on cherrypicking sequences. We first propose novel operational distances based on the minimum number of cherry operations required to transform one network into the other, or that are required to make the networks reach a common substructure. We also introduce the tail distance, which is based on the structure of the networks' CPSs and asks for a CPS on each network that maximizes a common suffix. We show that three of our proposed distances are equivalent, but that they are NPhard to compute even when comparing a network and a tree. On the positive side, we show that these distances can be computed in polynomial time when comparing two trees, providing a novel measure between phylogenetic trees. To develop our NP-hardness reductions, we also introduce the CP-SUB-TREE problem, which asks whether a tree can be obtained from a network by applying cherry-picking operations, and prove that it is NP-hard. This problem may be of independent interest since it represents a new form of tree containment, a widely studied problem in the area of phylogenetic networks.

Network Definitions
Given a directed graph D ¼ ðV; EÞ, we write d þ ðvÞ and d À ðvÞ for the number of out-neighbors and in-neighbors, respectively, of a node v 2 V . We may write V ðDÞ and EðDÞ to refer to the vertices and edges of D, respectively. A phylogenetic X-network, N ¼ ðV; E; XÞ, is a rooted acyclic directed graph where the leaves are bijectively labeled by a set of taxa X. We refer to the leaves of N as LðN Þ and assume that d þ ðlÞ ¼ 0 and d À ðlÞ ¼ 1 for each l 2 LðN Þ. For simplicity, a phylogenetic X-network is referred to hereafter as a network, with the understanding that X ¼ LðN Þ. Edges are directed towards the leaves LðN Þ from the root rðN Þ, which is the unique node with d À ðrðN ÞÞ ¼ 0 and d þ ðrðN ÞÞ ! 2. An internal node v 2 V n LðN Þ is a tree node when d À ðvÞ ¼ 1 and d þ ðvÞ ! 2, and v is a reticulation node when d À ðvÞ ! 2 and d þ ðvÞ ¼ 1. We write T ðN Þ and RðN Þ for the set of tree nodes and reticulation nodes, respectively. Unless otherwise stated, we assume that trees and networks are binary, that is, for a tree or network N , d þ ðrðN ÞÞ ¼ 2, d þ ðvÞ ¼ 2 for all v 2 T ðN Þ, and d À ðvÞ ¼ 2 for all v 2 RðN Þ. It may be that jV ðN Þj ¼ jLðN Þj ¼ 1, in which case, we call N a single-leaf network which has no root (frðN Þg ¼ ;). For a network N, For an edge ðu; vÞ 2 EðN Þ with v 2 T ðN Þ [ LðN Þ, we say that u is the parent of v and v is a child of u, denoted pðvÞ ¼ u. Generally, if there is a path from u to v, then u is an ancestor of v and v is a descendant of u. A node v is unary if d À ðvÞ ¼ d þ ðvÞ ¼ 1. Suppressing a unary node consists of adding an edge from pðvÞ to the child of v, and removing v with its incident edges. We write N ' N 0 if N and N 0 are isomorphic networks, with preservation of the leaf labels.

Cherry Operations
In phylogenetic trees, a cherry usually refers to two leaves that have the same parent. In networks, the authors of [19] proposed to distinguish two types of cherries. Let x; y be two distinct leaves of a network N . We say that ðx; yÞ is a nonreticulated cherry if pðxÞ ¼ pðyÞ. Note that in this case, ðy; xÞ refers to the same cherry, although the order will be relevant later on. Analogously, we say that ðx; yÞ is a reticulated cherry if pðxÞ 2 RðN Þ and ðpðyÞ; pðxÞÞ 2 E. Note that in this case, pðyÞ = 2 RðN Þ and ðy; xÞ is not a cherry. We let C c ðN Þ and C r ðN Þ denote the set of non-reticulated and reticulated cherries of a network N , respectively, and denote CðN Þ ¼ C c ðN Þ [ C r ðN Þ.
A sequence of cherries S ¼ hðx 1 ; y 1 Þ; . . . ; ðx n ; y n Þi is called a cherry sequence (CS) and is used to define a series of cherry operations. The reverse of S is denoted revðSÞ ¼ hðx n ; y n Þ; . . . ; ðx 1 ; y 1 Þi. The concatenation of two CSs S 1 and S 2 is denoted S 1 Á S 2 . CSs have hitherto in the literature been referred to as a cherry-picking sequence (CPS), but here we prefer a more general term, since CSs will refer to either network reduction operations, or network expansion operations.

Cherry Reduction
A cherry reduction, or cherry picking, is a cherry operation that modifies a network by deleting a cherry of either type. To be more specific, let N be a network. Then a cherry reduction on N of ðx; yÞ consists of one of the following, depending on the cherry type of ðx; yÞ: If ðx; yÞ 2 C c ðN Þ, then remove x and its incident edge from N . If pðxÞ is not the root of N , then suppress pðxÞ. If pðxÞ is the root of N , then remove pðxÞ and its incident edge. If ðx; yÞ 2 C r ðN Þ, then remove the edge ðpðyÞ; pðxÞÞ and suppress the two resulting unary nodes. If ðx; yÞ = 2 CðN Þ, then the cherry reduction of ðx; yÞ has no effect on N . Such a reduction will be called trivial, and non-trivial otherwise. Fig. 1 illustrates both cases of non-trivial cherry reductions (from ðaÞ to ðbÞ and from ðbÞ to ðcÞ). For a CS S, N hSi denotes the network that results from reducing the network N by the cherries of S in order. Assume that a cherrysequence S reduces N to a single-leaf network. Then noting that every cherry reduction removes two vertices and binary networks always have an odd number of vertices. Not every network can be reduced to a single-leaf network by a CS of cherry reductions, since there exist networks with no cherry. A network that can be reduced to a single-leaf network by a sequence of cherry reductions is called a cherry-picking network (CPN) or orchard.
See Fig. 2 for an example of a network that has two reticulations that are exclusive siblings, so is not an orchard. From here on all networks referred to are assumed to be an orchard unless otherwise specified.

Cherry Expansion
A cherry expansion is an operation that adds a cherry leaf or a reticulation. More precisely, let N be a network. Then the cherry expansion on N of ðx; yÞ consists of the following, depending on its type: 2 LðN Þ and y 2 LðN Þ, then check if pðyÞ exists. If so, subdivide the edge ðpðyÞ; yÞ creating the new node u to which the new leaf x is to be attached by a new edge ðu; xÞ. If pðyÞ does not exist, then N is a single leaf network. In this case, create a new root with children x and y. If x; y 2 LðN Þ, subdivide the edge ðpðyÞ; yÞ creating a node u, and subdivide the edge ðpðxÞ; xÞ creating a node v. Then insert the new edge ðu; vÞ so that v becomes a reticulation. If y = 2 LðN Þ then ðx; yÞ for any x 2 LðN Þ or x = 2 LðN Þ, has no effect on N . Such an expansion will be called trivial, and non-trivial otherwise. For a CS S, we denote by N hSi the network obtained by applying each cherry expansion in S in order (the overline notation emphasizes that the pairs in S must be interpreted as expansions rather than reductions). So for a network N and a CS S of cherry expansions jV ðN hSiÞj jV ðN Þj þ 2jSj Figs. 1d to 1g demonstrates both non-trivial cherry expansions.
The cherry expansion is the reverse operation to a cherry reduction, where the class of binary CPNs have been described by Janssen and Murakami as being a reconstructible class [19]. There are two corollaries to this feature important to our purposes. First, for a network N with a cherry c 2 CðN Þ, N hcihci ' N holds, which we refer to as the reversability of cherry-picking. Second, from any single-leaf network N where LðN Þ ¼ fxg, every binary CPN containing x can be reached from N by some sequence of cherry expansions.
We will refer to a CS of cherry reductions as a reducing CS, and refer to a CS of cherry expansions as an expanding CS. It might sometimes be desirable for a CS to contain both types of operations, with the overline and no-overline notation being used on a cherry-by-cherry basis to indicate the intended operation. We call a CS of this kind a mixed CS.

Complete Cherry Sequences and Cherry-Picking Subnetworks
For the remainder, we will assume that cherry operations in a CS S always affect the network and that S contains no trivial operation. Let S i denote the sequence with the i first elements of S and let ðx; yÞ be the ði þ 1Þ-th element of S. If ðx; yÞ is a cherry reduction, we assume that ðx; yÞ 2 CðN hS i iÞ, and if ðx; yÞ is a cherry expansion, we assume y 2 LðN hS i iÞ. In this way, equations 1 and 2 are always equalities. If S satisfies the above property, then S is called minimal. If a reducing CS S is minimal and reduces a network N to a single-leaf network, then we say S is complete for N . It is worth noting that a complete CS can always be found for a CPN. It is also known that applying a cherry reduction on a CPN results in another CPN [19,Observation 1].
CSs with non-trivial entries can be used to determine whether two networks are isomorphic. The next general-purpose result is analogous to Lemma 12 in [19], a result proving that the complete reduction of a binary network by the complete reducing CS for another network implies the former is a subnetwork of the latter. In the case where the complete reducing CS for both networks is the same, the lemma implies isomorphism between the networks by showing set equality, each input being a subnetwork of the other. Lemma 1. Let N 1 and N 2 be two networks with at least two leaves, and assume that there is a CS S that is complete for both N 1 and N 2 . Then N 1 ' N 2 .
Proof. We prove the statement by induction on jSj. As a base case, assume that jSj ¼ 1. Then S ¼ ððx; yÞÞ for some x; y and, since N 1 hSi and N 2 hSi are both single-leaf networks and ðx; yÞ is non-trivial, it must be that N 1 and N 2 both consist of a tree with two leaves x and y. Hence N 1 ' N 2 .
For the induction step, suppose that jSj ! 2. Let ðx; yÞ be the first element of S and let S 0 be obtained from S by removing ðx; yÞ (so that S ¼ hðx; yÞi Á S 0 ). Let N 0  complete for both N 0 1 and N 0 2 since it reduces them to a single-leaf network and does not contain trivial reductions (as otherwise, S would contain trivial reductions). Thus by induction, N 0 1 ' N 0 2 . Now consider the ðx; yÞ reduction. First assume that ðx; yÞ 2 C c ðN 1 Þ. Then x is removed from N 1 when ðx; yÞ is applied to N 1 . Since N 0 1 ' N 0 2 , x cannot be a leaf of N 0 2 , and since ðx; yÞ is non-trivial with respect to N 2 , it must be that x is removed from N 2 by the ðx; yÞ reduction. That is, ðx; yÞ 2 C c ðN 2 Þ as well. It follows that N 1 ' N 2 because both networks are obtained from N 0 1 and N 0 2 by adding the x leaf back on the branch from y to its parent.
Assume instead that ðx; yÞ 2 C r ðx; yÞ. Then when applied on N 1 , ðx; yÞ removes ðpðyÞ; pðxÞÞ from N 1 and thus x 2 LðN 0 1 Þ. Therefore, because N 0 1 ' N 0 2 , applying ðx; yÞ cannot remove x from LðN 2 Þ and, since ðx; yÞ is non-trivial with respect to N 2 , it must be that ðx; yÞ 2 C r ðN 2 Þ as well. It follows that N 1 ' N 2 because both networks are obtained from N 0 1 and N 0 2 by adding an edge from the branch above y to the branch above x. t u We finish this section by introducing cherry-picking subnetworks, which is the cherry-picking analogous notion of the well-studied agreement subtrees (see [21]) and agreement subnetworks (see [22]). Given two networks N and N 0 , we say that N 0 is a cherry-picking subnetwork of N if there exists a reducing CS S such that N hSi ' N 0 . If this is the case, we will write N 0 cp N . An agreement cherry-picking subnetwork (ACPS) of two networks N 1 and N 2 is a network N 0 satisfying N 0 cp N 1 and N 0 cp N 2 . The maximum agreement cherry-picking subnetwork (MACPS) for networks N 1 and N 2 is an ACPS that maximizes the total number of vertices. As we shall see, MACPS are closely related to cherry-picking distances, but it is NP-hard to decide whether N 1 cp N 2 .

Definitions
This section introduces new network distances based on cherry operations and CSs. Hereafter, we assume that N 1 and N 2 are cherry-picking networks, not necessarily on the same set of leaves. We do assume however that LðN 1 Þ \ LðN 2 Þ 6 ¼ ;, as otherwise all distances are 1. Similarly, if one of N 1 or N 2 is not a cherry-picking network, then all the distances are defined to be 1.
1) The Mixed distance, d m ðN 1 ; N 2 Þ, for networks N 1 and N 2 , is the length of a minimum mixed CS that transforms network N 1 into N 2 when its cherry operations are applied in order.
2) The Construction distance, d c ðN 1 ; N 2 Þ, for networks N 1 and N 2 , is the minimum combined length of a reducing CS S À and an expanding CS S þ where N 1 reaches N 2 when reduced by S À then expanded by S þ . In other words, d c ðN 1 ; N 2 Þ is the minimum of jS À j þ jS þ j over all CS pairs S À and S þ satisfying 4) The Tail distance, d t ðN 1 ; N 2 Þ, for networks N 1 and N 2 , is the minimum combined length of reducing CSs S 1 and S 2 that can both be concatenated with a common CS S to produce complete CSs for N 1 and N 2 . In other words, d t ðN 1 ; N 2 Þ is the minimum of jS 1 j þ jS 2 j over all pairs of complete CSs S 1 Á S and S 2 Á S for N 1 and N 2 , respectively. Intuitively speaking, d m minimizes the number of operations required to turn N 1 into N 2 , whereas d c requires first applying reductions, followed by expansions. On the other hand, d d minimizes the number of reductions required on both networks to reach a common subnetwork and d t focuses on finding complete sequences with the maximum number of common operations in the suffix.
In the rest of this section, we show how each of these distances are related. Particularly, we show that d c ; d d and d t are equal, but not always equal to d m .
Proof. If d c ðN 1 ; N 2 Þ ¼ 1, there is nothing to prove, so assume otherwise. Let S À and S þ be CSs satisfying To further elaborate on the finding of Theorem 1, Fig. 3 shows that d m ðN 1 ; N 2 Þ < d c ðN 1 ; N 2 Þ is possible. As illustrated, the difference between these distances can be arbitrarily large, so d c can hardly be used to approximate d m .
Theorem 2. For any networks N 1 and N 2 , d c ðN 1 ; Proof. For the first direction we show that d d ðN 1 ; N 2 Þ d c ðN 1 ; N 2 Þ. Let S À be a reducing CS and S þ be an expanding CS that minimize jS À j þ jS þ j such that N 1 hS À ihS þ i ' N 2 . Thus d c ðN 1 ; N 2 Þ ¼ jS À j þ jS þ j. By the reversibility of cherry picking For the second direction we show that d c ðN 1 ; N 2 Þ d d ðN 1 ; N 2 Þ. Let S 1 and S 2 be reducing CSs that minimize jS 1 j þ jS 2 j such that Since S 1 and S 2 are complete, we know that S reduces N 1 hS 0 1 i and N 2 hS 0 2 i to a single-leaf network and does not contain trivial entries. By Lemma 1, (which is a CPN and is isomorphic to N 2 hS 2 i) and let S be a complete reducing CS for N Ã . Then N 1 hS 1 Á Si is a single-leaf network and N 1 hS 2 Á Si is also a single-leaf network. Since S is a common suffix, it follows that It has now been shown that, for networks N 1 and N 2 , d t ðN 1 ; N 2 Þ, d d ðN 1 ; N 2 Þ, and d c ðN 1 ; N 2 Þ are equivalent and bounded from below by d m ðN 1 ; N 2 Þ. We finish this section by establishing a relationship between these distances and agreement cherry-picking subnetworks.
Proof. Let S 1 and S 2 be reducing CSs such that We show that equality holds. Assume for contradiction . Assume without loss of generality that jS 0 1 j < jS 1 j. Then N 1 hS 0 1 i has strictly more vertices than N Ã ¼ N 1 hS 1 i since fewer vertices need to be removed. This contradicts the fact that N Ã is a MACPS. Therefore,

Properties of Tail and Mixed Distances
The tail and mixed distance satisfy two conditions of a metric. The first is identity, isomorphic networks have a tail and a mixed distance of 0. The second is symmetry, proved by reversibility of cherry picking. The third condition of a metric, the triangle inequality, does not apply to the tail distance, as demonstrated by counterexample in Fig. 3. What we see in this example is that, for the tail distance, N 2 serves as a "shortcut" between N 1 and N 3 that simulates a mixed distance, which is shorter than the tail distance in some cases. It follows that the tail distance is not a metric.
As for the mixed distance, the triangle inequality is indeed satisfied, making the mixed distance a metric. Take any N 1 , N 2 , N 3 such that LðN 1 Þ \ LðN 2 Þ \ LðN 3 Þ 6 ¼ ; and find mixed cherry sequences S 12 corresponding to a mixed distance d m ðN 1 ; N 2 Þ, and S 23 corresponding to d m ðN 2 ; N 3 Þ. Since the order of cherry expansions and reductions can occur in any order, the concatenation S 12 Á S 23 is a valid mixed cherry sequence that will transform N 1 to N 3 and whose length is at most d m ðN 1 ; N 3 Þ by definition.
The diameter of the tail distance can be determined by finding the lower bound on the size of an MACPS between the any two input networks then it is not hard to show that there are networks for which the MACPS has only two leaves (e.g., caterpillars with reversed order of leaves). Conversely, we can show that any MACPS contains at least two leaves, i.e. at least a cherry remains. Although this can easily be shown to hold on trees, this is surprisingly difficult to prove on networks.
The following arguments requires a new definition of a leaf subset on a network N ¼ ðV; E; XÞ, in relation to a reducing CS S. For any leaf x 2 X and a CS S ¼ ðS 1 ; . . . ; S k Þ, we define the set subsumeðx; SÞ. Roughly speaking, when we delete a leaf y while it was in a cherry with x, subsumeðx; SÞ remembers that it "ate" y and all those that y ate before. To put this formally, if jSj ¼ 0, define subsumeðx; SÞ ¼ fxg for all x 2 X. If jSj > 0, let S 0 ¼ ðS 1 ; . . . ; S kÀ1 Þ. If S k is a reticulated cherry in N , then subsumeðx; SÞ ¼ subsumeðx; S 0 Þ for all x 2 X. If S k ¼ ðy; xÞ is non-reticulated, then subsume ðx; SÞ ¼ subsumeðx; S 0 Þ [ subsumeðy; S 0 Þ, and subsumeðz; SÞ ¼ subsumeðz; S 0 Þ for all z 2 X n fxg.
Proof. The proof is by induction on the number of entries in S. In the base case, we have jSj ¼ 0. By definition, every l 2 X has subsumeðl; SÞ ¼ flg, and the lemma holds.
Then, in the inductive step, assume that S contains k þ 1 elements and that the lemma holds for any CS of length k. Let S 0 be the CS (of length k) obtained by removing the last entry of S.
Then the ðk þ 1Þ-th entry of S, cherry ðy; xÞ, falls under two possibilities. In the first, ðy; xÞ is a reticulated cherry in which case no changes are made to the subsume sets and the lemma holds. In the second case, we have that LðAÞg where A is an unspecified but equal subnetwork in all networks. The construction distance d c ðN 1 ; N 3 Þ can be determined by cherry sequence S 13 ¼ ðc; bÞS A ðb; aÞðd; aÞðc; aÞðb; aÞS 0 A ðd; aÞ where S A , S 0 A reduces and expands respectively the subnetwork A (and would include one leaf outside of the subnetwork A to fully reduce/expand the subnetwork), and where all reductions come before all expansions. The mixed distance d m ðN 1 ; N 2 Þ can be determined by mixed cherry sequence S 12 ¼ ðc; bÞðc; dÞ and ðy; xÞ is a non-reticulated cherry. Note that y is not in N hSi and that each subsumeðz; SÞ ¼ subsumeðz; S 0 Þ, except that we have subsumeðx; SÞ ¼ subsumeðx; S 0 Þ [ subsumeðy; S 0 Þ. By induction, no two subsumeðw; S 0 Þ and subsumeðz; S 0 Þ sets intersect. This clearly still holds for subsumeðw; SÞ and subsumeðz; SÞ if w; z 6 ¼ x. If, say, w ¼ x, then by induction, subsumeðz; S 0 Þ did not intersect either subsumeðx; S 0 Þ nor subsumeðy; S 0 Þ, so it still does not intersect subsumeðx; SÞ. Thus the intersection property holds.
As for the union property, it suffices to observe that from N hS 0 i to N hSi, we removed y but subsumeðy; S 0 Þ is added to subsumeðx; SÞ, with every other subsume set remaining unchanged. It follows that X ¼ S Proof. This proof will proceed by induction on the length of the sequence S. In the base case, jSj ¼ 0. In this case, x 0 2 subsumeðx; SÞ without any reduction, therefore x 0 ¼ x and the claim holds.
In the inductive step, assume the claim holds for all jSj k, and let there be S such that jSj ¼ k þ 1. Consider the state of the network reduced by all but the ðk þ 1Þ-th, entry in S, let S inclusive up to the k-th entry be called S k . Then, there are two cases to consider. In the first case x 0 2 subsumeðx; S k Þ and the conditions of the inductive hypothesis implies there exists S 0 , jS 0 j ¼ k, such that x 0 has replaced x. Take that S 0 and, if the ðk þ 1Þ-th entry of S refers to the leaf x in the form of ðl; xÞ for some l, append ðl; x 0 Þ to S 0 , jS 0 j ¼ k þ 1 and the claim holds. The last entry of S will not be ðx; lÞ because x 2 LðN hSiÞ.
In the second case x 0 = 2 subsumeðx; S k Þ. Since we know x 0 2 subsumeðx; SÞ, it must be that the ðk þ 1Þ-th entry of S is the cherry ðx 0 ; xÞ. Take S k as S 0 and append the cherry ðx; x 0 Þ such that jS 0 j ¼ k þ 1 and the claim holds. t u Theorem 5. For any two orchard networks N 1 ¼ ðV 1 ; E 1 ; X 1 Þ and N 2 ¼ ðV 2 ; E 2 ; X 2 Þ such that jV 1 j; jV 2 j ! 3 and X 1 ¼ X 2 , the maximum tail distance between them is d t ðN 1 ; Proof. Proving that the MACPSðN 1 ; N 2 Þ has a minimum of three nodes (a cherry network with two leaves and one root), then by referring to Theorem 4 the theorem is proved. Consider reducing N 1 by some reducing CS S 1 such that N 1 hS 1 i results in a non-reticulated cherry of leaves a and x with resulting sets subsumeða; S 1 Þ and subsumeðx; S 1 Þ. We may assume that such a CS exists, as otherwise N 1 is not an orchard.
The leaf a could be replaced by any a 0 2 subsumeða; S 1 Þ by Lemma 3, and since the two sets subsumeða; S 1 Þ and subsumeðx; S 1 Þ don't intersect (by Lemma 2), the same is true of x and any x 0 2 subsumeðx; S 1 Þ. We want to argue that MACPSðN 1 ; N 2 Þ is not a singleton, i.e. has at least three vertices. If the MACPSðN 1 ; N 2 Þ were indeed a singleton, then every CS reducing N 2 to a non-reticulated cherry would remove all of subsumeða; S 1 Þ or all of subsumeðx; S 1 Þ.
Towards a contradiction, let S 2 be a CS such that N 2 hS 2 i is a non-reticulated cherry (again, such a CS exists if we assume that N 2 is an orchard), and assume that, w.l.o.g., all members of subsumeða; S 1 Þ are removed by S 2 . Then, the two leaves of N 2 hS 2 i are in subsumeðx; S 1 Þ. Moreover, there must be some leaf x 0 of N 2 hS 2 i such that subsumeðx 0 ; S 2 Þ contains a (this is because of Lemma 2, which states that the subsume sets of N 2 hS 2 i form a partition of X). Then by Lemma 3, there is an alternate CS S 0 2 that replaces x 0 by a. The resulting network N 2 hS 0 2 i has a leaf from subsumeða; S 1 Þ, namely a, and a leaf from subsumeðx; S 1 Þ, because N 2 hS 2 i is a non-singleton. This contradicts our initial assumption. t u

COMPUTING THE TAIL DISTANCE BETWEEN TWO TREES
In this section, we show that computing d t ðT 1 ; T 2 Þ between two trees T 1 and T 2 can be done in polynomial time, even if LðT 1 Þ 6 ¼ LðT 2 Þ. This is achieved by showing that computing d t is equivalent to finding a special type of maximum agreement subtree, which can be found in time OðjV ðT 1 ÞjjV ðT 2 ÞjÞ using dynamic programming. This polynomial time solvability does not extend as we later show the problem to be NP-hard for a network-tree comparison.
A tree is a network with no reticulations. Let T be a tree. For x; y 2 LðT Þ, lca T ðx; yÞ is the lowest common ancestor of x and y, which is well-defined. Let S LðT Þ. By T jS, we denote the smallest connected subgraph of T that contains each leaf in S. Note that T jS may contain unary nodes. By T jjS, we denote the tree obtained from T jS after suppressing unary nodes.
Focusing on a certain restriction, for non-empty S LðT Þ, we say that T jjS is a leaf-restricted subtree of T if either jSj ¼ 1, or if both of the following hold: 1) there exist x; y 2 S such that lca T ðx; yÞ ¼ rðT Þ; 2) if v is a unary node of T jS, then every descendant of v in T jS is either a unary node or a leaf. We write T 0 lr T if T 0 is isomorphic to T jjLðT 0 Þ and if T jjLðT 0 Þ is a leaf-restricted subtree of T . Roughly speaking, unless jLðT 0 Þj ¼ 1, to have T 0 lr T , Condition 1 requires rðT Þ to be part of T 0 , and Condition 2 requires that all removed subtrees to have the parent of their root to lead only to unary nodes and a leaf (see Fig. 4). Note that the name "leaf-restricted" subtree was chosen to illustrate that all the unary nodes that remain after pruning are restricted to have a single leaf as a descendant. This lets us establish the connection with cherry reductions.
Given two phylogenetic trees T 1 and T 2 , a leaf-restricted agreement subtree between T 1 and T 2 is a tree T Ã such that both T Ã lr T 1 and T Ã lr T 2 hold. A leaf-restricted maximum agreement subtree, or LR-MAST for short, is a leaf-restricted agreement subtree with the maximum number of leaves. Note that since an LR-MAST T Ã is a tree, jV ðT Ã Þj ¼ 2jLðT Ã Þj À 1, so maximizing the number of vertices is the same as maximizing the number of leaves.
We first prove the transitivity of the lr relationship.
Lemma 4. If T 1 lr T 2 and T 2 lr T 3 , then T 1 lr T 3 .
Proof. For the duration of the proof, denote L 1 ¼ First notice that by the conditions of the lemma, L 1 L 2 L 3 . Since T 2 is isomorphic to T 3 jjL 2 , it is not hard to see that for any X L 2 , T 2 jjX is isomorphic to T 3 jjX. In particular, T 2 jjL 1 is isomorphic to T 3 jjL 1 , which in turn is isomorphic to T 1 (because T 1 lr T 2 , and thus T 1 ' T 2 jjL 1 ). It only remains to show that T 3 jjL 1 satisfies both conditions of leafrestricted subtrees. If jL 1 j ¼ 1, then this is trivially the case, so suppose that jL 1 j ! 2. Since T 2 jjL 1 is a leaf-restricted subtree of T 2 , there must be x; y 2 L 1 such that lca T 2 ðx; yÞ ¼ rðT 2 Þ. In a similar vein, since T 2 lr T 3 , there are x 0 ; y 0 2 L 2 such that lca T 3 ðx 0 ; y 0 Þ ¼ rðT 3 Þ. Moreover, because T 2 is isomorphic to T 3 jjL 2 , lca T 2 ðx 0 ; y 0 Þ ¼ rðT 2 Þ must hold. The fact that lca T 2 ðx; yÞ ¼ lca T 2 ðx 0 ; y 0 Þ then implies that lca T 3 ðx; yÞ ¼ rðT 3 Þ, and so T 3 jjL 1 satisfies Condition 1. Now assume that T 3 jjL 1 does not satisfy Condition 2. That is, there is a unary node v in T 3 jL 1 that has a descendant w with two children. Let v be the deepest node of T 3 jL 1 with this property. Then we may assume that v is the parent of w in T 3 jL 1 (and thus in T 3 ). Let a; b be leaves of T 3 jL 1 such that lca T 3 jL 1 ða; bÞ ¼ w.
Since L 1 L 2 , a; b; w and v are all in T 3 jL 2 . However, v is not unary in T 3 jL 2 because T 2 lr T 3 . Therefore, there exists d 2 L 2 such that lca T 3 ðd; aÞ ¼ v. Let w 0 ¼ lca T 2 ða; bÞ and v 0 ¼ lca T 2 ðd; aÞ. Since T 2 is isomorphic to T 3 jjL 2 and v is the parent of w in T 3 , v 0 is the parent of w 0 in T 2 . But then, v 0 must be unary in T 2 jL 1 , since otherwise, there would exist d 0 2 L 1 such that lca T 2 jL 1 ðd 0 ; aÞ is the parent of lca T 2 jL 1 ða; bÞ in T 2 jL 1 . If this was the case, v would not be unary in T 3 jL 1 . Also, w 0 is not unary in T 2 jL 1 since a; b 2 L 1 . The existence of w 0 and v 0 contradict T 1 lr T 2 . We deduce that T 3 jjL 1 satisfies Condition 2, and therefore that T 1 lr T 3 . t u We can now connect lr with cherry sequences, as it turns out to be equivalent to the cp relationship. Proof. We first note that if T 0 has only one node, it consists of a leaf of T . In that case, T 0 lr T holds, and one can easily find C such that T hCi ¼ T 0 . Thus we assume that T 0 , and thus T , has more than one leaf, and prove the two directions of the lemma separately.
()) : We first show that if T 0 lr T , then T 0 ¼ T hCi for some cherry sequence C. We prove the statement by induction over the quantity k :¼ jLðT Þj À jLðT 0 Þj. As a base case, assume that k ¼ 0. Then T 0 is isomorphic to T and the empty reducing CS proves this case. Now, consider the inductive step with k > 0. For convenience, denote S ¼ LðT 0 Þ, noting that T 0 is isomorphic to T jjS. Assume that in T , there is a cherry c ¼ ðx; yÞ such that x = 2 S. Because T hci is obtained by deleting x and suppressing pðxÞ, it is not hard to see that T jjS is isomorphic to T hcijjS, and thus that T 0 lr T hci. Furthermore, we have jLðT hciÞj À jLðT 0 Þj ¼ k À 1, and we know by induction that there is a reducing CS transforming T hci into T 0 , hence a cherry reduction from T to T 0 .
So suppose that no cherry c as described above exists. That is, for every cherry ðx; yÞ of T , both x; y 2 S. We know that S 6 ¼ LðT Þ since k > 0, so there exists some leaf x 2 V ðT Þ n S. By our assumption, x cannot belong to a cherry of T , and so the child w of pðxÞ other than x must be an internal node of T . Thus, there is a cherry ðy; zÞ in T that belongs to the subtree induced by w and its descendants. By our assumption, y; z 2 S, and it follows that the parent w 0 of y and z in T must be in T jS. But then, by the first condition of leaf-restricted subtrees, rðT Þ must be in T jS. Moreover, pðxÞ must be in T jS since it lies on the path between the root and w 0 . However, pðxÞ has only one child in T jS since x = 2 S, and pðxÞ has descendant w 0 with two children in T jS. This contradicts the second condition of the definition of T 0 lr T , and so this case does not occur. We deduce that there does exist a CS from T to T 0 .
(() : We now show that if there exists a CS C ¼ ðc 1 ; . . . ; c k Þ such that T 0 ' T hCi, then T hCi lr T . In fact, by Lemma 4, it suffices to show that if T 0 is obtained from T after applying one cherry reduction, then T 0 lr T . The statement will follow, since if T i denotes the i-th tree after applying the i-th cherry reduction of C, this shows that T k lr T kÀ1 lr . . . lr T 1 lr T , and then T k lr T by transitivity (Lemma 4).
Therefore, assume that T 0 ¼ T hci for some cherry c ¼ ðx; yÞ. Then from T to T 0 , we remove x and suppress its parent pðxÞ. Defining S ¼ LðT Þ n fxg, it is then easy to see that T hci ¼ T jjS. Moreover, x could not be a child of the root since otherwise, c would not be a cherry (recall that jLðT 0 Þj > 1). This implies that rðT Þ is in T jjS, satisfying Condition 1. Moreover, only pðxÞ can be unary in T jS and Condition 2 is satisfied since pðxÞ has two children leaves. Therefore, T hci lr T , as desired.
t u Next, we show that d t can be computed easily if an LR-MAST T Ã is known. Proof. Let us denote n 1 :¼ jV ðT 1 Þj; n 2 ¼ jV ðT 2 Þj and n Ã ¼ jV ðT Ã Þj. Let C 1 ¼ ða 1 ; . . . ; a k Þ and C 2 ¼ ðb 1 ; . . . ; b h Þ be reducing CSs to apply on T 1 and T 2 , respectively, so that T 1 hC 1 i and T 2 hC 2 i are isomorphic, and such that k þ h is minimum among all possibilities. By Theorem 3, we know that d t ðT 1 ; T 2 Þ ¼ k þ h. Furthermore, by Lemma 5, we know that T 1 hC 1 i lr T and T 2 hC 2 i lr T , and thus T 1 hC 1 i is a leaf-restricted agreement subtree of T 1 and T 2 . Denoten ¼ jV ðT 1 hC 1 iÞj (which is equal to jV ðT 2 hC 2 iÞj). Notice thatn n Ã because T Ã maximizes the number of nodes among all leaf-restricted agreement subtrees. Also note that each cherry reduction removes two nodes, namely a leaf and its parent. Therefore, T 1 hC 1 i has n 1 À 2k nodes and T 2 hC 2 i has n 2 À 2h nodes, i.e.n ¼ n 1 À 2k ¼ n 2 À 2h. Isolating k and h, it follows that This proves the first bound of the proof. Consider now the complementary bound. By Lemma 5, since T Ã lr T 1 and T Ã lr T 2 , there is a reducing CS C 1 from T 1 to T Ã , and another reducing CS C 2 from T 2 to T Ã . Because a cherry reduction removes two nodes, C 1 must contain ðn 1 À n Ã Þ=2 elements, and C 2 must contain ðn 2 À n Ã Þ=2 elements. Since T 1 hC 1 i and T 2 hC 2 i are isomorphic, it follows that d t ðT 1 ; T 2 Þ ðn 1 À n Ã Þ=2 þ ðn 2 À n Ã Þ=2 ¼ ðn 1 þ n 2 Þ=2 À n Ã . This concludes the proof. t u

Computing an LR-MAST
Because maximizing jV ðT Ã Þj is equivalent to maximizing jLðT Ã Þj, Theorem 6 shows that, on trees, computing d t ðT 1 ; T 2 Þ is equivalent to computing an LR-MAST. This can be achieved using a dynamic programming procedure, described below, which leads to the following. For a tree T and v 2 V ðT Þ, T ½v denotes the subtree induced by v and all of its descendants. We may write LðvÞ instead of LðT ½vÞ.
For u 2 V ðT 1 Þ and v 2 V ðT 2 Þ, M½u; v denotes the number of leaves in an LR-MAST between T 1 ½u and T 2 ½v. The idea is to take an LR-MAST on both sides of u and v and combine them into a larger LR-MAST, when possible. This is similar to the classical MAST algorithm, but with less cases to check because of the additional restrictions. We now describe the recurrence for M.
Internal Node Case. Assume that u and v are both internal nodes. Let u 1 ; u 2 be the children of u, and v 1 ; v 2 be the children of v. We compute two temporary values M 1 ½u; v and M 2 ½u; v, and take the maximum of the two. More precisely, apply the recurrence definition in Fig. 5.
Roughly speaking, M 1 corresponds to mapping u 1 to v 1 and u 2 to v 2 , and M 2 corresponds to mapping u 1 to v 2 and u 2 to v 1 . We now show that these recurrences are correct. Proof. We proceed by induction over the height of the trees T 1 ½u and T 2 ½v. As a base case, assume that one of u or v is a leaf, say u without loss of generality. If LðuÞ \ LðvÞ 6 ¼ ;, then u 2 LðvÞ and the tree consisting of only u is an LR-MAST, hence M½u; v ¼ 1. Otherwise, there is no leaf in common, there cannot exist an LR-MAST, and M½u; v ¼ 0 is correct. Now assume that u and v are internal nodes. Let T Ã be an LR-MAST between T 1 ½u and T 2 ½v, and let S be such that T Ã is isomorphic to T 1 ½ujjS and T 2 ½vjjS. First assume that S ¼ ;, i.e. T Ã has no node. Then it must be that LðuÞ \ LðvÞ ¼ ;. If follows that Lðu i Þ \ Lðv j Þ ¼ ; for all i; j 2 1; 2, in which case the recurrence specifies M 1 ½u; v ¼ M 2 ½u; v ¼ 0. Thus M½u; v ¼ 0 will be correctly set.
Assume that (1) holds. Then Lðu 1 Þ \ Lðv 1 Þ 6 ¼ ; and Lðu 2 Þ \ Lðv 2 Þ 6 ¼ ;, so the M 1 ½u; v entry will be set by the fourth case in the recurrence. We now argue that T 1 ½u 1 jjU 1 is a leaf-restricted agreement subtree of T 1 ½u 1 . If jU 1 j ¼ 1, this trivially holds, so assume jU 1 j ! 2. We prove that both conditions of leaf-restricted subtrees hold: Condition 1. If there are no a; b 2 U 1 such that lca T 1 ½u 1 ða; bÞ ¼ u 1 , then all members of U 1 are below one child of u 1 . This means that in T 1 ½ujjS, u 1 is unary, but has a descendant of degree 2 since jU 1 j ! 2, a contradiction to the fact that T 1 ½ujjS is a leaf-restricted subtree. Thus Condition 1 holds for T 1 ½u 1 jjU 1 . Condition 2. There cannot be a unary node w with a binary descendant in T 1 ½u 1 jjU 1 , as otherwise w would also be unary in T 1 ½ujjU 1 and would also have a binary descendant. It follows that T 1 ½u 1 jjU 1 is a leaf-restricted subtree of T 1 ½u 1 . By the same reasoning, T 2 ½v 1 jjV 1 is a leaf-restricted subtree of T 2 ½v 1 . And since T 1 ½u 1 jjU 1 and T 2 ½v 1 jjV 1 are isomorphic, they are both leaf-restricted agreement subtrees of T 1 ½v 1 and T 2 ½v 2 . By symmetry, T 1 ½u 2 jjU 2 is a leaf-restricted agreement subtree of T 1 ½u 2 and T 2 ½v 2 .
It is clear that T 0 is isomorphic to T 1 ½ujjðA [ BÞ and to T 2 ½vjjðA [ BÞ. Thus it suffices to show that T 0 satisfies the conditions of leaf-restricted subtrees. Since T A and T B are non-empty, T 0 contains a leaf from both sides of u and v and Condition 1 of leaf-restricted subtrees is satisfied. Consider Condition 2. All the nodes of T 0 have the same number of children as in T A or T B , except the root of T 0 which is not present in either tree. This root has two children, so we could not have created a new unary node with a binary descendant. Therefore Condition 2 is also satisfied.
We deduce that T 0 is a leaf-restricted agreement subtree of T 1 ½u and T 2 ½v, and thus jLðT 0 Þj jLðT Ã Þj. We therefore have The case M 2 ½u; v ! M 1 ½u; v can be handled in the same manner by symmetry.
t u The value of interest here is M½rðT 1 Þ; rðT 2 Þ. It can be obtained by calculating M½u; v for each u 2 V ðT 1 Þ and each v 2 V ðT 2 Þ in a bottom-up fashion. Since each calculation of each M½u; v entry can be done in time Oð1Þ, assuming the values of the descendants of u and v have been computed and stored, the total time required to fill M is OðjV ðT 1 Þjj V ðT 2 ÞjÞ.

NP-HARDNESS OF D T BETWEEN A TREE AND A NETWORK
We show that computing d t ðT; NÞ between a tree T and a network N is NP-hard, holding even when LðT Þ & LðNÞ. In fact, we show something stronger, that deciding whether T cp N is NP-hard. This directly implies computing d t is NP-hard.
The CP-SUBTREE problem. Input: a tree T and a network N such that LðT Þ LðNÞ. Question: is T cp N? Roughly speaking, the hardness of CP-SUBTREE implies the hardness of computing d t since, given a network N and a tree T , the smallest d t one can hope for is jV ðNÞ À V ðT Þj=2. This is because we need to at least make N and T have the same number of vertices, and each cherry reduction affects two vertices. Furthermore, we can attain this distance if and only if T cp N, establishing the equivalence between the two problems. Now we show the CP-SUBTREE is NP-hard with a reduction from the 3-SAT-3-OCC problem, known to be NP-hard (see [23] and [24,Problem 1]). This version of 3-SAT gives sets of clauses, each of which contains either 2 or 3 literals related by logical or denoted _. Each literal occurs exactly three times, twice positively and once negatively (a literal is a boolean variable x i or its negation x i ). Examples of clauses are The goal is to decide if an assignment of the x i variables exists satisfying every clause.
Let f be a 3-SAT-3-OCC instance, with n variables x 1 ; . . . ; x n and m clauses C 1 ; . . . ; C m . We construct a corresponding tree T and network N. Let T be any tree with 2m leaves and m cherries, each cherry representing a clause C i . Name the cherry's leaves that correspond to C i by c i and c 0 i . Obtain a network N by starting at T , then replacing each leaf c i by a substructure as in Fig. 6.
More precisely, from T , replace each leaf c i as follows, depending on the number of literals of clause C i (we will specify how the A j i vertices are connected to the B j i vertices later): If C i has 2 literals, replace leaf c i by a tree with 2 leaves A 1 i ; A 2 i . Add vertices B 1 i ; B 2 i and leaves a i ; b i ; g i ; c i as in the middle substructure in Fig. 6.
If C i has 3 literals, replace leaf c i by a tree with 3 leaves A 1 i ; A 2 i ; A 3 i . Add vertices B 1 i ; B 2 i ; B 3 i and leaves a i ; b i ; g i ; d i ; c i as in the left or right substructure in Fig. 6. Conceptually, A 1 i ; B 1 i represent the first literal that can satisfy clause C i , A 2 i ; B 2 i represent the second literal and A 3 i ; B 3 i the third literal (if present). We can now specify the connections between the A j i 's and B j i 's. Consider a variable x h and recall that it has two positive occurrences and one negative. Assume that x h occurs positively in clauses C i and C j and negatively in clause C k . Then there are two pairs of vertices A a i ; B a i and A b j ; B b j representing the positive occurrences x h , and one pair of vertices A c k ; B c k representing the negative occurrence x h , with a; b; c 2 f1; 2; 3g. Add vertices and edges between these vertices as in Fig. 7, thereby creating two new leaves p a i and p c k . We will refer to the subgraph illustrated in Fig. 7 as the x h gadget. We construct this gadget for each variable x h . After this, since each A a i ; B a i pair represents a distinct literal, each A a i node has exactly two children and each B a i node has exactly one parent. This concludes the construction. The main intuition is that we need to get rid of dummy leaves to turn N into T . To achieve this, each c i leaf will need to be "brought up" to its c 0 i sibling by eliminating the substructures of N. We must thus choose a path for each c i , either through A 1 i ; A 2 i or A 3 i (if present). Such a choice will correspond to choosing a literal to satisfy each C i , and the x h gadgets prevent us from choosing two paths/literals that are contradictory.
Theorem 9. The CP-SUBTREE problem is NP-hard.
Proof. Let f be an instance of 3-SAT-3-OCC. Let T and N be constructed as described above. For the remainder of the proof, a leaf in LðNÞ n LðT Þ will be called a dummy leaf.
We show that f is satisfiable if and only if there exists a cherry sequence C such that NhCi is isomorphic to T . ð)Þ : suppose that f is satisfiable by some assignment Q of the x i variables. We show that there is a cherry sequence that transforms N into T . Consider a clause C i . Then Q satisfies the j-th literal of C i for some j 2 f1; 2; 3g. If there are multiple choices for j, choose one arbitrarily. Depending on j, apply one of the cherry sequences appearing in Fig. 8. The figure assumes a clause C i with three literals. If C i has two literals, then d i and B 3 i do not exist, c i is a sibling of g i and we have j 2 f1; 2g. For such a clause, the cases for j ¼ 1 or j ¼ 2 can be applied as in Fig. 8, ignoring the first ðc i ; d i Þ move.
As a result, for each i 2 f1; . . . ; mg, B j i becomes replaced by c i when Q satisfies the j-th literal of C i . Moreover, each B j 0 i ; j 0 6 ¼ j, has been replaced by a dummy leaf.
Next, consider a variable x h . Assume that x h occurs positively in clauses C i and C j and negatively in clause C k . After applying the above cherry sequence for each clause, the x h gadget has three leaves that have replaced the B a i ; B b j and B c k vertices. From this point, we distinguish three possible cases: (1) none of c i ; c j or c k is a leaf of the x h gadget; (2) c i and/or c j is a leaf of the x h gadget. In this case, c k cannot be a leaf of the x h gadget, since this would imply that assignment Q assigns x h positively and negatively. Indeed, in our described sequence B a i gets replaced by c i when x h ¼ true satisfies clause C i , whereas B c k gets Fig. 6. The main structure of T and N obtained from an instance with three clauses C 1 ; C 2 ; C 3 . Here, N is obtained from T by replacing each leaf c i by a substructure. In this example, C 1 and C 3 have 3 literals whereas C 2 has 2 literals. Not shown: children of the A j i vertices and parents of the B i j vertices, which make the connections between clauses and variables. Fig. 8. The three possible ways to handle leaf c i , depending on whether we satisfy clause C i with its first, second or third literal, respectively corresponding to j ¼ 1; j ¼ 2 and j ¼ 3. The colors on the nodes are there to emphasize which node receives c i as a child after the cherry reduction sequence. The handling of cases (2) and (3) is shown in Fig. 9, top and bottom respectively.
The handling of Case 1 can be performed as in Case 2, except that c i and c j are dummy leaves instead. The same applies in Case 2 when one of c i or c j is not present.
After applying this to every x h gadget, each A j i node of N is replaced by either c i or some dummy leaf. Importantly, notice that in all cases, every c i leaf ends up replacing an A j i node, j 2 f1; 2; 3g, and not some A j k leaf with k 6 ¼ i. In other words, N has become a tree such that for every i 2 f1; . . . ; mg, each of A 1 i ; A 2 i , and A 3 i if present, has become a leaf, one of which is c i (and the others are dummy leaves). It follows that at this point, N has become a tree identical to T but with extra dummy leaves. It is then easy to see that these can be removed by cherry reduction moves to obtain T . Indeed, for each clause C i , if C i has two variables, A 1 i ; A 2 i are replaced by leaves that form a cherry containing c i and a dummy leaf. We simply pick the dummy leaf and make c i ; c 0 i siblings. If C i has three variables, A 1 i ; A 2 i are replaced by leaves that form a cherry. At least one of these leaves is a dummy, so we pick it. After that, we are left with a cherry with the leaf that contains A 3 i and again, we pick whichever is not c i , making c i and c 0 i siblings.. Therefore, T cp N.
ð(Þ : suppose that there exists a cherry sequence C that transforms N into T . We build a satisfying assignment Q for f. The assignment is constructed by adding literals to Q -our goal is to add one literal per clause, without adding two contradictory literals x h and x h . Consider a c i leaf of N, and let L i be the literals that can satisfy clause C i . If C i has 2 literals, let L i ¼ f' 1 ; ' 2 g, and if C i has 3 literals, let L i ¼ f' 1 ; ' 2 ; ' 3 g. Let X be the first cherry reduction move of C that contains c i (which must exist since otherwise, c i would remain the child of a reticulation). We consider all possible cases.
1) If C i has 2 literals, then c i is a sibling of g i . In that case, go to Case 3 below. 2) If C i has 3 literals, then either X ¼ ðc In this case, notice that the next cherry-picking affecting c i must delete d i , and that B 3 i gets replaced by c i . If instead X ¼ ðc i ; d i Þ, then c i becomes a sibling of g i . Then go to Case 3 below.
3) If c i is a sibling of g i , notice that the next cherrypicking affecting c i must delete g i . After g i is deleted, consider the next cherry-picking X 0 that contains c i . Whether C i has 2 or 3 variables, it must be that either In this case, notice that the next cherry-picking of C affecting c i must delete b i , and that B 2 i gets replaced by c i . If X 0 ¼ ðc i ; b i Þ, then add ' 1 to Q. In this case, notice that the next cherry-picking of C affecting c i must delete a i , and that B 1 i gets replaced by c i . It follows that in all cases, we add a literal ' j to Q satisfying C i . Thus Q satisfies all the clauses of f. It remains to show that we have not added two contradictory literals x h and x h .
Let us assume that we did add both x h and x h . Assume that x h occurs positively in clauses C i and C j and negatively in clause C k . Let A a i ; B a i and A b j ; B b j correspond to the occurrences of x h , and A c k ; B c k correspond to x h . By our construction of Q, we know that x h was added to Q because c k ended up replacing B c k . Moreover, since x h was added to Q, then c i replaced B a i or c j replaced B b j (or both). Now, notice that the next cherry reduction affecting c k must be with the leaf that eventually replaces B b j , by the construction of the x h gadget. Therefore, c j cannot end up replacing B b j , since otherwise the cherry sequence C would have to remove one of c j or c k , preventing it from transforming N into T . Therefore, we may assume that x h was added to Q because c i ended up replacing B a i . This situation is illustrated in Fig. 10. The reader may bear in mind that the situation shown on top of Fig. 10 is not entirely general, since we do not know when exactly c i replaces B a i and when c k replaces B c k . That is, c i might replace B a i first, and then more cherry-operations might affect c i before c j replaces B c k , and hence the exact network on top of Fig. 10 might not be reached. Nonetheless, our arguments hold only under the assumption that eventually, c i replaces B a i and eventually, c k replaces B c k . Note that i ; j ; k are used to denote dummy leaves. Also, on top, one of c i or c j could be a dummy leaf. Fig. 10. The x h gadget when C i gets satisfied by x h and C k by x h .
We argue that after c i replaces B a i , ðc i ; p a i Þ cannot be in the cherry sequence C. If this were the case, ðc i ; p a i Þ would remove the edge from A a i leading to c i , and the parent of c 0 j would be on the path between the (unique) lowest ancestor of c i and c 0 i . At this point, to make c i and c 0 i siblings using cherry-picking, we would eventually reach a situation where c i and c 0 j are siblings. We cannot delete either, making it impossible to reach T . Therefore, we can never remove the unique edge incident to A a i that leads to c i . By a similar argument, because we know that c k replaces B c k eventually, we can never remove the unique edge from A c k that leads to c k . It follows that at some point, we must reach the situation in Fig. 10 at the bottom. But then, the only two possible moves that involve one of c i or c k are ðc i ; p a i Þ and ðc k ; p c k Þ. As we argued, both of these prevent us from reaching T , which is a contradiction.
We conclude that we could not have added two contradictory literals in Q, and thus f is satisfiable.
t u Theorem 10. The problem of deciding whether d t ðT; NÞ k for given network N, tree T and integer k is NP-hard.
Proof. We show that there is a polynomial-time reduction from CP-SUBTREE to the problem of computing d t . Let N; T be an instance of CP-SUBTREE. Our instance of computing d t is also N; T , and we put k ¼ jV ðNÞ À V ðT Þj=2.
We show that T cp N if and only if d t ðN; T Þ ¼ jV ðNÞÀV ðT Þj 2 . ()) : Assume T cp N. First, note that the tail distance is equivalent to the deconstruction distance by Theorem 3.
This direction is easy to see in light of Theorem 4. The assumption T cp N implies that T is a MACPS of N and T . This is because T is the largest possible agreement subnetwork of T and N that can be reached by cherry picking. It follows from Theorem 4 that . Let S T be a complete CS for T , and let CS S N be a complete CS for N. Say S T and S N have a maximum common ending subsequence S, so that d t ðN; T Þ ¼ jS N j þ jS T j À 2jSj Substituting the given value of k for d t ðN; T Þ we get jV ðNÞj À jV ðT Þj 2 ¼ jS N j þ jS T j À 2jSj We also know from equation 1 the length of a complete CS, so we substitute for the value of S N .
jV ðNÞj 2 À jV ðT Þj 2 ¼ jV ðNÞj 2 À 1 2 þ jS T j À 2jSj 2jSj ¼ jS T j þ jV ðT Þj 2 À 1 2 It happens to be that the last two terms on the right hand side express the length of a complete reducing CS for T . Thus we have 2jSj ¼ jS T j þ jS T j jSj ¼ jS T j and S is a complete reducing sequence for T . If we write S N ¼ S 0 Á S, NhS 0 i yields a network for which S is a complete CS. By Lemma 1, NhS 0 i is isomorphic to T , implying that T cp N.
t u Corollary 1. The problem of computing the distances d t ; d c or d d on two given networks is NP-hard.
By slightly adapting the argument of the last result, we can also show that computing the mixed distance is hard. ()) : Assume that T cp N. Then by definition, there exists a CS S that contains only cherry-reductions such that NhSi ¼ T . Notice that each elements of S removes exactly two nodes of the network. It follows that jSj ¼ jV ðNÞjÀjV ðT Þj 2 ¼ k. Moreover, since the mixed cherry distance allows cherry-reduction operations, we obtain d m ðN; T Þ k.
(() : Suppose that d m ðN; T Þ k. Let S be a mixed CS of at most k operations that can transform N into T . It is not hard to see that S contains only cherry-reductions. Indeed, let r be the number of cherry-reductions in S (which each decrease the number of vertices by 2) and let " be the number of cherry-expansions in S (which each increase the number of vertices by 2). Observe that jSj ¼ r þ " k. In particular, r À " k À 2". Then the number of nodes in NhSi is jV ðNÞj À 2r þ 2" ¼ jV ðT Þj (the latter because NhSi ¼ T ). Therefore, k ¼ jV ðNÞj À jV ðT Þj 2 ¼ r À " k À 2" If " > 0, this yields a contradiction. We deduce that there is no cherry-expansion in S. Therefore, S transforms into T using only cherry-reductions, and therefore T cp N. t u

DISCUSSION AND FUTURE WORK
These novel distances have certain advantages and disadvantages, we can also reflect on their algorithmic complexity, and also on their context in network classes. In terms of accuracy, one immediately obvious feature of these distances is that they have a "bottom bias". That is, disagreements in the networks closer to the leaves are easier to access with cherry operations than those disagreements closer to the root. A specific result of this bias is that the tail distance won't penalize misplaced leaves near other leaves. However, differences in the networks have a gradually increasing cost with the further the occurrence is from a cherry.
In this work we have only provided a single algorithm for the case of the inputs being two trees. In fact, a naive algorithm to calculate these distances on networks may run in exponential time. Future work in engineering an algorithm for calculating these distances will consider the possibility of approximation, heuristics, and parameterization of the problem on a variable other than the input size, such as the resulting distance.
Then there is the question of the context of network classes. Our findings rely on the results from Janssen and Murakami on reconstructible network classes, four of which are defined. Here we looked at the reconstructible class of binary CPNs, which begs the question of whether our results apply to the other three reconstructible classes. If we want to extend our work to general networks, this would require some assurance that the network can be reduced to a single leaf. It has been shown by Linz and Semple that attaching new (non-X) leaves can transform any network into a CPN [17]. Extending cherry operation-based distances to general networks may require a leaf-attaching operation.