COMUNITAT UNIVERSITÀRIA
9.3 SERVEI DE CÀLCUL I INFORMATITZACIÓ
A nested-word automaton is calledbottom-upif it resets its state along the call transition: ifδc(q,a) = (q0,p)thenq0 = q0. The well-matched nested word sandwiched between
a call and its matching return is processed by a bottom-up NWA independent of the outer context. It is known that bottom-up NWAs are as expressive as NWAs over well- matched nested words [AM09]. We show that a similar result holds for transducers
also: there is no loss of expressiveness if the STT is disallowed to propagate information at a call to the linear successor. Notice that STTs reinitialize all the variables at every call. An STTSis said to be abottom-up STTif for every stateq∈ Qand symbola ∈ Σ, ifδc(q,a) = (q0,p)thenq0 = q0, and for every variablex∈ X,ρc(q,a,x) = x.
Theorem 5.7(Bottom-up STTs). Every STT-definable transduction is definable by a bottom-
up STT.
Proof. Let S = (Q,q0,P,X,η,F,δ,ρ) be an STT. We construct an equivalent bottom-
up STTS0 = (Q0,q0
0,P0,X0,η0,F0,δ0,ρ0). Intuitively,S0 delays the application of a call
transition of S to the corresponding return. This is done by computing a summary of all possible executions of S on the subword between a call and the corresponding matching return. At the return this summary can be combined with the information stored on the stack to continue the summarization.
Auxiliary notions. Given a nested wordw= a1a2. . .an, for each position 1≤ i ≤n, let WMS(w,i)be the longest well-matched subword aj. . .ai ending at positioni. For- mally, given a well-matched nested wordw = a1a2. . .an, we define WMS(w,i)as fol- lows:
• WMS(w, 0) =ε;
• ifai is internal, thenWMS(w,i) =WMS(w,i−1)ai; • ifai is a call, thenWMS(w,i) =ε;
• ifai is a return with matching callaj, thenWMS(w,i) =WMS(w,j−1)ajaj+1. . .ai. The nested wordWMS(w,i)is always well-matched, and represents the subword from the innermost unmatched call position up to position i. For a well-matched nested word w of length n, WMS(w,n) equals w. Moreover let LC(w,i)denote the last un-
matched call at positioni:
• LC(w, 0) =⊥is undefined;
• ifai is internal, thenLC(w,i) =LC(w,i−1); • ifai is a call, thenLC(w,i) =i;
State components and invariants. Each state f ofQ0is a function fromQtoQ. After reading the i-th symbol of w, S0 is in state f such that f(q) = q0 iff when Sprocesses WMS(w,i)starting in stateq, it reaches the stateq0. The initial state ofS0 is the identity function f0mapping each stateq∈ Qto itself. A stack state inP0is a pair(f,a)where
f is a function mappingQtoQandais a symbol inΣ.
Next, we define the transition relationδ0. When reading an internal symbola, starting
in state f,S0goes to state f0 such that for eachq∈ Q, f0(q) =δi(f(q),a). When reading a call symbolha, starting in state f,S0stores f on the stack along with the symbolaand goes to state f0. When reading a return symbolbi, starting in state f, and with(f0,a)
on top of the stack,S0goes to state f00defined as: for eachq∈ Q, if f0(q) =q1(the state reached bySwhen readingWMS(w,LC(w,i−1))starting inq),δc(q1,ha) = (q2,p), and
f(q2) = q3 (the state reached by S when reading WMS(w,i−1,) starting inq2), then
f00(q) =δr(q3,p,b).
Variable updates and invariants. We now explain howS0 achieves the summariza- tion of the variable updates of S. For each variablex ∈ X and stateq ∈ Q, X0 con- tains a variable xq. After reading the i-th symbol, xq contains the value of x com- puted by S, when reading WMS(w,i) starting in state q. Given an assignment α ∈ A(X,X,Σ)∪ A(X,X∪Xp,Σ), a state q ∈ Q, and a set of variablesY ⊆ X∪Xp, we define SUBq,Y(α) to be the assignment α0 ∈ A(X0,X0,Σ)∪ A(X0,X0 ∪X0p,Σ), where X0 = (X\Y)∪Y0 with Y0 = {yq | y ∈ Y}, and each variable y ∈ Y is replaced by
yq∈Y0.
Initially, and upon every call, each variablexqis assigned the value ? orε, ifxis a type- 1 or type-0 variable respectively. We usee{x/x0}to denote the expressione in which every variablexis replaced with the variablex0. When processing the input symbola, starting in state f, each variablexqis updated as follows:
a is internal: if f(q) = q0, then xq := SUBq,X(ρi(q0,a,x)) is the result of applying the variable update function ofSin stateq0where each variablex∈ Xis renamed to
xq;
a is a call: sinceS0 is bottom-up, every variable is simply stored on the stack, and the
update function at the call is delayed to the corresponding return,xq:= xq;
a =biis a return: if (f0,c)is the state popped from the stack, f0(q) = q1, δc(q1,c) =
(q2,p), and f(q2) =q3, then
is the result of applying the call variable update function in stateq1, followed by
the return variable update function ofS in stateq0 where each variablex ∈ Xis renamed toxq2, and each variablex∈ Xpis renamed toxq.
Output function. The output function F0 of S0 is defined as follows: for each state
f ∈ Q0,F0(f) = SUBq0,X(F(f(q0)))is the result of applying the output function ofSin state f(q0)where each variablex∈ Xis renamed toxq0.
Conflict relation. The conflict relationη0contains the following rules:
1. Variable summarizing different states are in conflict: for all x,y ∈ X, for allq 6= q0 ∈ Q,η0(xq,yq0);
2. Variables that conflict inSalso conflict inS0, for every possible summary: for all
q∈Q, for allx,y∈ X, ifη(x,y), thenη0(xq,yq).
Next, we prove thatη0is consistent with the update functionρ0. We assume the current
statef ∈ Q0to be fixed. We first show that two conflicting variables never appear in the same right hand side. Each assignment ofS0has the formSUBq,Y(ρ(q,a,x)). Therefore if no variables ofSare conflicting inρ(q,a,x)with respect toη, no variables are conflicting
in SUBq(ρ(q,a,x))with respect toη0. Secondly, we show that for eachx,y,x0,y0 ∈ X0, if η0(x,y)holds, x appears inρ0(q,x0), andy appears inρ0(q,y0), then η(x0,y0) holds. From the definition ofη0, we have that two variables inX0 can conflict for one of the
following two reasons.
• Two variablesxq1,yq01 ∈ X0such thatq1 6= q01appear in two different assignments
towq2 andzq20 respectively, for somew,z ∈ Xandq2,q02 ∈ Q. We need to show
η0(wq2,zq02)and we have two possibilities.
– If q2 = q20, assuming the current symbol is internal, we have that wq2 and
zq2 are updated toSUBq2(ρi(f(q2),a,w))andSUBq2(ρi(f(q2),a,z)), where all
variables are labeled withq2. This violates the assumption thatq1 6= q01. If
the current symbol is a call or a return a similar reasoning holds. – Ifq26=q02,η0(wq2,zq02)follows from the first rule ofη0.
• Two variablesxq1,yq1 ∈X0, such thatη(x,y), appear in two different assignments
towq2 andzq02 respectively, for somew,z ∈ X, andq2,q02 ∈ Q. We need to show
η0(wq2,zq02). Ifq2 = q02,η0(wq2,zq02)follows from the second rule ofη0. Ifq2 6= q02,
η0(wq2,zq02)follows from the first rule ofη0.