Vaucanson  1.4.1
is_ltl.hxx
1 // is_ltl.hxx: this file is part of the Vaucanson project.
2 //
3 // Vaucanson, a generic library for finite state machines.
4 //
5 // Copyright (C) 2001, 2002, 2003, 2004, 2005, 2006, 2008, 2010 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_IS_LTL_HXX
18 # define VCSN_ALGORITHMS_IS_LTL_HXX
19 
21 
22 # include <vaucanson/misc/usual_macros.hh>
23 
24 # include <vaucanson/automata/concept/automata_base.hh>
25 # include <vaucanson/algebra/concept/freemonoid_product.hh>
26 
27 namespace vcsn
28 {
29  template<typename S, typename A, typename B, typename T>
30  bool
31  do_is_ltl(// t must be an automaton ...
32  const AutomataBase<S>&,
33  // ... over a free monoid product.
34  const algebra::FreeMonoidProduct<A, B>&,
35  const T& t)
36  {
37  BENCH_TASK_SCOPED("is_ltl");
38 
39  // Type helper.
40  AUTOMATON_TYPES(T);
41 
42  for_all_const_initial_states(i, t)
43  {
44  series_set_elt_t l = t.get_initial(*i);
45  if (l.supp().size() > 1)
46  return false;
47  // We assume that an initial transition cannot be labeled by
48  // the empty series. In other words, l.supp().size() >= 1.
49  assertion(l.supp().size() == 1);
50  monoid_elt_value_t m = *l.supp().begin();
51  if (m.first.size() > 0 || m.second.size() > 0)
52  return false;
53  }
54 
55  for_all_const_transitions(e, t)
56  {
57  series_set_elt_t label = t.series_of(*e);
58  for_all_const_(series_set_elt_t::support_t, it, label.supp())
59  {
60  if (((*it).first.size() != 1) || ((*it).second.size() != 1))
61  return false;
62  }
63  }
64 
65  for_all_const_final_states(f, t)
66  {
67  series_set_elt_t l = t.get_final(*f);
68  if (l.supp().size() > 1)
69  return false;
70  // We assume that an initial transition cannot be labeled by
71  // the empty series. In other words, l.supp().size() >= 1.
72  assertion(l.supp().size() == 1);
73  monoid_elt_value_t m = *l.supp().begin();
74  if (m.first.size() > 0 || m.second.size() > 0)
75  return false;
76  }
77 
78  return true;
79  }
80 
81  /*---------------.
82  | is_ltl facades |
83  `---------------*/
84 
85  template <typename S, typename A>
86  bool
88  {
89  return do_is_ltl(t.structure(),
90  t.structure().series().monoid(), t);
91  }
92 
93 } // ! vcsn
94 
95 #endif // ! VCSN_ALGORITHMS_IS_LTL_HXX