Synthesizing Computable Functions from Rational Specifications over Infinite Words

The synthesis problem asks to automatically generate, if it exists, an algorithm from a specification of correct input-output pairs. In this paper, we consider the synthesis of computable functions of infinite words, for a classical Turing computability notion over infinite inputs. We consider specifications which are rational relations of infinite words, i.e., specifications defined non-deterministic parity transducers. We prove that the synthesis problem of computable functions from rational specifications is undecidable. We provide an incomplete but sound reduction to some parity game, such that if Eve wins the game, then the rational specification is realizable by a computable function. We prove that this function is even computable by a deterministic two-way transducer. We provide a sufficient condition under which the latter game reduction is complete. This entails the decidability of the synthesis problem of computable functions, which we prove to be ExpTime-complete, for a large subclass of rational specifications, namely deterministic rational specifications. This subclass contains the class of automatic relations over infinite words, a yardstick in reactive synthesis.


Introduction
Program synthesis aims at automatically generating programs from specifications. This problem can be formalized as follows. There are four parameters: two sets of input and output domains I, O, a set S of relations (called specifications) from I to O, and a set I of (partial) functions (called implementations) from I to O. Then, given a specification S ∈ S defining the correct input/output relationships, the synthesis problem asks to check whether there exists a function f ∈ I satisfying S in the following sense: its graph is included in S and it has the same domain as S (i.e., f is defined on x ∈ I iff (x, y) ∈ S for some y ∈ O). Using a set-theoretic terminology, f is said to uniformize S. Moreover in synthesis, if such an f exists, then the synthesis algorithm should return (a finite presentation of) it.
Program synthesis quickly turns to be undecidable depending on the four parameters mentioned before. Therefore, research on synthesis either turn to developing efficient sound but incomplete methods, see for example the syntax-guided synthesis approach [2] or bounded synthesis [14,15], or restrict the class of specifications S and/or the class of implementations I. A well-known example of the latter approach is reactive synthesis, where S are automatic relations 1 over infinite words, and I are Mealy machines [6,23,10]. Infinite words (over a finite alphabet) are used to model infinite executions of reactive systems, and Mealy machines are used as a model of reactive systems processing bit streams.
In this paper, our goal is to synthesize, from specifications which are semantically binary relations of infinite words, stream-processing programs, which are semantically streaming computable functions of infinite words (just called computable functions in the sequel). Let us now make the computability notion we use more precise. Let Σ and Γ be to finite alphabets.
A partial function f : Σ ω → Γ ω , whose domain is denoted dom(f ), is said to be computable, if there exists a deterministic (Turing) machine M with three tapes, a read-only one-way input tape, a two-way working tape, and a write-only output tape that works as follows: if the input tape holds an input sequence α ∈ dom(f ), then M outputs longer and longer prefixes of f (α) when reading longer and longer prefixes of α. A definition of this machine model can be found, for instance, in [25].
▶ Example 1. Over the alphabet Σ = Γ = {a, b, A, B}, consider the specification given by the relation R 1 = {(uxα, xuβ) | uα, uβ ∈ {a, b} ω , x ∈ {A, B}}. The relation R 1 is automatic: an automaton needs to check that the input prefix u occurs shifted by one position on the output, which is doable using only finite memory. Checking that the first output letter x also appears after u on the input can also be done by storing x in the state. Note that some acceptance condition (e.g., parity) is needed to make sure that x is met again on the input. There is no Mealy machine which can realize R 1 , because Mealy machines operate in a synchronous manner: they read one input symbol and must deterministically produce one output symbol. Here, the first output symbol which has to be produced depends on the letter x which might appear arbitrarily far in the input sequence. However, R 1 can be uniformized by a computable function: there is an algorithm reading the input from left to right and which simply waits till the special symbol x ∈ {A, B} is met on the input. Meanwhile, it stores longer and longer prefixes of u in memory (so it needs unbounded memory) and once x is met, it outputs xu. Then, whatever it reads on the input, it just copies it on the output (realizing the identity function over the remaining infinite suffix α). Note that this algorithm produces a correct output under the assumption that x is eventually read.

