• Aucun résultat trouvé

Trimming Visibly Pushdown Automata

N/A
N/A
Protected

Academic year: 2022

Partager "Trimming Visibly Pushdown Automata"

Copied!
19
0
0

Texte intégral

(1)

Trimming Visibly Pushdown Automata

Mathieu Caralp, Pierre-Alain Reynier, Jean-Marc Talbot

Laboratoire d’Informatique Fondamentale de Marseille UMR 7279, Aix-Marseille Universit´e & CNRS, France

Abstract

We study the problem of trimming visibly pushdown automata (VPA). We first describe a polynomial time proce- dure which, given a visibly pushdown automaton that accepts only well-nested words, returns an equivalent visibly pushdown automaton that is trimmed. We then show how this procedure can be lifted to the setting of arbitraryVPA.

Furthermore, we present a way of building, given aVPA, an equivalentVPAwhich is both deterministic and trimmed.

Last, our trimming procedures can be applied to weightedVPA.

Keywords: Visibly Pushdown Automata, Trimming

1. Introduction

Visibly pushdown automata (VPA) are a particular class of pushdown automata defined over an alphabet split into call, internal and return symbols [2, 3]1. InVPA, the stack behavior is driven by the input word: when reading a call symbol, a symbol is pushed onto the stack, for a return symbol, the top symbol of the stack is popped, and for an internal symbol, the stack remains unchanged.VPAhave been applied in research areas such as software verification (VPAallow one to model function calls and returns, thus avoiding the study of data flows along invalid paths) and XML documents processing (VPAcan be used to model properties over words satisfying a matching property between opening and closing tags).

Languages defined by visibly pushdown automata enjoy many properties of regular languages such as (effective) closure by Boolean operations and these languages can always be defined by a deterministic visibly pushdown au- tomaton. However,VPAdo not have a unique minimal form [1]. Instead of minimization, one may consider trimming as a way to deal with smaller automata. Trimming a finite state automaton amounts to removing useless states,i.e.

states that do not occur in some accepting computation of the automaton: every state of the automaton should be both reachable from an initial state, and co-reachable from a final state. This property is important from both a practical and a theoretical point of view. Indeed, most of the algorithmic operations performed on an automaton will only be relevant on the trimmed part of this automaton. Removing useless states may thus avoid the study of irrelevant paths in the automaton, and speed up the analysis. From a theoretical aspect, there are several results holding for automata provided they are trimmed. For instance, the boundedness of finite-state automata with multiplicities can be char- acterized by means of simple patterns for trimmed automata (see [14, 9]). Similarly, Choffrut introduced in [8] the twinning property to characterize sequentiality of (trimmed) finite-state transducers. This result was later extended to weighted finite-state automata in [6]. Both of these results have been extended to visibly pushdown automata and transducers in [7] and [10] respectively, requiring these objects to be trimmed.

While trimming finite state automata can be done easily in linear time by solving two reachability problems in the graph representing the automaton, the problem is much more involved forVPA(and for pushdown automata in general). Indeed, in this setting, the current state of a computation (called a configuration) is given by both a “control”

state and a stack content. A procedure has been presented in [12] for pushdown automata. It consists in computing, for

Email addresses:mathieu.caralp@lif.univ-mrs.fr(Mathieu Caralp),pierre-alain.reynier@lif.univ-mrs.fr (Pierre-Alain Reynier),jean-marc.talbot@lif.univ-mrs.fr(Jean-Marc Talbot)

1These automata were first introduced in [5] as “input-driven automata”.

(2)

each state, the regular language of stack contents that are both reachable and co-reachable, and using this information to constrain the behaviors of the pushdown automaton in order to trim it. This approach has however an exponential time complexity.

Contributions. In this work, we present a procedure for trimming visibly pushdown automata. The running time of this procedure is bounded by a polynomial in the size of the inputVPA. We first tackle the case ofVPArecognizing only so-calledwell-nestedwords,i.e. words which have no unmatched call or return symbols. This class ofVPAis called well-nestedVPA, and denoted bywnVPA. We actually present a construction for reducingwnVPA,i.eensuring that every run starting from an initial configuration can be completed into an accepting run. Symmetrically, we define a construction for co-reduction acting in a dual fashion. Combination of both constructions yields a trimming procedure.

In a second step, we address the general case. To do so, we present a construction which modifies aVPAin order to obtain awnVPA. This construction has to be reversible, in order to recover the original language, and to be compatible with the trimming procedure. In addition, we also design this construction in such a way that it allows to prove the following result: given aVPA, we can effectively build an equivalentVPAwhich is both deterministic and trimmed.

Moreover, when considering deterministic inputs, we prove that there is no trimming procedure running in polynomial time while preserving determinism. Finally, we show that our constructions can be applied to weightedVPA.

Organization of the paper. In Section 2 we introduce definitions. We address the case of well-nestedVPAin Section 3 and the general case in Section 4. We consider the issue of determinization in Section 5 and the extension to weighted VPAin Section 6. Last, a summary of our results is presented in Section 7.

Related models. VPAare tightly connected to several models:

Context-free grammars: it is well-known that pushdown automata are equivalent to context-free grammars. This observation yields the following procedure for trimming pushdown automata2. One can first translate the automaton into an equivalent context-free grammar, then eliminate from this grammar variables generating the empty language or not reachable from the start symbol, and third convert the resulting grammar into the pushdown automaton performing its top-down analysis. This construction has a polynomial time complexity but, in this form, it does not apply toVPA.

Indeed, the resulting pushdown automaton may not satisfy the condition of visibility as the third step may not always produce rules respecting the constraints on push and pop operations associated with call and return symbols.

Tree automata: by the standard interpretation of XML documents as unranked trees,VPAcan be understood as acceptors of unranked tree languages. It is shown in [2] that they actually do recognize precisely the set of regular (ranked) tree languages, using the encoding of so-calledstack-trees, which is similar to the first-child next-sibling encoding. Trimming ranked tree automata is standard (and can be performed in linear time), and one can wonder whether this approach could yield a polynomial time trimming procedure for VPA. Actually, going through tree automata would not ease the construction of a trimmedVPA. Indeed, trimming the first-child next-sibling encoding of awnVPA, and then translating back the result into awnVPAyields an automaton which is reduced but not trimmed (this is intuitively due to the fact that the first-child next-sibling encoding realizes a left-to-right traversal of the tree).

