The definition of a weighted automaton is generally given over an arbitrary semiring, an abstract set with an addition operation and a multiplication operation . The automaton consists of a finite set of states, a finite input alphabet of characters and edges which are labeled with both a character in and a weight in . The weight of any path in the automaton is defined to be the product of weights along the path, and the weight of a string is the sum of the weights of all paths which are labeled with that string. The weighted automaton thus defines a function from to .[2]
is a finite set of transitions , where is called a character and is called a weight.
is an initial weight function.
is a final weight function.
A path on input is a finite path in the graph, where the concatenation of the character labels equals . The weight of the path is the product () of the weights along the path, additionally multiplied by the initial and final weights . The weight of the word is the sum () of the weights of all paths on input (or 0 if there are no accepting paths). In this way the machine defines a function .
Ambiguity and determinism
Since is a set of transitions, weighted automata allow multiple transitions (or paths) on a single input string.
Therefore a weighted automaton can be considered analogous to a nondeterministic finite automaton (NFA).
As is the case with NFAs, restrictions of weighted automata are considered that correspond to the concepts of deterministic finite automaton and unambiguous finite automaton (deterministic weighted automata and unambiguous weighted automata, respectively).
First, a preliminary definition: the underlying NFA of is an NFA formed by removing all transitions with weight and then erasing all of the weights on the transitions , so that the new transition set lies in . The initial states and final states are the set of states such that and , respectively.
A weighted automaton is deterministic if the underlying NFA is deterministic and unambiguous if the underlying NFA is unambiguous.
Every deterministic weighted automaton is unambiguous.
In both the deterministic and unambiguous cases, there is always at most one accepting path, so the operation is never applied and can be omitted from the definition.
Variations
The requirement that there is a zero element for is sometimes omitted; in this case the machine defines a partial function from to rather than a total function.
It is possible to extend the definition to allow epsilon transitions, where is the empty string. In this case, one must then require that there are no cycles of epsilon transitions. This does not increase the expressiveness of weighted automata.[2][10] If epsilon transitions are allowed, the initial weights and final weights can be replaced by initial and final sets of states without loss of expressiveness.
Some authors omit the initial and final weight functions and .[1] Instead, and are replaced by a set of initial and final states. If epsilon transitions are not present, this technically decreases expressiveness as it forces to depend only on the number of states that are both initial and final.
The transition function can be given as a matrix with entries in for each , rather than a set of transitions. The entry of the matrix at is the sum of all transitions labeled .[2][11]
Some authors restrict to specific semirings, such as or , particularly when studying decidability results.[1][9][4]