Contributions.
We first investigate the synthesis of computable functions from rational specifications, which are those relations recognizable by non-deterministic finite state transducers, i.e., parity automata over a product of two free monoids. We however show this problem is undecidable (Proposition 4). We then give an incomplete but sound algorithm in Section 3, based on a reduction to ω-regular two-player games. Given a transducer T defining a specification R T , we show how to effectively construct a two-player game G T , proven to be solvable in ExpTime, such that if Eve wins G T , then there exists a computable function which uniformizes the relation recognized by T , which can even be computed by some input-deterministic two-way finite state transducer (a transducer which whenever it reads an input symbol, it deterministically produces none or several output symbols and either moves forward or backward on the input). It is easily seen that two-wayness is necessary: the relation R 1 cannot be uniformized by any deterministic device which moves only forward over the input and only uses finitely many states, as the whole prefix u has to be remembered before reaching x. However, a two-way finite-state device can do it: first, it scans the prefix up to x, comes back to the beginning of the input, knowing whether x = A or x = B, and then can produce the output.
Intuitively, in the two-player game we construct, called unbounded delay game, Adam picks the input symbols while Eve picks the output symbols. Eve is allowed to delay her moves an arbitrarily number of steps, gaining some lookahead information on Adam's input. We use a finite abstraction to store the lookahead gained on Adam's moves. We show that any finite-memory winning strategy in this game can be translated into a function uniformizing the specification such that it is computable by an input-deterministic two-way transducer.
In Section 4, we provide a sufficient condition P on relations for which the game reduction is complete. In particular, we show that if a relation R satisfies P, then Eve wins the game iff R can be uniformized by a computable function. A large subclass of rational relations satisfying this sufficient condition is the class of deterministic rational relations (DRAT, [24]). Deterministic rational relations are those relations recognizable by deterministic two-tape automata, one tape holding the input word while the other holds the output word. It strictly subsumes the class of automatic relations, and, unlike for automatic relations, the two heads are not required to move at the same speed. Furthermore, when the domain of the relation is topologically closed for the Cantor distance 2 , we show that strategies in which Eve delays her moves at most a bounded number of steps are sufficient for Eve to win. Such a strategy can in turn be converted into an input-deterministic one-way transducer. This entails that for DRAT-specifications with a closed domain (such as for instance specifications with domain Σ ω , i.e., total domains), if it is uniformizable by a computable function, then it is uniformizable by a function computable by an input-deterministic one-way transducer.
Based on the completeness result, we prove our main result, that the synthesis problem of computable functions from deterministic rational relations is ExpTime-complete. Hardness also holds in the particular case of automatic relations of total domain. Total versus partial domains. We would like to emphasize here on a subtle difference between our formulation of synthesis problems and the classical formulation in reactive synthesis. Classically in reactive synthesis, it is required that a controller produces for every input sequence an output sequence correct w.r.t. the specification. Consequently, specifications with partial domain are by default unrealizable. So, in this setting, the specification R 1 of the latter example is not realizable, simply because its domain is not total (words with none or at least two occurrences of a symbol in {A, B} are not in its domain). In our definition, specifications with partial domain can still be realizable, because the synthesized function, if it exists, can be partial and must be defined only on inputs for which there exists at least one matching output in the specification. A well-known notion corresponding to this weaker definition is that of uniformization [21,9,7,13], this is why we often use the terminology "uniformizes" instead of the more widely used terminology "realizes". The problem of synthesizing functions which uniformize quantitative specifications has been recently investigated in [1]. In [1], it was called the good-enough synthesis problem, a controller being good-enough if it is able to compute outputs for all inputs for which there 2 A set X ⊆ Σ ω is closed if the limit, if it exists, of any sequence (x i ) i of infinite words in X is in X. The limit here is defined based on the Cantor distance, which, for any two infinite words u, v, is 0 if u = v and otherwise 2 −ℓ where ℓ is the length of their longest common prefix.

43:4
Synthesizing Computable Functions from Rational Specifications over Infinite Words exists a least one matching output by the specification. The uniformization setting can be seen as an assumption that the input the program receives is not any input, but belongs to some given language. Related to that, there is a number of works on reactive synthesis under assumptions on the behavior of the environment [8,4,22,11,5].

Related work.
To the best of our knowledge, this work is the first contribution which addresses the synthesis of algorithms from specifications which are relations over infinite inputs, and such that these algorithms may need unbounded memory, as illustrated by the specification R 1 for which any infinite-input Turing-machine realizing the specification needs unbounded memory. There are however two related works, in some particular or different settings. First, in [12], the synthesis of computable functions has been shown to be decidable in the particular case of functional relations, i.e., graphs of functions. The main contribution of [12] is to prove that checking whether a function represented by a non-deterministic two-way transducer is computable is decidable, and that computability coincides with continuity (for the Cantor distance) for this large class of functions. The techniques of [12] are different to ours, e.g., games are not needed because output symbols functionally depends on input ones, even in the specification, so, there is not choice to be made by Eve.
Second, Hosch and Landweber [19] proved decidability of the synthesis problem of Lipschitz-continuous functions from automatic relations with total domain, Holtmann, Kaiser and Thomas [17] proved decidability of the synthesis of continuous functions from automatic relations with total domain, and Klein and Zimmermann [20] proved ExpTime-completeness for the former problem. So, we inherit the lower bound because automatic relations are particular DRAT relations, and as we show in the last section of the paper, the synthesis problem of computable functions is the same as the synthesis problem of continuous functions. We obtain the same upper bound as [20] for a more general class of specifications, namely DRAT, and in the more general setting of specifications with partial domain. As we show, total vs. partial domains make an important difference: two-way transducers may be necessary in the former case, while one-way transducers are sufficient in the latter. [17,20] also rely on a reduction to two-player games called delay games, but for which bounded delay are sufficient. However, our game is built such that it accounts for the fact that unbounded delays can be necessary and it also monitors the domain, which is not necessary in [17,20] because specifications have total domain. Accordingly, the main differences between [20] and our delay games are their respective winning objectives and correctness proofs. Another difference is that our game applies to the general class of rational relations, which are asynchronous (several symbols, or none, can correspond to a single input symbol) in contrast to automatic relations which are synchronous by definition.
Omitted and sketched proofs can be found in full in the full version.

