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")
234 template <Automaton Aut>
237 bool prune =
true,
const std::string& algo =
"auto")
251 template <Automaton Aut>
258 "backward direction for lazy proper is not implemented");
259 return make_shared_ptr<lazy_proper_automaton<Aut>>(aut, prune);
268 template <Automaton Aut>
271 bool prune =
true,
const std::string& algo =
"auto")
290 template <Automaton Aut,
typename Dir,
typename Bool,
typename String>
292 const std::string& algo)
294 const auto& a = aut->as<Aut>();
auto proper_lazy(const Aut &aut, direction dir=direction::backward, bool prune=true) -> lazy_proper_automaton< Aut >
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.
This class contains the core of the proper algorithm.
labelset_t_of< automaton_t > labelset_t
This class contains the core of the proper algorithm.
automaton proper(const automaton &aut, direction dir, bool prune, const std::string &algo)
Bridge.
std::enable_if_t< Status==star_status_t::TOPS, aut_proper_t > proper_star_() const
automaton make_automaton(const Aut &aut)
Build a dyn::automaton.
std::enable_if_t< Status==star_status_t::STARRABLE, aut_proper_t > proper_star_() const
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
std::enable_if_t< Status==star_status_t::STARRABLE > proper_star_here_()
std::enable_if_t< Status==star_status_t::NON_STARRABLE > proper_star_here_()
weightset_t_of< automaton_t > weightset_t
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
std::enable_if_t< Status==star_status_t::NON_STARRABLE, aut_proper_t > proper_star_() const
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
void here()
In-place spontaneous transition removal.
weightset_mixin< detail::r_impl > r
Provide a variadic mul on top of a binary mul(), and one().
aut_proper_t remover_() const
Aut transpose(const transpose_automaton< Aut > &aut)
#define BUILTIN_UNREACHABLE()
A mapping from strings to Values.
bool prune_
Whether to prune states that become inaccessible.
aut_proper_t operator()() const
Proper automata with proper context.
This class contains the core of the proper algorithm.
auto make_properer(Aut aut, bool prune=true, const std::string &algo="auto")
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::shared_ptr< detail::automaton_base > automaton
properer(automaton_t aut, bool prune=true, const std::string &algo="auto")
Remove the epsilon-transitions of the input.
bool prune_
Whether to prune states that become inaccessible.
void proper_here(Aut &aut, direction dir=direction::backward, bool prune=true, const std::string &algo="auto")
Eliminate spontaneous transitions in place.
const std::string & algo_
fresh_automaton_t_of< automaton_t, detail::proper_context< context_t_of< automaton_t >>> aut_proper_t
The result type.
std::enable_if_t< Status==star_status_t::TOPS > proper_star_here_()
std::remove_cv_t< Aut > automaton_t
Spontaneous transition elimination.
std::shared_ptr< detail::lazy_proper_automaton_impl< Aut >> lazy_proper_automaton
bool is_valid(const Aut &aut)
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.
bool prune_
Whether to prune states that become inaccessible.
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 ...
std::enable_if_t< Status==star_status_t::ABSVAL, aut_proper_t > proper_star_() const