Compositional Properties of Alignments

Alignments, i.e., position-wise comparisons of two or more strings or ordered lists are of utmost practical importance in computational biology and a host of other fields, including historical linguistics and emerging areas of research in the Digital Humanities. The problem is well-known to be computationally hard as soon as the number of input strings is not bounded. Due to its practical importance, a huge number of heuristics have been devised, which have proved very successful in a wide range of applications. Alignments nevertheless have received hardly any attention as formal, mathematical structures. Here, we focus on the compositional aspects of alignments, which underlie most algorithmic approaches to computing alignments. We also show that the concepts naturally generalize to finite partially ordered sets and partial maps between them that in some sense preserve the partial orders. As a consequence of this discussion we observe that alignments of even more general structure, in particular graphs, are essentially characterized by the fact that the restriction of alignments to a row must coincide with the corresponding input graphs. Pairwise alignments of graphs are therefore determined completely by common induced subgraphs. In this setting alignments of alignments are well-defined, and alignments can be decomposed recursively into subalignments. This provides a general framework within which different classes of alignment algorithms can be explored for objects very different from sequences and other totally ordered data structures.

underlie most algorithmic approaches to computing alignments. We also show that the concepts naturally generalize to finite partially ordered sets and partial maps between them that in some sense preserve the partial orders. As a consequence of this discussion we observe that alignments of even more general structure, in particular graphs, are essentially characterized by the fact that the restriction of alignments to a row must coincide with the corresponding input graphs. Pairwise alignments of graphs are therefore determined completely by common induced subgraphs. In this setting alignments of alignments are well-defined, and alignments can be decomposed recursively into subalignments. This provides a general framework within which different classes of alignment algorithms can be explored for objects very different from sequences and other totally ordered data structures.
Keywords Multiple sequence alignment · Tree alignment · Subgraph isomorphism · Partial order · Projection

Introduction
Alignments play an important role in particular in bioinformatics as a means of comparing two or more strings by explicitly identifying correspondences between letters (usually called matches and mismatches) as well as insertions and deletions [13]. The aligned positions are interpreted either as deriving from a common ancestor ("homologous") or to be functionally equivalent. Alignments have also been explored as means of comparing words in natural languages, see e.g. [6,10,37,57], as a convenient way of comparing ranked lists [19], for comparison of text editions [59,63], and to analyse synteny in the comparison of genomes [24,60].
Alignment problems are usually phrased as optimization problems. Most commonly a scoring model is defined for pairs of sequences and generalized to multiple alignments as sums over certain pairwise alignments that are obtained as projections. The pairwise scoring is usually specified either in terms of matches or in terms of edit operations (insertions, deletions, or substitutions). In this contribution, however, we will almost completely disregard the scoring of alignments and instead focus on the structure of (multiple) alignments as combinatorial objects. Our aim here is not to construct concrete alignment algorithms but the systematic generalization of alignments from strings to more general discrete objects.
Alignments are usually constructed from strings or other totally ordered inputs, hence the columns of the resulting alignment are usually also treated as a totally ordered set. Consecutive insertions and deletions, however, are not naturally ordered relative to each other: gugugu--acgggcca guguguac--gggcca gucuguug--gggccc gucugu--uggggccc (1) are alignments that are equivalent under most plausible scoring models. The idea to consider alignment columns as partial orders was explored systematically in [41] and a series of follow-up publications [25,40]. Here, (mis)matches are considered as an ordered backbone, with no direct ordering constraints between an insertion and a deletion. The resulting alignments are then represented as directed acyclic graphs (DAGs), more precisely, as the Hasse diagrams of the partial order. The key idea behind the POA software [41] is that a sequence of DAGs can be used as an input to a modified version of the Needleman-Wunsch algorithm [49]. Recently this idea has been generalized to the problem of aligning a sequence to a general directed graph [33,52]. Despite the immense practical importance of alignments, they have received very little attention as mathematical structures in the past. The most comprehensive treatment, at least to our knowledge, is the Technical Report [48], which considers (pairwise) alignments as binary relations between sequence positions that represent matchings and preserve order. Here, we will make use of many of these ideas and show how they can be extended to a notion of alignments on partially ordered sets. We shall see that such a generalization still supports the recursive construction that underlies the exact dynamic programming algorithms employed to compute score-optimal alignments in the totally ordered case. Following our earlier work [51], we will use a language that is closer to graph theory than the presentation of [47,48]. The notion of a composition of pairwise alignments-formalized as composition of partial maps that represent the matching-first appears in [43], see also Sect. 5. In the next two sections, we first review the sequence alignment problem and introduce a formal framework that separates the structure of multiple alignments from their scoring. In the following sections, we explore the consequence of relaxing some of the axioms to cover partial orders in general. Then we explore the compositional properties. Our main concerns are to ensure that alignments of alignments are well-defined as a foundation for progressive alignment procedures, and that decompositions into blocks exist that can form the basis of divide-and-conquer approaches to aligning partially ordered sets. Following a brief discussion of the view of alignments as compositions of pairwise matching relations, we further generalize the formalism to include first ordered trees, then directed and undirected graphs, and finally essentially arbitrary finite spaces that admit well-behaved subspace constructions. We shall conclude that alignments are alternatively specified in terms by common induced subgraphs (or the corresponding common induced subspaces in full generality).

A Very Brief Review of Sequence Alignments
The literature on alignments is extensive. However, it is concerned almost exclusively with practical algorithms and applications. The alignment problem for two input strings has an elegant recursive solution for rather general cost models and has served as one of the early paradigmatic examples of dynamic programming [49,55]. Since these algorithms have only quadratic space and time requirements for simple cost models [22,49], they are of key importance in practical applications. The same recursive structure easily generalizes to alignments of more than two sequences [9,42] even though the cost models need to be more restrictive to guarantee polynomial-time algorithms [35]. The computational effort for these exact solutions to the alignment problem increases exponentially with the number of sequences, hence only implementations for 3-way [23,36,38] and 4-way alignments [57] have gained practical importance. A wide variety of multiple sequence alignment problems (for arbitrary numbers of input sequences) have been shown to be NP-hard [7,17,31,34,61] and MAX SNP-hard [44,62]. The construction of practical multiple alignment algorithms therefore relies on heuristic approximations, see e.g. [3,14] for reviews: (1) Progressive methods typically compute all pairwise alignments and then use a "guide tree" to determine the order in which these are stepwisely combined into a multiple alignment of all input sequences. The classical example is ClustalW [39]. The approach can be extended to starting from exact 3-way [36,38] or 4-way alignments [57]. (2) Iterative methods start by aligning small gapless subsequences and then extend and improve the alignment iteratively until the score converges. The iterative approach is often used as a refinement step in combination with other basic methods. (3) Consistency-based alignments and consensus methods start from a collection of partial alignments (often exact pairwise alignments) to obtain candidate matches and extract a multiple alignment using agreements between the input alignments. A paradigmatic example for the combination of consistency-based alignments and the iterative approach is DIALIGN [46] using additionally local motifs as anchors.
Most of the successful multiple alignment algorithms in computational biology combine these paradigms. For example T-COFFEE [50] and ProbCons [11] use consistency ideas in combination with progressive constructions; MUSCLE [15] and MAFFT [32] combine progressive alignments with iterative refinements.
A key assumption underlying consistency based methods is transitivity: considering three input sequences x, y, and z, if x i aligns with y j and y j aligns with z k , then x i should also align with z k . While this property holds for the pairwise constituents of a multiple alignment, it is a well known fact that the three score-optimal alignments that can be constructed from three sequences in general violate transitivity, see Fig. 1. TRANSALIGN [43] uses transitivity to align input sequences to a target database using an intermediary database of sequences to increase the search space. Here, intermediary sequences show which subsequences of input and target sequence can be transitively aligned. This may result in a few well aligned subsequences that are then extended to one aligned region via a simple scoring function. The same notion of transitivity is also used in psiblast [2] to stepwisely increase the set of sequences that are faintly similar to an input sequence.
In practical applications one is interested in alignments that optimize some scoring function, which typically depends on the matches, mismatches, and gaps (see Fig. 1), as well as a the actual letters in an alignment column. In this contribution, however, we are only interested in the structure of the alignments themselves. Their scoring will play no role here. Practical applications also distinguish whether the complete input sequences are to be aligned, or whether a maximally scoring interval is to be considered. In the latter case one allows an additional "unaligned state" for prefixes and/or suffixes of the input. This leads to slight changes in exact algorithms, exemplified by an extra term in the local Smith-Waterman algorithm [56] compared to the global Needleman-Wunsch [49] algorithm. This idea can be generalized to mixed problems in which a user can determine for each of the two ends of each input sequence whether it is to be treated as local or global [54]. Here, we will discuss only global alignments since all forms of local alignments amount to global alignments of substrings.