Moreover, this construction does not ensure a bijection between accepting runs, a property that is useful when moving to weightedVPA.

Nested word automata [3]: this model is equivalent to that ofVPA. One could thus rephrase our constructions in this context, and obtain the same results.

2. Definitions 2.1. Preliminaries

Words and well-nested words. Astructured alphabetΣis a finite set partitioned into three disjoint setsΣcrand Σι, denoting respectively thecall,returnandinternalalphabets. We denote byΣ˚the set of words overΣand byε the empty word.

The set ofwell-nestedwordsΣ˚wnis the smallest subset ofΣ˚such thatεPΣ˚wnand for allaPΣι,cPΣc,rPΣr and allu, vPΣ˚wn,auPΣ˚wnandcurvPΣ˚wn.

2We thank G´eraud S´enizergues for pointing us this construction.

(3)

Given a family of elementse1, e2, . . . , en, we denote byΠn

i“1eithe concatenatione1e2. . . en. The length of a worduis denoted by|u|. For a tuplee“ pf1, . . . , flq, we define for alliP t1, . . . , luthe projectionπipeqasfi. We extend this notion of projection to sequences asπin

k“1ekq “śn

k“1πipekq

Visibly pushdown automata (VPA). Visibly pushdown automata are a restriction of pushdown automata in which the stack behavior is imposed by the input word. On a call symbol, theVPApushes a symbol onto the stack, on a return symbol, it must pop the top symbol of the stack, and on an internal symbol, the stack remains unchanged. The only exception is that some return symbols may operate on the empty stack.

Definition 2.1 (Visibly pushdown automata). A visibly pushdown automaton(VPA) on finite words overΣ is a tupleA“ pQ, I, F,Γ, δqwhereQis a finite set of states,I ĎQis the set of initial states,F ĎQis the set of final states,Γis a finite stack alphabet andδ“δcrKrιis the (finite) transition relation withδcrKr andδιfour disjoint sets, withδcĎQˆΣcˆΓˆQ,δrĎQˆΣrˆΓˆQ,δrKĎQˆΣrˆ tKu ˆQ, andδι ĎQˆΣιˆQ.

For a transitiont“ pq, α, γ, q1qfromδcrorδrKort“ pq, α, q1qinδι, we denote bysourceptqandtargetptqthe statesqandq1respectively, and byletterptqthe symbolα.

Astack is a word from Γ˚ and we denote byKthe empty word on Γ. Aconfiguration κof aVPA is a pair pq, σq PQˆΓ˚.

Definition 2.2. A run ofAon a wordw“α1. . . αl˚over a finite (and possibly empty) sequence of transitions ptkq1ďkďlfrom a configurationpq, σqto a configurationpq1, σ1qis a finite sequence of symbols and configurations ρ“ pq0, σ0l

k“1kpqk, σkqqsuch thatpq, σq “ pq0, σ0q,pq1, σ1q “ pql, σlq, and, for each1ďkďl, there exists γksuch that either:

tk“ pq1, αk, γk, qkq Pδcandσk“σ1γk, or

tk“ pq1, αk, γk, qkq Pδrandσ1“σkγk, or

tk“ pq1, αk,K, qkq PδrKandσ1“σk“ K, or

tk“ pq1, αk, qkq Pδιandσk “σ1.

We denote byRunwpAqthe set of runs ofAover the wordwand byRunpAqthe set of runs ofA. Note that a run for the empty word is simply any configuration. We writeρ:pq, σqÝÑ pqw 1, σ1qwhen there exists a runρoverwfrom pq, σqtopq1, σ1q. We may omit the superscriptwwhen irrelevant. For this runρ, we denote byfirstpρqthe configura- tionpq, σqand bylastpρqthe configurationpq1, σ1q. Given two runsρi “κi0Πi

k“1ikikqqforiP t1,2u, we define the concatenationρ1ρ2of these runs, provided thatlastpρ1q “firstpρ2q, asρ1ρ2“κ10Π1

k“11kκ1k2

k“12kκ2kq.

Initial and final configurations are configurations of the formpq,KqwithqPIandpq, σqwithqPF respectively.

A run isinitialized if it starts in an initial configuration and it is accepting if it is initialized and ends in a final configuration. We denote byARunwpAqthe set of accepting runs ofAover the wordw. A word is accepted byAiff there exists an accepting run ofAon it. The language ofA, denoted byLpAq, is the set of words accepted byA.

A configurationκisreachable from a configurationκ1 if there exists a worduinΣ˚such thatκ1 ÝÑu κ; in this case we say also thatκ1isco-reachable fromκ. We say that a configurationκ1isreachableif there exists an initial configurationκisuch thatκ1is reachable fromκiandco-reachableif there exists an final configurationκfsuch that κ1is co-reachable fromκf.

Definition 2.3. AVPAA“ pQ, I, F,Γ, δqisdeterministicifIis a singleton and the following conditions hold:

• ifpp, c, γ, qq,pp, c, γ1, q1q Pδcthenγ“γ1andq“q1,

• ifpp, a, qq,pp, a, q1q Pδιorpp, r,K, qq,pp, r,K, q1q PδrKorpp, r, γ, qq,pp, r, γ, q1q Pδrtthenq“q1. A VPAAis said to bewell-nestedifLpAq ĎΣ˚wn. The class of well-nestedVPAis denoted bywnVPA.

Remark 2.1. IfAis well-nested then its final configurationspf, σq(withf a final state) are reachable only ifσ“ K.

(4)

2.2. (Co)-reduced and trimmed VPA

Definition 2.4. LetAbe aVPA. Let us consider the three following conditions : (1) every reachable configuration is co-reachable.

