Vaucanson  1.4.1
ltl_to_pair.hh
Go to the documentation of this file.
1 // ltl_to_pair.hh: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2008, 2009 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_LTL_TO_PAIR_HH
18 # define VCSN_ALGORITHMS_LTL_TO_PAIR_HH
19 
20 # include <map>
21 # include <set>
22 # include <utility>
23 # include <string>
24 
25 # include <vaucanson/automata/concept/automata.hh>
26 # include <vaucanson/automata/concept/transducer.hh>
27 # include <vaucanson/algebra/concept/freemonoid_product.hh>
28 # include <vaucanson/algebra/implementation/alphabets/alphabet_set.hh>
29 # include <vaucanson/algebra/implementation/monoid/free_monoid.hh>
30 
31 // Needed for the operator<< on pairs
32 # include <vaucanson/algebra/implementation/letter/couple_letter.hh>
33 
47 // INTERFACE: void ltl_to_pair(const Automaton& a, LtlToPair& b) { return vcsn::ltl_to_pair(*a, *b); }
48 // INTERFACE: LtlToPair ltl_to_pair(const Automaton& a) { return vcsn::ltl_to_pair(*a); }
49 
50 namespace vcsn
51 {
54 
55 
56 
57 
58 
59  // Helper to mute an FMP into its corresponding pair automaton.
60  template <typename S, typename T>
61  struct mute_ltl_to_pair
62  {
63  // The automaton type.
64  typedef Element<S, T> automaton_t;
65 
66  // The free monoid product type.
67  typedef typename automaton_t::monoid_elt_t::set_t monoid_set_elt_t;
68 
69  // The semiring type.
70  typedef typename automaton_t::semiring_t semiring_t;
71 
72  // The first alphabet type.
73  typedef typename monoid_set_elt_t::
74  first_monoid_t::alphabet_t first_alphabet_t;
75 
76  // The second alphabet type.
77  typedef typename monoid_set_elt_t::
78  second_monoid_t::alphabet_t second_alphabet_t;
79 
80  // The first letter type.
81  typedef typename first_alphabet_t::set_t::letter_t first_letter_t;
82 
83  // The second letter type.
84  typedef typename second_alphabet_t::set_t::letter_t second_letter_t;
85 
86  // The return letter type.
87  typedef std::pair<first_letter_t, second_letter_t> ret_letter_t;
88 
89  // The return alphabet type.
90 
91  // 1 - structure
92  typedef typename algebra::AlphabetSet<ret_letter_t> ret_alphabet_set_t;
93 
94  // 2 - implementation
95  typedef std::set<ret_letter_t> ret_alphabet_impl_t;
96 
97  // 3 - element
98  typedef Element<ret_alphabet_set_t, ret_alphabet_impl_t>
99  ret_alphabet_t;
100 
101  typedef algebra::FreeMonoid<ret_alphabet_t> ret_monoid_t;
102 
103  typedef Element<ret_monoid_t, std::basic_string<ret_letter_t> >
104  ret_monoid_elt_t;
105 
106  // Helper to calculate the Cartesian product of two
107  // alphabets: E = {(a,x)| a \in A, x \in B}.
108  static ret_alphabet_t
109  cartesian_product(const first_alphabet_t& A,
110  const second_alphabet_t& B);
111 
112  // The muted automaton type.
113 
114  // 1 - structure
115  typedef typename algebra::
116  mute_series_traits<typename automaton_t::series_set_t,
117  typename automaton_t::semiring_t,
118  algebra::FreeMonoid<ret_alphabet_t> >::ret
119  ret_series_set_t;
120  typedef Automata<ret_series_set_t, typename automaton_t::kind_t> ret_set_t;
121 
122  // 2 - implementation
123  typedef typename mute_graph_impl_monoid_traits<typename automaton_t::
124  value_t, typename ret_monoid_elt_t::value_t, ret_letter_t>::ret
125  ret_impl_t;
126 
127  // 3 - element
128  typedef Element<ret_set_t, ret_impl_t> ret;
129 
130  // Automaton "makers".
131  static inline ret
132  make_automaton(const ret_alphabet_t& A)
133  {
134  semiring_t semiring;
135  ret_monoid_t freemonoid(A);
136  typename ret::series_set_t series(semiring, freemonoid);
137  return ret(Automata<typename ret::series_set_t, typename ret::kind_t>(series));
138  }
139 
140  static ret
141  make_automaton(const automaton_t&);
142 
143  // Series converter.
144  static typename ret::series_set_elt_t
145  series_convert(const ret_series_set_t&,
146  const typename automaton_t::series_set_elt_t&);
147  };
148 
149  template <typename S, typename T>
150  void
151  ltl_to_pair(const Element<S, T>& ltl,
152  typename mute_ltl_to_pair<S, T>::ret& res);
153 
154  template <typename S, typename T>
155  typename mute_ltl_to_pair<S, T>::ret
156  ltl_to_pair(const Element<S, T>& ltl);
157 
159 
162 } // ! vcsn
163 
164 # if !defined VCSN_USE_INTERFACE_ONLY && !defined VCSN_USE_LIB
165 # include <vaucanson/algorithms/ltl_to_pair.hxx>
166 # endif // ! VCSN_USE_INTERFACE_ONLY
167 
168 #endif // ! VCSN_ALGORITHMS_LTL_TO_PAIR_HH