Multi-tape Computing with Synchronous Relations

We sketch an approach to encode relations of arbitrary arity as simple languages. Our main focus will be faithfulness of the encoding: we prove that with normal ﬁnite-state methods, it is impossible to properly encode the full class of rational (i.e. transducer recognizable) relations; however, there is a simple encoding for the synchronous rational relations. We present this encoding and show how standard ﬁnite-state methods can be used with this encoding, that is, arbitrary operations on relations can be encoded as operations on the code. Finally we sketch an implementation using an existing library ( FOMA ).


Introduction
There is no need to list the merits and advantages of finite-state methods. However, there are some drawbacks, which are partly due to intrinsic properties of rational (i.e. transducer recognizable) relations in general, partly due to restrictions in current libraries: 1. In general, the rational relations are not closed under intersection and complement. Some libraries offer an approximate version of intersection, but this is not guaranteed to provide accurate results.
2. The question whether given two transducers, the relation recognized by one is a subset of (or equal to) the other is generally undecidable. 3. Standard libraries only support binary relations; we will in fact prove there is no way to faithfully (we will make this precise below) encode rational relations (binary or more than binary) as regular languages by finite-state means.
The goal of this article is to solve all these problems with one step: restrict our attention to synchronous rational relations. This solves problem 1. because this class actually forms a Boolean algebra; it follows that 2. is also solved, as this way, it is easy to decide the inclusion/equivalence problem. We can also solve problem 3., because we can faithfully encode arbitrary n-ary synchronous relations as simple languages. This encoding preserves recognizability (by finite-state automata) and allows to faithfully encode standard operations on relations via (different) standard operations on the code (we will define and explain this in more detail below). As the only drawback, we have to renounce to the additional expressive power of rational relations over synchronous relations; but as it was argued in [9], there might be little actual need for this in linguistic applications. While from a theoretical point of view, we think there is little to object to our approach, there are large practical obstacles: firstly, synchronous relations are not as comfortable to specify as rational relations: for the latter, the representation of rational expressions is particularly practical and compelling (it is used i.e. by FOMA/XFST). We solve this problem here by defining a subclass of rational expressions which allows us to represent all and only synchronous relations, and we provide a program checking whether an expression is in this class. Secondly, we do not want to build a new program or library from scratch, but rather stick to existing ones. Therefore, we implement an interface which allows to define arbitrary n-ary synchronous relations, which are then encoded as languages and can be passed on to FOMA, a standard automaton library (see [5]). We have to add, 41 however, that the implementation is still work in progress.
Hence we show that we can make use of synchronous relations in finite-state processing without really big obstacles, and this solves the three problems we mentioned above. The paper is structured as follows: next, we lay out the motivations we have sketched here more explicitly. Then we provide the basic definitions of classes of relations and operations on them. Then we sketch our approach and procedure to solve the problems. Finally, we discuss the implementation.