Preliminaries
Words, languages, and relations. Let N denote the set of non-negative integers. Let Σ and Γ denote alphabets of elements called letters or symbols. A word resp. ω-word over Σ is an empty or non-empty finite resp. infinite sequence of letters over Σ. The empty word is denoted by ε, the length of a word by | · |. Usually, we denote finite words by u, v, w, etc., and infinite words by α, β, γ, etc. Given an (in)finite word α = a 0 a 1 · · · over Σ with a 0 , a 1 , · · · ∈ Σ, let α(i) denote the letter a i , α(i : j) denote the infix a i a i+1 · · · a j , α( : i) the prefix a 0 a 1 · · · a i , and α(i : ) the suffix a i a i+1 · · · for i ≤ j ∈ N. For two (in)finite words α, β, let α ∧ β denote their longest common prefix. Let Σ * , Σ + , and Σ ω denote the set of finite, non-empty finite, and infinite words over Σ, respectively. Let Σ ∞ denote Σ * ∪ Σ ω . A language resp. ω-language L is a subset of Σ * resp. Σ ω , its set of prefixes is denoted by By default in this paper, relations and functions are partial, i.e., are not necessarily total.

Automata. A parity automaton is a tuple
where Q is a finite set of states, Σ a finite alphabet, q 0 ∈ Q an initial state, ∆ ⊆ Q × Σ × Q a transition relation, and c : Q → N is a function that maps states to priorities, also called colors. A parity automaton is deterministic if its transition relation ∆ is given as a transition function δ. We denote by δ * the usual extension of δ from letters to finite words.
We say that ρ begins in ρ(0) and ends in ρ(|w|) if w is finite. We define Occ(ρ) as the set of states that occur in ρ, Inf(ρ) as the set of states that occur infinitely often in ρ, and c(ρ) as A finite non-empty run ρ is a non-empty sequence of transitions of the form Similarly, we define an infinite run. A run is accepting if it is infinite, begins in the initial state and satisfies the parity condition. In this paper, we also assume that for any accepting run ρ, its input and output are both infinite. This can be syntactically ensured with the parity condition. The relation recognized by T is R(T ) = {(α, β) | there is an accepting run of T with input α and output β}. Note that with the former assumption, we have R(T ) ⊆ Σ ω × Γ ω . A relation is called rational if it is recognizable by a transducer, we denote by RAT the class of rational relations. A sequential function is a function whose graph is R(T ) for an input-deterministic transducer T .
We assume that the arena is deadlock-free. We use letters on edges as it is more convenient to have them at hand for the proofs, it is however not Note that a play is uniquely determined by its action sequence. A game is of the form A strategy for Eve resp. Adam is a function Problem statement. In this section, we introduce the problem we want to solve. Let Σ, Γ be two finite alphabets. Given a relation R ⊆ Σ ω × Γ ω and a (partial) function f : Σ ω → Γ ω , f is said to uniformize R if dom(f ) = dom(R) and (α, f (α)) ∈ R for all α ∈ dom(R). We also say that R is uniformizable by f or that f is a uniformizer of R. We are interested in computable uniformizers, which we now introduce.
▶ Definition 2 ([25] computable functions). A function f : Σ ω → Γ ω is called computable if there exists a deterministic multi-tape machine M that computes f in the following sense, M has a read-only one-way input tape, a two-way working tape, and a write-only one-way output tape. All tapes are infinite to the right, finite to the left. For any finite word w ∈ Σ * , let M (w) denote the output 3 of M on w. The function f is said to be computable if for all Note that in the above definition, checking whether the infinite input belongs to the domain is not a requirement and should not be, because in general, it is impossible to do it reading only a finite prefix of the input. That is why in this definition, we assume that the input belongs to the domain of the function. It is a reasonable assumption. For instance, the inputs may have been produced by another program (e.g., a transducer) for which one has guarantees that they belong to some well-behaved (e.g., regular) language.
▶ Example 3. To begin with, consider the function f 1 : {a, b, c} ω → {b, c} ω defined by f 1 (a n ba ω ) = b ω and f 1 (a n ca ω ) = c ω for all n ∈ N ≥1 . It is computable by a TM which on inputs of the form a n xa ω for x ∈ {b, c}, outputs nothing up to reading x, and then, depending on x, either outputs c or b whenever it reads an a in the remaining suffix a ω . 3 The finite word written on the output tape the first time M reaches the |w|th cell of the input tape Consider the function f 2 : {a, b} ω → {a, b} ω defined by f 2 (α) = a ω if α contains infinitely many a and f (α) = b ω otherwise for all α ∈ {a, b} ω . It is rational but not computable, because to determine even the first output letter, an infinite lookahead is needed.
Let S be a class of relations. The S-synthesis problem asks, given a relation S ∈ S (finitely represented), whether there exists a computable function which uniformizes S. If such a function exists, then the procedure must return a TM computing it. Our first result, proved using an easy adaptation of the proof of [7, Theorem 17], showing that it is undecidable whether a given rational relation of finite words has a sequential uniformizer, is an undecidability result.
▶ Proposition 4. The RAT-synthesis problem is undecidable, even if restricted to the subclass of rational relations with total domain. Proof sketch. We sketch a reduction from Post's correspondence problem. Let u 1 , . . . , u n and v 1 , . . . , v n be a PCP instance. We construct the ω-rational relation R that contains pairs (α, β) of the form α = i 1 · · · i k α ′ with i 1 · · · i k ∈ {1, . . . , n} * and α ∈ {a, b} ω and β = u i1 · · · u i k a ω if α ′ contains infinitely many a and β ̸ = v i1 · · · v i k β ′ otherwise. If the PCP has no solution, then the function f : The function f is clearly computable. If the PCP has a solution, no computable function uniformizes R. If the integer sequence i 1 · · · i k is the solution, then u i1 · · · u i k = v i1 · · · v i k . Intuitively, for an input sequence starting with the solution, no prefix of the input sequence allows to determine whether the output must begin with u i1 · · · u i k or is not allowed to begin with u i1 · · · u i k .
The relation R can be made complete by also allowing all "invalid" inputs together with any output, i.e., by adding all pairs (α, β) ∈ {1, . . . , n, a, b} ω × {1, . . . , n, a, b} ω where the input sequence α is not of the form i 1 · · · i k α ′ with i 1 · · · i k ∈ {1, . . . , n} * and α ∈ {a, b} ω , and any output sequence β. Any Turing machine that computes f can easily be adapted to verify whether the input valid. ◀ Next, we give a semi-decision procedure for solving the RAT-synthesis problem which is sound but not complete. In Section 4, we introduce a sufficient condition for completeness which yields a (sound and complete) decision procedure for large classes of rational relations.

