12 #include <vcsn/algos/fwd.hh>
28 template <Automaton Aut>
57 const std::string& algo =
"auto")
66 return proper_star_<weightset_t::star_status()>();
72 proper_star_here_<weightset_t::star_status()>();
89 {
"default",
"inplace"},
90 {
"distance", [](
const self_t& s) {
96 {
"inplace", [](
const self_t& s) {
97 auto a =
copy(s.aut_);
101 {
"separate", [](
const self_t& s) {
112 template <star_status_t Status>
113 std::enable_if_t<Status == star_status_t::ABSVAL, aut_proper_t>
120 template <star_status_t Status>
121 std::enable_if_t<Status == star_status_t::NON_STARRABLE, aut_proper_t>
128 template <star_status_t Status>
129 std::enable_if_t<Status == star_status_t::STARRABLE, aut_proper_t>
135 template <star_status_t Status>
136 std::enable_if_t<Status == star_status_t::TOPS, aut_proper_t>
143 catch (
const std::runtime_error&)
145 raise(
"proper: invalid automaton");
161 else if (
algo_ ==
"separate" ||
algo_ ==
"distance")
162 raise(
"proper: algorithm ",
algo_,
" cannot be used in place");
164 raise(
"proper: invalid algorithm: ",
algo_);
167 template <star_status_t Status>
168 std::enable_if_t<Status == star_status_t::ABSVAL>
175 template <star_status_t Status>
176 std::enable_if_t<Status == star_status_t::NON_STARRABLE>
183 template <star_status_t Status>
184 std::enable_if_t<Status == star_status_t::STARRABLE>
190 template <star_status_t Status>
191 std::enable_if_t<Status == star_status_t::TOPS>
198 catch (
const std::runtime_error&)
200 raise(
"proper: invalid automaton");
209 template <Automaton Aut>
212 const std::string& algo =
"auto")
218 catch(
const std::runtime_error& e)
220 raise(e,
" while making proper");
242 template <Automaton Aut>
245 bool prune =
true,
const std::string& algo =
"auto")
259 template <Automaton Aut>
266 "backward direction for lazy proper is not implemented");
267 return make_shared_ptr<lazy_proper_automaton<Aut>>(aut, prune);
277 template <Automaton Aut>
279 bool prune =
true,
const std::string& algo =
"auto")
298 template <Automaton Aut,
typename Dir,
typename Bool,
typename String>
300 const std::string& algo)
302 const auto& a = aut->
as<Aut>();
fresh_automaton_t_of< automaton_t, detail::proper_context< context_t_of< automaton_t >>> aut_proper_t
The result type.
aut_proper_t remover_() const
bool is_valid(const Aut &aut)
std::shared_ptr< detail::lazy_proper_automaton_impl< Aut >> lazy_proper_automaton
This class contains the core of the proper algorithm.
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::enable_if_t< Status==star_status_t::STARRABLE > proper_star_here_()
std::enable_if_t< Status==star_status_t::TOPS > proper_star_here_()
aut_proper_t operator()() const
Proper automata with proper context.
weightset_mixin< detail::r_impl > r
void require(Bool b, Args &&...args)
If b is not verified, raise an error with args as message.
Provide a variadic mul on top of a binary mul(), and one().
labelset_t_of< automaton_t > labelset_t
typename Aut::element_type::template fresh_automaton_t< Context > fresh_automaton_t_of
Given an automaton type, the type of its copies.
This class contains the core of the proper algorithm.
typename detail::labelset_t_of_impl< base_t< ValueSet >>::type labelset_t_of
bool prune_
Whether to prune states that become inaccessible.
std::enable_if_t< Status==star_status_t::TOPS, aut_proper_t > proper_star_() const
Spontaneous transition elimination.
weightset_t_of< automaton_t > weightset_t
std::enable_if_t< Status==star_status_t::NON_STARRABLE, aut_proper_t > proper_star_() const
auto proper_lazy(const Aut &aut, direction dir=direction::backward, bool prune=true) -> lazy_proper_automaton< Aut >
std::enable_if_t< Status==star_status_t::STARRABLE, aut_proper_t > proper_star_() const
#define BUILTIN_UNREACHABLE()
std::enable_if_t< Status==star_status_t::NON_STARRABLE > proper_star_here_()
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.
automaton proper(const automaton &aut, direction dir, bool prune, const std::string &algo)
Bridge.
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, aut_proper_t > proper_star_() const
typename detail::weightset_t_of_impl< base_t< ValueSet >>::type weightset_t_of
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 ...
A mapping from strings to Values.
auto make_properer(Aut aut, bool prune=true, const std::string &algo="auto")
void here()
In-place spontaneous transition removal.
auto & as()
Extract wrapped typed automaton.
bool prune_
Whether to prune states that become inaccessible.
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.
const std::string & algo_
std::remove_cv_t< Aut > automaton_t
bool prune_
Whether to prune states that become inaccessible.
Aut transpose(const transpose_automaton< Aut > &aut)
The transpose of a transpose automaton is the original automaton.
std::enable_if_t< Status==star_status_t::ABSVAL > proper_star_here_()