Abstract 1 Introduction 2 Preliminaries 3 Computing distance of finite-valued transducers 4 Computing relative distance 5 Discussion and conclusion References

Edit Distance of Finite-Valued Transducers

Prince Mathew ORCID Université libre de Bruxelles, Belgium    Saina Sunny ORCID Université libre de Bruxelles, Belgium
Abstract

Transducers generalise automata by producing output word(s) for each input word, thereby defining a relation over words. A transducer is said to be finite-valued if, for every input word, it produces at most k output words, for some constant k. If k=1, then the transducer is said to be functional. The edit distance between two transducers is the minimal number of edits required to transform every output of one transducer into some output of the other, for each input word. This notion has been studied for functional transducers, where it is shown to be computable. However, it is uncomputable for transducers in general. In this work, we show the computability of the edit distance of finite-valued transducers, a class that is strictly more expressive than functional transducers.

Keywords and phrases:
Edit distance, Finite state transducers, Rational relations, Finite-valued, Multi-sequential
Category:
Track B: Automata, Logic, Semantics, and Theory of Programming
Funding:
Prince Mathew: Supported by the FNRS–DFG Weave project FORM-LEARN-POMDP (Ref. 40028647).
Saina Sunny: Supported by the FNRS project T011724F.
Copyright and License:
[Uncaptioned image] © Prince Mathew and Saina Sunny; licensed under Creative Commons License CC-BY 4.0
2012 ACM Subject Classification:
Theory of computation Transducers
; Theory of computation Quantitative automata
Related Version:
Full Version: https://arxiv.org/abs/2605.06269
Acknowledgements:
We would like to thank all the anonymous reviewers for their in-depth feedback which contributed to improving this paper.
Editors:
Sayan Bhattacharya, Danupon Nanongkai, Michael Benedikt, and Gabriele Puppis

1 Introduction

The theory of automata and transducers provides a rich foundation for modelling and reasoning about languages and relations and has numerous applications, particularly in program synthesis and the formal verification of hardware and software systems. While automata map words to Boolean values, word transducers extend this framework by modelling transformations: they read input words and produce output words using finite memory, thereby defining relations between words, known as rational relations. Their study dates back to the early days of computer science, where they were referred to as generalised sequential machines [14, 9, 13, 7] and the references therein. Their ability to capture input–output behaviour makes them a natural tool in diverse applications such as natural language processing, formal verification, and program analysis.

A notable subclass of transducers is that of finite-valued transducers. They compute rational relations where each input word is mapped to at most k output words, for a fixed k. Such relations are called k-valued (or finite-valued) rational relations. When k=1, the rational relation is called a rational function. Many problems that are undecidable in general for transducers become decidable under finite-valuedness. For instance, inclusion and equivalence are undecidable in general [8], but become decidable under the finite-valued restriction [11, 21, 4]. The subclass of finite-valued relations is decidable within the class of rational relations, i.e., given a finite state transducer 𝒯, it is decidable in polynomial time whether 𝒯 is a finite-valued transducer [20, 15]. In fact, it is also decidable in polynomial time to check if 𝒯 recognises a k-valued rational relation for a given k [10, 15]. Thus, finite-valued transducers strike a balance between expressive power and algorithmic tractability.

Recently, a quantitative notion of distance between transducers was introduced in [2] by lifting standard word metrics, most notably the edit distance, from words to word-to-word transformations. The edit distance measures the minimum number of edits (such as inserting or deleting a letter, or substituting a letter with another) required to transform one word into another. The edit distance between transducers provides such a quantitative measure: for every input word, it asks how many edits are required to transform every output of one transducer into some output of the other. This notion generalises the classical Boolean equivalence problem of two transducers to a numerical setting, where two transducers are assigned a distance, and are considered close if their distance is finite (reducing to standard equivalence when the distance is zero). This arises naturally in applications such as comparing text-based tools, such as spell checkers or grammatical correction tools. This distance between transducers was used in the study of approximate counterparts of fundamental decision problems for rational relations – such as functionality, determinisability, and uniformisation [6]. It is shown in [2] that the edit distance of functional transducers is computable; however, the problem is uncomputable for transducers in general [19].

This naturally raises the question: Is there an expressive yet well-behaved class of transducers, beyond the functional case, where edit distance remains computable? In this work, we answer this question affirmatively for finite-valued transducers, showing that their edit distance is computable. This result extends the computability of edit distance beyond functional transducers and provides a foundation for approximate reasoning within a class of transducers that is both expressive and practically motivated.

The procedure for computing the edit distance between finite-valued transducers exploits the fact that every finite-valued transducer can be decomposed into a finite union of functional transducers [21, 16]. We reduce the problem of computing the distance between finite-valued transducers to that of computing the distance between multi-sequential transducers (equivalent to a finite union of sequential transducers – those that are deterministic in the input). This further reduces to a new notion we introduce in this work, called the relative distance between a function and a relation. The relative distance between a function f and a relation R is defined as the least upper bound, over all inputs, of the minimal edit distance between the output of f and some output of R on the same input. Intuitively, this captures how far, in the worst case, the behaviour of f deviates from that of R. Beyond its technical role in our reductions, relative distance also provides a natural framework for approximate verification. In classical (exact) verification of reactive systems (systems that continuously interact with an environment by consuming inputs and producing outputs), it is checked whether the given reactive system (modelled by f) exactly satisfies a user-defined specification (modelled by R). The notion of relative distance makes it possible to reason about reactive systems that are “close” to a given specification, which is crucial when exact conformance fails, and minor deviations to the specification are acceptable.

In summary, we extend the known results on functional transducers to finite-valued transducers, showing that their edit distance is computable. The techniques we develop not only advance the theory of transducer comparison but also provide tools for approximate reasoning and verification of transducer-defined relations.

2 Preliminaries

We now recall the basic notions and notations that will be used throughout the paper. Let denote the set of natural numbers. For every k, we use [k] to denote the set {1,2,,k}.

Words and relations.

Let A and B denote finite alphabets of letters. A word is a sequence of letters. The empty word is denoted by ε. The length of a word is denoted by |w|. The set of all finite words over the alphabet A is denoted by A. A binary relation R between two sets U and V is a subset of the Cartesian product U×V. The domain of R is defined as 𝑑𝑜𝑚(R)={u(u,v)R}. For uU, the set of elements related to u under R is denoted as R(u)={v(u,v)R}. Note that u𝑑𝑜𝑚(R) iff R(u) is nonempty. A relation R is said to be k-valued (resp. exactly k-valued) for some k1, if for all u𝑑𝑜𝑚(R), the cardinality of the set R(u) is at most k (resp. exactly k). A function f:UV is a relation over U×V which is exactly 1-valued. The function f is partial if 𝑑𝑜𝑚(f)U.

Finite state automata.

A finite state automaton is a fundamental model of computation that accepts a set of words using finite memory.

Definition 1.

A (nondeterministic) finite state automaton 𝒜 is a tuple (Q,A,I,Δ,F), where Q is a finite set of states, A is the input alphabet, IQ is the set of initial states, ΔQ×(A{ε})×Q is the finite set of transitions, and FQ is the set of final states.

For aA{ε}, we write p𝑎q whenever (p,a,q)Δ. A run of 𝒜 on an input word w=a1an, where aiA{ε} for all i[n], is a sequence of transitions q0a1q1anqn. We use q0𝑤qn to denote this. The run is accepting if q0I and qnF. The language of 𝒜, denoted by L(𝒜), is the set of words w s.t. 𝒜 has an accepting run on w.