Unbounded Delay Game
In this section, given a rational relation (as a transducer), we show how to construct a finite-state ω-regular two-player game called (unbounded) delay game. We prove that if Eve wins this game then there exists a computable function which uniformizes the relation. Moreover, this function is computable by an input-deterministic two-way transducer. We analyze the complexity of solving the game, which turns out to be in ExpTime. Solving these games yields an incomplete, but sound, decision procedure for the RAT-synthesis problem.
In the game, Adam provides inputs and Eve must produce outputs such that combination of inputs and outputs is in the relation. However, as seen in Example 1, Eve might need to wait arbitrarily long before she can safely produce output. Hence, as the game is finite, it can not store arbitrary long input words, and Eve's actions cannot produce arbitrarily long words neither. Instead, we finitely abstract input and output words using a notion we call profiles. Informally, a profile of an input word stores the effects of the word (together with some output word) on the states of the transducer (that specifies the relation) as well as the maximal priority seen along the induced state transformation. Such profiles contain 43:8 Synthesizing Computable Functions from Rational Specifications over Infinite Words sufficient information to express a winning condition which makes sure that given the word of input symbols provided by Adam, if Eve would output concrete output words instead of their abstraction, she would produce infinitely often non-empty output words whose concatenation, together with the input word, belongs to the relation.

