Transducer-based Rewriting Games for Active XML
aa r X i v : . [ c s . F L ] J un Transducer-based Rewriting Games for ActiveXML
Martin Schuster
TU Dortmund University
Tuesday 21 st August, 2018
Abstract
Context-free games are two-player rewriting games that are playedon nested strings representing XML documents with embedded functionsymbols. These games were introduced to model rewriting processes forintensional documents in the
Active XML framework, where input docu-ments are to be rewritten into a given target schema by calls to externalservices.This paper studies the setting where dependencies between inputs andoutputs of service calls are modelled by transducers, which has not beenexamined previously. It defines transducer models operating on nestedwords and studies their properties, as well as the computational com-plexity of the winning problem for transducer-based context-free gamesin several scenarios. While the complexity of this problem is quite high inmost settings (ranging from NP -complete to undecidable), some tractablerestrictions are also identified. Scientific context
Context-free games on strings are two-player games ex-tending context-free grammars, with the first player (called
Juliet ) choosingthe non-terminal to be replaced and the second player (called
Romeo ) choos-ing a replacement for that non-terminal. The winning condition for
Juliet isreaching, at some point during the game, some string in a given target languageover the combined alphabet of non-terminals and terminals.These games were first introduced in [12] to model the rewriting processof
Active XML (AXML) [1] documents. The intention of AXML is modelling intensional documents, i.e. documents that do not store all required informationexplicitly but instead contain references to external services, from which currentinformation may be materialised on demand, as illustrated in the example below.To this end, AXML extends standard XML with function nodes referring toexternal web services that may be called to insert data into the AXML documentwhen the document is requested. Context-free games abstract from AXML tomodel the uncertainty inherent in using external data.A standard example (cf. [11, 12]) of an application for AXML is depicted inFigure 1. In this example, we consider (part of) an AXML document retainedby a local online news site providing information about current weather andevents. Initially, the server-side document looks like the one in Figure 1a. The1odes labelled @weather svc and @events svc are function nodes referring toexternal weather and event services.
City Events@events svcDortmundWeather@weather svcCentigradeNameDortmund (a) Example document before rewriting.
City Events@events svcDortmundSports@sports svcWeather20 ˝ /sunnyNameDortmund (b) Same document after function calls. Figure 1: Example of Active XML rewriting. After calls to function nodes@weather svc and @events svc in Fig. 1a, external data is materialised to yieldthe document in Fig. 1b.Figure 1b shows the document from Figure 1a after both function nodes havebeen called, replacing them by the external services’ results. As exemplified bythe function node labelled @weather svc, call results replace the entire subtreerooted at the called function node, with that subtree being passed to the externalservice as a parameter. Concretely, the @weather svc node’s child tells theweather service that temperatures returned should be in centigrade. As the callresult of the @event svc node shows, returns of external services may containfurther function nodes, even copies of the called function node.The safe rewriting problem [11] of determining whether a given AXML doc-ument can always be rewritten into a target schema was abstracted in [12] intothe problem of determining whether
Juliet has a winning strategy in a givencontext-free game on strings, with
Juliet representing a rewriting algorithmand
Romeo representing the uncertainty inherent in function calls. This re-search assumed DTDs as schema formalisms. Allowing more expressive schemalanguages such as XML Schema [14] then led to research into context-free gameson nested strings (i.e. XML-like linearisations of trees) [3]. Even though none ofthese previous works modelled dependencies between parameters and outputsof function calls, they already showed that the winning problem for
Juliet canbe undecidable or of a very high complexity, unless strategies for
Juliet andallowed schema languages are seriously restricted.The impact of service call parameters has so far only been studied in a limitedfashion. In [14] (and in [11], for AXML rewriting with DTDs), external serviceswere modelled by input (or validation ) and output (or replacement ) schemas,the semantics being that a function node could only be called if its parametersubtree was valid with regard to its corresponding input schema, which wouldthen yield a return conforming to its output schema. This is a purely syntactichandling of input parameters which models a rather simple relationship betweeninput and output of function calls; for instance, an @event svc call reproducingits input parameters in its output as shown in Figure 1 cannot be enforced inthis model.While dependencies between parameters and outputs of service calls havealways been implicit in the AXML model, they have not been studied in detailso far. Therefore, we extend the context-free games on nested words from [14]by (generally non-deterministic) transformations relating function parameters to2ossible outputs. We define nested word transducers (NWT) as a comparativelysimple finite representation for transformations on nested words that naturallyextends the nested word automata used in [14]. We then study the complexityof the winning problem for
Juliet in various restrictions of context-free gameswith transducer-based replacement. As auxiliary results of potentially indepen-dent interest, we also examine closure properties and basic algorithmic problemsof NWT.
Contributions
In light of prior undecidability and complexity results, themain objective of this paper is finding suitable restrictions to transducer-basedcontext-free games that render the winning problem for
Juliet decidable withas low complexity as possible. The two basic types of restrictions we exam-ine are strategy restrictions (i.e. restrictions to
Juliet ’s capabilities of callingfunction symbols) and restrictions to the type of NWT used for rewriting. Toavoid undecidability, we only allow left-to-right strategies, i.e. once a functionnode has been called, no function calls to nodes preceding it (in post-order) arepossible (cf. [12]).The most important class of strategy restrictions considered here are re-strictions to games with limited replay . In general context-free games, after afunction call,
Juliet continues her rewriting on that function call’s result; wecall this the unbounded replay case, as
Juliet may continue rewriting functioncall results for as long as new function nodes are returned. In the replay-free case,
Juliet is instead forbidden to call any function nodes inside results offunction calls. As an intermediate case between unbounded replay and replay-free games, we also consider bounded replay games, where
Juliet may only callfunctions returned by function calls up to a fixed maximum recursion depth.For instance, in a replay-free game,
Juliet could call neither of the functionnodes labelled @sports svc and @events svc in the situation of Figure 1b; in abounded replay game of depth 2, on the other hand, she could call these nodes,but not any function nodes returned by those secondary calls.The second type of restrictions comes from limiting expressiveness of thetransducer used in games. Generally, transducers are allowed to be non-functional ,i.e. any input string, may have several transducts (to model the fact that func-tion call results are dependent upon, but not uniquely determined by, inputparameters). The main types of transducers examined here are the following: • Nested word transducers (NWT) allow for transforming input strings intooutput strings that are arbitrarily long, regardless of the input string’ssize. • Nested word transducers without ǫ -transitions ( ǫ -free NWT) may only in-crease the size of an input string by no more than a linear factor. • Relabelling transducers may only change labels of input strings, not theirstructure. • As a special case, functional relabelling transducers are relabelling trans-ducers whose output string is uniquely determined by their input.This paper’s main complexity results are summarised in Table 1. The centralinsight here is that the least restricted settings yield an undecidable or non-elementary winning problem, and even for strong restrictions, the complexity3 o replay Bounded UnboundedNWT undecidable undecidable ǫ -free NWT co-NEXPTIME non-elementary undecidableRelabelling PSPACE PSPACE EXPTIME
Functional relabelling
NP NP PSPACE
Table 1: Summary of complexity results. All results are completeness results.of the winning problem is generally quite high, with no tractable case amongthe standard settings. For this reason, we also study several limitations of thesesettings, derived from our lower bound proofs, in order to reduce complexity: • Depth-bounded NWT lower the complexity of the replay-free case to
EXPSPACE -complete (in comparison to for general NWT). • Strategies with bounded Call width lower the complexity of the bounded-replay case for ǫ -free NWT from non-elementary to co-NEXPTIME -complete or co-NP -complete, depending on the precise formalisation ofbounded Call width. • Write-once strategies yield a tractable case for functional relabelling trans-ducers in a setting even more restrictive than the replay-free one.
Related Work
Beyond the work already discussed, further complexity anddecidability results for context-free games can be found in [2, 4], and [12] con-tains further references to related work.Our concept of nested word transducers is based on Visibly Pushdown Trans-ducers [13, 16], specifically the well-nested VPT of [8]. The original defini-tions of VPT in [13, 16] included ǫ -transitions, which were dropped from laterdefinitions, as they caused several algorithmic problems, such as functionalityand equivalence, to become undecidable (cf. [15]). Different from these ap-proaches, this paper combines ǫ -transitions with the restriction to well-nestedwords, which is (to the best of the author’s knowledge) new research. Organisation
Section 2 gives basic notation and definitions. Section 3 definesnested word transducers and examines their structural and algorithmic prop-erties. The next three sections give results on the complexity of the winningproblem for games with transducer-based replacement, from most to least ex-pressive – general nested word transducers (Section 4), nested word transducerswithout ǫ -transitions (Section 5), and relabelling transducers (Section 6). Eachof these sections also discusses one of the restrictions with reduced complexitymentioned above. Section 7 concludes the paper. Due to space limitations,proofs and technical definitions are deferred to the appendix. The author isgrateful to Gaetano Geck and Thomas Schwentick for careful proof-reading andvaluable suggestions, and to the anonymous reviewers of MFCS 2016 for theirinsightful and constructive comments. 4 h a i : p a h b i : p b h { a i , p a h { b i , p b (a) NWA A q q h { a i , p h a i : p h { a i , p (b) NWA A Figure 2: NWAs A and A from Example 1 For any natural number n P N , we denote by r n s the set t , . . . , n u . For finitesets M , P p M q denotes the powerset of M , i.e. the set of all subsets of M . Foran alphabet Σ, we denote the set of finite strings over Σ by Σ ˚ and ǫ denotesthe empty string. Nested words
For a finite alphabet Σ, h Σ i def “ t h a i | a P Σ u denotes theset of all opening Σ -tags and h { Σ i def “ t h { a i | a P Σ u the set of all closing Σ -tags . We denote by ˆΣ def “ h Σ i Y h { Σ i the set of all Σ-tags. The set NW p Σ q Ď ˆΣ ˚ of (well-)nested words (or (well-)nested strings ) over Σ is the smallest setsuch that ǫ P NW p Σ q , and if u, v P NW p Σ q and a P Σ, then also u h a i v h { a i P NW p Σ q . We (informally) associate with every nested word w its canonicalforest representation , such that words h a ih { a i , h a i v h { a i and uv correspond to an a -labelled leaf, a tree with root a (and subforest corresponding to v ), and theforest of u followed by the forest of v , respectively. A nested string w is rooted ifits corresponding forest is a tree. We denote the set of rooted nested strings overΣ by rNW p Σ q . In a string w “ w . . . w n P ˆΣ ˚ , two tags w i P h Σ i and w j P h { Σ i with i ă j are associated if the substring w i . . . w j of w is a rooted nested string.An opening (closing) tag w i in w is unmatched , if it has no associated closing(opening) tag in w . To stress the distinction from nested strings in NW p Σ q , werefer to strings in Σ ˚ as flat strings . Nested word automata A nested word automaton (NWA) A “ p Q, P, Σ , δ, q , F q [3] is basically a pushdown automaton which performs a push operation on ev-ery opening tag and a pop operation on every closing tag, and in which thepushdown symbols are just states. More formally, A consists of a set Q of linearstates , a set P of hierarchical states , an alphabet Σ, a transition relation δ , an initial state q P Q , and a set F Ď Q of accepting (linear) states . The relation δ is a subset of the union of sets p Q ˆ h Σ i ˆ Q ˆ P q and p Q ˆ P ˆ h { Σ i ˆ Q q . Wesometimes interpret δ as the union of two functions from p Q ˆ h Σ i q to P p Q ˆ P q and from p Q ˆ P ˆ h { Σ i q to P p Q q and write accordingly p q , p q P δ p q, h a i q for p q, h a i , q , p q P δ and q P δ p q, p, h { a i q for p q, p, h { a i , q q P δ . The semantics ofNWA as well as the language L p A q decided by a NWA A are defined in the nat-ural way, with a NWA accepting if it reaches a configuration with an acceptingstate and empty stack. If A is a NWA, we call L p A q a regular language (of nestedwords). A NWA is deterministic (or DNWA) if | δ p q, h a i q| “ “ | δ p q, p, h { a i q| for all q P Q , p P P and a P Σ. In this case, we simply write δ p q, h a i q “ p q , p q instead of δ p q, h a i q “ tp q , p qu (and accordingly for δ p q, p, h { a i q ).5 xample 1. The NWA A (Fig. 2a) checks that its input string is well-nestedby pushing hierarchical state p a (resp. p b ) to the stack on each opening h a i (resp. h b i ) tag and popping an according hierarchical state with each matchingclosing tag. In this manner, A decides the set of all well-nested strings over t a, b u . The NWA A (Fig. 2b) initially pushes a hierarchical state p each timeit reads h a i in linear state q , then changes linear state to q on reading thefirst h { a i and accepts iff each initial h a i is matched by a h { a i . In this manner, itdecides the language t h a i n h { a i n | n ě u . Context-free games A context-free game (with transduction) on nested words(cfG) G “ p Σ , Γ , R, T q consists of a finite alphabet Σ, a set Γ Ď Σ of functionsymbols , a (replacement) rule set R Ď rNW p Σ q ˆ NW p Σ q and a target language T Ď NW p Σ q . We will only consider the case where T is a non-empty regularnested word language and replacement rules are given by nested word transduc-ers, to be defined in Section 3. A play of G is played by two players, Juliet and
Romeo , on a word w P NW p Σ q . In a nutshell, Juliet moves the focus along w from left to right and decides for each closing tag h { a i , whether she plays a Read or, in case a P Γ, a
Call move. In the latter case,
Romeo then replaces therooted word u ending at the position of h { a i with some word v with p u, v q P R and the focus is set on the first symbol of v . If no such word v exists, Romeo immediately wins the play. In case of a Read move, the focus just moves furtheron.
Juliet wins a play if the word obtained at its end is in T . Strategies A strategy for player p P t J , R u maps game states where player p is to move into allowed moves for player p , i.e. strategies σ for Juliet returnmoves in t Read , Call u while strategies τ for Romeo return replacement stringsin NW p Σ q . Given an initial word w and strategies σ, τ the play Π p σ, τ, w q according to σ and τ on w is uniquely determined. A winning strategy for Juliet is a strategy σ such that Juliet wins the play Π p σ, τ, w q , for every τ of Romeo . By JWin p G q we denote the set of all words for which Juliet has awinning strategy in G .The Call depth of a play Π is the maximum nesting depth of Call movesin Π, if this maximum exists. That is, the Call depth of a play is zero, if noCall is played at all, and one, if no Call is played inside a string yielded by areplacement move. For a strategy σ of Juliet and a string w P NW p Σ q , the Call depth
Depth G p σ, w q of σ on w is the maximum Call depth in any playΠ p σ, τ, w q . A strategy σ has k -bounded Call depth if Depth G p σ, w q ď k for all w P NW p Σ q . As a more intuitive formulation, we use the concept of replay :Strategies for Juliet of Call depth one are called replay-free , and strategies of k -bounded Call depth, for any k , have bounded replay . Algorithmic problems
In this paper, we study the following algorithmicproblem
JWin p G q for various classes G of context-free games with replacementtransducers. JWin p G q Given: A context-free game G P G and a string w .Question: Is w P JWin p G q ?A class G of context-free games in JWin p G q generally comes with threeparameters: 6 the representation of the target language T , • the representation of the replacement relation R , and • to which extent replay is restricted.We generally assume target languages to be represented by DNWAs, be-cause the complexity of the winning problem is already quite high under thatassumption, and our main interest is in finding classes G for which JWin p G q istractable. Replacement relations will be given as different types of nested wordtransducers (defined in Section 3). By a slight abuse of notation, the replace-ment transducer implementing a replacement relation R will also be referred toas R .In each setting, we consider the cases of unrestricted replay, bounded replay(Call depth k , for some k ), and no replay (Call depth 1). We note that replaydepth is formally not an actual game parameter, but the algorithmic problemcan be restricted to strategies of Juliet of the stated kind. If the class G of games is clear from the context, we often simply write JWin instead of
JWin p G q . In this section, we define nested word transducers and examine their closureproperties and complexities of algorithmic problems. Thanks to our definitionputting some rather severe restrictions on the use of ǫ -transitions and the al-lowed output of transducers, we obtain advantageous closure properties andcomparatively low complexities.Intuitively, a NWT T works much like a NWA with output and additional ǫ -transitions – T reads its input from left to right and decides nondeterministicallywhich available transition to use; on an opening (resp. closing) transition, itreads an opening (closing) input tag, changes its linear state and pushes (pops)a hierarchical state while producing an output. Opening (closing, internal) ǫ -transitions do not consume input symbols but induce state changes and outputs. T only produces an output string if it accepts the input string. Definition 2. A nested word transducer (or NWT ) is a tuple T “ p Q, P, P ǫ , Σ , δ, q , F q consisting of a set Q of linear states , a set P of hierarchical states , a set P ǫ Ď P of hierarchical ǫ -states , an alphabet Σ, a transition relation δ , whichis the union of three relations from p Q ˆ p h Σ i Y t h ǫ i uq ˆ Q ˆ P ˆ ˆΣ ˚ q (called opening transitions), p Q ˆ t ǫ u ˆ Q ˆ NW p Σ qq (called internal transitions) and p Q ˆ P ˆ p h { Σ i Y t h { ǫ i uq ˆ Q ˆ ˆΣ ˚ q (called closing transitions), an initial state q P Q , and a set of accepting states F Ď Q , such that for all q, q , r, r P Q , p P P , a P Σ Y t ǫ u and u, v P ˆΣ ˚ it holds that • p q, h ǫ i , q , p, u q P δ or p q, p, h { ǫ i , q , u q P δ if and only if p P P ǫ ( ǫ -consistency ), • if p q, h a i , q , p, u q P δ and p r, p, h { a i , r , v q P δ , then uv P NW p Σ q ( well-formedness ), and These three conditions make NWT roughly correspond to synchronized visibly pushdowntransducers [13]; we mainly require them to ensure closure of regular nested word languagesunder NWT transduction. a a fb b ǫ : ǫǫ : ǫ ǫ : ǫ h a i : p a , h a ih b i : p b , h a ih { a i , p a : h { a ih { b i , p b : h { a i ǫ : ǫ h ǫ i : p ǫa , h a i ǫ : ǫ h a i : p a , h b ih b i : p b , h b ih { a i , p a : h { b ih { b i , p b : h { b i ǫ : ǫ h ǫ i : p ǫb , h b ih { ǫ i , p ǫa : h { a ih { ǫ i , p ǫb : h { b i Figure 3: Nested Word Transducer T ab from Example 3. • for each p q, h a i , q , p, u q P δ (resp. p r, p, h { a i , r , u q P δ ) with u ‰ ǫ , u contains at least one unmatched opening (resp. closing) tag ( synchroni-sation ).As for standard NWA, we also write p q , p, u q P δ p q, h a i q (resp. p q , u q P δ p q, p, h { a i q , p q , u q P δ p q, ǫ q ) instead of p q, h a i , q , p, u q P δ (resp. p q, p, h { a i , q , u q , p q, ǫ, q , u q P δ ). A detailed semantics definition can be found in the appendix. Example 3.
Figure 3 shows a NWT T ab , with linear states displayed as circlesand transitions as arrows. From the initial state i , T ab branches nondetermin-istically into either state a or b . In state a , T ab checks that the input stringis well-nested just as the NWA A from Example 1. During this check, T ab outputs h a i (resp. h { a i ) for each opening (resp. closing) input tag, effectivelyrelabelling the input string to consist exclusively of a -labelled tags. In state a , T ab inserts into the output string an arbitrary number of opening h a i tags,for which a matching number of h { a i tags are inserted in state f before T ab accepts. The behaviour of T ab in states b and b is analogous, but outputs con-sist only of b -labelled tags. Altogether, T ab chooses nondeterministically some x P t a, b u , relabels all tags of a well-nested input string into x -labelled tags andthen appends a string of the form h x i n h { x i n .The image T p w q of a well-nested string w P NW p Σ q under T is the set of alloutputs of T on w according to some accepting run of T on w . This definitionextends to sets of input strings in the natural way: For a set S Ď NW p Σ q , wedefine T p S q “ Ť w P S T p w q . The domain D p T q of T is the set of all strings w such that T p w q ‰ H , and the range R p T q of T is the set of all strings u suchthat there exists a w P NW p Σ q with u P T p w q , i.e. the set of all possible outputsof T .We next define several restrictions on the expressiveness of NWT. Definition 4.
Let T “ p Q, P, P ǫ , Σ , δ, q , F q be a NWT. We call T • ǫ -free if P ǫ “ H and δ contains no ǫ -transitions. • non-deleting if the output component of every non-internal transition in δ is a non-empty string; • deterministic (or a DNWT) if for every q P Q, p P P and a P Σ, it holdsthat | δ p q, h a i q| “ | δ p q, p, h { a i q| “ a relabelling transducer if it is ǫ -free and for every q, q P Q, p P P , a P Σand u P Σ ˚ , if p q , p, u q P δ p q, h a i q , then u P h Σ i , and if p q , u q P δ p q, p, h { a i q ,then u P h { Σ i ; • functional , if for every w P NW p Σ q , it holds that | T p w q| “ ǫ -free NWT is at mostlinear in the length of the input string, while outputs of general NWT may growto an arbitrary length. We note that functionality, unlike the other restrictionsdefined here, is a semantic condition. We do not investigate in this paper thedecidability or complexity of determining whether a NWT is functional; likely,techniques for Visibly Pushdown Transducers in [8] could be adapted for thispurpose. Also, while determinism implies functionality, the converse does nothold.The following lemma shows that we can assume without loss of generalitythat each transition of a NWT involves at most one input and at most one outputsymbol, i.e. each opening (closing) transition outputs at most one opening(closing) tag and each internal ǫ -transition outputs nothing. Lemma 5.
Each NWT T “ p Q, P, P ǫ , Σ , δ, q , F q can be transformed in poly-nomial time into an NWT T “ p Q , P , P ǫ , Σ , δ , q , F q with T p w q “ T p w q foreach w P NW p Σ q , such that for any transition in δ with output u , it holds that | u | ď normal form .In most of this paper, we restrict our attention to non-deleting transducers.This is because regular nested word languages are closed under transduction bynon-deleting NWT, which does not hold in the presence of deletions (consider,for instance, a NWT deleting all matched opening and closing c -labelled tags onthe regular input language tp h a ih { a ih c i q n p h { c ih b ih { b i q n | n ě u ). The practicalmotivation for desiring this property is the fact that the AXML setting assumesthat function call results can be specified by standard XML schema languages,which are subclasses of regular nested word languages.Moreover, for most of the transducer models examined here, non-deletingtransducers are not a significant restriction when it comes to context-free games,as the following result states. Lemma 6.
Any context-free game G “ p Σ , Γ , R, T q with NWT R can be trans-formed in polynomial time into a game G “ p Σ , Γ , R , T q such that R isnon-deleting and it holds that JWin p G q X NW p Σ q “ JWin p G q .Using Lemma 5, it is comparatively easy (if tedious) to prove that non-deleting NWTs are closed under composition. This proof, like most proofs forproperties of NWT in this section, follows proof ideas used in [8, 13] adapted tothe specifics of NWT. Proposition 7.
Let T , T be non-deleting NWT. Then there exists a non-deleting NWT T such that for all w P NW p Σ q , it holds that T p w q “ p T ˝ T qp w q def “ T p T p w qq . This NWT T can be computed from T and T in poly-nomial time and is of size O p| T | ¨ | T |q .Since we are solely interested in NWTs operating on well-nested strings,we restrict our attention to NWTs with well-nested domains. The followingcorollary to Proposition 7 justifies this restriction.9 orollary 8. Let T be a non-deleting NWT and A a NWA over alphabetΣ. Then, there exists a non-deleting NWT T of size O p| T | ¨ | A |q such that D p T q “ D p T q X L p A q and T p w q “ T p w q for each w P D p T q X L p A q .In order to prove closure of regular nested word languages under transductionby non-deleting NWT, we observe another helpful property of these transducers. Lemma 9.
Let T be a non-deleting NWT with D p T q Ď NW p Σ q . Then R p T q is a regular language of nested words. Corollary 10.
Regular nested word languages are closed under transductionby non-deleting NWT, i.e. if L Ď NW p Σ q is regular and T an NWT, then T p L q is regular.We now turn to the complexity of standard decision problems for NWT. Theupper bounds use relatively simple constructions based on Proposition 7, whilelower bounds follow from comparable results for NWA. Theorem 11.
The membership problem for non-deleting NWT (Given a non-deleting NWT T and strings w, u P NW p Σ q , is u P T p w q ?) is in PTIME . Theorem 12.
The nonemptiness problem for non-deleting NWT (Given a non-deleting NWT T , is there a string w P NW p Σ q with T p w q ‰ H ?) is PTIME -complete with regard to logspace reductions.
Theorem 13.
The type checking problem for non-deleting NWT (Given a non-deleting NWT T and NWA A , A , is T p L p A qq Ď L p A q ?) is(a) EXPTIME -complete in general, and(b)
PTIME -complete (w.r.t. logspace reductions) if A is a DNWA. Having laid the foundation with basic results on NWT, we now examine context-free games with NWT-based replacement. The main characteristic distinguish-ing general NWT from ǫ -free NWT is the fact that, for any input string w and NWT T , transducts in T p w q may be arbitrarily large in the size of w .This behaviour is necessary if we want to simulate games with regular replace-ment languages (in the sense of [14]) by transducer-based games. As it turnsout, however, NWT-based replacement is much more complex than that: thewinning problem in games with replay becomes undecidable (as opposed to with regular replacement languages), which may be proven by arather straightforward reduction from the complement of the halting problemfor Turing machines. Theorem 14.
For the class of games with NWT and Call depth k ě JWin is not recursively enumerable.Even the replay-free winning problem for
Juliet is quite hard when us-ing NWT for replacement – we show that this problem is complete for doublyexponential time. The lower bound uses a rather intricate reduction from atwo-player tiling problem, while the upper bound is proven by reduction to thepurely NWT-based problem of alternating iterated transduction , which can beproven to be in . 10 heorem 15.
For the class of replay-free games with NWT,
JWin is -complete.The lower bound proofs for both of these results require replacement trans-ducers to output nested words of arbitrary depth. Considering our practicalmotivation, it is rarely required that function calls in Active XML documentsreturn arbitrarily deep trees. Therefore, we now investigate the impact of lim-iting replacement transducers’ output depth.For simplicity’s sake, we assume depth-boundedness as a semantic restric-tion, i.e. we assert that all outputs in R p w q produced by a depth-bounded re-placement transducer R on a string w obey a given upper bound on their depth,without examining the decidability and complexity of determining whether ornot a given transducer is depth-bounded.We note that NWT with an output depth linear in the size of the input stringare already strictly more expressive than ǫ -free NWT, so the lower bounds fromSection 5 also hold for NWT with linear output depth. As these lower boundsare already quite high, we focus only on transducers whose output depth isbounded by a constant. Definition 16.
An NWT R is called depth-bounded if there is some constant d ě w P NW p Σ q and any w P R p w q , the depth of w is atmost d .Using depth-bounded NWT as replacement transducers places the complex-ity of the winning problem between those for general NWT and for ǫ -free NWT.The upper and lower bounds are proven similarly to those of Theorem 15, butuse the fact that the stack size of a depth-bounded NWT on a fixed input isbounded by a constant. Theorem 17.
For the class of replay-free games with depth-bounded NWT,
JWin is EXPSPACE -complete. ǫ -free NWT replacement In this section, we examine context-free games with replacement relations givenby ǫ -free NWT. As we shall see, this leads to a decidable winning problem forgames with bounded replay, but non-elementary complexity in all but the easiestcase. For the unbounded replay case, we can construct a rather straightforwardreduction from the halting problem for TMs. Theorem 18.
For the class of games with ǫ -free NWT and unbounded replay, JWin is undecidable.Different from games with general NWT, the winning problem for
Juliet in games with ǫ -free NWT and fixed Call depth is decidable; however, thecomplexity of deciding JWin is already non-elementary for Call depth 2.
Theorem 19.
For the class of games with ǫ -free NWT and Call depth boundedby d ě JWin is decidable, but not decidable in elementary time.Even for replay-free games with ǫ -free NWT, the complexity of deciding thewinning problem for Juliet is still rather high. The lower bound is proven by11eduction from a tiling problem, and the co-NEXPTIME algorithm uses non-determinism to guess moves for
Romeo while trying out all possible strategiesfor
Juliet by backtracking.
Theorem 20.
For the class of replay-free games with ǫ -free NWT, JWin iscomplete for co-NEXPTIME .The non-elementary lower bound in Theorem 19 follows from the fact that,in each string returned by
Romeo , Juliet may play Call arbitrarily often. Ona return string corresponding to a path of length n , Juliet may play Call onall n nodes bottom-up, with each such Call doubling the number of nodes belowthe called node, inducing a non-elementary blow-up.To avoid this, we now examine games with bounded Call width , where,intuitively,
Juliet may only play Call for a bounded number of times in eachreplacement string given by
Romeo . Note that Call width is counted withineach individual replacement string – so, in a game of Call depth 3 and Callwidth c , if Juliet plays Call on some position of the input string, she may thenplace up to c calls within the string returned by Romeo , and again up to c callsin each of the depth-2 replacement strings resulting from those calls.More formally, the Call width of a play Π is the maximum number of times Juliet plays Call in any replacement string given by
Romeo in Π. This def-inition extends naturally into that of Call width of a strategy. Note that Callwidth only applies to replacement strings, so
Juliet may still call arbitrarilymany positions of the input string, even for games with Call width 0. For thisreason, replay-free strategies always have bounded Call width.The proof of Theorem 18 shows that
JWin remains undecidable for gameswith unbounded Call depth, even with Call width bounded by 1. For boundedreplay, though, the complexity of
JWin collapses to that of the replay-free caseif Call width is bounded.
Theorem 21.
For the class of games with ǫ -free NWT, Call depth bounded by d ě k ě JWin is co-NEXPTIME -complete.As mentioned above, bounded Call width does not affect Juliet ’s optionsfor Call moves on the input string, as we generally want
Juliet to be able to atleast process all function symbols in the input. Dropping this requirement (i.e.bounding
Call width including input ) yields at least an exponential improvementin complexity.
Theorem 22.
For the class of games with ǫ -free NWT, Call depth bounded by d and Call width including input bounded by k , JWin is(a) co-NP -complete for d ě k ě co-NP -complete for d ě k ě
1, and(c) in
PTIME for d “ k “ Juliet and the occurring replacement strings.12
Games with relabelling replacement
As seen before, even the limited amount of insertion allowed by ǫ -free NWTrenders the winning problem for Juliet quite complex. We now examine howthis changes if we disallow insertion entirely. First, we show that the winningproblem is greatly simplified by the fact that transducts of relabelling trans-ducers do not require any additional space beyond that provided by the input.In fact, the upper bounds of Theorems 23 to 26 all use a nigh-trivial (alter-nating or nondeterministic) algorithm that simply simulates the game. Lowerbounds, on the other hand, are proven by reduction from the word problem forlinearly bounded (alternating) Turing machines (Theorems 23 and 25) and fromstandard logic-based problems (Theorems 24 and 26).
Theorem 23.
For the class of games with relabelling transducers and un-bounded replay,
JWin is EXPTIME -complete.With limited or no replay, the complexity decreases even further.
Theorem 24.
For any k ě
1, for the class of games with relabelling transducersand bounded Call depth k , JWin is PSPACE -complete.As the winning problem for
Juliet remains intractable (assuming
PTIME ‰ PSPACE ) for replay-free games with relabelling transducers, we now turn tothe even more limited class of functional relabellings. Note that games withfunctional transducers are essentially “solitaire games” for
Juliet , as they donot allow for any choice of transducts by
Romeo . Theorem 25.
For the class of games with functional relabelling transducersand unbounded replay,
JWin is PSPACE -complete.As for general relabelling transducers, the complexity of
JWin is the samefor games with bounded replay and no replay when restricted to functionalrelabelling transducers.
Theorem 26.
For any k ě
1, for the class of games with functional relabellingtransducers and bounded Call depth k , JWin is NP -complete.We see that even in this very simple class of games, we still fail to obtain a PTIME upper bound. Careful examination of lower bound proofs shows thatour semantics for replay-free games still allows for a sort of “hidden replay”:On a string of the form h a ih b i v h { b ih { a i , if Juliet plays Call first on h { b i thenon h { a i , the substring v undergoes two transductions – one from the Call to h { b i , another from the Call to h { a i . This allows us to perform any number d oftransductions on a given string by enclosing it inside d nested function symbols.Excluding this hidden replay yields a very narrow restriction of context-free games, which we call write-once games. In these, no substring may betransduced more than once, i.e. Juliet may only play Call on any closing tag h { a i if the substring enclosed in it does not contain a substring on which Juliet has played Call before. Note that write-once games are always replay-free, buteven weaker as far as
Juliet ’s rewriting capabilities are concerned.A slight adaptation of the proof of Theorem 24 shows that
JWin remains
PSPACE -hard for write-once games with arbitrary relabelling transducers; forfunctional (and deterministic) relabelling transducers, however, we can prove13ractability. The proof constructs from a given game G a NWT R J such thatfor each w P NW p Σ q , the set of all strings into which Juliet way rewrite w in G is given by R J p w q . Theorem 27.
For the class of write-once games with functional relabellingtransducers,
JWin is in
PTIME . The research presented in this paper shows that a major challenge in usingtransducers for context-free games is finding sensible transducer models andstrategy restrictions that do not cause a prohibitive increase in the complex-ity of the winning problem compared to context-free games without parametertransformation. This paper has made a first step towards identifying what suit-able restrictions may look like; however, the few tractable cases identified hereare still so restricted that they may be only of limited practical interest.It is possible that the complexity of the winning problem in games with re-placement transducers may be further reduced by restricting relevant schemasto be closer to practical schema specifications for XML (such as DTDs or XMLSchema). However, since research in [14] indicates that specifications of inputschemas for external services influence the complexity of the safe rewriting prob-lem, further research might be necessary to find transducer models whose inputand output schemas can be described by DTDs or XML Schema.
References [1] Serge Abiteboul, Omar Benjelloun, and Tova Milo. The Active XMLproject: an overview.
VLDB J. , 17(5):1019–1040, 2008.[2] Serge Abiteboul, Tova Milo, and Omar Benjelloun. Regular rewriting ofactive XML and unambiguity. In
PODS , pages 295–303, 2005.[3] Rajeev Alur and P. Madhusudan. Adding nesting structure to words.
J.ACM , 56(3), 2009.[4] Henrik Bj¨orklund, Martin Schuster, Thomas Schwentick, and Joscha Kul-batzki. On optimum left-to-right strategies for active context-free games.In
ICDT , pages 105–116, 2013.[5] A. K. Chandra, D. Kozen, and L. J. Stockmeyer. Alternation.
Journal ofthe ACM , 28(1):114–133, 1981.[6] B. S. Chlebus. Domino-tiling games.
Journal of Computer and SystemSciences , 32(3):374–392, 1986.[7] Stephen A. Cook. A hierarchy for nondeterministic time complexity.
J.Comput. Syst. Sci. , 7(4):343–353, 1973.[8] Emmanuel Filiot, Jean-Fran¸cois Raskin, Pierre-Alain Reynier, Fr´ed´eric Ser-vais, and Jean-Marc Talbot. Properties of visibly pushdown transducers.In
MFCS , pages 355–367, 2010. 149] E. Gr¨adel, W. Thomas, and T. Wilke, editors.
Automata, Logics, andInfinite Games. A Guide to Current Research . Springer, 2002.[10] John E. Hopcroft, Rajeev Motwani, and Jeffrey D. Ullman.
Introduction toautomata theory, languages, and computation - (2. ed.) . Addison-Wesleyseries in computer science. Addison-Wesley-Longman, 2001.[11] Tova Milo, Serge Abiteboul, Bernd Amann, Omar Benjelloun, and Fred-eric Dang Ngoc. Exchanging intensional XML data.
ACM Trans. DatabaseSyst. , 30(1):1–40, 2005.[12] Anca Muscholl, Thomas Schwentick, and Luc Segoufin. Active context-freegames.
Theory Comput. Syst. , 39(1):237–276, 2006.[13] Jean-Fran¸cois Raskin and Fr´ed´eric Servais. Visibly pushdown transducers.In
ICALP (2) , pages 386–397, 2008.[14] Martin Schuster and Thomas Schwentick. Games for Active XML revisited.In
ICDT , pages 60–75, 2015.[15] Fr´ed´eric Servais.
Visibly pushdown transducers . Dissertation, ULB Bel-gique, 2011.[16] Alex Thomo, S. Venkatesh, and Ying Ying Ye. Visibly pushdown trans-ducers for approximate validation of streaming xml. In
FoIKS .[17] Margus Veanes. On computational complexity of basic decision problemsof finite tree automata. Technical report, UPMAIL Technical Report 133,Uppsala University, Computing Science Department, 1997.15
Appendix
For easier reference, we restate the results that were already stated in the bodyof the paper. Definitions and results not stated in the body can be identifiedby their number of the type A.xxx.
Additional preliminaries
This section gives additional notations and definitions needed only for proofs inthe following sections.
Nested words
For the purpose of reductions, we will sometimes need toencode flat strings as nested strings; for a string w “ w ¨ ¨ ¨ w n P Σ ˚ with w , . . . , w n P Σ, the standard nested string encoding p w of w is p w “ h w ih { w i . . . h w n ih { w n i P NW p Σ q . Nested word automata A configuration κ of A is a tuple p q, α q P Q ˆ P ˚ ,with a linear state q and a sequence α of hierarchical states, reflecting thepushdown store. A run of A on w “ w . . . w n P NW p Σ q is a sequence κ , . . . , κ n of configurations κ i “ p q i , α i q of A such that for each i P r n s and a P Σ it holdsthat κ i is a successor configuration of κ i ´ with w i , i.e. that • if w i “ h a i , then p q i ´ , h a i , q i , p q P δ (for some p P P ), and α i “ pα i ´ , or • if w i “ h { a i , then p q i ´ , p, h { a i , q i q P δ (for some p P Q ), and pα i “ α i ´ .In this case, we also write κ w ❀ A κ n . We say that A accepts w if p q , ǫ q w ❀ A p q , ǫ q for some q P F . The language L p A q Ď NW p Σ q is defined as the set of allstrings accepted by A . Context-free games
Towards a formal definition of play, a configuration is atuple κ “ p p, u, v q P t J , R uˆ ˆΣ ˚ ˆ ˆΣ ˚ where p is the player to move, uv P NW p Σ q is the current word , and the first symbol of v is the current position . A winningconfiguration for Juliet is a configuration κ J “ p J , u, ǫ q with u P T , and a winning configuration for Romeo is a configuration κ R “ p R , u h a i v, h { a i u q ,with h a i v h { a i P rNW p Σ q such that there is no v P NW p Σ q with p h a i v h { a i , v q P R . The configuration κ “ p p , u , v q is a successor configuration of κ “ p p, u, v q (Notation: κ Ñ κ ) if one of the following holds:(1) p “ p “ J , u “ us , and sv “ v for some s P ˆΣ ( Juliet plays Read);(2) p “ J , p “ R , u “ u , v “ v “ h { a i z for z P ˆΣ ˚ , a P Γ, (
Juliet plays Call);(3) p “ R , p “ J , u “ x h a i y , v “ h { a i z for x, z P ˆΣ ˚ , h a i y h { a i P rNW p Σ q , u “ x and v “ y z for some y P NW p Σ q with p h a i y h { a i , y q P R ( Romeo plays y ).The initial configuration of game G for string w is κ p w q def “ p J , ǫ, w q . A play of G is either an infinite sequence Π “ κ , κ , . . . or a finite sequenceΠ “ κ , κ , . . . , κ k of configurations, where, for each i ą κ i ´ Ñ κ i and, inthe finite case, κ k has no successor configuration. In the latter case, Juliet wins the play if κ k is a winning position for Juliet , in all other cases,
Romeo wins. 16 trategies A strategy for player p P t J , R u maps prefixes κ , κ , . . . , κ k ofplays, where κ k is a p -configuration, to allowed moves. We denote strategies for Juliet by σ, σ , σ , . . . and strategies for Romeo by τ, τ , τ , . . . .A strategy σ is memoryless if, for every prefix κ , κ , . . . , κ k of a play, theselected move σ p κ , κ , . . . , κ k q only depends on κ k . As context-free games arereachability games we only need to consider memoryless strategies; see, e.g., [9]. Proposition A.1.
Let G be a context-free game, and w a string. Then either Juliet or Romeo has a winning strategy on w , which is actually memoryless.Therefore, in the following, strategies σ for Juliet map configurations κ tomoves σ p κ q P t Call , Read u and strategies τ for Romeo map configurations κ tomoves τ p κ q P NW p Σ q .For configurations κ, κ and strategies σ, τ we write κ σ,τ ÝÑ κ if κ is theunique successor configuration of κ determined by strategies σ and τ . Given aninitial word w and strategies σ, τ the play Π p σ, τ, w q def “ κ p w q σ,τ ÝÑ κ σ,τ ÝÑ ¨ ¨ ¨ is uniquely determined. If Π p σ, τ, w q is finite, we denote the word representedby its final configuration by word G p w, σ, τ q .A strategy σ for Juliet is finite on string w if the play Π p σ, τ, w q is finitefor every strategy τ of Romeo . It is a winning strategy on w if Juliet wins theplay Π p σ, τ, w q , for every τ of Romeo . A strategy τ for Romeo is a winningstrategy for w if Romeo wins Π p σ, τ, w q , for every strategy σ of Juliet . Weonly consider finite strategies for
Juliet , due to
Juliet ’s winning condition. Wedenote the set of all finite strategies for
Juliet in the game G by STRAT J p G q ,and the set of all strategies for Romeo by STRAT R p G q . Tilings
Several of our lower bound proofs use algorithmic problems involvingtilings. We will define the individual algorithmic problems in later sections asneeded and only give basic common definitions here.A tiling of height m and width ℓ (or m ˆ ℓ -tiling ) over a tile set U with vertical constraints V Ď U ˆ U , horizontal constraints H Ď U ˆ U , initial tile u i P U and final tile u f P U is a mapping t : r m s ˆ r ℓ s Ñ U such that • p t p i, j q , t p i ` , j qq P V for each i P r m ´ s and j P r ℓ s , • p t p i, j q , t p i, j ` qq P H for each i P r m s and j P r ℓ ´ s , • t p , q “ u i , and • t p m, ℓ q “ u f .Intuitively, a tiling arranges m ¨ ℓ tiles from U in m rows and ℓ columns suchthat the first row starts with the initial tile, the last row ends with the finaltile and horizontally or vertically adjacent tiles match (as per the horizontaland vertical constraints). Accordingly, for a tiling t of width ℓ and height m , we refer to the string t p i, q t p i, q ¨ ¨ ¨ t p i, ℓ q P U ˚ as the i -th row and to t p , j q t p , j q ¨ ¨ ¨ t p m, j q P U ˚ as the j -th column of t .We will often encode an m ˆ ℓ -tiling t as a string w t of the form p U ℓ q m using a special line divider symbol R U , with the interpretation that t p i, j q isthe p i ´ q ¨ p ℓ ` q ` m -th symbol of w t . As the underlying game G will always be clear from the context, our notation does notmention G explicitly. roofs and additional results for Section 3 The following result is used in several complexity proofs for Section 3.
Theorem A.2.
The emptiness problem for DNWA (given a DNWA A , is L p A q “ H ?) is complete for PTIME with regard to logspace reductions.
Proof.
The upper bound was proven in [3]. The lower bound can be provenby a straightforward (if technical) reduction from the emptiness problem fordeterministic top-down tree automata (cf. Section 7.2 in [3] and Theorem 1 in[17]).In the next subsection, we extend nested word automata by (internal) ǫ -transitions. These ǫ -NWA will be of use in the proofs for section 3. Nested Word Automata with ǫ -transitions It is well known (see, for instance, [10]) that extending finite-state automatawith ǫ -transitions does not change their expressive power; (nondeterministic)finite-state automata with ǫ -transitions still decide exactly the class of regularlanguages of flat strings.Even though nested word automata and the class of regular nested wordlanguages strongly parallel finite-state automata and flat regular languages, asimilar investigation has so far not been performed for nested word automata.We now define and examine nested word automata with ǫ -transitions, mainlyas a tool for the analysis of nested word transducers with ǫ -transitions. Definition A.3. A Nested Word Automaton with ǫ -transitions ( ǫ -NWA) A “p Q, P, Σ , δ, q , F q consists of • a set Q of linear states , • a set P of hierarchical states , • an alphabet Σ, • a transition relation δ Ď p Q ˆ h Σ i ˆ Q ˆ P qYp Q ˆ P ˆ h { Σ i ˆ Q qYp Q ˆt ǫ uˆ Q q , • an initial state q P Q , and • a set of accepting states F Ď Q .As for standard NWA, we also write p q , p q P δ p q, h a i q (resp. q P δ p q, p, h { a i q , q P δ p q, ǫ q ) instead of p q, h a i , q , p q P δ (resp. p q, p, h { a i , q q , p q, ǫ, q q P δ ).Note that ǫ -transitions are always internal transitions that merely changethe current linear state, not the hierarchical stack; allowing ǫ -transitions tomanipulate the stack as well would yield a strictly more expressive automatonmodel.The semantics of ǫ -NWA is defined almost exactly like that of NWA, byway of (accepting) runs. The only difference is that for a run κ , . . . , κ n of an ǫ -NWA A “ p Q, P, Σ , δ, q , F q on a nested string w P NW p Σ q , it merely holdsthat n ě | w | , and each configuration κ i is either a successor configuration of κ i ´ with the next unread symbol of w (as defined in Section 2), or a successorconfiguration with ǫ , i.e. κ i ´ “ p q, α q , κ i “ p q , α q and p q, ǫ, q q P δ .18he following properties of ǫ -NWA follow easily from the proofs for corre-sponding properties of NWA in [3]. Lemma A.4.
For each ǫ -NWA A , there exists a DNWA A of size at mostexponential in | A | such that L p A q “ L p A q . Proof. (Sketch) The proof of this statement for NWA without ǫ -transitions inTheorem 3.3 of [3] uses a modified subset construction, where states of theexponential-sized DNWA A correspond to sets of pairs of states of A (so-called summaries ) such that if a (not necessarily well-nested) string w induces a (par-tial) run from the initial state of A to some summary state S P P p Q ˆ Q q , thenthere are (partial) runs with w from each q P Q to all q P t q | p q, q q P S u in A . To account for ǫ -transitions, we modify these summaries to include ǫ -closures of target states, i.e. for each pair p q, q q of states contained in a summary S asconstructed in [3], we add to S all pairs p q, q q , where q is reachable from q by a series of ǫ -transitions in A . Otherwise, the construction (and correctnessproof) is the same as in [3]. Lemma A.5.
For all ǫ -NWA A and A , it is possible to construct in polynomialtime ǫ -NWA deciding L p A q Y L p A q and L p A q X L p A q . Proof. (Sketch) This proof, like the one for Theorem 3.5 in [3], uses a stan-dard product construction simulating A and A simultaneously on the input.The product automaton A “ p Q ˆ Q , P ˆ P , Σ , δ , p q , , q , q , F q is con-structed as in [3] and simply extended by ǫ -transitions. Note that, unlike read-ing transitions, ǫ -transitions do not have to be synchronised between the twoautomata, i.e. an ǫ -transition of A simulates an ǫ -transition of only one ofthe component automata A or A . The transition relation δ of A is there-fore extended by the sets tpp q , q q , ǫ, p q , q qq | p q , ǫ, q q P δ , q P Q u and tpp q , q q , ǫ, p q , q qq | p q , ǫ, q q P δ , q P Q u . Theorem A.6. (a) The membership and emptiness problem for ǫ -NWA are in PTIME .(b) The universality, equivalence and inclusion problem for ǫ -NWA are EXPTIME -complete.(c) Deciding, given an ǫ -NWA A and a DNWA B , whether L p A q Ď L p B q is PTIME -complete with respect to logspace reductions.
Proof.
These complexity properties mostly follow from the corresponding resultsfor NWA without ǫ -transitions, proven in [3] (Proposition 6.1 and Theorem 6.2).For (a), ǫ -NWA may also be interpreted as pushdown automata, whose mem-bership and emptiness problem are decidable in polynomial time.Lower bounds for (b) directly follow from the corresponding lower bounds forNWA without ǫ -transitions. Corresponding upper bounds can be proven usingLemmas A.4 and A.5 as well as the complement construction for DNWA ([3],Theorem 3.5) and set-theoretic formulations for universality (is L p A q “ H ?),equivalence (is p L p A q X L p A qq Y p L p A q X L p A qq “ H ?) and inclusion (is L p A q X L p A q “ H ?).The upper bound in (c) also follows from the fact that DNWA can be ef-ficiently complemented and the fact that L p A q Ď L p B q holds if and only if19 p A q X L p B q “ H . By Lemma A.5 and part (a) of this theorem, this can bechecked in polynomial time.The lower bound in (c) is proven by reduction from the emptiness problemfor DNWA (cf. Theorem A.2). Let B be a DNWA to be checked for emptiness.We can construct in logarithmic space an ǫ -NWA A deciding NW p Σ q , and (since B is deterministic) a DNWA B deciding the complement of L p B q . It then holdsthat L p A q Ď L p B q if and only if L p B q “ NW p Σ q , which is the case if and onlyif L p B q is empty. Proofs for Section 3
We begin by defining the formal semantics of NWT.
Definition A.7.
Let T “ p Q, P, P ǫ , Σ , δ, q , F q be an NWT. A configuration κ “ p q, α q consists of a linear state q P Q and a stack α P P ˚ of hierarchicalstates.For any string w P NW p Σ q , an ǫ -extension of w is a string ˆ w obtained byinserting symbols h ǫ i , h { ǫ i and ǫ into w such that the maximal subsequence of ˆ w consisting only of symbols from ˆΣ Y t h ǫ i , h { ǫ i u is a well-nested word over Σ Y t ǫ u .A run of T on an ǫ -extension ˆ w “ ˆ w . . . ˆ w n of a string w P NW p Σ q startingat configuration p r , α q is a finite sequence ρ “ p r , α qp r , α q . . . p r n , α n q suchthat for each i P r n s , one of the following holds: • ˆ w i “ h a i for some a P Σ Y t ǫ u , p r i , p i , u i q P δ p r i ´ , h a i q and α i “ α i ´ p , • ˆ w i “ ǫ , p r i , u i q P δ p r i ´ , ǫ q and α i “ α i ´ , or • ˆ w i “ h { a i for some a P Σ Y t ǫ u , p r i , u i q P δ p r i ´ , p, h { a i q and α i p “ α i ´ .The run ρ is accepting if r “ q , r n P F , and α “ α n “ ǫ ; in this case, thestring u u . . . u n is considered the output of T on w according to ρ . Note that the semantics for NWT directly carry over to ǫ -free NWT, withthe only ǫ -extension of any w P D p T q on which there are accepting runs of T being w itself. Lemma 5 (restated).
Each NWT T “ p Q, P, P ǫ , Σ , δ, q , F q can be trans-formed in polynomial time into an NWT T “ p Q , P , P ǫ , Σ , δ , q , F q with T p w q “ T p w q for each w P NW p Σ q , such that for any transition in δ withoutput u , it holds that | u | ď .We say that a NWT of this shape is in normal form .Proof. An arbitrary NWT T is transformed into an NWT T in normal formby successively replacing each transition that is not of the required form by asequence of new states and transitions. We only describe this procedure for anopening transition; closing and internal transitions can be handled in a similarmanner.Assume for some q P Q and a P Σ that p q , p , v q P δ p q, h a i q with v “ v ¨ ¨ ¨ v n P ˆΣ ˚ for some n ą
1. We add new states q , . . . , q n ´ to Q and p p ,a to P ǫ . Let k ď n be the position of the last unmatched opening tag in v ,i.e. v ¨ ¨ ¨ v k ´ P ˆΣ ˚ , v k P h Σ i and v k ` ¨ ¨ ¨ v n P NW p Σ q . We add a transition Note that the ǫ -extension ˆ w on which the output u u . . . u n is produced is already implicitin the run ρ , so we do not specify it explicitly. q , p p ,a , v q to δ p q, h ǫ i q , a transition p q k ` , p , v k q to δ p q k , h a i q and, for each i P r n ´ s with i ‰ k , a transition p q i ` , p p ,a , v i q to δ p q i , h ǫ i q if v i P h Σ i , or p q i ` , v i q to δ p q i , p p ,a , h { ǫ i q if v i P h { Σ i , identifying q n with q . Finally, we removethe original transition. This takes care of (reading or ǫ -)transitions producingmore than one output symbol.The resulting NWT T is obviously in normal form. Its equivalence to T isrelatively simple (if tedious) to prove by an induction over the structure of inputstrings, with the main argument using the fact that T fulfils the ǫ -consistencyand well-formedness condition. Notably, these conditions also justify the abovesimplification that newly added ǫ transitions obtained from a transition reading a and pushing the hierarchical state p use solely the new hierarchical ǫ -state p p ,a . Lemma 6 (restated).
Any context-free game G “ p Σ , Γ , R, T q with NWT R can be transformed in polynomial time into a game G “ p Σ , Γ , R , T q suchthat R is non-deleting and it holds that JWin p G q X NW p Σ q “ JWin p G q .Proof. (Sketch) The idea behind this proof is modifying R into R in such a waythat, whenever R would delete some tag h a i (or h { a i ), R instead replaces tagby a special “strike-out” version h a i (or h { a i ) with a R Σ, instead; we thereforeset Σ “ Σ Z t a | a P Σ u . To ensure that iterated transductions respect deletedtags, we add transitions to each state of R that only replace “strike-out” tagsby themselves without changing the state of R . Finally, we similarly modifythe target DNWA for T in order to ignore all tags with labels not in Σ (i.e. onlycheck them for their nesting structure without changing states). Since Juliet may only play Call on symbols from Σ,
Romeo is unable to rewrite “strike-out”symbols, and the DNWA for T ignores symbols outside of Σ, it is clear that Juliet has a winning strategy on any string w P NW p Σ q in G if and only ifshe has a winning strategy on w in G . Proposition 7 (restated).
Let T , T be non-deleting NWT. Then, thereexists a non-deleting NWT T such that for all w P NW p Σ q , it holds that T p w q “p T ˝ T qp w q def “ T p T p w qq . This NWT T can be computed from T and T inpolynomial time and is of size O p| T | ¨ | T |q .Proof. The basic idea behind this construction is simple: The transducer T sim-ulates T on its input and directly feeds the output of T into T . This is doneby a sort of product construction which is, for the most part, quite straight-forward. However, there are some subtleties that need to be addressed, whichstem from the fact that both T and T are NWT, so the various possibilitieshow one of the two transducers might perform a step while the other is idle haveto be dealt with. We note that this proof could be extended to general (notnecessarily non-deleting) NWT, but since the proof details are quite technicalalready, we restrict our attention to non-deleting NWT here.Let T “ p Q , P , P ǫ , Σ , δ , q , F q and T “ p Q , P , P ǫ , Σ , δ , q , F q betwo NWT in normal form. We construct from T and T the NWT T “p Q, P, P ǫ , Σ , δ, q , F q as follows: • Q “ Q ˆ Q , Note that v P h Σ i due to well-formedness. P “ p P Y tKuq ˆ P for a special symbol K not used in T or T , • P ǫ “ p P ǫ ˆ P q Y ptKu ˆ P ǫ q • q “ p q , q q , • F “ F ˆ F , and • δ is constructed as detailed below.The construction of δ is quite straightforward in the case where T producesan output on which T is simulated: If p q , p , h b i q P δ p q , h a i q (or p q , p , h b i q P δ p q , h ǫ i q , respectively) and p q , p , h c i q P δ p q , h b i q , then pp q , q q , p p , p q , h c i q P δ pp q , q q , h a i q (or pp q , q q , p p , p q , h c i q P δ pp q , q q , h ǫ i q , respectively), and anal-ogously for the corresponding closing ( ǫ -) transitions.Internal ǫ -transitions for T and T are also easily handled, as for thesetransitions, neither transducer consumes an input or produces an output. If p q , ǫ q P δ p q , ǫ q , then pp q , q q , ǫ q P δ pp q , q q , ǫ q for each q P Q , and if p q , ǫ q P δ p q , ǫ q , then pp q , q q , ǫ q P δ pp q , q q , ǫ q for each q P Q .The only case requiring special attention is the one where only one of thetwo transducers modifies the input. This happens when T produces an outputsymbol by an ǫ -transition, without T consuming an input symbol. In this case, T produces a hierarchical state while T doesn’t; to this end, some states inthe set P ǫ contain a component K to indicate a “null transition” for T .More formally, if for some q , q P Q , p P P and a P Σ, p q , p , h a i q P δ p q , h ǫ i q , then pp q , q q , pK , p q , h a i q P δ pp q , q q , h ǫ i q for all q P Q (and anal-ogously for closing transitions).It follows directly from the construction that T is ǫ -consistent; the well-formedness condition for T follows from well-formedness of T and T by asimple but lengthy case distinction over all the sorts of transitions introducedhere. Furthermore, since T is obviously in normal form, it automatically fulfilssynchronisation. It remains to be proven that T p w q “ T p T p w qq indeed holdsfor all w P NW p Σ q .To this end, let w P T p T p w qq ; let further ρ be an accepting run of T with output w on an ǫ -extension ˆ w of w , and let ρ be an accepting run of T with output w on an ǫ -extension ˆ w of w . We construct an ǫ -extension ˆ w of w and an accepting run ρ of T on ˆ w with output w .We denote all positions of ˆ w in which T outputs some symbol as .Note that there is a bijective correspondence between positions of w and 1-producing positions of ˆ w and that all h ǫ i - and h { ǫ i -positions of ˆ w are 1-producing.Next, we examine all h ǫ i - and h { ǫ i -positions of ˆ w ; these, we call .Due to the well-formedness and ǫ -consistency restrictions on T and T , it ispossible to insert all h ǫ i -, h { ǫ i - and ǫ -positions of ˆ w into ˆ w in such a way thatwe obtain an ǫ -extension ˆ w of w that has both ˆ w and ˆ w as subsequences.It is now easy to see that an accepting run ρ of T on ˆ w with output w can be obtained by combining the transitions used in ρ and ρ – positions inˆ w that are 1-producing correspond to “standard” transitions of T , ǫ -positionscorrespond to internal ǫ -transitions, and 2-producing positions correspond to ǫ -transitions with a K component in their hierarchical state. This shows that T p T p w qq Ď T p w q .For the other direction, let ρ be a run of T on an ǫ -extension ˆ w of w withoutput w . We label the positions of ˆ w according to the transitions taken22y T in ρ – positions where “standard” transitions are used are labelled as 1-producing, ǫ -positions are labelled as internal, and positions with transitionswhose hierarchical stack contains a K component are labelled as 2-producing.Similar to the previous part of the proof, we can then use these labels to separate ρ into an accepting run ρ of T on an ǫ -extension ˆ w of w with output w and anaccepting run ρ of T on an ǫ -extension ˆ w of w with output w , thus provingthat w P T p T p w qq holds. Corollary 8 (restated).
Let T be a non-deleting NWT and A a NWA overalphabet Σ . Then, there exists a non-deleting NWT T of size O p| T | ¨ | A |q suchthat D p T q “ D p T q X L p A q and T p w q “ T p w q for each w P D p T q X L p A q .Proof. Let T A be a NWT with D p T A q “ L p A q and T A p w q “ t w u for each w P NW p Σ q , i.e. T A accepts exactly the strings in L p A q and simply outputs itsinput string. Such a NWT is easy to construct with a size in O p| A |q .Then, we set T to be the NWT for T ˝ T A as constructed in Proposition7. For each w P L p A q X D p T q , it holds that T p w q “ T p T A p w qq “ T p w q , foreach w R L p A q , T p w q “ T pHq “ H , and for each w P L p A qz D p T q , it holds that T p w q “ T p w q “ H . This proves that D p T q “ D p T q X L p A q and T p w q “ T p w q for each w P D p T q X L p A q . The desired bound on the size of T follows directlyfrom Proposition 7. Lemma 9 (restated).
Let T be a non-deleting NWT with D p T q Ď NW p Σ q .Then R p T q is a regular language of nested words.Proof. Let T “ p Q, P, P ǫ , Σ , δ, q , F q be a non-deleting NWT in normal form.The basic idea behind constructing the ǫ -NWA A for R p T q is taking the inputstring for A and verifying it against the output component of T . This way, it iseasy to ensure that every string in R p T q is accepted by A ; some care has to betaken, however, to make certain that for every string w accepted by A , there isa string w P NW p Σ q such that w P T p w q .Since T is in normal form, all opening transitions in δ are of the form p q, h a i , q , p, h b i q and all closing transitions of the form p q, p, h { a i , q , h { b i q (for a P Σ Y t ǫ u and b P Σ) while internal transitions are of the form p q, ǫ, q , ǫ q .The linear state set of A is Q and its set of hierarchical states is P ˆ p Σ Yt ǫ uq ; its starting and accepting states are those of T . Reading transitionsin A are constructed from those of T by taking, for each opening transition p q, h a i , q , p, h b i q P δ , a transition p q, h b i , q , p p, a qq , and for each closing transition p q, p, h { a i , q , h { b i q P δ , a transition p q, p p, a q , h { b i , q q . Each internal transition p q, ǫ, q , ǫ q P δ translates to an ǫ -transition p q, ǫ, q q in A .To prove correctness of this construction, we need to show that for any string w P NW p Σ q it holds that w P L p A q if and only if w P R p T q .For the “if” direction, if w P R p T q , then there is some w P NW p Σ q such that T has an accepting run ρ on some ǫ -extension of w with output w . Translatingthe transitions of T taken in ρ into transitions of A as per the above constructionnaturally yields an accepting run of A on w .For the “only if” direction, assume that w P L p A q for some w P NW p Σ q .Then, there is an accepting run ρ of A on w . We can construct from ρ an ǫ -extension ˆ w of a string w P NW p Σ q by extracting the sequence of hierarchicalcomponents of transitions in ρ – every opening (closing) transition in ρ withhierarchical component p p, a q with some p P P , a P Σ Y t ǫ u corresponds to23 symbol h a i ( h { a i ) in ˆ w , and every ǫ -transition taken in ρ corresponds to asymbol ǫ in ˆ w . It is clear to see that indeed ˆ w is an ǫ -extension of some string w P NW p Σ q and that there is an accepting run of T on ˆ w that outputs w , whichyields w P R p T q as was to be proven. Corollary 10 (restated).
Regular nested word languages are closed undertransduction by non-deleting NWT, i.e. if L Ď NW p Σ q is regular and T a NWT,then T p L q is regular.Proof. Let A be a NWA for L and T a NWT. From A , we can construct byCorollary 8 a NWT T A with D p T A q “ L X D p T q and T A p w q “ T p w q for each w P D p T A q , which implies that R p T A q “ T p L q . By Lemma 9, this implies that T p L q is regular as well. Theorem 11 (restated).
The membership problem for non-deleting NWT(Given a non-deleting NWT T and strings w, u P NW p Σ q , is u P T p w q ?) is in PTIME .Proof.
From w , we can easily compute a NWA A of size O p w q with L p A q “ t w u .By Corollary 8, we can compute from A and T in polynomial time a non-deletingNWT T w with D p T w q “ D p T q X t w u and R p T w q “ T p w q . By Corollary 10, T p w q is regular, and by Lemma 9 an ǫ -NWA A for T p w q can be computedin polynomial time. This ǫ -NWA is of polynomial size, and checking u formembership in L p A q is possible in polynomial time by Theorem A.6 (a). Theorem 12 (restated).
The nonemptiness problem for non-deleting NWT(Given a non-deleting NWT T , is there a string w P NW p Σ q with T p w q ‰ H ?)is PTIME -complete with regard to logspace reductions.Proof.
By definition, it holds that there is some w P NW p Σ q with T p w q ‰ H if and only if D p T q X NW p Σ q ‰ H . By Corollary 8, we can compute from T a NWT T whose domain is exactly D p T q X NW p Σ q . Clearly, it holds that D p T q ‰ H if and only if R p T q ‰ H , so by Lemma 9 we can extract from T an ǫ -NWA A of polynomial size with L p A q “ R p T q . All of these transformations,as well as testing whether L p A q ‰ H , are feasible in polynomial time. Thisproves the upper bound.The lower bound follows by reduction from the emptiness problem for DNWA(cf. Theorem A.2). Let A “ p Q, P, Σ , δ, q , F q be a DNWA to be tested for non-emptiness. We construct from A a NWT T with T p ǫ q “ L p A q and T p w q “ H forall w ‰ ǫ . The idea behind the reduction is replacing, for each a P Σ, each h a i (resp. h { a i ) transition of A by an h ǫ i (resp. h { ǫ i ) transition in T that writes h a i (resp. h { a i ) as an output. Formally, we set T “ p Q, P ˆ Σ , P ˆ Σ , Σ , δ , q , F q ,where δ contains a transition p q, h ǫ i , q , p p, a q , h a i q (resp. p q, p p, a q , h { ǫ i , q , h { a i q )if and only if δ contains a transition p q, h a i , q , p q (resp. p q, p, h { a i , q q ). Thisconstruction is feasible using logarithmic space, and it holds that T p ǫ q “ L p A q and T p w q “ H for all w ‰ ǫ , so D p T q ‰ H if and only if L p A q ‰ H . Theorem 13 (restated).
The type checking problem for non-deleting NWT(Given a non-deleting NWT T and NWA A , A , is T p L p A qq Ď L p A q ?) is(a) EXPTIME -complete in general, and(b)
PTIME -complete (w.r.t. logspace reductions) if A is a DNWA. roof. The lower bound in (a) follows directly by a reduction from the inclusionproblem for NWA, which is known to be
EXPTIME -complete [3]. Let B and B be NWA to be checked for inclusion of L p B q in L p B q . We can constructin polynomial time a NWT T that simply reproduces each input symbol in theoutput and accepts any input (i.e. T p w q “ t w u for any w P ˆΣ ˚ ). Then, clearly, L p B q Ď L p B q if and only if T p L p B qq Ď L p B q , as T p L p B qq “ L p B q .The lower bound in (b) follows from PTIME -hardness of the emptinessproblem for DNWA by a similar reduction to that used in the proof of TheoremA.6 (c). Let A be a DNWA to be tested for emptiness. We can construct inlogarithmic space an ǫ -NWA A deciding NW p Σ q , and (since A is deterministic)a DNWA A deciding the complement of L p A q . For T , we construct a NWTreproducing its input, i.e. with D p T q “ NW p Σ q and T p w q “ t w u for each w P NW p Σ q . It then holds that T p L p A qq Ď L p A q if and only if L p A q “ NW p Σ q ,which is the case if and only if L p A q is empty.The upper bounds in both (a) and (b) can easily be proven using prior resultsfrom this section. By Corollary 8 and Lemma 9, we can construct in polynomialtime an ǫ -NWA deciding T p L p A qq ; checking this ǫ -NWA for inclusion in L p A q is generally possible in exponential time, and in polynomial time if A is aDNWA by Theorem A.6 (b) and (c). 25 roofs for Section 4 Theorem 14 (restated).
For the class of games with NWT and Call depth k ě , JWin is not recursively enumerable.Proof.
The proof is by reduction from the complement of the halting problemfor Turing machines with an empty input. From a given Turing machine M with working alphabet Σ and state set Q , we construct a game G and string w such that Juliet has a winning strategy on w in G if and only if M doesnot halt on an empty input. The game G uses two function symbols, s and t ,which are not in Σ in order to avoid plays according to G interfering with theworkings of M .The idea behind the reduction is rather simple. The game begins on theinput string h s ih { s i , where Juliet is supposed to Call h { s i as her first move.For his reply, Romeo then picks a number r such that M halts on the emptyinput after exactly r steps (if such a number exists) and returns h t i r p v h { t i r , with p v being a string representing the initial configuration of M on the empty input. Juliet should then call each h { t i in left-to-right order, making Romeo simulatea step of M on the current position of M encoded in the current string. After Juliet has called all r closing h { t i tags and thus rewritten p v into a string p v r representing the configuration of M after r computation steps, Juliet wins thegame if p v r does not represent a halting configuration.We can represent configurations of M as flat strings over the alphabet Σ ˆp Q Yt´uq in the standard fashion – a string p x , ´q ¨ ¨ ¨ p x k ´ i , ´qp x k , q qp x k ` , ´q ¨ ¨ ¨ p x m , ´q denotes that the content of M ’s working tape is x ¨ ¨ ¨ x m , with the head of M being on the tape’s k -th cell and M being in state q . Each such flat string v canthen be represented as a nested string p v using the standard nested word encod-ing defined in the preliminaries. Without loss of generality, we assume that M always moves its head to the left-most used tape cell before halting, i.e. the flatstring encoding of a halting configuration is of the form p Σ ˆ t h uqp Σ ˆ t´uq ˚ for the halting state h of M .It is easy to construct a polynomial-sized NWT rewriting h s ih { s i into a stringof the form h t i r p v h { t i r (for arbitrary r P N and a nested string encoding p v of M ’s initial configuration) and every string h t i p v i h { t i where p v i is the nestedword encoding of some configuration of M into p v i ` , where p v i ` encodes thesuccessor configuration of the one encoded by p v i ; in fact, the latter rewriting iseven functional (if nondeterministic for requiring a look-ahead when M movesits head to the left). We can also easily construct a DNWA accepting all nested-word encodings of non-halting configurations of M .It only remains to be explained how we ensure that the game is played inthe fashion sketched above, i.e. that Juliet plays Call first on h { s i and then oneach h { t i in left-to-right order. To keep Juliet from leaving h { s i or some h { t i uncalled, we simply set up the target DNWA such that it doesn’t accept anynested strings containing tags with labels s or t . Finally, to safeguard against Juliet skipping some h { t i before calling the next, we modify the replacementtransducer R in such a way that it rejects any input string containing two ormore nested t tags, i.e. strings of the form h t ih t i v h { t ih { t i with v P NW p Σ q .In the game G thus constructed, Juliet clearly has a winning strategyon w “ h s ih { s i if and only if there is no r such that M reaches a haltingconfiguration within r steps, i.e. if M doesn’t halt.26e now prove the lower and upper bounds for Theorem 15. Since context-free games with general and with non-deleting NWT are polynomially equivalentby Lemma 6, we prove the lower bound for general NWT and the lower boundfor non-deleting NWT. Proposition A.8.
For the class of replay-free games with NWT,
JWin is -hard. Proof.
The proof is by reduction from the complement of the problem. In this problem, we are given a tiling instance consisting of a tile set U ,vertical and horizontal constraints V , H , initial and final tile u i , u f and unarynumber n and consider the following game: Player 1 and Player 2 place tilesfrom U in an alternating fashion (starting with u i for Player 1); Player 1 winsthe game if Player 2 places a tile violating some vertical or horizontal constraint,or some player places a tile completing a valid tiling of width 2 n ´
1, while Player2 wins if Player 1 places an invalid tile or if the game does not terminate with avalid tiling. asks whether, givena tiling instance, Player 1 has a winning strategy in this game. This problem(and therefore also its complement problem of determining whether Player 2has a winning strategy) is complete for
AEXPSPACE “ [6].Given a tiling instance I “ p U, V, H, u i , u f , n q , we construct a game G “p Σ , Γ , R, T q and string w such that Juliet has a winning strategy in G on w if and only if Player 2 has a winning strategy in the exponential-width tilinggame on instance I .The input string is w “ p h d ih e i q n h s ih { s i p h { e ih { d i q n . The basic idea behindthe game G is that Juliet is first supposed to play Call on h { s i , to which Romeo should give a witness for the existence of a winning strategy for Player1 in the tiling game.
Juliet should then use calls to the rest of the input stringto uncover a flaw in
Romeo ’s witness and thus have a winning strategy in G on w if and only if Romeo cannot prove the existence of a winning strategy forPlayer 1.More concretely,
Romeo should give as his witness (a slightly modified lin-earisation of) a strategy tree for Player 1, in which nodes are labelled with tilesfrom two disjoint copies U , U of U , representing moves by Player 1 and Player2. Each node labelled with an element of U has a single child (corresponding toa move of Player 1), each node labelled with an element of U has | U | children(corresponding to the possible moves of Player 2) and the sequence of labels oneach path from the root to a leaf (called a tiling candidate ) either makes up avalid tiling or contains an invalid move by Player 2. Replacement strings for Romeo on a Call to h { s i will be somewhat extended linearisations of strategytrees, with extensions that we will discuss later on.Proof trees given by Romeo should be restricted (by construction of thereplacement transducer R ) to only represent tiling candidates that start withthe initial tile u i and contain no horizontal errors. Juliet ’s task in trying toinvalidate
Romeo ’s proof tree therefore consists of uncovering vertical errorsand incorrect final tiles (as well as encoding errors within the aforementionedextensions, to be discussed later). To this end,
Juliet uses Call moves on h { e i and h { d i tags to select parts of the proof tree given by Romeo that correspondto a fixed column in each tiling candidate represented in the proof tree; if thiscolumn contains an error in at least one of these tiling candidates (which shouldbe detected by the target language DNWA),
Juliet wins the game.27e now describe how strategy trees should be encoded. Throughout therest of the proof, we will identify nested words and their forest representationsto simplify presentation.The most intuitive approach to generate strategy trees in which all tilingcandidates are horizontally correct would be to fix the replacement transducerin such a way that each node labelled with some u P U has only childrenlabelled by some v P U with p u, v q P H ; additionally, to make certain that astrategy tree correctly represents all possible counter-strategies for Player 2, wewould have to require that each node corresponding to a move by Player 2 hasas children nodes with all possible labels v such that p u, v q P H . This intuitiveapproach leads to two minor problems, though: • For some tiles u , there may be no tiles v with p u, v q P H . If this happens,we fix the replacement transducer such that it may only follow u up witha special “pseudo-tile” u err R U . • If a tile u is placed at the end of a line, the next tile v does not haveto fulfil p u, v q P H . In order to account for this fact and still have thereplacement transducer produce horizontally correct tiling candidates, weintroduce a special line divider symbol R U which may be placed bythe replacement transducer at any time it could normally place a node forsome player, regardless of its parent tile, and which may be followed upby either any tile u P U as a move for Player 1, or by all tiles u P U as possible moves for Player 2.In a correct encoding of a strategy tree, the line divider symbol n . However, the above construction of replacement transducer allows Romeo to construct incorrect encodings of strategy trees. Dealing with attempts by
Romeo to cheat in this manner, as well as with vertical errors, is what wediscuss next.We interpret a tree given by
Romeo as a tree whose paths from root to leafencode tiling candidates with 2 n columns and an arbitrary number of lines (i.e.root-to-leaf paths should always have as their length a multiple of 2 n ), withthe last column in a correctly encoded tiling candidate consisting only of linedivider symbols, and no line divider symbol occurring in any other column.As mentioned above, to check for vertical errors and incorrect encodings, Juliet selects some column number ℓ P r n s and removes all nodes not cor-responding to some tile in that column, i.e. reduces the original tree t to onecontaining only the nodes at depths k ¨ p n q ` ℓ for all k ě
0. How this is doneexactly will be explained later on. Due to the alternation between Players 1and 2, if the column chosen by
Juliet is not the last column, each node witha label from U should only have children with labels from U in this reducedtree, or vice versa.At first glance, it seems clear that, with the considerations on encodingmade above, Juliet can already uncover attempts by
Romeo to cheat or givea non-winning strategy, namely • by picking a column where ℓ ‰ n and in some path of the resulting tree,there are two directly subsequent labels from U or from U ( Romeo triedto cheat by disrespecting the correct player sequence after a by picking a column ℓ ‰ n in which some path contains a Romeo tried to cheat by placing an incorrect • by picking a column where ℓ ‰ n and in some path of the resultingtree, there is a tile u P U followed either by u err or some v P U with p u, v q R V (the strategy given by Romeo is non-winning due to ahorizontal or vertical error), or • by picking ℓ “ n ´ u f (the strategy given by Romeo is non-winning due to a wrong finaltile), or • by picking ℓ “ n if the last column contains some symbol that is not Romeo tried to cheat by not placing a correct
Romeo has given an incorrect or non-winning strategy tree, our constructionso far is still too restrictive in that it sometimes fails to recognise a correctwinning strategy tree. Consider, for instance, the case where all paths of thestrategy tree either contain a vertical error for Player 2 or end with a valid tiling.According to our construction so far,
Juliet could still win on a strategy tree ofthis shape, as our construction requires
Romeo to continue giving horizontallycorrect tiles even after a vertical error has occurred, and these “irrelevant” tilesmight not always make it possible to end a line with u f , thus allowing Juliet tofind some path in the strategy tree corresponding to column 2 n ´ u f .To address this problem, we further modify the replacement transducer R insuch a way that, whenever it is supposed to output a node with label u P U corresponding to a move by Player 2, it may instead nondeterministically chooseto output a marked version ˆ u of u instead. This is supposed to indicate thatchoosing u leads to a vertical error for Player 2, so below the node labelledˆ u , the replacement transducer may produce a sequence of arbitrary tiles from U for Player 1 and from U for Player 2 (as vertically correct “pseudo-tiles”),terminating with u f at an odd depth followed by u err everoccurs instead of a move of Player 2 due to a horizontal error, it is followed upby a similar path.In this way, we make it Romeo ’s responsibility to flag vertical errors forPlayer 2. This would allow
Romeo to cheat by claiming a vertical error when,in fact, there is none, but such attempts at cheating can be penalised by onceagain adapting the target language in such a way that
Juliet wins if she selectsa column in which
Romeo has falsely flagged a vertical error (i.e. the selectedcolumn number ℓ is not 2 n and some path in the corresponding tree contains amarked tile ˆ v that is not preceded by some u P U with p u, v q R V ).Next, we examine how Juliet selects a column in the strategy tree givenby
Romeo . Recall that the input string is w “ p h d ih e i q n h s ih { s i p h { e ih { d i q n , andthat the first move by Juliet is supposed to be a Call on h { s i to replace h s ih { s i by an encoding of a strategy tree, in which each path is to be interpreted as atiling candidate with 2 n ´ Juliet now selects one of these 2 n columns by incrementallycausing Romeo to delete either all odd-numbered columns or all even-numbered29olumns (i.e. all nodes at odd or even depths in the strategy tree) until only asingle column is left. This is the purpose of the nodes labelled d and e .By a Call to some node labelled e , Juliet causes
Romeo to change its labelto o (without changing the tree nested below it). A Call to a d -node with e -labelled child causes Romeo to delete both of these nodes as well as all nodesat even depths in the strategy tree nested below them; similarly, a Call to a d -node with o -child deletes these nodes and all odd-depth nodes in the strategytree.To keep Juliet from cheating in this selection process, we have to make cer-tain that she calls all d -nodes in left-to-right order. We can easily keep Juliet from leaving uncalled d -nodes by fixing the target language to not contain anystrings including the label d ; to make certain that she does not skip any d -nodes,the replacement transducer rejects any strings containing a d -node as child ofan e - or o -node.To later check for the right kinds of vertical errors or inconsistencies, we haveto keep track of the column selected by Juliet , i.e. the sequence of Call movesdeleting odd or even columns. The following cases have to be distinguished: • If Juliet deletes odd columns on all n calls, she selects column 2 n ; • if Juliet deletes even columns as her first call and then only odd columnson the following n ´ n ´ • otherwise, Juliet selects a column with index ℓ ď n ´ Romeo returns as the root of his chosen strategy tree after
Juliet ’s Callon h { s i . This node is then updated throughout the column-deletion process asfollows: • A label 0 signifies that no deletions have been made so far; on a Call to d which deletes odd columns, 0 is rewritten to l , on a Call deleting evencolumns, it becomes x • A label l (“last”) signifies that the column Juliet selects may possibly bethe 2 n -th line divider column. As long as only odd columns are deleted,the label l remains, if even columns are deleted, l is rewritten to r . • A label x (“neXt-to-last”) signifies that the column Juliet selects maypossibly be the (final) column with number 2 n ´
1. As long as only evencolumns are deleted, the label x remains, if odd columns are deleted, x isrewritten to r . • A label r (“standaRd”) signifies that the column Romeo selects will def-initely not be one of the last two columns, i.e. have a number at most2 n ´
2. The label r is not rewritten by any deletion.To summarise, the game G “ p Σ , Γ , R, T q constructed from the tiling in-stance p U, V, H, u i , u f , n q is as follows.The alphabet of G isΣ “ U Y ˆ U Y U Y U Y t u err , , s, d, e, o, , l, x, r u , U “ t ˆ u | u P U u , U “ t u | u P U u and U “ t u | u P U u ) withfunction symbols Γ “ t s, d, e u .The replacement transducer R behaves as follows: • R rewrites h s ih { s i into a string of the form h i w h { i , where w is thelinearisation of a strategy tree as described above, i.e. a tree t with thefollowing properties: – t has a root node labelled u i ; – Each node labelled with some u P U that does not have a nodewith label from ˆ U Y t u err u as ancestor has as its children either asingle node labelled v or ˆ v for each v P U with p u, v q P H , or a single node labelled u err if no such v exists. – Each node labelled with some u P U that does not have a node withlabel from ˆ U Y t u err u as ancestor has a single child labelled either v for some v P U with p u, v q P H , or u err if no such v exists, or – Each node that has a node with label from ˆ U Y t u err u as its own labelor as an ancestor has a single child labelled either by some u P U ,or by some u P U , or by – Each node labelled with u P U ,or by u P U , or no child at all. • R rewrites strings of the form h e i v h { e i , for arbitrary v P NW p Σ q , into h o i v h { o i . • R rewrites strings of the form h d ih e i v h { e ih { d i into strings v as follows: – If v “ h i v h { i (with v P NW p Σ q ), then v “ h x i v h { x i , where v is derived from v by deleting all nodes at even depths; – If v “ h l i v h { l i or v “ h x i v h { x i or v “ h r i v h { r i (with v P NW p Σ q ), then v “ h r i v h { r i , where v is derived from v by deletingall nodes at even depths. • R rewrites strings of the form h d ih o i v h { o ih { d i into strings v as follows: – If v “ h i v h { i or v “ h l i v h { l i (with v P NW p Σ q ), then v “ h l i v h { l i , where v is derived from v by deleting all nodes at odddepths; – If v “ h x i v h { x i (with v P NW p Σ q ), then v “ h x i v h { x i , where v is derived from v by deleting all nodes at odd depths; – If v “ h r i v h { r i (with v P NW p Σ q ), then v “ h r i v h { r i , where v is derived from v by deleting all nodes at odd depths. • All other strings are rejected by R .The target language T contains all strings v of the following kinds: • v “ h l i v h { l i , where the tree represented by v has some path from root toleaf containing a label different from • v “ h r i v h { r i , where the tree represented by v has some path from rootto leaf 31 containing a label – containing two subsequent labels from U or two subsequent labelsfrom U , or – containing some label u from U followed either by u err or by a u with p u, u q R V , or – containing some label from ˆ U that is not part of a vertical error. • v “ h x i v h { x i , where the tree represented by v has some path from rootto leaf – containing a label – containing two subsequent labels from U or two subsequent labelsfrom U , or – containing some label u from U followed either by u err or by a u with p u, u q R V , or – containing some label from ˆ U that is not part of a vertical error – containing no vertical error, no label u err and ending with a labeldifferent from u f , u f .It is relatively easy to see (but tedious to prove formally) that this con-struction is possible in polynomial time and that Juliet indeed has a winningstrategy in G on w if and only if Player 1 has no winning strategy on the tilinginstance I .For the upper bound, we first prove decidability in for a“purely NWT-based” problem, to which we will later reduce JWin . Definition A.9.
The alternating iterated transduction problem for non-deletingNWT is defined as the following decision problem:
AIT (NWT)Given: A string w P NW p Σ q , number k (given in unary), DNWA A ,and pairs of non-deleting NWTs p T , , T , q , . . . , p T k, , T k, q Question: Is there an i P t , u such that for every w P T ,i p w q thereexists i P t , u such that for every w P T ,i p w q . . . thereexists i k P t , u such that for every w k P T k,i k p w k ´ q itholds that w k P L p A q ? Proposition A.10.
AIT(NWT) P Proof.
We assume, without loss of generality, that each transducer T j,i (for j P r k s , i P t , u ) is in normal form, i.e. that each (reading or ǫ -) transition ofeach transducer produces exactly one output tag (cf Lemma 5).The idea behind this proof is to eliminate the existential quantification inthe problem setting by constructing an NWT T that simulates in parallel both transducers T j, and T j, at each level j P r k s . More concretely, T takes asinput a string w and outputs a 2 k -tuple of strings, each component of whichcorresponds to a sequence of existential choices i . . . i k P t , u k of transducers,while the non-determinism in T simulates universal choice. It then holds (aswe will prove after the construction of T ) that the condition of AIT(NWT) isfulfilled if and only if for each possible transduct w of w by T , at least one of32he 2 k component strings is contained in (an appropriate modification of) thetarget language L p A q .To construct T , we construct from T j, and T j, for each level j P r k s atransducer T j that takes as input a nested string w j ´ over an alphabet of 2 j ´ -tuples of alphabet symbols and outputs a nested string w j over 2 j -tuples, withthe intuition being that T j simulates one run of both T j, and T j, on each ofthe 2 j ´ input strings encoded in w j ´ to produce a total of 2 ¨ j ´ “ j outputstrings, which are encoded in w j . From all of the transducers T j for all j P r k s ,we then use Proposition 7 to construct T as the transducer for T k ˝ . . . ˝ T .The main difficulty in the construction of each T j is the fact that, while both T j, and T j, should be simulated for exactly one run on each of the componentson the input string, all of these runs should be independent of each other.For instance, if T wanted to simulate some run ρ of T , on the first and adifferent run ρ of T , on the second input string component, ρ might start byreading the first tag from the input string while ρ starts with an ǫ -transitionand reads the first input tag afterwards. In such a situation, ρ would producean output before the output of ρ even starts. We therefore need to constructeach T j in such a manner that runs are synchronised , producing an output for all components of the output string, even if only one run of some transducer T j,i j calls for producing an output.To address this problem, we introduce a special blank symbol \ R Σ andconstruct each T j in such a way that reading transitions of T j simulate syn-chronous reading transitions of T j, and T j, on all symbols of the next inputtuple; ǫ -transitions of T j , on the other hand, simulate only one of T j, or T j, ononly one of the 2 j ´ input components and output tuples consisting of exactlyone symbol from Σ in the corresponding component and \ symbols in all theothers. To keep this construction consistent and allow for later transductions,this also means that all transducers T j,i ( j P r k s , i P t , u ) have to be modifiedin such a way that, on reading an opening (closing) \ tag, they always outputan opening (closing) \ tag and do not change states.More formally, if (for each j P r k s and i P t , u ) T j,i “ p Q j,i , P j,i , P ǫj,i , Σ , δ j,i , q j,i , F j,i q ,then let first T j,i be an extension of T j,i to strings containing \ tags that ig-nores and reproduces these tags as described above, i.e. T j,i “ p Q j,i , P j,i Yt p \ u , P ǫj,i , Σ Yt\u , δ j,i , q j,i , F j,i q , where p \ R P j,i and δ j,i consists of δ j,i extendedby transitions p q, h \ i , q, p \ , h \ i q and p q, p \ , h {\ i , q, h {\ i q for each q P Q j,i . Forany w P NW p Σ Y t\uq , let Strip p w q P NW p Σ q denote the nested string obtainedfrom w by deleting all \ -labelled tags, and for any set S Ď NW p Σ Y t\uq , letStrip p S q def “ t Strip p w q | w P S u . Then, it is clear that for any w P NW p Σ Y t\uq ,it holds that Strip p T j,i p w qq “ T j,i p Strip p w qq .Now we describe in detail the construction of T j from T j, and T j, . Let T j “ p Q j , P j , P ǫj , Σ in j Y Σ out j , δ j , q j , F j q , where the linear and hierarchical state sets as well as initial and final statessimply derive from a 2 j ´ -fold product construction of T j, and T j, , i.e. Q j “ p Q j, ˆ Q j, q j ´ ,P j “ pp P j, Y t p \ uq ˆ p P j, Y t p \ uqq j ´ ,q j “ p q j, ˆ q j, q j ´ , F j “ p F j, ˆ F j, q j ´ . The working alphabet of T j consists of input alphabet Σ in j “ p Σ Y t\uq j ´ andoutput alphabet Σ out j “ p Σ Y t\uq j . The construction of P ǫj is similar, but hasto be adjusted slightly; since ǫ -transitions of T j are supposed to simulate T j, or T j, on only one component of the output string and the other components haveto be filled in with \ symbols, we add a new hierarchical ǫ -state p ǫ \ R P j, Y P j, and set P ǫj “ pp P ǫj, Y t p ǫ \ uq ˆ p P j, ǫ Y t p ǫ \ uqq j ´ .In accordance with the above intuition, we construct the transition relation δ j of T j . Reading transitions in δ j (i.e. transitions that read one input symboland produce one output symbol) are pretty much products of transitions from δ j, and δ j, . That is, δ j contains an opening transition which, for ℓ P r j s ,starts with linear state q , ends in state q and produces hierarchical state q inthe ℓ -th position of the corresponding state tuples while reading h a i in the t ℓ u -th position of the input tuple and writing h b i in the ℓ -th position of the outputtuple if the transition p q, h a i , q , p, h b i q is in δ j, (for odd ℓ ) or in δ j, (for even ℓ ). Closing reading transitions in δ j are constructed accordingly.As for ǫ -transitions, δ j contains an opening transition p q, h ǫ i , q , p, a q if thereis an ℓ P r j s such that (with x i denoting the i -th component of a tuple x ) • for all ℓ ‰ ℓ , it holds that q ℓ “ q ℓ , p ℓ “ p ǫ \ and a ℓ “ \ , and • for q ℓ “ q , q ℓ “ q , p ℓ “ p and a ℓ “ a , there is a transition p q, h ǫ i , q , p, h a i q in δ j, (for odd ℓ ) or in δ j, (for even ℓ ),and accordingly for closing ǫ -transitions.With this construction, T j is indeed an NWT in normal form (i.e. fulfils the ǫ -consistency, well-formedness and synchronisation properties). This directlyimplies that T j transduces well-nested strings over Σ in j into well-nested stringsover Σ out j . We now identify nested strings over tuples of alphabet symbols withtuples of nested strings as follows: For some j , let w “ w ¨ ¨ ¨ w n be a well-nested string over p Σ Y t\uq j , and for each w i P h p Σ Y t\uq j i , let w iℓ denoteits ℓ -th component interpreted as an opening tag (and analogously for closingtags). Then the nested string w ℓ is defined as w ℓ “ w ℓ ¨ ¨ ¨ w nℓ . It is clear that,if w P NW pp Σ Y t\uq j q , then w ℓ P NW p Σ Y t\uq for each ℓ .Identifying strings of tuples with tuples of strings in this way, it is easy (iftedious) to prove that, for each j and each string w P NW p Σ in j q , interpretedas a 2 j ´ -tuple p w , . . . , w j ´ q of nested strings, it holds that Strip p T j p w qq “ ś j ´ ℓ “ T j, p Strip p w ℓ qqˆ T j, p Strip p w ℓ qq , where the Strip operator is applied component-wise, i.e. Strip pp w , . . . , w n qq “ p Strip p w q , . . . , Strip p w n qq . In other words, dis-regarding \ tags, every run of T j on a 2 j ´ -tuple of nested words simulates onerun each of T j, and T j, on each of its component strings, and all combinationsof such component runs can be simulated by a run of T j .By a simple induction argument, it follows that each transducer of the form T j ˝ ¨ ¨ ¨ ˝ T completely describes all possible series of existential choices up to At first glance, it may seem more intuitive to associate even positions with T j, and oddpositions with T j, , but seeing as ℓ is a number between 1 and 2 j which will later be encodedas ℓ ´ j , the association described here is indeed the moreuseful one. j -th level. More precisely, denoting by S ℓ “ t w ℓ | w P S u the set of all ℓ -th component strings in a set S of tuples of nested strings, we get that forevery j ď k , w P NW p Σ q and ℓ P r j s , it holds that Strip pp T j ˝ ¨ ¨ ¨ ˝ T p w qq ℓ q “ T j,i j ˝ ¨ ¨ ¨ T ,i p w q , where i ¨ ¨ ¨ i j P t , u j is the binary representation of thenumber ℓ ´ T “ T k ˝ ¨ ¨ ¨ ˝ T for solving the alternating iteratedtransduction problem as described initially, we now need to prove that thedefining property of AIT(NWT) (i.e. “There is an i P t , u such that forevery w P T ,i p w q ...”) is equivalent to the following: For every w P T p w q ,there is an ℓ P r k s such that Strip p w ℓ q P L p A q . We denote this property by(*). As we have already seen, the existence of ℓ in property (*) is equivalentto the existence of an index sequence i ¨ ¨ ¨ i k P t , u k representing ℓ ´ AIT(NWT) is equivalent toa single universal choice of iterated transducts for each possible index sequenceof existential choices, followed by a single existential choice of index sequence.The proof of this equivalence is by induction; the central step is proving, forany set S of nested strings, the equivalence of @ w P T j ´ ˝ ¨ ¨ ¨ ˝ T p w qD ℓ P r j ´ sD i j P t , u@ w P T j,i j p Strip p w ℓ qq : w P S and @ w P T j ˝ T j ´ ˝ . . . ˝ T p w qD ℓ P r j s : Strip p w ℓ q P S, which follows primarily from the fact that T j simulates both T j, and T j, aswas shown before.To sum up the proof thus far, we have constructed from an AIT(NWT) instance a transducer T such that the original instance is a positive one ifand only if for the input string w it holds that all transducts in T p w q havea component string that is in L p A q when stripped of all \ -labelled tags. Itremains to be seen how we can check for this property in doubly exponentialtime.To that end, let A be a modification of A that ignores \ -labelled tags,constructed from A using a similar construction to that one for each T j,i j . From A , we can construct a DNWA B that gets as input a nested string of tags over2 k -tuples of symbols from Σ Y t\u , simulates a copy of A on each of the 2 k components and accepts if and only if at least one of its components accepts. Itthen holds that the original AIT(NWT) instance is a positive one if and only if T p w q Ď L p B q , which yields an instance of a type checking problem. Each leveltransducer T j is of size at most O pp| T j, | ¨ | T j, |q k q , therefore T is of doublyexponential size, and so is B . Since the type checking problem with targetDNWA is decidable in PTIME by Theorem 13(b), this yields a algorithm for
AIT(NWT) , as was to be proven.A reduction to
AIT( ǫ -NWT) , along with Proposition A.8 now proves The-orem 15. Theorem 15 (restated).
For the class of replay-free games with NWT,
JWin is -complete.Proof. The lower bound was proven as Proposition A.8. We prove a matchingupper bound by reduction to
AIT( ǫ -NWT) , which is in accord-ing to Proposition A.10. 35et G “ p Σ , Γ , R, T q be a game with NWT replacement, and let w be aninput string for G . Let furthermore k ď | w | be the number of occurrences ofclosing tags from h { Γ i in w .The idea behind the reduction to AIT( ǫ -NWT) is taking k rounds of al-ternating transduction, where the j -th round (with transducers T j, , T j, ) cor-responds to the replay-free subgame on the j -th function symbol in w (in left-to-right order). The choice between transducers T j, and T j, models Juliet ’schoice between Read and Call; to that end, T j, basically does not change itsinput string at all, while T j, simulates the replacement transducer R on thesubstring that Juliet chose to be replaced. The only minor technical difficultyin this construction is the fact that, in the game G , the transducer R onlyrewrites the called substring, while each T j,i rewrites the entirety of the currentstring. This difficulty can be solved by some minor modifications, which we willnow examine.The input string w for AIT( ǫ -NWT) is derived from w by replacing, inleft-to-right order, each substring h f i v h { f i of w by h j ih f i v h { f ih { j i , where h { f i is the j -th closing function tag in w and j R Σ for each j P r k s . In otherwords, the substring on which Juliet has to make her j -th strategy decision isencapsulated in j -tags.For each j P r k s , the transducer T j, simply deletes the h j i and h { j i tags fromits input, leaving it otherwise unchanged. The transducer T j, , on the otherhand, also directly outputs its input until it reaches the h j i tag. It deletes thistag and then starts simulating the replacement transducer R . Once T j, reachesthe h { j i tag, it deletes that tag as well and stops its simulation, rejecting itsinput if R has not reached an accepting state. Afterwards, T j, simply outputsits input again. Note that the simulation of R in T j, will never receive as inputany tags with labels not in Σ, as all such tags have a label strictly less than j and have therefore already been removed by earlier transductions.The target DNWA A for AIT( ǫ -NWT) is simply the target DNWA A p T q of G .It is easy to see that k , w and each T j, for j P r k s can be computed from w in polynomial time, as can each T j, from R . As the alternating transductionsimulates the replay-free game, it is also clear that Juliet has a replay-free win-ning strategy on w in G if and only if the constructed instance for AIT( ǫ -NWT) is a positive one, which concludes the reduction. Theorem 17 (restated).
For the class of replay-free games with depth-bounded NWT,
JWin is EXPSPACE -complete.
We prove the lower and upper bounds of this theorem as separate proposi-tions.
Proposition A.11.
For the class of replay-free games with depth-boundedNWT,
JWin is EXPSPACE -hard.
Proof. (sketch) This lower bound proof uses the problem
Exponential Corridor Tiling :Given a tiling instance consisting of a tile set U , vertical and horizontal con-straints V , H , initial and final tile u i , u f and unary number n , is there a tilingof width 2 n ´ G “ p Σ , Γ , R, T q withdepth-bounded NWT R and an input word w such that Juliet has a winningstrategy on w in G if and only if there exists no valid tiling of width 2 n ´
1, i.e.36e reduce from the complement of
Exponential Corridor Tiling . Since
Exponential Corridor Tiling is EXPSPACE -complete, so is its comple-ment.The basic idea behind the construction of G is similar to that used in theproof of Proposition A.8. The input string is w “ h r ih o n ih e n i ¨ ¨ ¨ h o ih e ih s ih { s ih { e ih { o i ¨ ¨ ¨ h { e n ih { o n ih { r i . Juliet is first supposed to Call h { s i , allowing Romeo to respond with the stan-dard nested string encoding p v of a flat string v P p U Yt uq ˚ which is supposedto encode a valid tiling t of width 2 n ´ t are concatenated and separated by R insuch a way that v is always a concatenation of horizontally correct substrings(not necessarily of length 2 n ´
1) separated by p v is given, Juliet then plays Call on either e or o , prompting Romeo to delete either alleven-numbered or all odd-numbered positions in v and yielding the standardnested string encoding p v of the resulting flat string v . Continuing this processfurther (i.e. sequentially calling exactly one of e i or o i for each i P r n s ) even-tually yields a nested string p v n which encodes what is supposed to be a singlecolumn in the tiling given by Romeo . This string is then checked for verticalcorrectness by the target DNWA. In this way,
Juliet has a winning strategyon w in G if and only if every tiling candidate that can be provided by Romeo contains some (horizontal or encoding) error, i.e. if there is no valid tiling ofthe desired width.Similar to the proof of Theorem 15, the upper bound in Theorem 17 isproven by a reduction to (a variant of) the alternating iterated transductionproblem: Given a string w P NW p Σ q , number k (given in unary), DNWA A , andpairs of depth-bounded NWTs p T , , T , q , . . . , p T k, , T k, q , is there an i P t , u such that for every w P T ,i p w q there exists i P t , u such that for every w P T ,i p w q . . . there exists i k P t , u such that for every w k P T k,i k p w k ´ q itholds that w k P L p A q ? Proposition A.12.
The alternating iterated transduction problem for depth-bounded NWT is in
EXPSPACE . Proof.
Basically, the exponential-space algorithm solving this problem followsthe same idea as the algorithm from the proof of PropositionA.10; here, the bounded depth of input transducers ensures that the construc-tion and type checking of transducers T j (for each j ) and T from that proof maybe simulated on-the-fly by a co-nondeterministic exponential-space algorithm A .More specifically, it can be easily proven by induction that, in any run ρ of an NWT receiving as input a string of depth d in and outputting a stringof depth at most d out , the sequence of hierarchical states in any configurationoccurring in ρ has length at most d in ` d out .Since all input transducers are depth-bounded, we can assume without lossof generality that they have a common upper bound d on their output depth.Then, for each j ą
1, each T j,i has an input and output depth bounded by d ,since T j,i receives as its input the output of some T j ´ ,i . On the other hand, T , and T , also have an output depth bounded by d and an input depth boundedby | w | , which is also fixed for fixed input strings w . Similarly, the DNWA A receives as inputs only outputs of T k, or T k, , so we may restrict our attentionto configurations of A with a hierarchical state sequence of length at most d .37he idea behind the algorithm A , then, is to traverse the input string w fromleft to right and, on each input tag, co-nondeterministically guess transducts foreach combination of follow-up transducers and check that at least one resultingfinal transduct is in L p A q , thus simulating the transducer T from the proof ofProposition A.10 and checking that each transduct from T p w q is accepted bythe NWA B from that proof.The algorithm A is organised into k layers, with the j -th layer (for j P r k s )simulating the workings of transducer T j from the proof of Proposition A.10,which takes as input 2 j ´ -tuples of symbols from Σ Y t\u and outputs 2 k -tuplesof such symbols by guessing transitions of both T j, and T j, on each componentof the input tuple. The algorithm A does this simulation based on a single tupleof symbols for each layer (called that layer’s active input tuple ) – once layer j ´ j , and A continues its simulation with layer j , producing an output to become the activeinput tuple for layer j ` j or by an ǫ -transition (which leaves the active input tuple for layer j unchanged).Once the active input tuple of some layer j has been consumed, control passesback to layer j ´
1. The bottom layer k , instead of producing further activeinput tuples, directly simulates the effect of its output on 2 k modified copies ofthe DNWA A (i.e. simulates the NWA B from the proof of Proposition A.10).Some extra care has to be taken regarding deletions. The proof sketch so far(as well as the construction for Proposition A.10) assumes that simulated tran-sitions are synchronised in such a way that, when an input tuple is consumed,each component of that tuple produces two components of the output tuple.This assumption obviously does not hold in the presence of deleting transitions.For this reason, we allow active input tuples to contain null positions labelled K , which do not induce any transition on the corresponding transducers oncethe tuple is consumed.In the sequel, as in the proof of Proposition A.10, assume that all inputtransducers are in normal form as per Lemma 5, and for each i P t , u and j P r k s , let T j,i be an extension of T j,i to strings containing \ tags that ignoresand reproduces these tags, and let A be an analogous extension of A . We nowdescribe the algorithm A in more detail.For each j , the following information is stored for layer j : • A 2 j -tuple of configurations of T j, (in odd positions) and T j, (in evenpositions), each consisting of a linear state and a sequence of at most d `| w | (for j “
1) or 2 d (for j ą
1) hierarchical states. These configurations areinitialised with the starting configuration of T j, or T j, . • A 2 j ´ -tuple of symbols from h Σ Y t\u i Y h { Σ Y t\u i Y tKu , where eitherall non- K components are opening tags or all are closing tags (called the active input tuple of layer j ). The non- K components of each active inputtuple gives the next input symbols to be consumed by (2 j ´ copies of) T j, and T j, . The active input tuple of layer j is initialised to K j ´ Additionally, A stores the following global information: • A counter ℓ P t , . . . , | w |u denoting the last position of the input string w that has been read, initialised to ℓ “ A 2 k -tuple of configurations of A , each consisting of a single linear stateand a sequence of up to d hierarchical states. These configurations areinitialised with the starting configuration of A . • A layer counter j P t , . . . , k u denoting the current active layer beingprocessed (with layer 0 corresponding to the input string itself). Thiscounter is initialised to j “ A now proceeds as follows:1. If j “ ℓ ă | w | , then the input has not yet been completely read. Inthis case, A sets the active input (2 -)tuple of layer 1 to the p l ` q -thsymbol of w , ℓ : “ ℓ `
1, and j : “ ℓ “ | w | , then the input has been processed completely, and A halts.2. If 0 ă j ă k ...(a) ...and the active input tuple of layer j is not equal to K j ´ , thenlayer j still has some input to be processed. In this case, A guessesco-nondeterministically which of the following two steps to perform:i. A processes the input of layer j , i.e. for each non- K position i Pr j ´ s of the active input tuple, A guesses a transition of T j, withthe input symbol from that position starting at the configurationin position 2 i ´ j , andupdates that configuration accordingly; similarly, A guesses atransition for T j, with position 2 i of the configuration tuple. Theoutputs of these transitions are written to positions 2 i ´ i of a new 2 j -tuple t . For any K -position i P r j ´ s , positions2 i ´ i of t are then filled with K markers. Afterwards, theactive input tuple of layer j ` t , the active input tupleof layer j is reset to K j ´ , and j : “ j ` A performs an ǫ -transition. To that end, A guesses an index i Pr j s . If i is odd, A guesses an opening (resp. closing) ǫ -transitionfor T j, available in the configuration at position p i ` q{ p i ` q{ j -tuple t and fills all other positions of t with h \ i (resp. h {\ i ) symbols. If i is even, A proceeds analogously with T j, instead of T j, and i { p i ` q{
2. Finally, A sets theactive input tuple of layer j ` t and j : “ j ` without resetting the active input tuple of layer j .(b) ...and the active input tuple of layer j is K j ´ , i.e. layer j currentlyhas no input waiting to be processed. In this case, A guesses co-nondeterministically which of the following two steps to perform:i. A performs an ǫ -transition, as described under 2.a.ii.39i. A ends its processing of layer j and sets j : “ j ´ j “ k , then A basically proceeds as described under 2., with the onlydifference being that any time A has created an output tuple t of size 2 k ,instead of setting j : “ j ` A directly aggregates t onto the configuration2 k -tuple for A , simulating, for each i P r k s , a transition of A startingfrom the i -th component of the configuration tuple, consuming the i -thcomponent of t and storing the resulting configuration in the i -th positionof the configuration tuple for A .Finally, once A halts, it accepts if at least one of the following conditions ismet: • One of the 2 k stored configurations for A is accepting. In this case, thereis some sequence of existential choices of transducers such that, for theuniversal choices made co-nondeterministically by A , the final transductis in L p A q . • For some j P r k s , the configuration tuple for layer j contains some non-accepting configuration. In this case, the co-nondeterministic choicestaken by A have lead to an incorrect transduction being performed, i.e.the corresponding run of A should not be counted against the acceptancecondition.To show correctness of A , it needs to be proven that there exists a non-accepting run of A if and only if for all i P t , u there exists w P T ,i p w q such that for all i P t , u . . . for all i k P t , u there exists w k P T k,i k p w k ´ q with w k R L p A q .The proof for this is rather technical, but its basic idea is as follows: For the“only if” direction, we extract from an accepting run of A each “witness string” w j inductively based on the sequence i , . . . , i j of universal choices and priorwitness strings w , . . . , w j ´ by taking the output string produced in component i ` j , where i P t , . . . , j ´ i ¨ ¨ ¨ i j . Using the construction of A , it is then easy to see that w j P T j,i j p w j ´ q , and that w k R L p A q . Similarly, for the “if” direction we canconstruct a run of A from witness strings given universal choices of indices in t , u , which is non-accepting because all transductions are performed correctlyand, regardless of universal choices, the resulting final string w k is not in L p A q .Finally, as stated above, A requires only co-nondeterministic exponentialspace and can therefore be simulated by an EXPSPACE algorithm.
Proof of Theorem 17.
The lower bound was proven as Proposition A.11.For the upper bound, we reduce
JWin to the alternating iterated transductionproblem for depth-bounded transducers using the same reduction as in the proofof Theorem 15.Some care needs to be taken with this reduction, as the reduction fromTheorem 15 constructs, from an input string w and a game G whose replace-ment transducer has output depth bounded by some constant d , an instance forthe alternating iterated transduction problem whose transducers have a depthbound d ` | w | ; that is, the depth bound for the alternating iterated transduc-tion problem actually depends on the size of the input. However, the proof of40roposition A.12 shows that the algorithm given there still only takes exponen-tial space, even if the depth bound of transducers depends on the input, sincein this case, the algorithm keeps track of (exponentially many) configurationswhose size is still at most polynomial in the input size. In this way, PropositionA.12 still yields an EXPSPACE upper bound for
JWin .41 roofs for Section 5
This section gives proofs for the results of Section 5. Since Lemma 6 appliesin this setting, we generally prove lower bounds for deleting ǫ -free NWT andupper bounds for non-deleting ǫ -free NWT. Theorem 18 (restated).
For the class of games with ǫ -free NWT and un-bounded replay, JWin is undecidable.Proof.
The proof is by reduction from the halting problem for Turing machineswith an empty input. From a given Turing machine M with working alphabetΣ and state set Q , we construct a game G and string w such that Juliet has awinning strategy on w in G if and only if M halts on an empty input. Withoutloss of generality, we assume that M always moves its head to the left-most usedtape cell before halting.The basic idea behind the reduction is encoding configurations of M bystrings nested below a root r R Σ and using Call moves by
Juliet to h { r i tosimulate moves of M . The input string is w “ h r i p v h { r i , where p v representsthe initial configuration of M , and any time Juliet plays Call on h { r i in somestring h r i p v i h { r i (with p v i representing some configuration of M ), that string getsreplaced by h r i p v i ` h { r i , where p v i ` represents the successor configuration of theone represented by p v i . The target language of G is constructed to contain allstrings of the form h r i p v h h { r i , where p v h represents a halting configuration of M .This way, Juliet has a winning strategy of Call depth k on the input string ifand only if M halts on the empty input within at most k steps.We represent configurations of M in the same way as in the proof of Theorem14: a flat string p x , ´q ¨ ¨ ¨ p x k ´ , ´qp x k , q qp x k ` , ´q ¨ ¨ ¨ p x m , ´q over the alpha-bet Σ ˆ p Q Y t´uq denotes that the content of M ’s working tape is x ¨ ¨ ¨ x m ,with the head of M being on the tape’s k -th cell and M being in state q , andthese flat strings are represented as nested strings using the standard nestedstring representation. Again, by our assumption on the shape of M ’s haltingconfigurations, the flat string encoding of a halting configuration is of the form p Σ ˆ t h uqp Σ ˆ t´uq ˚ for the halting state h of M .From M , we can easily construct a ǫ -free NWT implementing M ’s transitionfunction on configurations represented in this way. A DNWA accepting allstrings h r i v h { r i in which v represents a halting configuration for M is similarlyeasy to construct. Finally, it is clear that Juliet has a winning strategy onthe input string w using at most k Call moves if and only if M reaches ahalting configuration from its initial configuration within at most k steps, whichcompletes the proof.Throughout the rest of this section, let Exp p k, n q be the k -fold exponentialtower function in n , defined recursively by Exp p , n q “ n and Exp p k, n q “ Exp p k ´ ,n q for all integers k ą n ě Lemma A.13.
An input string of length 2 ¨ p n ` k ´ q can be transformedinto a string of length 2 ¨ Exp p k, n q by a game of Call depth 2 with deterministic ǫ -free NWT replacement. Note that this ǫ -free NWT is functional, so G is basically a “solitaire” game for Juliet ,where
Romeo does not get to make any choices. In fact, the replacement relation can evenbe implemented using a deterministic finite-state transducer that inserts at most two symbolswith each transduction. roof. Choose as input a string of the form h k ´ ih k ´ i ¨ ¨ ¨ h ih c i n h c i ¨ ¨ ¨ h c k ih { c k i ¨ ¨ ¨ h { k ´ i .The tree represented by this string is obviously a path of length n ` k ´
2. Playproceeds in k rounds as follows: In round i P r k s , Juliet plays Call on eachnode labelled c i ´ in bottom-up (i.e. left-to-right) order. Each such Call movedeletes the called c i ´ node and doubles the number of c i nodes below it (i.e. re-places each h c i i by h c i ih c i i and h { c i i by h { c i ih { c i i ). Afterwards, if i ă k , Juliet plays Call on the node labelled i , which deletes that node, attaches its childpath to its i ` Juliet to play again on its childpath, since this is the first time
Juliet has played Call on the node labelled i .By an induction argument, it is easy to show that at the conclusion of round i , the current string contains exactly 2 ¨ Exp p i, n q tags labelled c i (half of themopening, the other half closing tags).Lemma A.13 is an integral part in proving the following lower bound. Proposition A.14.
For each k ě
1, it holds that for the class of games with ǫ -free NWT, and Call depth bounded by 2, JWin is hard for co- k -NEXPTIME . Proof.
Let k ě
1. We show co- k -NEXPTIME -hardness by reduction from thecomplement of the k -NEXPTIME -complete problem k -ExpTiling of, given atile set U , vertical and horizontal constraints V , H , initial and final tile u i , u f and unary number n , determining whether there exists a valid tiling of heightExp p k, n q and width Exp p k, n q ´ k -ExpTiling a game G and a string w such that Juliet has a winning strategy in G starting at w if and only if thereexists no valid tiling of the given size. We first give a rough overview over thegame before describing the construction of G and w in detail.Play proceeds in three phases: • In the first phase, the construction from Lemma A.13 is used to transformthe polynomial-sized input string into a seed string of size O p Exp p k ´ , n qq .This phase is deterministic in the sense that we will design the replacementtransducer and target language in a way such that neither Juliet nor
Romeo get to make any choices in phase 1. • In phase 2,
Romeo constructs from this seed string a tiling candidate , i.e.a (representation of a) potential tiling of size Exp p k, n qˆp Exp p k, n q´ q . Inthis phase, Juliet still doesn’t get to make any choices; all she is supposedto do is to Call certain nodes in order to allow
Romeo to construct thetiling candidate. By fixing the replacement transducer in the proper way,we can ensure that this tiling candidate has no horizontal errors and startswith the initial tile. • In the final phase,
Juliet tries to show that the tiling candidate
Romeo constructed in phase 2 does not represent a valid tiling. To this end, sherepeatedly forces
Romeo to delete either all even or all odd columns inhis tiling candidate until only a single column is left; this column is thenchecked for vertical errors by the target language automaton.Note that, during all of the three phases, we require
Juliet to stick to acertain “game plan”, in which she only calls certain nodes in a pre-determinedorder. This can be enforced by constructing the replacement transducer and43arget language automaton in an appropriate way. We will first examine phase-by-phase how the game G is constructed, assuming Juliet ’s compliance, andlater describe how G has to be modified to prevent deviations from the gameplan.Let v k,n be the sequence of opening tags from the proof of Lemma A.13, i.e. v k,n “ h k ´ ih k ´ i ¨ ¨ ¨ h ih c i n h c i ¨ ¨ ¨ h c k i , and let v n,k be the complementarysequence of closing tags. The input string w , then, is of the form w “ h start2 ih mv ih dbl ih cp1 i v k ´ ,n h r ih p ih { p ih { r i v k ´ ,n h { cp1 ih { dbl ih { mv ih { start2 i . The purpose of each tag will be explained when it is first used in the game.At the start of phase 1,
Juliet uses the procedure described in the proof ofLemma A.13 to rewrite w into the following string of p k ´ q -fold exponentialsize: h start2 ih mv ih dbl ih cp1 ih c k ´ i ℓ h r ih p ih { p ih { r ih { c k ´ i ℓ h { cp1 ih { dbl ih { mv ih { start2 i , where ℓ “ Exp p k ´ , n q . Afterwards, Juliet plays her first Call on thenode labelled cp1 (where “cp” stands for “copy”), allowing her a replay on h c k ´ i e h r ih { r ih { c k ´ i e . In this replay, she calls every c k ´ in left-to-right order;each such Call replaces the called c k ´ by c k ´ , replaces h r i by h r ih d ih e i andreplaces h { r i by h { e ih { d ih { r i . After this rewriting, the r -labelled node has a childpath consisting of ℓ alternating d - and e -nodes.Next, Juliet plays Call on the node labelled dbl (for “double”), whichrewrites the c k ´ -labelled path into a c k ´ -labelled path of double length, i.e.the rewriting transducer replaces each h c k ´ i by h c k ´ ih c k ´ i and each h { c k ´ i by h { c k ´ ih { c k ´ i . With her next call to mv (for “move”), Juliet gets anotherreplay on this path of length 2 ℓ , calling each c k ´ node in left-to-right order,which causes Romeo to delete that node and insert a single c (for “create”)node below the bottom p -labelled node. Finally, Juliet plays Call on the rootnode labelled start2 to start the second phase of the game; as his reply to thisCall,
Romeo deletes the start2-node and inserts a node labelled u i as a leaf atthe very bottom of the path. This ends phase 1 and leaves Juliet to play areplay-free game on the string w “ h r i p h d ih e i q ℓ h p ih c i ℓ h u i ih { u i ih { c i ℓ h { p i p h { e ih { d i q ℓ h { r i . In the second phase,
Romeo is supposed to set up a tiling candidate. Thiscandidate will be encoded within the leaves of the current string, i.e. in siblingsof the initial u i -labelled leaf. To this end, Juliet calls each of the c -nodes inbottom-up order. On each such call, Romeo deletes the called node and doublesthe number of leaves in the current string. More precisely, the replacementtransducer may replace each h { u i (for some u P U ) either by h { u ih u ih { u i forsome u P U with p u, u q P H , or by h { u ih ih { i for a divider symbol R U .Since each Call to a c -node doubles the length of the current tiling candidate, itis clear that when all c -nodes have been called (and phase 2 ends), the currentstring is of the form w “ h r i p h d ih e i q ℓ h p i v t h { p i p h { e ih { d i q ℓ h { r i , where v t , the final tiling candidate, is a string of nesting depth zero consistinga total of 2 ℓ “ p ℓ q “ Exp p k, n q pairs of corresponding opening and closingtags with labels from U Y t u , beginning with h u i ih { u i i .44e interpret the tiling candidate v t as the concatenation of Exp p k, n q lines oflength Exp p k, n q each. To encode a valid tiling of size Exp p k, n qˆp Exp p k, n q´ q ,we expect v t to be of the form pp h U ih { U i q Exp p k,n q´ q Exp p k,n q , i.e. we expect Romeo to use the symbol v t represents a con-catenation of several (possibly empty) horizontally correct substrings of tiles,separated by u i . The tiling candidate encodedby v t may, however, still contain one or more of the following types of errors: • Vertical error : Two vertically adjacent tiles u, u with p u, u q R V ; • Incorrect line lengths : Strictly more or less than Exp p k, n q ´ U between two subsequent • Incorrect final tile : The last symbol from U in v t is not u f .The main observation needed for this part of the reduction is the following:if a tiling candidate does not represent a correct tiling, then at least one of theseerrors can be found by examining just a single column of the tiling candidate. Ifa tiling candidate contains a vertical error, then there is a column containing twosubsequent tiles u, u with p u, u q R V ; if some line length is incorrect, then thelast column contains some symbol other than not the last column; and finally, if the tiling candidate does not end with u f ,then the next-to-last column (i.e. column number Exp p k, n q ´
1) does not endwith u f . It is easy to see that, once a single column of v t has been isolated, allthree of these conditions can easily be checked using a polynomial-sized DNWA. Juliet ’s task on the string w therefore consists of isolating a single columncontaining an error. If and only if she manages to do so, she wins the game (i.e.the target DNWA checking for the existence of one of the above kinds of errorsaccepts).To isolate a single column, Juliet plays Call moves on all nodes labelled d (for “destroy”) in bottom-up order. Each such Call removes the called d -node and its child, and forces the replacement transducer to either delete alleven-numbered columns or all odd-numbered columns by deleting every othernode in v t . Juliet makes the choice of whether to delete all even-numberedor all odd-numbered columns by playing either Read or Call on the e -labellednode just below the d -node she is to call next; a Read move leaved the label e (“even”) intact, causing the replacement transducer to delete all even-numberedcolumns on Juliet ’s Call to the d -node above, while a Call move relabels e into o (“odd”), causing all odd-numbered columns to be deleted analogously. Eachsuch deletion step halves the number of remaining columns, which means thatafter ℓ deletion moves, only a single column of length Exp p k, n q remains of v t .From the above considerations concerning error types, it is clear that someadditional information needs to be tracked through the deletion phase, to de-termine whether the column chosen by Juliet is the last, next-to-last, or someother column. This is the purpose of the node labelled p (“position”), whichis rewritten depending on the sequence of Juliet ’s choices of even and oddcolumns: • To reach the last column,
Juliet must successively remove only odd-numbered columns. Therefore, on the first Call to a d -node with o -child45and p -grandchild), p is rewritten into l (“last”). Any Call to a d -nodewith e -child and l -grandchild rewrites l into s (“standard”, i.e. the columnto be checked is not a special case), while calling a d -node with o -childleaves the label l as is. • To reach the next-to-last column,
Juliet must remove all even-numberedcolumns in the first step and successively remove only odd-numberedcolumns after that. Therefore, on the first Call to a d -node with e -child(and p -grandchild), p is rewritten into x (“neXt-to-last”). Any Call toa d -node with o -child and x -grandchild leaves the label x intact, while aCall to a d -node with e -child and x -grandchild relabels x to s .Using the label of the rewritten p -node as an indicator, a polynomial-sizedDNWA can now easily check whether a column chosen by Juliet containssome error. Assuming that
Juliet is restricted to strategies that follow thedescribed order of Call moves, it is straightforward (if tedious) to prove that
Juliet has a winning strategy if and only if there does not exist a valid tilingof size Exp p k, n q ˆ p Exp p k, n q ´ q . If such a tiling exists, Romeo can give itsencoding as v t and deny Juliet the opportunity to find any errors, no matterwhich column she isolates, and if no such tiling exists, then any tiling candidategiven by
Romeo necessarily contains at least one error, which
Juliet can thenpoint out.Finally, we examine how
Juliet may be restricted to play only accordingto the game plan described above. The basic idea behind this is to constructthe replacement transducer and target DNWA in such a way that any deviationfrom the game plan causes
Juliet to immediately and irrevocably lose thegame, thus ensuring that any winning strategy, should one exist, sticks to thegame plan.The construction of the target language so far already ensures that
Juliet does not leave any undesired uncalled nodes behind, i.e. since target stringsmay only have tags from U Y t , r, l, x, s u , Juliet loses automatically if, forinstance, there are any uncalled d -nodes left behind in the final string.The only thing that still needs to be ensured is that Juliet does not skipany calls. For instance, we could imagine
Juliet trying to cheat in phase 1 byplaying Call on some i -labelled node without having called all nodes labelled c i ´ below it, or in phase 3 by calling some d -labelled node while there are stilluncalled c -labelled nodes. There are numerous further situations like these, butthey are all handled in the same way: on any Call to a function symbol, thenested substrings supposed to be rewritten due to that Call are required to beof a specific form; for instance, on a Call to some i -labelled node in phase 1, thesubstring nested below it has to be of the form h c i i ˚ h c i ` i ¨ ¨ ¨ h c k ih r ih p ih { p ih { r ih { c k i ¨ ¨ ¨ h { c i ` ih { c i i ˚ . If the substring below the called function node is not of the desired form (forinstance due to remaining c i ´ -nodes in the previous example), the replacementtransducer constructed according to the ideas laid out above will not have anaccepting run on this incorrect substring, therefore reject that substring, and,according to the semantics of NWT games, Romeo will win the game imme-diately. This shows that we can safely assume
Juliet to be restricted to thegame plan laid out above. 46inally, it is relatively easy (but again rather tedious) to prove that thereplacement transducer described above can be constructed to be of polynomialsize in | U | , n and k . Theorem 19 (restated).
For the class of games with ǫ -free NWT and Calldepth bounded by d ě , JWin is decidable, but not decidable in elementarytime.Proof.
Decidability follows from the fact that, due to the restriction to ǫ -freeNWT, there are only finitely many possible replacements for each substring that Juliet plays Call on. This, combined with the finite Call depth, means that allstrategies for
Juliet and all possible plays for each strategy can be enumeratedin finite time.The non-elementary lower bound on complexity is implied by PropositionA.14: Assume that, for some d ě
2, there exists a k such that JWin p G d q is decidable in k -fold exponential time, where G d denotes the class of gameswith ǫ -free NWT and Call depth d . It then follows (by a trivial reduction)that JWin p G q is also in k -EXPTIME , and therefore in co- k -NEXPTIME .However, by Proposition A.14, JWin p G q is hard for co- p k ` q -NEXPTIME ,which yields a contradiction to the nondeterministic time hierarchy theorem[7]. Theorem 20 (restated).
For the class of replay-free games with ǫ -free NWT, JWin is co-NEXPTIME -complete.Proof. The lower bound follows as in the proof for Proposition A.14, omittingthe first phase of the game constructed there and setting k “ Juliet while guessing universally
Romeo ’s strategy decisions.To formalise this algorithm, we use the shorthand notation r u, v s for game po-sitions, where uv P NW p Σ q , with u denoting the substring that has already beenprocessed and v the substring that is yet to be played on (including the closingtag on which Juliet is to move next). For a string u h { a i P ˆΣ ˚ , let LAST p u h { a i q denote the (unique) rooted substring of u h { a i ending at h { a i . The followingalgorithm CheckWin p G, r u, v sq then tests whether Juliet has a replay-freewinning strategy in game G “ p Σ , Γ , R, T q starting at position r u, v s .As the algorithm CheckWin p G, r ut, v sq directly mimics the gameplay ac-cording to G from position r u, v s , a simple induction argument suffices to provethat CheckWin p G, r ut, v sq accepts if and only if Juliet has a replay-free win-ning strategy in G from r u, v s ; therefore, CheckWin p G, r ǫ, w sq accepts if andonly if w P JWin p G q . It remains to be shown that CheckWin indeed runs inco-nondeterministic exponential time.To that end, we first examine the maximum size of positions used as inputsfor recursive calls of
CheckWin (where the size of a position r u, v s is definedas | uv | ). On some input r u, v s , CheckWin can only increase the size of r u, v s through the transduction in lines 14 and 15. Since R is a NWT without ǫ -transitions, any of its outputs on some input x may only have size c ¨| x | for some47 lgorithm 1 CheckWin p G, r u, v sq if v “ ǫ then if u P T then Accept else Reject if v “ tv for t P h Σ i Y p h { Σ i z h { Γ i q then // Juliet may not make a strategy choice on t ; move to the right. Return
CheckWin p G, r ut, v sq if v “ h { f i v for f P Γ then // Try out both strategy options for Juliet ; Read first. if CheckWin p G, r u h { f i , v sq accepts then Accept else
Guess universally a transduct u t P R p LAST p u h { f i qq u Ð u h { f i with LAST p u h { f i q replaced by u t if CheckWin p G, r u , v sq accepts then Accept else
Rejectconstant c depending only on R . This in turn means that the size of positionsmay only increase by a factor of c for each recursive call to CheckWin .Obviously, as each recursive call to
CheckWin removes one symbol fromthe right side of a position and insertions only occur on the left side of positions,the recursion depth of
CheckWin on an input position r ǫ, w s is at most w . Thisin turn means that input positions for recursive calls to CheckWin may be ofsize at most | w | ¨ c | w | .Finally, since each recursive call branches into at most two further callsof CheckWin , the algorithm’s recursion tree has at most exponentially manynodes in the size of w . This implies that the membership test in line 2 and theco-nondeterministic choice in line 14 are executed at most exponentially manytimes on at most exponentially long strings. Since membership testing both forNWA and for NWT is in PTIME , this yields an exponential upper bound onthe running time of
CheckWin . Theorem 21 (restated).
For the class of games with ǫ -free NWT, Call depthbounded by d ě and Call width bounded by k ě , JWin is co-NEXPTIME -complete.Proof. As replay-free games always have bounded Call width, the lower boundcarries over directly from Theorem 20.The algorithm for the upper bound is almost the same as the one for Theorem20, simply going through the input string from left to right, trying out allpossible strategies for
Juliet and guessing co-nondeterministically replacementstrings for
Romeo . The only difference is that, in this case, it also needs totrack how much of the allowed Call width and depth in the current substringhas been used up already. 48s in the proof of Theorem 20, the correctness of this algorithm is obviousas it basically just simulates gameplay.To prove that the running time and amount of non-determinism requiredby the algorithm is at most exponential, we again examine the maximum sizeof occurring strings and of the decision tree for
Juliet for any fixed counter-strategy of
Romeo , i.e. the recursion tree in any run of the algorithm.For string sizes, we again note that, for any replacement NWT R and string w , all strings in R p w q are of size at most s ¨| w | for some constant s only dependingon R . Furthermore, any replacement substring v resulting from a Call move ofdepth r ă d allows for at most k further Call moves of depth r ` k if r ` ă d ). Each of thesedepth- p r ` q substrings may be of size at most s k ¨ | v | (in case all k allowed callsgo into re-transducing v in some fashion). In total, this means that increasingCall depth by 1 increases the size of occurring strings by a multiplicative factorexponential in k . Therefore, with Call depth d and Call width k , the final stringafter a play on some input string w is at most of size | w | ¨ O p dk q , and this sizeis also an upper bound on the size of each single transduct (and therefore alsoon the amount of non-determinism required any time a transduct is guessed).Since each Call move of depth r enables at most k further calls of depth r `
1, and there are at most | w | possible Call positions of depth 0 in any inputstring w , Juliet may play at most c max def “ | w | ¨ k d Call moves in any play on w .To reach an upper bound on the number of positions Juliet has available toplace calls on during an entire play, we use the above upper bound of | w | ¨ O p dk q on the size of working strings and assume (as a generous estimate) that the entire string is replaced by a different string of length | w | ¨ O p dk q every time Juliet plays Call on some position. Then, the total number ℓ max of positions Juliet can place calls on is bounded by the total number of positions thatever become available during the entire game, which is at most the maximumstring length times the maximum number of available Call moves, i.e. ℓ max “p| w | ¨ O p dk q q ¨ p| w | ¨ k d q “ | w | ¨ O p dk q .We can now give an upper bound on the size of the decision tree for Juliet for a given counter-strategy by
Romeo . Assume nodes of this tree to be labelledwith positions that
Juliet has to make a strategy decision on, and outgoingedges to be labelled either Read or Call. Then, each root-to-leaf path has lengthequal to at most ℓ max and contains at most c max edges labelled Call, with allother edges being labelled Read. Since the sequence of Read- and Call-edgestaken from the root forms a unique address in this tree, the number of differentpaths in the tree is at most the number of strings of length ℓ max over t Read , Call u containing at most c max occurrences of Call, which is in ℓ O p c max q max . Together with ℓ max being the maximum length of paths, this implies that the decision tree hasat most ℓ O p c max q max “ | w | ¨ O p| w |¨ dk d ` q nodes.Since d and k are fixed, this means that the size of the recursion tree forthe co-nondeterministic algorithm simulating play is at most exponential, andsince each node of this recursion tree requires at most exponential computationtime and non-determinism, the algorithm indeed runs in co-nondeterministicexponential time, as was to be proven. Theorem 22 (restated).
For the class of games with ǫ -free NWT, Call depthbounded by d and Call width including input bounded by k , JWin is a) co-NP -complete for d ě and k ě ,(b) co-NP -complete for d ě and k ě , and(c) in PTIME for d “ k “ .Proof. The co-NP upper bound uses almost exactly the same algorithm as The-orem 21, going through the input string from left to right, trying out all possiblestrategies for
Juliet , guessing co-nondeterministically replacement strings for
Romeo and tracking Call depth and width along the way. The only differenceto that algorithm lies in the fact that Call width is also tracked for the inputstring, which changes the analysis from the proof of Theorem 21 as follows.With fixed bounds d on Call depth and k on Call width, the maximumnumber of Call moves that Juliet can play is c max “ k d , which is constant.With each Call move increasing the size of the current string by at most amultiplicative constant s (depending only on the replacement transducer), thismeans that the maximum size of strings is ℓ max “ | w | ¨ s c max for any inputstring w , which is linear in | w | . In analogy to the arguments from the proofof Theorem 21, this means that Juliet may perform calls on at most c max out of c max ¨ ℓ max “ O p| w |q positions, implying that the decision tree has atmost ℓ O p c max q max paths of length ℓ max each, and therefore size O p| w | c q for someconstant c . Since all strings that need to be processed or nondeterministicallyguessed at each node of the recursion tree are of polynomial length, this impliesa co-nondeterministic polynomial time complexity.The lower bounds in (a) and (b) follow by reductions from the problem co-3-SAT : Given a propositional formula ϕ in conjunctive normal form withthree literals per clause, is ϕ unsatisfiable? This problem is the complementof the well-known NP -complete problem , and therefore complete for co-NP .The reductions work as follows. Let ϕ “ C ^ . . . ^ C m be a 3-CNF formulaover variables x , . . . , x n with clauses C , . . . , C m . We construct from ϕ a game G “ p Σ , Γ , R, T q and input string w such that Romeo has a winning strategyon w in G if and only if ϕ is satisfiable; the basic idea behind the reductionis that Juliet ’s first Call to the input string allows
Romeo to pick a variableassignment α for ϕ , while Juliet ’s second Call is supposed to mark a clause thatis not satisfied by α (if one exists). In this way, Juliet has a winning strategyif and only if every possible assignment that
Romeo can chose does not satisfyall of the clauses in ϕ . Using this idea, Juliet needs to perform exactly twoCall moves; where and how these calls should be performed depends on whetherthe game is replay-free with Call width 2 (for (a)) or has Call depth 2 and Callwidth 1 (for (b)).For both reductions, the input string w is of the form w “ h r ih C i ¨ ¨ ¨ h C m ih V ih x ih { x i ¨ ¨ ¨ h x n ih { x n ih { V ih { C m i ¨ ¨ ¨ h { C ih { r i , i.e. its tree representation is a path with labels r, C , . . . , C m , V (in top-downorder), with the V -labelled node having as children leaves labelled x , . . . , x n .For the reduction in (a), the set of function symbols are Γ “ t V, C , . . . , C m u . Juliet ’s first Call is supposed to be on h { V i , which relabels V to V and each x i to either 0 i or 1 i (for i P r n s ), at Romeo ’s choice; afterwards, she calls exactlyone h { C j i (with j P r m s ), which relabels the called node to ˆ C j and leaves the50est of the string unchanged. If Juliet plays Call on some h { C j i without havingcalled h { V i first, the replacement transducer rejects its input string and Juliet loses the game immediately. The target language accepts all strings containingexactly one node labelled with a symbol ˆ C j P t ˆ C , . . . , ˆ C m u such that the clause C j is not satisfied by the variable assignment encoded below V .For (b), the set of function symbols is Γ “ t r, C , . . . C m u . Juliet ’s firstCall (the only one she can perform in the input string) is to h { r i , which relabels r to r , each C j to C j (for j P r m s ) and each x i to either 0 i or 1 i (for i P r n s ),at Romeo ’s choice; afterwards,
Juliet is supposed to call exactly one h { C j i ,relabelling it to ˆ C j . The target language accepts all strings rooted with r thatcontain exactly one node labelled with a symbol ˆ C j P t ˆ C , . . . , ˆ C m u such thatthe clause C j is not satisfied by the variable assignment encoded below V .It is easy to see that both reductions can be computed in polynomial timeand that in both cases, Juliet has a winning strategy in G if and only if ϕ isnot satisfiable.The PTIME upper bound in (c) is quite simple. Let G “ p Σ , Γ , R, T q be a game and w an input string; we now need to find out whether exactlyone of the function symbols occurring in w can be called to yield a string inthe target language. For any fixed occurrence of a function symbol in w , it iseasy to construct a NWT R that simulates R on the substring rooted at thechosen function symbol and otherwise leaves w unchanged. A type checking testagainst the target DNWA can then determine in polynomial time (cf. Theorem13 (b)) whether calling that function symbol leads to a string in the targetlanguage. Since there are less than | w | occurrences of function symbols in w ,polynomially many such type checking tests suffice to determine whether Juliet has a winning strategy in G on w that plays at most one Call move.51 roofs for Section 6 Theorem 23 (restated).
For the class of games with relabelling transducersand unbounded replay,
JWin is EXPTIME -complete.Proof.
The upper bound uses a trivial alternating polynomial-space algorithmthat moves through the input string in a left-to-right order (resetting its focus asnecessary after Call moves), guesses existentially for each closing tag a move for
Juliet and, in case of a Call, guesses universally a relabelling chosen by
Romeo and applies it to the input string. As relabellings are generally of linear size,they can easily be guessed on polynomial space, and the verification whethera guessed relabelling is indeed consistent with the replacement transducer isfeasible in polynomial time by Theorem 11.The lower bound follows by a reduction from the membership problem for lin-ear bounded alternating Turing machines, which is complete for
APSPACE “ EXPTIME [5].Let M be a linear bounded ATM with state set Q and working alphabet Σ(i.e. on input w , M uses at most | w | tape cells in any computation). Assumewithout loss of generality that any non-halting state of M is either existential oruniversal, that the transition relation for M has exactly two transitions for eachstate and tape symbol (i.e. each non-halting configuration of M has exactly twosuccessor configurations), that the initial state of M is universal and that M always moves its head to the left-most tape position before halting.We construct from M and a given input string w a game G and input string w such that Juliet has a winning strategy on w in G if and only if M accepts w . To this end, we use a similar technique as for Theorem 18: We representconfigurations of M by strings rooted at a function symbol r R Σ and have eachCall by
Juliet to h { r i initiate a transition of M , updating M ’s configurationby the replacement transduction.The main difference to the proof of Theorem 18 is that we have to takealternation into account. We simulate the alternation in M by strategy choicesof Juliet and
Romeo , with
Juliet choosing existential and
Romeo choosinguniversal transitions. Universal choice can simply be encoded into the replace-ment transducer, such that when
Juliet initiates a transition of M , Romeo chooses which of the two possible successor configurations to rewrite the currentstring to. A little more care has to be taken with existential choice, as
Juliet may not select any rewritings but can only choose whether or not a substringshould be rewritten.To allow
Juliet to choose between transitions, we extend the nested wordrepresentation of M ’s current configuration by a special flag substring , whichmay be either h ih { i or h ih { i or h ih { i . This flag should be 0 if the currentconfiguration is universal or halting, and initially set to 1 once an existentialconfiguration is reached. If it is 1, Juliet has the option to have
Romeo rewriteit to 2 by way of a Call move, or leave it as is with a Read move. Once
Juliet then initiates a transition of M , the flag indicates which of the two possiblesuccessor configuration is reached by the rewriting, i.e. Romeo does not getany choice but rewrites the current string based on the flag’s value.Once again, we represent configurations of M as in the proof of Theorem 14:a flat string p x , ´q ¨ ¨ ¨ p x k ´ i , ´qp x k , q qp x k ` , ´q ¨ ¨ ¨ p x m , ´q over the alphabetΣ ˆ p Q Y t´uq denotes that the content of M ’s working tape is x ¨ ¨ ¨ x m , with52he head of M being on the tape’s k -th cell and M being in state q , and theseflat strings are represented as nested strings using the standard nested stringencoding. By our assumption on the shape of M ’s halting configurations, the flatstring encoding of an accepting configuration is of the form p Σ ˆt q ` uqp Σ ˆt´uq ˚ for the accepting state q ` of M .The input string w for the game G is constructed as w “ h r ih ih { i p v h { r i ,where p v is the nested string representation of M ’s initial configuration withinput w (which is universal by our assumption above, hence the 0 flag). Thegame G is over the alphabet p Σ ˆ p Q Y t´uqq Y t r, , , u with function symbolsΓ “ t r, u .The replacement transducer simulates a transition of M at a Call on h { r i as described above. Such a transducer can be computed from M ’s transitionrelation in polynomial time. It is also easy to construct in polynomial time atarget DNWA accepting all strings of the form h r ih ih { i v h { r i where v representsan accepting configuration of M . It follows from the above considerations that Juliet has a winning strategy on w in G if and only if M accepts w . Theorem 24 (restated).
For any k ě , for the class of games with relabellingtransducers and bounded Call depth k , JWin is PSPACE -complete.Proof.
The upper bound again uses the trivial alternating algorithm that movesthrough the input string in a left-to-right order, guesses existentially for eachclosing tag a move for
Juliet and, in case of a Call, guesses universally arelabelling chosen by
Romeo and applies it to the input string. As in the proofof Theorem 23, relabellings can be guessed and verified in polynomial time;additionally, since the game has bounded Call depth k , strategy decisions andrelabellings are guessed at most k ¨ | w | times, which yields a polynomial timebound for the alternating algorithm.The lower bound for k “ PSPACE lower boundproof for games with fixed replacement languages without transducers ([14] ,Proposition 10(b)), as that proof only requires relabelling.
Theorem 25 (restated).
For the class of games with functional relabellingtransducers and unbounded replay,
JWin is PSPACE -complete.Proof.
As for Theorems 23 and 24, the upper bound uses the trivial algorithmsimulating the game with functional relabelling transducers by moving throughthe input string in a left-to-right order (resetting its focus as necessary after Callmoves), guessing existentially for each closing tag a move for
Juliet and, incase of a Call, also guessing the relabelling chosen by
Romeo and applying it tothe input string. Since there is only at most a single possible rewriting for eachstring input into the relabelling transducer and relabellings are of linear sizein the input, this is a nondeterministic polynomial-space algorithm witnessingmembership of
JWin in NPSPACE “ PSPACE .The lower bound for games with deterministic relabelling transducers isproven similarly to the one in Theorem 23 by reduction from the membershipproblem for linear bounded deterministic
Turing machines. The simulationof a TM by a game works as in the proof of Theorem 18, as that proof alsojust requires a deterministic transducer. For linear bounded TMs, a relabellingtransducer suffices, since no additional tape cells beyond those provided by theinput are ever inserted. 53ince all deterministic NWTs are also functional, the upper bound also ap-plies to deterministic relabelling NWTs and the lower bound also to functionalrelabelling NWTs, which proves the claim.
Theorem 26 (restated).
For any k ě , for the class of games with functionalrelabelling transducers and bounded Call depth k , JWin is NP -complete.Proof. The upper bound for functional relabelling transducers uses the samenondeterministic algorithm as the one used for the upper bound of Theorem 25;the only difference is that, since the input game has Call depth k , the algorithmhas to guess nondeterministically and verify at most k ¨ | w | strategy choices andrelabellings, each of which may be done nondeterminstically in polynomial time.This yields the desired NP upper bound.We prove the lower bound for replay-free games with deterministic rela-belling transducers by a reduction from the problem: Given a proposi-tional formula ϕ “ C ^ . . . ^ C m over variables x , . . . , x n where each clause C j isa disjunction of exactly three literals, is there an assignment α : t x , . . . , x n u Ñt , u such that ϕ evaluates to 1 under α ?We construct from ϕ a game G “ p Σ , Γ , R, T q and string w P NW p Σ q suchthat Juliet has a winning strategy on w in G if and only if ϕ is satisfiable.Thebasic idea behind the reduction is that the string w contains variable substrings ,on which Juliet chooses an assignment α by using Read and Call moves, and a clause substring , which models the structure of ϕ and which gets rewritten after Juliet ’s choice of variable assignment into a form that allows a target DNWAto check whether α satisfies ϕ .More concretely, the clause substring is w ϕ “ h C ih ℓ , ih { ℓ , ih ℓ , ih { ℓ , ih ℓ , ih { ℓ , ih { C i ¨ ¨ ¨ h C m ih ℓ m, ih { ℓ m, ih ℓ m, ih { ℓ m, ih ℓ m, ih { ℓ m, ih { C m i , where for each i P r m s , j P r s and k P r n s , ℓ i,j “ " x k , if x k is the j -th literal of C i x k , if x k is the j -th literal of C i .The input string w is constructed inductively; we set w “ w , where for each i P r n ` s , w i “ " h r ih y i ih { y i i w i ` h { r i , for i P r n s w ϕ , for i “ n ` w is supposed to proceed as follows: Juliet first goes through thevariable substrings of the form h y i ih { y i i , choosing whether or not to call each h { y i i in turn. On a Call, y i gets relabelled to y i . In this way, Juliet choosesa variable assignment α , with a remaining y i interpreted as α p x i q “ y i interpreted as α p x i q “ Juliet is supposed to call each h { r i in turn. On each suchCall, the relabelling transducer T takes the valuation y i (or y i respectively)of the variable immediately following the corresponding h r i and rewrites alloccurrences of x i in w ϕ into 0 and all x i into 1 (or x i into 1 and x i into 0,respectively). After all literals in w ϕ have been rewritten into 0 or 1, the targetDNWA simply needs to check whether, for each j P r m s , the substring enclosedin C j tags contains at least one substring h ih { i .54ore formally, the game G uses the alphabet Σ “ t x i , x i , y i , y i | i P r n su Yt C j | j P r m su Y t r u with function symbols Γ “ t r u Y t y i | i P r n su .The relabelling transducer R behaves as follows: • R rewrites each input of the form h y i ih { y i i into h y i ih { y i i . • On an input of the form h r ih ℓ ih { ℓ i v h { r i (for ℓ P t y i , y i | i P r n su ), R memorises ℓ in its state and performs a relabelling on v : – If ℓ “ y i for some i P r n s , then R relabels each x i in v to 0 and each x i to 1, and – If ℓ “ y i for some i P r n s , then R relabels each x i in v to 1 and each x i to 0.The target language T contains all strings w of the form of w as definedabove, with the following modifications: • w does not contain any labels from t x i , x i | i P r n su , and • each h C j i tag (for j P r m s ) is followed by at least one h ih { i substringbefore the corresponding h { C j i tag.The construction of G and w from ϕ is obviously possible in polynomial time.Furthermore, by the above consideration on the construction and verification ofassignments for ϕ , it is easy to see that Juliet has a winning strategy on w in G if and only if ϕ is satisfiable. Theorem 27 (restated).
For the class of write-once games with functionalrelabelling transducers,
JWin is in
PTIME .Proof.
The crucial insight for this proof is the fact that games with functionalreplacement transducers are essentially solitaire games for
Juliet – the result ofany Call on some substring is uniquely determined by that substring, with nochoice for
Romeo .We utilise this fact by constructing from a given game G “ p Σ , Γ , R, T q a(generally non-functional) relabelling NWT R J such that for each input string w P NW p Σ q , the image R J p w q is exactly the set of all strings that w can berewritten into by some left-to-right sequence of Read and Call moves by Juliet .Checking for the existence of a winning strategy for