We say that a finite state automaton is complete if for every state qQ and for every input symbol aA, there exists qQ s.t. (q,a,q)Δ. An automaton is real-time if it has no transitions of the form p𝜀q. An automaton is said to be trim if, for any state q, there exists at least one accepting run visiting q. A finite state automaton is deterministic if I is a singleton set and the set of transitions is a (partial) function from Q×A to Q. The problem of checking equivalence is 𝖯𝖲𝖯𝖠𝖢𝖤-complete for nondeterministic finite state automata (NFA) [18] and in polynomial time for deterministic [17] finite state automata (DFA).

Finite state transducers.

Transducers extend finite state automata by labelling each transition and each final state by an output word (possibly empty), thereby realising word-to-word relations.

Definition 2.

A (nondeterministic) finite state transducer 𝒯 with input alphabet A and output alphabet B is a tuple (Q,A,B,I,Δ,F,λ,𝒪), where (Q,A,I,Δ,F) is a nondeterministic finite state automaton over A (also called the underlying automaton of 𝒯), λ:ΔB is a labelling function that maps transitions to output words over B, and 𝒪:QB is a labelling function that maps states to output words over B.

We write pav𝒯q, if (p,a,q)Δ and v=λ(p,a,q). When the transducer 𝒯 is clear from the context, we omit the subscript and simply write pavq. A run of 𝒯 labelled by an input word a1an, where aiA{ε} for all i[n], is a sequence of transitions q0a1v1q1anvnqn. We denote such a run by q0a1anv1vnqn. The output word along this run is v1vn𝒪(qn). The run is accepting if q0I and qnF. A loop rooted at state q of 𝒯 is a run of 𝒯 s.t. the run starts and ends at q. The relation defined/recognised by 𝒯, denoted as [[𝒯]]A×B, is defined as

[[𝒯]]={(u,v)vB is the output along some accepting run of 𝒯 labelled by u}.

Relations defined by transducers are called rational relations. For convenience, we use 𝒯(u) for [[𝒯]](u), and use 𝑑𝑜𝑚(𝒯) to denote 𝑑𝑜𝑚([[𝒯]]), called the domain of the transducer 𝒯. We say that a transducer is complete (resp. real-time, trim) if its underlying automaton is complete (resp. real-time, trim). The Cartesian product of two transducers 𝒯i=(Qi,A,B,Ii,Δi,Fi,λi,𝒪i) for i[2], denoted by 𝒯1×𝒯2, is defined as the transducer (Q1×Q2,A,(B{ε})×(B{ε}),I1×I2,Δ,F1×F2,λ,𝒪) where  ((p1,p2),a,(q1,q2))Δ if (pi,a,qi)Δi for each i[2], λ((p1,p2),a,(q1,q2))=(λ1(p1,a,q1),λ2(p2,a,q2)), and 𝒪(p1,p2)=(𝒪1(p1),𝒪2(p2)) for all (p1,p2)Q1×Q2.

We will now review some important subclasses of rational relations that capture natural restrictions on transducers encountered in this work.

Subclasses of rational relations.

Let 𝒯 be a real-time transducer. If [[𝒯]] is k-valued for some k, then 𝒯 is said to be finite-valued (or k-valued). The relations recognised by such transducers are called finite-valued rational relations. For example, the k-subword relation {(u,v)u,v{a,b},v is a subword of u of length k} is finite-valued. Since for any input word u, the number of possible outputs v is bounded by 2k, corresponding to all words of length k over the alphabet {a,b}.

If [[𝒯]] is functional, then 𝒯 is said to be a functional transducer. The functions recognised by functional transducers are called rational functions. An example is the function flast:uσσu where u{a,b},σ{a,b}; that moves the last letter of the input word to the beginning. If the underlying automaton of 𝒯 is unambiguous (i.e., has at most one accepting run on any input), then 𝒯 is referred to as an unambiguous transducer. It is well-known that a function is recognised by a real-time transducer iff it is recognised by a rational transducer [3] iff it is recognised by an unambiguous transducer [5].

A transducer is called sequential if its underlying automaton is deterministic. Such transducers define functions known as sequential functions. In this case, the transition relation Δ becomes a function Δ:Q×AQ. Sequential functions are a strict subset of rational functions. For instance, the function flast is not sequential since, intuitively, the transducer recognising flast must guess the last letter initially.

Any finite-valued transducer is known to be (effectively) equivalent to a finite union of unambiguous transducers [21]. Consequently, any finite-valued rational relation can be expressed as a finite union of rational functions. A notable strict subclass of finite-valued rational relations is the class of multi-sequential relations, which corresponds to a finite union of sequential functions [12]. A transducer is said to be multi-sequential if it is a finite union of state-disjoint sequential transducers. The function flast is multi-sequential as it can be expressed as the union of two sequential functions fa:uaau and fb:ubbu. However, the function f𝗅𝖺𝗌𝗍 that maps u1#un#, for n1, to f𝗅𝖺𝗌𝗍(u1)#f𝗅𝖺𝗌𝗍(un)# for some separator # is 1-valued, but not multi-sequential.

Distances between words and word relations.

A metric d on a set E is a mapping d:E2+{} satisfying the following properties. For any u,v,wE, d(u,v)=0u=v (separation), d(u,v)=d(v,u) (symmetry), and d(u,v)d(u,w)+d(w,v) (triangle inequality). The most commonly studied metrics between finite words are the edit distances. An edit distance between two words is the minimum number of edit operations required to rewrite one word into another if possible, and otherwise. Different choices of permitted operations give rise to different edit distances. Table 1 lists some commonly used edit distances along with their corresponding sets of allowed operations. They are referred to as the Levenshtein family of distances, as they are equivalent up to a constant factor [2].

Table 1: Levenshtein family of edit distances and their allowed operations.
Edit distances Notation Permissible edit operations
Longest Common Subsequence dlcs insertions and deletions
Levenshtein dl insertions, deletions and substitutions
Damerau-Levenshtein ddl insertions, deletions, substitutions and swapping adjacent letters

In the literature, the concept of distance between two words is naturally lifted to distance between a word and a set of words, or between two sets of words, and so on. The study of such extensions has received considerable attention in the literature. The distance between two languages L and L can be defined in a standard way, by resorting to the Hausdorff distance, denoted by Hd(L,L). Informally, it is defined to be the least upper bound of all the distances from an element in one set to the “closest element” in the other set. In order to precisely define the Hausdorff distance, we first introduce the notion of directed distance. The directed distance d from L to L is defined as d(L,L)=supwLinfwLd(w,w). The Hausdorff distance between L and L is defined as Hd(L,L)=max{d(L,L),d(L,L)}. Distances between words and languages can be lifted to that between relations over words.

Definition 3 (Distance between relations).

Given a metric d on words, and two relations R,SA×B, the distance between R and S, denoted as d(R,S), is defined as follows.

