Weighted Tiling Systems for Graphs: Evaluation Complexity
WWeighted Tiling Systems for Graphs: EvaluationComplexity
C. Aiswarya
Chennai Mathematical Institute, India and IRL ReLaX, CNRS [email protected]
Paul Gastin
LSV, ENS Paris-Saclay, CNRS, Université Paris-Saclay, [email protected]
Abstract
We consider weighted tiling systems to represent functions from graphs to a commutative semiringsuch as the Natural semiring or the Tropical semiring. The system labels the nodes of a graph byits states, and checks if the neighbourhood of every node belongs to a set of permissible tiles, andassigns a weight accordingly. The weight of a labeling is the semiring-product of the weights assignedto the nodes, and the weight of the graph is the semiring-sum of the weights of labelings. We showthat we can model interesting algorithmic questions using this formalism - like computing the cliquenumber of a graph or computing the permanent of a matrix. The evaluation problem is, given aweighted tiling system and a graph, to compute the weight of the graph. We study the complexityof the evaluation problem and give tight upper and lower bounds for several commutative semirings.Further we provide an efficient evaluation algorithm if the input graph is of bounded tree-width.
Theory of computation → Quantitative automata
Keywords and phrases
Weighted graph tiling, tiling automata, Evaluation, Complexity, Tree-width
Related Version
An extended abstract of preliminary version is accepted at FSTTCS’20.
Funding
Supported by IRL ReLaX
C. Aiswarya : Supported by DST Inspire
Weighted automata have been classically studied over words, as they naturally extendautomata from representing languages to representing functions from words to a semiring.We are interested in finite state formalisms for representing functions from graphs to asemiring. Many natural algorithmic questions on graphs are about computing a function,such as the clique number, weight of the shortest path etc. It is interesting to see if onecan design weighted automata to model such problems. Further can one design efficientalgorithms for problems modeled by such weighted automata?We study weighted tiling systems (WTS), a variant of the weighted graph automata ofDroste and Dück [10], motivated by the graph acceptors of Thomas [25]. This subsumesmany quantitative models that have been studied on words, trees [13, 14], nested words [23],pictures [17], Mazurkiewicz traces [11, 24, 5], etc. The reader is referred to the handbook [12]for more details and references. Many of these works are mainly interested in expressivityquestions, and show that the model has good expressive power. The model is also easy tounderstand as it is formulated in terms of tiling/colouring respecting local constraints. Wereiterate the expressivity by modeling computational problems on graphs using this model.Our focus is on the computational complexity of the evaluation problem. It is closer in spiritto [18] which provides an efficient evaluation algorithm for weighted pebble automata onwords. a r X i v : . [ c s . F L ] S e p Weighted Tiling Systems for Graphs: Evaluation Complexity
We show that many algorithmic questions, like computing the clique number, computingthe permanent of a matrix, or counting variants of SAT, can be naturally modeled usingthis formalism. We investigate the computational complexity of the evaluation problem andobtain tight upper- and lower-bounds for various semirings.To give more details, a WTS has a finite number of states and a run labels the verticesof a graph with states. The tiles (analogous to transitions) observe the neighbourhood ofa vertex under the labeling, and assign a weight accordingly. The weight of the run is thesemiring-product of the weights thus assigned, and the weight assigned to a graph is thesemiring-sum of the weights of the runs. We only consider commutative semirings and hencethe order in which the product is taken does not matter.The evaluation problem is to compute the weight of an input graph in an input WTS.We study the computational complexity of this problem for various semirings. OverNatural semiring and non-negative rationals, the problem is shown to be ( N , max , +) , ( Z , max , +) , ( N , min , +) , ( Z , min , +) – the problem is FP NP [ log ] complete.We further consider the evaluation problem for graphs of bounded tree-width and showthat they are computable in time polynomial in the WTS and linear in the graph. Boundedtree-width captures a variety of formal models of concurrent and infinite state systems such asMazurkiewicz traces, nested words, and decidable under-approximations of message passingautomata or multi-pushdown automata [21, 1, 2].Even though our focus is evaluation, and not expressiveness of the model, we get a deepinsight into the modeling power of this formalism through the upper and lower complexitybounds. For instance, we cannot polynomially encode the traveling salesman problem (lowerbound FP NP ) in our formalism over tropical semiring (upper bound FP NP [ log ] ) unless thepolynomial hierarchy collapses [19]. First we will fix the notations for semirings, graphs and then introduce the WTS formally.
Preliminaries.
Let N denote the set of natural numbers including 0, Z the integers, and Q the rationals.Let A = { a , . . . a n } and B be two sets. We sometimes write a function f ∶ A → B explicitlyby listing the image of each element: f = [ a ↦ f ( a ) , . . . , a n ↦ f ( a n )] . The set of allfunctions from A to B is denoted B A . If A is ∅ then the only relation (and hence function)from A to B is ∅ . We denote this trivial empty function by f ∅ .Let M be a non-deterministic Turing machine. The number of accepting runs of M on aninput x is denoted M ( x ) , and the number of rejecting runs of M on x is denoted M ( x ) .A semiring is an algebraic structure S = ( S, ⊕ , ⊗ , S , S ) where S is a set, ⊕ and ⊗ aretwo binary operations on S , ( S, ⊕ , S ) is a commutative monoid, ( S, ⊗ , S ) is a monoid, ⊗ distributes over ⊕ , 0 S is an annihilator for ⊗ . A semiring is commutative if ⊗ is commutative.Examples include Boolean = ({ , } , ∨ , ∧ , , ) , Natural = ( N , + , × , , ) , Integer = ( Z , + , × , , ) , Rational = ( Q , + , × , , ) and Rational + = ( Q ≥ , + , × , , ) . Further examples are tropicalsemirings: max-plus- N = ( N ∪ {−∞} , max , + , −∞ , ) , max-plus- Z = ( Z ∪ {−∞} , max , + , −∞ , ) , min-plus- N = ( N ∪ {+∞} , min , + , +∞ , ) and min-plus- Z = ( Z ∪ {+∞} , min , + , +∞ , ) . We willconsider only these semirings in this paper. Note that all these semirings are commutative. . Aiswarya and P. Gastin 3 Graphs.
We consider graphs with different sorts of edges. For example, a grid will havehorizontal successor edges, and vertical successor edges. A binary tree will have left-childrelations and right-child relations. Message sequence charts will have process-successorrelations and message send-receive relations. These graphs have bounded degree, and foreach sort of edge, a vertex will have at most one outgoing/incoming edge of that sort . Ourdefinition of graphs below allows to capture such graph classes.Let Γ be a finite set of edge names, and let Σ be a finite set of node labels. A ( Γ , Σ ) -graph G = ( V, ( E γ ) γ ∈ Γ , λ ) has a finite set of vertices V , an edge relation E γ ⊆ V × V for every γ ∈ Γ,and a mapping λ ∶ V → Σ assigning a label from Σ to each vertex v ∈ V . The graphs weconsider will have at most one outgoing edge and at most one incoming edge for every edgename. That is, for each γ ∈ Γ, for all v ∈ V , ∣{ u ∣ ( v, u ) ∈ E γ }∣ ≤ ∣{ u ∣ ( u, v ) ∈ E γ }∣ ≤ τ = ( Γ in , Γ out ) indicates that the set of incoming (resp. outgoing) edge names is Γ in (resp. Γ out ). Let Types = Γ × Γ be the set of all types. We define type ∶ V → Types and use type ( v ) to denotethe type of vertex v . (cid:73) Remark 1.
Even though we consider only bounded degree graphs, we are able to modelgraph functions on arbitrary graphs (even edge weighted) as illustrated in the examplesbelow. Basically an arbitrary graph is input via its adjacency matrix, which is naturallya grid, a special case of the graphs that we can handle. We can even model problems onarbitrary graphs with edge weights.
A weighted Tiling System is a finite state mechanism for defining functions from a classof graphs to a weight domain. It has a finite set of states and a set of permissible tiles foreach type of vertices. Formally, a weighted tiling system (WTS) over ( Γ , Σ ) -graphs and asemiring S = ( S, ⊕ , ⊗ , S , S ) is a tuple T = ( Q, ∆ , wgt ) where Q is the finite set of states,∆ = ⋃ τ ∈ Types ∆ τ — for a type τ = ( Γ in , Γ out ) ∈ Types , the set ∆ τ ⊆ Q Γ in × Q × Σ × Q Γ out gives the set of permissible tiles of type τ , wgt ∶ ∆ → S , assigns a weight for each tile.A run ρ of T on a graph G = ( V, ( E γ ) γ ∈ Γ , λ ) is a labeling of the vertices by states thatconforms to ∆. Given a labeling ρ ∶ V → Q , for a vertex v ∈ V with type ( v ) = ( Γ in , Γ out ) wedefine the tile of v wrt. ρ to be tile ρ ( v ) = ( f in , ρ ( v ) , λ ( v ) , f out ) where f in ∶ Γ in → Q is givenby γ ↦ ρ ( u ) if ( u, v ) ∈ E γ and f out ∶ Γ out → Q is given by γ ↦ ρ ( u ) if ( v, u ) ∈ E γ . A labeling ρ ∶ V → Q is a run if for each v ∈ V , tile ρ ( v ) ∈ ∆ type ( v ) .The weight of a run ρ , denoted wgt ( ρ ) , is the product of the weights of the tiles in ρ .With commutative semirings, we do not need to specify an order for this product. The value [[T ]]( G ) computed by T for a graph G is the sum of the weights of the runs. That is, [[T ]]( G ) = ⊕ ρ ∣ ρ is a run of T on G wgt ( ρ ) wgt ( ρ ) = ⊗ v ∈ V wgt ( tile ρ ( v )) . (cid:73) Remark 2.
The WTS is a variant of the weighted graph automata (WGA) of [10]. Thereare two main differences. First, WGA admits tiles of bigger radius and the tile size is a This choice is mainly for notational convenience, and is not really a restriction provided we consideronly bounded degree graphs. Another option would be to enumerate the neighbours in some order andaddress a neighbour as the i th incoming/outgoing neighbour. Weighted Tiling Systems for Graphs: Evaluation Complexity parameter. This is not more powerful, as it can be realized with immediate neighborhoodtiles like in WTS. Second, WGA allows occurrence constraints. We discuss this in moredetail in Section 5.We give some examples of WTS below, which will also serve as reductions provingcomplexity lower-bounds in Section 3. (cid:73)
Example 3 (A WTS to compute the clique number of a graph) . The clique number of agraph is the size of the largest clique in the graph.The graphs on which we want to compute the clique number have unbounded degreesindeed. In our setting we consider only bounded degree graphs. Hence we need to encode anyarbitrary graph as a bounded degree graph. One way to do that is to consider the adjacencymatrix and represent this matrix using a grid graph.For the particular case of clique number, our input is an undirected graph, so we willconsider a lower-right triangular matrix in a lower-right triangular grid graph. For this welet Γ = {→ , ↓} and Σ = { , } . The labels of all diagonal vertices are 1. A graph is depicted inFigure 1 and its lower-right triangular adjacency matrix is depicted in Figure 2. A B CDE
Figure 1
A graph
Figure 2
The lower-right trian-gular adjacency matrix of the graphof Figure 1 as a grid graph ⊟ ⊞⊞ ⊟ ⊞ (cid:31) ⊟⊟ (cid:31) ⊟ ⊞⊞ ⊟ ⊞ (cid:31) Figure 3
A run. Three tiles B,C and E gets weights 1, and hencethe weight of this run is 3.
We will now construct a WTS over the tropical semiring max-plus- N that computes theclique number on a lower triangular grid graph. The run of the WTS will guess a subset ofvertices of the original graph (corresponds to labeling some diagonal elements with state (cid:1) )and checks that there is an edge between every pair of these (corresponds to checking thelabel is 1, if the row and column end in a (cid:1) -labeled vertex). The weight of such a run will bethe size of the subset, and the max over all the runs gives us the clique number as required.Let Q = { (cid:1) , (cid:12) , (cid:12) , (cid:31) } . A run will label a subset of diagonal vertices with (cid:1) . A vertex islabeled with (cid:12) (resp. (cid:12) , (cid:1) ) if its column (resp. row, both) starts in a vertex labeled (cid:1) . Inaddition a vertex may get state (cid:1) only if its label is 1. All other vertices get state (cid:31) . A runon the graph in Figure 2 is depicted in Figure 3.Tiles for diagonal vertices are given by ∆ (∅ , Γ out ) = {( f ∅ , (cid:31) , , f out ) , ( f ∅ , (cid:1) , , f out )} . Foran inside vertex we have ( f out being arbitrary in all tuples):∆ ({→ , ↓} , Γ out ) = {( f in , (cid:31) , b, f out ) ∣ b ∈ { , } , f in (→) ∈ { (cid:12) , (cid:31) } , f in (↓) ∈ { (cid:12) , (cid:31) }}∪ {( f in , (cid:1) , , f out ) ∣ f in (→) ∈ { (cid:1) , (cid:12) } , f in (↓) ∈ { (cid:1) , (cid:12) }}∪ {( f in , (cid:12) , b, f out ) ∣ b ∈ { , } , f in (→) ∈ { (cid:1) , (cid:12) } , f in (↓) ∈ { (cid:12) , (cid:31) }}∪ {( f in , (cid:12) , b, f out ) ∣ b ∈ { , } , f in (→) ∈ { (cid:12) , (cid:31) } , f in (↓) ∈ { (cid:1) , (cid:12) }} . The weight of a tile of the form ( f ∅ , (cid:1) , , f out ) is 1. Notice that only the diagonal verticeslabeled (cid:1) will get such a tile. The weight of all other tiles is 0. Thus the weight of a run . Aiswarya and P. Gastin 5 is the number of diagonal vertices labeled (cid:1) - which corresponds to a subset of verticesinducing a clique. The maximum weight across different runs will compute the clique numberas required. (cid:74)(cid:73) Example 4 (A WTS to compute the permanent of a (0,1)-matrix) . We will model (0,1)-matrices as (0,1)-labelled grids. As in Example 3, we let Γ = {→ , ↓} and Σ = { , } . A 5 × T on such graphs over Natural such that [[T ]]( G ) is the permanentof the 0,1 matrix A represented by G . In each run exactly one vertex in each row and eachcolumn will be circled – representing one permutation σ of { , . . . , n } if G is an n × n grid. Theweight of the tile on the circled vertex will be the vertex label (0 or 1) interpreted as an integer.Every other tile will have weight 1. Thus the weight of a run will be ∏ i A ( i, σ ( i )) where σ is the permutation represented by the run. Finally the value of a graph G representing an n × n ( , ) -matrix A will be ∑ σ ∏ i A ( i, σ ( i )) which is its permanent.The WTS T has five states: Q = {◯ , ˝ , (cid:204) , ˇ , ˛} . We will define tiles so as to acceptonly the labeling reflecting the following:a vertex labeled ◯ means it is the circled vertex in its row and column,a vertex v labeled ˝ means that the circled vertex in its column is upward of v , and thecircled vertex in its row is to the right of v ,similarly for other states (cid:204) , ˇ , ˛ .The tiles are given formally below. The weight function wgt assigns weight 0 to any tilelabeling a 0 labeled node with ◯ . The weight of all other tiles is 1. A run of this WTS isillustrated in Figure 5. Figure 4
A 5 × ÎÎ◯ÏÏÎÎÍ◯ÏÎ◯ÌÌÏÎÍÍÍ◯◯ÌÌÌÌ
Figure 5
A run of the WTS T on the graph inFig. 4. It has weight 0 as two tiles have wgt We now describe the tiles formally. For the top-left vertex we have∆ (∅ , {→ , ↓}) = {( f ∅ , ◯ , b, f out ) ∣ b ∈ { , } , f out (→) = ˇ , f out (↓) = ˝}∪ {( f ∅ , (cid:204) , b, f out ) ∣ b ∈ { , } , f out (→) ∈ {(cid:204) , ◯} , f out (↓) ∈ {(cid:204) , ◯}} The tiles for other corner vertices are analogous. For the left border vertices we have∆ ({↓} , {→ , ↓}) ={( f in , ◯ , b, f out ) ∣ b ∈ { , } , f in (↓) = (cid:204) , f out (→) ∈ {ˇ , ˛} , f out (↓) = ˝}∪ {( f in , (cid:204) , b, f out ) ∣ b ∈ { , } , f in (↓) = (cid:204) , f out (→) ∈ {˝ , (cid:204) , ◯} , f out (↓) ∈ {(cid:204) , ◯}}∪ {( f in , ˝ , b, f out ) ∣ b ∈ { , } , f in (↓) ∈ {˝ , ◯} , f out (→) ∈ {˝ , (cid:204) , ◯} , f out (↓) = ˝} Weighted Tiling Systems for Graphs: Evaluation Complexity
The tiles for other border vertices are analogous. For an interior vertex, we have∆ ({→ , ↓} , {→ , ↓}) = {( f in , ◯ , b, f out ) ∣ b ∈ { , } , f in (↓) ∈ {ˇ , (cid:204)} , f in (→) ∈ {˝ , (cid:204)} ,f out (→) ∈ {˛ , ˇ} , f out (↓) ∈ {˛ , ˝}}∪ {( f in , (cid:204) , b, f out ) ∣ b ∈ { , } , f in (↓) ∈ {ˇ , (cid:204)} , f in (→) ∈ {˝ , (cid:204)} ,f out (→) ∈ {˝ , ◯ , (cid:204)} , f out (↓) ∈ {ˇ , ◯ , (cid:204)}}∪ {( f in , ˝ , b, f out ) ∣ b ∈ { , } , f in (↓) ∈ {˛ , ◯ , ˝} , f in (→) ∈ {˝ , (cid:204)} ,f out (→) ∈ {˝ , ◯ , (cid:204)} , f out (↓) ∈ {˛ , ˝}}∪ {( f in , ˛ , b, f out ) ∣ b ∈ { , } , f in (↓) ∈ {˛ , ◯ , ˝} , f in (→) ∈ {˛ , ◯ , ˇ} ,f out (→) ∈ {˛ , ˇ} , f out (↓) ∈ {˛ , ˝}}∪ {( f in , ˇ , b, f out ) ∣ b ∈ { , } , f in (↓) ∈ {ˇ , (cid:204)} , f in (→) ∈ {˛ , ◯ , ˇ} ,f out (→) ∈ {˛ , ˇ} , f out (↓) ∈ {ˇ , ◯ , (cid:204)}} Finally, we describe the weight function wgt . The weight of a tile of the form ( f in , ◯ , , f out ) is 0. The weight of all other tiles is 1. (cid:74)(cid:73) Example 5 (Permanent of matrix with entries from N ) . The purpose of this example is toillustrate that it is possible to encode natural numbers, which may appear as matrix entriesor edge weights, also as bounded degree graphs with a fixed alphabet Σ.A length k bit string b k − ⋯ b b where b i ∈ { , } for all 0 ≤ i < k , is represented by a pathgraph of length k . The vertices of this path graph are labelled with 1 or 0 to indicate thevalue of the bit, and the edges are labeled ≺ . We describe a WTS on such path graphs whosecomputed weight is the binary number ∑ i b i i . The WTS guesses a prefix ending with label1. All the nodes in the prefix take state q and all nodes after the prefix may take the twostates q or q . The weight of all tiles is 1. The number of runs is ∑ i ∶ b i = k − i × i = ∑ i b i i .As before, we will have an n × n grid graph to represent the matrix, but the vertices ofthe grid graph take a neutral label, say X . A path graph originates from every vertex of thegrid graph indicating the entry of the matrix at that cell. Now, to compute the permanent,the path graphs starting from a circled vertex can start the WTS described in the previousparagraph. All other path graphs vertices can be labeled only by a special state q . Theweights of all permissible tiles are 1. The weight computed by one permutation will indeedbe the product of the entries. This crucially depends on the distributivity of the semiring.Thus, this WTS computes the permanent of an arbitrary matrix with entries in N . (cid:74) Evaluation problem (Eval) is to compute [[T ]]( G ) , given the following input: T : a WTS over ( Γ , Σ ) -graphs and a semiring S , and G : a ( Γ , Σ ) -graph. We study the complexity of this problem in Section 3, for various semirings. We provide anefficient algorithm for this problem in the case of bounded tree-width graphs in Section 4. InSection 5 we discuss the decision variants of the above problem.
Recall that we only consider the boolean semiring, the counting semirings over N , Z , Q or Q ≥ and the tropical semirings over N or Z .Given a WTS T and a graph G , we can compute [[T ]]( G ) in polynomial space as follows.Initialise the current aggregate to 0 S . Enumerate in lexicographic order through the different . Aiswarya and P. Gastin 7 labelings of the vertices of G with states of T . For each labeling, if it conforms to ∆, computeits weight and add to the current aggregate. Thus Eval belongs to
FPSpace — the set offunctions computable in polynomial space. (cid:73)
Theorem 6.
Problem
Eval is in
FPSpace . However, for particular semirings the complexity is different as stated in the followingsubsections. (+ , ×) -semirings (cid:73) Theorem 7.
The evaluation problem is
P-complete over
Natural , and non-negative
Rational . It is GapP-complete over
Integer and
Rational . The upper bounds hold for arbitrary graphs, and the lower bounds hold for the specialcase of grids. The weights can be assumed to be given in binary.A function f is in M such that f ( x ) = M ( x ) . That is, itdenotes the set of function problems that correspond to counting the number of acceptingpaths in a non-deterministic polynomial time turing machine. Computing the permanentof a (0,1)- matrix is a f ( x ) is in GapP if there is a non-deterministic polynomial time turing machine M such that f ( x ) = M ( x ) − M ( x ) . GapP is also the closure of Natural and
Integer . After thatwe give reductions from respective counting versions of SAT to prove the lower bounds. Thecase of
Rational is finally considered.
The Turing Machine M such that M(T , G ) = [[T ]]( G ) : We describe a non-determinsitcpolynomial time turing machine M that takes as input a WTS T over Natural with weightsgiven in binary, and a graph G . The number of accepting runs M(T , G ) = [[T ]]( G ) . Weassume the states, weights etc. are given by some standard encoding.The turing machine M non-deterministically guesses a labeling of the vertices of G by thestates of T . Then it computes the product w of the weights of the tiles in the guessed tilingand writes it in binary (MSB on the left) in a different tape. Computing the product can bedone in time polynomial in ∣ G ∣ and log ( k ) where k = max { x ∣ x is a weight of some tile of T } .Afterwards it enters a phase which will have exactly w different accepting branches.Simply decrementing the value while it is positive, and non-deterministically accepting atany step will have w accepting branches, but the running time is exponential. We want themachine to run in polynomial time. Hence we implement this phase similar to Example 5. Itruns in O(∣ w ∣) steps as we detail below. M scans w from left to right starting in some state q . While in state q and the currentcell is labeled 0 it moves right. If in state q and the current cell is labelled 1 it moves rightand non determistically stays in state q or enters one of the two special states q or q . Whenit is in state q or q and the current cell is labelled with 0 or 1, it will move right and nondeterministically chose either q or q . Finally, When in state q or q and the current cell is blank (i.e., the scan of w is over), then M accepts. Thus if the i th bit from the right of w is labeled 1, then M can have 2 i accepting runs if it moved from state q to q or q when Weighted Tiling Systems for Graphs: Evaluation Complexity reading this bit. Switching from state q can occur at any 1-labelled cell, and hence M willhave w many accepting runs.The machine M non deterministically picks a labeling at first, and hence the totalnumber of accepting runs M(T , G ) = [[T ]]( G ) . With this we prove the Natural . The Turing Machine M ′ such that M ′ (T , G ) − M ′ (T , G ) = [[T ]]( G ) : This is similarto the machine M above. There are two differences. The machine M ′ still guesses alabeling of vertices of G with states of T over Integer and computes the weight w . If w ispositive, it proceeds exactly as M does to produce w accepting runs. If the weight w isnegative, the machine M ′ proceeds analogously but with states q ′ , q ′ and q ′ instead. Ifthe machine is in state q ′ or q ′ with current cell blank then it rejects instead of accepting.The second difference is for blocked runs (e.g., if the guessed labeling of vertices of G bystates of T is not a valid tiling, or if at the end the machine is still in state q or q ′ withcurrent cell blank ). In such a case, M ′ will non-deterministically proceed to either accept orreject. Thus the net difference between accepting runs and rejecting runs is kept intact and M ′ (T , G ) − M ′ (T , G ) = [[T ]]( G ) . This proves the GapP upper bound for Integer . Encoding a CNF formula ϕ in a grid G ϕ : Given a CNF formula ϕ with n variables and m clauses, we encode it in an n × m grid with node labels { p, n, ⋆} . If the node ( i, j ) islabeled by p (resp. n ) it means that the i th variable appears in j th clause positively (resp.negatively). The node ( i, j ) is labeled ⋆ if the i th variable does not occur in the j th clause. A WTS T over Natural for counting ϕ : Recall that ϕ is the number of satisfyingassignments for the formula ϕ . We assume input to the WTS T is given as G ϕ — a { p, n, ⋆} -labeled grid encoding a CNF formula.A state of T is a pair from { q true , q false } × { q ′ true , q ′ false } . The first part of a state indicatesa truth assignment with q true and q false . The allowed tiles make sure that in this part thetruth assignment remains the same along a row. The second part of a state indicates with q ′ true and q ′ false the partial evaluation of the formula. A p -labeled node which is assigned q true from the first part, and an n -labeled node which is assigned q false from the first part gets thevalue q ′ true in the second part of the state (call this condition A for future reference). Furtherall the successor nodes in the column of the q ′ true labeled node also gets the value q ′ true , exceptfor the nodes in the last row. For the nodes in the last row, it gets the value q ′ true if the leftneighbour is labeled q ′ true (assume this is satisfied if the left neighbour does not exist), and a)if it satisfies condition A or b) if the node above is labeled q ′ true . Otherwise the nodes get thevalue q ′ false . The second part of a state labeling a node ( n, j ) in the last row indicates theevaluation of the prefix of the formula until the j th clause.The tiles capture the description above. The weight of all tiles is 1, except for the tilelabeling the last node ( n, m ) . If it is labeled (− , q ′ true ) then the weight is 1, otherwise it is 0.The value [[T ]]( G ϕ ) = ϕ , the number of satisfying assignments.This proves the Natural . As alluded to earlier, the permanentcomputation (Example 4) gives an alternate lower bound proof.
A WTS T gap over Integer for counting ϕ − ϕ : We will reduce the GapP-completeproblem of computing ϕ − ϕ , where ϕ and ϕ are input CNF formulas on the same setof n variables with m and m clauses respectively. We represent the input in an n ×( m + m ) grid by putting G ϕ and G ϕ side by side. The node labels contain a special tag i ∈ { , } to . Aiswarya and P. Gastin 9 indicate that it comes from G ϕ i . The WTS T gap will ensure that rows are of the form 1 ∗ ∗ and columns are of the form 1 ∗ or 2 ∗ . In a run it evaluates either ϕ or ϕ similar to T . Ifit is evaluating ϕ i all nodes with the tag 3 − i gets a special state q skip . The weight of all tilesis 1, except for the tile labeling the nodes ( n, m ) and ( n, m + m ) . If the node ( n, m ) islabeled (− , q ′ true ) or q skip then the weight is 1, otherwise it is 0. If the node ( n, m + m ) islabeled (− , q ′ true ) (resp. q skip ) then the weight is − Rational
We will use counting reduction from
Rational (resp. non-negative
Rational ) to theevaluation problem over
Integer (resp.
Natural ) in order to prove the upper bounds. First wewill transform an input (T , G ) of the evaluation problem over Rational (resp. non-negative
Rational ) to an input (T ′ , G, ) over Integer (resp.
Natural ). In T ′ we will multiply the weightof a tile by ‘ - the lcm of the denominators appearing in the weights of any tile of T . Themultiplication can be performed in time polynomial. Now T ′ is a WTS over Integer (resp.
Natural ), and following the GapP procedure (resp. [[T ′ ]]( G ) .Now, we transform the output back to the required output over Rational (resp. non-negative
Rational ) by dividing with ‘ ∣ V G ∣ . That is, Eval ( G, A) =
Eval ( G, A ′ ) ‘ ∣ VG ∣ .Notice that we allow the weights to be given in binary. The lcm ‘ and ‘ ∣ V G ∣ can becomputed in polynomial time. The counting reduction is hence polynomial. This proves theupper bounds.The GapP-hardness (resp. Integer (resp.
Natural ) is a specialcase of
Rational (resp. non-negative
Rational ). Note that the evaluation problem
Eval over
Boolean is in fact the classical Membershipproblem (denoted
Membership ) and is indeed a decision problem. We can check in NPwhether the value is 1 (witnessed by the NP machine M , if the input is assumed to beover Boolean then × serve as ∧ ). It is also NP-hard by a simple reduction from CNF SAT(witnessed by T interpreted over Boolean ). (cid:73) Theorem 8.
Membership is NP-complete. (cid:73)
Theorem 9.
We assume the weights are given in unary. The evaluation problem over anytropical semiring is FP NP [ log ] -complete. FP NP [ log ] is the class of functions computable by a polynomial time turing machine withlogarithmically many queries to NP. Proof.
We will prove the upper bound for max-plus- Z . The case of max-plus- N is subsumed.The cases of min-plus- N and min-plus- Z are analogous.Let k be the maximal constant and ‘ be the minimal constant (other than +/ − ∞ )appearing in the WTS A . The maximum possible weight of a run is n × k and the minimumis n × ‘ where n is the number of vertices in the input graph. We will do a binary searchin the set W = { n × ‘, . . . , − , , , . . . , n × k } checking if [[A]]( G ) ≥ s to find the value of [[A]]( G ) . In each iteration of the binary search, we make an oracle call to the NP machinefor [[A]]( G ) ≥ s . The number of NP oracle queries is O( log ( n × k )) which is only logarithmicin the input size. Recall that the weights are encoded in unary.Finding the clique number is an FP NP [ log ] -complete problem [19]. From Example 3, thelower bound follows. (cid:74) In this section, we show that the problem
Eval can be solved efficiently when restricted tographs of bounded tree-width (the bound is not part of the input). By efficient, we meantime polynomial wrt. the WTS T and linear wrt. the graph G (see Theorems 13 and 16below). Bounded tree-width covers many graphs used to model behaviours of concurrent orinfinite-state systems. For example, it is well-known that words and trees have tree-width 1,nested words used for pushdown systems have tree-width 2, Mazurkiewicz traces describingbehaviours of concurrent asynchronous systems with rendez-vous, and most decidable under-approximations of Turing complete models such as multi-pushdown automata, messagepassing automata with unbounded FIFO channels, etc. [22, 9, 4]. We start by explaining ourresults for bounded path-width since this is technically simpler. Then we explain how this isextended to bounded tree-width. A path decomposition of a ( Γ , Σ ) -graph G = ( V, ( E γ ) γ ∈ Γ , λ ) , is a sequence V , . . . , V n ofnonempty subsets of vertices satisfying: for all v ∈ V , we have v ∈ V i for some 1 ≤ i ≤ n , for all ( u, v ) ∈ ⋃ γ ∈ Γ E γ , we have u, v ∈ V i for some 1 ≤ i ≤ n , for all 1 ≤ i ≤ j ≤ k ≤ n , we have V i ∩ V k ⊆ V j .The width of the path decomposition is max {∣ V i ∣ − ∣ ≤ i ≤ n } . The path-width of a graph G is the least k such that G admits a path decomposition of width k .Words have path-width 1, but trees, nested words, grids have unbounded path-width.We present below an equivalent definition of path-width which will be convenient to solvethe evaluation problem on graphs with bounded path-width. Let [ k ] = { , , . . . , k } . Graphsover ( Γ , Σ ) of path-width at most k can be described with words over the alphabetΩ k = {( i, a ) ∣ i ∈ [ k ] , a ∈ Σ } ∪ { Forget i ∣ i ∈ [ k ]} ∪ { Add γi,j ∣ i, j ∈ [ k ] , γ ∈ Γ } The semantics of a word τ ∈ Ω ∗ k is a colored graph {∣ τ ∣} = ( G τ , χ τ ) where G τ is a ( Γ , Σ ) -labeledgraph and χ τ ∶ [ k ] → V is a partial injective function coloring some vertices of G τ . We saythat a color i ∈ [ k ] is active in τ if it is in the domain of χ τ . The semantics is defined byinduction on the length of τ . The semantics of the empty word τ = ε is the empty graph.Assuming that {∣ τ ∣} = ( V, ( E γ ) γ ∈ Γ , λ, χ ) , we define the effect of appending a new letter to τ : ( i, a ) adds a new a -labeled vertex with color i , provided i is not active in τ , Forget i removescolor i from the domain of the color map, and Add αi,j adds an α -labeled edge between thevertices colored i and j (if such vertices exist, i.e., if i, j are active in τ ). Formally, {∣ τ ⋅ ( i, a )∣} = ( V ′ , ( E γ ) γ ∈ Γ , λ ′ , χ ′ ) is defined if i ∉ dom ( χ ) and in this case V ′ = V ⊎ { v } , λ ′ ( v ) = a and λ ′ ( u ) = λ ( u ) for all u ∈ V , dom ( χ ′ ) = dom ( χ ) ⊎ { i } , χ ′ ( i ) = v and χ ′ ( j ) = χ ( j ) for all j ∈ dom ( χ ) . {∣ τ ⋅ Forget i ∣} = ( V, ( E γ ) γ ∈ Γ , λ, χ ′ ) with dom ( χ ′ ) = dom ( χ ) ∖ { i } and χ ′ ( j ) = χ ( j ) for all j ∈ dom ( χ ′ ) . {∣ τ ⋅ Add αi,j ∣} = ( V, ( E ′ γ ) γ ∈ Γ , λ, χ ) with E ′ γ = E γ if γ ≠ α and E ′ α = ⎧⎪⎪⎨⎪⎪⎩ E α if { i, j } /⊆ dom ( χ ) E α ∪ {( χ ( i ) , χ ( j ))} otherwise.We say that a word τ over Ω k is well-formed if the following conditions are satisfied: if τ ′ ⋅ ( i, a ) is a prefix of τ then i is not active in τ ′ , . Aiswarya and P. Gastin 11 if τ ′ ⋅ Forget i is a prefix of τ then i is active in τ ′ , if τ ′ ⋅ Add γi,j is a prefix of τ then i, j are active in τ ′ and the edge labeled γ was not alreadyadded in τ ′ between χ τ ′ ( i ) and χ τ ′ ( j ) .In the following, a well-formed word over Ω k is called a k - word . The set W k ⊆ Ω ∗ k of k - words is clearly regular. (cid:73) Lemma 10. 1.
Given a path decomposition V , . . . , V N of width at most k of a ( Γ , Σ ) -graph G , we can construct in linear time wrt. ∣ G ∣ a k - word τ such that {∣ τ ∣} = ( G, ∅) . Given a k − word τ , we can construct a path decomposition of width at most k of the graph G τ defined by τ : {∣ τ ∣} = ( G τ , χ τ ) . Proof. We construct by induction a sequence of k - words τ ‘ for 0 ≤ ‘ ≤ N such that {∣ τ ‘ ∣} = ( G ‘ , χ ‘ ) where G ‘ is the subgraph of G = ( V, ( E γ ) γ ∈ Γ , λ ) induced by the vertices V ∪ ⋯ ∪ V ‘ , and χ ‘ ([ k ]) = V ‘ ∩ V ‘ + (with V = V N + = ∅ ). We let τ = (cid:15) .Let now 0 ≤ ‘ < N and assume that τ ‘ has been constructed. Let C ‘ = dom ( χ ‘ ) ⊆ [ k ] be theactive colors in τ ‘ . By induction, we know that ∣ C ‘ ∣ = ∣ V ‘ + ∩ V ‘ ∣ . Let V ‘ + ∖ V ‘ = { u , . . . , u m } .Since the decomposition is of width at most k , we have ∣ V ‘ + ∣ ≤ + k and we find i < ⋯ < i m available colors in [ k ]∖ C ‘ . We define τ ′ ‘ + = τ ‘ ⋅( i , λ ( u ))⋯( i m , λ ( u m )) . Let D = { i , . . . , i m } and let {∣ τ ′ ‘ + ∣} = ( G ′ , χ ′ ) . We have dom ( χ ′ ) = C ‘ ∪ D , χ ′ ( C ‘ ) = V ‘ + ∩ V ‘ and χ ′ ( D ) = V ‘ + ∖ V ‘ .For each γ ∈ Γ, i ∈ C ‘ ∪ D and j ∈ D such that ( χ ′ ( i ) , χ ′ ( j )) ∈ E γ (resp. ( χ ′ ( j ) , χ ′ ( i )) ∈ E γ ),we append Add γi,j (resp.
Add γj,i ) to the word τ ′ ‘ + . We obtain a k - word τ ′′ ‘ + which defines thesubgraph G ‘ + of G induced by V ∪ ⋯ ∪ V ‘ + . Notice that, from the third condition of apath decomposition, we have V ‘ + ∖ V ‘ = V ‘ + ∖ ( V ∪ ⋯ ∪ V ‘ ) and the edges in G ‘ + whichwere not already in G ‘ are between some vertex in V ‘ + ∖ V ‘ and some vertex in V ‘ + . Finally,for each i ∈ C ‘ ∪ D such that χ ′ ( i ) ∉ V ‘ + , we append Forget i to the word τ ′′ ‘ + . We obtainthe k - word τ ‘ + satisfying our invariant.Finally, from the invariant we deduce that {∣ τ N ∣} = ( G, ∅) , which concludes the first partof the proof. Let τ be a k - word and n = ∣ τ ∣ be its length. For 0 ≤ ‘ ≤ n , let τ ‘ be the prefix of τ of length ‘ . Let {∣ τ ‘ ∣} = ( G ‘ , χ ‘ ) and V ‘ = χ ‘ ([ k ]) be the subset of vertices which are colored in {∣ τ ‘ ∣} .We show that V , . . . , V n is a path decomposition of G = G n = ( V, ( E γ ) γ ∈ Γ , λ ) .Let u ∈ V be a vertex of G . For some 1 ≤ ‘ ≤ n , we have τ ‘ = τ ‘ − ⋅ ( i, a ) with χ ‘ ( i ) = u ∈ V ‘ .This proves that the first condition of a path decomposition is satisfied.Let ( u, v ) ∈ E γ for some γ ∈ Γ. For some 1 < ‘ < n , we have τ ‘ + = τ ‘ ⋅ Add γi,j with χ ‘ ( i ) = u and χ ‘ ( j ) = v . We deduce that u, v ∈ V ‘ , which proves that the second condition of a pathdecomposition is satisfied.For the third condition, let 1 ≤ i ≤ j ≤ m ≤ n and u ∈ V i ∩ V m . We deduce that for some ‘ ∈ [ k ] , we have u = χ i ( ‘ ) = χ m ( ‘ ) and that color ‘ was not forgotten between τ i and τ m .Therefore, u = χ j ( ‘ ) ∈ V j as desired. (cid:74) Existentially bounded graphs.
Another characterization of bounded path-width is thenotion of existentially-bounded graphs [9, 4]. Let G = ( V, ( E γ ) γ ∈ Γ , λ ) be a ( Γ , Σ ) graph and k > G is existentially k -bounded ( ∃ k -bounded) if there is a linearorder < on the vertices of G such that for all v ∈ V , the number of vertices u ≤ v connectedto some vertices w > v is at most k : ∣{ u ∈ V ∣ u ≤ v and ( u, w ) ∈ ⋃ γ ∈ Γ E γ ∪ E − γ for some w > v }∣ ≤ k . (1) A linear order < satisfying (1) is called k -bounded .Words are ∃ ∃ K -bounded where K is the number of processes. Message sequence charts (MSCs) arenot existentially bounded in general. But existentially bounded MSCs is a fundamentalwell-behaved under-approximation for message passing automata with unbounded FIFOchannels. (cid:73) Example 11. An m × n grid is existentially min ( m, n ) -bounded. Indeed, the set of verticesof an m × n grid is V = { , . . . , m } × { , . . . , n } . We have horizontal and vertical edges: E → = {(( i, j ) , ( i, j + )) ∣ ≤ i ≤ m, ≤ j < n } E ↓ = {(( i, j ) , ( i + , j )) ∣ ≤ i < m, ≤ j ≤ n } Assuming that n ≤ m , we define a linear order on V by listing the first row, then the secondrow, etc. ( , ) < ⋯ < ( , n ) < ( , ) < ⋯ < ( , n ) < ⋯ < ( m, ) < ⋯ < ( m, n ) . It is easy to check that this linear order is n -bounded. If m < n then we list the verticescolumn by column. (cid:73) Lemma 12.
A graph G is ∃ k -bounded if and only if its path-width is at most k . Proof.
Let G = ( V, ( E γ ) γ ∈ Γ , λ ) be a ( Γ , Σ ) graph and let τ be a k - word with {∣ τ ∣} = ( G, χ ) .Let < be the linear order on V corresponding to the order in which the vertices of G arecreated by τ . We show that < is k -bounded. Let v ∈ V be a vertex. We have to showthat there are at most k vertices u ≤ v which are connected to some vertex w > v . This isobvious if v is one of the first k vertices wrt. the linear order < . Let τ ′ be the prefix of τ which ends in the creation of v : τ ′ = τ ′′ ⋅ ( ‘, a ) , {∣ τ ′ ∣} = ( G ′ , χ ′ ) and χ ′ ( ‘ ) = v . Let u ≤ v < w with ( u, w ) ∈ E γ ∪ E − γ for some γ ∈ Γ. Let i, j be the colors of u and w when they wererespectively added. The edge between u and w was added with Add γi,j or Add γj,i after thecreation of w , hence after the prefix τ ′ of τ . We deduce that color i was not forgotten at τ ′ and i ∈ dom ( χ ′ ) . Therefore, the set U of vertices u ≤ v which are connected to some vertex w > v is contained in χ ′ ([ k ]) . If ∣ dom ( χ ′ )∣ ≤ k then ∣ U ∣ ≤ k and we are done. Otherwise, wehave dom ( χ ′ ) = [ k ] . Assume U ≠ ∅ and let u ≤ v < w with ( u, w ) ∈ E γ ∪ E − γ for some γ ∈ Γ.Let j be the color of w when it was created. Since j ∈ dom ( χ ′ ) , we must see Forget j betweenthe creation of v at τ ′ and the creation of w . Let τ ′′ be the least prefix of τ which ends withsome Forget m operation and such that τ ′ is a prefix of τ ′′ . With {∣ τ ′′ ∣} = ( G ′′ , χ ′′ ) , we have dom ( χ ′′ ) = [ k ] ∖ { m } and χ ′′ ([ k ]) contains exactly k vertices. As above, we can show that U ⊆ χ ′′ ([ k ]) , which concludes this direction of the proof.Let G = ( V, ( E γ ) γ ∈ Γ , λ ) be a ( Γ , Σ ) graph and let < be a linear order on V which is k -bounded. We assume that V = { v , . . . , v n } with v < ⋯ < v n . For each 0 ≤ ‘ ≤ n , weconstruct by induction a k - word τ ‘ which describes the subgraph of G induced by thevertices { v , . . . , v ‘ } , keeping colors on vertices v i which are still missing some edges, i.e., ( v i , v j ) ∈ ⋃ γ ∈ Γ E γ ∪ E − γ with 1 ≤ i ≤ ‘ < j ≤ n . We start with τ = ε .Now, let 1 ≤ ‘ ≤ n and assume that τ ‘ − is already defined. Let C ‘ − ⊆ [ k ] = { , , . . . , k } be the set of active colors in τ ‘ − . Since the linear order < is k -bounded, we have ∣ C ‘ − ∣ ≤ k Notice that the bound is on the number of vertices and not on the number of edges ( u, w ) crossing over v , i.e., with u ≤ v < w . But when the graph has bounded degree, the bound on the number of verticesinduces a bound on the number of crossing edges. . Aiswarya and P. Gastin 13 and we let i = min ([ k ] ∖ C ‘ − ) . We add the new vertex v ‘ by considering τ ′ ‘ = τ ‘ − ⋅ ( i, λ ( v ‘ )) .Then, we obtain τ ′′ ‘ by adding all edges connecting v ‘ with earlier vertices. Assume that ( v m , v ‘ ) ∈ E γ (resp. ( v ‘ , v m ) ∈ E γ ) for some 1 ≤ m < ‘ and γ ∈ Γ. Then, from our invariant, v m has some color j ∈ C ‘ − in τ ‘ − (hence also in τ ′ ‘ ). We append to the current word Add γj,i (resp.
Add γi,j ). Finally, we obtain τ ‘ from τ ′′ ‘ by forgetting colors of completed vertices. If v m is the vertex corresponding to some active color j ∈ C ‘ − ∪ { i } and v m is connected only tovertices in { v , . . . , v ‘ } , then we append Forget j to the current word. Notice that the set C ‘ of active colors in τ ‘ satisfies C ‘ ⊆ C ‘ − ∪ { i } and ∣ C ‘ ∣ ≤ k since < is k -bounded.Finally, we have {∣ τ n ∣} = ( G, ∅) , which completes the proof. Notice that the constructionof the k − word τ from the k -bounded linearization < takes linear time. (cid:74) Solving the evaluation problem in polynomial time.
The problem k - PW - FVal is to compute [[T ]]( G ) , given a WTS T and a ( Γ , Σ ) -graph G of path-width at most k . (cid:73) Theorem 13.
The problem k - PW - FVal can be solved in linear time wrt. the input graph G and polynomial time wrt. the input WTS T . Proof.
The evaluation algorithm for bounded path-width graphs proceeds in three steps: From the input graph G , which is assumed to be of path-width at most k , we computein linear time a path decomposition V , . . . , V n using Bodlaender’s algorithm [3]. Then,using Lemma 10, we compute in linear time a k - word τ such that {∣ τ ∣} = ( G, ∅) . By Lemma 14 below, we construct in time polynomial in T a weighted word automaton B k which is equivalent to T on graphs of path-width at most k . Equivalent means thatfor all k - words τ with {∣ τ ∣} = ( G, ∅) , we have [[T ]]( G ) = [[B k ]]( τ ) . We compute [[B k ]]( τ ) . It is well-known that the value of a weighted word automaton B on a given word w can be computed in time O(∣B∣ ⋅ ∣ w ∣) assuming that sum and productin the semiring take constant time. For the sake of completeness, we give details inLemma 15. Alternatively, we may use Algorithm 1 which achieves the same complexityin the more general case of weighted tree automata. (cid:74) A weighted word automaton over alphabet Σ is usually given as a tuple
B = (
Q, T, I, F, wgt ) where I, F ⊆ Q are the subsets of initial and final states, T ⊆ Q × Σ × Q defines the transitionsand wgt ∶ T → S gives weights to transitions. This is an equivalent representation of a WTSover ({→} , Σ ) . (cid:73) Lemma 14.
Given a WTS T over ( Γ , Σ ) -graphs and k > , we can compute in polynomialtime wrt. T , a weighted word automaton B k which is equivalent to T over graphs of pathwidth at most k . That is, for all k - words τ with {∣ τ ∣} = ( G, ∅) , we have [[T ]]( G ) = [[B k ]]( τ ) . Proof.
Let
T = ( Q, ∆ , wgt ) be a WTS over ( Γ , Σ ) -graphs. By adding tiles with weight 0 S ,we may assume wlog that ∆ contains all possible tiles. Fix k ≥ B k is a partial map δ ∶ [ k ] → ∆. When reading a k - word τ with {∣ τ ∣} = ( G, χ ) ,the automaton will guess a labelling ρ ∶ V → Q of vertices of G with states of T and will reacha state δ satisfying the following two conditions: dom ( δ ) = dom ( χ ) ⊆ [ k ] is the set of active colors, for each active color i ∈ dom ( χ ) , δ ( i ) = ( f in ( i ) , q ( i ) , a ( i ) , f out ( i )) = tile ρ ( χ ( i )) is thecurrent ρ -tile at vertex χ ( i ) in G .The only initial state is the empty map δ ∅ with dom ( δ ∅ ) = ∅ . This is also the only finalstate, which is reached on a k - word τ if all colors have been forgotten: {∣ τ ∣} = ( G, χ ∅ ) .Transitions of the word automaton B k are given in Table 1. As above, we write δ ( i ) =( f in ( i ) , q ( i ) , a ( i ) , f out ( i )) and δ ′ ( i ) = ( f ′ in ( i ) , q ′ ( i ) , a ′ ( i ) , f ′ out ( i )) . δ ( i,a ) ——→ δ ′ if i ∉ dom ( δ ) . Then, dom ( δ ′ ) = dom ( δ ) ∪ { i } , δ ′ ( j ) = δ ( j ) for all j ∈ dom ( δ ) , and δ ′ ( i ) = ( f ∅ , q, a, f ∅ ) for some q ∈ Q .The weight of this transition is 1 S . δ Forget i ———→ δ ′ if i ∈ dom ( δ ) . Then δ ′ is the restriction of δ to dom ( δ ′ ) = dom ( δ ) ∖ { i } .The weight of this transition is wgt ( δ ( i )) . δ Add γi,j ———→ δ ′ if i, j ∈ dom ( δ ) , i ≠ j , γ ∉ dom ( f out ( i )) and γ ∉ dom ( f in ( j )) .Then, dom ( δ ′ ) = dom ( δ ) , δ ′ ( ‘ ) = δ ( ‘ ) for all ‘ ∈ dom ( δ ) ∖ { i, j } , δ ′ ( i ) = ( f in ( i ) , q ( i ) , a ( i ) , f out ( i ) ∪ [ γ ↦ q ( j )]) , δ ′ ( j ) = ( f in ( j ) ∪ [ γ ↦ q ( i )] , q ( j ) , a ( j ) , f out ( j )) .The weight of this transition is 1 S . Table 1
Transitions of the weighted word automaton B k . The number of partial maps from A to B is ( + ∣ B ∣) ∣ A ∣ . Hence, the number of states of B k is ( + ∣ ∆ ∣) + k . In a tile ( f in , q, a, f out ) ∈ ∆, both f in and f out can be seen as partial mapsfrom Γ to Q . Hence, ∣ ∆ ∣ = ( + ∣ Q ∣) ∣ Γ ∣ ⋅ ∣ Q ∣ ⋅ ∣ Σ ∣ . Also, ∣ Ω k ∣ = ( + k )(∣ Σ ∣ + ) + ( + k ) ∣ Γ ∣ . Wededuce that, if Σ , Γ , k are fixed, the automaton B k can be constructed in polynomial timewrt. the given WTS T .Notice that we can reduce the size of B k if we only consider states δ ∶ [ k ] → ∆ suchthat for all i ∈ dom ( δ ) the tile δ ( i ) = ( f in ( i ) , q ( i ) , a ( i ) , f out ( i )) is a subtile of some tile t = ( f ′ in , q ( i ) , a ( i ) , f ′ out ) ∈ ∆ with wgt ( t ) ≠ S . By subtile we mean that f in ( i ) is the restrictionof f ′ in to dom ( f in ( i )) , i.e., f in ( i )( γ ) = f ′ in ( γ ) for all γ ∈ dom ( f in ( i )) ⊆ dom ( f ′ in ) ; and similarly f out ( i ) is the restriction of f ′ out to dom ( f out ( i )) . (cid:74) Evaluation of a weighted word automaton. (cid:73)
Lemma 15.
Given a weighted word automaton B and an input word w ∈ Σ ∗ , we cancompute [[B]]( w ) in time O(∣B∣ ⋅ ∣ w ∣) . Proof.
We defined a weighted word automaton as a tuple
B = (
Q, T, I, F, wgt ) . Anotherequivalent representation of B allows to compute efficiently the value [[B]]( w ) on a givenword w ∈ Σ ∗ . Assume that Q = { , . . . , n } . We view I ∈ { , } Q as a row vector and F ∈ { , } Q as a column vector. For each a ∈ Σ, we let µ ( a ) ∈ S Q × Q be the n × n matrixdefined by µ ( a ) i,j = wgt (( i, a, j )) ∈ S (giving weight 0 S for missing transitions, we mayassume wlog that T = Q × Σ × Q ). Square matrices over the semiring S form a monoidwith matrix multiplication. Hence, µ extends to a morphism µ ∶ Σ ∗ → S Q × Q by µ ( w ) = µ ( a ) ⋅ µ ( a )⋯ µ ( a m ) if w = a a ⋯ a m . Using distributivity of the semiring S , we obtain [[B]]( w ) = I ⋅ µ ( w ) ⋅ F = I ⋅ µ ( a ) ⋅ µ ( a ) ⋅ ⋯ ⋅ µ ( a m ) ⋅ F . Computing these products from leftto right (left associativity), we perform n products of a row vector by a matrix, and finallythe product of the resulting row vector I ⋅ µ ( a ) ⋅ µ ( a ) ⋅ ⋯ ⋅ µ ( a m ) by the column vector F .Assuming that sum and product in the semiring S take constant time, the product of a rowvector by a matrix takes time O( n ) . Hence the overall time complexity of this evaluation is O( m ⋅ n ) = O(∣ w ∣ ⋅ ∣B∣) . (cid:74) We extend the efficient evaluation of WTS for graphs of bounded path-width to graphs ofbounded tree-width, which is a larger class of graphs. For instance, nested words may haveunbounded path-width but their tree-width is at most 2. As for path-width, tree-width can . Aiswarya and P. Gastin 15 be defined via tree decompositions: instead of a sequence of subsets of vertices, we use atree of subsets of vertices. Since we will use weighted tree automata to achieve the efficientevaluation over graphs of bounded tree-width, we define directly tree terms. These are similarto k - words , with an additional binary union ⊕ . Tree terms (TTs) form an algebra to define labeled graphs. With a ∈ Σ, γ ∈ Γ and i, j ∈ [ k ] = { , , . . . , k } , the syntax of k - TTs over ( Γ , Σ ) is given by τ ∶∶= ( i, a ) ∣ Add γi,j τ ∣ Forget i τ ∣ τ ⊕ τ Each k - TT represents a colored graph {∣ τ ∣} = ( G τ , χ τ ) where G τ is a ( Γ , Σ ) -labeled graphand χ τ ∶ [ k ] → V is a partial injective function coloring some vertices of G τ . Colors in dom χ τ are said to be active in τ . The semantics is defined as for k − words : a leaf ( i, a ) creates agraph with a single a -labeled vertex with color i , Forget i removes color i from the domain ofthe color map, and Add αi,j adds an α -labeled edge between the vertices colored i and j (ifsuch vertices exist). Formally, if {∣ τ ∣} = ( V, ( E γ ) γ ∈ Γ , λ, χ ) then {∣ Add αi,j τ ∣} = ( V, ( E ′ γ ) γ ∈ Γ , λ, χ ) with E ′ γ = E γ if γ ≠ α and E ′ α = ⎧⎪⎪⎨⎪⎪⎩ E α if { i, j } /⊆ dom ( χ ) E α ∪ {( χ ( i ) , χ ( j ))} otherwise. {∣ Forget i τ ∣} = ( V, ( E γ ) γ ∈ Γ , λ, χ ′ ) with dom ( χ ′ ) = dom ( χ ) ∖ { i } and χ ′ ( j ) = χ ( j ) for all j ∈ dom ( χ ′ ) .The main difference with k - words is ⊕ which takes the union of the two graphs, mergingvertices with the same colors, if any.Formally, consider τ ′ ⊕ τ ′′ with {∣ τ ′ ∣} = ( G ′ , χ ′ ) = ( V ′ , ( E ′ γ ) γ ∈ Γ , λ ′ , χ ′ ) and {∣ τ ′′ ∣} =( G ′′ , χ ′′ ) = ( V ′′ , ( E ′′ γ ) γ ∈ Γ , λ ′′ , χ ′′ ) . Let I = dom ( χ ′ ) ∩ dom ( χ ′′ ) be the set of colors thatare defined in both graphs. Wlog, we may assume that V ′ ∩ V ′′ = χ ′ ( I ) = χ ′′ ( I ) and χ ′ ( i ) = χ ′′ ( i ) for all i ∈ I , i.e., we may rename the vertices so that the shared colors definethe shared vertices. The union τ ′ ⊕ τ ′′ is well-defined only if the shared vertices have thesame labels: λ ′ ( χ ′ ( i )) = λ ′′ ( χ ′′ ( i )) for all i ∈ I . Then, {∣ τ ′ ⊕ τ ′′ ∣} = ( G ′ ∪ G ′′ , χ ′ ∪ χ ′′ ) =( V, ( E γ ) γ ∈ Γ , λ, χ ) where V = V ′ ∪ V ′′ , λ = λ ′ ∪ λ ′′ , and E γ = E ′ γ ∪ E ′′ γ for all γ ∈ Γ.The tree-width of a nonempty graph G is the least k ≥ G = G τ for some k - TT τ .Trees have tree-width 1, and as a special case, words also have tree-width 1. Nested wordshave tree-width (at most) 2 [22]. They are words with an additional binary relation frompushes to matching pops, which are used to represent behaviours of pushdown automata. Onthe other end, grids as used for instance in Example 4, have unbounded tree-width. Moreprecisely, an n × n grid has tree-width n .We will focus on a regular subset of terms which ensures that the semantics is well-defined and that the k - TTs do not contain redundant operations such as
Add γi,j
Add γi,j τ or Add γi,j τ ⊕ Add γi,j τ . A k - TT is well-formed if the following are satisfied: if Forget i τ ′ is a subterm of τ then i is active in τ ′ , if Add γi,j τ ′ is a subterm of τ then i, j are active in τ ′ and the edge γ was not alreadyadded in τ ′ between χ τ ′ ( i ) and χ τ ′ ( j ) . if τ ′ ⊕ τ ′′ is a subterm of τ then for all i, j that are active in both τ ′ and τ ′′ , the vertices χ τ ′ ( i ) and χ τ ′′ ( i ) have the same label from Σ, and we do not already have a γ -edge bothbetween ( χ τ ′ ( i ) , χ τ ′ ( j )) and ( χ τ ′′ ( i ) , χ τ ′′ ( j )) .The problem k - TW - FVal is to compute [[T ]]( G ) , given a WTS T and a ( Γ , Σ ) -graph G of tree-width at most k . (cid:150) ( i,a ) ——→ δ if dom ( δ ) = { i } and δ ( i ) = ( f ∅ , q, a, f ∅ ) for some q ∈ Q .The weight of this transition is 1 S . δ Add γi,j ———→ δ ′ if i, j ∈ dom ( δ ) , i ≠ j , γ ∉ dom ( f out ( i )) and γ ∉ dom ( f in ( j )) .Then, dom ( δ ′ ) = dom ( δ ) , δ ′ ( ‘ ) = δ ( ‘ ) for all ‘ ∈ dom ( δ ) ∖ { i, j } , δ ′ ( i ) = ( f in ( i ) , q ( i ) , a ( i ) , f out ( i ) ∪ [ γ ↦ q ( j )]) , δ ′ ( j ) = ( f in ( j ) ∪ [ γ ↦ q ( i )] , q ( j ) , a ( j ) , f out ( j )) .The weight of this transition is 1 S . δ Forget i ———→ δ ′ if i ∈ dom ( δ ) . Then δ ′ is the restriction of δ to dom ( δ ′ ) = dom ( δ ) ∖ { i } .The weight of this transition is wgt ( δ ( i )) . δ ′ , δ ′′ ⊕ —→ δ if for all i ∈ dom ( δ ′ ) ∩ dom ( δ ′′ ) we have: q ′ ( i ) = q ′′ ( i ) , a ′ ( i ) = a ′′ ( i ) , and dom ( f ′ in ( i )) ∩ dom ( f ′′ in ( i )) = ∅ = dom ( f ′ out ( i )) ∩ dom ( f ′′ out ( i )) .Then, δ is the union of δ ′ and δ ′′ : dom ( δ ) = dom ( δ ′ ) ∪ dom ( δ ′′ ) , δ ( i ) = δ ′ ( i ) for all i ∈ dom ( δ ′ ) ∖ dom ( δ ′′ ) , δ ( i ) = δ ′′ ( i ) for all i ∈ dom ( δ ′′ ) ∖ dom ( δ ′ ) , and δ ( i ) = ( f ′ in ( i ) ∪ f ′′ in ( i ) , q ′ ( i ) , a ′ ( i ) , f ′ out ( i ) ∪ f ′′ out ( i )) for i ∈ dom ( δ ′ ) ∩ dom ( δ ′′ ) .The weight of this transition is 1 S . Table 2
Transitions of the weighted tree automaton B k . (cid:73) Theorem 16.
The problem k - TW - FVal can be solved in linear time wrt. the input graph G and polynomial time wrt. the input WTS T . Proof.
The proof follows the same three steps as for Theorem 13 using tree terms instead of k - words and weighted tree automata instead of weighted word automata. From the input graph G , which is assumed to be of tree-width at most k , we computein linear time a tree decomposition using Bodlaender’s algorithm [3]. Then, similarly toLemma 10, we compute in linear time a well-formed k - TT τ such that {∣ τ ∣} = ( G, ∅) . Inparticular, ∣ τ ∣ = O(∣ G ∣) . Using Lemma 17 below, from the WTS T we construct in polynomial time an equivalentweighted tree automaton B k on graphs of tree-width at most k : [[T ]]( G ) = [[B k ]]( τ ) . We compute [[B k ]]( τ ) with Algorithm 1. The main complexity comes from the call TreeEval . Executing the body of this function (without the recursive calls) takes time
O(∣B k ∣) . Hence, the overall time complexity of this evaluation is O(∣ τ ∣ ⋅ ∣B k ∣) . (cid:74) A weighted (binary) tree automaton over alphabet Σ is usually given as a tuple
B =(
Q, T, F, wgt ) where F ⊆ Q is the subset of accepting states, T ⊆ ({(cid:150)} ∪ Q ∪ Q ) × Σ × Q defines the bottom-up transitions and wgt ∶ T → S gives weights to transitions. This is anequivalent representation of a WTS over ({↗ , ↖} , Σ ) . (cid:73) Lemma 17.
Given a WTS T over ( Γ , Σ ) -graphs and k > , we can compute in polynomialtime wrt. T , a weighted tree automaton B k which is equivalent to T over graphs of tree-widthat most k . Here, equivalent means that for all well-formed k - TTs τ with {∣ τ ∣} = ( G, ∅) , wehave [[T ]]( G ) = [[B k ]]( τ ) . Proof.
Let
T = ( Q, ∆ , wgt ) be a WTS over ( Γ , Σ ) -graphs. By adding tiles with weight 0 S ,we may assume wlog that ∆ contains all possible tiles. Fix k ≥ B k is a partial map δ ∶ [ k ] → ∆. When reading a k - TT τ with {∣ τ ∣} = ( G, χ ) , theautomaton will guess a labelling ρ ∶ V → Q of vertices of G with states of T and will reach astate δ satisfying the following two conditions: dom ( δ ) = dom ( χ ) ⊆ [ k ] is the set of active colors, . Aiswarya and P. Gastin 17 Algorithm 1
Evaluation algorithm for a weighted tree automaton
B = (
Q, T, F, wgt ). function main ( τ ∶ term ): value from S ▷ Computes [[B]]( τ ) val ← TreeEval ( τ ) ; x ← S for all q ∈ F do x ← x + val [ q ] end for return x end function function TreeEval ( τ ∶ term ): array indexed by Q of values from S ▷ TreeEval ( τ )[ q ] is the sum of the weights of the runs of B on τ reaching state q . match τ with Leaf a : for all q ∈ Q do val [ q ] ← wgt ((cid:150) , a, q ) end for Unary a ( τ ) : val ← TreeEval ( τ ) for all q ∈ Q do val [ q ] ← S end for for all ( q , a, q ) ∈ T do val [ q ] ← val [ q ] + val [ q ] × wgt ( q , a, q ) end for Binary a ( τ , τ ) : val ← TreeEval ( τ ) ; val ← TreeEval ( τ ) for all q ∈ Q do val [ q ] ← S end for for all ( q , q , a, q ) ∈ T do val [ q ] ← val [ q ] + val [ q ] × wgt ( q , q , a, q ) × val [ q ] end for end match return val end function for each active color i ∈ dom ( χ ) , δ ( i ) = ( f in ( i ) , q ( i ) , a ( i ) , f out ( i )) = tile ρ ( χ ( i )) is thecurrent ρ -tile at vertex χ ( i ) in G .The only accepting state is the empty map δ ∅ with dom ( δ ∅ ) = ∅ , which is reached on a k - TT τ if all colors have been forgotten: {∣ τ ∣} = ( G, χ ∅ ) .The bottom-up transitions of the tree automaton B k are given in Table 2. As above, for i ∈ dom ( δ ) we write δ ( i ) = ( f in ( i ) , q ( i ) , a ( i ) , f out ( i )) and similarly for δ ′ and δ ′′ .The analysis of the number of states of B k is as in the proof of Lemma 14. We deducethat, if Σ , Γ , k are fixed, the automaton B k can be constructed in polynomial time wrt. thegiven WTS T . (cid:74) Connections with CSP.
The quantitative versions of the constraint satisfaction problem(CSP) are closely related to the evaluation problem for weighted tiling systems and graphs.Classic (boolean) CSPs ask for the existence of a solution of a set of constraints, as non-deterministic automata ask for the existence of an accepting run. In the valued -CSP (seee.g. [20]), weights (costs) are assigned to each constraint depending on how the constraint isfulfilled, these weights are summed over all constraints and the aim is to minimize this totalcost. This corresponds to our evaluation problem in the min-plus tropical semiring.The weighted counting CSP (weighted (+ , ×) -semiring such as N , Z , Q , . . . , (see e.g. [7, 8]). The cost of a solution is the product of the weights over all constraints and the value of the weighted Natural when functions in the languageonly take values 0 or 1, thus counting the number of solutions of the classic CSP.One of the main problems in CSP is to determine conditions under which the problemsare tractable (polynomial time). Feder and Vardi conjectured [16] that, depending on theconstraint language Γ, problems in CSP(Γ) are either in P or NP -complete. The dichotomyconjecture extends to FP or P -complete, see e.g. [6, 15]. In this paper, we show that for WTS, the evalution problem is P -complete (Theorem 7).Most often the non-uniform complexity is considered, meaning that the language (forus the WTS) is not part of the input and the complexity only depends on the instance (forus the input graph). One such structural restriction is when the constraint graph of theinstance has bounded tree-width. This is indeed related to our efficient evaluation describedin Section 4. Our approach is different though since we reduce WTS to weighted word/treeautomata and obtain a complexity linear in the input graph.As future work, we plan to investigate more closely the relationship between weighted On the generality of the model.
Even though our WTS is defined to run over boundeddegree graphs, we have seen (cf. Remark 1) that we can naturally model computationalproblems on arbitrary graphs that can be input as the adjacency matrix. The model of WGA[10] additionally has occurrence constraints (boolean combinations of constraints of the form tile ≥ n , where tile ∈ ∆ and n ∈ N ). A run is valid only if the occurrence constraints aresatisfied. We could allow these constraints as well, without compromising the complexityupper bounds. In fact, we can allow more expressive quantifier-free Presburger constraintson the tiles (e.g., tile + tile = tile ). The NP machine witnessing the upper boundscan compute the Parikh vector of the tiles used in a guessed run, and check in polynomialtime whether the constraints are satisfied. Variants.
The evaluation problem
Eval is a function problem. The decision variants cor-respond to threshold languages such as, is the computed weight {> , ≥ , < , ≤ , = , ≠} s , s being athreshold. There are further variants depending on whether the threshold s is part of theinput or is fixed. The complexity depend on the semiring as well as on the value of thethreshold when it is fixed. Conclusion.
We have given tight complexity bounds for the evaluation problem for varioussemirings. Our complexity upper bounds allows weights to be given in binary for problemsover (+ , ×) -semirings. However for tropical semirings the weights are assumed to be given inunary. While our upper bounds hold for arbitrary graphs, lower bounds are given uniformlyfor pictures (grid graphs). Further if we assume that the input graph does not have unboundedgrid as a minor (bounded tree-width), then we provide efficient evaluation algorithm. References C. Aiswarya, Paul Gastin, and K. Narayan Kumar. MSO decidability of multi-pushdownsystems via split-width. In
CONCUR , volume 7454 of
Lecture Notes in Computer Science ,pages 547–561. Springer, 2012. . Aiswarya and P. Gastin 19 C. Aiswarya, Paul Gastin, and K. Narayan Kumar. Verifying communicating multi-pushdownsystems via split-width. In (ATVA , volume 8837 of
Lecture Notes in Computer Science , pages1–17, Sidney, Australia, November 2014. Springer. doi:10.1007/978-3-319-11936-6_1 . Hans L. Bodlaender. A linear-time algorithm for finding tree-decompositions of small treewidth.
SIAM Journal on Computing , 25(6):1305–1317, Dec 1996. Benedikt Bollig and Paul Gastin. Non-sequential theory of distributed systems.
CoRR ,abs/1904.06942, 2019. URL: http://arxiv.org/abs/1904.06942 . Benedikt Bollig and Ingmar Meinecke. Weighted distributed systems and their logics. In
International Symposium on Logical Foundations of Computer Science, LFCS 2007 , volume4514 of
Lecture Notes in Computer Science , pages 54–68. Springer, 2007. Andrei A. Bulatov and Víctor Dalmau. Towards a dichotomy theorem for the countingconstraint satisfaction problem.
Inf. Comput. , 205(5):651–678, 2007. Andrei A. Bulatov, Martin E. Dyer, Leslie Ann Goldberg, Markus Jalsenius, Mark Jerrum,and David Richerby. The complexity of weighted and unweighted
J. Comput. Syst. Sci. ,78(2):681–688, 2012. Clément Carbonnel and Martin C. Cooper. Tractability in constraint satisfaction problems: asurvey.
Constraints An Int. J. , 21(2):115–144, 2016. Aiswarya Cyriac.
Verification of communicating recursive programs via split-width. (Vérificationde programmes récursifs et communicants via split-width) . PhD thesis, École normale supérieurede Cachan, France, 2014. URL: https://tel.archives-ouvertes.fr/tel-01015561 . Manfred Droste and Stefan Dück. Weighted automata and logics on graphs. In
MathematicalFoundations of Computer Science (MFCS’15) , volume 9234 of
Lecture Notes in ComputerScience , pages 192–204. Springer, 2015. Manfred Droste and Paul Gastin. The kleene-schützenberger theorem for formal power seriesin partially commuting variables.
Inf. Comput. , 153(1):47–80, 1999. Manfred Droste, Werner Kuich, and Heiko Vogler, editors.
Handbook of Weighted Automata .Springer Berlin Heidelberg, 2009. Manfred Droste, Christian Pech, and Heiko Vogler. A Kleene theorem for weighted treeautomata.
Theory Comput. Syst. , 38(1):1–38, 2005. Manfred Droste and Heiko Vogler. Weighted tree automata and weighted logics.
Theor.Comput. Sci. , 366(3):228–247, 2006. Martin E. Dyer, Leslie Ann Goldberg, and Mark Jerrum. The complexity of weighted boolean
SIAM J. Comput. , 38(5):1970–1986, 2009. Tomás Feder and Moshe Y. Vardi. The computational structure of monotone monadic SNPand constraint satisfaction: A study through datalog and group theory.
SIAM J. Comput. ,28(1):57–104, 1998. Ina Fichtner. Weighted picture automata and weighted logics.
Theory Comput. Syst. , 48(1):48–78, 2011. Paul Gastin and Benjamin Monmege. Adding pebbles to weighted automata: Easy specification& efficient evaluation.
Theoretical Computer Science , 534:24–44, May 2014. Mark W. Krentel. The complexity of optimization problems.
Journal of Computer and SystemSciences , 36(3):490 – 509, 1988. doi:https://doi.org/10.1016/0022-0000(88)90039-6 . Andrei A. Krokhin and Stanislav Zivny. The complexity of valued csps. In Andrei A.Krokhin and Stanislav Zivny, editors,
The Constraint Satisfaction Problem: Complexityand Approximability , volume 7 of
Dagstuhl Follow-Ups , pages 233–266. Schloss Dagstuhl -Leibniz-Zentrum für Informatik, 2017. P. Madhusudan and Gennaro Parlato. The tree width of auxiliary storage. In
POPL , pages283–294, 2011. P. Madhusudan and Gennaro Parlato. The tree width of auxiliary storage. In Thomas Balland Mooly Sagiv, editors,
Proceedings of the 38th ACM SIGPLAN-SIGACT Symposium onPrinciples of Programming Languages, POPL 2011, Austin, TX, USA, January 26-28, 2011 ,pages 283–294. ACM, 2011. Christian Mathissen. Weighted logics for nested words and algebraic formal power series.
Logical Methods in Computer Science , 6(1), Feb 2010. Ingmar Meinecke. Weighted logics for traces. In Dima Grigoriev, John Harrison, and Edward A.Hirsch, editors,
First International Computer Science Symposium in Russia, CSR 2006 , volume3967 of
Lecture Notes in Computer Science , pages 235–246. Springer, 2006. Wolfgang Thomas. On logics, tilings, and automata. In Javier Leach Albert, Burkhard Monien,and Mario Rodríguez Artalejo, editors,
Automata, Languages and Programming , pages 441–454,Berlin, Heidelberg, 1991. Springer Berlin Heidelberg. L.G. Valiant. The complexity of computing the permanent.
Theoretical Computer Science ,8(2):189 – 201, 1979. doi:https://doi.org/10.1016/0304-3975(79)90044-6doi:https://doi.org/10.1016/0304-3975(79)90044-6