automaton
.is_equivalent
(aut
)
Whether this automaton is equivalent to aut
, i.e., whether they accept the same words with the same weights.
Preconditions:
The join of the weightsets is either , or a field ().
Algorithm:
for Boolean automata, check whether
is_useless(difference(a1.realtime(), a2.realtime())
and conversely.otherwise, check whether
is_empty(reduce(union(a1.realtime(), -1 * a2.realtime()))
.
See also:
Examples
Automata with different languages are not equivalent.
Automata that computes different weights are not equivalent.
The types of the automata need not be equal for the automata to be equivalent. In the following example the automaton types are
Boolean automata
Of course the different means to compute automata from rational expressions (thompson
, standard
, derived_term
...) result in different, but equivalent, automata.
Labelsets need not to be free. For instance, one can compare the Thompson automaton (which features spontaneous transitions) with the standard automaton:
Of course useless states "do not count" in checking equivalence.
Weighted automata
In the case of weighted automata, the algorithms checks whether , so the preconditions of automaton.reduce
apply.
In particular, beware that for numerical inaccuracy (with ) or overflows (with or ) may result in incorrect results. Using is safe.