Formal Definitions of Sequence Alignments
Suppose we are given a set S of |S| ≥ 1 sequences with not necessarily equal length. For s ∈ S we write s i for the i-th position in s, and |s| denotes the length of s, i.e., the number of positions. The most common representation of an alignment is a rectangular matrix whose rows are indexed by the sequences and whose columns are indexed by integers i ∈ [1, L], where L is the number of alignment columns. Each sequence is then associated with a strictly monotonically increasing function α s : [1, |s|] → [1, L] such that for each i ∈ [1, |s|], α s (i) is the index of the column containing s i . The alignment matrix contains a gap symbol in row s and column k whenever α −1 s (k) = ∅, otherwise, the matrix element is s α −1 s (k) . Consider the following simple example: We have α A (i) = i for 1 ≤ i ≤ 13, α B (i) = i for 1 ≤ i ≤ 9, and α C (i) = i + 4 for 1 ≤ i ≤ 9. For the 10th column of the example we have α −1 a (10) = 10, α −1 b (10) = ∅, α −1 c (10) = 6; hence the entries in the 10th column are a α −1 a (10) = a 10 = 0, − because α −1 b (10) = ∅, and c α −1 c (10) = c 6 = 0. It will be convenient in the discussion below to also consider single sequences as (trivial) alignments, using the identity on [1, |s|].
The actual values of the sequence elements, i.e., the s i are of course important to determine the scoring. For our purposes, however, they are irrelevant, since we will only be interested in the structure of the alignments. It therefore suffices to consider the set X s := [1, |s|] of sequence positions for each input sequence and their arrangement in the alignment columns. This information is completely contained in the functions α s . We can therefore "forget" about almost all the details about the sequence s except its length, which by construction satisfies |X s | = |s|. From here on, we can therefore treat s simply as an index used solely to enumerate the elements of S. We will use the symbol • to indicate that a particular cell in the alignment matrix is occupied, while − indicates gaps. The • eventually will become vertices in a graph representation.
For our purposes the set of sequence positions X s is simply a finite ordered set. To emphasize this fact, and to make generalizations below more transparent, we write (X s , < s ) to explicitly expose the order relation on X s . For a given set of sequences, furthermore, we will need the set of all sequence positions defined as the disjoint union X := · s∈S X s of all sequence positions, sometimes called the site set of the alignment. A simple way to define an alignment is to consider an alignment as a s × L matrix such that to each entry either an element of the sets X s of sequence positions or a gap symbol − is assigned. Formally, we handle this by defining an alignment map as follows: Definition 1 (Alignment Map) Let X = · s∈S X s and |L| ≥ max s |X s |. An alignment map is a function ω : The alignment map ω plays the role of a (slightly modified) inverse of α since ω s (α( j)) = j for j ∈ X s and s ∈ S. The alignment map ω and the site set X = · s∈S X s thus completely determine the alignment. The image ω(k) corresponds to the k-th alignment column. We note in passing that alignment maps exist if and only if L ≥ max s |X s |. It is customary, furthermore, to exclude alignment columns that consist entirely of gap symbols: Definition 2 (Proper Alignment) An alignment with site set X = · s∈S X s and alignment map ω is proper if there is no k such that ω s (k) = − for all s ∈ S.
Given the alignment, we can use the alignment map to construct a graph representation.

Definition 3 (Alignment Graph)
The alignment graph (X, A) of an alignment with site set X = · s∈S X s and alignment map ω has vertex set X and edge set A such that x y ∈ A if there is k ∈ [1, L] and there are distinct sequences s ∈ S and t ∈ S such that ω s (k) = x and ω t (k) = y.
In other words, positions x and y are joined by an edge if and only if x and y appear in the same column of the alignment.