(2) every configuration co-reachable from some reachable and final configuration is reachable.

(3) for every stateq, there exists an accepting run going through a configurationpq, σq.

We say that the automatonAisreducedif it fulfills conditionsp1qandp3q, andco-reducedif it fulfills conditionsp2q andp3q. It istrimmedif it is both reduced and co-reduced. It isweakly reducedif it fulfills conditionp1qandweakly co-reducedif it fulfills conditionp2q.

κi κf

κ

ñ

κi κf

κ κ1i

Figure 1: Ifκis co-reachable from a final configuration κf,κf being reachable from an intial configurationκi, thenκis reachable from an initial configurationκ1i.

Observe in Figure 1 that conditionp2qlooks more compli- cated than the property stating that every co-reachable config- uration is reachable. Indeed, unlike in finite state-automata, the presence of a stack requires one to focus on reachable final configurations, and not to consider arbitrary final configuration.

However, we will see that forwnVPA, this condition is equiva- lent to the simpler one.

Observe that condition p3q simply corresponds to the re- moval of states that are useless, which can easily be done in polynomial time:

Proposition 2.1. ([4]) LetA“ pQ, I, F,Γ, δqbe aVPA. For any stateqPQ, one can build in polynomial time from Atwo finite state automataBq andCq over the alphabetΓsuch thatLpBqq “ tσ PΓ˚ | pq, σqis reachable inAu andLpCqq “ tσPΓ˚| pq, σqis co-reachable inAu.

The property of being co-reduced can be rephrased when consideringwnVPA:

Proposition 2.2. LetA “ pQ, I, F,Γ, δqbe awnVPAsuch that for all statef P F there exists an accepting run leading to the configurationpf,Kq. ThenAisweakly co-reducedif and only if every configuration co-reachable from some configurationpf,Kqwithf PFis reachable.

PROOF. By Remark 2.1 and the assumption onAin the proposition, the set of reachable final configurations ofAis

tpf,Kq |f PFu. l

3. Trimming well-nestedVPA

In this section, given awnVPAA, we present the construction of awnVPA trimwnpAq, which recognizes the same language, and in addition is trimmed. First we define the reducedwnVPA reducepAqwhich is equivalent toA. Next we will presentcoreducepAqand lastly we will combine these two procedures in order to producetrimwnpAq.

3.1. Construction ofwreducepAqandreducepAq

For awnVPAA, we describe the construction of the weakly reducedVPA wreducepAq. TheVPA reducepAqis simply obtained by removing useless states ofwreducepAqusing Proposition 2.1. In fact, ifLpBqq XLpCqq “ H thenqcan be removed because there is no accepting run going through a configurationpq, σqinA.

Consider awnVPAA“ pQ, I, F,Γ, δq. We defineWNas the settpp, qq PQˆQ| Dpp,Kq Ñ pq,Kq PRunpAqu.

This set can be computed in quadratic time as the least one satisfying

• tpp, pq |pPQu ĎWN,

• ifpp, p1q PWNandpp1, p2q PWN, thenpp, p2q PWN

• ifpp, qq PWN, andDpq, i, q1q Pδι, thenpp, q1q PWN

(5)

• ifpp, qq PWNandDpp1, c, γ, pq Pδc,pq, r, γ, q1q Pδr, thenpp1, q1q PWN

Definition 3.1. Given awnVPAA “ pQ, I, F,Γ, δq, we define thewnVPA wreducepAq “ pQ1, I1, F11, δ1qwith Q1“WN,I1“WNX pIˆFq,F1 “ tpf, fq |f PFu,Γ1“ΓˆQ, andδ1defined by its restrictions on call, return3 and internal symbols respectively (namelyδc1,δr1 andδι1):

δ1c

"

ppp, qq, c,pγ, qq,pp1, q1qq pp, qq,pp1, q1q PQ1,pp, c, γ, p1q Pδc

DrPΣr,DsPQ,pq1, r, γ, sq Pδrandps, qq PQ1

*

δ1r“ t ppq1, q1q, r,pγ, qq,pp, qqq | pp, qq PQ1,pq1, r, γ, pq Pδru

δ1ι“ t ppp, qq, a,pp1, qqq | pp, qq,pp1, qq PQ1,pp, a, p1q Pδιu

pp, σq

pp1, σ.γq pq1, σ.γq

ps, σq pq, σq c

w1

r

w2

Figure 2: Construction of call transitions.

Intuitively, the states (and the stack) ofwreducepAqextend those ofAwith an additional state ofA. This extra component is used bywreducepAq, when simulating a run of theVPAA, to store the target state that the run should reach to pop the symbol on top of the stack. The source states of return transitions are of the formpq, qqto ensure that the target state is reached when popping the top of the stack. To obtain a weakly reducedVPA, we require for the call transitions the existence of a matching return transition that allows one to reach the target state. This condition is depicted on Figure 2, and we give an example of the construction in Figure 3.

1 2 3

