spot  1.2.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
taexplicit.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2010, 2011, 2012, 2013 Laboratoire de Recherche et
3 // Développement de l'Epita (LRDE).
4 //
5 // This file is part of Spot, a model checking library.
6 //
7 // Spot is free software; you can redistribute it and/or modify it
8 // under the terms of the GNU General Public License as published by
9 // the Free Software Foundation; either version 3 of the License, or
10 // (at your option) any later version.
11 //
12 // Spot is distributed in the hope that it will be useful, but WITHOUT
13 // ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
14 // or FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public
15 // License for more details.
16 //
17 // You should have received a copy of the GNU General Public License
18 // along with this program. If not, see <http://www.gnu.org/licenses/>.
19 
20 #ifndef SPOT_TA_TAEXPLICIT_HH
21 # define SPOT_TA_TAEXPLICIT_HH
22 
23 #include "misc/hash.hh"
24 #include <list>
25 #include "tgba/tgba.hh"
26 #include <set>
27 #include "ltlast/formula.hh"
28 #include <cassert>
29 #include "misc/bddlt.hh"
30 #include "ta.hh"
31 
32 namespace spot
33 {
34  // Forward declarations. See below.
35  class state_ta_explicit;
36  class ta_explicit_succ_iterator;
37  class ta_explicit;
38 
41  class SPOT_API ta_explicit : public ta
42  {
43  public:
44  ta_explicit(const tgba* tgba, bdd all_acceptance_conditions,
45  state_ta_explicit* artificial_initial_state = 0,
46  bool own_tgba = false);
47 
48  const tgba*
49  get_tgba() const;
50 
52  add_state(state_ta_explicit* s);
53 
54  void
55  add_to_initial_states_set(state* s, bdd condition = bddfalse);
56 
57  void
58  create_transition(state_ta_explicit* source, bdd condition,
59  bdd acceptance_conditions, state_ta_explicit* dest,
60  bool add_at_beginning = false);
61 
62  void
63  delete_stuttering_transitions();
64  // ta interface
65  virtual
66  ~ta_explicit();
67  virtual const states_set_t
68  get_initial_states_set() const;
69 
70  virtual ta_succ_iterator*
71  succ_iter(const spot::state* s) const;
72 
73  virtual ta_succ_iterator*
74  succ_iter(const spot::state* s, bdd condition) const;
75 
76  virtual bdd_dict*
77  get_dict() const;
78 
79  virtual std::string
80  format_state(const spot::state* s) const;
81 
82  virtual bool
83  is_accepting_state(const spot::state* s) const;
84 
85  virtual bool
86  is_livelock_accepting_state(const spot::state* s) const;
87 
88  virtual bool
89  is_initial_state(const spot::state* s) const;
90 
91  virtual bdd
92  get_state_condition(const spot::state* s) const;
93 
94  virtual void
95  free_state(const spot::state* s) const;
96 
99  {
100  return (spot::state*) artificial_initial_state_;
101  }
102 
103  void
104  set_artificial_initial_state(state_ta_explicit* s)
105  {
106  artificial_initial_state_ = s;
107 
108  }
109 
110  virtual void
111  delete_stuttering_and_hole_successors(spot::state* s);
112 
113  ta::states_set_t
114  get_states_set()
115  {
116  return states_set_;
117  }
118 
127  bdd
129  {
130  return all_acceptance_conditions_;
131  }
132 
133  private:
134  // Disallow copy.
135  ta_explicit(const ta_explicit& other);
136  ta_explicit&
137  operator=(const ta_explicit& other);
138 
139  const tgba* tgba_;
140  bdd all_acceptance_conditions_;
141  state_ta_explicit* artificial_initial_state_;
142  ta::states_set_t states_set_;
143  ta::states_set_t initial_states_set_;
144  bool own_tgba_;
145  };
146 
149  class SPOT_API state_ta_explicit : public spot::state
150  {
151 #ifndef SWIG
152  public:
153 
155  struct transition
156  {
157  bdd condition;
158  bdd acceptance_conditions;
159  state_ta_explicit* dest;
160  };
161 
162  typedef std::list<transition*> transitions;
163 
164  state_ta_explicit(const state* tgba_state, const bdd tgba_condition,
165  bool is_initial_state = false, bool is_accepting_state = false,
166  bool is_livelock_accepting_state = false, transitions* trans = 0) :
167  tgba_state_(tgba_state), tgba_condition_(tgba_condition),
168  is_initial_state_(is_initial_state), is_accepting_state_(
169  is_accepting_state), is_livelock_accepting_state_(
170  is_livelock_accepting_state), transitions_(trans)
171  {
172  }
173 
174  virtual int
175  compare(const spot::state* other) const;
176  virtual size_t
177  hash() const;
178  virtual state_ta_explicit*
179  clone() const;
180 
181  virtual void
182  destroy() const
183  {
184  }
185 
186  virtual
188  {
189  }
190 
191  transitions*
192  get_transitions() const;
193 
194  // return transitions filtred by condition
195  transitions*
196  get_transitions(bdd condition) const;
197 
198  void
199  add_transition(transition* t, bool add_at_beginning = false);
200 
201  const state*
202  get_tgba_state() const;
203  const bdd
204  get_tgba_condition() const;
205  bool
206  is_accepting_state() const;
207  void
208  set_accepting_state(bool is_accepting_state);
209  bool
210  is_livelock_accepting_state() const;
211  void
212  set_livelock_accepting_state(bool is_livelock_accepting_state);
213 
214  bool
215  is_initial_state() const;
216  void
217  set_initial_state(bool is_initial_state);
218 
220  bool
221  is_hole_state() const;
222 
225  void
226  delete_stuttering_and_hole_successors();
227 
228  void
229  free_transitions();
230 
231  state_ta_explicit* stuttering_reachable_livelock;
232  private:
233  const state* tgba_state_;
234  const bdd tgba_condition_;
235  bool is_initial_state_;
236  bool is_accepting_state_;
237  bool is_livelock_accepting_state_;
238  transitions* transitions_;
239  Sgi::hash_map<int, transitions*, Sgi::hash<int> > transitions_by_condition;
240 #endif // !SWIG
241  };
242 
245  {
246  public:
248 
249  ta_explicit_succ_iterator(const state_ta_explicit* s, bdd condition);
250 
251  virtual void
252  first();
253  virtual void
254  next();
255  virtual bool
256  done() const;
257 
258  virtual state*
259  current_state() const;
260  virtual bdd
261  current_condition() const;
262 
263  virtual bdd
264  current_acceptance_conditions() const;
265 
266  private:
267  state_ta_explicit::transitions* transitions_;
268  state_ta_explicit::transitions::const_iterator i_;
269  };
270 
271 }
272 
273 #endif // SPOT_TA_TAEXPLICIT_HH

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Sat Dec 6 2014 12:28:44 for spot by doxygen 1.8.4