Vcsn  2.1
Be Rational
is-functional.hh
Go to the documentation of this file.
1 #pragma once
2 
3 #include <vcsn/algos/compose.hh>
5 #include <vcsn/dyn/automaton.hh>
6 #include <vcsn/dyn/fwd.hh>
7 
8 namespace vcsn
9 {
10  /*---------------.
11  | is-functional. |
12  `---------------*/
13 
16  template <typename Aut>
17  bool is_functional(const Aut& aut)
18  {
19  // Compose aut and its invert.
20  auto l = focus<0>(aut);
21  auto r = insplit(l);
22  auto compose = detail::make_composer(l, r);
23  auto c = compose();
24  return is_partial_identity(c);
25  }
26 
27  namespace dyn
28  {
29  namespace detail
30  {
32  template <typename Aut>
33  bool is_functional(const automaton& aut)
34  {
35  return is_functional(aut->as<Aut>());
36  }
37  }
38  }
39 }
auto make_composer(Lhs &lhs, Rhs &rhs) -> typename detail::composer< Lhs, Rhs >
Definition: compose.hh:275
bool is_partial_identity(const Aut &aut)
Whether transducer aut is equivalent to a partial identity function on all successful paths...
bool is_functional(const Aut &aut)
Whether aut is functional.
bool is_functional(const automaton &aut)
Bridge.
Provide a variadic mul on top of a binary mul(), and one().
Definition: fwd.hh:46
std::shared_ptr< detail::automaton_base > automaton
Definition: automaton.hh:69
auto insplit(const Aut &aut) -> decltype(detail::insplit(aut))
Definition: insplit.hh:107
auto compose(Lhs &lhs, Rhs &rhs) -> typename detail::composer< focus_automaton< OutTape, Lhs >, focus_automaton< InTape, Rhs >>::automaton_t
Build the (accessible part of the) composition.
Definition: compose.hh:290