17 #ifndef VCSN_ALGORITHMS_LTL_TO_PAIR_HXX
18 # define VCSN_ALGORITHMS_LTL_TO_PAIR_HXX
26 # define MUTE_TRAITS mute_ltl_to_pair<S, T>
28 template <
typename S,
typename T>
29 inline typename MUTE_TRAITS::ret_alphabet_t
31 cartesian_product(
const typename MUTE_TRAITS::first_alphabet_t& A,
32 const typename MUTE_TRAITS::second_alphabet_t& B)
36 for_all_const_(first_alphabet_t, i, A)
38 for_all_const_(second_alphabet_t, j, B)
40 E.insert(std::make_pair(*i, *j));
47 template <
typename S,
typename T>
48 inline typename MUTE_TRAITS::ret
50 make_automaton(
const Element<S, T>& A)
52 ret_alphabet_t E = cartesian_product(A.structure().series().monoid().
53 first_monoid().alphabet(),
54 A.structure().series().monoid().
55 second_monoid().alphabet());
57 return make_automaton(E);
60 template <
typename S,
typename T>
61 inline typename MUTE_TRAITS::ret::series_set_elt_t
63 series_convert(
const typename MUTE_TRAITS::ret_series_set_t& series,
64 const typename MUTE_TRAITS::automaton_t::
67 typename ret::series_set_elt_t R(series);
70 std::basic_string<ret_letter_t> m;
71 if (!(*(ss.supp().begin())).first.empty())
72 m += std::make_pair(((*(ss.supp().begin())).first)[0],
73 ((*(ss.supp().begin())).second)[0]);
74 R.assoc(m, ss.get(*(ss.supp().begin())));
79 template <
typename S,
typename T>
81 do_ltl_to_pair(
const Element<S, T>& src,
82 typename MUTE_TRAITS::ret& res)
84 BENCH_TASK_SCOPED(
"ltl_to_pair");
90 typedef typename MUTE_TRAITS::automaton_t automaton_t;
91 typedef MUTE_TRAITS pair_automaton_traits_t;
92 typedef typename pair_automaton_traits_t::ret res_t;
93 AUTOMATON_TYPES(automaton_t);
94 AUTOMATON_TYPES_(res_t, res_);
97 std::map<hstate_t, res_hstate_t> m;
99 for_all_const_states(p, src)
100 m[*p] = res.add_state();
103 for_all_const_initial_states(i, src)
105 res.set_initial(m[*i],
106 pair_automaton_traits_t::
107 series_convert(res.structure().series(),
108 src.get_initial(*i)));
112 for_all_const_transitions(e, src)
114 res.add_series_transition(m[src.src_of(*e)],
116 pair_automaton_traits_t::
117 series_convert(res.structure().series(),
122 for_all_const_final_states(f, src)
125 pair_automaton_traits_t::
126 series_convert(res.structure().series(),
135 template <
typename S,
typename T>
137 ltl_to_pair(
const Element<S, T>& ltl,
138 typename MUTE_TRAITS::ret& res)
140 do_ltl_to_pair(ltl, res);
143 template <
typename S,
typename T>
144 typename MUTE_TRAITS::ret
145 ltl_to_pair(
const Element<S, T>& ltl)
147 typename MUTE_TRAITS::ret res = MUTE_TRAITS::make_automaton(ltl);
149 do_ltl_to_pair(ltl, res);
158 #endif // ! VCSN_ALGORITHMS_LTL_TO_PAIR_HXX