State transformation profiles.
Let R ⊆ Σ ω × Γ ω be a rational relation given by a transducer T = (Q T , Σ, Γ, q T 0 , ∆ T , c T ), and C T = img(c T ) its set of used priorities. Let D = (Q D , Σ, q D 0 , δ D , c D ) be a deterministic parity automaton that recognizes dom(R), and C D = img(c D ) its set of used priorities; D can always be constructed from T by projecting away its outputs and by determinizing the resulting automaton.
Finite-state unbounded delay game. We now present a two-player ω-regular game G T = (G, Win) such that if Eve has a winning strategy, then R has a computable uniformizer. In this game, Adam's actions are to provide input letters, letter-by-letter. Eve's goal is to construct a sequence of state transformations (q 0 , q 1 , m 1 )(q 1 , q 2 , m 2 ) . . . such that if the infinite input α ∈ Σ ω provided by Adam is in dom(R), then (i) the maximal priority seen infinitely often in (m i ) i is even and (ii) α = u 0 u 1 · · · for some u i ∈ Σ * such that (q i , q i+1 , m i+1 ) ∈ P ui for all i ≥ 0. As a consequence, all these finite runs can be concatenated to form an accepting run on α/v 0 v 1 . . . , entailing (α, v 0 v 1 . . . ) ∈ R. One can then show that if Eve has a strategy to pick the state transformations while ensuring the latter property, then this strategy can be turned into a computable function, and conversely. Picking a state transformation is what we call a producing action for Eve. Since a state transformation picked by Eve may correspond to an arbitrarily long word u i , she also has an action skip which allows her to wait before making such a producing action. Now, the difficulty for Eve is to decide when she makes producing actions, in other words, how to decompose the input α, only based on prefixes of α. To that end, before picking a state transformation, she may need to gather lookahead information from Adam. Consequently, the vertices of the game manipulates two consecutive profiles P 1 and P 2 , with the invariant that P 1 is the profile of u i while P 2 is the profile of u i+1 , when the input played so far by Adam is u 0 . . . u i+1 . When Eve knows enough, she picks a state transformation (q i , q i+1 , m i ) in P 1 , then P 1 becomes P 2 and P 2 is reset to P ε . The inputs of Adam up to the next producing action of Eve form the word u i+2 , and so on. The vertices of the game also store information to decide whether the input belongs to the domain of R (states of D), the parities m i , as well as the states q 0 , q 1 , . . . . Formally, the game graph G = (V, E) is composed of vertices of the form q, c, P 1 , P 2 , r × {∀, ∃}, where q ∈ Q T , State reached on the combination of input and output sequence. c ∈ {−1} ∪ C T , Priorities of the state transformations, -1 is used to indicate that no state transformation was chosen (skip action below). P 1 , P 2 , Profiles obtained from the given lookahead of the input word. r ∈ Q D . State reached on the given lookahead of the input word. From a vertex of the form q, c, P 1 , P 2 , r, ∀ , Adam has the following actions: a − → q, −1, P 1 , P 2 ⊗ P a , δ D (r, a), ∃ , for all a ∈ Σ.
Adam provides the next lookahead letter and P 2 is updated accordingly.
Eve makes a producing action: a state transformation from the first lookahead profile is chosen, the state transformation is applied, and the first profile is consumed. The initial vertex of the game is q T 0 , −1, P ε , P ε , q D 0 , ∀ . Let us now define Win ⊆ V ω . The condition makes sure that if the input sequence provided by Adam is in the domain of R, then the sequence of state transformations can be used to build on accepting run of T on that input. Win ⊆ V ω is the set of all plays γ satisfying the property max Inf(col D (γ)) is even → max Inf(col T (γ)) is even, where col D (γ) = c D (π 5 (γ)), col T (γ) = π 2 (γ), and π i (γ) is the projection of γ onto the ith component of each vertex. It is not difficult to see that Win is ω-regular, e.g., one can design a parity automaton for it.
We explain the intuition behind Win. Our goal is to extract a computable function that uniformizes the relation from a winning strategy. Intuitively, there is a computable function that uniformizes R, if every input word α ∈ dom(R) can be read letter-by-letter, and from time to time, a segment of output letters is produced, continuously building an infinite output word β such that (α, β) ∈ R. We relate this to Win. Recall that R is defined by T , and dom(R) by D. Given a play γ, there is a unique input word α ∈ Σ ω that corresponds to γ. Since we are looking to build a computable function f with dom(f ) = dom(R), we care whether α ∈ dom(R). The ω-word col D (γ) is equal to c(ρ D ), where ρ D is the run of D on α. If max Inf(col D (γ)) is even, α ∈ L(D), i.e., α ∈ dom(R). An output word β ∈ Γ ∞ that corresponds to γ is only indirectly defined, instead the play defines a (possibly finite) sequence of state transformations that an output word β should induce together with α. How to extract a concrete β from γ is formally defined in the proof of Theorem 5. The ω-word col T (γ) contains the relevant information to determine whether (α, β) ∈ R(T ), i.e., (α, β) ∈ R. In particular, if β is finite, max Infcol T (γ) is −1, that means that only finitely many producing actions have been taken. If max Infcol T (γ) is even, we have that (α, β) ∈ R. Thus, Win expresses that if α ∈ L(D), then there is some β ∈ Γ ω , which can be built continuously while reading α such that (α, β) ∈ R.
From winning strategies to uniformizers. We are ready to state our first positive result: If Eve has a winning strategy in the unbounded delay game G T , then R(T ) is uniformizable by a computable function. In fact, we show a more precise result, namely, that if Eve has a winning strategy, then the relation is uniformizable by a function recognized by a deterministic two-way parity transducer. Additionally, if the domain of the relation is closed 4 , then a deterministic one-way transducer suffices. Just as (one-way) transducers extend parity automata with outputs on their transitions, input-deterministic two-way transducers extend deterministic two-way parity automata with outputs. The reading tape is two-way, but the output tape is one-way. The class of functions recognizable by 2DFTs is smaller than the class of computable functions and enjoys many good algorithmic properties, e.g., decidability Algorithm 1 Algorithm computing continuous function f that uniformizes R. The algorithm is described in the proof sketch of Theorem 5. Input: α ∈ Σ ω , G game arena, S = (M, V, m 0 , δ, µ) strategy automaton of the equivalence problem [3]. Note that any function recognizable by a 2DFT is computable, in the sense that it suffices to "execute" the 2DFT to get the output. So, from now on, we may freely say that a function is computable by a 2DFT.

