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

automaton.eliminate_state(state=-1)

In the Brzozowski-McCluskey procedure, remove one state.

Preconditions:

  • The labelset is oneset (i.e., the automaton is spontaneous).

  • The weightset is expressionset (i.e., the weights are expressions).

  • The state is indeed a state of the automaton, or it is -1, in which case a heuristics is used to select the next state.

See also:

Examples

import vcsn

The following examples will use this automaton as input.

a0 = vcsn.B.expression('ab*c').standard() a0
Image in a Jupyter notebook

We first need to convert this automaton into a spontaneous automaton labeled with expressions. That's the purpose of automaton.lift.

a1 = a0.lift() a1
Image in a Jupyter notebook

Explicit state elimination

Let's remove state 2:

a2 = a1.eliminate_state(2) a2
Image in a Jupyter notebook

Note that the result is a fresh automaton: the original automaton is not modified:

a1
Image in a Jupyter notebook

Let's eliminate state 1.

a3 = a2.eliminate_state(1) a3
Image in a Jupyter notebook

We can also remove the initial and final states.

a4 = a3.eliminate_state(0) a4
Image in a Jupyter notebook

Eventually, when all the states have been removed, you get a broken automaton, with no states, but a "lone transition" that bears the answer.

a5 = a4.eliminate_state(1) a5
Image in a Jupyter notebook

Rest assured that such automata (no states but with one transition) never occur in the normal course of use of Vcsn.

Using the heuristics

Use -1 (or no argument at all) to leave the choice of the next state to eliminate to Vcsn. This is how automaton.expression works.

a1.eliminate_state()
Image in a Jupyter notebook
a1.eliminate_state().eliminate_state().eliminate_state().eliminate_state()
Image in a Jupyter notebook

Interactive Examples

You may use the following widgets to see, step by step, how state elimination works.

a2 = a1 ** 2 %demo a2 eliminate_state