Vaucanson  1.4.1
pair_to_fmp.hh
Go to the documentation of this file.
1 // pair_to_fmp.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2008 The Vaucanson Group.
6 //
7 // This program is free software; you can redistribute it and/or
8 // modify it under the terms of the GNU General Public License
9 // as published by the Free Software Foundation; either version 2
10 // of the License, or (at your option) any later version.
11 //
12 // The complete GNU General Public Licence Notice can be found as the
13 // `COPYING' file in the root directory.
14 //
15 // The Vaucanson Group consists of people listed in the `AUTHORS' file.
16 //
17 #ifndef VCSN_ALGORITHMS_PAIR_TO_FMP_HH
18 # define VCSN_ALGORITHMS_PAIR_TO_FMP_HH
19 
20 # include <map>
21 # include <utility>
22 
23 # include <vaucanson/automata/concept/automata.hh>
24 # include <vaucanson/algebra/concept/freemonoid_product.hh>
25 # include <vaucanson/algebra/implementation/alphabets/alphabet_set.hh>
26 # include <vaucanson/algebra/implementation/monoid/free_monoid.hh>
27 
28 // Needed for op_rout(fmp)
29 # include <vaucanson/algebra/implementation/monoid/pair_str_words.hh>
30 
44 // INTERFACE: void pair_to_fmp(const Automaton& a, PairToFMP& b) { return vcsn::pair_to_fmp(*a, *b); }
45 // INTERFACE: PairToFMP pair_to_fmp(const Automaton& a) { return vcsn::pair_to_fmp(*a); }
46 
47 namespace vcsn
48 {
51 
52 
53 
54 
55  // Helper to mute a pair automaton into its corresponding FMP transducer.
56  template <typename S, typename T>
57  struct mute_pair_to_fmp
58  {
59  // The automaton type.
60  typedef Element<S, T> automaton_t;
61 
62  // The monoid type.
63  typedef typename automaton_t::monoid_elt_t monoid_elt_t;
64 
65  // The alphabet type.
66  typedef typename monoid_elt_t::set_t::alphabet_t alphabet_t;
67 
68  // Alphabet traits.
69  typedef algebra::alphabet_traits<typename alphabet_t::set_t,
70  typename alphabet_t::value_t> alphabet_traits_t;
71 
72  // Word traits.
73  typedef algebra::word_traits<typename monoid_elt_t::set_t,
74  typename monoid_elt_t::value_t> word_traits_t;
75 
76  // The first computed monoid.
77  typedef typename word_traits_t::first_monoid_t first_monoid_t;
78 
79  // The second computed monoid.
80  typedef typename word_traits_t::second_monoid_t second_monoid_t;
81 
82  // The semiring type.
83  typedef typename automaton_t::semiring_t semiring_t;
84 
85  // The first alphabet type.
86  typedef typename first_monoid_t::alphabet_t ret_first_alphabet_t;
87 
88  // The second alphabet type.
89  typedef typename second_monoid_t::alphabet_t ret_second_alphabet_t;
90 
91  // The free monoid product type.
92 
93  // 1 - structure
94  typedef algebra::FreeMonoidProduct<first_monoid_t,
95  second_monoid_t> ret_monoid_t;
96 
97  // 2 - implementation
98  typedef std::pair<typename word_traits_t::first_projection_t::value_t,
99  typename word_traits_t::second_projection_t::value_t>
100  ret_word_impl_t;
101 
102  // 3 - element
103  typedef Element<ret_monoid_t, ret_word_impl_t> ret_monoid_elt_t;
104 
105  // The muted automaton type.
106 
107  // 1 - structure
108  typedef typename algebra::
109  mute_series_traits<typename automaton_t::series_set_t,
110  typename automaton_t::semiring_t,
111  ret_monoid_t>::ret
112  ret_series_set_t;
113  typedef Automata<ret_series_set_t, typename automaton_t::kind_t> ret_set_t;
114 
115  // 2 - implementation
116  typedef typename mute_graph_impl_monoid_traits<typename automaton_t::
117  value_t, ret_word_impl_t, undefined_type>::ret ret_impl_t;
118 
119  // 3 - element
120  typedef Element<ret_set_t, ret_impl_t> ret;
121 
122  // Automaton "makers".
123  static ret
124  make_automaton(const ret_first_alphabet_t&, const ret_second_alphabet_t&);
125 
126  static ret
127  make_automaton(const automaton_t&);
128 
129  // Series converter.
130  static typename ret::series_set_elt_t
131  series_convert(const ret_series_set_t&,
132  const typename automaton_t::series_set_elt_t&);
133  };
134 
135  template <typename S, typename T>
136  void
137  pair_to_fmp(const Element<S, T>& aut,
138  typename mute_pair_to_fmp<S, T>::ret& res);
139 
140  template <typename S, typename T>
141  typename mute_pair_to_fmp<S, T>::ret
142  pair_to_fmp(const Element<S, T>& aut);
143 
145 
148 } // ! vcsn
149 
150 # if !defined VCSN_USE_INTERFACE_ONLY && !defined VCSN_USE_LIB
151 # include <vaucanson/algorithms/pair_to_fmp.hxx>
152 # endif // ! VCSN_USE_INTERFACE_ONLY
153 
154 #endif // ! VCSN_ALGORITHMS_PAIR_TO_FMP_HH