▶ Theorem 5. Let R be defined by a transducer T . If Eve has a winning strategy in G T , then R is uniformizable by a function computable by a 2DFT.
Proof sketch. If Eve has a winning strategy in G T , then she also has a finite-state winning strategy because the winning condition is ω-regular. From such a strategy we can build an algorithm (a Turing machine), see Algorithm 1, that computes a function f that uniformizes R. The high-level idea of the algorithm is to simulate the strategy, which abstracts inputs and outputs by profiles, and in parallel store concrete inputs and outputs corresponding to those profiles. This is possible as Turing machines have infinite storage capacity. In the algorithm, an input sequence α is read letter-by-letter and the corresponding play in G is simulated where Adam plays according to α and Eve according to her winning strategy. In the play, a lookahead u i ∈ Σ * gained on Adam's input is stored as its profile P ui . In the algorithm, the lookahead u i is stored concretely in addition to its profile P ui . When Eve takes an action she picks a state transformation (that should occur in the transducer) from P ui−1 , the profile of the previous lookahead sequence u i−1 , also stored by the algorithm. The algorithm picks some v i−1 ∈ Γ * such that u i−1 /v i−1 induces the state transformation picked by Eve. A new non-empty lookahead u i+1 ∈ Σ * is built, stored as its profile P ui+1 in the play and as the concrete sequence u i+1 in the algorithm until Eve picks a state transformation from P ui , and so on. The lookaheads that are built are non-empty (except for the first one), and since Eve plays according to her winning strategy, the sequence of state transformations she picked can be used to build an accepting run of T on (u 0 u 1 . . . , v 0 v 1 . . . ), proving that the latter pair belongs to R.
Then we show that f can be actually recognized by a 2DFT. The main idea is to use two-wayness to encode finite lookahead over the input: the reading head goes forward to gather input information, and then must return to the initial place where the lookahead was needed to transform the input letter. The difficulty is for the 2DFT to return to the correct position, even though the lookahead can be arbitrarily long. In order to find the correct positions, we make use of a finite-state strategy automaton for Eve's winning strategy in the following sense. A (left-to-right) run of the strategy automaton on the input word yields a unique segmentation of the input, such that segments i and i + 1 contain enough information to determine the output for segment i. The idea is to construct a 2DFT that simulates the strategy automaton in order to find the borders of the segments. If the 2DFT goes right, simulating a computation step of the deterministic strategy automaton is easy. Recovering the previous step of the strategy automaton when the 2DFT goes left is non-trivial, it is possible to compute this information using the Hopcroft-Ullman construction presented in [18]. We show that having the knowledge of the profiles of segments i and i + 1 is enough to deterministically produce a matching output for segment i on-the-fly going from left-to-right over segment i again. ◀ We make some remarks about the form of the game, in particular the use of two lookahead profiles, instead of one. Assume we would have only one profile abstracting the lookahead over Adam inputs. For simplicity, assume the specification is automatic (i.e., letter-to-letter). Suppose, so far, Adam and Eve have alternated between providing an input letter and producing an output letter (in the finite-state game, Eve producing letter(s) corresponds to the abstract action of picking state transformations), but now, she needs to wait for more inputs before she can safely output something new. Suppose that Adam has provided some more input, say the word u, and Eve now has enough information about the input to be able to produce something new. Abstractly, it means that in the game, Adam has given the word u but only its profile P is stored. Eve might not be able to produce an output of the same length as u (for example, if producing the ith output letter depends on the i + kth input letter). So, she cannot consume the whole profile P (i.e., pick a state transformation in P ). What she has to do, is to decompose the profile P into two profiles such that P = P 1 ⊗ P 2 and pick a state transformation in P 1 , and then continue the game with profile P 2 (and keep on updating it until she can again produce something). The problem is, firstly, that there is no unique way of decomposing P as P 1 ⊗ P 2 , and secondly, P 1 might not correspond to any prefix of u. That is why it is needed to have explicitly the decomposition at hand in the game construction.
▶ Lemma 6. Deciding whether Eve has a winning strategy in G T is in ExpTime.

