automaton.is_cycle_ambiguous

Whether the automaton is cycle ambiguous. It means that there exist a state $s$ and a label $x$ such that there is more than one cycle in $s$ labeled with $x$.

Preconditions:

  • the labelset is free.

Examples


In [1]:
import vcsn


:0: FutureWarning: IPython widgets are experimental and may change in the future.

In [2]:
a = vcsn.automaton('''digraph
{
  vcsn_context = "lal_char(ab), b"
  I0 -> 0
  0 -> F0
  0 -> 1 [label = "a"]
  0 -> 2 [label = "a"]
  1 -> 0 [label = "b"]
  2 -> 0 [label = "b"]
}''')
a


Out[2]:
%3 I0 0 0 I0->0 F0 0->F0 1 1 0->1 a 2 2 0->2 a 1->0 b 2->0 b

At state $0$, the automaton has two cycles "ab" so it is cycle ambiguous.


In [3]:
a.is_cycle_ambiguous()


Out[3]:
True

In [4]:
a = vcsn.automaton('''digraph
{
  vcsn_context = "lal_char(abc), b"
  I0 -> 0
  0 -> F0
  0 -> 1 [label = "a"]
  0 -> 2 [label = "a"]
  1 -> 0 [label = "b"]
  2 -> 0 [label = "c"]
}''')
a


Out[4]:
%3 I0 0 0 I0->0 F0 0->F0 1 1 0->1 a 2 2 0->2 a 1->0 b 2->0 c

At state $0$, the automaton has two cycles with different label "ab", "ac" so it is not cycle ambiguous (it is cycle-unambiguous).


In [5]:
a.is_cycle_ambiguous()


Out[5]:
False

In [6]:
a = vcsn.context("lal_char(abc), b").ladybird(3)
a


Out[6]:
%3 I0 0 0 I0->0 F0 0->F0 1 1 0->1 a 1->0 c 1->1 b, c 2 2 1->2 a 2->0 a, c 2->2 b, c

Two cycles in $0$ with label "acac".


In [7]:
a.is_cycle_ambiguous()


Out[7]:
True

In [8]:
a = vcsn.automaton('''digraph {
  vcsn_context = "lal_char(abc), b"
  I0 -> 0
  0 -> F0
  0 -> 1 [label = "a"]
  0 -> 2 [label = "a"]
  1 -> 0 [label = "b"]
  1 -> 3 [label = "b"]
  2 -> 1 [label = "c"]
  2 -> 2 [label = "b"]
  3 -> 1 [label = "c"]
}''')
a


Out[8]:
%3 I0 0 0 I0->0 F0 0->F0 1 1 0->1 a 2 2 0->2 a 1->0 b 3 3 1->3 b 2->1 c 2->2 b 3->1 c

Two cycles in $0$ with label "babc".


In [9]:
a.is_cycle_ambiguous()


Out[9]:
True

In [10]:
a = vcsn.automaton('''digraph {
  vcsn_context = "lal_char(ab), b"
  I0 -> 0
  0 -> F0
  1 -> 2 [label = "a"]
  1 -> 3 [label = "a"]
  2 -> 1 [label = "b"]
  3 -> 1 [label = "b"]
}''')
a


Out[10]:
%3 I0 0 0 I0->0 F0 0->F0 1 1 2 2 1->2 a 3 3 1->3 a 2->1 b 3->1 b

In [11]:
a.is_cycle_ambiguous()


Out[11]:
True