A Nivat Theorem for Weighted Alternating Automata over Commutative Semirings

This paper connects the classes of weighted alternating finite automata (WAFA), weighted finite tree automata (WFTA), and polynomial automata (PA). First, we investigate the use of trees in the run semantics for weighted alternating automata and prove that the behavior of a weighted alternating automaton can be characterized as the composition of the behavior of a weighted finite tree automaton and a specific tree homomorphism, if weights are taken from a commutative semiring. Based on this, we give a Nivat-like characterization for weighted alternating automata. Moreover, we show that the class of series recognized by weighted alternating automata is closed under inverses of homomorphisms, but not under homomorphisms. Additionally, we give a logical characterization of weighted alternating automata, which uses weighted MSO logic for trees. Finally, we investigate the strong connection between weighted alternating automata and polynomial automata. We prove: A weighted language is recognized by a weighted alternating automaton iff its reversal in recognized by a polynomial automaton. Using the corresponding result for polynomial automata, we are able to prove that the ZERONESS problem for weighted alternating automata with weights taken from the rational numbers decidable.


Introduction
Non-determinism, a situation with several possible outcomes, is usually interpreted as a choice.This view has deep historical and philosophical roots and is adapted to automata theory in the following way: An (existential) automaton accepts if there exists at least one successful run.However, we may as well view a situation with several possible outcomes as an obligation: A universal automaton accepts only if all possible runs are successful.While this notion of "universal non-determinism" is less prominent, without further context it is as natural as the well known (existential) non-determinism.Allowing for the simultaneous use of existential and universal non-determinism leads to the concept of alternation, such as in alternating Turing machines [CKS81] or alternating automata on finite [BL80], or infinite structures [DS87].States of an alternating finite automaton (AFA) are either existential, or universal.For an existential state at least one of the outgoing runs needs to be successful, for a universal state all outgoing runs need to be successful to make the entire run successful.It is even possible to mix both modes by assigning a propositional formula over the states to each pair of state and letter.Alternating finite automata have been known for a long time.They are more succinct than finite automata and constructions like the complement, or intersection are easy for them.Due to this, they have many uses such as a stepping stone between logics and automata [DGV13], or in program verification [Var95].
While alternating automata recognize the same class of languages as finite automata, the situation is different in the weighted setting.A weighted finite automaton (WFA) assigns a weight to each of its transitions.The weight of a run is computed by multiplying its transition weights.Finally, the automaton assigns to each input the sum over all weights of runs corresponding to this input.By this, a weighted automaton recognizes a quantitative language i.e. a mapping from the set of words into a weight structure.Depending on the weight structure used, we may view a quantitative language as a probability distribution over the words, as a cost or yield assignment, or as the likelihood or quantity of success for each input.To simultaneously allow for a multitude of interesting weight structures, weighted automata have been studied over arbitrary semirings [DKV09].
To adapt alternating automata into the weighted setting, it can be observed that the existence of a run in a finite automaton becomes a sum over all runs in a weighted automaton.Analogously, the demand for all runs to be successful becomes a product over all runs.More precisely, if a weighted alternating finite automaton (WAFA) is in an additive state, it will evaluate to the sum over the values of all outgoing runs.If the weighted alternating automaton is in a multiplicative state, it will evaluate to the product over the values of all outgoing runs.And again, we are able to mix both modes, this time by assigning polynomials over the states to each pair of state and letter.Weighted alternating automata over infinite words were studied in [CDH09] and in [AK11] over finite words.While these authors focused on very specific weight structures, a more recent approach defines weighted alternating automata over arbitrary commutative semirings [KM18].
Weighted alternating automata have the same expressive power as weighted automata if and only if the semiring used is locally finite [KM18].However, for many interesting semirings such as the rational numbers, weighted alternating automata are strictly more expressive than weighted automata.While we have a fruitful framework for weighted automata, woven by results like the Nivat theorem for weighted automata [DK21], the equivalence of weighted automata and weighted rational expressions [Sch61] and weighted restricted MSO logic [DG07], or the decidability of equality due to minimization if weights are taken from a field [Sch61] and many more, no such results are known for weighted alternating automata.In this paper we will extend the results on weighted alternating automata by connecting them to known formalisms and thereby establishing further characterizations of quantitative languages recognized by weighted alternating automata.From there on, we will use these connections to prove interesting properties for weighted alternating automata and vice versa to translate known results for weighted alternating automata into other settings.
After a brief recollection of basic notions and notations in Section 2, Section 3 will establish several normal forms for weighted alternating automata (Lemma 3.1, Lemma 3.2) that are used as the basis of later proofs.Section 4 includes our core result (Theorem 4.5), a characterization of weighted alternating automata by the concatenation of weighted finite tree automata (WFTA) together with certain homomorphisms.More precisely, we consider word-to-tree homomorphisms that translate words viewed as trees into trees over some arbitrary ranked alphabet.We can show that a quantitative language is recognized by a weighted alternating automaton if, and only if there exists word-to-tree homomorphism and a weighted tree automaton such that the evaluation of the weighted alternating automata on any given word is the same as the evaluation of the weighted tree automaton on the image of the homomorphism of this word.
In Section 5 we will use this result to prove that the class of quantitative languages recognized by weighted alternating automata is closed under inverses of homomorphisms (Corollary 5.2).However, we can prove the same is not true for homomorphisms in general (Lemma 5.3).Since the closure under homomorphisms plays a key part in the proof of the Nivat theorem for weighted automata this prohibits a one-to-one translation of the Nivat theorem for weighted automata into the setting of weighted alternating automata.Nonetheless, we will utilize the connection between weighted alternating automata and weighted tree automata, as well as a Nivat theorem for weighted tree automata, to prove an adequate result for weighted alternating automata (Theorem 5.7).This will lead us directly into a logical characterization of quantitative languages recognized by weighted alternating automata with the help of weighted restricted MSO logic for weighted tree automata (Section 6 Theorem 6.2).It is well known that recognizable tree languages are closed under inverses of tree homomorphisms.However, the same does not hold in the weighted setting for arbitrary commutative semirings.Section 7 gives a precise characterization of the class of semirings for which the respective class of recognizable weighted tree languages is closed under inverses of homomorphisms (Theorem 7.1).For this purpose, we will use our core theorem, and a result form [KM18].
Lastly, in Section 8, we investigate the connection between weighted alternating automata and recently introduced polynomial automata [BTSW17] to prove the decidability of the ZERONESS and EQUALITY problems for weighted alternating automata if weights are taken from the rational numbers (Corollary 8.2).