Lemma 4
Let (X, A) be the alignment graph of an alignment with site set X = · s∈S X s and alignment map ω. Suppose x ∈ X r , y ∈ X s , and z ∈ X t and both x y and x z are edges in the alignment graph. Then (i) r , s, and t are pairwise distinct.
(ii) yz is also an edge in the alignment graph.
Proof Property (i) follows immediately from the requirement that α s is strictly monotonically increasing, i.e., any two positions of the same sequence are mapped to distinct alignment columns. Property (ii) follows directly from the definition. If x y and xz are edges, then x, y, and z are located in the same alignment column and thus yz is an edge of the alignment graph.
The alignment graph therefore is the disjoint union of complete graphs such that every connected component (which is a clique) contains at most one element of each of the input sequences X s . Every clique thus corresponds to an alignment column. We write C(X, A) for the set of alignment columns, which for convenience we identify with their vertex sets. More precisely, Q ∈ C(X, A) is an alignment column if and only if there are x ∈ Q, k ∈ [1, L], and s ∈ S such that x = ω s (k) = −. In particular, for each s ∈ S we have either Q ∩ X s = ∅ or Q ∩ X s = {ω s (k)} for some k. The alignment graph is consistent with the input orders < s on X s , s ∈ S in the following sense: Lemma 5 Let Q and Q be two distinct connected components of the alignment graph (X, A) of an alignment with site set X = · s∈S X s and alignment map ω and suppose there are sequences s, t ∈ S such that x s ∈ Q ∩ X s , y s ∈ Q ∩ X s , x t ∈ Q ∩ X t , and y t ∈ Q ∩ X t . Then x s < s y s if and only if x t < t y t .
Proof By Lemma 4, two vertices x s and x t are in the same connected component Q if and only if they are in the same column, i.e., if α(x s ) = α(x t ) =: k . Analogously, α(y s ) = α(y t ) =: k . By monotonicity of α s and α t , we therefore have x s < s y s if and only if k < k , which in turn is true if and only if x t < t y t .
In particular, we may conclude: Observation 1 Let C(X, A) be the set of columns of the alignment graph (X, A) of an alignment with site set X = · s∈S X s and alignment map ω. Then there exists an order on C(X, A) such that, for all Q , Q ∈ C(X, A), Q < A Q implies x < s y whenever x ∈ Q ∩ X s and y ∈ Q ∩ X s .
Proof By construction, the alignment columns are ordered. Lemma 5 implies that this order is consistent with the order < s of each X s .
In the following it will be convenient to write each element of X as a pair that explicitly specifies the input sequence from which it derives. That is, we write (a, i) ∈ X for i ∈ X a and a ∈ S. The simple observations of this section suggest to redefine an alignment by means of an alignment graph with a suitable order of the columns. The following definition rephrases the approach taken e.g. in [47,48,58] in a form that will be most convenient for further generalizations: Definition 6 (Total Alignment [51]) A total alignment of a finite collection of finite totally ordered sets (X s , < s ), s ∈ S, is a triple (X, A, <) where X := · s∈S X s , (X, A) is an undirected, loop-free graph with vertex set X with C(X, A) being the set of its connected components, and < is a total order relation on C(X, A) such that the following conditions are satisfied. 1 (1) Q ∈ C(X, A) is a complete subgraph of (X, A).
As above, the connected components of the alignment graph (X, A) play the role of the alignment columns. Condition (2) ensures that every alignment column contains at most one element of each ordered set X a . Conversely, every element (a, i) is contained in exactly one connected component, i.e., alignment column. Condition (4) requires that alignment columns do not cross. Condition (5) ensures that the restriction of order on the columns to each row recovers the order (X a , < a ). A bit more formally, we may phrase this as follows: A well known observation in the theory of alignments is that Conditions (4) and (5) in general only specify a partial order but not a total order of the alignment columns: Lemma 7 Let (X, A) be an alignment graph and denote by ≺ the relation defined for all P, Q ∈ C(X, A) by P≺Q whenever there is an a ∈ S such that (a, i) ∈ P, (a, j) ∈ Q and i < j. Then the transitive closure ≺ of≺ is a partial order on C(X, A).
Proof By construction,≺ is antisymmetric. By definition P ≺ Q if and only if there is a sequence of columns P = Q 0≺ Q 1≺ · · ·≺Q k = Q. Since the sequence of elements (a, i) belonging to the same X a is strictly increasing with the column index j for each a along any such sequence of columns, it follows that the transitive closure of ≺ is still antisymmetric. Thus ≺ is a partial order.
As an immediate consequence, there is also a (not necessarily unique) total order < of the alignment columns, obtained as an arbitrary linear extension of ≺, which by construction satisfies We summarize this reasoning in Theorem 8 Let (X, A) be an alignment graph for X = · s∈S X s and conditions (1), (2), and (4) of Definition 6 are satisfied. Then there exists a total order < on C(X, A) satisfying condition (5), i.e., such that (X, A, <) is a total alignment.
Theorem 8 provides the justification for considering alignment graphs with ordered columns instead of the matrix representation specified by an alignment map ω. Obviously (X, A, <)-or more precisely the order < of the alignment columns-completely defines α, ω, and L provided we require that there are no alignment columns consisting entirely of gap symbols, i.e., in the case of proper alignments. Before we proceed, a few remarks are in order: In this setting the actual data associated with the sequence element (a, i), whether it is simply the i-th letter of input sequence a or an extensive entry at position i of the list a, is treated as a label that influences only the scoring but not the structure of the alignment. This separation between the underlying (index) structure and the data associated with them is also used in algebraic dynamic programming approaches to alignments [5,29], where the structure of the recursions depends only on the possible alignments (X, A, <) for a given set X , while the scoring depends on the labeling of X . In order to treat (partially) local alignments it is necessary to distinguish aligned and "unaligned" columns. Each unaligned column may contain only a single element, i.e., every unaligned position is considered as an insertion relative to all other elements of X . Whether a position is aligned or unaligned affects only the scoring, hence at the level of alignment graphs we do not need to concern ourselves with a distinction of local, partially local, and global alignments.

Alignments of Partially Ordered Sets
Since the alignment of totally ordered sets in general only specifies a partial order of columns but not a total order, it seems natural to ask whether the concept of alignments and alignment graphs can be extended to partial orders instead of total orders and inputs. From here, one therefore considers a collection of finite partial orders (X a , ≺ a ), a ∈ S, |S| ≥ 1. As a generalization of Definition 6 we consider Definition 9 (PO Alignment) A partial order (PO) alignment of X is a triple (X, A, ≺) where (X, A) is a graph and ≺ is a partial order on the set of connected components C(X, A) such that Condition (A3) constrains the partial order on the columns to respect the partial order of the rows. Condition (A4) insists that columns also must not cross indirectly.
If all (X a , ≺ a ) are totally ordered then condition (A4) implies the non-crossing condition (4) because (b, j) and (b, l) cannot be incomparable w.r.t. ≺ b , and thus the required partial order ≺ is obtained as the transitive closure of the relative order of any two columns. Definitions 6 and 9 therefore coincide for totally ordered rows.
Condition (A4) obviously implies the following generalization of (4): However, (A4 * ) is not sufficient to guarantee that the alignment columns form a partially ordered set. A counterexample is shown in Fig. 2. It is therefore necessary to require the existence of the partial order ≺ on the alignment columns C(X, A) as an extra condition in Definition 9.
The existence of (non-trivial) alignments of any collection of finite partial orders (X s , ≺ s ), s ∈ S, is easy to see: each of the partial orders can be linearly extended to a total order (X s , < s ). Any alignment of these total orders is also an alignment of the underlying partial orders, with a suitable partial order of the columns given by Lemma 7.
Before we proceed we briefly remark that at the level of our discussion we do not need to concern ourselves with the distinction of global and local alignments. In order to model a partially local alignment of posets we is not sufficient to ensure the existence of a partial order ≺ on C(X, A). Consider the partial orders (a, 4) ≺ a (a, 1) and (a, 2) ≺ a (a, 3) and , and (A4 * ) holds, but the directed cycle shows that no partial order on the columns exists that is consistent with both partial orders consider the set A of aligned columns and a partition of the set of "unaligned columns" into two not necessarily non-empty subsets P and S such that for all U ∈ P, V ∈ A and W ∈ S it holds that W V and V U , i.e., no "unaligned" suffix column precedes an aligned column, and no "unaligned" prefix column succeeds an aligned column. "Unaligned" prefix columns belonging to different rows (X a , ≺ a ) are considered mutually incomparable; the same is assumed for "unaligned" suffix columns. With the caveat that "unaligned" columns need to be marked as such, there is again no structural difference between local and global alignments.
The projection of (X, A, ≺) onto a row a ∈ S is obtained as the set π a (X ) It is therefore of interest to to consider a (much) stronger version of axiom (A4): First we note that (A5) implies (A4). The definition of the projection of (X, A, ≺) to a row a ∈ S then immediately implies Observation 2 furthermore implies that (A4) and (A5) are equivalent if all (X a , ≺ a ) are totally ordered. In general this is not the case, however, as the example in Fig. 3 shows.
The following simple, technical result is a generalization of Lemma 7, showing that condition (A5) is sufficient to guarantee the existence of a partial order on the columns.

