spot  1.99.7
taexplicit.hh
1 // -*- coding: utf-8 -*-
2 // Copyright (C) 2010, 2011, 2012, 2013, 2014, 2015 Laboratoire de
3 // Recherche 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 <spot/misc/hash.hh>
23 #include <list>
24 #include <spot/twa/twa.hh>
25 #include <set>
26 #include <spot/tl/formula.hh>
27 #include <cassert>
28 #include <spot/misc/bddlt.hh>
29 #include <spot/ta/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 = nullptr);
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  const 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(const 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) = delete;
122  ta_explicit& operator=(const ta_explicit& other) = delete;
123 
124  const_twa_ptr tgba_;
125  state_ta_explicit* artificial_initial_state_;
126  ta::states_set_t states_set_;
127  ta::const_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  const 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,
149  bool is_accepting_state = false,
150  bool is_livelock_accepting_state = false,
151  transitions* trans = nullptr) :
152  tgba_state_(tgba_state), tgba_condition_(tgba_condition),
153  is_initial_state_(is_initial_state), is_accepting_state_(
154  is_accepting_state), is_livelock_accepting_state_(
155  is_livelock_accepting_state), transitions_(trans)
156  {
157  }
158 
159  virtual int
160  compare(const spot::state* other) const;
161  virtual size_t
162  hash() const;
163  virtual state_ta_explicit*
164  clone() const;
165 
166  virtual void
167  destroy() const
168  {
169  }
170 
171  virtual
173  {
174  }
175 
176  transitions*
177  get_transitions() const;
178 
179  // return transitions filtred by condition
180  transitions*
181  get_transitions(bdd condition) const;
182 
183  void
184  add_transition(transition* t, bool add_at_beginning = false);
185 
186  const state*
187  get_tgba_state() const;
188  const bdd
189  get_tgba_condition() const;
190  bool
191  is_accepting_state() const;
192  void
193  set_accepting_state(bool is_accepting_state);
194  bool
195  is_livelock_accepting_state() const;
196  void
197  set_livelock_accepting_state(bool is_livelock_accepting_state);
198 
199  bool
200  is_initial_state() const;
201  void
202  set_initial_state(bool is_initial_state);
203 
205  bool
206  is_hole_state() const;
207 
210  void
211  delete_stuttering_and_hole_successors();
212 
213  void
214  free_transitions();
215 
216  state_ta_explicit* stuttering_reachable_livelock;
217  private:
218  const state* tgba_state_;
219  const bdd tgba_condition_;
220  bool is_initial_state_;
221  bool is_accepting_state_;
222  bool is_livelock_accepting_state_;
223  transitions* transitions_;
224  std::unordered_map<int, transitions*, std::hash<int>>
225  transitions_by_condition;
226 #endif // !SWIG
227  };
228 
231  {
232  public:
234 
235  ta_explicit_succ_iterator(const state_ta_explicit* s, bdd condition);
236 
237  virtual bool first();
238  virtual bool next();
239  virtual bool done() const;
240 
241  virtual const state* dst() const;
242  virtual bdd cond() const;
243 
244  virtual acc_cond::mark_t acc() const;
245 
246  private:
247  state_ta_explicit::transitions* transitions_;
248  state_ta_explicit::transitions::const_iterator i_;
249  };
250 
251  typedef std::shared_ptr<ta_explicit> ta_explicit_ptr;
252  typedef std::shared_ptr<const ta_explicit> const_ta_explicit_ptr;
253 
254  inline ta_explicit_ptr
255  make_ta_explicit(const const_twa_ptr& tgba,
256  unsigned n_acc,
257  state_ta_explicit* artificial_initial_state = nullptr)
258  {
259  return std::make_shared<ta_explicit>(tgba, n_acc, artificial_initial_state);
260  }
261 }
Definition: graph.hh:32
Successor iterators used by spot::ta_explicit.
Definition: taexplicit.hh:230
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/PSL formula interface.
Abstract class for states.
Definition: twa.hh:43
Explicit transitions.
Definition: taexplicit.hh:138
Definition: taexplicit.hh:40
virtual void destroy() const
Release a state.
Definition: taexplicit.hh:167
Definition: taexplicit.hh:132
A Testing Automaton.
Definition: ta.hh:75
Iterate over the successors of a state.
Definition: ta.hh:197
Definition: acc.hh:34

Please direct any question, comment, or bug report to the Spot mailing list at spot@lrde.epita.fr.
Generated on Fri Jan 15 2016 13:01:50 for spot by doxygen 1.8.9.1