Motivation and previous work
We here outline the motivations of this paper more explicitly. It is well-known that rational relations are not closed under intersection (for proof, see [1]), and consequently not under complement. This is problematic for some applications: we might want to intersect two relations, each one implementing a certain set of constraints, where grammatical forms have to satisfy both. Also complementation might be useful, because this way we might specify ill-formed transformations and go from there to well-formed transformations. In fact, libraries as FOMA have a pseudo-intersection operation, but it is not guaranteed to yield a mathematically correct result. 1 What is more problematic about the lack of intersection and complement is that without them, we cannot decide whether two transducers compute the same relation. This is problematic, because there are many different ways and methodologies to define the same relation. It would be nice to be able to see whether two relations are actually equivalent or one is more permissive than another (e.g. in comparing grammatical frameworks), but this is generally impossible with rational relations: proving equivalence of transducers is equivalent to giving a solution to the Post correspondence problem, which is undecidable (see [4]).
Finally, to our knowledge all existing libraries for transducers and rational relations only support binary relations. This is sufficient for most purposes in grammar engineering: we are interested in input/output relations, for example word form/morphological analysis; intermediate steps can and should be discarded. This is no longer true if we are interested in reconstruction of old languages from reported sound changes and shifts: here we often are interested in intermediate forms, and would need a form of "lossless composition" which preserves the intermediate steps. An alternative motivation is for example the desire to include phonology, prosody, semantics etc. into relations. For a nice motivation see [6,7]. Once we have intersection and arbitrary relations, we also have the possibility to generalize composition by "matching" an arbitrary number of components instead of just one. As this allows to encode intersection, rational relations are obviously not closed under these operations, whereas synchronous rational relations are (for a general definition see below).
The most important previous work on this topic is [7], which also gives an encoding of string tuples of arbitrary size into strings. However, this encoding is somewhat problematic: it either does not preserve recognizability, that is, if an n-ary rational relation is encoded in this way, the code language is not a regular language, or it cannot be computed by a finite automaton (this follows from lemma 4). Moreover, it is not faithful for some operations (see below). This is one main motivation for our approach. Synchronous relations actually have already been used in some applications (see [8]), but in a different library (Vaucanson) and unrelated to the issue of introducing relations of arbitrary arity.
Informally, SR are the relations computed by finite-state transducers which allow -transitions in a component only if no other letter is to follow in this component. There is also a characterization of SR in terms of first-order logic (see [2]), which is very convenient as it entails a lot of closure properties, in particular Boolean closure and closure under projection and cylindrification.
To have a more perspicuous notation, we sometimes use the identity expansion on languages: We thus expand languages to their identity relations. For example FOMA represents every language L as id(L), hence the concept is well-known.
We use projection in a slightly different sense than usual, namely in the sense of projecting away. We define for i ≤ n, R ⊆ (Σ * ) n , π i (R) = {(w 1 , ..., w i−1 , w i+1 , ..., w n ) : (w 1 , ..., w n ) ∈ R}. We urge the reader to keep in mind that for us, the ith projection is not choosing the ith component of tuples, but rather discarding it. On binary relations, these two notions of projection are obviously notational variants, but on relations of higher arity, our notion is much more powerful and convenient. The inverse of projections are cylinders: hence cylinders are maximal pre-images of projections. To avoid undefined terms, we introduce the following convention: if R ⊆ (Σ * ) n , i > n, then π i (R) = R, and if i > n + 1, then C i (R) = R (these two conventions are again necessarily parallel, otherwise C i is no longer an inverse for π i ).
When we encode tuples as strings, relations as languages, the two notions are closely connected to homomorphisms and inverse homomorphisms. We define homomorphisms as fol- for the maximal pre-image. For clarity, we distinguish between a function f and its graph, For every relabelling h, graph(h) is a relation computed by a one-state synchronous transducer.
For an arbitrary function f : A less well-known notion we need to explain is (generalized) composition with relations of arbitrary arity. We put, for Hence if o = 0, this becomes Cartesian product. Standard composition is • 1 (usually applied to binary relations), and we will usually write • for • 1 . We also define a relative we call lossless composition: Hence in this case, the "matching components" are not discarded, but rather kept, this way increasing the arity of the relation; if m = n = o, then this becomes intersection. As before, we usually write ⊕ instead of ⊕ 1 , which is the standard lossless composition as in [7]. A simple operation is inversion: Two more standard operations for relations over strings are concatenation and Kleene star: assume The following lemma summarizes the most important closure properties: These results are all well-known and easy to verify, given the logical characterization of SR (see [2], [9]): operations in 1. correspond to logical connectives; regarding 2., projection corresponds to existential quantification, cylindrification to introducing new (free) variables. Generalized (lossless) composition in 3. can be easily defined with operations in 1. and 2. (see section 4.2), and claim 4. is obvious.
What is problematic for SR is the lack of closure under concatenation and Kleene star: if R, S ⊆ (Σ * ) n , R, S ∈ SR, then R · S and R * need not be in SR.