F S T T C S 2 0 2 1
Proof sketch. Two-player ω-regular games are decidable (see, e.g., [16]). The claimed upper bound is achieved by representing the winning condition as a deterministic parity automaton, carefully analyzing its size, and then solving a parity game. ◀ ▶ Remark 7. The converse of Theorem 5 is not true.
Clearly, if the converse was true, the RAT-synthesis problem would be decidable, which is a contradiction to Proposition 4. We also give a small example that illustrates that uniformizability does not imply the existence of a winning strategy.
▶ Example 8. Consider the identity function f : {a, b} ω → {a, b} ω such that all inputs with either finitely many a or b are in the domain. A (badly designed) letter-to-letter transducer T that recognizes f has five states S, A, B, A ′ , B ′ , where S is the starting state, A, B (resp. A ′ , B ′ ) are used to recognize finitely many b (resp. a), and from S, the first input/output letter non-deterministically either enters A or A ′ . In a play in G T , at some point, Eve must make her first output choice, i.e., she starts to build a run of T . This choice fixes whether the run is restricted to A, B or A ′ , B ′ . No matter Eve's choice, Adam can respond with an infinite sequence of either only a (for A, B) or b (for A ′ , B ′ ), making it impossible to build an accepting run. Thus, Eve has no winning strategy, but clearly the function f is computable. While in the above example, the point of failure is clearly the bad presentation of the specification, this is not the case in general. Recall the proof sketch of Proposition 4, where we provide a reduction from Post's correspondence problem. A non-deterministic transducer constructed from a given PCP instance u 1 , v 1 , . . . , u n , v n can guess whether the input word contains infinitely many a, and accordingly either checks that the output begins with u i1 · · · u i k for input sequences beginning with indices i 1 · · · i k , or checks that it does not begin with a prefix equal to v i1 · · · v i k . As detailed in the proof sketch, if the PCP instance has no solution, there is a computable uniformization, however, using the same argumentation as in the above example, such a transducer would make it impossible to have a winning strategy. In order to have a winning strategy, the transducer must be changed such that it checks at the same time whether the output starts with u i1 · · · u i k and does not start with something equal to v i1 · · · v i k for input sequences beginning with i 1 · · · i k . In general, depending on the PCP instance, it is not possible to make both checks in parallel.
We state a lemma about bounded delay.
▶ Lemma 9. Let R be defined by a transducer T . If there exists ℓ ≥ 0, such that Eve has a winning strategy in G T with at most ℓ consecutive skip-moves, then R is uniformizable by a function computable by a 1DFT.
Intuitively, such a strategy yields a function computable by a 1DFT, because the needed lookahead (as it is bounded) can be stored in the state space.

A Sufficient Condition for Completeness
As we have seen in the previous section, ▶ Remark 10. Theorem 5 yields a semi-decision procedure for solving the RAT-synthesis problem (it is sound but not complete).
In this section, we show that the procedure is complete for two known and expressive classes of rational relations, namely the class of automatic relations (AUT), which are for example used as specifications in Church synthesis, as well as the class of deterministic rational relations (DRAT) [24] (to be formally defined below), see Corollary 13. To arrive at these results, we define a structural restriction on transducers that turns out to be a sufficient condition for completeness. Let T be a transducer. An input (resp. output) state is a state p from which there exists an outgoing transition (p, u, v, q) such that u ̸ = ε (resp. v ̸ = ε). The set of input (resp. output) states is called Q i (resp. Q o ). A transducer T has property P if for all words u ∈ Σ * , all v 1 , v 2 ∈ Γ * such that v 1 is a prefix of v 2 the following holds: − −− → r, and q, r are input states, then q = r.
This property implies that, given α ∈ Σ ω , β ∈ Γ ω such that there is a run of T with input α and output β, for each prefix u ∈ Σ * of α there exists a unique prefix v ∈ Γ * of β that has to be produced while reading u before the remainder α ′ (let α = uα ′ ) can be read. Furthermore, the target state of T : q 0 u/v − − → is unique and this state is exited only when further input (from α ′ ) has to be read. In simpler terms, given a prefix of an input word, it is uniquely determined how long the prefix of a given output word has to be so that further input can be processed and the reached state is unique. This implies that input prefixes together with (long enough) output prefixes are sufficient to determine the beginning of an accepting run if such a run exists. This allows us to show the following. ▶ Theorem 11. Let R be defined by a transducer T with property P. If R is uniformizable by a computable function, then Eve has a winning strategy in G T .
Proof sketch. In fact, we explain how to construct a winning strategy from a continuous (a computable function is always continuous, see Section 5) uniformizer f of R. Given α ∈ dom(R) and f (α), we show that it is possible to decompose the input α into u 0 u 1 · · · and the output f (α) into v 0 v 1 · · · such that there exists an accepting run T : q 0 where each q i is an input state for i > 0. Moreover, this decomposition and run can be determined in a unique way and on-the-fly, in the sense that a factor u i /v i only depends on the factors u 0 /v 0 ,. . ., u i−1 /v i−1 . This makes it possible for Eve to pick a corresponding state transformation sequence (q 0 , q 1 , c 0 )(q 1 , q 2 , c 1 ) · · · which is only dependent on the so far seen actions of Adam spelling u 0 u 1 · · · . The main idea to determine the u i is to look at the indices j for which the longest common prefix of the sets S j = {f (α(:j)β) | α(:j)β ∈ dom(R)} strictly increases. Given u i , the output v 0 v 1 · · · v i is any common prefix of the sets S j , such that a run T : q i ui/vi −−−→ is defined and its target is an input state. The fact that T has property P guarantees that each of these runs has the same target, thus, the next state transformation (q i , q i+1 , c i ) is uniquely determined. ◀ We turn to the setting of closed domains.
▶ Lemma 12. Let R with dom(R) closed be defined by a transducer T with property P. If R is uniformizable by a computable function, then there exists a computable ℓ ≥ 0 such that Eve has a winning strategy in G T with at most ℓ consecutive skip-moves.
Proof sketch. Intuitively, the reason why bounded lookahead suffices in the setting of closed domains is that (basically at each point of time during a play) Adam's moves describe a series of longer and longer finite input words that "converge" to a valid infinite input word from the domain. Hence, Eve can not wait arbitrarily long to make producing moves, as such a play describes a valid infinite input sequence and a finite output sequence. ◀ We formally introduce AUT and DRAT. A relation is deterministic rational if it is recognized by a transducer where Q i and Q o partition its state space, and its transition relation ∆ is a function ( . It is automatic if additionally ∆ strictly alternates between Q i and Q o states. It is easy to see that every DRAT-transducer (and a fortiori every AUT-transducer) satisfies the property P. In general, given any transducer T , we do not know if it is decidable whether T has property P.
Main result. We now state our main result: Asking for the existence of a uniformization which is computable by a Turing machine or computable by an input-deterministic two-way transducer (2DFT), are equivalent questions, as long as specifications are DRAT relations. Moreover, these questions are decidable.
▶ Corollary 13. Let R be defined by a DRAT-transducer T . The following are equivalent: 1. R is uniformizable by a computable function.

