• Aucun résultat trouvé

Visibly Pushdown Transducers with Well-nested Outputs

N/A
N/A
Protected

Academic year: 2022

Partager "Visibly Pushdown Transducers with Well-nested Outputs"

Copied!
12
0
0

Texte intégral

(1)

Visibly Pushdown Transducers with Well-nested Outputs

Pierre-Alain Reynier?and Jean-Marc Talbot?

Aix Marseille Universit´e, CNRS, LIF UMR 7279, 13288, Marseille, France

Abstract. Visibly pushdown transducers (VPTs) are visibly pushdown automata extended with outputs. They have been introduced to model transformations of nested words, i.e. words with a call/return structure. When outputs are also struc- tured and well nested words,VPTs are a natural formalism to express tree trans- formations evaluated in streaming. We prove the class ofVPTs with well-nested outputs to be decidable in PTIME. Moreover, we show that this class is closed un- der composition and that its type-checking against visibly pushdown languages is decidable.

1 Introduction

Visibly pushdown automata (VPA) [1] (first introduced as input-driven pushdown au- tomata [3]) are pushdown machines whose stack behavior is synchronized with the structure of the input word. More precisely, the input alphabet is partitioned into call and return symbols; when reading a call symbol the machine must push a symbol onto the stack, when reading a return symbol it must pop a symbol from the stack and when reading an internal symbol the stack remains unchanged. Such words over a structure alphabet are called nested words.

Visibly pushdown transducers (VPTs) [7,9,6,10] extend visibly pushdown automata with outputs. Each transition is equipped with an output word; aVPTthus transforms an input word into an output word obtained as the concatenation of all the output words produced along a successful run (i.e.a sequence of transitions) on this input.VPTs are a strict subclass of pushdown transducers (PTs) and strictly extend finite state transduc- ers. Several problems that are undecidable for PTs are decidable forVPTs similarly to finite state transducers: functionality (in PTIME),k-valuedness (in co-NPTIME) and functional equivalence (EXPTIME-complete) [6]. However, some decidability results or valuable properties of finite-state transducers do not hold forVPTs [7]:VPTs are not closed under composition and type-checking againstVPAis undecidable (deciding whether the range of a transducer is included into the language of a givenVPA).

Unranked trees and more generally hedges can be linearized into nested words over a structured alphabet (such as XML documents). These words for which the matching between call and return symbols is perfect are called well-nested words. So, VPTs are a suitable formalism to express hedge transformations. Moreover, as they process the linearization from left to right, they are also an adequate formalism to model and analyze transformations in streaming, as shown in [5].VPTs output strings; operating on well-nested inputs, they define hedge-to-string transformations. If the output strings are well-nested too, they define hedge-to-hedge transformations [4].

?Partly supported by the PEPS project ”Synthesis of Stream Processors” funded by CNRS.

(2)

In [6], by means of a syntactical restriction on transition rules, a class ofVPTs whose range contains only well-nested words is presented. This class enjoys good prop- erties: it is closed under composition and type-checking against visibly pushdown lan- guages is decidable. One may then wonder whether these properties come from this particular subclass or from the fact that the range of theseVPTs contains only well- nested words.

In this paper, we consider two classes of transductions (that is, of relations) over nested words definable byVPTs. First, the class ofglobally well-nestedtransductions, denotedGwn, is the class ofVPTtransductions whose range contains only well-nested words. The second class, namedalmost well-nestedand denotedAwn, slightly gener- alizes the first one as follows: there must exist k 2 Nsuch that every output word contains at mostkunmatched returns and at mostkunmatched calls. These two classes of transductions naturally define two classes of transducersgwnVPTandawnVPT: a VPTis ingwnVPT(resp. inawnVPT) if the transduction it represents is inGwn(resp.

inAwn). While defined in a semantical way, we provide criteria on successful computa- tions ofVPTs characterizing precisely the classesgwnVPTandawnVPT. Then, based on these criteria, we prove the class awnVPTto be decidable in PSPACE. Regarding the classgwnVPT, using a recent result of [2], we prove it is decidable in PTIME. Fi- nally, we prove that the two classesgwnVPTandawnVPTenjoy good properties: they are closed under composition and type-checking is decidable against visibly pushdown languages.

The paper is organized as follows: definitions and recalls of some basic proper- ties onVPTs are presented in Section 2. We introduce in Section 3 the two classes of transductions we define in this paper as well as the corresponding classes of transduc- ers. Considering additionally the (restricted) class introduced in [6], we prove also that they form a strict hierarchy. Then, we give in Section 4 a precise characterization of the classesgwnVPTandawnVPTby means of some criteria onVPTs. Section 5 de- scribes decision procedure of the considered classes of transducers. Finally, the closure of the considered classes under composition and the decidability of type-checking are addressed in Section 6. Omitted details can be found in a technical report [8].