Lemma 10
Let (X, A) be a graph with connected components C(X, A) satisfying (A1) and (A2). Let≺ denote the transitive closure of the relation ≺ defined by (A3), i.e., P≺Q whenever (a, i) ∈ P, (a, j) ∈ Q and (a, i) ≺ a (a, j) then P ≺ Q; ∀P, Q ∈ C(X, A). Finally assume that axiom (A5) holds. Then ≺ is a partial order on C(X, A).
Proof It suffices to show that≺ is antisymmetric. It is clear from the construction that by (A5) we know that ≺ is antisymmetric. If≺ is not antisymmetric, then there is a finite sequence of columns P i , i = 0, . . . , k such that P 0≺ P 1≺ . . .≺P k≺ P 0 such that any two consecutive columns P i and P i+1 have a pair of entries, say (a i , h) ∈ P i and (a i , h ) ∈ P i+1 , in the same row. For the transitive closure this would imply both h) by going around the cycle, contradicting axiom (A5).
Finite partial orders (X a , ≺ a ) are equivalent to finite directed transitive acyclic graphs. The projection property of Observation 3, can be expressed in graph-theoretical terms in the following manner: Observation 4 Let (X, A, ≺) be an alignment of partial orders (X a , ≺ a ), S ⊆ S a subset of columns, and Q ⊆ C(X, A) such that X a ∩ Q = ∅ for all a ∈ S and Q ∈ Q . Then the graph with vertex set Q and directed edges whenever P ≺ Q is an induced subgraph of (the graph representation of) (X a , ≺ a ).
Thus the set of alignment columns Q defines an induced common subgraph of the transitive acyclic graphs (X a , ≺ a ) in a ∈ S . This is of course also true for pairwise alignments. In the pairwise case, none of the columns Q ∈ C(X, A) \ Q describe a (mis)match, i.e. they contain only insertions and deletions, while all Q ∈ Q describe Alignment edges are shown in green. Bottom: the induced partial order of the alignment columns with corresponding points vertically aligned. The partial order is again shown as a Hasse diagram, with superfluous edges omitted. Both the l.h.s. and the r.h.s. example satisfy (A4), i.e., none of the order relations ≺ 1 and ≺ 2 is violated in the alignment. The red edges highlight two comparabilities introduced by partial order of the columns that are absent in the input posets. Red edges therefore imply a violation of condition (A5). Hence the l.h.s. alignment violates (A5), while the r.h.s. alignment does not (mis)matches. A score-optimal alignment of two partial orders therefore corresponds to a maximal induced common subgraph of two transitive acyclic graphs. In both specifications of the problem, the scoring function will of course depend on the labels. We refer to [8] for a discussion of the relationships of edit distances and maximum common subgraph problems in a more general setting.

Composition of Alignments
In order to study the composition of alignments it seems natural to first consider the properties of parts of given alignments. The most natural starting point is to consider restrictions induced by considering subsets of the input sequences. The following result, which generalizes Lemma 1 of [51], provides a convenient starting point. Proof Every induced subgraph of a complete graph is again a complete graph, hence (A1) holds for (X, A)[Y ], hence the connected components of (X, A)[Y ] are exactly the non-empty intersections of Y with the components Q of (X, A). Condition (A2) remains unchanged by the restriction to Y . Finally, the partial order ≺ satisfying (A3) restricted to the non-empty intersections Q ∩ Y for Q ∈ C(X, A) is a partial order that obviously still satisfies (A4) since the restriction to Y only removes some of the conditions in (A4).
To see that the restriction of (X, A)[Y ] again satisfies (A5) it suffices to recall that the partial order in the column is given by P ∩ Y ≺ Q ∩ Y whenever P ≺ Q and both P ∩ Y = ∅ and Q ∩ Y = ∅. If one of the intersections is empty, axiom (A5) becomes void since the empty set is not a column in (X, A)[Y ]. On the other hand, if the two restricted columns have entries (a, i) and (a, j) in the same row, then (A5) for (X, A, ≺) ensures (a, i) ≺ a (a, j), i.e., the implication (A5) remains true for the restricted alignment.
Note that additional partial orders on connected components of the induced subgraph (X, A)[Y ] may exist that are not obtained as restrictions of the partial order on C (X, A). The reason is that omitting parts of the columns may allow a relaxation of their mutual ordering.
Rooted trees can be seen as partially ordered sets, with the natural partial order defined by x ≺ y if y lies on the unique path connecting x and the root of the tree. This special case is thus covered in the general framework Column Q ∈ C(X, A) (marked in grey) is highlighted as an example. On the right, the two sub-alignments with the corresponding restrictions of Q are shown: Q α ∈ C(X, A)[X α ] and Q β ∈ C(X, A)[X β ] are connected components and complete subgraphs of the sub-alignment graphs and can be composed to Q by applying the disjoint union and adding extra edges between all elements in Q that are in distinct sub-alignments thus Q α and Q β (dashed lines). Indices at nodes in the graph refer to the sequence the node is coming from. The alignment (X, A)/P on the right is the alignment of the sub-alignments (X α , A) and (X β , A). Thus the nodes in the alignment graph are columns of the sub-alignments. Alignment edges show matched columns. The unmatched columns correspond to the columns marked by dashed lines in the alignments on the left and middle outlined here. Usually, tree alignments are defined on rooted oriented trees, however, where the relative order of siblings is preserved [5,26,30], thus imposing additional restrictions on valid alignments. We will return to this point in some generality in the discussion section.
The fact that alignments are again totally or partially ordered sets implies that one can also meaningfully define alignments of alignments. As before, we start from a collection of finite partial orders (X a , ≺ a ), a ∈ S. Let P be a non-trivial partition of the rows, i.e., of S, whose classes we will write as S α indexed by α. We write X α := · a∈S α X a . By construction, X α ∩ X β = 0 for α = β, i.e., the site sets of the row classes are disjoint. The row partition P thus implies a partition of X .  (x , x ) whenever there is a column Q ∈ C(X, A) with x ∈ Q ∩ X α and x ∈ Q ∩ X β for classes α = β.
Proof By Lemma 11, the alignments (X, A, ≺)[X α ] subalignments of (X, A, ≺) and thus (X, A)[X α ] is an induced subgraph of (X, A). Their disjoint union therefore lacks exactly all edges that connect pairs of vertices that are in the same connected component of (X, A) but do not below to the same class of rows α. Since the partial order on the columns of (X, A)[X i ] is the one inherited from (X, A, ≺), the re-composition of the columns also recovers the original partial order.
A corresponding example is shown in Fig. 4 where the alignment (X, A, ≺) is composed out of sub-alignments (X, A, ≺)[X α ] and (X, A, ≺)[X β ] with Q, Q α , and Q β as examples for connected components of the alignment graphs and their composition by disjoint union and extra edges (dashed lines) between elements of distinct subalignments.
The (X, A, ≺)[X α ] can also be interpreted as partially ordered sets whose points are the non-empty restrictions Q ∩ X α of the connected components of (X, A) to the row classes α.

Definition 13
We denote by (X, A)/P the quotient graph whose vertices are the columns of the induced sub-graphs (X, A)[X α ], that is, the non-empty sets Q ∩ X i where Q is a connected component of (X, A). Its edges are the pairs (Q ∩ X α , Q ∩ X β ) for which both Q ∩ X α and Q ∩ X α are non-empty.
The connected components of the graph (X, A)/P are therefore of the form Q := Q/P = {Q ∩ X α |Q ∩ X α = ∅}. Note that Q is non-empty since the column Q of (X, A) contains at least one element, which belongs to (X, A)[X α ] for at least one of the classes α of P. Thus there is a 1-1 correspondence between the connected components of (X, A) and those of (X, A)/P. The columns of (X, A)/P therefore naturally inherit the partial order ≺ of C(X, A). We write (X, A, ≺)/P for the quotient graph with this partial order on its connected components. (X, A, ≺) is an alignment, then (X, A, ≺)/P is also an alignment.

Lemma 14 If
Proof Consider the quotient graph (X, A)/P. By construction, each column Q is a complete graph and contains at most one node for each class of P since it is the quotient of a column of (X, A, ≺) w.r.t. P. Also by construction, we have P ≺ Q for the columns of (X, A)/P whenever P ≺ Q in (X, A, ≺). Since there is a 1-1 correspondence between columns of (X, A, ≺) and (X, A, ≺)/P, ≺ also serves as a partial order on the columns of (X, A)/P, which is by construction consistent with the partial order on (X, A)[X α ] for each of the row classes α.