Encodings: faithfulness and completeness 4.1 Coding preliminaries
We say a map ψ : (T * ) n → Σ * encodes tuples in strings, if there are maps φ 1 , ..., φ n such that for all i : 1 ≤ i ≤ n, We write x to refer to tuples of strings. This means ψ( x) contains all relevant information of all components, as they can be uniquely reconstructed. Note that this already entails a number of things, like: for x = (w 1 , ..., w n ), We define the complexity of the encoding via the complexity of the maps φ i , as these are string-to-string and hence more convenient to handle (but in most natural cases, the complexity of φ i determines that of ψ). An encoding is simple, if the maps φ i are relabellings; it is rational, if the φ i are finite-state computable. In general, we say a function f is rational if graph(f ) is a rational relation. Given an encoding ψ : (T * ) n → Σ * , code ψ := ψ[(T * ) n ] denotes the set of code words. The crucial question for encodings is whether we can faithfully transform operations on relations to operations on the code. Let R 1 , ..., R n be relations, τ be an n-ary operation, ψ be an encoding. Then we say that the operation τ ψ faithfully encodes τ , if (2) ψ(τ (R 1 , ..., R n )) = τ ψ (ψ(R 1 ), ..., ψ(R n )) Hence we can simulate operations on relations by operations on codes. ψ being an injective function already entails that it is faithful for union, intersection and composition; complement easily follows, provided code ψ is a regular language. For us, the most relevant property of encodings is the following: we want that all standard finite-state methods (FSM) can be faithfully encoded as standard finitestate methods, so if τ is a standard FSM, then τ ψ should be a standard FSM (though possibly a different one).
We now come to our simple encoding. It is based on tuple concatenation, but not componentwise: we defined · by (a, b) · (c, d) = (ac, bd), which results in a tuple of strings. To encode tuples as strings, we form (a, b)(c, d) (without ·), which is not a tuple of strings, but rather a string of two tuples. We say that a string of tuples x 1 ... x i is a factorization of y ∈ (Σ * ) n , if 1. x 1 , ..., x i ∈ (Σ ∪ ) n , and x 1 · ... · x i = y. Factorizations are thus maximal decompositions, but importantly, factorizations are not unique, because there are factorizations such as (a, )( , b) of (a, b). What is however unique are synchronous factorizations: a factorization x 1 .... x n is synchronous, if the following holds: if the jth letter of x i is , then for all m : i ≤ m ≤ n, the jth letter of x m is . Hence synchronous factorizations simply embody the synchronicity condition of synchronous relations, and synchronous factorizations correspond to convolutions, except that the latter are relations, the former are words -which is a crucial difference! Note: all relations over strings have a unique synchronous factorization, regardless of whether they are synchronous, rational, or even computable. Hence we can conceive of synfact : (Σ * ) n → ((Σ ∪ { }) n ) * as a function, which for every tuple gives its synchronous factorization. This is actually a simple encoding in our sense, where φ i is defined by the relabelling h(a 1 , ..., a n ) = a i . Keep in mind however that in factorizations, (a 1 , ..., a n ) is treated as an arbitrary letter, just as b. The following result is most important for synfact: Proof. The proof is actually straightforward: just interpret a synchronous transducer recognizing a relation as recognizing a language, then you recognize the factorization of the relation, and vice versa. So the transducer remains the same, just its interpretation changes.
This lemma is also very useful in order to prove that a relation is not synchronous. For example, take the relation R 1 = (b, ) * · (a, a) * . In its synchronous factorization, we have three letters, namely (a, a), (b, a) and (a, ), which for simplicity we write c, d, e. Then the synchronous factorization has the form synfact(R 1 ) = {d m c n e o : m+n = n+o}. If we intersect this with d * e * , then we obtain {d m e m : m ∈ N}, which is well-known to be not regular, and hence R 1 is not synchronous. We now provide a useful lemma showing how the maps φ i relate to ψ. We define We extend this to sets in the pointwise fashion.
By closure under inversion, this means that if ψ(R) is finite-state decodable, it is also finite-state encodable: there is an (n + 1)-ary rational relation graph(ψ) = {(w 1 , ..., w n , v) : ψ(w 1 , ..., w n ) = v}. Now we can state that there does not exist a rational encoding for rational relations: Lemma 4 There is no rational encoding ψ : (Σ * ) n → T * such that for all rational relations R, ψ[R] is regular.

Faithfulness for standard operations
After fixing the encoding for relations, we here present the encoding of operations τ ψ for some standard operations τ . Here it is important to keep in mind: whereas for defining relations, the "tuple structure" of (a 1 , ..., a n ) is essential, if we consider languages/factorizations, then (a 1 , ..., a n ) is just an arbitrary letter no different from b. For reasons of space, in the following table we write ψ for synfact; on the left, we present the operation on (synchronous) relations, on the right the corresponding operation on the code.
τ (on relation) τ ψ (on language) , h a relabelling. These are the set-theoretic operations (in a wide sense). As regards π and C (projection and cylindrification), these are usually not considered standard operations on relations, but this is only because on binary relations, they do not make too much effect. For our codes/factorizations, they become homomorphisms/inverse homomorphisms: as our letters have the form (a 1 , ..., a n ), π i is simply the relabelling h i : (a 1 , ..., a n ) = h(a 1 , ..., a i−1 , a i+1 , ..., a n ); cylindrification C i becomes the corresponding inverse relabelling h −1 i . We usually do not have homomorphisms directly in our libraries, but we can easily define the one-state synchronous transducers computing them, and obtain the results by composition: 45 So in some way or other, we can easily encode these operations, and hence all these operations can be used without any restriction. What is more serious and problematic are concatenation and Kleene star.