Preliminaries
Let N = {0, 1, 2, . ..} denote the set of non-negative integers.For sets M, N we denote the cardinality of M by |M |, the set of subsets of M by P(M ), the Cartesian product of M and N by M × N , and the set of mappings from M to N by For the remainder of this paper, let Σ, Γ and Λ denote alphabets.The set of all (finite) words over Σ is denoted by Σ * .Let |w| denote the length of a word w and Σ k = {w ∈ Σ * | |w| = k}.The unique word in Σ 0 is called the empty word and denoted by ε.The concatenation of words u, v is denoted by u A monoid is an algebraic structure (M, •, 1), where • is a binary associative internal operation and m A semiring is an algebraic structure (S, +, •, 0, 1), where (S, +, 0) is a commutative monoid, (S, •, 1) is a monoid, s • 0 = 0 = 0 • s for all s ∈ S, and For the remainder of this paper, let S denote a commutative semiring.
For any set M , we denote S M by S⟨⟨M ⟩⟩.Furthermore, for L ⊆ M we define the characteristic function 1 L ∈ S⟨⟨M ⟩⟩ by 1 L (w) = 1 if w ∈ L and 1 L (w) = 0 otherwise for all w ∈ M .An element s ∈ S⟨⟨Σ * ⟩⟩ is called a S-weighted Σ-language (for short: weighted language).Let X n always denote a linearly ordered set with |X n | = n ∈ N, we refer to the i-th element of X n by x i .Let S [X n ] denote the semiring of polynomials with coefficients in S and commuting indeterminates x 1 , . . ., x n .We say for some s ∈ S and k 1 , . . ., k n ∈ N. The degree of m is n i=1 k i .A monomial m is a proper monomial if it has a non-zero degree.Each polynomial that can be written as a sum of proper monomials is called a polynomial without constants and the set of all polynomials without constants is denoted by S [X n ] const=0 .For p, p 1 , . . ., p n ∈ S [X n ] let p⟨p 1 , . . ., p n ⟩ denote the polynomial gained from the simultaneous substitution of x i by p i in p for all 1 ≤ i ≤ n.
Next, we give a concise collection of definitions from the topic of ranked trees that are needed in this paper.For a more detailed introduction to trees and tree automata, we recommend [CDG + 08].
A ranked alphabet is an ordered pair (Γ, Rank), where Rank : Γ → N is a mapping.Without loss of generality, we assume We extend Rank by putting Rank(x i ) = 0 for all i ∈ N. If Rank is clear from the context, we just write g(t 1 , . . ., t k ).Moreover, we identify g and g() for g ∈ Γ (0) ∪ X n .Hence, all terms t ∈ T Γ [X n ] are of the form t = g(t 1 , . . ., t k ) for some g ∈ Γ ∪ X n and t 1 , . . ., t k ∈ T Γ [X n ].
We define Pos : T Γ [X n ] → P(N * ) : g(t 1 , . . ., t k ) → {ε} ∪ k i=1 {i} • Pos(t i ).Let t = g(t 1 , . . ., t k ).The mapping Label t : Pos(t) → Γ ∪ X n is defined by Label t (ε) = g; and Label t (w) = Label t i (v) if w = iv ∈ Pos(t).We will identify t and the mapping Label t : We write t(w) to denote Label t (w) and refer to terms as trees.Consequently, we have t −1 (g) = {w ∈ Pos(t) | Label t (w) = g} for all g ∈ T Γ [X n ].This coincides with the definition of a tree as a directed graph in the following way: The set of vertices is Pos(t), the root is ε, and for u, v ∈ Pos(t) we have a (u, v)-edge iff v = ui for some i ∈ N.
For t = g(t 1 , . . ., t k ), t ′ ∈ T Γ [X n ], and w ∈ Pos(t), the subtree of t at w, denoted by t| w and the substitution of t ′ in t at w, denoted by t⟨w ← t ′ ⟩ are defined by t| ε = t and , where m i is the i-th element of M with regard to the lexicographical order on N * .In case t We say a tree t is non-deleting in l variables if it contains at least one symbol from Γ and each of the variables x 1 , . . ., x l occurs at least once in t.We say t is linear in l variables if it is non-deleting in l variables and each of the variables occurs at most once in t.Moreover, let r(t) = n i=1 |t −1 (x i )| denote the number of nodes of t labeled by variables.For any r ∈ N 27: = r} be the set of Γ-trees with exactly r positions labeled by variables.
A tree homomorphism h : T Γ → T Λ is a mapping such that for all g ∈ Γ (r) there exists t g ∈ T Λ [X r ] with h(g(t 1 , . . ., t r )) = t g ⟨h(t 1 ), . . ., h(t r )⟩ for all t 1 , . . ., t r ∈ T Γ .We will denote t g by h(g), even though t g is not necessarily in T Λ .A tree homomorphism is non-deleting (resp.linear ) if each h(g) is non-deleting (resp.linear) in Rank(g) variables.For more information on tree homomorphisms consider Paragraph 1.4 in [CDG + 08].

