Vcsn  2.4
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 <Automaton Aut>
17  bool is_functional(const Aut& aut)
18  {
19  // Compose aut and its invert.
20  auto c = make_compose_automaton<false, 0, 0>(aut, aut);
21  c->compose();
22  return is_partial_identity(c);
23  }
24 
25  namespace dyn
26  {
27  namespace detail
28  {
30  template <Automaton Aut>
31  bool is_functional(const automaton& aut)
32  {
33  return is_functional(aut->as<Aut>());
34  }
35  }
36  }
37 }
bool is_functional(const Aut &aut)
Whether aut is functional.
bool is_functional(const automaton &aut)
Bridge.
Definition: a-star.hh:8
A dyn automaton.
Definition: automaton.hh:17
auto & as()
Extract wrapped typed automaton.
Definition: automaton.hh:37
bool is_partial_identity(const Aut &aut)
Whether transducer aut is equivalent to a partial identity function on all successful paths...