c{γ

r{γ c11

c22 r{γ2

r{γ1

1,1 2,2

3,3 2,3 c{γ,1

r{γ,1 r{γ2,3

r{γ1,2 c11,2

c22,3 r{γ1,3 c11,3

Figure 3: On the left aVPAA, on the rightreducepAq. There exists an initialized run ofAovercc2which cannot be completed into an accepting run. This run is no longer present inreducepAq.

For the rest of this subsection, we assume fixed somewnVPAA“ pQ, I, F,Γ, δqand denoteAwredthewnVPA wreducepAq.

TheVPAAwredsatisfies that :

Lemma 3.1. For allwPΣ˚wnand allρ1:ppp, qq,KqÝwÑ ppp1, q1q,Kq PRunpAwredq,we haveq“q1.

PROOF. By induction on the structure ofw; we show the property forw“εfor the base case. The induction step is done overw“cw1rw2andw“aw1 withw1, w2˚wn,c PΣc,r PΣrandaP Σι assuming the property on

w1, w2. l

We now relate accepting runs ofAand ofAwred: we define a mappingΦwredfromRunpAwredqtoRunpAq. For any runρ1“ ppp0, q0q, σ0ki“1ipppi, qiq, σiqqofAwred, we letΦwred1qbe the runpp0, π10qqΠki“1ippi, π1iqqq.

Lemma 3.2. For allwPΣ˚and all runsρPRunwpAwredq, we haveΦwredpρq PRunwpAq.

PROOF. By induction on the structure ofw. l

3As the language is well-nested, we do not consider return transitions on the empty stack.

(6)

The next two lemmas prove the injectivity and surjectivity ofΦwred.

Lemma 3.3. For allw P Σ˚wn, if there exists a runρ : pp,Kq ÝÑ pq,w KqinRunpAq, then there exists a runρ1 : ppp, qq,KqÝwÑ ppq, qq,Kq PRunpAwredqsuch thatΦwred1q “ρ.

PROOF. By induction on the structure ofwusing Lemma 3.2. l

Lemma 3.4. For allwPΣ˚wnand allρ11, ρ12PRunwpAwredq, ifΦwred11q “Φwred12qandlastpρ11q “lastpρ12q, then ρ11“ρ12.

PROOF. By induction on the structure ofwusing Lemma 3.2 and Lemma 3.1. l Theorem 3.1. LetAbe awnVPA, and letAwred“wreducepAqandAred“reducepAq.AwredandAredcan be built in polynomial time, and satisfy:

p1q for allwPΣ˚wn, there exist bijections betweenARunwpAwredqandARunwpAq, andARunwpAredqandARunwpAq and thus in particularLpAq “LpAwredq “LpAredq,

p2q Awredis weakly reduced, andAredis reduced.

PROOF. We prove that when restricted toARunwpAwredq, the mappingΦwredis bijective.

• Φwredis surjective: it is easy to verify that applying Lemma 3.3 on an accepting run ofAyields an accepting run ofAwred, which is in its inverse image by the mappingΦwred.

• Φwredis injective: this is an immediate corollary of Lemma 3.4 as last states of accepting runs ofAwredare of the formpf, fq. Thus, if two accepting runsρ11, ρ12have the same image byΦwred, they must verifylastpρ11q “ lastpρ12q.

We now prove thatwreducepAqis weakly reduced that is, that any reachable configuration ofAwred is also co- reachable.

Letκ“ ppp, qq, σqbe a reachable configuration ofAwred. There exists a runρofAwredof the formppi, fq,Kq Ñκ starting in an initial configurationppi, fq,Kq. We show by induction on the size of the stackσthat we can reach a final configuration fromκ.

If|σ| “0, by Lemma 3.1, we obtainq“f. In particular, this impliesqPF. Sincepp, qq PWN, there is a run pp,Kq Ñ pq,KqinA, thus by Lemma 3.3 we have a runppp, qq,Kq Ñ ppq, qq,KqofAwred. This concludes this case as by the above observation (qPF), we havepq, qq PF1.

We now assume for the induction that the property holds when|σ| ď n and we consider a stack σsuch that

|σ| “ n`1. Let denote by pγ, q1qthe top symbol of σ, writeσ “ σ1.pγ, q1q, and consider the first position in the runρthat pushes this symbol onto the stack. We denote bycthe associated call. More precisely, there exists a unique decomposition ofρasρ : ppi, fq,Kq Ñ ppp1, q1q, σ1q ÝÑ pppc 2, q2q, σq Ñ ppp, qq, σqsuch that the run from ppp2, q2q, σqtoppp, qq, σqis associated with a well-nested word. By Lemma 3.1, we obtainq2 “q. Considering the call transition associated withc, and by definition ofδc1, there exists a return transitionppq, qq, r,pγ, q1q,ps, q1qq Pδ1r for some letterrPΣr. In addition, aspp, qq PWN, there is a runpp,Kq Ñ pq,KqinA, and thus by Lemma 3.3 we have a runppp, qq,Kq Ñ ppq, qq,KqinAwred, and thus a runppp, qq, σq Ñ ppq, qq, σqinAwred.

As the top symbol ofσispγ, q1q, the above return transition can be used to reach configurationpps, q1q, σ1qwhose

height isn. The result follows by induction hypothesis. l

An important feature of the constructionreduceis that it preserves the co-reduction:

Proposition 3.1. LetAbe awnVPA. IfAis co-reduced, thenreducepAqis co-reduced as well.

PROOF. We will prove that ifAis co-reduced, thenAwred“wreducepAqis co-reduced as well. SincereducepAqis obtained by removing all the useless states ofAwred, we can conclude thatreducepAqis also co-reduced.

Letκ“ ppp, qq, σqandκi “ pppi, qiq,Kqbe two configurations of Awredsuch that ppi, qiqis an initial state of Awredand there exists inAwredtwo runsρ:κÑ ppf, fq, σ1qandκi Ñ ppf, fq, σ1qwheref is a final state ofA. As

(7)

Awredis awnVPAand by Remark 2.1, we haveσ1“ K. We show by induction on the size of the stackσthatκcan be reached from an initial configuration.

If|σ| “ 0, by Lemma 3.1, q “ f. By construction of the setWN,pp,Kq Ñ pf,Kqis a run ofA. SinceAis co-reduced, there exists a runpi,Kq Ñ pp,KqwithiPI. Thus by Lemmas 3.3 and 3.1ppi, fq,Kq Ñ ppp, fq,Kq Ñ ppf, fq,Kqis a run ofAwred.

We now assume for the induction that the property holds when|σ| ď n and we consider a stack σsuch that

|σ| “n`1. Let us consider the first position in the runρthat pops the top symbol from the stack. We denote byr the associated return. More precisely, there exists a unique decomposition ofρas follows:

ppp, qq, σqÝÑ ppqw 2, q2q, σqÝÑ pppr 1, q1q, σ1qÝÑ ppf, fw1 q,Kq withwPΣ˚wnandσ“σ1pγ, q1qforγPΓ By Lemma 3.1,q2“q. By Lemma 3.4, the projection ofρis a run inA:

pp,σq¯ ÝwÑ pq,σq¯ ÝÑ ppr 1,¯σ1qÝÑ pf,w1 Kq PRunpAq whereσ¯“π1pσqandσ¯1“π11q

SinceAis co-reduced, the configurationpp,σq¯ is reachable from an initial configuration ofAby some runρ1. We decomposeρ1so as to exhibit the call transition that pushed the top symbol ofσ:¯

ρ1:pi,Kq Ñ pp2,σ¯1qÝÝÑ ps,c,γ σq¯ ÝÝÑ pp,w2 σq P¯ RunpAq wherecPΣcandw2˚wn By Lemmas 3.3 and 3.1, we deduce:

pps, qq,KqÝÝÑ ppp, qq,w2 KqÝwÑ ppq, qq,Kq PRunpAwredq and thus

pps, qq, σqÝÝÑ ppp, qq, σqw2 ÝwÑ ppq, qq, σq PRunpAwredq

Consider now the call transition oncused in the runρ1. It is of the formt “ pp2, c, γ, sq. By the existence of the above run inAwred, we can deduce the existence of the transitionppp2, q1q, c,pγ, q1q,ps, qqqinδ1c. We can thus extend the above run ofAwredas follows:

ppp2, q1q, σ1qÝÑ pps, qq, σqc ÝÝÑ ppp, qq, σqw2 ÝwÑ ppq, qq, σqÝÝÑ ppf, fq,rw1 Kq PRunpAwredq

and the result follows by induction hypothesis. l

3.2. Construction ofcoreducepAqandwcoreducepAq

For awnVPAA, we now describe the construction of theVPA wcoreducepAq, which is weakly co-reduced. This construction can be seen as the application ofwreduceon the dual ofAwhich is obtained by swapping call and return symbols and transitions, swapping initial and final states and swapping target and source of transitions. TheVPA coreducepAqis then obtained similarly asreducepAqby removing useless states ofwcoreducepAq.

Definition 3.2. Given awnVPAA“ pQ, I, F,Γ, δq, we define thewnVPA wcoreducepAq “ pQ1, I1, F11, δ1qwith Q1“WN,I1 “ tpi, iq |iPIu,F1“WNX pIˆFq,Γ1 “ΓˆQ, andδ1defined by its restrictions on call, return and internal symbols respectively (namelyδc1,δr1 andδι1):

δ1c“ tppp, qq, c,pγ, pq,pq1, q1qq | pp, qq PQ1,pq, c, γ, q1q Pδcu

δ1r

"

ppp, qq, r,pγ, p1q,pp1, q1qq pp, qq,pp1, q1q PQ1,pq, r, γ, q1q Pδr,

DcPΣc,DsPQ,ps, c, γ, pq Pδcandpp1, sq PQ1

*

δ1ι“ tppp, qq, a,pp, q1qq | pp, qq,pp, q1q PQ1,pq, a, q1q Pδιu

(8)

As we did forwreduce, the states (and the stack) ofwreducepAqextend those ofAwith an additional state of A. Here this information is used to store the stateqreached when the current top symbol of the stack was pushed.

To obtain a weakly co-reducedVPAwe require for the return transitions the existence of a matching call transition that allows one to go through the source stateq. Similarly aswreduceandreduce, the constructionswcoreduceand coreducehave the following properties:

Theorem 3.2. LetAbe awnVPA, and letAwcor “wcoreducepAqandAcor “coreducepAq.Awcor andAcorcan be built in polynomial time, and satisfy:

p1q for allwPΣ˚there exist bijections betweenARunwpAwcorqandARunwpAq, andARunwpAcorqandARunwpAq and thus in particularLpAq “LpAwcorq “LpAcorq,

p2q Awcoris weakly co-reduced, andAcoris co-reduced.

To prove Theorem 3.2, we proceed the same way as in the proof of Theorem 3.1. Thus we define a mappingΦwcor fromRunpAwcorqtoRunpAq. For any runρ1 “ ppp0, q0q, σ0k

i“1ipppi, qiq, σiqqofAwcor, we letΦwcor1qbe the runpq0, π10qqΠk

i“1ipqi, π1iqqq.

PROOF. Since wcoreduce can be seen as the dual of wreduce, we can prove that Φwcor is a bijection between ARunwpAwcorqandARunwpAqby following the lines of the proof of propertyp1qof Theorem 3.1.

Due to Proposition 2.2, forwnVPA, being co-reduced is the exact dual of being reduced. Therefore, the proof of propertyp2qcan be done by following the lines of the proof of propertyp2qof Theorem 3.1. l

The co-reduction construction preserves two importants properties:

Proposition 3.2. LetAbe a reducedVPA, thencoreducepAqis also reduced.

PROOF. The proof of this proposition follows the lines of that of Proposition 3.1. l Proposition 3.3. LetAbe a deterministicVPA, thencoreducepAqis also deterministic.

PROOF. The proof of this proposition is done by inspecting the transitions ofAwcor. l 3.3. Trimming awnVPA

We define the constructiontrimwn astrimwn “ coreduce˝reduce. Proposition 3.2 entails that the construction coreducepreserves the reduction, and thus by Theorems 3.1 and 3.2 we obtain the following result:

Theorem 3.3. LetAbe awnVPA, andAtrim “ trimwnpAq. Atrim is trimmed and can be built in polynomial time.

Furthermore, for allwPΣ˚, there exists a bijection betweenARunwpAqandARunwpAtrimq, and thus in particular LpAq “LpAtrimq.

4. TrimmingVPA

We now present a construction which turns aVPAAinto awnVPAover a special alphabet. In a second step, we trim the resultingVPAusing the procedure described in Section 3 forwnVPA. Last, from the resultingwnVPAwe construct aVPAover the original alphabet recognizing the languageLpAqand which is still trimmed. It is not obvious to propose procedures for transforming aVPAintownVPA, and back, which are compatible with the notion of being trimmed.

(9)

4.1. FromVPAtownVPA...

Words fromΣ˚differ from well-nested words as they admit unmatched returns and calls. We address these issues by extending the alphabetΣand by modyfing words fromΣ˚: some new symbols are added and used to complete the unmatched calls by adding new return symbols and to replace unmatched returns by new internal symbols.

LetΣ“Σcrιbe a structured alphabet. We introduce the structured alphabetΣext“Σext

cext

rext

ι

defined byΣext

c “Σcext

r “ΣrZ tru, and¯ Σext

ι “ΣιZ tar|rPΣru, wherer¯andtar|rPΣruare fresh symbols.

We define inductively the mappingΩwhich transforms a word overΣinto a word overΣext as follows, given aPΣι,rPΣr,cPΣcandnPN:

• Ωpǫ, nq “ǫ, Ωpaw, nq “aΩpw, nq,

• Ωprw, nq “rΩpw, n´1qifną0, Ωprw,0q “arΩpw,0q,

• Ωpcw, nq “

"

cw1rΩpw2, nq ifDw1˚wn,w2˚andrPΣrsuch thatw“w1rw2, cΩpw, n`1q¯r otherwise.

For example, Ωprrccar,1q “ rarccarr. We denote by¯ extpwq the wordΩpw,0q. Intuitively, this mapping replaces every unmatched returnrby the internal symbolarand adds a suffix of the formr¯˚in order to match every unmatched call. We can prove by induction on the structure ofwthatextpwqis a well-nested word over the alphabet Σext.

Given a wordwand a naturaln,Ωpw, nqis obtained fromwby replacing every unmatched returnrof height less thannby the internal symbolarand adds a suffix of the formr¯˚in order to match every unmatched call. We extend the functionsΩandextto languages in the obvious way.

We define also a variant ofΩwhich does not add the suffixr¯˚, we call this mappingΩι: Ωιpw, nq “w1such thatΩpw, nq “w1w2withw1P pΣextzt¯ruq˚andw2Pr¯˚ We also defineextιpwqasΩιpw,0q. We extend the functionΩιto runs in the following way:

ι0Πlk“1kκkq, nq “κ0Πlk“11kκkq withΩι1. . . αl, nq “α11. . . α1l

LetAbe aVPA, we now present the constructionextendwhich turns aVPAoverΣinto awnVPAoverΣext. Intuitively, the construction adds a suffix to theVPAwhich reads words fromr¯` and replaces the returns on empty stack by internals, thus implementing the mappingext. To achieve this, theVPAmust have some specific properties, introduced in the next definition:

Definition 4.1. LetA “ pQ, I, F,Γ, δqbe aVPA. ThenAisstack-compliantif there exist partitions ofQasQ “ QKZQMandΓasΓKMsuch that:

1. For all initialized run ofAleading to a configurationpp, σq, σ“ KiffpPQK, 2. For all initialized run ofAleading to a configurationpp, σq, σP tKu Y pΓK¨Γ˚

Mq, 3. For alltPδr,sourceptq RF.

We can now present the constructionextend, which operates on stack-compliantVPA. We will present in Subsec- tion 4.3 the constructionscompliantthat allows to build stack-compliantVPA.

Definition 4.2. LetA“ pQ, I, F,Γ, δqbe a stack-compliantVPAover the alphabetΣwith partitionsQ“QKZQM and Γ “ ΓKM. We construct extendpAq “ pQ1, I1, F11, δ1qas thewnVPA over the alphabetΣext where:

Q1“QY tf¯K,f¯Mu,I1“I,F1“ pFXQKq Y tf¯Ku,Γ1“Γ, andδ1is given by:

δ1c“δc and δK1r “ H

δ1r“δrY tpp,r, γ,¯ f¯τq |τ P tK,Mu, pPFXQM, γ PΓτu Y tpf¯M,r, γ,¯ f¯τq |τ P tK,Mu, γ PΓτu

δ1ι“διY tpp, ar, qq | pp, r,K, qq PδKr, pPQKu

(10)

Intuitively, extendpAqhas two components: the first one, composed of the states of A, can read words over pΣextztruq¯ ˚and replaces every unmatched return by internal symbols, whereas the second one, composed of the two added statestf¯K,f¯Mu, reads words of the formr¯`. This intuition is formalized for an arbitraryVPAover the alphabet Σextin the next definition:

Definition 4.3. LetΣbe an alphabet andA“ pQ, I, F,Γ, δqbe aVPAover the alphabetΣext. We define two subsets ofQas follows:

trappAq “ tqPQ| Dp,pp,¯r, γ, qq Pδru

borderpAq “ tpRtrappAq | DtPδsuch thatsourceptq “pandtargetptq PtrappAqu Elements ofborderpAqare calledborder statesofA.

Border states are the only ones that allow to reach a state intrappAqfrom a state not intrappAq. One can verify that in the case of theVPA extendpAq, we havetrappextendpAqq “ tf¯M,f¯KuandborderpextendpAqq “FXQM. We give an example of these properties in Figure 4.

1 2 3

4 5 6

c{γ c{γ

c{γ1 r{γ r{γ1 r{γ1 r{K

c{γ1 c{γ1

1 2 3 f¯M

f¯K

4 5 6

c{γ c{γ

c{γ1 r{γ r{γ1 r{γ1

¯r{γ1

¯r{γ

ar ¯r{γ

c{γ1 c{γ1

r{γ¯ 1

Figure 4: On the left, theVPAA“ pQ, I, F,Γ, δq, on the right thewnVPAAext extendpAq. The dashed parts are the components ofA modified byextend.Ais stack-compliant forQQKZQMandΓΓKZΓMwhereQK“ t1,4u,QM“ t2,3,5,6u,ΓK“ tγuandΓM 1u. We will see later thatAis produced by the constructionscompliant. Moreover we haveborderpAextq “ t3uandtrappAextq “ tf¯M,f¯Ku.

LetA“ pQ, I, F,Γ, δqbe a stack-compliantVPAwith partitionsQ“QKZQMandΓ“ΓKM. We define Aext“extendpAqand will prove thatLpAextq “extpLpAqq.

Lemma 4.1. Letw“α1. . . αk P Σ˚ be a word andρ “κ0Π

k“1kkqq, withκia configuration ofAfor alli, thenρis an initialized run ofAoverwif and only ifextιpρqis an initialized run ofAextoverextιpwq.

PROOF. By definition,extιpwqis obtained fromwby replacing every unmatched return by an internal symbol. The constructionextendimplements correctly this transformation thanks to pointp1qof definition of stack-compliance.l Lemma 4.2. Letρbe an initialized run ofAextover some wordwleading to configuration pp, σqsuch thatpis a border state ofAext, then there exists exactly one runρ1over¯r|σ|such thatρρ1is an accepting run ofAext.

PROOF. By construction ofAext, the wordwdoes contain any occurrence of the letterr. Thus, by Lemma 4.1, there¯ exists a runρ1ofAsuch thatρ“extι1q. As observed above, we haveborderpAextq “ FXQM. Thus by point p2qof definition of stack-compliance,σPΓK¨Γ˚

M, and by construction there exists a unique run ofAextwhich leads

fromptof¯Koverr¯|σ|and pops all the symbols of the stack. l

Theorem 4.1. Letw P Σ˚ be a word, there exists a bijection betweenARunwpAqandARunextpwqpAextq, and thus LpAextq “extpLpAqq.

PROOF. First suppose thatwis a word without unmatched calls, thenextιpwq “ extpwq. Letρbe an accepting run ofAoverwleading to configurationpp, σq. extιpwq “extpwqentailsσ“ Kand thus, by pointp1qof the definition of stack-compliance, we havepPFXQK. The result follows from Lemma 4.1.

Otherwise,wis a word with some unmatched calls. We define the setERunwasERunw“ tρPRunextιpwqpAextq | ρis initialized and ends in a border stateu.

As border states of Aext arise from accepting states of A and by Lemma 4.1, for all runρ P RunwpAq, ρ P ARunwpAqif and only ifextιpρq PERunw. The result follows from Lemma 4.2. l

(11)

4.2. ... And back.

We will define the converse of the functionextend, named retract, which performs the last step of the proce- dure. However, we have to identify the trap amongst the states of thewnVPAin order to remove it and recover the original language. This transformation is not always possible, and thus we introduce a sufficient condition, named retractability, allowing to apply theretractprocedure:

Definition 4.4. LetΣbe an alphabet andA “ pQ, I, F,Γ, δqbe aVPAover the alphabetΣext. Let us consider the following conditions:

p1q There exists aVPABoverΣsuch thatLpAq “extpLpBqq, p2q We havetrappAq XI“ H,

p3q For all transitionstinδ,letterptq “r¯if and only iftargetptq PtrappAq, p4q For all transitionstinδsuch thatsourceptq PtrappAq,letterptq “r,¯

p5q For each initialized run ofA, which ends in a border state there exists exactly one runρ1over¯r`such thatρρ1is an accepting run.

p6q For all transitionstPδrsuch thatsourceptq PborderpAq,letterptq “r.¯

We say thatAisretractableif it fulfills conditionsp1q, . . . ,p5qandstrongly retractableif it is retractable and fulfills conditionp6q.

Retractability properties warrant thatretractcan be applied. In the sequel we will prove that our different con- structions preserve the retractability property and thus preserve the trap: for example the trap of thewnVPAproduced bywreduce˝extendis of the formtpf¯K,f¯Kq,pf¯M,f¯Mqu. Note that we need the strong retractability property because thereduceconstruction does not preserve the retractability. We first show that the constructionextendensures the strong retractability:

Theorem 4.2. LetAbe a stack-compliantVPA, thenextendpAqis strongly retractable.

PROOF. Propertyp1qis a consequence of Theorem 4.1. Propertiesp2q,p3q,p4qare consequences of the construction, propertyp5qis a consequence of Lemma 4.2 and propertyp6qis a consequence of pointp3qof definition of stack-

compliance. l

We now define the constructionretract:

Definition 4.5. LetA“ pQ, I, F,Γ, δqbe a retractablewnVPAover the alphabetΣext, we define theVPA retractpAq “ pQ1, I1, F1,Γ, δ1q over the alphabet Σ with Q1 “ QztrappAq, I1 “ I, F1 “ pFztrappAqq YborderpAq, and the set of transition rules δ1 “ δ1cr1r1Kι1 is defined by δc1 “ δc, δ1r “ tt P δr | letterptq ‰ ¯ru, δr1K“ tpp, r,K, qq | pp, ar, qq Pδιu, andδι1 “ ttPδι |letterptq PΣιu.

This construction works as follows: it replaces all the internal transitions overarby return transitions on empty stack over symbolr, and removes the return transitions overr. Note that the final states of¯ retractpAqare the final states ofAwhich are not intrappAqand the border states ofA.

Lemma 4.3. Letw“α1. . . αk˚be a word andρ“κ0Π

k“1kkqq, withκia configuration ofretractpAqfor alli, starting in configurationκ0“ pp, σq, thenρPRunwpretractpAqqif and only ifιpρ,|σ|q PRunιpw,|σ|qpAq.

PROOF. First observe thatwPΣ˚entails, by pointsp2qandp3qof the definition of retractability, that configurations κi “ ppi, σiqverify the propertypiRtrappAqfor alli. AsΩιis applied onρwith|σ|as second argument, it replaces the unmatched returns ofwthat are taken inρwith an empty stack by internal symbols. The lemma is then proved by

an induction on the length ofw. l

(12)

Theorem 4.3. Let A be a retractableVPA on Σext then for any word w P Σ˚, there exists a bijection between ARunwpretractpAqqandARunextpwqpAq, and thus in particularLpAq “extpLpretractpAqqq.

PROOF. LetwP Σ˚be a word and distinguish two cases. Ifwis a word without unmatched calls, thenextpwq “ extιpwq. By Lemma 4.3 and pointp2qof the definition of retractability,extinduces a bijection between the set of initialized runs ofretractpAqoverwand the set of initialized runs ofAoverextpwq. In addition, an initialized runρ ofretractpAqoverwis accepting iffextpρqis accepting inA. Indeed, aswhas no unmatched calls, the configuration pp, σqreached byρverifiesσ“ K, and thuspRborderpAqby pointp5qof the definition of retractable. Thenpis a final state ofretractpAqiffpis a final state ofA. Otherwise,wis a word with some unmatched calls. We define the setRRunwasRRunw“ tρPRunextιpwqpAq |ρis initialized and ends in a border stateu.

As in the previous case, we can show by pointp2qof the definition of retractability and by Lemma 4.3 thatextι induces a bijection betweenARunwpretractpAqqandRRunw. Thus by pointp5qof the definition of retractable, we have a bijection betweenARunwpretractpAqqandARunextpwqpAq.

Last, by point p1qof the definition of retractability, any word accepted by Ais of the form extpwq for some wPΣ˚, and thus the previous bijections implyLpAq “extpLpretractpAqqq. l

Our constructionretractpreserves the trim property:

Proposition 4.1. LetAbe a retractableVPAonΣext, then ifAis trimmed, so isretractpAq.

PROOF. LetAret“retractpAq. For the reduced part, let us consider an initialized runρ: pp,KqÝÑ pq, σqw ofAret

overw. By Lemma 4.3 ρˆ “ extιpρqis a run of Aover wˆ “ extιpwq. Observe that ρˆis initialized. Since Ais reduced, there exists a runρˆ1overw1such thatρˆρˆ1is an accepting run ofA. By construction we can decomposew1 asw1“w1w2withw1˚andw2P¯r˚andρˆ1asρˆ1:pq, σqÝÝÑ pqw1 1, σ1qoverw1andρˆ2:pq1, σ1qÝÝÑ ppw2 1,Kqover w2. Ifw2 “ε, thenσ1 “ Kand by constructionq1is a final state ofAret. By Lemma 4.3, there exists a runρ1such thatρˆ1 “Ωpρ1,|σ|qandρρ1is an accepting run ofAret. Ifw2 ‰ε, thenq1 PborderAand soq1is a final state of Aret. Again, by Lemma 4.3 there exists a runρ1such thatρˆ1“Ωpρ1,|σ|qandρρ1is an accepting run ofAret.

For the co-reduced part, let us consider two runsρ:pp, σqÝwÑ pq, σ1qandρ1:pi,KqÝÑ pq, σw1 1qofAretwithqa final state andian initial state. We distinguish two cases:

• Ifσ1 “ K, then by pointp5qof the definition of retractability, stateqcannot be inborderpAq. By definition of Aret, this implies thatqis a final state ofA. By Lemma 4.3,ρˆ“Ωιpρ,|σ|qis a run ofAoverwˆ “Ωιpw,|σ|q, then since Aas awnVPAand is co-reduced, there exists a runρˆ2 ofAover a word wˆ2 such thatρˆ2ρˆis an accepting run ofAoverwˆ2w. Thus by Lemma 4.3 there exists a runˆ ρ2 ofAretsuch thatρˆ2 “extι2qover w2withwˆ2“extpw2qandρ2ρis an accepting run ofAretoverw2w.

• Ifσ1 ‰ K, then by construction,qPborderpAq. By Lemma 4.3,ρˆ“Ωιpρ,|σ|qandρˆ1 “extι1qare runs of AoverΩιpw,|σ|qandextιpw1qrespectively. Observe thatρˆ1is initialized. Then by pointp5qof the definition of retractability there exists exactly one runρ¯overr¯`such thatρˆ1ρ¯is an accepting run ofAand soρˆρ¯is also a run ofA. SinceAis co-reduced there exists a runρˆ2ofAover a wordwˆ2such thatρˆ2ρˆρ¯is an accepting run of A. By Lemma 4.3, there exists a runρ2ofAretsuch thatρˆ2“extι2qoverw2withwˆ2 “extpw2q. Thus by

Lemma 4.3,ρ2ρis an accepting run ofAretoverw2w. l

We prove that the constructionsreducepreserves the strong retractability andcoreducepreserves the retractability:

Proposition 4.2. LetAbe a strongly retractableVPA, thenAred“reducepAqis strongly retractable.

PROOF. We letA“ pQ, I, F,Γ, δqandAred“ pQ1, I1, F11, δ1q. First note that by construction:

For allpp, qq PQ1, ifpp, qq PtrappAredqthenpPtrappAq (1a) For allpp, qq PQ1, ifpp, qq PborderpAredqthenpPborderpAq (1b) Equation (1a) is a consequence of the constructionreduce. Concerning Equation (1b), to prove thatpP borderpAq, the fact thatpR trappAqfollows from pointp3qof Definition 2.4 applied onpp, qq, and the fact that there exists a transition on¯rfromptotrappAqfollows from the constructionreduce.

Références

Documents relatifs

Although the collection of increasingly large perfect numbers continues unabated to this day, no odd perfect number has even been found. Worse still, no proof of their non-existence

Such connections are harder to obtain for transducers, but important results have been obtained recently for word-to-word transformations, showing that the three following models

We first describe a polynomial time procedure which, given a visibly pushdown automaton that accepts only well-nested words, returns an equivalent visibly pushdown automaton that

Ne croyez pas que le simple fait d'afficher un livre sur Google Recherche de Livres signifie que celui-ci peut etre utilise de quelque facon que ce soit dans le monde entier..

2.4 Detecting two faults is hard for our test in the worst case The test of Section 2.1 works to detect a one-gate error, because if only one gate is affected then there is a

We prove that arbitrary actions of compact groups on finite dimensional C ∗ -algebras are equivariantly semiprojec- tive, that quasifree actions of compact groups on the Cuntz

La plénitude dans le ciel, ou cercle de Gwenved ; et sans ces trois nécessités, nul ne peut être excepté Dieu. îS Trois sortes de nécessités dans

ERRATUM ON “ENTROPY-ENERGY INEQUALITIES AND IMPROVED CONVERGENCE RATES FOR NONLINEAR..