12 #include <vcsn/algos/fwd.hh>
28 template <Automaton Aut>
56 const std::string& algo =
"auto")
65 return proper_star_<weightset_t::star_status()>();
71 proper_star_here_<weightset_t::star_status()>();
88 {
"default",
"inplace"},
89 {
"distance", [](
const self_t& s) {
95 {
"inplace", [](
const self_t& s) {
96 auto a =
copy(s.aut_);
100 {
"separate", [](
const self_t& s) {
111 template <star_status_t Status>
112 std::enable_if_t<Status == star_status_t::ABSVAL, aut_proper_t>
119 template <star_status_t Status>
120 std::enable_if_t<Status == star_status_t::NON_STARRABLE, aut_proper_t>
127 template <star_status_t Status>
128 std::enable_if_t<Status == star_status_t::STARRABLE, aut_proper_t>
134 template <star_status_t Status>
135 std::enable_if_t<Status == star_status_t::TOPS, aut_proper_t>
142 catch (
const std::runtime_error&)
144 raise(
"proper: invalid automaton");
160 else if (
algo_ ==
"separate" ||
algo_ ==
"distance")
161 raise(
"proper: algorithm ",
algo_,
" cannot be used in place");
163 raise(
"proper: invalid algorithm: ",
algo_);
166 template <star_status_t Status>
167 std::enable_if_t<Status == star_status_t::ABSVAL>
174 template <star_status_t Status>
175 std::enable_if_t<Status == star_status_t::NON_STARRABLE>
182 template <star_status_t Status>
183 std::enable_if_t<Status == star_status_t::STARRABLE>
189 template <star_status_t Status>
190 std::enable_if_t<Status == star_status_t::TOPS>
197 catch (
const std::runtime_error&)
199 raise(
"proper: invalid automaton");
208 template <Automaton Aut>
211 const std::string& algo =
"auto")
217 catch(
const std::runtime_error& e)
219 raise(e,
" while making proper");
241 template <Automaton Aut>
244 bool prune =
true,
const std::string& algo =
"auto")
258 template <Automaton Aut>
265 "backward direction for lazy proper is not implemented");
266 return make_shared_ptr<lazy_proper_automaton<Aut>>(aut, prune);
275 template <Automaton Aut>
277 bool prune =
true,
const std::string& algo =
"auto")
296 template <Automaton Aut,
typename Dir,
typename Bool,
typename String>
298 const std::string& algo)
300 const auto& a = aut->
as<Aut>();
std::enable_if_t< Status==star_status_t::STARRABLE, aut_proper_t > proper_star_() const
bool prune_
Whether to prune states that become inaccessible.
std::enable_if_t< Status==star_status_t::NON_STARRABLE > proper_star_here_()
weightset_t_of< automaton_t > weightset_t
Aut transpose(const transpose_automaton< Aut > &aut)
#define BUILTIN_UNREACHABLE()
auto proper(const Aut &aut, direction dir=direction::backward, bool prune=true, const std::string &algo="auto") -> fresh_automaton_t_of< Aut, detail::proper_context< context_t_of< Aut >>>
Eliminate spontaneous transitions.
std::shared_ptr< detail::lazy_proper_automaton_impl< Aut >> lazy_proper_automaton
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
This class contains the core of the proper algorithm.
std::enable_if_t< Status==star_status_t::ABSVAL, aut_proper_t > proper_star_() const
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
automaton proper(const automaton &aut, direction dir, bool prune, const std::string &algo)
Bridge.
bool prune_
Whether to prune states that become inaccessible.
auto proper_lazy(const Aut &aut, direction dir=direction::backward, bool prune=true) -> lazy_proper_automaton< Aut >
void here()
In-place spontaneous transition removal.
properer(automaton_t aut, bool prune=true, const std::string &algo="auto")
Remove the epsilon-transitions of the input.
This class contains the core of the proper algorithm.
auto copy(const AutIn &input, KeepState keep_state, KeepTrans keep_trans) -> decltype(keep_state(input->null_state()), keep_trans(input->null_transition()), make_fresh_automaton< AutIn, AutOut >(input))
A copy of input keeping only its states that are accepted by keep_state, and transitions accepted by ...
const std::string & algo_
std::remove_cv_t< Aut > automaton_t
void proper_here(Aut &aut, direction dir=direction::backward, bool prune=true, const std::string &algo="auto")
Eliminate spontaneous transitions in place.
std::enable_if_t< Status==star_status_t::ABSVAL > proper_star_here_()
typename Aut::element_type::template fresh_automaton_t< Context > fresh_automaton_t_of
Given an automaton type, the type of its copies.
std::enable_if_t< Status==star_status_t::STARRABLE > proper_star_here_()
fresh_automaton_t_of< automaton_t, detail::proper_context< context_t_of< automaton_t >>> aut_proper_t
The result type.
auto map(const std::tuple< Ts... > &ts, Fun f) -> decltype(map_tuple_(f, ts, make_index_sequence< sizeof...(Ts)>()))
Map a function on a tuple, return tuple of the results.
bool is_valid(const Aut &aut)
Spontaneous transition elimination.
bool prune_
Whether to prune states that become inaccessible.
aut_proper_t remover_() const
auto make_properer(Aut aut, bool prune=true, const std::string &algo="auto")
This class contains the core of the proper algorithm.
labelset_t_of< automaton_t > labelset_t
std::enable_if_t< Status==star_status_t::TOPS, aut_proper_t > proper_star_() const
std::enable_if_t< Status==star_status_t::TOPS > proper_star_here_()
aut_proper_t operator()() const
Proper automata with proper context.
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
auto & as()
Extract wrapped typed automaton.
A mapping from strings to Values.
Provide a variadic mul on top of a binary mul(), and one().
std::enable_if_t< Status==star_status_t::NON_STARRABLE, aut_proper_t > proper_star_() const
weightset_mixin< detail::r_impl > r