Weighted alternating finite automata
This section introduces weighted alternating finite automata (WAFA) and shows how to achieve desirable normal forms of WAFA (Lemma 3.1, Lemma 3.2).We will follow the definitions of [KM18].

. , [A] qn (w) .
A weighted language s is recognized by A if and only if [[A]] = s.Two WAFA are said to be equivalent if they recognize the same weighted language.
Within the scope of this paper, we define a weighted finite automaton as follows: A weighted finite automaton (WFA) is a WAFA A = ({q 1 , . . ., q n }, Σ, δ, P 0 , τ ) where P 0 = n j=1 s j • q j and δ(q i , a) = n j=1 s a ij • q j for all 1 ≤ i ≤ n, a ∈ Σ.This definition coincides with the well known definition cf.[DG09], [DG07].For example P 0 = q 1 + 3 • q 4 corresponds to initial weight 1 in q 1 , initial weight 3 in q 4 , and initial weight 0 in all other states; or δ(q 2 , a) = 3 • q 2 + 4 • q 3 corresponds to a situation where state q 2 has an a-loop with weight 3 and an a-transition to state q 3 with weight 4 (and vice versa).Lastly, τ (q 2 ) = 2 means state q 2 has final weight 2.
Let A be a WAFA with weights taken from S. We define M (q,a) as the set of monomials that appear in δ(q, a) and M 0 as the set of monomials that appear in P 0 .An element s ∈ S is called a coefficient in A if s is the coefficient of a monomial in M 0 , or the coefficient of a monomial in M (q,a) for some q ∈ Q, a ∈ Σ.Similarly, s is called a constant in A if P 0 (0, . . ., 0) = s, or δ(q, a)(0, . . ., 0) = s for some q ∈ Q, a ∈ Σ.
We say A is nice if it has the following properties: (i) δ(q, a) is a finite sum of pairwise distinct monomials of the form s • q k 1 1 • . . .• q kn n for all q ∈ Q, a ∈ Σ, (ii) all monomials in P 0 and δ are proper, (iii) P 0 = q 1 .Moreover, we say that A is purely polynomial if: (iv) all monomials (in P 0 and δ) have coefficient 1.
We want to show that we can always assume a WAFA to be nice and purely polynomial.
Lemma 3.1.For each WAFA A there exists an equivalent WAFA A ′ such that (i)-(iv) hold for A ′ .The construction of A ′ is effective.
) which includes a new state q c for each constant c in A. Furthermore, δ ′ and P ′ 0 are as δ and P 0 , respectively, but each occurrence of each constant c is replaced by q c .Moreover, δ ′ (q c , a) = q c for all a ∈ Σ and τ ′ (q c ) = c.There is a finite number of constants in A. Thus, A ′ is a WAFA.It is easy to see that A and A ′ are equivalent and that (i)-(ii) hold for A ′ .(iii) Assume (i)-(ii) hold for A. Due to Lemma 6.3 of [KM18], there exists an equivalent WAFA A ′ such that (i)-(iii) hold for A ′ .The construction of A ′ is straightforward: we add a new state q to A with δ(q, a) = P 0 ⟨δ(q 1 , a), . . ., δ(q n , a)⟩ and τ (q) = P 0 ⟨t(q 1 ), . . ., τ (q n )⟩.We rename the states of A such that q becomes the new q 1 .Lastly, we set P 0 = q 1 .(iv) Assume that (i)-(iii) hold for A. We define We may assume that the two sets forming this union are disjoint.Furthermore, let δ ′ be defined by q otherwise for all q ∈ Q ′ , a ∈ Σ.Moreover, let τ ′ be defined by ] and that every monomial in A ′ has 1 as coefficient.
If the appropriate order on Q ′ is chosen, properties (i)-(iii) hold for A ′ , too.
We would like to point out: while the construction described in the proof of Property (iv) also works for WFA the resulting automaton does not have to be a WFA.
In [KM18] the transition function and the initial polynomial are not allowed to contain constants.This corresponds to the property that runs are not allowed to terminate before the entire word is read.Since it will help with several constructions, we allowed constants in our definition.Nevertheless, as Lemma 3.1 (ii) shows, the introduction of constants does not increase expressiveness since it is possible to simulate terminating transitions by "deadlock"-states.
We say a WAFA (Q, Σ, δ, P 0 , τ ) is equalized if all monomials occurring in δ have the same degree.27:7 Lemma 3.2.For each WAFA A there exists an equivalent, equalized and niceWAFA A ′ .The construction of A ′ is effective.
Proof.Let A = (Q, Σ, δ, q 1 , τ ) be a nice WAFA and d the maximum degree of monomials occurring in δ.Let q n+1 be a new state and Due to the form of the constructed polynomials and since the initial polynomial remains unchanged, we may assume that A ′ is nice.Moreover, we didn't change the coefficients, thus A ′ is purely polynomial, if A was purely polynomial.
Nice WAFA can be represented in the following way: As usual we depict each state by a circle.Then, each monomial s • q k 1 1 . . .q kn n in δ(q i , a) is represented by a multi-arrow which is labeled by a : s, begins in q i , and has k j heads in q j for all 1 ≤ j ≤ n, respectively.In case a multi-arrow has more than one head, we join these heads by a .If s = 1, we omit the s-label.If s = 0, we omit the complete multi-arrow.The initial polynomial is represented analogously.The final weights are represented as usual.Note that the multi-arrows can be viewed as a parallel or simultaneous transitions and that this representation coincides with the usual representation if the automaton is a WFA.Consider the following example: Example 3.3.Let S = (N, +, •, 0, 1), Σ = {a, b}, and s the weighted language We consider the WAFA A = ({q, p}, Σ, P 0 , δ, τ ), defined by: A depiction of this automaton can be seen in Figure 1.One can check that [[A]] = s, for example: Two-mode alternating automata are a subclass of alternating automata.In the weighted setting two-mode alternating automata are defined as follows (cf.[KM18]): each state q is either existential (δ(q, a) = n i=1 s a i • q i for all a ∈ Σ) or universal (δ(q, a) for all a ∈ Σ).In [KM18] run semantics were defined for two-mode alternating automata.However, they can be defined for alternating automata with mixed states, in an analogue fashion.Here, we give the definition of runs for nice WAFA.For one, as seen above, we can transform every WAFA into a nice one.For another, it is only a technicality to define runs for arbitrary WAFA, based on the definition below.
The idea of reading monomials as multi-transitions was already introduced above.Having this in mind, a run tree is a tree labeled by states such that: (i) Our run begins in the initial state, (ii) if a vertex at depth k is q labeled, then the labels of its children fit the states of an a k labeled multi-transition beginning in state q, and (iii) our run halts after n steps.
More formally, if A = (Q, Σ, δ, q 1 , τ ) is a nice WAFA, we define the ranked alphabet for some a ∈ Σ} where Rank(q, x) is the rank of x as a polynomial.A run over w = a 1 . . .a n in A is a Γ A -tree t R with the following properties: (i) If |p| = 0, then t R (p) = (q 1 , x), for some x.
) and for all l−1 u=1 k u ≤ i < l u=1 k u we have t R (pi) = (q l , x) for some x.
The weight of a run tree t R is defined by s .
Note that the final weights are accounted for, since they are the labels of the leaves of our run tree.
And as usual we have (Theorem 5.15 & Theorem 5.17 in [KM18]): Example 3.4.Later we will use the connection between WAFA and trees heavily.For a better understanding of this connection we want to point out the following: First off, let us observe that |M (q,a) | = 1 if δ(q, a) is a monomial.Consequently, if δ(q, a) is a monomial for all q ∈ Q, a ∈ Σ, then every word has a unique run.We call a WAFA with this property universal.A two-mode WAFA where every state is universal is universal and vice versa.Universality for WAFA is as determinism for finite automata.However, in general universal WAFA and WFA are incomparable it terms of expressive power (cf.Corollary 3 in [AK11]).(q, q) (q, q • p) (q, q) (p, p) (q, 1) (p, 2) (q, q) (q, q • p) Figure 4: Runs of WAFA from Figure 3 on aba Second, we consider the non-universal automaton from Figure 3.This automaton is not universal since δ(q, a) = q + p.As a consequence, we may have several runs, whenever the letter a is to be processed in state q we can choose one of two possible children in our tree.Figure 4 shows these run-trees for the input aba.This connection becomes more clear, if we observe the behavior of the automaton on aba: Clearly, every monomial in the final polynomial corresponds to one of the run-trees.Moreover, the weight of a run-tree is the product of the coefficients in its nodes and its leaves correspond to the final weights of their state.Thus, we get that the sum of all run-weights is the behavior of the automaton.
Due to the bound on the growth of series recognized by WFA, we can see that s from Example 3.3 is not recognizable by a WFA.Thus, WAFA are more expressive than WFA when weights are taken from the non-negative integers.However, this is not the case for every semiring.A semiring S is locally finite if for every finite X ⊆ S the generated subsemiring ⟨X⟩ is finite.The following result characterizes semirings on which WAFA and WFA are equally expressive: Theorem 3.5 [KM18, Theorem 7.1].The class of S-weighted Σ-languages recognizable by WAFA and the class of S-weighted Σ-languages recognizable by WFA are equal if and only if S is locally finite.