R is uniformizable by a function computable by a 2DFT.
3. Eve has a winning strategy in G T . Moreover, if dom(R) is closed, then it is equivalent to R being uniformizable by a function computable by a 1DFT.
Note that the above result also holds for the slightly more general case of relations given by transducers with property P. We highlight two facts regarding closed domains.
▶ Remark 14. The set of infinite words over a finite alphabet is closed, i.e., every total domain is closed. Furthermore, it is decidable whether a domain (e.g., given by a Büchi automaton) is closed. It is a well-known fact that the topological closure of a Büchi language is a Büchi language (one can trim the automaton and declare all states to be accepting) and therefore one can check closedness by checking equivalency with its closure. Proof. Membership in ExpTime directly follows from Lemma 6 and Corollary 13. In [20] it was shown that this problem is ExpTime-hard in the particular case of automatic relations with total domain, so the lower bound applies to our setting. ◀

Discussion
Continuous functions. We have shown that checking the existence of a computable function uniformizing a relation given by transducer with property P is decidable (a consequence of Theorems 5 and 11 and Lemma 6). The proofs of Theorems 5 and 11 use another notion, which is easier to manipulate mathematically than computability, that of continuity. A function is called continuous if ∀α ∈ dom(f ) ∀i ∈ N ∃j ∈ N ∀β ∈ dom(f ) : |α ∧ β| ≥ j → |f (α) ∧ f (β)| ≥ i.
(1) ▶ Example 16. Consider the function f 1 of Example 3. f 1 is continuous, because the ith output symbol only depends on the max(i, n + 1) first input symbols. Consider the function f 2 of Example 3. The function f 2 is clearly rational, but it is not continuous. We verify that f 2 is not continuous, let α n denote a n b ω , we have that |α n ∧a ω | = n and |f 2 (α n )∧f 2 (a ω )| = 0 for all n ∈ N. Thus, f 2 is not continuous.
The notions of computability and continuity are closely related. If a function f : Σ ω → Γ ω is computable, it is also continuous. This is not difficult to see when comparing the definitions of computable and continuous functions. The converse does not hold because the continuity definition does not have any computability requirements (see [12] for a counter-example). However, regarding synthesis, the two notions coincide: Proof. Indeed, any computable uniformizer is continuous. Theorem 11 states that if there exists a computable uniformizer, then there exists a winning strategy in the delay game. However, in the proof of this theorem, we show a stronger statement: If there exists a continuous uniformizer, then there exists a winning strategy in the delay game. Such a strategy can be assumed to have finite-memory (as finite-memory suffices to win games with ω-regular conditions). We have shown in the proof (sketch) of Theorem 5 how to translate a finite-state winning strategy into an algorithm (a Turing machine) that computes a function f which uniformizes the relation. ◀ Conclusion and future work. We investigated the synthesis of algorithms (aka. Turing machine computable functions) from rational specifications. While undecidable in general, we have proven decidability for DRAT (and a fortiori AUT). Furthermore, we have shown that the whole computation power of Turing machines is not needed, two-way transducers are sufficient (and necessary). As TMs reading heads are read-only left-to-right, converting a 2DFT into a TM requires that the TM stores longer and longer prefixes of the input in the working-tape for later access. This is the only use the TM needs to make of the working tape. This is a naive translation, and sometimes the working tape can be flushed (some prefixes of the input may possibly not be needed anymore). More generally, it is an interesting research direction to fine-tune the class of functions targeted by synthesis with respect to some constraints on the memory, including quantitative constraints. Related to the latter research direction is the following open question: is the synthesis problem of functions computable by input-deterministic one-way (aka. sequential) transducers from deterministic rational relations decidable? It is already open for automatic relations. We have shown that if a rational relation with closed domain is uniformizable by a computable function, then also by a sequential function. However, closedness is not a sufficient condition: e.g., the function which maps any a n xc ω to xc ω for x ∈ {#, $}, is sequential; a sequential transducer just has to erase the a n part, but its domain is not closed. This problem is interesting because sequential transducers only require bounded memory to compute a function (in contrast to two-way transducers that require access to unboundedly large prefixes of the input).