Contact
CoCalc Logo Icon
StoreFeaturesDocsShareSupport News AboutSign UpSign In
| Download
Views: 45899
Kernel: Python 3

automaton.push_weights

Push the weights towards in the initial states.

This algorithm uses a generalized shortest distance defined as: d[q]=πP(q,F)E(π)\begin{align*} d[q] = \bigoplus_{\pi \in P(q, F)} E(\pi) \end{align*}

Where P(q,F)P(q, F) is the set of paths from q to a final state, and E(π)E(\pi) is the weight of the path π\pi, i.e. the product of the weights of its transitions.

push_weights is defined for any acyclic automaton, since P(q,F)P(q, F) is finite for any state qq.

For cyclic automata, P(q,F)P(q, F) might be infinite, in which case push_weights is guaranteed to terminate and to be correct only if the sum converges in a finite number of steps. Examples of automata verifying this property include

  • automata with weights in B\mathbb{B}

  • automata with positive cycles and weights in Zmin\mathbb{Z}_\text{min}

Preconditions:

  • The weightset is zero-sum-free and weakly divisible

  • The shortest distance to the final state is defined for every state of the automaton

Postconditions:

  • The Result is equivalent to the input automaton

Examples

import vcsn

In a Tropical Semiring

The following example is taken from mohri.2009.hwa, Figure 12.

%%automaton --strip a context = "lal_char, zmin" $ -> 0 0 -> 1 <0>a, <1>b, <5>c 0 -> 2 <0>d, <1>e 1 -> 3 <0>e, <1>f 2 -> 3 <4>e, <5>f 3 -> $
Image in a Jupyter notebook
a.push_weights()
Image in a Jupyter notebook

Note that weight pushing improves the "minimizability" of weighted automata:

a.minimize()
Image in a Jupyter notebook
a.push_weights().minimize()
Image in a Jupyter notebook

In Q\mathbb{Q}

Again, the following example is taken from mohri.2009.hwa, Figure 12 (subfigure 12.d lacks two transitions), but computed in Q\mathbb{Q} rather than R\mathbb{R} to render more readable results.

%%automaton --strip a context = "lal_char, q" $ -> 0 0 -> 1 <0>a, <1>b, <5>c 0 -> 2 <0>d, <1>e 1 -> 3 <0>e, <1>f 2 -> 3 <4>e, <5>f 3 -> $
Image in a Jupyter notebook
a.push_weights()
Image in a Jupyter notebook