2 Preliminaries

(Well) nested words The set of all finite words (resp. of all words of length at mostn) over a finite alphabet⌃is denoted by⌃(resp.⌃n); the empty word is denoted by✏.

Astructured alphabetis a triple⌃= (⌃c,⌃i,⌃r)of disjoint alphabets, of call, internal and return symbols respectively. Given a structured alphabet⌃, we always denote by

c,⌃iand⌃rits implicit structure, and identify⌃with⌃c[⌃i[⌃r. Anested word is a finite word over a structured alphabet.

The set ofwell-nested wordsover a structured alphabet⌃is the least set, denoted by⌃wn , that satisfies(i)✏2⌃wn ,(ii)for alli2 ⌃i,w 2⌃wn ,iw2⌃wn , and(iii) for allw, w0 2⌃wn,c 2⌃c,r2⌃r,cwrw0 2⌃wn . E.g. on⌃ = ({c1, c2},;,{r}), the nested wordc1rc2ris well-nested whilerc1is not.

For a wordwfrom⌃, we define its balanceBas the difference between the number of symbols from⌃c and of symbols from⌃roccurring inw. Note that ifw 2 ⌃wn , thenB(w) = 0; but the converse is false as exemplified byrc1.

(3)

Lemma 1. Letu, v2⌃. We haveB(uv) =B(u) +B(v) =B(vu).

For any wordwfrom⌃, we denote byOc(w)(resp.Or(w)) the number of open calls (resp. open returns) inw. Formally,

Or(w) = min{B(w0)|w0w00=w} Oc(w) =B(w) +Or(w)

We define, for any wordw,O(w)as the pair(Or(w),Oc(w))2N2. Given(n1, n2)2 N2, we define||(n1, n2)||= max(n1, n2). Note that, for a wordw, we obtain||O(w)||= max{Or(w),Oc(w)}andw2⌃wn iff||O(w)||= 0, that isO(w) = (0,0).

Given a wordw 2⌃, we letheight(w) = max{||O(w1)|| |w =w1w2}be the height ofw. We denote by|w|the length ofw, defined as usual.

Definition 1. For any two pairs(n1, n2)and(n01, n02)of naturals fromN2, we define (n1, n2) (n01, n02)as the pair

⇢(n1, n2 n01+n02) if n2 n01 (n1+n01 n2, n02) if n01> n2

Proposition 1. (N2, ,(0,0)) is a monoid, and the mappingO is a morphism from (⌃, .,✏)to(N2, ,(0,0)); in particular, for any two wordsu1, u2from⌃,O(u1u2) = O(u1) O(u2).

Transductions - Transducers Let⌃be a structured (input) alphabet, and be a struc- tured (output) alphabet. A relation over ⌃ is atransduction. We denote by T(⌃, )the set of these transductions. For a transductionT, the set of wordsu(resp.

v) such that(u, v)2Tis called thedomain(resp. therange) ofT.

Avisibly pushdown transducerfrom⌃to (the class is denotedVPT(⌃, )) is a tupleA= (Q, I, F, , )whereQis a finite set of states,I✓Qthe set of initial states, F ✓Qthe set of final states, a (finite) stack alphabet, and = c] r] iis the transition relation where:

c✓Q⇥⌃c⇥ ⇥ ⇥Qare thecall transitions, – r✓Q⇥⌃r⇥ ⇥ ⇥Qare thereturn transitions.

i✓Q⇥⌃i⇥Qare theinternal transitions.

A stack (content) is a word over . Hence, is a monoid for the concatenation with?(the empty stack) as neutral element. A configuration ofAis a pair(q, )where q2Qand 2 is a stack content. Letu=a1. . . albe a (nested) word on⌃, and (q, ),(q0, 0)be two configurations ofA. Arunof theVPTAoverufrom(q, )to (q0, 0)is a (possibly empty) sequence of transitions⇢=t1t2. . . tl2 such that there existq0, q1, . . . ql 2Qand 0, . . . l 2 with(q0, 0) = (q, ),(ql, l) = (q0, 0), and for each 0 < k  l, we have either (i) tk = (qk 1, ak, , wk, qk) 2 c and

k = k 1 , or (ii) tk = (qk 1, ak, , wk, qk) 2 r, and k 1 = k , or (iii) tk = (qk 1, ak, wk, qk) 2 i, and k 1 = k. When the sequence of transitions is empty,(q, ) = (q0, 0).