d(R,S)={sup{Hd(R(w),S(w))|w𝑑𝑜𝑚(R)}if 𝑑𝑜𝑚(R)=𝑑𝑜𝑚(S),otherwise.

It was shown in [6, 19] that d defines a metric over relations. Consequently, R and S are equivalent iff d(R,S)=0. Observe that d(R,S)< iff 𝑑𝑜𝑚(R)=𝑑𝑜𝑚(S) and there exists a constant k0 s.t. for every word u in the domain and for every output v1R(u), there exists some output v2S(u) with d(v1,v2)k, and vice-versa.

Example 4.

Consider the following rational relations R and S over {a,b}×{a,b} and d to be a metric given in Table 1.

  1. 1.

    Let R:w{a|w|,b|w|},S:w{a|w|}. For any input w, we have R(w)={a|w|,b|w|} and S(w)={a|w|}. Clearly, d(a|w|,a|w|)=0 and d(b|w|,a|w|)=|w|. Hence,

    Hd(R(w),S(w))=max{d(R(w),S(w)),d(S(w),R(w))}=max{|w|,0}=|w|.

    As the input length |w| increases, Hd(R(w),S(w)) increases unboundedly (since the edit distance between b|w| and a|w| increases with |w|). Therefore, d(R,S)=.

  2. 2.

    Let R:w{(ab)|w|,(ba)|w|},S:w{(ab)|w|}. For any input w, we have R(w)={(ab)|w|,(ba)|w|} and S(w)={(ab)|w|}. One can observe that d((ab)|w|,(ab)|w|)=0, while d((ba)|w|,(ab)|w|)=2 – obtained by deleting the initial b and inserting a b at the end – whenever |w|>0, and is 0 otherwise. Thus, Hd(R(w),S(w))2 for any input w, and hence d(R,S)=2.

The distance between transducers 𝒯 and 𝒮, denoted by d(𝒯,𝒮), is defined as the distance between the relations they recognise. In the case of edit distances, finite distance means that 𝑑𝑜𝑚(𝒯)=𝑑𝑜𝑚(𝒮) and for all input u𝑑𝑜𝑚(𝒯), any output of 𝒯 on u can be converted to an output of 𝒮 on u by doing a bounded number of edits, and conversely, any output of 𝒮 on u can be transformed into some output of 𝒯 on u with a bounded number of edits. This is relevant for comparing transducers with text-based output, such as spell checkers.

In general, the distance between two transducers is uncomputable. This follows from the undecidability of the equivalence problem for transducers [8], which reduces to checking whether the distance is zero. Notably, it has been shown in [2] that the distance between two functional transducers (or rational functions) is computable with respect to various edit distances, including the Levenshtein family of distances (See Table 1). An analysis of their proof gives a doubly exponential space upper bound for the Levenshtein family of distances. The computability of distance in this context relies on the notion of conjugacy of words [1].

Definition 5 (Conjugacy).

Two words u and v are conjugate, denoted by uv, if there exist words x and y s.t. u=xy and v=yx. In other words, they are cyclic shifts of each other.

For example, the words aabb and bbaa are conjugate with x=aa and y=bb, whereas aabb and abab are not conjugate. The conjugacy defines an equivalence relation over words.

Proposition 6.

Let x,y,x,y,u,v be words and C. For any metric d{dl,dlcs,ddl},
d(xuky,xvky)C for all k in some infinite subset 𝕀, iff u and v are conjugate.

Proof.

The proof for () is an adaptation of the proof of Proposition 2 from [6]. Since d(xuky,xvky)C, we get |u|=|v|. Otherwise, as k𝕀 increases, the length difference of xuky and xvky increases, and hence their distance will not be bounded. Since |u|=|v|, either both u and v are nonempty, or u=v=ϵ. In the latter case, u and v are conjugate. Assume that u and v are nonempty words. Take k𝕀 s.t. k2C. Since d(xuky,xvky)C, there exist large portions of u’s and v’s that match. In fact, u’s and v’s overlap at least of length |u|+|v|. By Fine and Wilf’s111The Fine and Wilf’s theorem states that if some powers of two words u and v share a common factor of length |u|+|v|gcd(u,v) then their primitive roots are conjugate. theorem, the primitive roots222The primitive root of a word w, denoted by ρw, is the shortest word s.t. w=(ρw)n for some n. of u and v are conjugate. Since |u|=|v|, it follows that u and v themselves are conjugate.

For the other direction (), assume u and v are conjugate, i.e., there exist words p,q s.t. u=pq and v=qp. Hence, for every k1, d(xuky,xvky)=d(x(pq)ky,x(qp)ky)d(xpy,xpy). This is finite for d{dl,dlcs,ddl}.

Proposition 7 ([2]).

Let 𝒯 and 𝒮 be functional transducers. For d{dl,dlcs,ddl}, d(𝒯,𝒮)< iff 𝑑𝑜𝑚(𝒯)=𝑑𝑜𝑚(𝒮) and every pair of output words generated by loops in the (trim) Cartesian product of 𝒯 and 𝒮 is conjugate.

3 Computing distance of finite-valued transducers

In this section, we address the problem of computing the distance between two finite-valued transducers. Our approach proceeds in two main steps. First, we show how to convert finite-valued transducers into multi-sequential transducers in such a way that the distance between the original transducers is preserved. Second, we show that the distance between multi-sequential transducers can be computed via a notion of relative distance, whose computability will be proved in the next section.

3.1 Edit distance: finite-valued to multi-sequential

We begin by reducing the problem of computing the edit distance between two finite-valued transducers to the analogous problem for multi-sequential transducers. Throughout, we assume that each finite-valued transducer is given as a disjoint union of finitely many unambiguous transducers. Given two such transducers, we first check if their domains are equal by testing the equivalence of their underlying nondeterministic automata, which is known to be 𝖯𝖲𝖯𝖠𝖢𝖤-complete [18]. If their domains are not equal, then their distance is infinite.

Lemma 8.

Let 𝒯 and 𝒮 be two finite-valued transducers with dom(𝒯)=dom(𝒮). There exist multi-sequential transducers 𝒯 and 𝒮, effectively constructible from 𝒯 and 𝒮, s.t. 𝑑𝑜𝑚(𝒯)=𝑑𝑜𝑚(𝒮) and d(𝒯,𝒮)=d(𝒯,𝒮) for any metric d given in Table 1.

Proof.

Assume that we have two finite-valued transducers 𝒯𝒯1𝒯m and 𝒮𝒮1𝒮n, each expressed as the union of m and n state-disjoint unambiguous transducers, respectively. Let L denote the common domain of 𝒯 and 𝒮. For i[m] and j[n] let 𝒯i=(Qi,A,B,si,Δi,Fi,λi,𝒪i), and 𝒮j=(Pj,A,B,tj,Γj,Gj,μj,ηj) where 𝒯i and 𝒮j are unambiguous transducers that are complete.

We define m+n sequential transducers Ti and Sj, for i[m] and j[n], whose underlying automaton is a product automaton 𝒜 that captures the synchronous runs of all components of T and S. The output labels of each Ti and Sj are defined depending on the outputs of Ti and Sj, respectively. Before giving the formal definition of the underlying product automaton 𝒜, we give an intuitive overview of its construction. The input alphabet of 𝒜 is over the tuples of transitions of all components of 𝒯 and 𝒮, i.e., Δ1××Δm×Γ1××Γn, and hence making the automaton deterministic. The states of 𝒜 track, for each component, (i) the state reached by the current run, and (ii) the set of states reachable on the corresponding input word. Final states are defined so that an accepting run of 𝒜 corresponds to a tuple of synchronous runs of all components of 𝒯 and 𝒮 on a common input word in their domain, s.t. (i) at least one component of 𝒯 and at least one component of 𝒮 is accepting, and (ii) for every component whose reachable state set contains a final state, the state reached by the current run of that component is itself final. This condition ensures that all accepting runs induced by an input word are realised simultaneously by a single global run in 𝒜.

Formally, 𝒜=(Q,A,s,Δ,F) where

  • Q=Q1××Qm×P1×Pn is the set of states of 𝒜 s.t. for i[m] and j[n], Qi=Qi×2Qi and Pj=Pj×2Pj. Each (q,M)Qi (similarly Pj) keeps track of two things: the state q reached in Ti (resp. Sj) on a run, and the set M of all states reachable in Ti (resp. Sj) on the input word read along this run.

  • A=Δ1××Δm×Γ1××Γn is the input alphabet of 𝒜.

  • s=((s1,{s1}),,(sm,{sm}),(t1,{t1}),,(tn,{tn})) is the initial state of 𝒜.

  • ΔQ×A×Q is the set of transitions of 𝒜 defined as follows.
    Let 𝐪=((q1,M1),,(qm,Mm),(p1,N1),,(pn,Nn)), σ=(δ1,,δm,γ1,,γn), and 𝐪=((q1,M1),,(qm,Mm),(p1,N1),,(pn,Nn)). The transition (𝐪,σ,𝐪)Δ iff there exists a letter aA s.t. the following conditions hold:

    • For each i[m], δi=(qi,a,qi)Δi is a transition in 𝒯i, and the set Mi={qqMi,(q,a,q)Δi} consists of all states in 𝒯i reachable on an a from the states in Mi.

    • For each j[n], γj=(pj,a,pj)Γj is a transition in 𝒮j, and the set Nj={qqNj,(q,a,q)Γj} consists of all states in 𝒮j reachable on an a from states in Nj.

  • F is the set of all final states of 𝒜 s.t. ((q1,M1),,(qm,Mm),(p1,N1),,(pn,Nn))F iff the following holds:

    • there exist an i[m] and j[n] s.t. qiFi and pjGj.

    • for all i[m], if MiFi, then qiFi.

    • for all j[n], if NjGj, then pjGj.

By construction, the language L(Δ1××Δm×Γ1××Γn) of 𝒜 consists of all sequences of tuples of the form ρ=(δ11,,δm1,γ11,,γn1)(δ1k,,δmk,γ1k,,γnk), for k1 s.t. for each [k], i[m], and j[n], we have δiΔi and γjΓj. Moreover, there exists a word w=a1ak (denoted by wρ) s.t.

  1. 1.

    For every [k], i[m], and j[n], the transitions δi and χj are taken on the same input letter a.

  2. 2.

    For all i[m], the sequence δi1,δik, is a valid run on w in Ti. Similarly, for all j[n], the sequence γj1,γjk, is a valid run on w in Sj.

  3. 3.

    There exists i[m] and j[n], s.t. the sequence δi1δik forms an accepting run of 𝒯 on w and γj1γjk forms an accepting run of 𝒮 on w.

  4. 4.

    For all i[m], if w𝑑𝑜𝑚(𝒯i), then δi1δik forms the unique accepting run of 𝒯i on w, denoted as ρ𝒯i. Similarly, for all j[n], if w𝑑𝑜𝑚(𝒮j), then γj1γjk forms the unique accepting run of 𝒮j on w, denoted as ρ𝒮j.

Using the product automaton defined above, we now define two multi-sequential transducers 𝒯𝒯1𝒯m and 𝒮𝒮1𝒮n as follows: for i[m],j[n], let 𝒯i=(Q,A,B,s,Δ,F,λi,𝒪i) and 𝒮j=(Q,A,B,s,Δ,F,μj,ηj) where

  • (Q,A,B,s,Δ,F)=𝒜.

  • For i[m],j[n], λi:ΔB and μj:ΔB are the output transition labelling functions of of 𝒯i and 𝒮j respectively and are defined as follows. If ψ=(𝐪,(δ1,,δm,γ1,,γn),𝐪)Δ, then λi(ψ)=λi(δi) and μj(ψ)=μj(γj).

  • For all i[m],j[n], 𝒪i:QB and ηj:QB are the output state labelling functions of 𝒯i and 𝒮j respectively and are defined as follows:

    𝒪i((q1,M1),,(qm,Mm),(p1,N1),,(pn,Nn))=𝒪i(qi) and
    ηj((q1,M1),,(qm,Mm),(p1,N1),,(pn,Nn))=ηj(qj).

Each 𝒯i (resp. 𝒮j) simply projects the i-th output of 𝒯i (resp. j-th output of 𝒮j) along the synchronous run. Since both 𝒯 and 𝒮 have the same underlying automaton 𝒜, 𝑑𝑜𝑚(𝒯)=𝑑𝑜𝑚(𝒮)=𝑑𝑜𝑚(𝒜). It remains to show that d(𝒯,𝒮)=d(𝒯,𝒮). Observe that there is a correspondence between L and L. For each wL, there is a ρL (with wρ=w) s.t. 𝒯(w)=𝒯(ρ) and 𝒮(w)=𝒮(ρ). This follows since, by construction of final state of 𝒜, for all i[m], if w𝑑𝑜𝑚(𝒯i) then ρ𝒯i is an accepting run of 𝒯i on w, and likewise, for all j[n], if w𝑑𝑜𝑚(𝒮j) then ρ𝒮j is an accepting run of 𝒮j on w. Note that ρ is not necessarily unique (since there could be some non-determinism in a rejecting component leading to different sequences of transitions), however, the set of outputs remains the same for ρ and w. Similarly, for each ρL, there exists a unique wL s.t. w=wρ, and 𝒯(w)=𝒯(ρ) and 𝒮(w)=𝒮(ρ). Thus, {d(𝒯(w),𝒮(w))|wL}={d(𝒯(ρ),𝒮(ρ))|ρL}. Hence, we conclude that d(𝒯,𝒮)=d(𝒯,𝒮).

3.2 Edit distance of multi-sequential transducers

In this subsection, we present the computability of the edit distance for multi-sequential relations, which form a subclass of finite-valued relations. This result will be used to address the computability of the edit distance for general finite-valued relations by virtue of Lemma 8.

Our approach reduces the problem of computing the edit distance between multi-sequential relations (or multi-sequential transducers) to computing the relative distance (see Definition 9) between a sequential function and a multi-sequential relation.

Definition 9 (Relative distance).

Let d be a metric over words. The relative distance from a function f to a relation R w.r.t. d, denoted by d(f,R), is defined as the least upper bound of the minimal distance between the output of f and some output of R on each input.

d(f,R)={sup{inf{d(f(u),v)vR(u)}|u𝑑𝑜𝑚(f)}if 𝑑𝑜𝑚(f)𝑑𝑜𝑚(R)otherwise

The notion of relative distance is analogous to that of the directed distance defined for languages. The following lemma shows how to compute the edit distance between two multi-sequential relations using the notion of relative distance. We assume that the multi-sequential relation is given by a finite union of sequential functions.

Lemma 10.

Let Rf1fm and Sg1gn be two multi-sequential relations where fi and gj are sequential functions for all i[m] and j[n]. Then, for any integer-valued metric d,

d(R,S)={max({d(fi,S)i[m]}{d(gj,R)j[n]})if 𝑑𝑜𝑚(R)=𝑑𝑜𝑚(S)otherwise

Proof.

There are two cases to consider.

Case 1: d(R,S)=.

Assume for contradiction that

max({d(fi,S)i[m]}{d(gj,R)j[n]})k for some k0.

Thus, 𝑑𝑜𝑚(R)=𝑑𝑜𝑚(S). Moreover, by definition of relative distance, we can deduce that for any input u and for any output vR(u), there exists an output vS(u) s.t. d(v,v)k, and vice-versa. By Definition 3, we get that d(R,S)k, which is a contradiction.

Case 2: d(R,S)=k for some k0.

For any input u and any output vR(u), there exists an output vS(u) s.t. d(v,v)k, and vice-versa. Hence, for all i[m], d(fi,S)k and for all j[n], d(gj,R)k. Since d(R,S)=k, there exist an input u, s.t. Hd(R(u),S(u))=k. This implies that there exists an i[m],j[n] s.t. either d(fi,S)=k or d(gj,R)=k. Hence, max({d(fi,S)i[m]}{d(gj,R)j[n]})=k=d(R,S).

This completes the proof of the lemma.

We introduced the notion of relative distance since the distance d(R,S) cannot be expressed in terms of d(fi,S) and d(gj,R) (instead of d(fi,S) and d(gj,R)). For instance, consider Rfg, where f,g:AB are sequential functions defined as: f(w)=a|w|, g(w)=b|w| for all wA. Since d is a metric, d(R,R)=0. However, both d(f,R) and d(g,R) are infinite. Note that the distance between a function f and a relation R is finite iff, for every input u, the distance between f(u) and all outputs in R(u) are bounded.

The next section is dedicated to showing that the relative distance between a sequential function and a multi-sequential relation with respect to metrics d given in Table 1 is computable (see Theorem 13). As a consequence, we obtain the following result using Lemma 8 and Lemma 10.

Theorem 11.

The distance between two finite-valued rational relations with respect to any metric given in Table 1 is computable.

4 Computing relative distance

We show that the problem of computing the relative distance of a function f to a relation R can be reduced to two boundedness problems: (1) deciding whether it is finite (finiteness) and, (2) if finite, whether it is bounded by a given constant k (k-finiteness). This formulation, along with its proof, closely follows Proposition 3.6 in [2].

Proposition 12.

Let d be an integer-valued metric, f a function, and R a relation. The relative distance d(f,R) is computable iff it is decidable whether
(1) d(f,R)<,   and   (2) d(f,R)k for some k0.

Proof.

Clearly, if the relative distance d(f,R) with respect to d is computable, then we can decide whether d(f,R)< and whether d(f,R)k for some k0. For the converse, assume decidability of the two boundedness problems. Given a function f and a relation R, we first check whether d(f,R)<. If it is not, then d(f,R)=. Otherwise, we perform an exponential search: check whether d(f,R)k for k=20,21,22, until the condition fails. Once an interval containing the relative distance is found, we perform a binary search on the interval [2n,2n+1], n to determine the exact value of d(f,R).

We show in the upcoming subsections that both finiteness and k-finiteness of relative distance of a sequential function to a multi-sequential relation w.r.t. Levenshtein family of distances are decidable (See Lemma 16 and 17). Hence, using Proposition 12, we get

Theorem 13.

Let f be a sequential function, and R be a multi-sequential relation. The relative distance of a d(f,R) is computable for d{dl,dlcs,ddl}.

4.1 Deciding finiteness of relative distance

We will now show that given a sequential function f and a multi-sequential relation R, the problem of deciding whether d(f,R)< is decidable. The first step is to check whether 𝑑𝑜𝑚(f)𝑑𝑜𝑚(R); this reduces to the language inclusion problem of their underlying automata, which is decidable [18]. If 𝑑𝑜𝑚(f)𝑑𝑜𝑚(R), then d(f,R)=.

Partitioning the domain of 𝒇.

Now, consider the case where 𝑑𝑜𝑚(f)𝑑𝑜𝑚(R). Assume that the multi-sequential relation R is given as the union of m (complete) sequential transducers, D1,Dm. We partition 𝑑𝑜𝑚(f) into 2m1 classes, where each class is labelled by a nonempty subset of [m]. We denote the set of classes in the partition by 𝒫={P[m]P}. For each P[m], the corresponding class CP contains exactly those words w𝑑𝑜𝑚(f) such that w𝑑𝑜𝑚(Di) for every iP, and w𝑑𝑜𝑚(Dj) for every j[m]P. The set {CP}P𝒫 forms a partition of 𝑑𝑜𝑚(f), i.e., 𝑑𝑜𝑚(f)=P𝒫CP. Let f|P denote the function f restricted to CP. It is straightforward to observe that

d(f,R)=max{d(f|P,R)P𝒫}. (1)

For checking whether d(f,R)<, it now suffices to check whether d(f|P,R)< for each P𝒫. Finiteness of relative distance is solved using structural arguments based on conjugacy and SCC decompositions. Since R is multi-sequential, different input words may belong to the domain of different component transducers Di. Fixing a partition P allows us to restrict the structural arguments (particularly Claim 14 and 15) to only those components in P that accept the set of input words CP within the domain of f.

Checking whether 𝒅(𝒇|𝑷,𝑹)<.

Fix a P𝒫. We construct a product transducer 𝒯, defined as the Cartesian product of the transducers given by f and R. Let the sequential function f be defined by a (complete) sequential transducer D0=(Q0,A,B,Δ0,s0,F0,λ0,𝒪0), and let the multi-sequential relation R be given as the union of m (complete) sequential transducers Di=(Qi,A,B,Δi,si,Fi,λi,𝒪i)for i[m],m. The product transducer 𝒯 is defined as follows,

𝒯=(Q,A,B,Δ,s,F,λ,𝒪), where
  • Q=Q0×Q1××Qm is the set of states,

  • B=(B{ε})××(B{ε})m+1 times is the output alphabet,

  • s=(s0,s1,,sm) is the initial state,

  • Δ={((q0,q1,,qm),a,(p0,p1,,pm))i{0,1,,m},(qi,a,pi)Δi} is the set of transitions,

  • F={(q0,q1,,qm)q0F0 and i[m],qiFiiP} is the set of final states,

  • λ is the output transition labelling function where λ((q0,q1,,qm),a,(p0,p1,,pm))=(v0,v1,,vm) if vi=λi(qi,a,pi) for i{0,1,,m}, and

  • 𝒪 is the output state labelling function and is defined as

    𝒪(q0,q1,,qm)=(𝒪0(q0),𝒪1(q1),,𝒪m(qm)).

Note that the constructed product transducer 𝒯 is sequential and 𝑑𝑜𝑚(𝒯)=𝑑𝑜𝑚(f|P)=CP. WLOG, we further assume that 𝒯 is trim for the remainder of our proofs.

Figure 1: A sequential transducer D recognising the function f:σuσ|u|+1; a multi-sequential transducer D1D2 recognising the relation g:u{a|u|,b|u|}; and their product transducer 𝒯 w.r.t. unique partition P={1,2} where CP=𝑑𝑜𝑚(f).

The idea is to reduce the problem of checking whether d(f|P,R)< to several instances of checking whether the distance between two sequential transducers is finite. Checking finiteness of distance for functional transducers w.r.t. Levenshtein family was based on the notion of conjugacy in loops (See Propositions 6 and 7). Conjugacy in loops is also necessary in the context of relative distance, as stated in the following claim. Towards this, we define connected loops. Two loops of 𝒯, rooted at states q1 and q2 respectively, are connected if there exists a path between q1 and q2 in 𝒯. Extending this notion to sets of loops, we say that a set of loops is connected in 𝒯 if there exists a run of 𝒯 such that all loops in the set appears in the run.

Claim 14.

Let L be a set of connected loops in 𝒯. For each loop lL, let (v0l,v1l,,vml) denote the corresponding output tuple produced along that loop. If d(f|P,R)<, then there exists a common index iP s.t. v0l and vil are conjugate for every lL.

Proof.

Assume d(f|P,R)=K for a constant K0. Let l1 and l2 be two connected loops rooted at states q1 and q2, respectively. Without loss of generality, assume that there is a path from l1 to l2 in 𝒯. Since 𝒯 is trim, there exist words u,v,u,v,w, an accepting state qf and some output tuples
(u0,u1,,um),(v0,v1,,vm),(u0,u1,,um),(v0,v1,,vm),(w0,w1,,wm), such that

su|(u0,,um)q1v|(v0,,vm)q1u|(u0,,um)q2v|(v0,,vm)q2w|(w0,,wm)qf.

Since d(f|P,R)=K, for every input word in 𝑑𝑜𝑚(f|P), the edit distance between the output of f|P and some output of R is less than or equal to K. In particular, for each input of the form uvk1uvk2w with k1,k20, there exists an index jP s.t. d(u0v0k1u0v0k2w0,ujvjk1ujvjk2wj)K. We restrict only to indices in P since the input word in 𝑑𝑜𝑚(f|P)=CP will not be accepted by any transducer Dj for j[m]P (by definition of the partition P).

Finding indices conjugate to 𝒗𝟎 and 𝒗𝟎 in 𝑷.

First, increase k1 while keeping k2=1. By the pigeonhole principle, since |P| is finite, there exists an index i1P and an infinite subset I s.t. for all k1I, d(u0v0k1u0v0w0,ui1vi1k1ui1vi1wi1)K. Applying Proposition 6, we conclude that v0 is conjugate to vi1. Let J1={jPv0vj} denote the set of all indices in P whose outputs are conjugate to v0. By a symmetric argument by fixing k1=1 and increasing k2, we get the set J2={jPv0vj}, the set of indices in P whose outputs are conjugate to v0.

Existence of a common index in 𝑷.

Assume for contradiction that there is no common index iP such that v0vi and v0vi, i.e., J1J2=. We show that, for all iP, d(u0v0k1u0v0k2w0,uivik1uivik2wi)>K when k1,k2 are sufficiently large (say 2K). Since J1J2=, for any i[m], exactly one of the following three cases holds:

  1. Case-1:

    iJ1, iJ2. Here v0vi but v0≁vi. So for sufficiently large k2, the edit distance d(u0v0k1u0v0k2w0,uivik1uivik2wi) grows unboundedly (Proposition 6), contradicting
    d(u0v0k1u0v0k2w0,uivik1uivik2wi)K.

  2. Case-2:

    iJ1, iJ2. Here v0≁vi but v0vi. So for sufficiently large k1, the distance d(u0v0k1u0v0k2w0,uivik1uivik2wi) becomes unbounded, again contradicting
    d(u0v0k1u0v0k2w0,uivik1uivik2wi)K.

  3. Case-3:

    iJ1J2. Here v0≁vi and v0≁vi, for sufficiently large k1 and k2, the distance becomes unbounded contradicting d(u0v0k1u0v0k2w0,uivik1uivik2wi)K.

Since all three cases lead to a contradiction, there must exist a common index iP such that v0vi and v0vi. This proof can be generalised to any set of loops that occur along a single run, that is, to any set of connected loops.

Claim 14 holds when the loops are connected and need not be true for all loops of a trim transducer 𝒯. For instance, the loops in the product transducer 𝒯, depicted in Figure 1, rooted at states q2pr and q3pr are disjoint and have no common index witnessing conjugacy: in the former loop the outputs of 𝒟 and 𝒟1 are conjugate, whereas in the latter they are not.

Now, in order to decide whether d(f|P,R)<, we decompose 𝒯 into a directed acyclic graph of maximal strongly connected components (SCCs) S1,,SrQ for some r disregarding the labels on the transitions. Consider the set of paths Π, where each πΠ is of the form Si1ti1Si2tin1Sin where Si1 is an SCC that contains an initial state, Sin is an SCC that contains a final state, and for all 1k<n, tik is a transition of 𝒯 from a state in Sik to some state in Sik+1. Let 𝒯π denote the trim subtransducer of 𝒯 obtained by removing all the transitions in 𝒯 except the transitions tik (1k<n) and the transitions within the SCCs Sik for k[n]. Note that since the SCCs are maximal, the set Π is finite. Now, it is straightforward to see that 𝒯πΠ𝒯π.

For each i{0,,m}, let 𝒯π(i) denote the transducer obtained from 𝒯π by projecting the output labelling functions to the i-th component in the output of Tπ. That is, a transition δ in 𝒯π labelled with the output tuple (v0,v1,,vm) is labelled with vi in 𝒯π(i). Similarly, a state q in 𝒯π labelled with the output tuple (v0,v1,,vm) is labelled with vi in 𝒯π(i). Note that 𝑑𝑜𝑚(𝒯π(i))=𝑑𝑜𝑚(𝒯).

Claim 15.

d(f|P,R)< iff for all paths πΠ, iP s.t. d(𝒯π(0),𝒯π(i))<.

Proof.

() Assume that for each path πΠ, there is an index iπP s.t. d(𝒯π(0),𝒯π(iπ))=kπ for some kπ0. Since 𝒯 is sequential and 𝒯πΠ𝒯π, every input word w is accepted by a unique path πwΠ. In fact, w is accepted by 𝒯πw(i) for all iP since 𝑑𝑜𝑚(f|P)=𝑑𝑜𝑚(𝒯)=CP. Thus, for any w, the edit distance between f(w) and some output of R(w) is bounded by kπw. Hence, d(f|P,R)max{kππΠ}.

() Assume d(f|P,R)<. A path πΠ is of the form S1t1S2t2Sn, where S1 contains an initial state, Sn contains a final state, and every Sj (j[n]) is strongly connected. Hence, all loops in π are connected. By Claim 14, there exists an index iP s.t. for every output tuple (v0,v1,,vm) produced along a loop of 𝒯π, the words v0 and vi are conjugate. This implies that the Cartesian product of 𝒯π(0) and 𝒯π(i) produces only conjugate pairs of output words. Also, 𝑑𝑜𝑚(𝒯π(0))=𝑑𝑜𝑚(𝒯π(i))=𝑑𝑜𝑚(𝒯). By Proposition 7, we get d(𝒯π(0),𝒯π(i))<.

By virtue of the above claim, checking whether d(f|P,R)< reduces to computing d(𝒯π(0),𝒯π(i)) for all iP and all πΠ, and verifying that for each path πΠ, there exists some iP s.t. d(𝒯π(0),𝒯π(i))<. Since 𝒯 is sequential, each 𝒯π(i) for i{0,1,,m} and πΠ is also sequential. Therefore, computing d(𝒯π(0),𝒯π(i)) amounts to computing the edit distance between sequential transducers, which is decidable [2]. Consequently, using Equation 1, we get the following Lemma.

Lemma 16.

Given a sequential function f and a multi-sequential relation R, it is decidable whether the relative distance d(f,R) is finite for any metric d{dl,dlcs,ddl}.

4.2 Deciding k-finiteness of relative distance

In the next lemma, we prove that the k-finiteness of relative distance is decidable. The proof is a generalisation of the proof used for checking whether the edit distance between two sequential functions is at most a given k (Proposition 3.11, [2]).

Lemma 17.

For a given k, it is decidable to check whether the relative distance between a sequential function and a multi-sequential relation is less than or equal to k with respect to any metric d given in Table 1.

Proof.

Given a sequential function f and a multi-sequential relation R over the output alphabet B, we begin by checking whether 𝑑𝑜𝑚(f)𝑑𝑜𝑚(R); if so, we construct the product transducer 𝒯=(Q,A,B,s,Δ,F,λ,𝒪), whose domain is 𝑑𝑜𝑚(f)𝑑𝑜𝑚(R), and on each input word, produces an (m+1)-tuple consisting of the output of f together with the outputs of the m sequential transducers whose union defines R. Let L be the domain of 𝒯. For each i{0,1,,m}, let 𝒯i=(Q,A,B,s,Δ,F,λi,𝒪i) denote the transducer obtained from 𝒯 by projecting the output labelling functions to the i-th component of the (m+1)-tuple. i.e., for all q,qQ and aB, if λ(q,a,q)=(v0,v1,,vm), then λi(q,a,q)=vi. Similarly, for all qQ, if 𝒪(q)=(v0,v1,,vm), then 𝒪i(q)=vi.

Observe that d(f,R)k for k iff for all wL we can perform at most k edits to 𝒯0(w) and obtain 𝒯i(w) for some i[m].

First, we check whether d(f,R)<. If so, there exists a maximum length difference, denoted by max, between the partial outputs of 𝒯0 and 𝒯i for some i[m] on any input. In fact, max=N, where N is the number of states in 𝒯 and is the maximum length difference between outputs of 𝒯0 and 𝒯i (for all i[m]) along any transitions. Assume for contradiction that there exists a partial input u with output tuple (v0,,vm) s.t.mod(|v0||vi|)>max for all i[m]. Since each transition can contribute at most , the length difference on u between outputs of 𝒯0 and any 𝒯i is bounded by |u|. If |u|>N, then |u|>N, and some state repeats along the run of u in 𝒯. For each i[m], there exists a loop where the length difference between the outputs of 𝒯0 and 𝒯i increases; otherwise, it contradicts the fact thatmod(|v0||vi|)>N. The idea then is to show that pumping all the loops encountered during the run of u in 𝒯 will strictly increase the length difference between the outputs of 𝒯0 and 𝒯i for all i[m] contradicting d(f,R)<.

For each metric d{dl,dlcs,ddl}, fix the corresponding set of allowed edits C. In order to determine whether the relative distance is at most k, we construct a nondeterministic finite state automaton 𝒜C,k. The automaton reads words wL and accepts w if there exists i[m] s.t. the output 𝒯i(w) can be obtained from 𝒯0(w) using at most k edits from C. The NFA 𝒜C,k=(Q,A,s,Δ,F) is defined as follows.

  • The states Q of 𝒜C,k are tuples (q,(b1,,bm),(L1,,Lm)), where q is a state of 𝒯; for each i[m], bi{0,,k} denotes the remaining edit budget associated with 𝒯i; and Li records the current unmatched leftover between the outputs of 𝒯0 and 𝒯i. Formally, for each each i[m], a leftover Li is either an element of (B×{ϵ})({ϵ}×B) or the special symbol x. If Li=(ui,ϵ), then ui is the unmatched suffix of the output of 𝒯0 that has not yet been matched with the output of 𝒯i. If Li=(ϵ,ui), then ui is the unmatched suffix of the output of 𝒯i that has not yet been matched with the output of 𝒯0. Since the edits in C are local, the alignment must eventually match a common prefix, leaving an unmatched suffix on only one side. If Li=x, it indicates that the length of the unmatched output exceeds the threshold max(max,k) and can no longer be matched. We restrict to states for which at least one Lix.

  • The initial state is s=(s,(k,,k),((ϵ,ϵ),,(ϵ,ϵ))), where s is the initial state of 𝒯.

  • The transition ((q,(b1,,bm),(L1,,Lm)),σ,(q,(b1b1,,bmbm),(L1,,Lm))) is in Δ if there exists a transition δ=(q,σ,q) of 𝒯 with outputs λ0(δ) for 𝒯0 and λi(δ) for 𝒯i such that, for every i[m], the following holds. The automaton nondeterministically chooses bibi and attempts a partial match using bi edits from C:

    • if Li=(ϵ,u), then (λ0(δ),uλi(δ)) is partially matched using bi edits;

    • if Li=(u,ϵ), then (uλ0(δ),λi(δ)) is partially matched using bi edits.

    The unmatched suffix resulting from this partial match determines the new leftover Li; if its length exceeds max(max,k), then Li=x, otherwise Li is the resulting unmatched pair. If Li=x or no suitable bibi exists, then we set bi=0 and Li=x. The transition updates the edit budgets to (b1b1,,bmbm) and the leftovers to (L1,,Lm).

  • The set of accepting states is defined as F={(q,(b1,,bm),(L1,,Lm))QAq is a final state of 𝒯 and there exists at least one Li=(u,v)x with bi0 and  d(u𝒪0(qf),v𝒪i(qf))bi}.

Note that for every word w accepted by the NFA 𝒜C,k, there exists an index i[m] such that Lix, bi0, and d(u𝒪0(qf),v𝒪i(qf))bi}. This implies that the distance between the outputs of 𝒯0 and 𝒯i for the input w is at most k. This bound is witnessed by the sequence of edit operations encoded along the accepting run of 𝒜C,k. Consequently, 𝒜C,k accepts exactly those words in the domain of 𝒯 for which the distance between 𝒯0 and 𝒯i is bounded by k for some i[m]. Therefore, to determine whether the relative distance between the transducers is at most k, it suffices to check whether 𝑑𝑜𝑚(𝒯)=𝑑𝑜𝑚(𝒜C,k). In other words, the relative distance between f and R with respect to C is at most k if and only if L(𝒜C,k)=L.

5 Discussion and conclusion

In this work, we showed that the edit distance between finite-valued transducers is computable, extending the class of transducers for which edit distance computation is known to be decidable. The algorithm we present establishes decidability, but it is not optimised for efficiency. On analysing the algorithm, the first step of reducing the edit distance problem for finite-valued transducers (given by union of functional transducers) to multi-sequential transducers uses exponential space. Computing the edit distance for the resulting multi-sequential transducers then involves multiple instances of relative distance computation. Each instance requires deciding k-finiteness, which incurs another exponential blow-up in space, and checking the finiteness of the relative distance through a product automaton and distance computation for functional transducers, which requires doubly exponential space. Overall, these steps result in a 3-𝖤𝖷𝖯𝖲𝖯𝖠𝖢𝖤 procedure. Regarding the lower bound, computing the edit distance between two finite-valued transducers is at least as hard as checking their equivalence. This is because checking whether two transducers are equivalent reduces to computing their edit distance and verifying that it is zero. This problem is known to be PSPACE-hard. This follows from the fact that equivalence checking for nondeterministic automata – known to be PSPACE-complete [18] – can be reduced to equivalence checking for nondeterministic functional (i.e., 1-valued) transducers. Even for functional transducers, no better lower bound than PSPACE-hardness is known for computing the edit distance, while the best known upper bound is 2-EXPSPACE. In our setting, we rely on this result to compute the edit distance of multi-sequential transducers and incur an additional EXPSPACE overhead when reducing finite-valued transducers to the multi-sequential case. Improving the efficiency of this approach remains an important direction for future work.

The computation of relative distance for the metrics in Table 1 relies on a characterisation connecting finiteness of edit distance with conjugacy (see Propositions 6 and 7). This property does not extend to all edit metrics; for instance, it fails for Hamming distance, where only substitutions are allowed. Nevertheless, all results except Lemma 16 remain valid for Hamming distance. Lemma 16 can be adapted using existing characterisations of Hamming distance (see Theorem 4.10 in [2] and Lemma 3.6 in [6]). More generally, the method for computing relative distance depends on the set of allowed edit operations, and extending our techniques to more general distance notions is a natural direction for future work.

Promising directions for future work include improving the complexity of our constructions, extending to other distance measures, and adapting these methods to quantify approximate behaviours in broader classes of rational relations.

References

  • [1] C. Aiswarya, Amaldev Manuel, and Saina Sunny. Deciding conjugacy of a rational relation - (extended abstract). In Joel D. Day and Florin Manea, editors, Developments in Language Theory - 28th International Conference, DLT 2024, Göttingen, Germany, August 12-16, 2024, Proceedings, volume 14791 of Lecture Notes in Computer Science, pages 37–50. Springer, 2024. doi:10.1007/978-3-031-66159-4_4.
  • [2] C. Aiswarya, Amaldev Manuel, and Saina Sunny. Edit distance of finite state transducers. In Karl Bringmann, Martin Grohe, Gabriele Puppis, and Ola Svensson, editors, 51st International Colloquium on Automata, Languages, and Programming, ICALP 2024, Tallinn, Estonia, July 8-12, 2024, volume 297 of LIPIcs, pages 125:1–125:20. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2024. doi:10.4230/LIPIcs.ICALP.2024.125.
  • [3] Jean Berstel. Transductions and context-free languages, volume 38 of Teubner Studienbücher : Informatik. Teubner, 1979. URL: https://www.worldcat.org/oclc/06364613.
  • [4] Rodrigo de Souza. On the decidability of the equivalence for k-valued transducers. In Masami Ito and Masafumi Toyama, editors, Developments in Language Theory, 12th International Conference, DLT 2008, Kyoto, Japan, September 16-19, 2008. Proceedings, volume 5257 of Lecture Notes in Computer Science, pages 252–263. Springer, 2008. doi:10.1007/978-3-540-85780-8_20.
  • [5] Samuel Eilenberg. Automata, languages, and machines. A. Pure and applied mathematics. Academic Press, 1974. URL: https://www.worldcat.org/oclc/310535248.
  • [6] Emmanuel Filiot, Ismaël Jecker, Khushraj Madnani, and Saina Sunny. Approximate problems for finite transducers. In Keren Censor-Hillel, Fabrizio Grandoni, Joël Ouaknine, and Gabriele Puppis, editors, 52nd International Colloquium on Automata, Languages, and Programming, ICALP 2025, Aarhus, Denmark, July 8-11, 2025, volume 334 of LIPIcs, pages 155:1–155:19. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2025. doi:10.4230/LIPIcs.ICALP.2025.155.
  • [7] Emmanuel Filiot and Pierre-Alain Reynier. Transducers, logic and algebra for functions of finite words. ACM SIGLOG News, 3(3):4–19, 2016. doi:10.1145/2984450.2984453.
  • [8] Patrick C. Fischer and Arnold L. Rosenberg. Multitape one-way nonwriting automata. Journal of Computer and System Sciences, 2(1):88–101, 1968. doi:10.1016/S0022-0000(68)80006-6.
  • [9] Seymour Ginsburg and Gene F. Rose. A characterization of machine mappings. Journal of Symbolic Logic, 33(3):468–468, 1968. doi:10.2307/2270340.
  • [10] Eitan M. Gurari and Oscar H. Ibarra. A note on finitely-valued and finitely ambiguous transducers. Mathemtical Systems Theory, 16(1):61–66, 1983. doi:10.1007/BF01744569.
  • [11] Karel Culík II and Juhani Karhumäki. The equivalence of finite valued transducers (on HDT0L languages) is decidable. Theoretical Computer Science, 47(3):71–84, 1986. doi:10.1016/0304-3975(86)90134-9.
  • [12] Ismaël Jecker and Emmanuel Filiot. Multi-sequential word relations. International Journal of Foundations of Computer Science, 29(2):271–296, 2018. doi:10.1142/S0129054118400075.
  • [13] Anca Muscholl and Gabriele Puppis. The many facets of string transducers (invited talk). In Rolf Niedermeier and Christophe Paul, editors, 36th International Symposium on Theoretical Aspects of Computer Science, STACS 2019, Berlin, Germany, March 13-16, 2019, volume 126 of LIPIcs, pages 2:1–2:21. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, 2019. doi:10.4230/LIPIcs.STACS.2019.2.
  • [14] George N. Raney. Sequential functions. Journal of the ACM, 5(2):177–180, 1958. doi:10.1145/320924.320930.
  • [15] Jacques Sakarovitch and Rodrigo de Souza. On the decidability of bounded valuedness for transducers. In Edward Ochmanski and Jerzy Tyszkiewicz, editors, Mathematical Foundations of Computer Science 2008, 33rd International Symposium, MFCS 2008, Torun, Poland, August 25-29, 2008, Proceedings, volume 5162 of Lecture Notes in Computer Science, pages 588–600. Springer, 2008. doi:10.1007/978-3-540-85238-4_48.
  • [16] Jacques Sakarovitch and Rodrigo de Souza. On the decomposition of k-valued rational relations. In Susanne Albers and Pascal Weil, editors, Proceedings of the 25th Annual Symposium on Theoretical Aspects of Computer Science, STACS 2008, Bordeaux, France, February 21-23, 2008, volume 1 of LIPIcs, pages 621–632. Schloss Dagstuhl – Leibniz-Zentrum für Informatik, Germany, 2008. doi:10.4230/LIPIcs.STACS.2008.1324.
  • [17] Richard Edwin Stearns and Harry B. Hunt III. On the equivalence and containment problems for unambiguous regular expressions, regular grammars and finite automata. SIAM Journal on Computing, 14(3):598–611, 1985. doi:10.1137/0214044.
  • [18] Larry J. Stockmeyer and Albert R. Meyer. Word problems requiring exponential time: Preliminary report. In Alfred V. Aho, Allan Borodin, Robert L. Constable, Robert W. Floyd, Michael A. Harrison, Richard M. Karp, and H. Raymond Strong, editors, Proceedings of the 5th Annual ACM Symposium on Theory of Computing, April 30 - May 2, 1973, Austin, Texas, USA, pages 1–9. ACM, 1973. doi:10.1145/800125.804029.
  • [19] Saina Sunny. Distance and Conjugacy of Word Transducers. PhD thesis, School of Mathematics and Computer Science, Indian Institute of Technology (IIT) Goa, India, 2025. available at https://saisunny1994.github.io/pdfs/ThesisSigned.pdf.
  • [20] Andreas Weber. On the valuedness of finite transducers. Acta Informatica, 27(8):749–780, 1990. doi:10.1007/BF00264285.
  • [21] Andreas Weber. Decomposing finite-valued transducers and deciding their equivalence. SIAM Journal on Computing, 22(1):175–202, 1993. doi:10.1137/0222014.