Concatenation and Kleene star
Our encoding is not faithful for concatenation and Kleene star. This is because the concatenation of two synchronous factorizations is not necessarily a synchronous factorization, such as (a, )( , a). This is related to the fact that synchronous relations are not closed under concatenation, and correspondingly not under Kleene star, so there is no remedy to this problem. Lack of closure under these operations is probably the biggest problem with synchronous relations. We will circumvent this problem by introducing a category system of expressions. We can conceive of rational expressions as grammars with just one category, where every combination of categories yields that same category as result. We distinguish three categories of rational expressions: As we have said, these categories concern the syntactic form of expressions, not their denotation, for which it is just a heuristic. Fix an arbitrary arity; then we have the following syntactic rules: • (a 1 , ..., a n ) ∈ el, if a 1 = , ..., a n = • (a, ..., a n ) ∈ bd and (a, ..., a n ) ∈ ed if for some i ∈ {1, ..., n}, a i = Note that the assignment is polymorphic, where type polymorphism is handled in the standard way (it can also be avoided by adding a type ed ∧ bd).
The combinatorics are as follows (we use x as variable for arbitrary categories) Moreover, we define an order el ≤ bd, ed ≤ gd ≤⊥, and for + denoting union, for expressions e, e of type x, x , e + e has type x ∨ y, that is, the join with respect to the order. We call the expressions of category el, bd, ed, gd the synchronous rational expressions (SR-expressions); this consequently forms a (proper) subset of the rational expressions We could also devise a more fine-grained and permissive system, but we do not present it for reasons of space. The important thing is the following: Lemma 5 Every synchronous rational expression denotes a synchronous rational relation.
This is easy to prove; for the few critical cases, use the synchronization lemma from [3]. So with SR-expressions, we are on the safe side, though many expressions which do denote synchronous relations are excluded. Note that the problem whether an arbitrary rational expression denotes a synchronous relation is undecidable (see [3], proposition 5.5).

Completeness of the constructions
Here we prove that with extended SR-expressions (for definition see below), we can construct all and only the synchronous relations. Importantly, this is not to say that only extended synchronous rational expressions denote synchronous relations, but for every synchronous rational relation we can construct an extended SR-expression. Take an alphabet Σ with |Σ| ≥ 2. Let EL ⊆ (Σ * ) 2 be the set of equal-length string pairs {(w, v) : |w| = |v|}, pref ⊆ (Σ * ) 2 the set of pairs {(w, wv) : w, v ∈ Σ * }, and for a ∈ Σ, R a ⊆ Σ * the set of strings {wa : w ∈ Σ * }. It is easy to see that EL can be constructed as synchronous expression with category el, pref with category el · ed = gd, R a : a ∈ Σ with category el (as it is unary). The completeness of our construction follows from the crucial direction of Eilenberg's result in [2]: Theorem 6 (Eilenberg, Elgot, Shepherdson) Assume |Σ| > 1. Then every synchronous rational relation of arbitrary arity over Σ can be constructed from EL, pref , R a : a ∈ Σ by the opera- Actually, this is slightly different from the original formulation, as we leave out the logic part and only consider the semantics; still our formulation easily follows from the main theorem of [2]. The proof of this statement is long and complicated, so we omit a sketch. We define extended synchronous expressions as follows: • If e is a synchronous rational expression, then it is an extended synchronous rational expression.
• If e, f are extended synchronous rational expressions, then so are π i (e), C i (e), e ∩ f , e.
The interpretation of these expressions is straightforward, as constructors are interpreted as themselves. Now the previous lemmas 1,5 and theorem 6 have the following consequence: Corollary 7 A relation R is synchronous regular if and only if it is denoted by some extended synchronous regular expression.
Of course, our approach so far is rather terse, and there is lots of syntactic sugar we can add; in particular, the operations of (generalized) composition and lossless composition can be added, as they are straightforwardly definable by generalized synchronous expressions. For reasons of space, we do not present this here, but make use of this in our implementation.