Theorem 15
Let (X, A, ≺) be an alignment and let P be an arbitrary row partition. Then (X, A, ≺) is isomorphic to the alignment (X, A, ≺)/P of its restrictions (X, A, ≺)[X α ] to the row classes α of P.
Proof Since (X, A, ≺)/P is well defined by Lemma 14, Lemma 12 shows that expanding the classes points of (X, A, ≺)/P into corresponding sets Q α building the union of those that belong to a column of (X, A, ≺)/P exactly recovers the columns of (X, A, ≺) and their partial order.
We note that the constituent alignments (X α , A α , ≺ α ) := (X, A, ≺)[X α ] have at most the same number of columns since "all gap" columns, Q = Q ∩ X i = ∅, are removed. The decomposition of Theorem 15 can be applied recursively until each constituent alignment is one of the input posets (X a , ≺ a ), a ∈ S. Any such recursive composition is naturally represented as a rooted tree T. The leaves of T are the input posets (X a , ≺ a ), while the root represents (X, A, ≺). Each internal node of T corresponds to an alignment of its children. In particular, one can choose T to be any binary tree.
The reverse of this type of decomposition underlies all progressive alignment schemes. One starts from a guide tree T whose leaves are the (X a , ≺ a ) and for each inner node of T constructs an alignment (or a set of alternative alignments) from the (set of) alignments attached to its children. It is important to note that a score-optimal alignment (X, A, ≺) in general is not the score-optimal alignment (X, A, ≺)/P of score-optimal constituents (X α , A α , ≺ α ), or, in other words, if (X, A, ≺) is score-optimal, there is no guarantee that there is any nontrivial partition of the rows P such that all the restrictions (X, A, ≺)[X i ] are score-optimal subalignments. Progressive alignment methods thus cannot guarantee an exact solution of the multiple alignment problem. Results in practical applications depend substantially on the choice of the guide tree T. It has been suggested early [20], that T should closely resemble the evolutionary history of the input sequences. Usually T is constructed from distance or similarity measures between all pairs of input sequences-and usually pairwise alignments are employed to obtain these data. A special case of progressive alignment adds a single sequence in each step, instead of also considering alignments of larger sub-alignments.

Blockwise Decompositions
On the other hand, we can also decompose alignments into blocks of columns. More precisely, we consider an alignment (X, A, ≺) and a partition Q := {Y 1 , . . . , Y q } satisfying the following properties: (ii) There is a partial order on Q such that for any two distinct classes Y k , Y l ∈ Q such that Y k Y l whenever there are columns P ∈ Y k and Q ∈ Y l with P ≺ Q.
We call the classes of such a partition blocks. By Lemma 11 each block (X, A, ≺)[Y k ], Y k ∈ Q is again an alignment.

Theorem 16
Let (X, A, ≺) be a partial order alignment with blocks Y k ∈ Q, and a partial order on the set of blocks. Then there is a partial order alignment (X, A, ≺ ) such that ≺ is an an extension of ≺ defined by P ≺ Q if and only if P ≺ Q for P, Q ∈ Y for some Y ∈ Q and P ≺ Q for P ∈ Y k and Q ∈ Y l with Y k Y l and k, l ∈ (1, q).
Proof Each alignment block consists of the disjoint union of alignment column(s), thus the disjoint union of complete subgraphs. Given the partial order of alignment columns given by P ≺ Q, this order is preserved inside the alignment blocks Y k ∈ Q as each block is an alignment, too. Given an alignment block Y with P ≺ Q for P, Q ∈ Y for some Y ∈ Q, one can decompose this into two blocks Y k and Y l with at least one column in each block such that P ∈ Y k and Q ∈ Y l . Based on the decomposition of Y into Y k and Y l one can restore the order of the alignment blocks such that Y k Y l based on Y . Thus, one gets the order of P ≺ Q that is present for the alignment columns P and Q as well as for the alignment blocks Y k and Y l .
In the case of totally ordered inputs, the restriction X a ∩ Y of a block Y to an input X a is an interval of X a and the columns in Y form an interval of the columns of (X, A, <). Similarly, one can restrict the choice of blocks in such a way that just "mirrors" the initial partial order, i.e., Y k Y l if and only if P ≺ Q for P in Y k and Q in Y l , in which case ≺ = ≺ and the original alignment is recovered by the concatenation of the blocks. In particular, this also guarantees that valid block decompositions can be constructed for alignments satisfying (A5).
Each alignment can thus be recursively decomposed into blocks. This sets the stage for Divide-and-Conquer algorithms such as DCA [58], which cuts the sequences to be aligned into subsequences and then concatenates the subalignments so as to optimize a global score. In order to find the best cut-points, the algorithm recurses on differently cut subsequences. Algorithms such as dialign [46] work in a conceptually similar manner but use a bottom-up instead of a top-down approach: they first identify blocks with high sequence conservation as "anchors" and recurse to construct alignments for sequences between them.
An extreme case of the block-wise decomposition is to consider the division of an alignment (X, A, ≺) into a single maximal (or minimal) alignment column P, and the rest (X \ P, A , ≺) of the alignment. In order for X \ A P to hold, we have to ensure that p a ⊀ a q a for all p a ∈ P and q a ∈ X \ P, i.e., the column P must entirely consist of suprema of the respective input posets. Under this condition, we obtain a recursive column-wise decomposition of alignments. As we shall see in the following section, this recursion can also be used constructively.

Recursive Construction
Given a poset (Y, ≺) we say that P ⊆ Y is a bottom set if, for all p ∈ P, every p ≺ p satisfies p ∈ P. By definition, the empty set, Y itself, as well as the set { p ∈ Y | p y} for each y ∈ Y are bottom sets. Note, however, that P also may contain points that are incomparable to all other elements of P. Denote by sup P the set of suprema of P, i.e., the points such that there is no p ∈ P with p ≺ p . Clearly, if P is a bottom set and p ∈ sup P then P \ {p} is again a bottom set. The latter observation suggests that there is a recursive construction for the set of alignments.
For simplicity of exposition, we first consider the pairwise case, i.e., the set of alignments of two finite posets (X 1 , ≺ 1 ) and (X 2 , ≺ 2 ). Denote by A P Q the set of all pairwise alignments on bottom sets P in X 1 and Q in X 2 . An alignment A ∈ A P Q is necessarily of one of three types: where P := P \ {p} for p ∈ sup P, Q := Q \ {q} for q ∈ sup Q, and A ∅ ∅ contains only the empty alignment. The three cases correspond to (mis)match, insertion, and deletion. It is important to note that this recursion is in general not unique because the columns extracted from A in consecutive steps are not necessarily ordered relative to each other whenever | sup P| ≥ 1 or | sup Q| ≥ 1. It is, however, a proper generalization of the Needleman-Wunsch recursion [49] for the pairwise alignment of ordered sets (strings): If the ≺ a are total orders, then sup P a always contains a single element, and we recover the usual Needleman-Wunsch algorithm. In order to have a proper start and end case for the recursion and thus DP-algorithm, it is convenient to introduce "virtual" source and sink nodes being connected to all start or end nodes of the poset, respectively. This idea generalizes to alignments of an arbitrary number of partial orders in the obvious way. Denote by A(P 1 , P 2 , . . . , P N ) the set of all alignments where the P a are a bottom set of (X a , ≺ a ).