A characterization of WAFA via weighted finite tree automata
Our central result Theorem 4.5 is included in this section, as well as the definition of weighted finite tree automata.
The connection between alternating automata and trees was utilized before: Already in the non-weighted settings trees were used to define runs of alternating automata.As seen above, this is possible for WAFA too.We want to strengthen this connection by the use of tree automata and tree homomorphisms.In order to do so, we need some additional definitions.
If k is clear from the context, we will denote tuples (p 1 , . . ., p k ) by p.Moreover, since k in δ k (g) is clear from g, we will denote δ k (g) by δ g .
Let A = (Q, Γ, δ, λ) be a WFTA.Its state behavior [A] : Q × T Γ → S is the mapping defined by Usually, we will write [A] q (t) instead of [A](q, t).Now, the behavior of A is the weighted tree language [[A]] : T Γ → S defined by A weighted tree language s is recognized by A if and only if It is well known that a word over Σ can be represented as a 1-ary tree: Each letter of Σ is given rank one and a new end-symbol # of rank zero is added.Then w 0 w 1 . . .w n translates to the tree w 0 (w 1 (. . .w n (#) . ..)).Here, we want to represent words as full r-ary trees for any arbitary r ∈ N. Given an alphabet Σ and r ≥ 1, we define the ranked alphabet Σ r # = Σ ∪ {#} with Rank(#) = 0 and Rank(a) = r for all a ∈ Σ.For all w ∈ Σ * the tree t r w ∈ T Σ r # is defined by t r ε = #; and t r w = a(t r v , . . ., t r v ) if w = av with a ∈ Σ.We call h r : Σ * → T Σ r # : w → t r w the generic tree homomorphism (of rank r).The case r = 1 is special since for all t ∈ T Σ 1 # there exists w ∈ Σ * such that t = t 1 w .Therefore, if clear from the context, we will identify Σ and Σ 1 # , Σ * and T Σ 1 # , as well as w and t 1 w .It is well known that a weighted Σ language is recognizable by a WFA over Σ if and only if it is recognizable by a WFTA over Σ 1 # .The key observation is that the behavior of a WAFA A on w can be characterized by the behavior of a WFTA on t r w where r is the degree of polynomials in an equalized version of A. Even more, the behavior of a WFTA on h(w) (where h is a tree homomorphism) can be characterized by the behavior of a WAFA on w.Proof.Assume s is recognized by a WAFA.Due to Lemma 3.1 and Lemma 3.2, we may assume that s is recognized by a nice and equalized WAFA A = (Q, Σ, α, P 0 , τ ).Let r be the unique degree of monomials in A. Our goal is to define a WFTA B with To this purpose, we observe that the equalized A can be viewed as a WFTA over a ranked alphabet where each letter has rank r and where each multi-arrow in the representation of A corresponds to one transition in B. Formally, we define the WFTA B = (Q, Σ r # , β, λ) with: , and 0 otherwise , for all q ∈ Q and p ∈ Q r .
Note that the order of the p 1 , . . ., p r needs to be fixed, otherwise many runs of the WFTA may correspond to one run of the WAFA.Now, we will show that [A] q (w) = [B] q (t r w ) for all q ∈ Q and w ∈ Σ * by induction on |w| ∈ N. If |w| = 0, then w = ε.Thus, Figure 5: Run of translated WFTA on t 2 ab Assume there exists l ∈ N such that the claim holds for all w ′ ∈ Σ l and all q ∈ Q.For the induction step let w = aw ′ ∈ Σ • Σ l .For p ∈ Q k let k i (p) denote the number of q i 's in p.
Then, we get β a ( k i =r times q 1 , . . ., q 1 k 1 times , . . ., q n , . . ., q n kn times Since A is nice and thus P 0 = q 1 , we consequently have for all w ∈ Σ * .Since h r (w) = t r w , this finishes our proof.
The following example illustrates this connection between WAFA and WFTA.
Example 4.2.We consider the automaton A from Example 3.3.It is easy to construct the corresponding WFTA B = (Q, Γ, β, λ) from the equalized version A ′ (Figure 2).First, we copy the set of states (in order) Q = {q, p, h 1 }.Since the maximum degree of polynomials in A was 2 we get Γ = {a (2) , b (2) , # (0) }.The root weight function corresponds to the initial weights.However, A ′ is nice and thus λ = 1 {q} .The transition weight functions β a and β b can be defined using the multi arrows in Figure 2.For example, the b-labeled multi arrow in the middle corresponds to β b (ph 1 , q) = 1.Finally, the final weights in A ′ are captured by β # (ε, q) = 1, β # (ε, h 1 ) = 1, and β # (ε, p) = 2.The only non-zero run on t 2 ab can be seen in Figure 5.If h is the generic homomorphism, we can define δ ′ (q, a) = p∈Q r δ a (p, q) and use the same proof as in the first direction.However, we want to prove this for arbitrary homomorphisms.To achieve this, we give some additional definitions.
Under h, each letter becomes a tree.Nonetheless, we are not interested in the structure of h(a), but want to handle it as if it is a ranked letter.Therefore, we use h(a)⟨x 1 ← (p 1 , . . ., p r )⟩ to disambiguate its r = r(h(a)) variables.Furthermore, we extend the family of transition functions We use the same notations for δ ′ as for δ and define δ ′ k recursively as follows.
Proof.We prove this claim via induction on the depth of t.The claim is clear if k = 0. Therefore, we assume k > 0. If t = x 1 , we know t = t 1 and get Now, assume the claim holds for all t ∈ T Γ with depth ≤ n for some n ∈ N. Assume t has depth n+1 and t = g( t1 , . . ., tr ) for some g ∈ Γ (r) and t1 , . . ., tr ∈ T Γ∪{x 1 } .Of the k trees only the first r( t1 ) will be substituted in t1 , only the second r( t2 ) will be substituted in t1 , and so on.
We return to our main proof.
Here * holds due to Claim 4.4 with k = 0 and t = t = h(#).Assume there exists some l ∈ N such that [B] q (h(w)) = [A] q (w) for all q ∈ Q, w ∈ Σ l .For the induction step let w = aw ′ ∈ Σ • Σ l and k = r(h(a)).Similar to the first direction, we have ) for all q ∈ Q. Via induction, this finishes our proof of the second direction.
Finally, for all w ∈ Σ * we get: This leads us to our main result.
Theorem 4.5.A weighted language s ∈ S⟨⟨Σ * ⟩⟩ is recognized by a WAFA if and only if there exists a ranked alphabet Γ, a tree homomorphism h : Σ * → T Γ , and a Proof.This is an immediate consequence of Lemma 4.1 and Lemma 4.3.
This result allows us to transfer results from WFTA to WAFA.Moreover, additional observations in the proofs show that one can give a weight preserving, bijective mapping between the runs of A and B. This allows us to translate results about runs of WFTA into results about runs of WAFA.To see how to do this, we first revisit a well known result for non-weighted WAFA.
This result goes back to [CKS81] and deals with non-weighted automata.It is well known that the non-weighted setting corresponds to the weighted setting, if weights are taken from the Boolean semiring.Thus, we may still investigate the non-weighted setting with our methods.Therefore, we can reproduce this result by using the Boolean semiring.In doing so, we will get a better understanding of the translation of WAFA into WFA.In particular, we are able to identify cases, in which this translation is efficient.
Clearly, every WFA is a WAFA, hence we only have to concern ourselves with one direction.First, we observe that 1 L • h = 1 h −1 (L) for any tree language L ⊆ T Λ and tree homomorphism h : T Γ → T Λ .Assume 1 L is recognized by a WAFA.By Lemma 4.1, we get # regular.Since regular tree languages are closed under inverses of homomorphisms, we know It is also known that WFA and WFTA are equally expressive over Σ 1 # , thus 1 L is recognized by a WFA.The authors in [CKS81] also show that the translation of an alternating finite automaton into an equivalent deterministic finite automaton leads to a (worst case) doubly exponential blowup in states.By our proof we get a better understanding of where this blowup comes from.Constructing B (from the Proof of Lemma 4.1) is linear in states.However, to construct the tree automaton B ′ recognizing h −1 (L), we get an exponential blowup in states.Next, B ′ viewed as a WFA is non-deteministic (even if B ′ was bottom up deterministic).Thus, another exponent is needed to determinize B ′ .Immediately, we see that the translation of an alaternating automaton into a non-deterministic finite automaton is only exponential.Moreover, the first exponent is only needed, if B is not (bottom up) deterministic.If a nice Boolean WAFA has only one non-zero final weight and for every pair of states p, q we have M (q,a) ∩ M (p,a) = ∅ for all a ∈ Σ, then B is bottom up deterministic.Consequently, the translation of alternating automata with this property into a non-deterministic finite automaton is linear in states.

A Nivat theorem for WAFA
This section leads to the Nivat-like characterization of WAFA (Theorem 5.7), but first we will prove that weighted languages recognized by WAFA are closed under inverses of homomorphisms (Corollary 5.2), but not under homomorphisms (Lemma 5.3).
The original Nivat Theorem [Niv68] characterizes word-to-word transducers.A generalized version for WFA over arbitrary semirings (Theorem 6.3 in [DK21]) can be stated in the following way: Theorem 5.1 (Nivat-like theorem for WFA [DK21]).A weighted language s ∈ S⟨⟨Σ * ⟩⟩ is recognized by a WFA if and only if there exist an alphabet Γ, a non-deleting homomorphism h : Γ * → Σ * , a regular language L ⊆ Γ * , and a WFA A w with exactly one state such that: Please note, A w does not depend on any input and is called A w since it is responsible for the application of weights.Our goal is to generalize this result to WAFA.This Nivat-like theorem is strongly connected to the closure of weighted languages recognized by WFA under (inverses) of homomorphisms.Thus, we will investigate these properties for WAFA.5.1.Closure properties.A class K of S-weighted languages is said to be closed under homomorphisms if s ∈ S⟨⟨Γ * ⟩⟩ ∩ K and h : Γ * → Σ * a non-deleting homomorphism implies h(s) ∈ S⟨⟨Σ * ⟩⟩∩K.Moreover, K is closed under inverses of homomorphisms if s ′ ∈ S⟨⟨Γ * ⟩⟩∩K and h : Σ * → Γ * a homomorphism implies h −1 (s ′ ) ∈ S⟨⟨Σ * ⟩⟩ ∩ K.The same notions are used for weighted tree languages.
The class of weighted languages recognized by WFA is closed under (inverses of) homomorphisms (Lemma 6.2 in [DK21]).WAFA are also closed under inverses of homomorphisms.In fact, this is an easy corollary of Lemma 4.1 and Lemma 4.
# is a tree homomorphism.Thus, due to Lemma 4.3, However, the same is not true for the closure under homomorphisms.
for all w ∈ Σ * .Thus, h(r R ) is not recognized by a WAFA.The weighted language r R is recognized by the WAFA A R = ({q ι , q 1 , q a , q c , q d }, {a, #, c, d}, δ R , q ι , τ R ) with δ R and τ R defined by: A depiction of A R can be seen below.This completes our proof.
Nonetheless, the proof of the second direction of Theorem 5.1 relies on the closure under homomorphisms.Thus, due to Lemma 5.3, a one to one translation of Theorem 5.1 into the framework of alternating automata is prohibited.Moreover, in the proof of the first direction of Theorem 5.1, L is defined as a language of runs of A. As mentioned above, runs of WAFA are trees.Therefore, we will utilize a Nivat-like theorem for WFTA to prove the corresponding result for WAFA.5.2.A Nivat-like characterization of WFTA.Nivat-like characterizations for weighted tree languages have been investigated in the past.Unranked trees were considered in [DG17], while a very general result for graphs can be found in [DD15].Here, for the readers convenience, we want to restate a more restricted version for ranked trees.
Claim 5.6.For all q ∈ Q it holds Proof.The proof is by induction on the depth of t.If t = g for some g ∈ Γ (0) , we get for all q ∈ Q.
Assume the claim holds for all t ∈ T Γ of depth lower or equal to n for some n ∈ N.
We consider some t ∈ T Γ of depth n + 1.There exist g ∈ Γ (k) and t 1 , . . ., t k ∈ T Γ such that t = g(t 1 , . . ., t k ).Clearly, t i has a depth lower or equal to n for all 1 ≤ i ≤ k.Let us denote the tuple (t 1 , . . ., t k ) by t and h −1 (t 1 ) × . . .× h −1 (t k ) by h −1 (t).First, we observe for some q ∈ P , p ∈ Q k , and t ′ ∈ h −1 (t).Moreover, we have holds for all r ∈ S⟨⟨T Λ ⟩⟩.By this, we get This finishes the proof of the claim.27:19 We return to our main proof, it remains to show that we are able to apply the final weights.We consider some t ∈ T Γ .There exists g ∈ Γ (k) and t ∈ T k Γ (we use the same notation as above) with t = g(t).First, we make a similar observation as in the proof of our claim.Namely, for all r ∈ S⟨⟨T Λ ⟩⟩.Finally, analogously to the proof of Claim 5.6, we are able to deduce ω [q,g,p fin ] (q w , (q w , . . ., q w )) Since t was arbitrary, this completes our proof.
Based on this result and Theorem 4.5 a characterization of WAFA via a Nivat-like Theorem is immediate.
Theorem 5.7 (Nivat-like theorem for WAFA).A weighted language s ∈ S⟨⟨Σ⟩⟩ is recognized by a WAFA if and only if there exist a rank r ∈ N, a ranked alphabet Λ, a linear tree homomorphism h : T Λ → T Σ r # , a regular tree language L ⊆ T Λ , and a WFTA A w with exactly one state such that for all w ∈ Σ * , it holds: w ) for all w ∈ Σ.This finishes our proof.

A logical characterization of WAFA
Based on Theorem 4.5 we are able to give a logical characterization of WAFA (Theorem 6.2).For this purpose, we will use the logical characterization by weighted MSO logic for trees which was introduced in [DV06].
Weighted MSO logic over trees is an extension of MSO logic over trees.It allows for the use of usual MSO formulas, but also incorporates quantitative aspects such as semiring elements and operations, as well as weighted quantifiers.In the end, every weighted MSO formula defines a weighted tree language.More precisely, let Γ be a ranked alphabet, each weighted MSO formula φ ∈ MSO(Γ, S) defines a weighted tree language [[φ]] : T Γ → S. Weighted MSO logic is strictly more expressive than WFTA.Nevertheless, it is possible to restrict the syntax of weighted MSO in such a way that it characterizes weighted tree languages recognized by WFTA.This fragment is called weighted syntactically restricted MSO (srMSO).Since it is not needed to understand the following proofs, we have omitted the formal definition of srMSO.We will use syntax and semantics of weighted srMSO without any changes and refer the interested reader to [FV09] or [DV11].Our characterization of WAFA will be fully based on the following characterization theorem for WFTA: However, we still have to handle the homomorphism used in Theorem 4.5.This will be done by choosing an appropriate way of representing words as relational structures.
By definition [[φ]] ∈ S⟨⟨T Γ ⟩⟩ for all φ ∈ srMSO(Γ, S).However, we want to use weighted srMSO on trees to define weighted languages on words.To this end, we define While mirroring the branching behavior of WAFA in the logic gives a natural characterization of WAFA, the question arises how WAFA relate to the weighted MSO logic for words.

Lemma 4. 1 .
If s ∈ S⟨⟨Σ * ⟩⟩ is recognized by a WAFA, then s = [[B]] • h rfor some WFTA B and the generic homomorphism h r for some r ∈ N.

3 .
Corollary 5.2.The class of weighted languages recognized by WAFA is closed under inverses of homomorphisms.Proof.Let h ′ : Λ * → Σ * be a homomorphism and s ∈ S⟨⟨Σ * ⟩⟩ recognized by a WAFA.Due to Lemma 4.1, we get s = [[B]] • h r for the generic homomorphism h r : Σ * → Σ r # and some weighted Σ r # -WFTA B. Since homomorphisms are closed under composition, h r • h