The procedure and implementation
Of course, it would be possible to construct a library for synchronous relations of arbitrary arity from scratch. This is however not necessary, as our results indicate: we can use a library which is able to handle regular languages and binary relations, and all we have to do is mediate the input: user ⇐⇒ interface ⇐⇒ existing FS-library Hence the user can interact with our interface, writing relations of arbitrary arity with synchronous rational expressions. The interface encodes them as terms which denote languages (or rather their identity expansion), which are then passed on to an existing library, in our case FOMA. Furthermore, every request by the user is again mediated. These requests can be of different nature: 1. assign the relation in question to a variable, and use it to construct a larger relation 2. check equivalence of two expressions (with or without variables), or emptiness of an expression.
3. check whether a word w is denoted by an expression, or give the output for a certain input, or print some set of tuples which are recognized These three types of requests can be easily handled, and we quickly sketch the procedure. 1. is easily taken care of, as this is just a variable assignment. 2. emptiness is routinely checked in FOMA; in order to check inclusion R ⊆ S, we just have to construct R ∩ S and check its emptiness. As regards 3., we can just use the standard method constructing the relation id({w}) and compose/intersect, and print the output or check emptiness. The processing chain of the interface starts with the parsing of the user input. The language that we propose for describing relations is comparable to the one used for regular expressions in FOMA, except that the elementary units are tuples instead of atoms. Before being encoded, the abstract syntax tree resulting of the parsing must be checked, as only synchronous rational expressions will be encoded by the interface.
The checking uses a color system, where colors represent the level of threat to the synchronicity of the relation. Each node in the abstract syntax tree of the expression will be colored either in black, green, orange or red. We start by coloring all the leaves of the tree (the tuples), and then all the colors of the internal nodes of the tree (the operations) are determined depending on the color of their daughter nodes (the arguments of the operations). The checking process explores the tree bottom up until the root, so the whole relation, is given a color. After checking, we will consider that a relation is not synchronous only if its color is red. A tuple will be given the green color if it features an empty word. When a node represents the application of a Kleene star, the resulting color will be orange if its daughter node (its argument) is green, so if the Kleene star is applied to a term containing an empty word. The relation until now is still synchronous, but will not be anymore if anything is concatenated on the right. For this reason, a node is given the red color if it represents a concatenation and if its left daughter node is orange.
One problem still needs to be taken care of after the checking: empty words should not appear in a tuple, except if for all the other tuples concatenated to its right also feature the empty word at the same index. For example, (a, )(a, b) should be forbidden. However, (a, b)(a, ) denotes the same relation, and can be obtained by a simple transformation of the first expression. Our implementation realizes this type of transformation, which we call -shifting. Whenever two tuples are concatenated, for each empty word in the left tuple, if the word at the corresponding index in the right tuple is not empty, then we swap them. We repeat this process until no can be shifted anymore.
After checking the expression and performing -shifting, the encoding can be done. The encoding that we target is actually very close to the string that we had before parsing, due to the similarity between our language and the one of FOMA. The essential difference is that in the target string, we need to make sure that tuples will be interpreted by FOMA as atoms.
Let us now go through the steps of the processing chain while looking at a concrete example. We consider the following input: The checking of this tree starts by giving colors to the tuples: (a,epsilon,b) is green because of the , the two others are black. The concatenation does not produce a red color here, as the left daughter node ([('a', 'epsilon', 'b')]) is not orange but green. It would be the case for example if the input was: ( (a , epsilon , b) * (a , c , a) ) | (a , c , b) * In this case, the process would have been stopped after unsuccessful checking. The next step is the -shifting, which explores the tree looking for concatenations. Only one shift is performed, on: The tree which we obtain after the -shifting is as follows: [ where % is the escape character allowing us to let FOMA consider tuples (here represented as lists) as a single atoms. Now that the output string was produced, the user can compute with FOMA an automaton for the relation. Our interface supports all the operations mentioned in this article, except for composition. This is due to the fact that our interface does not implement its own operations, but uses the ones provided by FOMA, following the translations given in section 4.2. Projection and cylindrification, which are necessary to compute composition, are not supported by FOMA, as they depend on our specific way to encode the tuples. Even though there is no trivial solution for their implementation because of this reason, possible workarounds would include the use of homomorphisms or the development of an extension to FOMA which provides ways to access and modify the elements in our tuples.

Conclusion
We have presented an approach to allow users to work with (synchronous) rational relations of arbitrary arity, with full Boolean closure properties and a decidable inclusion problem. Our approach is based on the desire to work with existing libraries, and we have done this by encoding arbitrary relations as simple languages. Our two main results are the following: firstly, an approach as ours cannot work with the full class of rational relations, because it is impossible to encode arbitrary rational relations as regular languages by finite-state means. On the other hand, we have sketched that it works very well with synchronous rational relations, for which only concatenation and star are problematic. The second main result is that we have presented a class of expressions which denotes all and only the synchronous rational expressions, which is not trivial, as the problem whether a rational expression denotes a syn-