Theorem 17
Every alignment A ∈ A(P 1 , P 2 , . . . , P N ) is of the form A where the alignment column is a supremum w.r.t the partial order of ≺ of alignment columns and A ∈ A(P 1 , P 2 , . . . , P N ). The column contains in row a either a gap row a, in which case P a = P a , or p a ∈ sup P a , in which case P a = P a \ {p a }, and does not entirely consist of gaps. For every column ϒ of A we have either ϒ ≺ or ϒ and are incomparable.
Proof The P a are again bottom sets, hence A is an alignment. By assumption, there is a partial order on the columns ≺ of A . Since every non-gap entry in is a p a ∈ sup P a , it follows that this partial order extends to A if and only if is a supremum, i.e., it is either incomparable with or larger than any column in A . Now suppose that the column contains a q a / ∈ sup P a , i.e., there is a p a ∈ X a with p a q a . Consider the column ϒ containing p a . Then either no partial order ≺ on the columns exists (contradicting that A is an alignment), or ϒ (contradicting that is a supremum for the alignment columns. The bottom sets are of course uniquely defined by their suprema. Clearly sup P is an antichain, i.e., its elements are pairwisely incomparable. Conversely, every antichain U in (X a , ≺ a ) uniquely defines a bottom set P := { p ∈ X a | p U }. It is obvious therefore that for two bottom sets P and Q it holds that P = Q if and only if sup P = sup Q. Hence there is a 1-1 correspondence between the antichains of a partial order and their bottom sets. The recursion in the theorem can be written in terms of the antichains of the (X a , ≺ a ). Note that the recursion of Theorem 17 can be transformed into an exact dynamic programming algorithm for alignment of posets, provided the scoring function is the sum of column-wise contributions.
In order to capture the more restrictive notion of alignments satisfying (A5) the recursion has to be modified in a such a way that for every (mis)match between two rows it can be ensured that all previously formed columns are either comparable in both rows or incomparable in both rows. This is non-trivial because this information is not purely local. For ease of discussion, we only consider the case of aligning two posets. There are at least two strategies to maintain this information.
Attempting to construct a similar recursion as in the (A4) case, one could store with each pair P ∈ X 1 and Q ∈ X 2 also all the set M of all matchings p q "to the right" of P and Q, i.e., p ∈ X 1 \ P and q ∈ X 1 \ Q. Then every allowed matching/column p q , p ∈ sup P and q ∈ sup Q must satisfy: for all p q ∈ M holds: either p ≺ p and q ≺ q, or both p , p and q , q are incomparable. Every such pair can be appended to M, with corresponding updates P → P \ {p } and Q → Q \ {q }. Insertions and deletions of course only require the removal of either p from P or q from Q, respectively. Initially, P = X 1 , Q = X 2 , and M = ∅. Every set of valid partial alignments is characterized by a triple (P, Q, M).
An alternative approach is to store instead for each p ∈ P and q ∈ Q also the sets c Q ( p) and c P (q) that can form matches p q , q ∈ c Q ( p) and p q with p ∈ c P (q), respectively. Initially, we have P = X 1 , Q = X 2 , c Q ( p) = Q for all p ∈ P and c P (q) = P for all q ∈ Q. Whenever an alignment is continued with a (mis)match p q , p ∈ sup P, q ∈ sup Q, we have to remove all candidates from c P (q ) and c Q ( p ) that are inconsistent with p q . That is: if q ≺ q, then c P (q ) ← {p ∈ c P (q )| p ≺ p}. If q and q and incomparable, then c P (q ) ← {p ∈ c P (q )| p , p incomparable}. The c Q ( p ) are updated correspondingly. In the case of an insertion p − , we only need to remove p from f P (q ), q ∈ Q. Similarly, − q implies that q has to be removed from the f Q ( p ) for all p ∈ P. We suspect that an encoding of alignment sets of the form (P, f Q : P → 2 P ; Q, f P : Q → 2 P ) will be efficient if the poset has only small antichains. A more detailed analysis of this kind of recursive construction from the point of view of algorithmic efficiency will be considered elsewhere.
The POA algorithm [41] computes the alignment of two posets satisfying (A5), albeit with the restriction that one of the two inputs is totally ordered. This removes all ambiguities in the totally ordered poset and implies that, given any match ( u v ) in the alignment, all preceding matches u v satisfy v < v in the totally ordered set and thus u must be a predecessor of u. The alignment thus must follow a single path in the Hasse diagram of the unrestricted input poset.
The recursive formulation of the poset alignments is an extension of the well-known Needleman-Wunsch alignment algorithm. Beyond many implementations of the Needleman-Wunsch algorithm, the implementation based on ADPfusion (Algebraic Dynamic Programming with compile-time fusion of grammar and algebra) [27] is designed in a way to be extendable to different scoring functions, problem descriptions, and data structures [28]. Future work thus will include the adaptation of the ADPfusion framework written in a functional language (Haskell) to the data structure of posets. Earlier adaptations of the Needleman-Wunsch algorithm to trees, forests and sets already exist [5,29].

Alignments as Relations
Pairwise alignments have a particularly simple structure. They are bipartite (undirected) graphs, and hence can be regarded equivalently as symmetric binary relations R ⊆ X 1 × X 2 . More precisely, we can identify a relation R with an undirected graph with vertex set X 1∪ X 2 and (undirected) edges {x 1 , x 2 } whenever (x 1 , x 2 ) ∈ R. We write this graph as (X 1∪ X 2 , R).
Relations have a natural composition. For R ⊆ X × Y and S ⊆ Y × Z is defined by In the following we will be interested in these properties of binary relations:

Lemma 18 The composition of two binary relations satisfying (M) and (P) is again a binary relation satisfying (M) and (P).
Proof Suppose (x, z) ∈ R • S. Then there is y such that both (x, y) ∈ R and (y, z) ∈ S. By (M), there is no other y = y with (x, y ) ∈ R and no z = z such that (y , z ) ∈ S, hence in particular there is no z = z such that (x, z ) ∈ R • S. Analogously, one argues that there is no x = x such that (x , z) ∈ R • S. Thus R • S again satisfies (M).
It is easy to see that Axiom (P') is in general not preserved under concatenation: Requiring only (P') allows the intermediate vertices y 1 and y 2 to be incomparable. Hence it is possible in this scenario to have x 1 ≺ 1 x 2 , incomparable vertices y 1 and y 2 , and z 2 ≺ 3 z 1 with (x 1 , y 1 ), (x 2 , y 2 ) ∈ R and (y 1 , z 1 ), (y 2 , z 2 ) ∈ S while the concatenation violates the (P').
A relation satisfying (M) and (P') can easily be extended to an alignment (X 1 ∪ X 2 , R) considering each edge (x 1 , y 1 ) and considering all unmatched positions, i.e., every {x } such that there is no y ∈ X 2 (x , y) and every {y } such that there is no x ∈ X 1 (x, y ) as alignment columns. The relative order of these columns is inherited from the partial order (X 1 , ≺ 1 ) and (X 2 , ≺ 2 ).
Proof By definition, all edges are incident to one vertex in X 1 and one vertex in X 2 , thus the graph is a bipartite matching. Condition (M) is therefore equivalent to (A1) and (A2) for the case of two input posets. Axiom (A3) implies the ordering required by (P') as well as its extension to the in/del columns. (A4) and (P') equivalently guarantee the existence of the partial order on the columns that satisfy (A3).
Proof Axiom (A5) simplifies to (P) in the case of only two inputs. The existence of the required partial order on the set of all columns is guaranteed by Lemma 10. This suggests that the more restrictive condition (A5) may be a more natural condition for defining alignments of partially ordered sets. As a down-side, however, it seems that there is no convenient recursive construction of the search space similar to the dynamic programming approaches for sequence alignment. Instead, it seems more natural to treat this class of alignment problems as maximum induced subgraph problems.
Composition of binary relations is a powerful tool to construct multiple alignments. Suppose we are given a set of posets (X a , ≺ a ) and a set R of pairwise relations satisfying (M) and (P) such that the graph representation of R is tree, then there is a unique multiple alignment satisfying (A5) obtained as the transitive closure of the graph on X with edges defined by the R ∈ R. However, not every alignment can be represented in this manner. As a simple counterexample consider the alignment of the three sequences The first column gives an alignment of three input strings a, b, and c. It contains the pairwise alignments (a,b) and (b,c). Their relational composition (shown in the last column) contains only the matches BB from (b,c) and CC from (a,b). The match AA from the original alignment is not reconstructed in the composition of the pairwise alignment. One easily checks that, by symmetry, no composition of pairwise alignments recovers the original 3-way alignment. Hence not all alignments can be represented as relational compositions of pairwise alignments. On the other hand the progressive approach, in which sequence c is aligned to the pairwise alignment of a and b yields the example alignment. In fact, Lemma 14 implies that in principle every alignment can be obtained by a progressive alignment scheme. If R contains cycles, then there is no guarantee that the transitive closure A of R∈R R is an alignment: In general, both conditions (A1) and (A2) will be violated. So-called transitive alignment approaches deliberately accept this at an intermediate stage. Various heuristics can be used to remove superfluous edges from the graph (X, A), that is they construct a subgraph (X, A), A ⊆ A that again satisfies all conditions of a valid alignment.

Tree Alignments
A rooted tree with vertex set V is uniquely defined by two mutually exclusive partial order relations: the ancestor order ≺ defined such that x y whenever y is located on the path from x to the root, and the sibling order defined in terms of the ordering of the children of each vertex: For two vertices x and y that are incomparable w.r.t. ≺, let w be their last common ancestor and u and v be the distinct children of w such that x u and y ≺ v. Then x y if and only if u v. By construction, two vertices are either identical or comparable w.r.t. either the ancestor or the sibling order. The observation extends to ordered forests, where the sibling order is extended such that vertices from any two constituent subtrees are are always comparable w.r.t. the sibling order (Fig. 5).
Consider a forest T with vertex set V and define T v with vertex set V \ {v} as follows: (1) if v is the root of a subtree, delete v and replace the tree T (v) rooted at v by trees rooted at the children of v in sibling order; (2) if v Fig. 5 Example of a forest alignment of three forests (bottom). The resulting forest (top) is the superstructure combining all of the input trees. The node labels correspond to alignment columns and blue nodes indicate matches such that they exist in all the input trees. Original trees can be recovered from the supertree by only taking nodes without gap symbols in the corresponding alignment column. A node with a gap symbol is then removed and its edges contracted such that its children will be its parents children afterwards. This can be seen in F 1 where node b does not exist and nodes c 1 and h 1 become children of the root a 1 is not the root of a subtree, contract the edge from the parent of v to v. That is, the children of v become children of the parent of v. It is not hard to check that both the ancestor and sibling orders for T v is simply the restriction of ≺ and to V \ {v}.
A forest alignment is defined as a forest T such that each vertex v is labeled by an alignment column Q v . The constituent tree T s , s ∈ S is obtained from T by first simplifying the label on T to Q v ∩ X s at each vertex v; then all v with Q v ∩ X s = ∅ are removed by deletion or contraction of their parent edge as outlined above [5,26,30]. Thus T s has the vertex set V := {v ∈ V |Q v ∩ X s = ∅} and both its ancestor and sibling orders are the restriction of ≺ and to V . Tree or forest alignments thus fit seamlessly into the mathematical formalism for partial order alignments. We simply have to require that the alignment graph (X, A) satisfies (A1) and (A2) and that properties (A3) and (A5) hold w.r.t. both partial orders ≺ and . This observation suggest how alignments satisfying an analog of (A5) can be defined in a meaningful way for a much broader class of discrete structures.
A notion of alignment similar to tree/forest alignments is used in computational biology for RNA structures, where base pairs need to be preserved in addition the total order of the input sequences [45]. Here, however, only consistency similar in flavor to (A4) is enforced, suggesting that it may also be of interest to relax the requirement that restriction to the columns Q for which Q ∩ X a = ∅ exactly recovers the input tree (X a , ≺ a , a ).

Alignments of Graphs
In Sect. 4 we have seen that alignments of partially ordered sets can alternatively be viewed as alignments of graphs from a very restricted class, namely transitive acyclic digraphs. This raises the question whether the construction can be generalized to arbitrary (di)graphs. In this section we consider an input set of digraphs G a , a ∈ S, with vertex sets V (G a ) = X a and edge sets E(G a ), resp. As before, we write X = · V (G a ), introduce a set of alignment edges A, and denote by C(X, A) be the set of connected components of the (undirected) graph (X, A).

Definition 21
A triple (X, A, E * ), where A is a set of unordered pairs on X and E * is a relation on C(X, A), is a multiple alignment of the graphs G a , a ∈ S, if the following conditions are satisfied: A) and ((a, i), (a, j) a row a with (a, i) ∈ P, (a, j) ∈ Q and ((a, i), (a, j)) ∈ E(G a ), and (a, j) ∈ Q then ((a, i), (a, j)) ∈ E(G a ).
Condition (G4) is redundant and is included here only to emphasize the similarity to the constructions in the previous sections. It may also be interesting to consider graph alignments that satisfy only (G4) but not (G5). Proof The vertex set X/C(X, A) has a single representative for each column Q ∈ C(X, A). By axioms (G3) and (G5), there is an edge (P, Q) ∈ E * if and only if there are (a, i) ∈ P and (a, j) ∈ Q with ((a, i), (a, j)) ∈ E(G a ) for some a ∈ S. The edge set on the r.h.s., amounts to identical condition.
Thus (C(X, A), E * ) is obtained from (X, a∈S E(G a )) by identifying the vertices within each alignment column. In particular, therefore, the set Q of columns Q such that Q ∩ X a = ∅ for all a in a given subset S ⊆ S forms an induced subgraph (C(X, A), E * ) that is present in each G a . Observation 5 thus remains true for graphs in general: Observation 5 Let (X, A, E * ) be an alignment of graphs (X a , E a ), S ⊆ S a subset of columns, and Q ⊆ C(X, A) such that X a ∩ Q = ∅ for all a ∈ S and Q ∈ Q . Then the graph with vertex set Q and edge set E * is an induced subgraph of (the graph representation of) (X a , E a ).
We note in passing that alignments of ordered and partially ordered sets assuming axiom (A5) are special cases of the graph alignments satisfying (G5), since total and partial orders are isomorphic to transitive acyclic digraphs. One easily checks that (G3) and (G5) indeed reduce to the corresponding statements for the (partial) orders (Fig.  6).
Again this is in particular true for pairwise alignments. Given two graphs G 1 and G 2 and a common induced subgraph H (strictly speaking together with an embedding of H into G 1 and G 2 ) the graph defined by identifying the copies of H in G 1 and G 2 is the pairwise alignment G 1 • H G 2 of the input graphs. Naturally, an optimization criterion will be used in practice. The problem of aligning graphs therefore coincides with the maximum common induced subgraph problem. Finding maximal common induced subgraphs (MCIS) is well known to be a NPcomplete problem and closely related to the maximal common edge subgraph problem (MCES), together often referred to as the maximal common subgraph problem (MCS) [12,16]. However, several approaches exist to find exact or approximate solutions for connected (cMCS) or disconnected (dMCS) common subgraphs using different algorithmic strategies such as backtracking algorithms, dynamic programming, or clique-finding.
It is very easy to check that Lemmas 11, 12 and 14-and thus also Theorem 15-remain true for the graph alignments of Definition 21. Indeed, the alignment of two graphs is again a graph. Its vertices, corresponding to the columns of the alignment, are labeled by the content of the columns. Therefore, we can build alignments of alignments for graphs. In particular, furthermore, progressive alignments of graphs are well-defined. Given a guide tree T , at each inner node of T the maximum common induced subgraph of the graphs at its child-nodes is computed, and the graphs are "glued together" at the common vertices.
It is important to note that graph alignment in the sense used here-namely requiring a matching between vertices and notion of structural congruence between the alignment and its constituent graphs-are more restrictive than some concepts of "graph alignments" discussed in the literature. In particular, we make a sharp distinction here between "graph alignments" and various approaches of comparison by means of graph editing, see e.g. [18] for a recent review. Example for (progressive) graph alignment of G 1 and G 2 (top) with aligned graph structure on the r.h.s and alignment of (G 1 , G 2 ) with G 3 and aligned graph structure again on the r.h.s. Dashed blue lines show matches between nodes of the input graphs. Labels at nodes correspond to alignment columns, indices refer to input graphs G 1 , G 2 or G 3 . The red subgraph is the maximal common induced subgraph of all three input graphs

Alignments for General Structures
So far, we have considered alignments for sequences (strings), partially ordered sets, rooted ordered trees, and graphs. How far can we generalize the idea of alignments, and what are minimal conditions for well-defined alignments? Let us start from a finite space (X, S ) with some structure S . We are not really interested in the particular properties of S . Examples for S might be systems of not necessarily binary relations, topologies, proximities, etc. As a minimum requirement we ask that (X, S ) admits well-defined subspaces, that is, if Y ⊆ X , then there exists a unique subspace (Y, S Y ) =: (X, S )[Y ]. Furthermore we require that holds for all Z ⊆ Y ⊆ X , i.e., that induces subspaces that can be formed stepwisely in a consistent manner. This property is satisfied for the examples we have considered so far: strings and totally ordered sets in general, partial orders, as well as directed and undirected graphs. It also holds for ternary relations such as betweenness, as well as topologies, proximities, and similar constructions. Now suppose we are given input spaces (X a , S a ) for all a ∈ S. As in the previous sections, we set X := · a∈S X a , we introduce a set A of edges connecting the vertices in X and write C(X, A) for the set of connected components of the graph (X, A). Furthermore, we define C a := {Q ∈ C(X, A)|Q ∩ X a = ∅}.
Endowing C(X, A) with some structure S consider the subspace (X, S )[C a ] obtained from (X, S ) to the connected components (columns) of (X, A) in which X a is represented. As in the previous sections we assume (X1) (X, A)[Q] is a complete graph for all Q ∈ C(X, A), and (X2) |X a ∩ Q| ≤ 1 for all a ∈ S and Q ∈ C(X, A).
Assumption (X1) implies that there is a 1-1 correspondence between the columns of Q ∈ C a and the elements q ∈ X a define by Q ∩ X a = {q}. Denote the corresponding map by π a : C a → X a . The condition that "projecting" (C(X, A), S ) down the constituent rows a ∈ S recovers the input spaces can then be expressed as S a ) with π a being an isomorphism.
This construction provides a well-defined notion of an alignment in a very general setting. Again, the restriction of the alignment to a set C of columns that are represented in X a for all a ∈ S , i.e., (C(X, A), S )[C ] is a common subspace of the (X a , S a ) with a ∈ S . This corresponds the poset alignments satisfying (A5).
Properties (X1), (X2), and (X3) are sufficient to ensure that key properties of totally ordered alignments still hold in this much more general setting. Repeating the simple arguments leading to Lemmas 11, 12 and 14 above, we observe: (i) The restriction (X, A, S )[Y ] to Y ⊆ X is an alignment for the restricted input spaces (X a , S a )[X a ∩ Y ].
(ii) If P is a partition of X into groups of rows, the quotient (X, A, S )/P is an alignment of alignments: The rows of (X, A, S )/P are of the form (C(X, A), S)[C ], where C := {C ∈ C(X, A)|C ∩ X a = ∅, a ∈ S } where S ⊆ S determines a class of the row-wise partition P. That is, every row of (X, A, S )/P is (isomorphic to) a subspace of (C(X, A), S). (iii) For a given class of P determined by the row indices, we observe that by construction the restriction of (X, A, S )[Y ] to Y := · a∈S X a is isomorphic to (C(X, A) We conclude therefore, that alignments defined by (X1), (X2), and (X3) can be decomposed recursively into alignments of alignments on all spaces with subspaces satisfying Eq. (5). In particular, these properties are sufficient to guarantee that progressive alignments are well defined. A natural question that arises at this abstract level is whether for any collection (X a , S a ), a ∈ S, there exists an alignment. To answer this question we consider trivial alignments for which A = ∅. Then every alignment column contains an element from exactly one of the X a . Thus there is a 1-1 correspondence between C(X, ∅) and X , ensuring that (X, ∅, S) and (X, S) are isomorphic. By (X3), (X, ∅, S) is an alignment of the (X a , S a ) whenever (X, S * )[X a ] (X a , S ) for all a ∈ S. The existence of such a "disjoint union" (X, S * ) is thus a sufficient condition for the existence of alignments. All the examples discussed in this section allow such "disjoint unions" and hence support alignments of arbitrary input data.

Concluding Remarks
In this contribution we have analyzed the compositional properties of sequence alignments and explored the generalization to much more general structures. We find that meaningful concepts of alignments are not restricted to ordered sets as inputs, but can be extended to very general relational or topological structures that need not bear any resemblance with order relations. The key property of the generalized alignments considered here is that the restriction of the alignment to a row recovers the input row. While this property is a simple consequence for the familiar sequence alignments, it becomes an important defining property of alignments in general. It suffices under very mild conditions of the structure of input spaces to ensure that alignments of alignments and recursive, row-wise decompositions of alignments are well-defined. We have observed, furthermore, that some well-studied examples of alignment problems, such as tree alignment and the alignment of totally ordered sets to a poset seamlessly fit into the framework developed here.
In this setting, alignments are defined on common subspaces. In the case of graph alignments, alignment columns corresponding to (mis)matches form common induced subgraphs. The pairwise alignment problem for two input graphs G 1 and G 2 therefore boils down to the problem of finding a maximum common induced subgraph (MCIS). The MCIS is a well-known NP-hard problem, which can be reduced to clique finding [4]. Nevertheless it is of substantial practical importance, in particular in chemoinformatics, since molecules are conveniently represented as graphs. A variety of practically applicable algorithms are therefore available [12,16,53]. In addition to cliquefinding, dynamic programming algorithms have been explored in particular for restricted classes of graphs [1,21]. In the setting of graph alignments, it may be interesting not only to score the matches, i.e., the common induced subgraph, but also the insertions and deletions, possibly requiring modified algorithmic approaches. We will explore aspects of scoring graph alignments and the computation of pairwise and multiple alignments of graph in future work.
In the context of poset alignments we also explored notions of alignments that require less stringent conditions than the exact recovery of the structure of each input row: it also seems to be of interest to require only that the restriction to a row is an extension of the input order. In the case of graphs, a similarly relaxed condition would only require that the input is a subgraph of the restriction. RNA structures may be considered as totally ordered sets that in addition carry a graph structure defined by the base pairs. Structure annotated alignments, then, have to recover the sequence order upon restriction to the input order, while the restriction of consensus base pairing on the alignment columns only needs to be a subgraph of the input base pairings. It will certainly be interesting to study such relaxed requirements on structure preservation more systematically in future work.
The fact that (multiple) alignments can be defined for very general structures, in essence for finite spaces with reasonably well-behaved notions of subspaces, suggests that alignments may be of interest as mathematical objects also for infinite spaces. Can the idea of alignments be captured in the language of category theory, is there an interesting class of categories that admit well-defined alignments objects, and do the resulting alignments themselves form categories with useful properties?