Finite automata are widely used to model variety of systems working in discrete mode. One of active areas of research in a theory of finite automata is a synchronization problem, which can be understood as a problem of resetting a system to a chosen state, from any other state . For exhaustive survey of synchronization problem in automata theory see . A generalization of finite automata, where to every letter is attached a weight or a cost can be used to model a situation, in which different actions on system takes different amount of time. Such a modification of finite automata where studied for by number of authors, also in an aspect of synchronization, see for example , , ,, .
A weighted deterministic finite automaton (WFA) is an ordered tuple where is a finite set of states, is a finite alphabet, is a transition function and is a weight function. For and we define inductively as and for where is the empty word. We write instead of wherever it does not cause ambiguity. We define the weight of a word as a sum of weights of all letters in . By we denote the number of letters in . For a given WFA a word is called synchronizing if there exists such that for every , . A WFA is called synchronizing if it admits any synchronizing word. Let . We define and . All above definitions and notations also apply to deterministic finite automata (DFA) with constant cost function. Notice that problem of synchronization of a WFA is a generalization of synchronization for DFA. It becomes the problem of synchronization of DFA, if we define weights for all letters equal. Before moving further we make observation that follow from the classic results concerning theory of automata synchronization.
Let be a WFA. Then is synchronizing if and only if, for each there exist a word , such that .
Notice that problem of synchronization of a WFA is a generalization of synchronization for DFA. It becomes the problem of synchronization of DFA, if we define weights for all letters equal. It is not hard to find an example of a WFA, for which the shortest synchronizing word (with minimal number of letters) is not equal to the one with minimal weight. Example of such automaton is depicted on the figure below.
Let us define , , - it is easy to check, that although the shortest synchronizing word for is , the word with minimal weight is .
With all those definitions and observations we may now introduce a new, polynomial-time algorithm for approximating shortest synchronizing word in WFA.
We consider the following modification of our definition of WFA. Let be a (extended WFA) eWFA, where , and are as in WFA, but is a weight function which assigns weights to transitions rather than to letters. Let be a weight function. Let also and . We define . We also define the weight of synchronization of with a word as . Define the following decision problem:
E-WEIGHTED-SYNCHRO-WORD: Given an eWFA and a positive integer l, is it true that admits a synchronizing word such that ?
In 2012 Volkov et. al.  proved that E-WEIGHTED-SYNCHRO-WORD is NP-complete if is given in unary representation, however is PSPACE-complete, when is given in binary representation, because the shortest synchronizing words can be exponentially long in . We are going to discuss a similar problem but for WFA. Next, we give an algorithm which, for a given WFA, returns a weighted synchronizing word of weight , where is the maximum weight of a (single) letter, if such a word exists. Before moving forward we first discuss complexity issues of a problem of finding shortest synchronizing words in a WFA. Consider the following problem:
WEIGHTED-SYNCHRO-WORD: Given a WFA and a positive integer l, is it true that admits a synchronizing word such that ?
To prove that WEIGHTED-SYNCHRO-WORD is in NP it suffices to show that there exists a polynomial algorithm that verifies if an instance of the problem with , belongs to WEIGHTED-SYNCHRO-WORD. Namely we need to check if a given word , with synchronizes . To this end we check, if there exists a , such that for all we have that . It is obvious that we can do it in time and we claim the lemma holds. ∎
Notice that here we assumed, that was given in unary representation. Corollary of our further considerations is a fact, that if WFA is synchronizing, then it admits synchronizing word of weight at most polynomially long in a number of states and that proves, that WEIGHTED-SYNCHRO-WORD is in NP even if is given in binary representation. Recall the following theorem from .
Theorem 1 (Gawrychowski, Straszak).
For every constant , unless , no polynomial algorithm approximates shortest synchronizing word for a given DFA within a factor of .
Having that, we can construct a simple reduction from a problem of approximating shortest synchronizing word in DFA, to a problem of finding synchronizing word of minimal weight in WFA. Notice that the following theorem, together with Lemma 1 also implies -completeness of WEIGHTED-SYNCHRO-WORD. Let us state and prove the following theorem.
For every constant , unless , no polynomial algorithm approximates weighted synchronizing word for a given WFA with weights bounded by some constant , within a factor of .
Let be a DFA. We construct , such that , and are such as in , and for any , we define . Let us suppose that there exists an algorithm that approximates minimal weight of a synchronizing word for a bounded WFA. That would imply the existence of algorithm that approximates shortest synchronizing word in a given DFA, as follows. Algorithm constructs a WFA for a given DFA in a way described above (notice that this construction can be done in polynomial time), runs for and returns the word computed by . It can be easily seen that such a word would approximate shortest synchronizing word for within a factor of and that is a contradiction. ∎
Before proceeding, we introduce the following definition. With any WFA we associate another WFA, , where stands for the set of subsets of of cardinality at most , and are as in and the transition function is defined for and as follows: . Notice that for we obtain classic power automaton construction.
and then we prove their correctness and estimate their time complexity.
Now we are ready to introduce our algorithm. In the following we fix , define and . More detailed description of and is discussed further on. First we describe two procedures -COMPUTE-WORDS and -APPROXIMATE-WEIGHT-SYNCH
and then we prove their correctness and estimate their time complexity.
We can define and in a few ways. First let be a predicate and . Denote that choice of and as H1. Definition of and is motivated by the will to choose not necessarily the word with minimal possible weight in each iteration, but to balance between the weight and the ability of a word to reduce the cardinality of the set in each step. We propose also another three heuristics for choosing words
in each step. We propose also another three heuristics for choosing wordsin line 5 of Algorithm 2. Define in the same manner as in H1 and and denote this choice as H2. The reason for this definition is a possibility of finding words in , that may not be the shortest ones, but reduce more states in and therefore are a good choice. Next heuristic we propose is as follows: define and and denote this choice as H3. Here we model a greedy approach, known from the classic Eppstein’s heuristic algorithm for finding synchronizing words for a given DFA . The last variant, denoted as H4, is a modification of H2 above where we let be as in H2 and H1 and . Here we suppose that the ability of a word to send many states into one is more important than the weight . It is likely, that using H1, H2 or H3, the Algorithm 2 will take in first iteration, which can be not an optimal choice in numerous situations, for example Černý automata . Using we want to prevent this situation, by taking square in a denominator. For the sake of next proofs we define .
For each element returned by -COMPUTE-WORDS procedure we have and is a word with minimal weight having that property.
Consider procedure -COMPUTE-WORDS. In a for loop in line 4 we compute paths to all singletons in from all possible other states using the Dijkstra algorithm. After that loop every element in consists of a sequence of vertices from some state to a singleton. It is obvious that any such path corresponds to a word , such that , where is the first element of that path. Minimality of is immediate from the fact that contains paths with minimal weight and that concludes the proof. ∎
If is synchronizing then for each returned by -COMPUTE-WORDS procedure we have .
From Observation 1 we have that for any there exists a word , such that . Take the shortest with such property. Since is deterministic and is minimal, for each prefixes of , such that is a prefix of it holds, that and . That implies , since the weight of every letter is bounded by . Hence, we can construct a word , such that . On the other hand from Lemma 1 we have that and is minimal among all words with that property, so we have . ∎
If is synchronizing then for each , such that , there is exactly one element of having as the first coordinate.
Using similar argument as in the proof of Lemma 3, we can easily prove that there exists at least one such element in W. To prove that there is at most one such element, consider the if statement in line . It is obvious that after execution of that if, there can be at most one element with as the first coordinate in and that ends the proof. ∎
Procedure -APPROXIMATE-WEIGHT-SYNCH using H1,H2,H3 or H4 returns a weighted synchronizing word , such that if such a word exists.
Consider the while loop in -APPROXIMATE-WEIGHT-SYNCH procedure. At the start of that loop we have . In line 5 the algorithm chooses an element of , that ”reduces” the cardinality of . Notice that from Observation 1 such an element exists if is synchronizing and . If at any step of the while loop the algorithm cannot find an element that fulfills , we also can deduce from Observation 1 that there exists at least one pair that cannot be ”reduced” and by that there is no synchronizing word for that automaton. Notice that is . Also, any associated to in is of length , because any set on path from to a singleton can be visited at most once, and, since is deterministic, we know that for each prefix of we have that . So we know that -APPROXIMATE-WEIGHT-SYNCH in polynomial time decides if is synchronizing. Now we estimate the weight of returned by -APPROXIMATE-WEIGHT-SYNCH. Assume that is synchronizing. Denote by the pair chosen in -th step of while loop. Also denote , and for . If for any we have , we define and , for all . It is obvious that . On the other hand, from Lemma 3 for each we have that . So we have . Notice that for each , since it holds, that . Also . That implies and that concludes the proof. ∎
Procedure -APPROXIMATE-WEIGHT-SYNC using H1, H2, H3 or H4 works in time .
We first consider the procedure -COMPUTE-WORDS. Computing can be done in time . Notice that there are exactly singletons in , so the loop in line is executed exactly times. It is easy to see that the set of vertices of the underlying digraph of that automaton is of size and the edge set size is . If we use Dijkstra algorithm to compute shortest paths, we obtain time complexity of the for loop in line is . Now consider the for loop in line 6. We can implement Dijkstra algorithm to obtain words instead of paths, so line 7 does not affect the time complexity. Lines 9–12 can be executed in expected constant time using a dictionary, so the time complexity of the loop is . Joining it all together we obtain that the time complexity of -COMPUTE-WORDS procedure is . Now we estimate time complexity of -APPROXIMATE-WEIGHT-SYNC. COMPUTE-WORDS is executed once, and lines 2 and 3 have constant complexity. Consider the while loop. Notice, that at the end of the while block we have either or we return , so this loop is executed at most times. From earlier considerations and from Lemma 4 we obtain that the size of is , so choosing proper takes at most time. Lines 6, 7 and 8 are executed in constant time. Since and , we can compute in . From all that we have that -APPROXIMATE-WEIGHTED-SYNC works in time and that concludes this theorem. ∎
Another remark is that even for we obtain a weighted synchronizing word of weight . If we choose greater , we can shorten the intermediate words but at a cost of higher time complexity.
We also provide an example of an automaton (depicted below) that illustrates the difference between different heuristics. We define . Results of WEIGHTED-SYNCHRO-WORD for different values of and different heuristics are presented in a Table 1. They were obtained using author’s implementation of described algorithm, which can be found under this link https://colab.research.google.com/drive/14MmedWbN83KB-_t-rhaZwpexBaNBfQAa?usp=sharing.
The shortest synchronizing word for automaton is (19 letters, weight 79) and the word with minimal weight is (23 letters, weight 77). From the results in Table 1 we can deduce, that not always choosing higher does the job. Also, in this particular example heuristics H4 works the best for almost all values of we chose, except for , for which is the best choice.
-  Fominykh F., Volkov M. (2012) P(l)aying for Synchronization. In: Moreira N., Reis R. (eds) Implementation and Application of Automata. CIAA 2012. Lecture Notes in Computer Science, vol 7381. Springer, Berlin, Heidelberg.
-  Volkov M.V. (2008) Synchronizing Automata and the Černý Conjecture. In: Martín-Vide C., Otto F., Fernau H. (eds) Language and Automata Theory and Applications. LATA 2008. Lecture Notes in Computer Science, vol 5196. Springer, Berlin, Heidelberg.
-  Gawrychowski P., Straszak D. (2015) Strong Inapproximability of the Shortest Reset Word. In: Italiano G., Pighizzini G., Sannella D. (eds) Mathematical Foundations of Computer Science 2015. MFCS 2015. Lecture Notes in Computer Science, vol 9234. Springer, Berlin, Heidelberg.
-  Černý J.(1964). Poznámka k homogénnym eksperimentom s konečnými automatami. In: Mat.-Fyz. Cas. Slovens.Akad. Vied. 14, 208-216 (Slovak).
-  Eppstein, D. (1990). Reset Sequences for Monotonic Automata. SIAM J. Comput., 19, 500-510.
-  Doyen, L., Juhl, L., Larsen, K., Markey, N., Shirmohammadi, M. (2014). Synchronizing Words for Weighted and Timed Automata. In: FSTTCS.
-  Kretinsky, J., Larsen, K., Laursen, S., Srba, J. (2015). Polynomial time decidability of weighted synchronization under partial observability (Vol. 42, pp. 142–154). Presented at the CONCUR: Concurrency Theory, Madrid, Spain: Schloss Dagstuhl - Leibniz-Zentrum für Informatik.
-  Szabolcs, I. (2014). Synchronizing weighted automata. In: Proceedings 14th International Conference on Automata and Formal Languages (AFL 2014), Szeged, Hungary, May 27-29, 2014, Electronic Proceedings in Theoretical Computer Science 151, pp. 301–313
-  Mohri M. (2009) Weighted Automata Algorithms. In: Droste M., Kuich W., Vogler H. (eds) Handbook of Weighted Automata. Monographs in Theoretical Computer Science. An EATCS Series. Springer, Berlin, Heidelberg.