The length (resp. height) of a run⇢over some wordu 2 ⌃, denoted|⇢|(resp.

height(⇢)) is defined as the length ofu(resp. as the height ofu).

(4)

Theoutputof⇢(denotedoutput(⇢)) is the wordv 2 defined as the concate- nationw = w1. . . wlwhen the sequence of transitions is not empty and✏otherwise.

We write(q, ) u|w! (q0, 0)when there exists a run onufrom(q, )to(q0, 0)pro- ducingwas output. Initial (resp. final) configurations are pairs(q,?)withq2I(resp.

withq 2 F). A configuration(q, )isreachable (resp.co-reachable) if there exists some initial configuration(i,?)(resp. some final configuration(f,?)) and a run from (i,?)to(q, )(resp. from(q, )to(f,?)). A run isacceptingif it starts in an initial configuration and ends in a final configuration.

A transducerA defines relation/transduction from nested words to nested words, denoted by JAK, and defined as the set of pairs(u, v) 2 ⌃ such that there exists an accepting run on uproducingv as output. Note that since both initial and final configurations have empty stack,A accepts only well-nested words, i.e.JAK ✓

wn.

We denoteVP(⌃, )the class of transductions defined byVPTs over the struc- tured alphabets⌃(as input alphabet) and (as output alphabet).

Given aVPTA = (Q, I, F, , ), we let OAmaxbe the maximal number of open calls and of open returns in a word produced as output of a call or of a return transition inA. Formally, we have:

