1 #ifndef VCSN_ALGOS_IS_AMBIGUOUS_HH
2 # define VCSN_ALGOS_IS_AMBIGUOUS_HH
22 template <
typename Aut>
30 for (
const auto& o: prod->origins())
31 if (std::get<0>(o.second) != std::get<1>(o.second)
40 template <
typename Aut>
68 template <
typename Aut>
73 "automaton is unambiguous");
74 const auto& ls = *aut->labelset();
77 auto s = std::get<0>(witness);
78 for (
auto t:
path_bfs(aut, aut->pre(), s))
80 auto l = aut->label_of(t);
81 if (!ls.is_special(l))
82 res = ls.concat(res, l);
84 for (
auto t:
path_bfs(aut, s, aut->post()))
86 auto l = aut->label_of(t);
87 if (!ls.is_special(l))
88 res = ls.concat(res, l);
99 template <
typename Aut>
103 const auto& a = aut->as<Aut>();
120 template <
typename Aut>
124 const auto& coms =
scc(aut);
125 if (getenv(
"VCSN_DEBUG"))
127 std::cerr <<
"number states of automaton: " <<
128 aut->num_states() << std::endl;
129 std::cerr <<
"number components: " <<
130 coms.size() << std::endl;
134 if (coms.size() == 1)
136 for (
const auto &c : coms)
147 template <
typename Aut>
151 auto coms =
scc(prod);
152 const auto& origins = prod->origins();
163 auto p = origins.at(s);
164 if (std::get<0>(p) == std::get<1>(p))
180 template <
typename Aut>
184 const auto& a = aut->as<Aut>();
196 #endif // !VCSN_ALGOS_IS_AMBIGUOUS_HH
filter_automaton< Aut > coaccessible(const Aut &a)
bool is_ambiguous(const Aut &aut)
REGISTER_DECLARE(accessible,(const automaton &) -> automaton)
std::shared_ptr< detail::automaton_base > automaton
auto product(const Auts &...as) -> product_automaton< decltype(meet_automata(as...)), Auts...>
Build the (accessible part of the) product.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
Aut::element_type::automaton_nocv_t aut_of_component(const detail::component_t< Aut > &com, const Aut &aut)
Generate a subautomaton corresponding to an SCC.
std::vector< transition_t_of< Aut > > path_bfs(const Aut &aut, state_t_of< Aut > start, state_t_of< Aut > end)
A shortest path between two states.
labelset_t_of< Aut >::word_t ambiguous_word(const Aut &aut)
law_t< LabelSet > make_wordset(const LabelSet &ls)
The wordset of a labelset.
const detail::components_t< Aut > scc(const Aut &aut, SCC_ALGO algo=SCC_ALGO::TARJAN)
Find all strongly connected components of aut.
label ambiguous_word(const automaton &aut)
Bridge.
std::shared_ptr< const detail::label_base > label
bool is_cycle_ambiguous(const automaton &aut)
bool is_cycle_ambiguous(const Aut &aut)
Whether aut is cycle-ambiguous.
bool is_ambiguous(const automaton &aut)
Bridge.
states_t< Aut > coaccessible_states(const Aut &a)
typename detail::state_t_of_impl< base_t< ValueSet >>::type state_t_of
label make_label(const LabelSet &ls, const typename LabelSet::value_t &l)
bool is_cycle_ambiguous_scc(const Aut &aut)
Whether aut is cycle-ambiguous.
bool has(const std::map< Key, Value, Compare, Alloc > &s, const Key &e)
void require(bool b, Args &&...args)
If b is not verified, raise an error with args as message.