spot  1.99.3
 All Classes Files Functions Variables Typedefs Enumerations Enumerator Friends Modules Pages
taexplicit.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2010, 2011, 2012, 2013, 2014 Laboratoire de Recherche
3 // et 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 #pragma once
21 
22 #include "misc/hash.hh"
23 #include <list>
24 #include "twa/twa.hh"
25 #include <set>
26 #include "ltlast/formula.hh"
27 #include <cassert>
28 #include "misc/bddlt.hh"
29 #include "ta.hh"
30 
31 namespace spot
32 {
33  // Forward declarations. See below.
34  class state_ta_explicit;
35  class ta_explicit_succ_iterator;
36  class ta_explicit;
37 
40  class SPOT_API ta_explicit : public ta
41  {
42  public:
43  ta_explicit(const const_twa_ptr& tgba,
44  unsigned n_acc,
45  state_ta_explicit* artificial_initial_state = 0);
46 
47  const_twa_ptr
48  get_tgba() const;
49 
51  add_state(state_ta_explicit* s);
52 
53  void
54  add_to_initial_states_set(state* s, bdd condition = bddfalse);
55 
56  void
57  create_transition(state_ta_explicit* source, bdd condition,
58  acc_cond::mark_t acceptance_conditions,
59  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_ptr
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 
119  private:
120  // Disallow copy.
121  ta_explicit(const ta_explicit& other) SPOT_DELETED;
122  ta_explicit& operator=(const ta_explicit& other) SPOT_DELETED;
123 
124  const_twa_ptr tgba_;
125  state_ta_explicit* artificial_initial_state_;
126  ta::states_set_t states_set_;
127  ta::states_set_t initial_states_set_;
128  };
129 
132  class SPOT_API state_ta_explicit : public spot::state
133  {
134 #ifndef SWIG
135  public:
136 
138  struct transition
139  {
140  bdd condition;
141  acc_cond::mark_t acceptance_conditions;
142  state_ta_explicit* dest;
143  };
144 
145  typedef std::list<transition*> transitions;
146 
147  state_ta_explicit(const state* tgba_state, const bdd tgba_condition,
148  bool is_initial_state = false, bool is_accepting_state = false,
149  bool is_livelock_accepting_state = false, transitions* trans = 0) :
150  tgba_state_(tgba_state), tgba_condition_(tgba_condition),
151  is_initial_state_(is_initial_state), is_accepting_state_(
152  is_accepting_state), is_livelock_accepting_state_(
153  is_livelock_accepting_state), transitions_(trans)
154  {
155  }
156 
157  virtual int
158  compare(const spot::state* other) const;
159  virtual size_t
160  hash() const;
161  virtual state_ta_explicit*
162  clone() const;
163 
164  virtual void
165  destroy() const
166  {
167  }
168 
169  virtual
171  {
172  }
173 
174  transitions*
175  get_transitions() const;
176 
177  // return transitions filtred by condition
178  transitions*
179  get_transitions(bdd condition) const;
180 
181  void
182  add_transition(transition* t, bool add_at_beginning = false);
183 
184  const state*
185  get_tgba_state() const;
186  const bdd
187  get_tgba_condition() const;
188  bool
189  is_accepting_state() const;
190  void
191  set_accepting_state(bool is_accepting_state);
192  bool
193  is_livelock_accepting_state() const;
194  void
195  set_livelock_accepting_state(bool is_livelock_accepting_state);
196 
197  bool
198  is_initial_state() const;
199  void
200  set_initial_state(bool is_initial_state);
201 
203  bool
204  is_hole_state() const;
205 
208  void
209  delete_stuttering_and_hole_successors();
210 
211  void
212  free_transitions();
213 
214  state_ta_explicit* stuttering_reachable_livelock;
215  private:
216  const state* tgba_state_;
217  const bdd tgba_condition_;
218  bool is_initial_state_;
219  bool is_accepting_state_;
220  bool is_livelock_accepting_state_;
221  transitions* transitions_;
222  std::unordered_map<int, transitions*, std::hash<int>>
223  transitions_by_condition;
224 #endif // !SWIG
225  };
226 
229  {
230  public:
232 
233  ta_explicit_succ_iterator(const state_ta_explicit* s, bdd condition);
234 
235  virtual bool first();
236  virtual bool next();
237  virtual bool done() const;
238 
239  virtual state*
240  current_state() const;
241  virtual bdd
242  current_condition() const;
243 
244  virtual acc_cond::mark_t
245  current_acceptance_conditions() const;
246 
247  private:
248  state_ta_explicit::transitions* transitions_;
249  state_ta_explicit::transitions::const_iterator i_;
250  };
251 
252  typedef std::shared_ptr<ta_explicit> ta_explicit_ptr;
253  typedef std::shared_ptr<const ta_explicit> const_ta_explicit_ptr;
254 
255  inline ta_explicit_ptr make_ta_explicit(const const_twa_ptr& tgba,
256  unsigned n_acc,
258  artificial_initial_state = 0)
259  {
260  return std::make_shared<ta_explicit>(tgba, n_acc, artificial_initial_state);
261  }
262 }
Definition: public.hh:31
Successor iterators used by spot::ta_explicit.
Definition: taexplicit.hh:228
spot::state * get_artificial_initial_state() const
Get the artificial initial state set of the automaton. Return 0 if this artificial state is not imple...
Definition: taexplicit.hh:98
LTL formula interface.
Abstract class for states.
Definition: twa.hh:40
Explicit transitions.
Definition: taexplicit.hh:138
Definition: taexplicit.hh:40
virtual void destroy() const
Release a state.
Definition: taexplicit.hh:165
Definition: taexplicit.hh:132
A Testing Automaton.
Definition: ta.hh:75
Iterate over the successors of a state.
Definition: ta.hh:196
Definition: acc.hh:34

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Wed Aug 26 2015 08:42:37 for spot by doxygen 1.8.8