OAmax= max{||O(w)|| |(p,↵, w, , q)2 c[ r}

Visibly pushdown automata We define visibly pushdown automata (VPA) simply as a particular case ofVPT; we may think of them as transducers with no output. Hence, only the domain of the transduction matters and is called the language defined by the visibly pushdown automaton. For an automatonA, this language will be denotedL(A).

Properties of computations in VPA/VPT We recall two standard results on runs of visibly pushdown machines.

Lemma 2. LetAbe aVPAwith set of statesQand⇢: (p,?) !u (q,?)be a run ofA over some wordu2⌃wn . Leth2N>0. We have:

(i) ifheight(u)< hand|u| |Q|h, then⇢can be decomposed as follows:

⇢: (p,?) u!1 (p1, ) u!2 (p1, ) u!3 (q,?) withu1u3andu2well-nested words andu26=✏.

(ii) ifheight(u) |Q|2, then⇢can be decomposed as follows:

⇢: (p,?) u!1 (p1, ) u!2 (p1, 0) u!3 (p2, 0) u!4 (p2, ) u!5 (q,?) withu1u5,u2u4andu3well-nested words, and 06=?.

3 Classes of VPT producing (almost) well-nested outputs

In this section, after recalling the definition of (locally) well-nestedVPT, we introduce the new classes of globally and almost well-nestedVPT. Then, we prove relationships between these classes.

(5)

3.1 Definitions

Locally Well-nestedVPTs (lwnVPT) In [6], the class of (locally) well-nestedVPThas been introduced. For this class, the enforcement of the well-nestedness of the output is done locally and syntactically at the level of transition rules.

Definition 2 (Locally Well-nested).LetA= (Q, I, F, , )be aVPT.Ais alocally well-nestedVPT(lwnVPT)if:

– for any pair of transitions(q, a, v, , q0)2 c,(p, b, w, , p0)2 r, the wordvwis well nested, and

– for any transition(q, a, v, q0)2 i, the wordvis well-nested.

AVPTtransductionTislocally well-nestedif there exists alwnVPTAthat realizesT (JAK=T). The class of locally well-nestedVPTtransductions is denotedLwn.

It is straightforward to prove that

Proposition 2. LetAbe a locally well-nestedVPTand (p, ),(q, )two configura- tions ofA. For all well-nested wordu, if(p, ) u/v!(q, )thenv2⌃wn.

Therefore, any locally well-nestedVPTtransductionTis included into⌃wnwn. Globally well-nestedVPTtransduction - Almost well-nestedVPTtransduction In this section, we introduce the class of globally well-nested transductions and its weaker variant of ”almost” well-nested transductions. Unlike the definition of Lwn which is done at the level of transducers, these definitions are done at the level of transductions and thus, as a semantical property.

Definition 3 (Globally Well-nested).AVPTtransductionT isglobally well-nestedif T(⌃wn )✓ wn. The class of globally well-nestedVPTtransductions is denotedGwn.

AVPTA isglobally well-nestedif its transductionJAKis. The class of globally well-nestedVPTis denotedgwnVPT.

Definition 4 (Almost Well-nested). A VPTtransduction T isalmost well-nested if there existskinNsuch that for every pair of words(u, v)2T, it holds that||O(v)|| k. The class of almost well-nestedVPTtransductions is denotedAwn.

AVPTAisalmost well-nestedif its transductionJAKis. The class of almost well- nestedVPTis denotedawnVPT.

3.2 Comparison of the different classes

Classes of transductionsGwnandAwnare defined by semantical conditions on the de- fined relations. This yields a clear correspondence between the classesGwnandgwnVPT on one side andAwnandawnVPTon the other side. This is not the case forLwn: two examples ofVPTs are given in Figure 1. It is easy to verify thatA1, A2 2 gwnVPT.

Moreover, none of these transducers belongs tolwnVPT. However, one can easily build a transducerA02such thatJA2K = JA02KandA02 2 lwnVPT. Indeed one can perform the following modifications:

(6)

i c|ccc,γ p1 i|rr p2 r|r,γ f

c|cr,γ r|cr,γ

(a) TheVPTA1.

i c|cc,γ p1 i|c p2 r|rrr,γ f

c|cr,γ r|rc,γ

(b) TheVPTA2. Fig. 1.TwoVPTs inVP(⌃,⌃)with⌃c={c},⌃r={r}and⌃i={i}.

– the transition(p1, i, c, p2)becomes(p1, i,✏, p2)

– the transition(p2, r, rc, 0, p2)becomes(p2, r, cr, 0, p2) – the transition(p2, r, rrr, , f)becomes(p2, r, crrr, , f)

On the contrary, as we prove below, the transductionJA1Kdoes not belong toLwn: there exists no transducerA012lwnVPTsuch thatJA01K=JA1K.

To summarize, we prove the following proposition.

Proposition 3. The following inclusion results hold:

– For transducers:lwnVPT(gwnVPT(awnVPT – For transductions:Lwn (Gwn(Awn

Proof (Sketch).The non-strict inclusions are straightforward. The two strict inclusions gwnVPT ( awnVPT andGwn ( Awn follow from the constraint on the range. The strict inclusionlwnVPT (gwnVPTis witnessed byA2from Figure 1, as explained above.

We sketch now the proof of the strict inclusionLwn(Gwn, and therefore consider the transducerA1on Figure 1. Observe thatJA1K 2 Gwn, we show thatJA1K 62 Lwn. First note thatJA1K={(cckirkr, ccc(cr)krr(cr)kr)|k2N}and that

– (Fact 1) The transduction defined byA1is injective

– (Fact 2) Any word of the output can be decomposed asw1rrw2 wherew1 = ccc(cr)k andw2 = (cr)krfor some naturalkand for eachw1with fixedkthere exists a uniquew2such thatw1rrw2is in the range ofA1(and conversely).

By contradiction, suppose that there existsA012lwnVPTsuch thatJA01K=JA1K. Now, forksufficiently large and depending only on the fixed size ofA01,A01has an accepting run for the inputcckirkrof the form given in the point(ii)of Lemma 2. Let us denote byui (resp.vi),i 2 {1, . . . ,5} the corresponding decomposition of the input (resp.

output) word. Due to Proposition 2, wordsv1v5,v2v4andv3are well-nested.

Now, assume thatv2 = ✏ andv4 = ✏. Then, using a simple pumping argument over the pair(u2, u4), one would obtain a different input producing the same output, contradicting the injectivity ofA01(due to (Fact 1)). So,v26=✏orv46=✏.

Using a case analysis on the presence of the previously mentioned patternrrin the outputs ofA01, using the fact thatv2v4 6=✏, (Fact 2) and a pumping argument over the pair of words(u2, u4), one obtains a contradiction. ut

(7)

4 Characterizations

In this section we give criteria onVPTs that aim to characterize the classesgwnVPT andawnVPT.

Definition 5. LetAbe aVPT. Let us consider the following criteria:

(C1) For all statesp, i, f such thatiis initial andf is final, for any stack , then any accepting run

(i,?) u1/v!1 (p, ) u2/v!2 (p, ) u3/v!3 (f,?) withu1u3, u22⌃wn satisfiesB(v2) = 0.

(C2) For all statesp, q, i, f such thatiis initial andf is final, for any stack , 0, then any accepting run

(i,?) u1/v!1 (p, ) u2/v!2 (p, 0) u3/v!3 (q, 0) u4/v!4 (q, ) u5/v!5 (f,?) withu2u4, u32⌃wn and 0 6=?satisfiesB(v2) +B(v4) = 0andB(v2) 0.

The following result follows from Propositions 4 and 5 that we prove below.

Theorem 1. AVPTAis almost well-nested iff it verifies criteria(C1)and(C2).

Lemma 3. LetX ✓ ⌃such that the setB(X) = {B(u)| u2X}is infinite. Then the set{O(u)|u2X}is infinite as well.

Lemma 4. Letu 2 ⌃ and k be a strictly positive integer. ThenO(uk)is equal to (Or(u),(Oc(u) Or(u))⇤(k 1) +Oc(u)) if Oc(u) Or(u) and to(Or(u) + (Or(u) Oc(u))⇤(k 1),Oc(u))otherwise.

Proof. By definition of and by induction onk. ut

Proposition 4. LetAbe aVPT. IfAdoes not satisfy(C1)or(C2), thenA62awnVPT.

Proof. Let us assume that Adoes not satisfy (C1). Hence there exists an accepting run as described in criterion(C1)such thatB(v2)6= 0. We then build by iterating the loop on word u2 accepting runs for words of the formu1(u2)ku3 for any naturalk, producing output wordsv1(v2)kv3. Let us denote this set byX. AsB(v2)6= 0and by Lemma 1, the setB(X)is infinite. Lemma 3 entails thatAis not almost well-nested.

Assume now thatAdoes not satisfy(C2). Hence, there exists an accepting run as described in the statement of the proposition such that either(i)B(v2)+B(v4) =b6= 0 or(ii)B(v2)<0. In the case of(i), from this run, one can build by pumping accepting runs for words of the formu1(u2)ku3(u4)ku5for any naturalk, producing output words v1(v2)kv3(u4)kv5. As before, Lemmas 1 and 3 imply thatAis not almost well-nested.

Now, for(ii)assuming thatB(v2)+B(v4) = 0. AsB(v2)<0, it holds thatB(v4)>

0and thus,Or(v2)>Oc(v2),Or(v4)<Oc(v4). From the run of the statement, one can build by pumping accepting runs for words of the formu1(u2)ku3(u4)ku5for any natu- ralk, producing output wordsv1(v2)kv3(v4)kv5. Now, we considerO(v1(v2)kv3(v4)kv5)

(8)

which, by associativity of , is equal toO(v1) O((v2)k) O(v3) O((u4)k) O(v5)).

Now, by Lemma 4, it is equal to

O(v1) (Or(v2) + (Or(v2) Oc(v2))⇤(k 1),Oc(v2)) O(v3) (Or(v4),(Oc(v4) Or(v4))⇤(k 1) +Oc(v4)) O(v5)

It is easy to see that forkvarying, the described pairs are unbounded. ut Given aVPTA= (Q, I, F, , ), we define the integerNA= 2|Q|2|Q|2.

Lemma 5. LetAbe aVPT. IfA satisfies the criteria(C1)and (C2), then for any accepting run⇢such that|⇢| NA, there exists an accepting run⇢0such that|⇢0|<|⇢| and||O(output(⇢0))|| ||O(output(⇢))||.

Proof (Sketch).LetA= (Q, I, F, , )and⇢be an accepting run such that|⇢| NA. We distinguish two cases, depending onheight(⇢):

– whenheight(⇢)<2|Q|2: by definition ofNA, we can apply Lemma 2.(i)twice and prove that⇢is of the following form:

(i,?) u1/v!1 (p, ) u2/v!2 (p, ) u3/v!3 (q, 0) u4/v!4 (q, 0) u5/v!5 (f,?) withu2, u42⌃wn \ {✏}. Then, by criterion(C1), we haveB(v2) =B(v4) = 0.

One can prove that at least one ofu2andu4can be removed fromuwhile preserv- ing the valueOr(u). Let us denote byv0 the resulting output word. Observe also that removing this part of the run does not modify the balanceB(.)of the run, as B(v2) =B(v4) = 0. AsOc(v) =B(v) +Or(v), we obtainO(v) =O(v0), yielding the result.

– whenheight(⇢) 2|Q|2: in this case, we can apply Lemma 2.(ii)twice and prove that⇢is of the following form:

(i,?) u1/v!1 (p1, ) u2/v!2 (p1, 1) u3/v!3 (q1, 1 2) u4/v!4 (q1, 1 2 3)

u5/v5

!(q2, 1 2 3) u6/v!6 (q2, 1 2) u7/v!8 (p2, 1) u8/v!8 (p2, ) u9/v!9 (f,?), withu1u9, u2u8, u3u7, u4u6, u52⌃wn and 1, 36=?.

Then the two following runs can be built: the one obtained by removing the parts of⇢onu2andu8, and the one obtained by removing the parts of⇢onu4andu6, yielding runs whose length is strictly smaller than|⇢|. Let us denote these two runs by⇢0and⇢00respectively, and their outputs byv0andv00. AsAverifies the criterion (C2), we have thatB(v) =B(v0) =B(v00), asB(v2)+B(v8) =B(v4)+B(v6) = 0 andBis commutative. In order to obtain the result, we studyOr(v). Considering different cases, we manage to prove that eitherOr(v0) Or(v)orOr(v00) Or(v).

The result follows as for any wordwwe haveOc(w) =B(w) +Or(w). ut Proposition 5. LetAbe aVPT. IfAsatisfies(C1)and(C2), then every accepting run

⇢: (i,?) u|v!(f,?)ofAverifies||O(v)||NA.OAmax.

Proof. If|⇢|NAthe result is trivial; otherwise, assuming the existence of a minimal counter-example of this statement, a contradiction follows from Lemma 5. ut

(9)

Now we can show a precise characterization of transducers fromgwnVPTamongst those inawnVPT.

Definition 6. LetAbe aVPT. We consider the following criterion:

(D) For all(u, v)2JTK, if|u|NAthenv2⌃wn .

Theorem 2. AVPTAis globally well-nested iff it verifies criteria(C1),(C2)and(D).

Proof. The direct implication is trivial, the other one follows from Lemma 5. ut

5 Deciding the classes of almost and globally well-nested VPT

In this section, we prove that given aVPTA, it is decidable to know whetherJAK2Awn

and whetherJAK2Gwn. It is known that

Proposition 6. Given aVPTA= (Q, I, F, , )and statesp, qofA, deciding whether there exists some stack such that(p, )is reachable and(q, )is co-reachable can be done inPTIME.

Theorem 3. LetAbe aVPT. WhetherJAK2Awncan be decided inPSPACE. Proof (Sketch).By Theorem 1, deciding the classawnVPTamounts to decide criteria (C1)and(C2). Therefore we propose a non-deterministic algorithm running in poly- nomial space, yielding the result thanks to Savitch theorem.

We claim thatAverifies(C1)and(C2)if and only if it verifies these criteria on

”small instances”, defined as follows:

– Criterion(C1): consider only wordsu2 such thatheight(u2) |Q|2and|u2|  2.|Q||Q|2.

– Criterion(C2): consider only stacks 0 such that| 0||Q|2and wordsu2, u4of height at most2.|Q|2and length at most|Q|2.|Q||Q|2.

The non-deterministic algorithm follows from the claim: in order to exhibit a witness of the fact thatA62awnVPT, the algorithm guesses whether(C1)or(C2)is violated;

then, the claim implies the existence of a witness of at most exponential size. This witness can be guessed on-the-fly in polynomial space. Proposition 6 is then used to check that the witness can be completed into an accepted run.

To prove this claim, we show, by induction onu2⌃wn , that for every run(p,?) u|!v (q,?)that can be completed into an accepting run, and for every decomposition of this run according to criterion(C1)or(C2), the property stated by the corresponding crite-

rion is fulfilled. ut

The previous algorithm could be extended to handle in addition criterion(D), yield- ing a PSPACEalgorithm to decide whether aVPTAis globally well-nested. However, we can use a recent result to prove that this problem can be solved in PTIME.

Theorem 4. LetAbe aVPT. WhetherJAK2Gwncan be decided inPTIME.

(10)

Proof. This proof relies on results from [2] showing that deciding whether a context- free language is included into a Dyck language can be solved in PTIME.

We first erase the precise symbols of the produced outputs keeping track only of the type of the symbols: we build fromAaVPTA0 defined on the structured output alphabet⌃0 with⌃c0 = {(},⌃r0 = {)} and⌃i0 = ;. A transition ofA0 is obtained from a transition ofAby replacing in output words of the transition ofAcall symbols by (and return symbols by )and removing internal symbols. It is then easy to see thatAis ingwnVPTiffA0is ingwnVPT(actually, for each run inAproducingv, its corresponding run inA0produces somev0such thatO(v) =O(v0)). Then, as shown in [9], one can build in polynomial time a context-free grammarGA0generating the range

ofA0. Finally, we appeal to [2] to conclude. ut

6 Closure under composition and Type-checking

6.1 Definitions and existing results

We consider two natural problems for transducers : the first one is related to composition of transductions. The second problem is the type-checking problem that aims to verify that any output of a transformation belongs to some given type/language. ForVPT, the obvious class of ”types” to consider is the class of languages defined byVPA.

Definition 7 (Closure under composition). A classT of transductions included in

⇥⌃is closed under composition if for allT, T0 inT, the transductionT T0 is also inT. It is effectively closed under composition if for any transducersA,A0 such thatJAK,JA0K2T,A A0is computable andJA A0Kis inT.

A class of transducersTis effectively closed under composition if for any two trans- ducersA, A0inT,A A0is computable andA A0is inT.

Definition 8 (Type-checking (against VPA)). Given a VPTA and two VPA B, C, decide whetherJAK(L(B))✓L(C).

The following results give the status of these properties for arbitraryVPTs and for lwnVPT:

Theorem 5 ([7,6]).Regarding closure under composition, we have:

– The classVP(⌃,⌃)is not closed under composition.

– The classlwnVPTis effectively closed under composition.

In addition, the problem of type checking againstVPAis undecidable for (arbitrary) VPTand decidable forlwnVPT.

6.2 New results

Actually, regarding the closure under composition of the class lwnVPT, though not explicitly stated, the result proved in [6] is slightly stronger. It is indeed shown that for anyVPTA, Bsuch thatA2lwnVPT, there exists an (effectively computable)VPTC satisfyingJCK=JAK JBK. In addition, ifB2lwnVPT, thenC2lwnVPT.

(11)

We extend this positive result to any almost well-nested transducer.

One of the main ingredients of the proof of this result is the setUPSAdefined for anyVPTtransducerA= (QA, IA, FA, A, A)as

(

(p, p0, n1, n2) 9 2 , (p, )is reachable and(p0, )is co-reachable and 9u2⌃wn ,(p,?) u|v!(p0,?)andO(v) = (n1, n2)

)

Proposition 7. LetAinawnVPT. Then the setUPSAis finite and computable in ex- ponential time in the size ofA.

Theorem 6. LetA, Bbe twoVPTs. IfAis almost-well nested, then one can compute in exponential time in the size of A and B a VPTC such thatJCK = JAK JBK. Moreover, ifB is also almost well-nested, then so isC, and ifA andB are globally well-nested, then so isC.

Proof (Sketch).We present the construction ofC. By Proposition 7,UPSAis finite and we letKbe the computable integer valuemax{||(n1, n2)|| |(p, p0, n1, n2)2UPSA}.

GivenB= (QB, IB, FB, B, B), we defineC= (QC, IC, FC, C, C)as QC=QA⇥QBBK IC =IA⇥IB⇥{?}

C= ABOAmax+K FC =FA⇥FB⇥{?}

Now for the transition rules C:

– ((p, q, ), i, w,(p0, q0, 0))2 iCif there exist a wordv2 and a stack 02 B

such that = 0 1, 0 = 0 0

1,O(v) = (| 1|,| 10|), and(p, i, v, p0) 2 iAand there exists a run(q, 1) v|w!(q0, 01)inB,

– ((p, q, ), c, w,( , 3),(p0, q0, 4))2 Cc if there exist a wordv 2 , two stacks

0, 22 B and a stack symbol 2 Asuch that = 0 1,O(v) = (| 1|,| 2|),

0 2= 3 4,(p, c, v, , p0)2 Ac and there exists a run(q, 1) v|!w (q0, 2)inB such a transition exists provided the bounds on the sizes of the different stacks are fulfilled,i.e.| |K,| 4|K, and| 3|OAmax+K,

– ((p, q, ), r, w,( , 3),(p0, q0, 0))2 rCif there exist a wordv2 , a stack 02

B such that 0 1 = 3 , 0 2 = 0,O(v) = (| 1|,| 2|),(p, r, v, , p0) 2 Ar

and there exists a run(q, 1) v|w! (q0, 2)inBsuch a transition exists provided the bounds on the sizes of the different stacks are fulfilled,i.e.| |K,| 0|K, and| 3|OAmax+K.

In a state ofC, we store the current states ofAandB. In addition, a part of the top of the stack ofBis also stored in the state ofCto allow the simulation ofB. The (finite) amount that needs to be stored in the state is identified using the setUPSA. ut Corollary 1. The classesGwnandAwnare (effectively) closed under composition.

Theorem 7 (Type-checking againstVPA).Given an almost well-nestedVPTAand two visibly pushdown automata B, C, whether JAK(L(B)) ✓ L(C)is decidable in 2 EXPTIME.

(12)

Proof. Restricting the domain ofAtoL(B)is easy: it suffices to compute the product VPAofAandB. Then,VPAbeing closed under complementation, we computeC, the complement ofC. Note that the size ofCis at most exponential in the size ofC. We then turnCinto a transducerC0defining the identity relation overL(C)(this is obvious by simply transforming rules ofCinto rules of transducers outputting their input). Now, by Theorem 6, one can build a transducer defining the composition ofJAK JC0K. This can be done in doubly exponential time in the size ofAandC. Now, it is sufficient to test whether theVPAunderlying this transducer is empty or not. ut

7 Conclusion

In this paper, we have considered and precisely characterized the class ofVPTwith well-nested outputs. We have shown that this class is closed under composition and that its type-checking againstVPAis decidable. We have restricted ourselves in this paper to transducers with well-nested domains. We conjecture that this restriction can be easily relaxed and thus, one could consider transducers based on nested word automata [1].

We left open the problem of deciding the classLwn. As we have described on some examples, this problem is far from being trivial. In [4], a clear relationship between the class lwnVPTand hedge-to-hedge transducers is described; investigating such a relationship forgwnVPTis also an interesting problem.

References

1. R. Alur and P. Madhusudan. Adding Nesting Structure to Words. Journal of the ACM, 56(3):1–43, 2009.

2. A. Bertoni, C. Choffrut, and R. Radicioni. The inclusion problem of context-free languages:

Some tractable cases.International Journal of Foundations of Computer Science, 22(2):289–

299, 2011.

3. B. v. Braunm¨uhl and R. Verbeek. Input-driven Languages are Recognized in log n Space. In Fundamentals of Computation Theory, 4th International Conference, volume 158 ofLNCS, pages 40–51, 1983.

4. M. Caralp, E. Filiot, P.-A. Reynier, F. Servais, and J.-M. Talbot. Expressiveness of visibly pushdown transducers. InSecond International Workshop on Trends in Tree Automata and Tree Transducers, volume 134 ofEPTCS, pages 17–26, 2013.

5. E. Filiot, O. Gauwin, P.-A. Reynier, and F. Servais. Streamability of Nested Word Transduc- tions. InIARCS Annual Conference on Foundations of Software Technology and Theoretical Computer Science, volume 13 ofLIPIcs, pages 312–324, 2011.

6. E. Filiot, J.-F. Raskin, P.-A. Reynier, F. Servais, and J.-M. Talbot. Properties of Visibly Pushdown Transducers. InMathematical Foundations of Computer Science 2010, 35th In- ternational Symposium, volume 6281 ofLNCS, pages 355–367, 2010.

7. J.-F. Raskin and F. Servais. Visibly pushdown transducers. InAutomata, Languages and Programming, 35th International Colloquium, volume 5126 ofLNCS, pages 386–397, 2008.

8. P.-A. Reynier and J.-M. Talbot. Visibly Pushdown Transducers with Well-nested Outputs.

Technical report, http://hal.archives-ouvertes.fr/hal-00988129/PDF/wnVPT.pdf, 2014.

9. F. Servais.Visibly Pushdown Transducers. PhD thesis, Universit´e Libre de Bruxelles, 2011.

10. S. Staworko, G. Laurence, A. Lemay, and J. Niehren. Equivalence of deterministic nested word to word transducers. InFundamentals of Computation Theory, 17th International Sym- posium, volume 5699 ofLNCS, pages 310–322, 2009.

Références

Documents relatifs

In addition, we show how this procedure can be applied to weighted VPA , that is VPA in which transitions are also labelled by weights (such as visibly pushdown transducers

We introduce the following notations: let M ǫ be the identity matrix. This operator is naturally extended to integer matrices. For the hardness, we can proceed to a reduction from

Finally, we prove that the two classes gwnVPT and awnVPT en- joy good properties: they are closed under composition and type-checking is decidable against visibly pushdown

The pushdown module checking problem with imperfect infor- mation about the control states, but a visible pushdown store, is 2Exptime - complete for propositional

While functionality and equivalence are decidable, the class of visibly pushdown transductions, characterized by VPTs , is not closed under composition and the type checking problem

Visibly pushdown transducers (VPTs) form a subclass of pushdown transducers adequate for dealing with nested words and streaming evaluation, as the input nested word is pro- cessed

Visibly pushdown transducers form a reasonable subclass of pushdown transductions, but, contrarily to the class of finite state transducers, it is not closed under composition and

Using this bound, we prove that the two classes gwnVPT and awnVPT enjoy good properties: they are closed under composition and type-checking is decidable against visibly